@mxtommy/kip 4.8.2 → 4.8.4
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/CHANGELOG.md +5 -0
- package/package.json +27 -4
- package/public/{chunk-BIYHVfJl.js → chunk-07zHjmg-.js} +1 -1
- package/public/{chunk-NnB8OYZt.js → chunk-0z3nIRXw.js} +1 -1
- package/public/{chunk-CCiqU2uY.js → chunk-B09jfNia.js} +1 -1
- package/public/{chunk-Bq-eHuZV.js → chunk-B0D54iJs.js} +1 -1
- package/public/{chunk-DfGLo6Tb.js → chunk-B0eE4udE.js} +1 -1
- package/public/{chunk-CkfPr-c5.js → chunk-B9nVBlGj.js} +1 -1
- package/public/{chunk-B8zRhoG8.js → chunk-BFpzxIIT.js} +1 -1
- package/public/{chunk-D_wrJJxl.js → chunk-BIb-xYiS.js} +1 -1
- package/public/{chunk-CSpA60X7.js → chunk-BJ-wyixK.js} +1 -1
- package/public/{chunk-Bb1mO304.js → chunk-BLEZOsfR.js} +1 -1
- package/public/{chunk-7lulvsGI.js → chunk-BN7A4g6c.js} +1 -1
- package/public/{chunk-h2q_pbbF.js → chunk-BTOTKeBo.js} +1 -1
- package/public/{chunk-DjavLLpP.js → chunk-BUguZ7cK.js} +1 -1
- package/public/{chunk-B8gfh4xf.js → chunk-BZx964-p.js} +1 -1
- package/public/{chunk-CcvYOops.js → chunk-BeM64etA.js} +1 -1
- package/public/{chunk-DSvdWjO4.js → chunk-BfiyH3nV.js} +1 -1
- package/public/{chunk-B_PiPxb4.js → chunk-BjINKQ03.js} +1 -1
- package/public/{chunk-BdBWqZzL.js → chunk-BpcNrtxJ.js} +1 -1
- package/public/{chunk-C4FGoLDg.js → chunk-BuvyF0y5.js} +1 -1
- package/public/{chunk-DGOvRnAo.js → chunk-C6b8CVno.js} +1 -1
- package/public/{chunk-BgyxBAyq.js → chunk-CCfhzpE8.js} +1 -1
- package/public/{chunk-CoEM_FqS.js → chunk-CHAFm_nM.js} +1 -1
- package/public/{chunk-D0MyVrEL.js → chunk-CIGP2YJm.js} +1 -1
- package/public/{chunk-Bhah8DNM.js → chunk-CLTHuhlN.js} +1 -1
- package/public/{chunk-B6XxnPxk.js → chunk-CLs_NL1y.js} +1 -1
- package/public/{chunk-Cr34s2uQ.js → chunk-COI6IBXH.js} +1 -1
- package/public/{chunk-BxV0O2fU.js → chunk-CQMVIDcp.js} +1 -1
- package/public/{chunk-CHKQxw6E.js → chunk-CXvWM_vF.js} +1 -1
- package/public/{chunk-Di5pPpU7.js → chunk-CYYBxjrc.js} +1 -1
- package/public/{chunk-BW4m3O2L.js → chunk-C_OZJltF.js} +1 -1
- package/public/{chunk-CjsnWLUr.js → chunk-Co2wVrD6.js} +1 -1
- package/public/{chunk-DMhuBqKs.js → chunk-CoCQ3DW2.js} +1 -1
- package/public/{chunk-DMoEBcor.js → chunk-CxPx4NZv.js} +1 -1
- package/public/{chunk-CdSWuWKr.js → chunk-CyVRpGoJ.js} +1 -1
- package/public/{chunk-Dv77RFHm.js → chunk-D-_-GUVr.js} +1 -1
- package/public/{chunk-CU8RPnsi.js → chunk-D1HYfaL_.js} +1 -1
- package/public/{chunk-DBA0eRqb.js → chunk-D2953Rfp.js} +1 -1
- package/public/{chunk-Cu9FE8cB.js → chunk-DIl1k00y.js} +1 -1
- package/public/{chunk-CyURmwWh.js → chunk-DPnbM-aB.js} +1 -1
- package/public/{chunk-8hkXyEzG.js → chunk-DTN-sa1K.js} +1 -1
- package/public/{chunk-C3CwUYvD.js → chunk-DUEKoZhd.js} +1 -1
- package/public/{chunk-COMZv7NY.js → chunk-DmkAKXR1.js} +1 -1
- package/public/{chunk-zg7II0hz.js → chunk-Do8wqING.js} +1 -1
- package/public/{chunk-oPq9Nexl.js → chunk-JhFkJS7i.js} +1 -1
- package/public/{chunk-CJIxuzvd.js → chunk-OeQDZKFO.js} +1 -1
- package/public/{chunk-Bz9bswDl.js → chunk-_zRMMvCu.js} +1 -1
- package/public/{chunk-D-xDPCf7.js → chunk-eQ1pa34Q.js} +1 -1
- package/public/{chunk-DVB9tiW3.js → chunk-ibauGmSP.js} +1 -1
- package/public/{chunk-oZiyAw_P.js → chunk-otzyItXL.js} +1 -1
- package/public/{chunk-B6AwCAvV.js → chunk-q9NoPvcx.js} +1 -1
- package/public/{chunk-B15lj2T8.js → chunk-szQs8fiq.js} +1 -1
- package/public/{chunk-o977r5_s.js → chunk-x7L6DXVK.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-BNR44HGB.js → main-YKDNK5VZ.js} +4 -4
- package/plugin/history-series.service.js +0 -637
- package/plugin/index.js +0 -1322
- package/plugin/kip-series-contract.js +0 -31
- package/plugin/openApi.json +0 -855
- package/plugin/sqlite-history-storage.service.js +0 -1124
- package/plugin/src/history-series.service.js +0 -634
- package/plugin/src/index.js +0 -1322
- package/plugin/src/kip-series-contract.js +0 -31
- package/plugin/src/openApi.json +0 -855
- package/plugin/src/sqlite-history-storage.service.js +0 -1122
|
@@ -1 +1 @@
|
|
|
1
|
-
import {C,e as e$1}from'./chunk-CyURmwWh.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';var re=["inverterSvg"];function ie(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No inverters detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K inverter paths or select inverters in widget settings."),ul()());}function ne(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=class c$1{static INVERTER_DESCRIPTOR=a("widget-inverter");static SELF_ROOT_PATH=(()=>{let e=c$1.INVERTER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetInverterComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${ne(c$1.SELF_ROOT_PATH)}\\.([^.]+)\\.(.+)$`);static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,inverter:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("inverterSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredInverterIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["dcVoltage","dcCurrent","acVoltage","acFrequency"]});invertersByKey=vt({});visibleInverterKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(i=>i.key);let r=this.invertersByKey(),t=new Set(this.discoveredInverterIds());return Object.keys(r).filter(i=>{let o=r[i];return !!o&&t.has(o.id)}).sort((i,o)=>i.localeCompare(o))});visibleInverters=Dt(()=>{let e=this.visibleInverterKeys(),r=this.invertersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasInverters=Dt(()=>this.visibleInverters().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleInverters();return e.length!==1?"Inverters":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleInverters(),r=this.theme(),t=this.widgetColors(),i=this.ignoreZones(),o=new Map;e$1.forEach(n=>o.set(n.id,(o.get(n.id)??0)+1));let d=new Set([...o.entries()].filter(([,n])=>n>1).map(([n])=>n)),s={};for(let n of e$1){let l=n.deviceKey??n.id,a=!!n.source&&d.has(n.id),h=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null,n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null,n.temperatureState??null,n.inverterModeState??null),M=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null),b=this.resolveMostSevereState(n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null),[u,x]=this.buildMetricRows(n);s[l]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":n.inverterMode?`Mode ${n.inverterMode}`:"Mode -",busText:this.isCompactCardMode()?"":a?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:u,metricsLineTwo:x,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",r,i),titleTextColor:e(h,"var(--kip-contrast-color)",r,i),metaTextColor:e(n.inverterModeState??null,"var(--kip-contrast-dim-color)",r,i),primaryMetricsTextColor:e(M,"var(--kip-contrast-color)",r,i),secondaryMetricsTextColor:e(b,"var(--kip-contrast-color)",r,i)};}return s});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleInverters(),o=this.widgetColors();!this.svg||!o||this.requestRender({inverters:i,displayModels:t,widgetColors:o});});let e=[this.data.subscribePathTreeWithInitial(c$1.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>this.enqueuePathUpdate(i));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${c$1.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Inverter View"),this.layer=this.svg.append("g").attr("class","inverter-layer");}applyConfig(e){let r=this.resolveInverterConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById),this.cardMode.set(this.normalizeCardMode(r.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let i=r.get(t.id)??[];i.push(t.key),r.set(t.id,i);}),this.invertersByKey.update(t=>{let i=t,o=false;return r.forEach((d,s)=>{let n=t[s];if(n){for(let l of d){if(t[l])continue;let a=e.find(h=>h.key===l);o||(i=G({},t),o=true),i[l]=z(G({},n),{source:a?.source??null,deviceKey:l});}o&&i[s]?.deviceKey===void 0&&delete i[s];}}),o?i:t});}resolveInverterConfig(e){let r=e.inverter;return {trackedDevices:this.normalizeTrackedDevices(r?.trackedDevices),optionsById:this.normalizeOptionsById(r?.optionsById),cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,o=this.normalizeOptionalString(i.id),d=this.normalizeOptionalString(i.source);if(!o||!d)return;let s=this.normalizeOptionalString(i.key)??`${o}||${d}`;r.set(s,{id:o,source:d,key:s});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["dcVoltage","dcCurrent","acVoltage","acFrequency"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let i=t.trim();i.length>0&&r.add(i);}),[...r].sort((t,i)=>t.localeCompare(i))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r={};return Object.entries(e).forEach(([t])=>{let i=this.normalizeOptionalString(t);i&&(r[i]={});}),r}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,o=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:i,state:o}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},c$1.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(c$1.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(i=>i.id)).forEach(i=>this.trackDiscoveredInverter(i));let t=this.buildIdToDeviceKeysMap();this.invertersByKey.update(i=>{let o=i,d=false;for(let s of e){let n=t.get(s.id),l=n?.length?n:[s.id];for(let a of l){let h=!!n?.length,M=h?this.trackedDevices().find(I=>I.key===a):null,b=o[a]??{id:s.id,source:M?.source??null,deviceKey:h?a:void 0},u=G({},b);if(this.applyValue(u,s.key,s.value,s.state)){if(u.dcVoltage!=null&&u.dcCurrent!=null){let I=u.dcVoltage*u.dcCurrent;u.dcPower=Number.isFinite(I)?I:null,u.dcPowerState=this.resolveMostSevereState(u.dcVoltageState??null,u.dcCurrentState??null);}else u.dcPower=null,u.dcPowerState=null;d||(o=G({},o),d=true),o[a]=u;}}}return d?o:i});}trackDiscoveredInverter(e){let r=this.discoveredInverterIds();r.includes(e)||this.discoveredInverterIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "dc.voltage":return this.setMetricValue(e,"dcVoltage","dcVoltageState",this.toNumber(t,"V"),i);case "dc.current":return this.setMetricValue(e,"dcCurrent","dcCurrentState",this.toNumber(t,"A"),i);case "acin.voltage":return this.setMetricValue(e,"acInVoltage","acInVoltageState",this.toNumber(t,"V"),i);case "acin.current":return this.setMetricValue(e,"acInCurrent","acInCurrentState",this.toNumber(t,"A"),i);case "acin.frequency":return this.setMetricValue(e,"acInFrequency","acInFrequencyState",this.toNumber(t,"Hz"),i);case "acin.power":return this.setMetricValue(e,"acInPower","acInPowerState",this.toNumber(t,"W"),i);case "acin.1.currentLimit":return this.setMetricValue(e,"acIn1CurrentLimit","acIn1CurrentLimitState",this.toNumber(t,"A"),i);case "acin.currentLimit":return this.setMetricValue(e,"acInCurrentLimit","acInCurrentLimitState",this.toNumber(t,"A"),i);case "acState.acIn1Available":return this.setMetricValue(e,"acIn1Available","acIn1AvailableState",this.toBoolean(t),i);case "acState.ignoreAcIn1.state":return this.setMetricValue(e,"ignoreAcIn1","ignoreAcIn1State",this.toBoolean(t),i);case "ac.voltage":return this.setMetricValue(e,"acVoltage","acVoltageState",this.toNumber(t,"V"),i);case "ac.current":return this.setMetricValue(e,"acCurrent","acCurrentState",this.toNumber(t,"A"),i);case "ac.frequency":return this.setMetricValue(e,"acFrequency","acFrequencyState",this.toNumber(t,"Hz"),i);case "acout.voltage":return this.setMetricValue(e,"acOutVoltage","acOutVoltageState",this.toNumber(t,"V"),i);case "acout.current":return this.setMetricValue(e,"acOutCurrent","acOutCurrentState",this.toNumber(t,"A"),i);case "acout.frequency":return this.setMetricValue(e,"acOutFrequency","acOutFrequencyState",this.toNumber(t,"Hz"),i);case "acout.power":return this.setMetricValue(e,"acOutPower","acOutPowerState",this.toNumber(t,"W"),i);case "inverterMode":return this.setMetricValue(e,"inverterMode","inverterModeState",this.toStringValue(t),i);case "inverterModeNumber":return this.setMetricValue(e,"inverterModeNumber","inverterModeNumberState",this.toNumber(t,""),i);case "preferRenewableEnergy":return this.setMetricValue(e,"preferRenewableEnergy","preferRenewableEnergyState",this.toBoolean(t),i);case "preferRenewableEnergyActive":return this.setMetricValue(e,"preferRenewableEnergyActive","preferRenewableEnergyActiveState",this.toBoolean(t),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,o){let d=!Object.is(e[r],i),s=!Object.is(e[t],o);return !d&&!s?false:(e[r]=i,e[t]=o,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{inverters:this.visibleInverters(),displayModels:this.displayModels(),widgetColors:r},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e$1,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,o=e.inverters.map((a,h)=>({key:a.deviceKey??a.id,inverter:a,y:h*(i+c$1.CARD_GAP)})),d=o.length?o[o.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${d}`);let s=this.layer.selectAll("g.inverter-card").data(o,a=>a.key),n=s.enter().append("g").attr("class","inverter-card");n.append("rect").attr("class","inverter-card-bg"),n.append("rect").attr("class","inverter-state-bar"),n.append("text").attr("class","inverter-title"),n.append("text").attr("class","inverter-id"),n.append("text").attr("class","inverter-mode"),n.append("text").attr("class","inverter-bus"),n.append("text").attr("class","inverter-metrics-1"),n.append("text").attr("class","inverter-metrics-2");let l=n.merge(s);l.attr("transform",a=>`translate(0, ${a.y})`),l.select("rect.inverter-card-bg").attr("x",.5).attr("y",.5).attr("rx",t.cardCornerRadius).attr("ry",t.cardCornerRadius).attr("width",c$1.VIEWBOX_WIDTH-1).attr("height",i-1).attr("stroke","var(--mat-sys-outline-variant)").attr("stroke-width",.5).attr("fill","none"),l.select("rect.inverter-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",i-3).attr("fill",a=>e.displayModels[a.key]?.stateBarColor??e.widgetColors.dim),e.inverters.length>1?l.select("text.inverter-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",a=>e.displayModels[a.key]?.titleTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.titleText??this.resolveTitleText(a.inverter)):l.select("text.inverter-title").text(""),l.select("text.inverter-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(a=>a.inverter.id),l.select("text.inverter-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.modeText??""),l.select("text.inverter-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.busText??""),l.select("text.inverter-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",a=>e.displayModels[a.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineOne??""),l.select("text.inverter-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",a=>e.displayModels[a.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineTwo??""),s.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Inverter ${e.id}`}buildMetricRows(e){let r=this.cardMode();if(this.activeDisplayMode()==="full"){let i=e.acInVoltage!=null||e.acInCurrent!=null,o=this.formatValue(e.acInVoltage,"V"),d=this.formatValue(e.acInCurrent,"A"),s=this.formatValue(e.acOutVoltage??e.acVoltage,"V"),n=this.formatValue(e.acOutFrequency??e.acFrequency,"Hz");return [`DC ${this.formatValue(e.dcVoltage,"V")} ${this.formatValue(e.dcCurrent,"A")}`,i?`ACin ${o} ${d}`:`AC ${s} ${n}`]}let t=r.metrics.map(i=>this.toMetricLabel(i,e)).filter(i=>!!i);return t.length?[t.slice(0,2).join(" ")||" ",t.slice(2,4).join(" ")||" "]:["DC - -","AC - -"]}toMetricLabel(e,r){switch(e){case "dcVoltage":return `DC V ${this.formatValue(r.dcVoltage,"V")}`;case "dcCurrent":return `DC A ${this.formatValue(r.dcCurrent,"A")}`;case "dcPower":return `DC P ${this.formatValue(r.dcPower,"W")}`;case "acVoltage":return `AC V ${this.formatValue(r.acVoltage,"V")}`;case "acCurrent":return `AC A ${this.formatValue(r.acCurrent,"A")}`;case "acFrequency":return `Hz ${this.formatValue(r.acFrequency,"Hz")}`;case "acInVoltage":return `ACin V ${this.formatValue(r.acInVoltage,"V")}`;case "acInCurrent":return `ACin A ${this.formatValue(r.acInCurrent,"A")}`;case "acInFrequency":return `ACin Hz ${this.formatValue(r.acInFrequency,"Hz")}`;case "acInPower":return `ACin P ${this.formatValue(r.acInPower,"W")}`;case "acOutVoltage":return `ACout V ${this.formatValue(r.acOutVoltage,"V")}`;case "acOutCurrent":return `ACout A ${this.formatValue(r.acOutCurrent,"A")}`;case "acOutFrequency":return `ACout Hz ${this.formatValue(r.acOutFrequency,"Hz")}`;case "acOutPower":return `ACout P ${this.formatValue(r.acOutPower,"W")}`;case "acIn1CurrentLimit":return `ACin1 Lim ${this.formatValue(r.acIn1CurrentLimit,"A")}`;case "acInCurrentLimit":return `ACin Lim ${this.formatValue(r.acInCurrentLimit,"A")}`;case "temperature":return `T ${this.formatTemperature(r.temperature)}`;case "inverterModeNumber":return `Mode# ${r.inverterModeNumber?.toString()??"-"}`;default:return null}}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${r}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return typeof i=="number"&&Number.isFinite(i)?i:null}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return true;if(e===0)return false}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="on")return true;if(r==="false"||r==="0"||r==="off")return false}return null}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-inverter"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,re,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["inverterSvg",""],[3,"text","color"],["aria-hidden","false",1,"inverter-svg"],[1,"inverter-empty"],[1,"inverter-empty-title"],[1,"inverter-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,ie,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasInverters()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.inverter-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.inverter-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.inverter-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.inverter-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Z as WidgetInverterComponent};
|
|
1
|
+
import {C,e as e$1}from'./chunk-DPnbM-aB.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,$ as $j,v as vt,D as Dt,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,dx as n$1,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-YKDNK5VZ.js';import {c,e}from'./chunk-BIb-xYiS.js';var re=["inverterSvg"];function ie(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No inverters detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K inverter paths or select inverters in widget settings."),ul()());}function ne(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=class c$1{static INVERTER_DESCRIPTOR=a("widget-inverter");static SELF_ROOT_PATH=(()=>{let e=c$1.INVERTER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetInverterComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${ne(c$1.SELF_ROOT_PATH)}\\.([^.]+)\\.(.+)$`);static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static COMPACT_CARD_HEIGHT=100;static CARD_GAP=8;static PATH_BATCH_WINDOW_MS=500;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,inverter:{trackedDevices:[],optionsById:{}}};id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);svgRef=$j.required("inverterSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredInverterIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["dcVoltage","dcCurrent","acVoltage","acFrequency"]});invertersByKey=vt({});visibleInverterKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(i=>i.key);let r=this.invertersByKey(),t=new Set(this.discoveredInverterIds());return Object.keys(r).filter(i=>{let o=r[i];return !!o&&t.has(o.id)}).sort((i,o)=>i.localeCompare(o))});visibleInverters=Dt(()=>{let e=this.visibleInverterKeys(),r=this.invertersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasInverters=Dt(()=>this.visibleInverters().length>0);activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleInverters();return e.length!==1?"Inverters":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleInverters(),r=this.theme(),t=this.widgetColors(),i=this.ignoreZones(),o=new Map;e$1.forEach(n=>o.set(n.id,(o.get(n.id)??0)+1));let d=new Set([...o.entries()].filter(([,n])=>n>1).map(([n])=>n)),s={};for(let n of e$1){let l=n.deviceKey??n.id,a=!!n.source&&d.has(n.id),h=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null,n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null,n.temperatureState??null,n.inverterModeState??null),M=this.resolveMostSevereState(n.dcVoltageState??null,n.dcCurrentState??null),b=this.resolveMostSevereState(n.acVoltageState??null,n.acCurrentState??null,n.acFrequencyState??null),[u,x]=this.buildMetricRows(n);s[l]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":n.inverterMode?`Mode ${n.inverterMode}`:"Mode -",busText:this.isCompactCardMode()?"":a?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:u,metricsLineTwo:x,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",r,i),titleTextColor:e(h,"var(--kip-contrast-color)",r,i),metaTextColor:e(n.inverterModeState??null,"var(--kip-contrast-dim-color)",r,i),primaryMetricsTextColor:e(M,"var(--kip-contrast-color)",r,i),secondaryMetricsTextColor:e(b,"var(--kip-contrast-color)",r,i)};}return s});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleInverters(),o=this.widgetColors();!this.svg||!o||this.requestRender({inverters:i,displayModels:t,widgetColors:o});});let e=[this.data.subscribePathTreeWithInitial(c$1.ROOT_PATTERN)],r=false;for(let t of e)if(t.initial.length){r=true;for(let i of t.initial)this.enqueuePathUpdate(i,true);}r&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(i=>this.enqueuePathUpdate(i));}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${c$1.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Inverter View"),this.layer=this.svg.append("g").attr("class","inverter-layer");}applyConfig(e){let r=this.resolveInverterConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById),this.cardMode.set(this.normalizeCardMode(r.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let i=r.get(t.id)??[];i.push(t.key),r.set(t.id,i);}),this.invertersByKey.update(t=>{let i=t,o=false;return r.forEach((d,s)=>{let n=t[s];if(n){for(let l of d){if(t[l])continue;let a=e.find(h=>h.key===l);o||(i=G({},t),o=true),i[l]=z(G({},n),{source:a?.source??null,deviceKey:l});}o&&i[s]?.deviceKey===void 0&&delete i[s];}}),o?i:t});}resolveInverterConfig(e){let r=e.inverter;return {trackedDevices:this.normalizeTrackedDevices(r?.trackedDevices),optionsById:this.normalizeOptionsById(r?.optionsById),cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,o=this.normalizeOptionalString(i.id),d=this.normalizeOptionalString(i.source);if(!o||!d)return;let s=this.normalizeOptionalString(i.key)??`${o}||${d}`;r.set(s,{id:o,source:d,key:s});}),[...r.values()].sort((t,i)=>t.key.localeCompare(i.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(r=>{let t=e.get(r.id)??[];t.push(r.key),e.set(r.id,t);}),e}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["dcVoltage","dcCurrent","acVoltage","acFrequency"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let i=t.trim();i.length>0&&r.add(i);}),[...r].sort((t,i)=>t.localeCompare(i))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r={};return Object.entries(e).forEach(([t])=>{let i=this.normalizeOptionalString(t);i&&(r[i]={});}),r}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parsePath(e.path);if(!t)return;let i=e.update?.data?.value??null,o=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:i,state:o}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},c$1.PATH_BATCH_WINDOW_MS));}}parsePath(e){let r=e.match(c$1.PATH_REGEX);return r?{id:r[1],key:r[2]}:null}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(i=>i.id)).forEach(i=>this.trackDiscoveredInverter(i));let t=this.buildIdToDeviceKeysMap();this.invertersByKey.update(i=>{let o=i,d=false;for(let s of e){let n=t.get(s.id),l=n?.length?n:[s.id];for(let a of l){let h=!!n?.length,M=h?this.trackedDevices().find(I=>I.key===a):null,b=o[a]??{id:s.id,source:M?.source??null,deviceKey:h?a:void 0},u=G({},b);if(this.applyValue(u,s.key,s.value,s.state)){if(u.dcVoltage!=null&&u.dcCurrent!=null){let I=u.dcVoltage*u.dcCurrent;u.dcPower=Number.isFinite(I)?I:null,u.dcPowerState=this.resolveMostSevereState(u.dcVoltageState??null,u.dcCurrentState??null);}else u.dcPower=null,u.dcPowerState=null;d||(o=G({},o),d=true),o[a]=u;}}}return d?o:i});}trackDiscoveredInverter(e){let r=this.discoveredInverterIds();r.includes(e)||this.discoveredInverterIds.set([...r,e].sort((t,i)=>t.localeCompare(i)));}applyValue(e,r,t,i){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "dc.voltage":return this.setMetricValue(e,"dcVoltage","dcVoltageState",this.toNumber(t,"V"),i);case "dc.current":return this.setMetricValue(e,"dcCurrent","dcCurrentState",this.toNumber(t,"A"),i);case "acin.voltage":return this.setMetricValue(e,"acInVoltage","acInVoltageState",this.toNumber(t,"V"),i);case "acin.current":return this.setMetricValue(e,"acInCurrent","acInCurrentState",this.toNumber(t,"A"),i);case "acin.frequency":return this.setMetricValue(e,"acInFrequency","acInFrequencyState",this.toNumber(t,"Hz"),i);case "acin.power":return this.setMetricValue(e,"acInPower","acInPowerState",this.toNumber(t,"W"),i);case "acin.1.currentLimit":return this.setMetricValue(e,"acIn1CurrentLimit","acIn1CurrentLimitState",this.toNumber(t,"A"),i);case "acin.currentLimit":return this.setMetricValue(e,"acInCurrentLimit","acInCurrentLimitState",this.toNumber(t,"A"),i);case "acState.acIn1Available":return this.setMetricValue(e,"acIn1Available","acIn1AvailableState",this.toBoolean(t),i);case "acState.ignoreAcIn1.state":return this.setMetricValue(e,"ignoreAcIn1","ignoreAcIn1State",this.toBoolean(t),i);case "ac.voltage":return this.setMetricValue(e,"acVoltage","acVoltageState",this.toNumber(t,"V"),i);case "ac.current":return this.setMetricValue(e,"acCurrent","acCurrentState",this.toNumber(t,"A"),i);case "ac.frequency":return this.setMetricValue(e,"acFrequency","acFrequencyState",this.toNumber(t,"Hz"),i);case "acout.voltage":return this.setMetricValue(e,"acOutVoltage","acOutVoltageState",this.toNumber(t,"V"),i);case "acout.current":return this.setMetricValue(e,"acOutCurrent","acOutCurrentState",this.toNumber(t,"A"),i);case "acout.frequency":return this.setMetricValue(e,"acOutFrequency","acOutFrequencyState",this.toNumber(t,"Hz"),i);case "acout.power":return this.setMetricValue(e,"acOutPower","acOutPowerState",this.toNumber(t,"W"),i);case "inverterMode":return this.setMetricValue(e,"inverterMode","inverterModeState",this.toStringValue(t),i);case "inverterModeNumber":return this.setMetricValue(e,"inverterModeNumber","inverterModeNumberState",this.toNumber(t,""),i);case "preferRenewableEnergy":return this.setMetricValue(e,"preferRenewableEnergy","preferRenewableEnergyState",this.toBoolean(t),i);case "preferRenewableEnergyActive":return this.setMetricValue(e,"preferRenewableEnergyActive","preferRenewableEnergyActiveState",this.toBoolean(t),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,o){let d=!Object.is(e[r],i),s=!Object.is(e[t],o);return !d&&!s?false:(e[r]=i,e[t]=o,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{inverters:this.visibleInverters(),displayModels:this.displayModels(),widgetColors:r},this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let t=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,t&&this.render(t);})));}render(e){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e$1,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,o=e.inverters.map((a,h)=>({key:a.deviceKey??a.id,inverter:a,y:h*(i+c$1.CARD_GAP)})),d=o.length?o[o.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${d}`);let s=this.layer.selectAll("g.inverter-card").data(o,a=>a.key),n=s.enter().append("g").attr("class","inverter-card");n.append("rect").attr("class","inverter-card-bg"),n.append("rect").attr("class","inverter-state-bar"),n.append("text").attr("class","inverter-title"),n.append("text").attr("class","inverter-id"),n.append("text").attr("class","inverter-mode"),n.append("text").attr("class","inverter-bus"),n.append("text").attr("class","inverter-metrics-1"),n.append("text").attr("class","inverter-metrics-2");let l=n.merge(s);l.attr("transform",a=>`translate(0, ${a.y})`),l.select("rect.inverter-card-bg").attr("x",.5).attr("y",.5).attr("rx",t.cardCornerRadius).attr("ry",t.cardCornerRadius).attr("width",c$1.VIEWBOX_WIDTH-1).attr("height",i-1).attr("stroke","var(--mat-sys-outline-variant)").attr("stroke-width",.5).attr("fill","none"),l.select("rect.inverter-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",i-3).attr("fill",a=>e.displayModels[a.key]?.stateBarColor??e.widgetColors.dim),e.inverters.length>1?l.select("text.inverter-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",a=>e.displayModels[a.key]?.titleTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.titleText??this.resolveTitleText(a.inverter)):l.select("text.inverter-title").text(""),l.select("text.inverter-id").attr("x",t.idX).attr("y",t.idY).attr("text-anchor","end").attr("font-size",t.idFontSize).attr("fill","var(--kip-contrast-dim-color)").text(a=>a.inverter.id),l.select("text.inverter-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.modeText??""),l.select("text.inverter-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",a=>e.displayModels[a.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(a=>e.displayModels[a.key]?.busText??""),l.select("text.inverter-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",a=>e.displayModels[a.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineOne??""),l.select("text.inverter-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",a=>e.displayModels[a.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(a=>e.displayModels[a.key]?.metricsLineTwo??""),s.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Inverter ${e.id}`}buildMetricRows(e){let r=this.cardMode();if(this.activeDisplayMode()==="full"){let i=e.acInVoltage!=null||e.acInCurrent!=null,o=this.formatValue(e.acInVoltage,"V"),d=this.formatValue(e.acInCurrent,"A"),s=this.formatValue(e.acOutVoltage??e.acVoltage,"V"),n=this.formatValue(e.acOutFrequency??e.acFrequency,"Hz");return [`DC ${this.formatValue(e.dcVoltage,"V")} ${this.formatValue(e.dcCurrent,"A")}`,i?`ACin ${o} ${d}`:`AC ${s} ${n}`]}let t=r.metrics.map(i=>this.toMetricLabel(i,e)).filter(i=>!!i);return t.length?[t.slice(0,2).join(" ")||" ",t.slice(2,4).join(" ")||" "]:["DC - -","AC - -"]}toMetricLabel(e,r){switch(e){case "dcVoltage":return `DC V ${this.formatValue(r.dcVoltage,"V")}`;case "dcCurrent":return `DC A ${this.formatValue(r.dcCurrent,"A")}`;case "dcPower":return `DC P ${this.formatValue(r.dcPower,"W")}`;case "acVoltage":return `AC V ${this.formatValue(r.acVoltage,"V")}`;case "acCurrent":return `AC A ${this.formatValue(r.acCurrent,"A")}`;case "acFrequency":return `Hz ${this.formatValue(r.acFrequency,"Hz")}`;case "acInVoltage":return `ACin V ${this.formatValue(r.acInVoltage,"V")}`;case "acInCurrent":return `ACin A ${this.formatValue(r.acInCurrent,"A")}`;case "acInFrequency":return `ACin Hz ${this.formatValue(r.acInFrequency,"Hz")}`;case "acInPower":return `ACin P ${this.formatValue(r.acInPower,"W")}`;case "acOutVoltage":return `ACout V ${this.formatValue(r.acOutVoltage,"V")}`;case "acOutCurrent":return `ACout A ${this.formatValue(r.acOutCurrent,"A")}`;case "acOutFrequency":return `ACout Hz ${this.formatValue(r.acOutFrequency,"Hz")}`;case "acOutPower":return `ACout P ${this.formatValue(r.acOutPower,"W")}`;case "acIn1CurrentLimit":return `ACin1 Lim ${this.formatValue(r.acIn1CurrentLimit,"A")}`;case "acInCurrentLimit":return `ACin Lim ${this.formatValue(r.acInCurrentLimit,"A")}`;case "temperature":return `T ${this.formatTemperature(r.temperature)}`;case "inverterModeNumber":return `Mode# ${r.inverterModeNumber?.toString()??"-"}`;default:return null}}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${r}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(r=>r===n$1.Alert)?n$1.Alert:e.some(r=>r===n$1.Alarm)?n$1.Alarm:e.some(r=>r===n$1.Warn)?n$1.Warn:e.some(r=>r===n$1.Normal)?n$1.Normal:null}toNumber(e,r){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let i=this.units.convertToUnit(r,t);return typeof i=="number"&&Number.isFinite(i)?i:null}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return true;if(e===0)return false}if(typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="on")return true;if(r==="false"||r==="0"||r==="off")return false}return null}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-inverter"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,re,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["inverterSvg",""],[3,"text","color"],["aria-hidden","false",1,"inverter-svg"],[1,"inverter-empty"],[1,"inverter-empty-title"],[1,"inverter-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,ie,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasInverters()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.inverter-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.inverter-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.inverter-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.inverter-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Z as WidgetInverterComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e as e$1}from'./chunk-CyURmwWh.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,ea as K,aY as xe,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,a_ as Gp,av as _t,cv as G,J as JD,y as yt,dC as x,_ as _w,cn as wd,c as $h,M as Mw,e as EE,s as sg,f as eg,K as Kw,g as qw,B as Bh,P as Pi,T as TT,u as ul}from'./main-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';function H(i){return function(){return i}}var Mt=Math.abs,_=Math.atan2,z=Math.cos,qt=Math.max,rt=Math.min,$=Math.sin,W=Math.sqrt,S=1e-12,Z=Math.PI,tt=Z/2,Xt=2*Z;function jt(i){return i>1?0:i<-1?Z:Math.acos(i)}function Tt(i){return i>=1?tt:i<=-1?-tt:Math.asin(i)}var Ct=Math.PI,At=2*Ct,L=1e-6,ae=At-L;function Zt(i){this._+=i[0];for(let t=1,a=i.length;t<a;++t)this._+=arguments[t]+i[t];}function re(i){let t=Math.floor(i);if(!(t>=0))throw new Error(`invalid digits: ${i}`);if(t>15)return Zt;let a=10**t;return function(r){this._+=r[0];for(let e=1,n=r.length;e<n;++e)this._+=Math.round(arguments[e]*a)/a+r[e];}}var F=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Zt:re(t);}moveTo(t,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}`;}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`);}lineTo(t,a){this._append`L${this._x1=+t},${this._y1=+a}`;}quadraticCurveTo(t,a,r,e){this._append`Q${+t},${+a},${this._x1=+r},${this._y1=+e}`;}bezierCurveTo(t,a,r,e,n,o){this._append`C${+t},${+a},${+r},${+e},${this._x1=+n},${this._y1=+o}`;}arcTo(t,a,r,e,n){if(t=+t,a=+a,r=+r,e=+e,n=+n,n<0)throw new Error(`negative radius: ${n}`);let o=this._x1,l=this._y1,m=r-t,d=e-a,s=o-t,g=l-a,c=s*s+g*g;if(this._x1===null)this._append`M${this._x1=t},${this._y1=a}`;else if(c>L)if(!(Math.abs(g*m-d*s)>L)||!n)this._append`L${this._x1=t},${this._y1=a}`;else {let y=r-o,v=e-l,k=m*m+d*d,R=y*y+v*v,x=Math.sqrt(k),h=Math.sqrt(c),M=n*Math.tan((Ct-Math.acos((k+c-R)/(2*x*h)))/2),T=M/h,f=M/x;Math.abs(T-1)>L&&this._append`L${t+T*s},${a+T*g}`,this._append`A${n},${n},0,0,${+(g*y>s*v)},${this._x1=t+f*m},${this._y1=a+f*d}`;}}arc(t,a,r,e,n,o){if(t=+t,a=+a,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(e),m=r*Math.sin(e),d=t+l,s=a+m,g=1^o,c=o?e-n:n-e;this._x1===null?this._append`M${d},${s}`:(Math.abs(this._x1-d)>L||Math.abs(this._y1-s)>L)&&this._append`L${d},${s}`,r&&(c<0&&(c=c%At+At),c>ae?this._append`A${r},${r},0,1,${g},${t-l},${a-m}A${r},${r},0,1,${g},${this._x1=d},${this._y1=s}`:c>L&&this._append`A${r},${r},0,${+(c>=Ct)},${g},${this._x1=t+r*Math.cos(n)},${this._y1=a+r*Math.sin(n)}`);}rect(t,a,r,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}h${r=+r}v${+e}h${-r}Z`;}toString(){return this._}};function Jt(i){let t=3;return i.digits=function(a){if(!arguments.length)return t;if(a==null)t=null;else {let r=Math.floor(a);if(!(r>=0))throw new RangeError(`invalid digits: ${a}`);t=r;}return i},()=>new F(t)}function ne(i){return i.innerRadius}function ie(i){return i.outerRadius}function se(i){return i.startAngle}function oe(i){return i.endAngle}function le(i){return i&&i.padAngle}function ce(i,t,a,r,e,n,o,l){var m=a-i,d=r-t,s=o-e,g=l-n,c=g*m-s*d;if(!(c*c<S))return c=(s*(t-n)-g*(i-e))/c,[i+c*m,t+c*d]}function nt(i,t,a,r,e,n,o){var l=i-a,m=t-r,d=(o?n:-n)/W(l*l+m*m),s=d*m,g=-d*l,c=i+s,y=t+g,v=a+s,k=r+g,R=(c+v)/2,x=(y+k)/2,h=v-c,M=k-y,T=h*h+M*M,f=e-n,u=c*k-v*y,N=(M<0?-1:1)*W(qt(0,f*f*T-u*u)),w=(u*M-h*N)/T,E=(-u*h-M*N)/T,B=(u*M+h*N)/T,C=(-u*h+M*N)/T,I=w-R,p=E-x,b=B-R,O=C-x;return I*I+p*p>b*b+O*O&&(w=B,E=C),{cx:w,cy:E,x01:-s,y01:-g,x11:w*(e/f-1),y11:E*(e/f-1)}}function Bt(){var i=ne,t=ie,a=H(0),r=null,e=se,n=oe,o=le,l=null,m=Jt(d);function d(){var s,g,c=+i.apply(this,arguments),y=+t.apply(this,arguments),v=e.apply(this,arguments)-tt,k=n.apply(this,arguments)-tt,R=Mt(k-v),x=k>v;if(l||(l=s=m()),y<c&&(g=y,y=c,c=g),!(y>S))l.moveTo(0,0);else if(R>Xt-S)l.moveTo(y*z(v),y*$(v)),l.arc(0,0,y,v,k,!x),c>S&&(l.moveTo(c*z(k),c*$(k)),l.arc(0,0,c,k,v,x));else {var h=v,M=k,T=v,f=k,u=R,N=R,w=o.apply(this,arguments)/2,E=w>S&&(r?+r.apply(this,arguments):W(c*c+y*y)),B=rt(Mt(y-c)/2,+a.apply(this,arguments)),C=B,I=B,p,b;if(E>S){var O=Tt(E/c*$(w)),U=Tt(E/y*$(w));(u-=O*2)>S?(O*=x?1:-1,T+=O,f-=O):(u=0,T=f=(v+k)/2),(N-=U*2)>S?(U*=x?1:-1,h+=U,M-=U):(N=0,h=M=(v+k)/2);}var A=y*z(h),P=y*$(h),K=c*z(f),V=c*$(f);if(B>S){var Y=y*z(M),q=y*$(M),it=c*z(T),st=c*$(T),G;if(R<Z)if(G=ce(A,P,it,st,Y,q,K,V)){var ot=A-G[0],lt=P-G[1],ct=Y-G[0],dt=q-G[1],_t=1/$(jt((ot*ct+lt*dt)/(W(ot*ot+lt*lt)*W(ct*ct+dt*dt)))/2),Rt=W(G[0]*G[0]+G[1]*G[1]);C=rt(B,(c-Rt)/(_t-1)),I=rt(B,(y-Rt)/(_t+1));}else C=I=0;}N>S?I>S?(p=nt(it,st,A,P,y,I,x),b=nt(Y,q,K,V,y,I,x),l.moveTo(p.cx+p.x01,p.cy+p.y01),I<B?l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,y,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),!x),l.arc(b.cx,b.cy,I,_(b.y11,b.x11),_(b.y01,b.x01),!x))):(l.moveTo(A,P),l.arc(0,0,y,h,M,!x)):l.moveTo(A,P),!(c>S)||!(u>S)?l.lineTo(K,V):C>S?(p=nt(K,V,Y,q,c,-C,x),b=nt(A,P,it,st,c,-C,x),l.lineTo(p.cx+p.x01,p.cy+p.y01),C<B?l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,c,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),x),l.arc(b.cx,b.cy,C,_(b.y11,b.x11),_(b.y01,b.x01),!x))):l.arc(0,0,c,f,T,x);}if(l.closePath(),s)return l=null,s+""||null}return d.centroid=function(){var s=(+i.apply(this,arguments)+ +t.apply(this,arguments))/2,g=(+e.apply(this,arguments)+ +n.apply(this,arguments))/2-Z/2;return [z(g)*s,$(g)*s]},d.innerRadius=function(s){return arguments.length?(i=typeof s=="function"?s:H(+s),d):i},d.outerRadius=function(s){return arguments.length?(t=typeof s=="function"?s:H(+s),d):t},d.cornerRadius=function(s){return arguments.length?(a=typeof s=="function"?s:H(+s),d):a},d.padRadius=function(s){return arguments.length?(r=s==null?null:typeof s=="function"?s:H(+s),d):r},d.startAngle=function(s){return arguments.length?(e=typeof s=="function"?s:H(+s),d):e},d.endAngle=function(s){return arguments.length?(n=typeof s=="function"?s:H(+s),d):n},d.padAngle=function(s){return arguments.length?(o=typeof s=="function"?s:H(+s),d):o},d.context=function(s){return arguments.length?(l=s??null,d):l},d}var ue=["bmsSvg"];function pe(i,t){if(i&1&&$h(0,"widget-title",1),i&2){let a=qw();Bh("text",a.displayLabel())("color",a.labelColor());}}function me(i,t){i&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No batteries detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K battery paths or select batteries in widget settings."),ul()());}var ee=class i{static BMS_DESCRIPTOR=a("widget-bms");static ROOT_PATTERN=`${i.BMS_DESCRIPTOR?.selfRootPath??"self.electrical.batteries"}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,bms:{trackedDevices:[],groups:[],banks:[]}};static VIEWBOX_WIDTH=200;static MIN_VIEWBOX_HEIGHT=1;static BANK_CARD_WIDTH=200;static BATTERY_CARD_HEIGHT=50;static BATTERY_CARD_WIDTH=200;static CARD_GAP=8;static BANK_HEADER_HEIGHT=80;static BANK_MIN_HEIGHT=75;static SINGLE_ROW_BANK_HEIGHT=100;static IN_BANK_COLUMNS=2;static IN_BANK_COLUMN_GAP=5;static IN_BANK_PADDING_X=0;static BANK_GAUGE_RADIUS=50;static BANK_GAUGE_BG_STROKE=10;static BANK_GAUGE_VALUE_STROKE=10;static COMPACT_UNASSIGNED_BATTERY_SCALE=.82;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);iconRegistry=w(K);destroyRef=w(xe);svgRef=$j.required("bmsSvg");svg;root;bankLayer;batteryLayer;bankGaugeBackgroundPath=this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,1);glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;powerAvailableIconTemplate=null;powerRenewalIconTemplate=null;discoveredBatteryIds=vt([]);trackedBatteryDeviceIds=vt([]);banks=vt([]);cardMode=vt({displayMode:"full",metrics:[]});batteries=vt({});visibleBatteryIds=Dt(()=>{let t=this.trackedBatteryDeviceIds();return t.length?t:this.discoveredBatteryIds()});visibleBatteries=Dt(()=>{let t=this.visibleBatteryIds(),a=this.batteries();return t.map(r=>a[r]).filter(r=>!!r)});bankSummaries=Dt(()=>{let t=this.banks(),a=this.batteries();return t.map(r=>this.buildBankSummary(r,a))});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let t=this.bankSummaries();if(t.length===1)return t[0].name||"Bank";if(t.length>1)return "Batteries";let a=this.visibleBatteries();return a.length!==1?"Batteries":this.resolveBatteryTitleText(a[0])});labelColor=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t):null});batteryDisplayModels=Dt(()=>{let t=this.visibleBatteries(),a=this.theme(),r=this.widgetColors(),e$1=this.ignoreZones(),n={};for(let o of t){let l=e(o.stateOfChargeState,r?.dimmer??"var(--kip-contrast-dimmer-color)",a,e$1),m=e(o.stateOfChargeState,r?.dim??"var(--kip-contrast-dim-color)",a,e$1),d=e(o.currentState,"var(--kip-contrast-dim-color)",a,e$1),s=e(o.currentState,"var(--kip-contrast-color)",a,e$1);n[o.id]={id:o.id,titleText:this.resolveBatteryTitleText(o),chargeWidth:(i.BATTERY_CARD_WIDTH-3)*(o.stateOfCharge??0),chargeBarColorCompact:l,chargeBarColorRegular:m,currentTextColorCompact:d,currentTextColorRegular:s,currentText:`${this.formatCurrent(o.current)}`.trim(),detailLineCompact:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`,detailLineRegular:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatPower(o.power)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`.trim(),socText:this.formatSoc(o.stateOfCharge),socGlowEnabled:!e$1&&(o.stateOfChargeState===n$1.Warn||o.stateOfChargeState===n$1.Alarm||o.stateOfChargeState===n$1.Alert),remainingCapacityText:o.capacityActual?`${this.formatEnergy(o.capacityRemaining)}`:"",remainingTimeText:`${this.formatDuration(o.timeRemaining)}`.trim(),iconKey:o.current!=null&&o.current>0?"power_renewal":"power_available"};}return n});bankDisplayModels=Dt(()=>{let t=this.bankSummaries(),a=this.widgetColors(),r={};for(let e of t)r[e.id]={id:e.id,titleText:e.name||"Bank",currentText:this.formatCurrent(e.totalCurrent),powerText:this.formatPower(e.totalPower),socText:this.formatSoc(e.avgSoc),remainingTimeText:`${this.formatDuration(e.timeRemaining)}`.trim(),remainingCapacityText:e.remainingCapacity?`${this.formatEnergy(e.remainingCapacity)}`:"",gaugeValuePath:this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,e.avgSoc),gaugeValueColor:a?.color??"var(--kip-contrast-color)",zoneState:null,zoneColor:null};return r});hasBatteries=Dt(()=>this.visibleBatteries().length>0);hasBanks=Dt(()=>this.bankSummaries().length>0);constructor(){Fa(()=>{let a=this.runtime.options();a&&ge(()=>this.applyConfig(a));}),Fa(()=>{let a=this.bankSummaries(),r=this.visibleBatteries(),e=this.widgetColors(),n=this.batteryDisplayModels(),o=this.bankDisplayModels();!this.svg||!e||this.requestRender({banks:a,batteries:r,batteryDisplayModels:n,bankDisplayModels:o,widgetColors:e});});let t=this.data.subscribePathTreeWithInitial(i.ROOT_PATTERN);if(t.initial.length){for(let a of t.initial)this.enqueuePathUpdate(a,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}t.live$.pipe(Gp(this.destroyRef)).subscribe(a=>{this.enqueuePathUpdate(a);});}ngAfterViewInit(){this.initializeSvg(),this.loadPowerIcons(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${i.MIN_VIEWBOX_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Battery Management System View"),this.glowFilterId=`bms-soc-glow-${this.id()}`;let a=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");a.append("feFlood").attr("class","bms-soc-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),a.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),a.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let r=a.append("feMerge");r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","SourceGraphic"),this.root=this.svg.append("g").attr("class","bms-root"),this.bankLayer=this.root.append("g").attr("class","bms-banks"),this.batteryLayer=this.root.append("g").attr("class","bms-batteries");}loadPowerIcons(){this.loadNamedIcon("power_available",t=>{this.powerAvailableIconTemplate=t;}),this.loadNamedIcon("power_renewal",t=>{this.powerRenewalIconTemplate=t;});}loadNamedIcon(t,a){this.iconRegistry.getNamedSvgIcon(t).pipe(_t(1)).subscribe({next:r=>{a(r),this.requestRender();},error:()=>{}});}applyConfig(t){let a=this.resolveBmsConfig(t);this.trackedBatteryDeviceIds.set([...new Set((a.trackedDevices??[]).map(r=>r.id))]),this.banks.set(a.banks),this.cardMode.set(this.normalizeCardMode(a.cardMode));}resolveBmsConfig(t){let a=t.bms,r=this.normalizeTrackedDevices(a?.trackedDevices),e=this.normalizeBanksFromGroups(a?.groups),n=this.normalizeBanksFromLegacy(a?.banks);return {trackedDevices:r,groups:e,banks:e.length>0?e:n,cardMode:this.normalizeCardMode(a?.cardMode)}}normalizeTrackedDevices(t){if(!Array.isArray(t))return [];let a=new Map;return t.forEach(r=>{if(!r||typeof r!="object")return;let e=r,n=typeof e.id=="string"?e.id.trim():"",o=typeof e.source=="string"?e.source.trim():"default";if(!n||!o)return;let l=typeof e.key=="string"&&e.key.trim().length>0?e.key.trim():`${n}||${o}`;a.set(l,{id:n,source:o,key:l});}),[...a.values()].sort((r,e)=>r.key.localeCompare(e.key))}normalizeCardMode(t){let a=t&&typeof t=="object"?t:null,r=this.normalizeStringList(a?.metrics);return {displayMode:a?.displayMode==="compact"?"compact":"full",metrics:r}}normalizeStringList(t){if(!Array.isArray(t))return [];let a=new Set;return t.forEach(r=>{if(typeof r!="string")return;let e=r.trim();e.length>0&&a.add(e);}),[...a].sort((r,e)=>r.localeCompare(e))}normalizeBanksFromGroups(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.memberIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeBanksFromLegacy(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.batteryIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeOptionalString(t){if(typeof t!="string")return null;let a=t.trim();return a.length>0?a:null}normalizeConnectionMode(t){return t==="series"?"series":"parallel"}enqueuePathUpdate(t,a=false){let r=this.parseBatteryPath(t.path);if(!r)return;let{id:e,key:n}=r,o=t.update?.data?.value??null,l=t.update?.state??null,m=`${e}::${n}`;if(this.pendingPathUpdates.set(m,{id:e,key:n,value:o,state:l}),!a){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},i.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let t=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(t.map(r=>r.id)).forEach(r=>this.trackDiscoveredBattery(r)),this.batteries.update(r=>{let e=r,n=false;for(let o of t){let l=e[o.id]??{id:o.id},m=G({},l),d=this.applyBatteryValue(m,o.key,o.value,o.state),s=false;if(m.voltage!=null&&m.current!=null){let g=Number.isFinite(m.voltage)&&Number.isFinite(m.current)?m.voltage*m.current:null;Object.is(m.power,g)||(m.power=g,s=true);}!d&&!s||(n||(e=G({},e),n=true),e[o.id]=m);}return n?e:r});}parseBatteryPath(t){let a=t.match(/self\.electrical\.batteries\.([^.]+)\.(.+)$/);return a?{id:a[1],key:a[2]}:null}trackDiscoveredBattery(t){let a=this.discoveredBatteryIds();if(a.includes(t))return;let r=[...a,t].sort();this.discoveredBatteryIds.set(r);}applyBatteryValue(t,a,r,e){switch(a){case "name":{let n=r;return t.name===n?false:(t.name=n,true)}case "location":{let n=r;return t.location===n?false:(t.location=n,true)}case "associatedBus":{let n=r;return t.associatedBus===n?false:(t.associatedBus=n,true)}case "chemistry":{let n=r;return t.chemistry===n?false:(t.chemistry=n,true)}case "voltage":{let n=this.toNumber(r);return Object.is(t.voltage,n)?false:(t.voltage=n,true)}case "current":{let n=this.toNumber(r),o=!Object.is(t.currentState??null,e??null);return Object.is(t.current,n)&&!o?false:(t.current=n,t.currentState=e,true)}case "temperature":{let n=this.toNumber(r);return Object.is(t.temperature,n)?false:(t.temperature=n,true)}case "capacity.nominal":{let n=this.toNumber(r);return Object.is(t.capacityNominal,n)?false:(t.capacityNominal=n,true)}case "capacity.actual":{let n=this.toNumber(r);return Object.is(t.capacityActual,n)?false:(t.capacityActual=n,true)}case "capacity.remaining":{let n=this.toNumber(r);return Object.is(t.capacityRemaining,n)?false:(t.capacityRemaining=n,true)}case "capacity.stateOfCharge":{let n=this.toNumber(r),o=!Object.is(t.stateOfChargeState??null,e??null);return Object.is(t.stateOfCharge,n)&&!o?false:(t.stateOfCharge=n,t.stateOfChargeState=e,true)}case "capacity.timeRemaining":{let n=this.toNumber(r);return Object.is(t.timeRemaining,n)?false:(t.timeRemaining=n,true)}default:return false}}buildBankSummary(t,a){let r=t.batteryIds.map(s=>a[s]).filter(s=>!!s),e=this.normalizeConnectionMode(t.connectionMode),n=this.calculateBankCurrent(r,e),o=this.sumNumbers(r.map(s=>s.power)),l=this.sumNumbers(r.map(s=>s.capacityRemaining)),m=this.calculateBankSoc(r),d=this.calculateBankTimeRemaining(r,e);return {id:t.id,name:t.name,batteryIds:t.batteryIds,totalCurrent:n,totalPower:o,remainingCapacity:l,avgSoc:m,timeRemaining:d}}calculateBankSoc(t){let a=this.sumNumbers(t.map(n=>n.capacityRemaining)),r=this.sumNumbers(t.map(n=>n.capacityActual));if(a!=null&&r!=null&&r>0)return Math.max(0,Math.min(1,a/r));let e=this.sumNumbers(t.map(n=>n.capacityNominal));return a!=null&&e!=null&&e>0?Math.max(0,Math.min(1,a/e)):this.averageNumbers(t.map(n=>n.stateOfCharge))}calculateBankCurrent(t,a){let r=t.map(e=>e.current);return a==="series"?this.averageNumbers(r):this.sumNumbers(r)}calculateBankTimeRemaining(t,a){let r=t.map(e=>e.timeRemaining);return a==="series"?this.minNumber(r):this.averageNumbers(r)}requestRender(t){this.svg&&(this.pendingRenderSnapshot=t??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let a=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,a&&this.render(a);})));}buildRenderSnapshot(){let t=this.widgetColors();return t?{banks:this.bankSummaries(),batteries:this.visibleBatteries(),batteryDisplayModels:this.batteryDisplayModels(),bankDisplayModels:this.bankDisplayModels(),widgetColors:t}:null}render(t){if(!this.bankLayer||!this.batteryLayer)return;let{banks:a,batteries:r,bankDisplayModels:e,batteryDisplayModels:n,widgetColors:o}=t,l=this.buildRenderLayout(a,r,e,n,this.isCompactCardMode()),d=this.isCompactCardMode()?e$1:e$1,s=Math.max(i.MIN_VIEWBOX_HEIGHT,l.contentHeight);this.svg?.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${s}`),this.root?.attr("transform",null);let g=this.bankLayer.selectAll("g.bank-card").data(l.banks,u=>u.id),c=g.enter().append("g").attr("class","bank-card"),y=c.append("text").attr("class","bank-card-power");y.append("tspan").attr("class","bank-card-power-value"),y.append("tspan").attr("class","bank-card-power-unit");let v=c.append("text").attr("class","bank-card-current");v.append("tspan").attr("class","bank-card-current-value"),v.append("tspan").attr("class","bank-card-current-unit");let k=c.append("g").attr("class","bank-gauge");k.append("path").attr("class","bank-gauge-bg"),k.append("path").attr("class","bank-gauge-value");let R=k.append("text").attr("class","bank-gauge-soc");R.append("tspan").attr("class","bank-gauge-soc-value"),R.append("tspan").attr("class","bank-gauge-soc-unit");let x=c.append("text").attr("class","bank-actualCapacity");x.append("tspan").attr("class","bank-actualCapacity-value"),x.append("tspan").attr("class","bank-actualCapacity-unit"),c.append("text").attr("class","bank-remaining"),c.append("g").attr("class","bank-bms-batteries"),c.append("text").attr("class","bank-title");let h=c.merge(g);h.attr("transform",u=>`translate(${u.x},${u.y})`),l.banks.length>1?h.select("text.bank-title").attr("x",d.titleX).attr("y",d.titleY).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",d.titleFontSize).text(u=>u.displayModel.titleText):h.select("text.bank-title").text(""),h.select("text.bank-card-current").attr("x",d.lineOneX).attr("y",d.lineOneY).attr("fill","var(--kip-contrast-color)").attr("font-size",d.lineOneFontSize),h.select("tspan.bank-card-current-value").text(u=>this.splitMetricText(u.displayModel.currentText,"A").valueText),h.select("tspan.bank-card-current-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.currentText,"A").unitText),h.select("text.bank-card-power").attr("x",5).attr("y",42).attr("fill","var(--kip-contrast-color)").attr("font-size",10).attr("opacity",.8),h.select("tspan.bank-card-power-value").text(u=>this.splitMetricText(u.displayModel.powerText,"W").valueText),h.select("tspan.bank-card-power-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.powerText,"W").unitText),h.select("g.bank-gauge").attr("transform","translate(143, 60)"),h.select("path.bank-gauge-bg").attr("d",this.bankGaugeBackgroundPath).attr("fill","none").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",i.BANK_GAUGE_BG_STROKE).attr("stroke-linecap","round"),h.select("path.bank-gauge-value").attr("d",u=>u.displayModel.gaugeValuePath).attr("fill","none").attr("stroke",u=>u.displayModel.gaugeValueColor).attr("stroke-width",i.BANK_GAUGE_VALUE_STROKE).attr("stroke-linecap","round"),h.select("text.bank-gauge-soc").attr("x",0).attr("y",-5).attr("text-anchor","middle").attr("fill","var(--kip-contrast-color)").attr("font-size",d.primaryFontSize).attr("font-weight",d.primaryFontWeight),h.select("tspan.bank-gauge-soc-value").text(u=>this.splitMetricText(u.displayModel.socText,"%").valueText),h.select("tspan.bank-gauge-soc-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.socText,"%").unitText),h.select("text.bank-remaining").attr("x",143).attr("y",26).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).text(u=>u.displayModel.remainingTimeText),h.select("text.bank-actualCapacity").attr("x",143).attr("y",66).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8),h.select("tspan.bank-actualCapacity-value").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").valueText),h.select("tspan.bank-actualCapacity-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").unitText),h.select("g.bank-bms-batteries").each((u,N,w)=>{let B=ge$1(w[N]).selectAll("g.battery-card").data(u.batteries,p=>p.key),C=B.enter().append("g").attr("class","battery-card battery-card--in-bank");this.appendBatteryCardSkeleton(C);let I=C.merge(B);this.renderBatteryCards(I,o,t.batteries.length>1),B.exit().remove();}),g.exit().remove();let M=this.batteryLayer.selectAll("g.battery-card").data(l.unassignedBatteries,u=>u.key),T=M.enter().append("g").attr("class","battery-card battery-card--unassigned");this.appendBatteryCardSkeleton(T);let f=T.merge(M);this.renderBatteryCards(f,o,true),M.exit().remove(),this.root?.attr("data-theme","ready");}buildRenderLayout(t,a,r,e,n){let o=new Map(a.map(f=>[f.id,f])),l=new Set,m=this.computeInBankBatterySlotWidth(),d=Math.max(.35,Math.min(1,m/i.BATTERY_CARD_WIDTH)),s=i.BATTERY_CARD_HEIGHT*d,g=0,c=t.map(f=>{let u=new Set,N=f.batteryIds.map(A=>o.get(A)).filter(A=>!A||u.has(A.id)?false:(u.add(A.id),true));N.forEach(A=>l.add(A.id));let w=Math.ceil(N.length/i.IN_BANK_COLUMNS),E=i.SINGLE_ROW_BANK_HEIGHT,B=!n&&w===1,C=B?Math.max(0,E-s-i.CARD_GAP):i.BANK_HEADER_HEIGHT,I=w>0?w*s+(w-1)*i.CARD_GAP:0,p=Math.max(i.BANK_MIN_HEIGHT,C+I+i.CARD_GAP),b=B?E:p,O=N.map((A,P)=>{let K=P%i.IN_BANK_COLUMNS,V=Math.floor(P/i.IN_BANK_COLUMNS),Y=i.IN_BANK_PADDING_X+K*(m+i.IN_BANK_COLUMN_GAP),q=C+7+V*(s+i.CARD_GAP);return {id:A.id,displayModel:e[A.id],key:`${f.id}::${A.id}`,x:Y,y:q,scale:d,inBank:true,compact:true}}),U={id:f.id,name:f.name,batteryIds:f.batteryIds,totalCurrent:f.totalCurrent,totalPower:f.totalPower,avgSoc:f.avgSoc,remainingCapacity:f.remainingCapacity,timeRemaining:f.timeRemaining,displayModel:r[f.id],x:0,y:g,width:i.BANK_CARD_WIDTH,height:b,batteries:O};return g+=b+i.CARD_GAP,U}),y=c.length>0?g:0,v=n?i.COMPACT_UNASSIGNED_BATTERY_SCALE:1,k=i.BATTERY_CARD_HEIGHT*v,R=a.filter(f=>!l.has(f.id)).sort((f,u)=>f.id.localeCompare(u.id)).map((f,u)=>({id:f.id,displayModel:e[f.id],key:f.id,x:0,y:y+u*(k+i.CARD_GAP),scale:v,inBank:false,compact:n})),x=c[c.length-1],h=x?x.y+x.height:0,M=R[R.length-1],T=M?M.y+k:0;return {banks:c,unassignedBatteries:R,contentHeight:Math.max(h,T)}}computeInBankBatterySlotWidth(){return (i.BANK_CARD_WIDTH-i.IN_BANK_PADDING_X*2-i.IN_BANK_COLUMN_GAP)/i.IN_BANK_COLUMNS}appendBatteryCardSkeleton(t){t.append("rect").attr("class","bms-battery").attr("rx",4).attr("ry",4),t.append("rect").attr("class","bms-battery-tip").attr("rx",1).attr("ry",1),t.append("rect").attr("class","bms-charge-fill").attr("rx",3).attr("ry",3),t.append("g").attr("class","bms-state-icon"),t.append("text").attr("class","bms-ampere"),t.append("text").attr("class","bms-volt-power");let a=t.append("text").attr("class","bms-soc");a.append("tspan").attr("class","bms-soc-value"),a.append("tspan").attr("class","bms-soc-unit"),t.append("text").attr("class","bms-actualCapacity"),t.append("text").attr("class","bms-remaining"),t.append("text").attr("class","bms-title");}renderBatteryCards(t,a,r){t.attr("transform",e=>`translate(${e.x},${e.y}) scale(${e.scale})`),t.select("rect.bms-battery").attr("width",e=>e.inBank?i.BATTERY_CARD_WIDTH:e.compact?i.BATTERY_CARD_WIDTH-i.CARD_GAP:i.BATTERY_CARD_WIDTH).attr("height",i.BATTERY_CARD_HEIGHT).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",0),t.select("rect.bms-battery-tip").attr("x",i.BATTERY_CARD_WIDTH).attr("y",i.BATTERY_CARD_HEIGHT/2-10).attr("width",4).attr("height",20).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke",a.color).attr("stroke-width",0),t.select("rect.bms-charge-fill").attr("x",1.5).attr("y",1.5).attr("width",e=>e.displayModel.chargeWidth).attr("height",i.BATTERY_CARD_HEIGHT-3).attr("fill",e=>e.compact?e.displayModel.chargeBarColorCompact:e.displayModel.chargeBarColorRegular),r?t.select("text.bms-title").attr("x",5).attr("y",e=>e.compact?11:14).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",e=>e.compact?8:12).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.titleText):t.select("text.bms-title").text(""),t.select("text.bms-ampere").attr("x",10).attr("y",33).attr("fill",e=>e.compact?e.displayModel.currentTextColorCompact:e.displayModel.currentTextColorRegular).attr("font-size",16).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.currentText),t.select("text.bms-volt-power").attr("x",10).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",8).attr("opacity",.8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?e.displayModel.detailLineCompact:e.displayModel.detailLineRegular),t.select("text.bms-soc").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",34).attr("fill",e=>e.compact?"var(--kip-contrast-dim-color)":"var(--kip-contrast-color)").attr("text-anchor","middle").attr("font-size",25).attr("font-weight",700).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null),t.select("tspan.bms-soc-value").text(e=>this.splitMetricText(e.displayModel.socText,"%").valueText),t.select("tspan.bms-soc-unit").attr("dx",1).attr("font-size",16).attr("font-weight",500).text(e=>this.splitMetricText(e.displayModel.socText,"%").unitText),t.select("text.bms-actualCapacity").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingCapacityText),t.select("text.bms-remaining").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",12).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",6).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingTimeText),t.select("g.bms-state-icon").attr("transform",`translate(${i.BATTERY_CARD_WIDTH/2-18}, ${i.BATTERY_CARD_HEIGHT/2-18})`).attr("display",e=>e.compact&&e.scale<.45?"none":null).attr("color",e=>e.compact?a.dim:a.color).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).each((e,n,o)=>{let l=ge$1(o[n]),m=e.displayModel.iconKey,d=m==="power_renewal"?this.powerRenewalIconTemplate:this.powerAvailableIconTemplate;if(!d){l.selectAll("*").remove(),l.attr("data-icon-key",null);return}let s=l.node();if(!s||l.attr("data-icon-key")===m&&s.firstElementChild)return;l.selectAll("*").remove();let c=d.cloneNode(true);c.removeAttribute("id"),c.setAttribute("width","36"),c.setAttribute("height","36"),c.getAttribute("viewBox")||c.setAttribute("viewBox","0 0 24 24"),s.appendChild(c),l.attr("data-icon-key",m);});}formatVoltage(t){return t==null?"-- V":`${t.toFixed(1)}V`}formatCurrent(t){return t==null?"-- A":`${t.toFixed(1)}A`}formatPower(t){return t==null?"":`${t.toFixed(0)}W`}formatEnergy(t){return t==null?"":(t=this.units.convertToUnit("kWh",t),`${t}kWh`)}formatSoc(t){return t==null?"--%":`${Math.round(t*100)}%`}resolveBatteryTitleText(t){return t.name||`Battery ${t.id}`}formatDuration(t){if(t==null)return "";let a=this.units.convertToUnit("D HH:MM:SS",t);return a==null?"":typeof a=="string"?a:`${a}`}formatTemperature(t){if(t==null||typeof t!="number")return "";let a=this.units.getDefaults().Temperature,r=this.units.convertToUnit(a,t);return r===null?"":`${r.toFixed(1)} ${a==="celsius"?"\xB0C":"\xB0F"}`}splitMetricText(t,a){if(!t)return {valueText:"",unitText:""};let r=t.trim();return r?r.endsWith(a)?{valueText:r.slice(0,Math.max(0,r.length-a.length)).trim(),unitText:a}:{valueText:r,unitText:""}:{valueText:"",unitText:""}}sumNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0):null}averageNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0)/a.length:null}minNumber(t){let a=t.filter(r=>typeof r=="number");return a.length?Math.min(...a):null}toNumber(t){return t==null||typeof t!="number"?null:t}buildSemiGaugeArcPath(t,a){let r=Math.max(0,Math.min(1,a??0)),e=-Math.PI*.55,n=Math.PI*1.1,o=e+n*r;if(r<=0){let l=t*Math.cos(e),m=t*Math.sin(e);return `M ${l} ${m}`}return Bt()({innerRadius:t,outerRadius:t,startAngle:e,endAngle:o})??""}static \u0275fac=function(a){return new(a||i)};static \u0275cmp=JD({type:i,selectors:[["widget-bms"]],viewQuery:function(a,r){a&1&&eg(r.svgRef,ue,5),a&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:4,consts:[["bmsSvg",""],[3,"text","color"],["aria-hidden","false",1,"bms-svg"],[1,"bms-empty"],[1,"bms-empty-title"],[1,"bms-empty-sub"]],template:function(a,r){a&1&&(_w(0,pe,1,2,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),a&2&&(Mw(r.hasBanks()?0:-1),EE(),sg("bms-svg--full",!r.hasBanks()),EE(2),Mw(r.hasBatteries()?-1:3));},dependencies:[yt,x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.bms-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:0 10px 10px}.bms-svg.bms-svg--full[_ngcontent-%COMP%]{top:0;height:100%;padding-top:10px}.bms-card-metric[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:30px;font-weight:700}.bms-card-sub[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:18px;opacity:.9}.bms-card-meta[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:15px;opacity:.75}.bms-card-footer[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:16px;opacity:.8}.bms-flow-line[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color);stroke-width:3px;stroke-dasharray:6 6;animation:_ngcontent-%COMP%_flow-dash 2s linear infinite}.bms-flow-line--out[_ngcontent-%COMP%]{stroke:var(--kip-zone-warn-color)}.bms-flow-line--in[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color)}.bms-flow-line--neutral[_ngcontent-%COMP%]{stroke:var(--kip-widget-card-border-color);animation:none}.bms-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.bms-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.bms-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}@keyframes _ngcontent-%COMP%_flow-dash{to{stroke-dashoffset:-12}}"]})};export{ee as WidgetBmsComponent};
|
|
1
|
+
import {e as e$1}from'./chunk-DPnbM-aB.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,ea as K,aY as xe,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,a_ as Gp,av as _t,cv as G,J as JD,y as yt,dC as x,_ as _w,cn as wd,c as $h,M as Mw,e as EE,s as sg,f as eg,K as Kw,g as qw,B as Bh,P as Pi,T as TT,u as ul}from'./main-YKDNK5VZ.js';import {c,e}from'./chunk-BIb-xYiS.js';function H(i){return function(){return i}}var Mt=Math.abs,_=Math.atan2,z=Math.cos,qt=Math.max,rt=Math.min,$=Math.sin,W=Math.sqrt,S=1e-12,Z=Math.PI,tt=Z/2,Xt=2*Z;function jt(i){return i>1?0:i<-1?Z:Math.acos(i)}function Tt(i){return i>=1?tt:i<=-1?-tt:Math.asin(i)}var Ct=Math.PI,At=2*Ct,L=1e-6,ae=At-L;function Zt(i){this._+=i[0];for(let t=1,a=i.length;t<a;++t)this._+=arguments[t]+i[t];}function re(i){let t=Math.floor(i);if(!(t>=0))throw new Error(`invalid digits: ${i}`);if(t>15)return Zt;let a=10**t;return function(r){this._+=r[0];for(let e=1,n=r.length;e<n;++e)this._+=Math.round(arguments[e]*a)/a+r[e];}}var F=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Zt:re(t);}moveTo(t,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}`;}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`);}lineTo(t,a){this._append`L${this._x1=+t},${this._y1=+a}`;}quadraticCurveTo(t,a,r,e){this._append`Q${+t},${+a},${this._x1=+r},${this._y1=+e}`;}bezierCurveTo(t,a,r,e,n,o){this._append`C${+t},${+a},${+r},${+e},${this._x1=+n},${this._y1=+o}`;}arcTo(t,a,r,e,n){if(t=+t,a=+a,r=+r,e=+e,n=+n,n<0)throw new Error(`negative radius: ${n}`);let o=this._x1,l=this._y1,m=r-t,d=e-a,s=o-t,g=l-a,c=s*s+g*g;if(this._x1===null)this._append`M${this._x1=t},${this._y1=a}`;else if(c>L)if(!(Math.abs(g*m-d*s)>L)||!n)this._append`L${this._x1=t},${this._y1=a}`;else {let y=r-o,v=e-l,k=m*m+d*d,R=y*y+v*v,x=Math.sqrt(k),h=Math.sqrt(c),M=n*Math.tan((Ct-Math.acos((k+c-R)/(2*x*h)))/2),T=M/h,f=M/x;Math.abs(T-1)>L&&this._append`L${t+T*s},${a+T*g}`,this._append`A${n},${n},0,0,${+(g*y>s*v)},${this._x1=t+f*m},${this._y1=a+f*d}`;}}arc(t,a,r,e,n,o){if(t=+t,a=+a,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(e),m=r*Math.sin(e),d=t+l,s=a+m,g=1^o,c=o?e-n:n-e;this._x1===null?this._append`M${d},${s}`:(Math.abs(this._x1-d)>L||Math.abs(this._y1-s)>L)&&this._append`L${d},${s}`,r&&(c<0&&(c=c%At+At),c>ae?this._append`A${r},${r},0,1,${g},${t-l},${a-m}A${r},${r},0,1,${g},${this._x1=d},${this._y1=s}`:c>L&&this._append`A${r},${r},0,${+(c>=Ct)},${g},${this._x1=t+r*Math.cos(n)},${this._y1=a+r*Math.sin(n)}`);}rect(t,a,r,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+a}h${r=+r}v${+e}h${-r}Z`;}toString(){return this._}};function Jt(i){let t=3;return i.digits=function(a){if(!arguments.length)return t;if(a==null)t=null;else {let r=Math.floor(a);if(!(r>=0))throw new RangeError(`invalid digits: ${a}`);t=r;}return i},()=>new F(t)}function ne(i){return i.innerRadius}function ie(i){return i.outerRadius}function se(i){return i.startAngle}function oe(i){return i.endAngle}function le(i){return i&&i.padAngle}function ce(i,t,a,r,e,n,o,l){var m=a-i,d=r-t,s=o-e,g=l-n,c=g*m-s*d;if(!(c*c<S))return c=(s*(t-n)-g*(i-e))/c,[i+c*m,t+c*d]}function nt(i,t,a,r,e,n,o){var l=i-a,m=t-r,d=(o?n:-n)/W(l*l+m*m),s=d*m,g=-d*l,c=i+s,y=t+g,v=a+s,k=r+g,R=(c+v)/2,x=(y+k)/2,h=v-c,M=k-y,T=h*h+M*M,f=e-n,u=c*k-v*y,N=(M<0?-1:1)*W(qt(0,f*f*T-u*u)),w=(u*M-h*N)/T,E=(-u*h-M*N)/T,B=(u*M+h*N)/T,C=(-u*h+M*N)/T,I=w-R,p=E-x,b=B-R,O=C-x;return I*I+p*p>b*b+O*O&&(w=B,E=C),{cx:w,cy:E,x01:-s,y01:-g,x11:w*(e/f-1),y11:E*(e/f-1)}}function Bt(){var i=ne,t=ie,a=H(0),r=null,e=se,n=oe,o=le,l=null,m=Jt(d);function d(){var s,g,c=+i.apply(this,arguments),y=+t.apply(this,arguments),v=e.apply(this,arguments)-tt,k=n.apply(this,arguments)-tt,R=Mt(k-v),x=k>v;if(l||(l=s=m()),y<c&&(g=y,y=c,c=g),!(y>S))l.moveTo(0,0);else if(R>Xt-S)l.moveTo(y*z(v),y*$(v)),l.arc(0,0,y,v,k,!x),c>S&&(l.moveTo(c*z(k),c*$(k)),l.arc(0,0,c,k,v,x));else {var h=v,M=k,T=v,f=k,u=R,N=R,w=o.apply(this,arguments)/2,E=w>S&&(r?+r.apply(this,arguments):W(c*c+y*y)),B=rt(Mt(y-c)/2,+a.apply(this,arguments)),C=B,I=B,p,b;if(E>S){var O=Tt(E/c*$(w)),U=Tt(E/y*$(w));(u-=O*2)>S?(O*=x?1:-1,T+=O,f-=O):(u=0,T=f=(v+k)/2),(N-=U*2)>S?(U*=x?1:-1,h+=U,M-=U):(N=0,h=M=(v+k)/2);}var A=y*z(h),P=y*$(h),K=c*z(f),V=c*$(f);if(B>S){var Y=y*z(M),q=y*$(M),it=c*z(T),st=c*$(T),G;if(R<Z)if(G=ce(A,P,it,st,Y,q,K,V)){var ot=A-G[0],lt=P-G[1],ct=Y-G[0],dt=q-G[1],_t=1/$(jt((ot*ct+lt*dt)/(W(ot*ot+lt*lt)*W(ct*ct+dt*dt)))/2),Rt=W(G[0]*G[0]+G[1]*G[1]);C=rt(B,(c-Rt)/(_t-1)),I=rt(B,(y-Rt)/(_t+1));}else C=I=0;}N>S?I>S?(p=nt(it,st,A,P,y,I,x),b=nt(Y,q,K,V,y,I,x),l.moveTo(p.cx+p.x01,p.cy+p.y01),I<B?l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,I,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,y,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),!x),l.arc(b.cx,b.cy,I,_(b.y11,b.x11),_(b.y01,b.x01),!x))):(l.moveTo(A,P),l.arc(0,0,y,h,M,!x)):l.moveTo(A,P),!(c>S)||!(u>S)?l.lineTo(K,V):C>S?(p=nt(K,V,Y,q,c,-C,x),b=nt(A,P,it,st,c,-C,x),l.lineTo(p.cx+p.x01,p.cy+p.y01),C<B?l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(b.y01,b.x01),!x):(l.arc(p.cx,p.cy,C,_(p.y01,p.x01),_(p.y11,p.x11),!x),l.arc(0,0,c,_(p.cy+p.y11,p.cx+p.x11),_(b.cy+b.y11,b.cx+b.x11),x),l.arc(b.cx,b.cy,C,_(b.y11,b.x11),_(b.y01,b.x01),!x))):l.arc(0,0,c,f,T,x);}if(l.closePath(),s)return l=null,s+""||null}return d.centroid=function(){var s=(+i.apply(this,arguments)+ +t.apply(this,arguments))/2,g=(+e.apply(this,arguments)+ +n.apply(this,arguments))/2-Z/2;return [z(g)*s,$(g)*s]},d.innerRadius=function(s){return arguments.length?(i=typeof s=="function"?s:H(+s),d):i},d.outerRadius=function(s){return arguments.length?(t=typeof s=="function"?s:H(+s),d):t},d.cornerRadius=function(s){return arguments.length?(a=typeof s=="function"?s:H(+s),d):a},d.padRadius=function(s){return arguments.length?(r=s==null?null:typeof s=="function"?s:H(+s),d):r},d.startAngle=function(s){return arguments.length?(e=typeof s=="function"?s:H(+s),d):e},d.endAngle=function(s){return arguments.length?(n=typeof s=="function"?s:H(+s),d):n},d.padAngle=function(s){return arguments.length?(o=typeof s=="function"?s:H(+s),d):o},d.context=function(s){return arguments.length?(l=s??null,d):l},d}var ue=["bmsSvg"];function pe(i,t){if(i&1&&$h(0,"widget-title",1),i&2){let a=qw();Bh("text",a.displayLabel())("color",a.labelColor());}}function me(i,t){i&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No batteries detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K battery paths or select batteries in widget settings."),ul()());}var ee=class i{static BMS_DESCRIPTOR=a("widget-bms");static ROOT_PATTERN=`${i.BMS_DESCRIPTOR?.selfRootPath??"self.electrical.batteries"}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,bms:{trackedDevices:[],groups:[],banks:[]}};static VIEWBOX_WIDTH=200;static MIN_VIEWBOX_HEIGHT=1;static BANK_CARD_WIDTH=200;static BATTERY_CARD_HEIGHT=50;static BATTERY_CARD_WIDTH=200;static CARD_GAP=8;static BANK_HEADER_HEIGHT=80;static BANK_MIN_HEIGHT=75;static SINGLE_ROW_BANK_HEIGHT=100;static IN_BANK_COLUMNS=2;static IN_BANK_COLUMN_GAP=5;static IN_BANK_PADDING_X=0;static BANK_GAUGE_RADIUS=50;static BANK_GAUGE_BG_STROKE=10;static BANK_GAUGE_VALUE_STROKE=10;static COMPACT_UNASSIGNED_BATTERY_SCALE=.82;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);iconRegistry=w(K);destroyRef=w(xe);svgRef=$j.required("bmsSvg");svg;root;bankLayer;batteryLayer;bankGaugeBackgroundPath=this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,1);glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;powerAvailableIconTemplate=null;powerRenewalIconTemplate=null;discoveredBatteryIds=vt([]);trackedBatteryDeviceIds=vt([]);banks=vt([]);cardMode=vt({displayMode:"full",metrics:[]});batteries=vt({});visibleBatteryIds=Dt(()=>{let t=this.trackedBatteryDeviceIds();return t.length?t:this.discoveredBatteryIds()});visibleBatteries=Dt(()=>{let t=this.visibleBatteryIds(),a=this.batteries();return t.map(r=>a[r]).filter(r=>!!r)});bankSummaries=Dt(()=>{let t=this.banks(),a=this.batteries();return t.map(r=>this.buildBankSummary(r,a))});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let t=this.bankSummaries();if(t.length===1)return t[0].name||"Bank";if(t.length>1)return "Batteries";let a=this.visibleBatteries();return a.length!==1?"Batteries":this.resolveBatteryTitleText(a[0])});labelColor=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t).dim:"var(--kip-contrast-dim-color)"});widgetColors=Dt(()=>{let t=this.theme();return t?c(this.colorRole(),t):null});batteryDisplayModels=Dt(()=>{let t=this.visibleBatteries(),a=this.theme(),r=this.widgetColors(),e$1=this.ignoreZones(),n={};for(let o of t){let l=e(o.stateOfChargeState,r?.dimmer??"var(--kip-contrast-dimmer-color)",a,e$1),m=e(o.stateOfChargeState,r?.dim??"var(--kip-contrast-dim-color)",a,e$1),d=e(o.currentState,"var(--kip-contrast-dim-color)",a,e$1),s=e(o.currentState,"var(--kip-contrast-color)",a,e$1);n[o.id]={id:o.id,titleText:this.resolveBatteryTitleText(o),chargeWidth:(i.BATTERY_CARD_WIDTH-3)*(o.stateOfCharge??0),chargeBarColorCompact:l,chargeBarColorRegular:m,currentTextColorCompact:d,currentTextColorRegular:s,currentText:`${this.formatCurrent(o.current)}`.trim(),detailLineCompact:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`,detailLineRegular:`${this.formatVoltage(o.voltage)}\xA0\xA0\xA0\xA0${this.formatPower(o.power)}\xA0\xA0\xA0\xA0${this.formatTemperature(o.temperature)}`.trim(),socText:this.formatSoc(o.stateOfCharge),socGlowEnabled:!e$1&&(o.stateOfChargeState===n$1.Warn||o.stateOfChargeState===n$1.Alarm||o.stateOfChargeState===n$1.Alert),remainingCapacityText:o.capacityActual?`${this.formatEnergy(o.capacityRemaining)}`:"",remainingTimeText:`${this.formatDuration(o.timeRemaining)}`.trim(),iconKey:o.current!=null&&o.current>0?"power_renewal":"power_available"};}return n});bankDisplayModels=Dt(()=>{let t=this.bankSummaries(),a=this.widgetColors(),r={};for(let e of t)r[e.id]={id:e.id,titleText:e.name||"Bank",currentText:this.formatCurrent(e.totalCurrent),powerText:this.formatPower(e.totalPower),socText:this.formatSoc(e.avgSoc),remainingTimeText:`${this.formatDuration(e.timeRemaining)}`.trim(),remainingCapacityText:e.remainingCapacity?`${this.formatEnergy(e.remainingCapacity)}`:"",gaugeValuePath:this.buildSemiGaugeArcPath(i.BANK_GAUGE_RADIUS,e.avgSoc),gaugeValueColor:a?.color??"var(--kip-contrast-color)",zoneState:null,zoneColor:null};return r});hasBatteries=Dt(()=>this.visibleBatteries().length>0);hasBanks=Dt(()=>this.bankSummaries().length>0);constructor(){Fa(()=>{let a=this.runtime.options();a&&ge(()=>this.applyConfig(a));}),Fa(()=>{let a=this.bankSummaries(),r=this.visibleBatteries(),e=this.widgetColors(),n=this.batteryDisplayModels(),o=this.bankDisplayModels();!this.svg||!e||this.requestRender({banks:a,batteries:r,batteryDisplayModels:n,bankDisplayModels:o,widgetColors:e});});let t=this.data.subscribePathTreeWithInitial(i.ROOT_PATTERN);if(t.initial.length){for(let a of t.initial)this.enqueuePathUpdate(a,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}t.live$.pipe(Gp(this.destroyRef)).subscribe(a=>{this.enqueuePathUpdate(a);});}ngAfterViewInit(){this.initializeSvg(),this.loadPowerIcons(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${i.MIN_VIEWBOX_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Battery Management System View"),this.glowFilterId=`bms-soc-glow-${this.id()}`;let a=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");a.append("feFlood").attr("class","bms-soc-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),a.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),a.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let r=a.append("feMerge");r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","blur"),r.append("feMergeNode").attr("in","SourceGraphic"),this.root=this.svg.append("g").attr("class","bms-root"),this.bankLayer=this.root.append("g").attr("class","bms-banks"),this.batteryLayer=this.root.append("g").attr("class","bms-batteries");}loadPowerIcons(){this.loadNamedIcon("power_available",t=>{this.powerAvailableIconTemplate=t;}),this.loadNamedIcon("power_renewal",t=>{this.powerRenewalIconTemplate=t;});}loadNamedIcon(t,a){this.iconRegistry.getNamedSvgIcon(t).pipe(_t(1)).subscribe({next:r=>{a(r),this.requestRender();},error:()=>{}});}applyConfig(t){let a=this.resolveBmsConfig(t);this.trackedBatteryDeviceIds.set([...new Set((a.trackedDevices??[]).map(r=>r.id))]),this.banks.set(a.banks),this.cardMode.set(this.normalizeCardMode(a.cardMode));}resolveBmsConfig(t){let a=t.bms,r=this.normalizeTrackedDevices(a?.trackedDevices),e=this.normalizeBanksFromGroups(a?.groups),n=this.normalizeBanksFromLegacy(a?.banks);return {trackedDevices:r,groups:e,banks:e.length>0?e:n,cardMode:this.normalizeCardMode(a?.cardMode)}}normalizeTrackedDevices(t){if(!Array.isArray(t))return [];let a=new Map;return t.forEach(r=>{if(!r||typeof r!="object")return;let e=r,n=typeof e.id=="string"?e.id.trim():"",o=typeof e.source=="string"?e.source.trim():"default";if(!n||!o)return;let l=typeof e.key=="string"&&e.key.trim().length>0?e.key.trim():`${n}||${o}`;a.set(l,{id:n,source:o,key:l});}),[...a.values()].sort((r,e)=>r.key.localeCompare(e.key))}normalizeCardMode(t){let a=t&&typeof t=="object"?t:null,r=this.normalizeStringList(a?.metrics);return {displayMode:a?.displayMode==="compact"?"compact":"full",metrics:r}}normalizeStringList(t){if(!Array.isArray(t))return [];let a=new Set;return t.forEach(r=>{if(typeof r!="string")return;let e=r.trim();e.length>0&&a.add(e);}),[...a].sort((r,e)=>r.localeCompare(e))}normalizeBanksFromGroups(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.memberIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeBanksFromLegacy(t){return Array.isArray(t)?t.map(a=>{let r=this.normalizeOptionalString(a?.id)??`bank-${Date.now()}`,e=this.normalizeOptionalString(a?.name)??r,n=this.normalizeStringList(a?.batteryIds);return {id:r,name:e,batteryIds:n,connectionMode:this.normalizeConnectionMode(a?.connectionMode)}}).filter(a=>a.id.length>0):[]}normalizeOptionalString(t){if(typeof t!="string")return null;let a=t.trim();return a.length>0?a:null}normalizeConnectionMode(t){return t==="series"?"series":"parallel"}enqueuePathUpdate(t,a=false){let r=this.parseBatteryPath(t.path);if(!r)return;let{id:e,key:n}=r,o=t.update?.data?.value??null,l=t.update?.state??null,m=`${e}::${n}`;if(this.pendingPathUpdates.set(m,{id:e,key:n,value:o,state:l}),!a){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},i.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let t=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(t.map(r=>r.id)).forEach(r=>this.trackDiscoveredBattery(r)),this.batteries.update(r=>{let e=r,n=false;for(let o of t){let l=e[o.id]??{id:o.id},m=G({},l),d=this.applyBatteryValue(m,o.key,o.value,o.state),s=false;if(m.voltage!=null&&m.current!=null){let g=Number.isFinite(m.voltage)&&Number.isFinite(m.current)?m.voltage*m.current:null;Object.is(m.power,g)||(m.power=g,s=true);}!d&&!s||(n||(e=G({},e),n=true),e[o.id]=m);}return n?e:r});}parseBatteryPath(t){let a=t.match(/self\.electrical\.batteries\.([^.]+)\.(.+)$/);return a?{id:a[1],key:a[2]}:null}trackDiscoveredBattery(t){let a=this.discoveredBatteryIds();if(a.includes(t))return;let r=[...a,t].sort();this.discoveredBatteryIds.set(r);}applyBatteryValue(t,a,r,e){switch(a){case "name":{let n=r;return t.name===n?false:(t.name=n,true)}case "location":{let n=r;return t.location===n?false:(t.location=n,true)}case "associatedBus":{let n=r;return t.associatedBus===n?false:(t.associatedBus=n,true)}case "chemistry":{let n=r;return t.chemistry===n?false:(t.chemistry=n,true)}case "voltage":{let n=this.toNumber(r);return Object.is(t.voltage,n)?false:(t.voltage=n,true)}case "current":{let n=this.toNumber(r),o=!Object.is(t.currentState??null,e??null);return Object.is(t.current,n)&&!o?false:(t.current=n,t.currentState=e,true)}case "temperature":{let n=this.toNumber(r);return Object.is(t.temperature,n)?false:(t.temperature=n,true)}case "capacity.nominal":{let n=this.toNumber(r);return Object.is(t.capacityNominal,n)?false:(t.capacityNominal=n,true)}case "capacity.actual":{let n=this.toNumber(r);return Object.is(t.capacityActual,n)?false:(t.capacityActual=n,true)}case "capacity.remaining":{let n=this.toNumber(r);return Object.is(t.capacityRemaining,n)?false:(t.capacityRemaining=n,true)}case "capacity.stateOfCharge":{let n=this.toNumber(r),o=!Object.is(t.stateOfChargeState??null,e??null);return Object.is(t.stateOfCharge,n)&&!o?false:(t.stateOfCharge=n,t.stateOfChargeState=e,true)}case "capacity.timeRemaining":{let n=this.toNumber(r);return Object.is(t.timeRemaining,n)?false:(t.timeRemaining=n,true)}default:return false}}buildBankSummary(t,a){let r=t.batteryIds.map(s=>a[s]).filter(s=>!!s),e=this.normalizeConnectionMode(t.connectionMode),n=this.calculateBankCurrent(r,e),o=this.sumNumbers(r.map(s=>s.power)),l=this.sumNumbers(r.map(s=>s.capacityRemaining)),m=this.calculateBankSoc(r),d=this.calculateBankTimeRemaining(r,e);return {id:t.id,name:t.name,batteryIds:t.batteryIds,totalCurrent:n,totalPower:o,remainingCapacity:l,avgSoc:m,timeRemaining:d}}calculateBankSoc(t){let a=this.sumNumbers(t.map(n=>n.capacityRemaining)),r=this.sumNumbers(t.map(n=>n.capacityActual));if(a!=null&&r!=null&&r>0)return Math.max(0,Math.min(1,a/r));let e=this.sumNumbers(t.map(n=>n.capacityNominal));return a!=null&&e!=null&&e>0?Math.max(0,Math.min(1,a/e)):this.averageNumbers(t.map(n=>n.stateOfCharge))}calculateBankCurrent(t,a){let r=t.map(e=>e.current);return a==="series"?this.averageNumbers(r):this.sumNumbers(r)}calculateBankTimeRemaining(t,a){let r=t.map(e=>e.timeRemaining);return a==="series"?this.minNumber(r):this.averageNumbers(r)}requestRender(t){this.svg&&(this.pendingRenderSnapshot=t??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let a=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,a&&this.render(a);})));}buildRenderSnapshot(){let t=this.widgetColors();return t?{banks:this.bankSummaries(),batteries:this.visibleBatteries(),batteryDisplayModels:this.batteryDisplayModels(),bankDisplayModels:this.bankDisplayModels(),widgetColors:t}:null}render(t){if(!this.bankLayer||!this.batteryLayer)return;let{banks:a,batteries:r,bankDisplayModels:e,batteryDisplayModels:n,widgetColors:o}=t,l=this.buildRenderLayout(a,r,e,n,this.isCompactCardMode()),d=this.isCompactCardMode()?e$1:e$1,s=Math.max(i.MIN_VIEWBOX_HEIGHT,l.contentHeight);this.svg?.attr("viewBox",`0 0 ${i.VIEWBOX_WIDTH} ${s}`),this.root?.attr("transform",null);let g=this.bankLayer.selectAll("g.bank-card").data(l.banks,u=>u.id),c=g.enter().append("g").attr("class","bank-card"),y=c.append("text").attr("class","bank-card-power");y.append("tspan").attr("class","bank-card-power-value"),y.append("tspan").attr("class","bank-card-power-unit");let v=c.append("text").attr("class","bank-card-current");v.append("tspan").attr("class","bank-card-current-value"),v.append("tspan").attr("class","bank-card-current-unit");let k=c.append("g").attr("class","bank-gauge");k.append("path").attr("class","bank-gauge-bg"),k.append("path").attr("class","bank-gauge-value");let R=k.append("text").attr("class","bank-gauge-soc");R.append("tspan").attr("class","bank-gauge-soc-value"),R.append("tspan").attr("class","bank-gauge-soc-unit");let x=c.append("text").attr("class","bank-actualCapacity");x.append("tspan").attr("class","bank-actualCapacity-value"),x.append("tspan").attr("class","bank-actualCapacity-unit"),c.append("text").attr("class","bank-remaining"),c.append("g").attr("class","bank-bms-batteries"),c.append("text").attr("class","bank-title");let h=c.merge(g);h.attr("transform",u=>`translate(${u.x},${u.y})`),l.banks.length>1?h.select("text.bank-title").attr("x",d.titleX).attr("y",d.titleY).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",d.titleFontSize).text(u=>u.displayModel.titleText):h.select("text.bank-title").text(""),h.select("text.bank-card-current").attr("x",d.lineOneX).attr("y",d.lineOneY).attr("fill","var(--kip-contrast-color)").attr("font-size",d.lineOneFontSize),h.select("tspan.bank-card-current-value").text(u=>this.splitMetricText(u.displayModel.currentText,"A").valueText),h.select("tspan.bank-card-current-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.currentText,"A").unitText),h.select("text.bank-card-power").attr("x",5).attr("y",42).attr("fill","var(--kip-contrast-color)").attr("font-size",10).attr("opacity",.8),h.select("tspan.bank-card-power-value").text(u=>this.splitMetricText(u.displayModel.powerText,"W").valueText),h.select("tspan.bank-card-power-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.powerText,"W").unitText),h.select("g.bank-gauge").attr("transform","translate(143, 60)"),h.select("path.bank-gauge-bg").attr("d",this.bankGaugeBackgroundPath).attr("fill","none").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",i.BANK_GAUGE_BG_STROKE).attr("stroke-linecap","round"),h.select("path.bank-gauge-value").attr("d",u=>u.displayModel.gaugeValuePath).attr("fill","none").attr("stroke",u=>u.displayModel.gaugeValueColor).attr("stroke-width",i.BANK_GAUGE_VALUE_STROKE).attr("stroke-linecap","round"),h.select("text.bank-gauge-soc").attr("x",0).attr("y",-5).attr("text-anchor","middle").attr("fill","var(--kip-contrast-color)").attr("font-size",d.primaryFontSize).attr("font-weight",d.primaryFontWeight),h.select("tspan.bank-gauge-soc-value").text(u=>this.splitMetricText(u.displayModel.socText,"%").valueText),h.select("tspan.bank-gauge-soc-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text(u=>this.splitMetricText(u.displayModel.socText,"%").unitText),h.select("text.bank-remaining").attr("x",143).attr("y",26).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).text(u=>u.displayModel.remainingTimeText),h.select("text.bank-actualCapacity").attr("x",143).attr("y",66).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8),h.select("tspan.bank-actualCapacity-value").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").valueText),h.select("tspan.bank-actualCapacity-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(u=>this.splitMetricText(u.displayModel.remainingCapacityText,"kWh").unitText),h.select("g.bank-bms-batteries").each((u,N,w)=>{let B=ge$1(w[N]).selectAll("g.battery-card").data(u.batteries,p=>p.key),C=B.enter().append("g").attr("class","battery-card battery-card--in-bank");this.appendBatteryCardSkeleton(C);let I=C.merge(B);this.renderBatteryCards(I,o,t.batteries.length>1),B.exit().remove();}),g.exit().remove();let M=this.batteryLayer.selectAll("g.battery-card").data(l.unassignedBatteries,u=>u.key),T=M.enter().append("g").attr("class","battery-card battery-card--unassigned");this.appendBatteryCardSkeleton(T);let f=T.merge(M);this.renderBatteryCards(f,o,true),M.exit().remove(),this.root?.attr("data-theme","ready");}buildRenderLayout(t,a,r,e,n){let o=new Map(a.map(f=>[f.id,f])),l=new Set,m=this.computeInBankBatterySlotWidth(),d=Math.max(.35,Math.min(1,m/i.BATTERY_CARD_WIDTH)),s=i.BATTERY_CARD_HEIGHT*d,g=0,c=t.map(f=>{let u=new Set,N=f.batteryIds.map(A=>o.get(A)).filter(A=>!A||u.has(A.id)?false:(u.add(A.id),true));N.forEach(A=>l.add(A.id));let w=Math.ceil(N.length/i.IN_BANK_COLUMNS),E=i.SINGLE_ROW_BANK_HEIGHT,B=!n&&w===1,C=B?Math.max(0,E-s-i.CARD_GAP):i.BANK_HEADER_HEIGHT,I=w>0?w*s+(w-1)*i.CARD_GAP:0,p=Math.max(i.BANK_MIN_HEIGHT,C+I+i.CARD_GAP),b=B?E:p,O=N.map((A,P)=>{let K=P%i.IN_BANK_COLUMNS,V=Math.floor(P/i.IN_BANK_COLUMNS),Y=i.IN_BANK_PADDING_X+K*(m+i.IN_BANK_COLUMN_GAP),q=C+7+V*(s+i.CARD_GAP);return {id:A.id,displayModel:e[A.id],key:`${f.id}::${A.id}`,x:Y,y:q,scale:d,inBank:true,compact:true}}),U={id:f.id,name:f.name,batteryIds:f.batteryIds,totalCurrent:f.totalCurrent,totalPower:f.totalPower,avgSoc:f.avgSoc,remainingCapacity:f.remainingCapacity,timeRemaining:f.timeRemaining,displayModel:r[f.id],x:0,y:g,width:i.BANK_CARD_WIDTH,height:b,batteries:O};return g+=b+i.CARD_GAP,U}),y=c.length>0?g:0,v=n?i.COMPACT_UNASSIGNED_BATTERY_SCALE:1,k=i.BATTERY_CARD_HEIGHT*v,R=a.filter(f=>!l.has(f.id)).sort((f,u)=>f.id.localeCompare(u.id)).map((f,u)=>({id:f.id,displayModel:e[f.id],key:f.id,x:0,y:y+u*(k+i.CARD_GAP),scale:v,inBank:false,compact:n})),x=c[c.length-1],h=x?x.y+x.height:0,M=R[R.length-1],T=M?M.y+k:0;return {banks:c,unassignedBatteries:R,contentHeight:Math.max(h,T)}}computeInBankBatterySlotWidth(){return (i.BANK_CARD_WIDTH-i.IN_BANK_PADDING_X*2-i.IN_BANK_COLUMN_GAP)/i.IN_BANK_COLUMNS}appendBatteryCardSkeleton(t){t.append("rect").attr("class","bms-battery").attr("rx",4).attr("ry",4),t.append("rect").attr("class","bms-battery-tip").attr("rx",1).attr("ry",1),t.append("rect").attr("class","bms-charge-fill").attr("rx",3).attr("ry",3),t.append("g").attr("class","bms-state-icon"),t.append("text").attr("class","bms-ampere"),t.append("text").attr("class","bms-volt-power");let a=t.append("text").attr("class","bms-soc");a.append("tspan").attr("class","bms-soc-value"),a.append("tspan").attr("class","bms-soc-unit"),t.append("text").attr("class","bms-actualCapacity"),t.append("text").attr("class","bms-remaining"),t.append("text").attr("class","bms-title");}renderBatteryCards(t,a,r){t.attr("transform",e=>`translate(${e.x},${e.y}) scale(${e.scale})`),t.select("rect.bms-battery").attr("width",e=>e.inBank?i.BATTERY_CARD_WIDTH:e.compact?i.BATTERY_CARD_WIDTH-i.CARD_GAP:i.BATTERY_CARD_WIDTH).attr("height",i.BATTERY_CARD_HEIGHT).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke","var(--kip-contrast-dimmer-color)").attr("stroke-width",0),t.select("rect.bms-battery-tip").attr("x",i.BATTERY_CARD_WIDTH).attr("y",i.BATTERY_CARD_HEIGHT/2-10).attr("width",4).attr("height",20).attr("fill",e=>e.compact?"var(--mat-sys-background)":"var(--kip-contrast-dimmer-color)").attr("stroke",a.color).attr("stroke-width",0),t.select("rect.bms-charge-fill").attr("x",1.5).attr("y",1.5).attr("width",e=>e.displayModel.chargeWidth).attr("height",i.BATTERY_CARD_HEIGHT-3).attr("fill",e=>e.compact?e.displayModel.chargeBarColorCompact:e.displayModel.chargeBarColorRegular),r?t.select("text.bms-title").attr("x",5).attr("y",e=>e.compact?11:14).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",e=>e.compact?8:12).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.titleText):t.select("text.bms-title").text(""),t.select("text.bms-ampere").attr("x",10).attr("y",33).attr("fill",e=>e.compact?e.displayModel.currentTextColorCompact:e.displayModel.currentTextColorRegular).attr("font-size",16).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.displayModel.currentText),t.select("text.bms-volt-power").attr("x",10).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",8).attr("opacity",.8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?e.displayModel.detailLineCompact:e.displayModel.detailLineRegular),t.select("text.bms-soc").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",34).attr("fill",e=>e.compact?"var(--kip-contrast-dim-color)":"var(--kip-contrast-color)").attr("text-anchor","middle").attr("font-size",25).attr("font-weight",700).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null),t.select("tspan.bms-soc-value").text(e=>this.splitMetricText(e.displayModel.socText,"%").valueText),t.select("tspan.bms-soc-unit").attr("dx",1).attr("font-size",16).attr("font-weight",500).text(e=>this.splitMetricText(e.displayModel.socText,"%").unitText),t.select("text.bms-actualCapacity").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",45).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",8).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingCapacityText),t.select("text.bms-remaining").attr("x",i.BATTERY_CARD_WIDTH-33).attr("y",12).attr("fill","var(--kip-contrast-dim-color)").attr("text-anchor","middle").attr("font-size",6).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).text(e=>e.compact?"":e.displayModel.remainingTimeText),t.select("g.bms-state-icon").attr("transform",`translate(${i.BATTERY_CARD_WIDTH/2-18}, ${i.BATTERY_CARD_HEIGHT/2-18})`).attr("display",e=>e.compact&&e.scale<.45?"none":null).attr("color",e=>e.compact?a.dim:a.color).attr("filter",e=>e.displayModel.socGlowEnabled?`url(#${this.glowFilterId})`:null).each((e,n,o)=>{let l=ge$1(o[n]),m=e.displayModel.iconKey,d=m==="power_renewal"?this.powerRenewalIconTemplate:this.powerAvailableIconTemplate;if(!d){l.selectAll("*").remove(),l.attr("data-icon-key",null);return}let s=l.node();if(!s||l.attr("data-icon-key")===m&&s.firstElementChild)return;l.selectAll("*").remove();let c=d.cloneNode(true);c.removeAttribute("id"),c.setAttribute("width","36"),c.setAttribute("height","36"),c.getAttribute("viewBox")||c.setAttribute("viewBox","0 0 24 24"),s.appendChild(c),l.attr("data-icon-key",m);});}formatVoltage(t){return t==null?"-- V":`${t.toFixed(1)}V`}formatCurrent(t){return t==null?"-- A":`${t.toFixed(1)}A`}formatPower(t){return t==null?"":`${t.toFixed(0)}W`}formatEnergy(t){return t==null?"":(t=this.units.convertToUnit("kWh",t),`${t}kWh`)}formatSoc(t){return t==null?"--%":`${Math.round(t*100)}%`}resolveBatteryTitleText(t){return t.name||`Battery ${t.id}`}formatDuration(t){if(t==null)return "";let a=this.units.convertToUnit("D HH:MM:SS",t);return a==null?"":typeof a=="string"?a:`${a}`}formatTemperature(t){if(t==null||typeof t!="number")return "";let a=this.units.getDefaults().Temperature,r=this.units.convertToUnit(a,t);return r===null?"":`${r.toFixed(1)} ${a==="celsius"?"\xB0C":"\xB0F"}`}splitMetricText(t,a){if(!t)return {valueText:"",unitText:""};let r=t.trim();return r?r.endsWith(a)?{valueText:r.slice(0,Math.max(0,r.length-a.length)).trim(),unitText:a}:{valueText:r,unitText:""}:{valueText:"",unitText:""}}sumNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0):null}averageNumbers(t){let a=t.filter(r=>typeof r=="number");return a.length?a.reduce((r,e)=>r+e,0)/a.length:null}minNumber(t){let a=t.filter(r=>typeof r=="number");return a.length?Math.min(...a):null}toNumber(t){return t==null||typeof t!="number"?null:t}buildSemiGaugeArcPath(t,a){let r=Math.max(0,Math.min(1,a??0)),e=-Math.PI*.55,n=Math.PI*1.1,o=e+n*r;if(r<=0){let l=t*Math.cos(e),m=t*Math.sin(e);return `M ${l} ${m}`}return Bt()({innerRadius:t,outerRadius:t,startAngle:e,endAngle:o})??""}static \u0275fac=function(a){return new(a||i)};static \u0275cmp=JD({type:i,selectors:[["widget-bms"]],viewQuery:function(a,r){a&1&&eg(r.svgRef,ue,5),a&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:4,consts:[["bmsSvg",""],[3,"text","color"],["aria-hidden","false",1,"bms-svg"],[1,"bms-empty"],[1,"bms-empty-title"],[1,"bms-empty-sub"]],template:function(a,r){a&1&&(_w(0,pe,1,2,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),a&2&&(Mw(r.hasBanks()?0:-1),EE(),sg("bms-svg--full",!r.hasBanks()),EE(2),Mw(r.hasBatteries()?-1:3));},dependencies:[yt,x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.bms-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;padding:0 10px 10px}.bms-svg.bms-svg--full[_ngcontent-%COMP%]{top:0;height:100%;padding-top:10px}.bms-card-metric[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:30px;font-weight:700}.bms-card-sub[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:18px;opacity:.9}.bms-card-meta[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:15px;opacity:.75}.bms-card-footer[_ngcontent-%COMP%]{fill:var(--mat-sys-on-surface);font-size:16px;opacity:.8}.bms-flow-line[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color);stroke-width:3px;stroke-dasharray:6 6;animation:_ngcontent-%COMP%_flow-dash 2s linear infinite}.bms-flow-line--out[_ngcontent-%COMP%]{stroke:var(--kip-zone-warn-color)}.bms-flow-line--in[_ngcontent-%COMP%]{stroke:var(--kip-zone-nominal-color)}.bms-flow-line--neutral[_ngcontent-%COMP%]{stroke:var(--kip-widget-card-border-color);animation:none}.bms-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.bms-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.bms-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}@keyframes _ngcontent-%COMP%_flow-dash{to{stroke-dashoffset:-12}}"]})};export{ee as WidgetBmsComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {WidgetFreeboardskComponent as ae}from'./chunk-
|
|
1
|
+
import {WidgetFreeboardskComponent as ae}from'./chunk-CYYBxjrc.js';import {$ as $j,w,G as Gi,a as G$1,i as ir,v as vt,D as Dt,W as Wp,E as Em,F as Fa,J as JD,Q as Qn,z as za,q as qo,O as Op,R as Rp,y as yt,b as wt,P as Pi,_ as _w,c as $h,u as ul,d as ig,B as Bh,j as jT,e as EE,M as Mw,s as sg,f as eg,K as Kw,g as qw,h as Fw,k as Qh,l as ud,m as dd}from'./main-YKDNK5VZ.js';import'./chunk-ibauGmSP.js';var G=["panel"],Q=(i,f)=>[i,f];function j(i,f){if(i&1&&$h(0,"div",7),i&2){let t=qw();ig("transform",t.ghostTransform());}}function H(i,f){if(i&1){let t=Fw();Pi(0,"div",8),Qh("pointerdown",function(n){ud(t);let o=qw();return dd(o.startResize(n))}),Pi(1,"button",9),Qh("pointerdown",function(n){ud(t);let o=qw();return dd(o.startResize(n))}),$h(2,"mat-icon",10),ul()();}}var pt=(()=>{class i{panelEl=$j.required("panel");_settings=w(Gi);_dashboard=w(G$1);breakpointObserver=w(ir);side=vt(this._settings.getSplitShellSide());panelRatio=vt(this._settings.getSplitShellWidth());originalPanelRatio=null;panelWidth=vt(0);panelCollapsed=Dt(()=>{let t=this._dashboard.dashboards(),e=this._dashboard.activeDashboard();return e==null||e<0?false:!!t[e]?.collapseSplitShell});_fskShellSwipeDisabled=Wp(this._settings.getSplitShellSwipeDisabledAsO(),{initialValue:false});fskShellSwipeDisabled=Dt(()=>this._fskShellSwipeDisabled()??false);handset$=this.breakpointObserver.observe(Em.HandsetPortrait);handset=Wp(this.handset$,{initialValue:{matches:false,breakpoints:{}}});freeboardWidgetStub={uuid:"persistent-freeboard-shell",type:"widget-freeboardsk",config:{}};chartplotterModeInPortrait=Dt(()=>this.handset().matches&&!this.panelCollapsed());canResize=Dt(()=>!this._dashboard.isDashboardStatic()&&!this.panelCollapsed());resizing=false;startX=0;startW=0;boundMove=t=>this.onMove(t);boundUp=()=>this.onUp();static MIN_DELTA_PX=1;ghostActive=vt(false);ghostTransform=vt("");ghostWidth=0;recomputeWidth=()=>{let t=this.panelEl()?.nativeElement.parentElement;if(!t)return;let e=t.clientWidth;this.panelWidth.set(Math.round(e*this.panelRatio()));};constructor(){window.addEventListener("resize",this.recomputeWidth,{passive:true}),queueMicrotask(this.recomputeWidth),Fa(()=>{this.chartplotterModeInPortrait(),this.panelRatio(),this.recomputeWidth(),setTimeout(()=>window.dispatchEvent(new Event("resize")),0);}),Fa(()=>{let t=this._dashboard.isDashboardStatic();t||this.originalPanelRatio===null&&(this.originalPanelRatio=this.panelRatio()),t&&this.originalPanelRatio;}),Fa(()=>{if(this._dashboard.layoutEditSaved(),this.originalPanelRatio!==null){let t=this.panelRatio();this._settings.setSplitShellWidth(t),this.originalPanelRatio=null;}}),Fa(()=>{if(this._dashboard.layoutEditCanceled(),this.originalPanelRatio!==null){let t=this.originalPanelRatio;this.panelRatio.set(t),queueMicrotask(()=>this.recomputeWidth()),this.originalPanelRatio=null;}});}startResize(t){this.canResize()&&(this.resizing=true,this.startX=t.clientX,this.startW=this.panelWidth(),this.ghostWidth=this.startW,this.ghostActive.set(true),this.updateGhostTransform(this.startW),t.target.setPointerCapture(t.pointerId),window.addEventListener("pointermove",this.boundMove,{passive:true}),window.addEventListener("pointerup",this.boundUp,{passive:true}));}onMove(t){if(!this.resizing)return;let e=this.side()==="left"?t.clientX-this.startX:this.startX-t.clientX,o=this.panelEl()?.nativeElement.parentElement?.clientWidth??1,p=this.startW+e,_=o*.1,$=o*.9,v=Math.min($,Math.max(_,p));Math.abs(v-this.ghostWidth)<i.MIN_DELTA_PX||(this.ghostWidth=v,this.updateGhostTransform(v));}onUp(){if(!this.resizing)return;this.resizing=false,window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp);let t=this.ghostWidth;this.ghostActive.set(false);let e=this.panelEl();e&&!this.panelCollapsed()&&(e.nativeElement.style.width=t+"px"),this.panelWidth.set(t);let o=this.panelEl()?.nativeElement.parentElement?.clientWidth??t,p=o?t/o:.3,_=this.panelRatio();Math.abs(p-_)>5e-4&&this.panelRatio.set(p);}updateGhostTransform(t){this.side()==="left"?this.ghostTransform.set(`translateX(${t}px)`):this.ghostTransform.set(`translateX(-${t}px)`);}ngOnDestroy(){window.removeEventListener("resize",this.recomputeWidth),this.resizing&&(window.removeEventListener("pointermove",this.boundMove),window.removeEventListener("pointerup",this.boundUp));}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JD({type:i,selectors:[["split-shell"]],viewQuery:function(e,n){e&1&&eg(n.panelEl,G,5),e&2&&Kw();},decls:8,vars:18,consts:[["panel",""],[1,"split-root",3,"ngClass"],[1,"resize-ghost",3,"transform"],[1,"fsk-shell"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle"],[1,"fsk-iframe",3,"type","id","swipeDisabled","disableWidgetShell"],[1,"dash-container"],[1,"resize-ghost"],["role","separator","aria-label","Resize Freeboard chartplotter panel","aria-orientation","vertical",1,"drag-handle",3,"pointerdown"],["mat-mini-fab","","tabindex","-1","aria-hidden","true",1,"drag-fab",3,"pointerdown"],["fontIcon","drag_indicator"]],template:function(e,n){e&1&&(Pi(0,"div",1),_w(1,j,1,2,"div",2),Pi(2,"div",3,0),_w(4,H,3,0,"div",4),$h(5,"widget-freeboardsk",5),ul(),Pi(6,"div",6),$h(7,"dashboard"),ul()()),e&2&&(ig("--panel-ratio",n.panelRatio()),Bh("ngClass",jT(15,Q,n.side()==="left"?"side-left":"side-right",n.chartplotterModeInPortrait()?"portrait-column":"")),EE(),Mw(n.ghostActive()?1:-1),EE(),ig("width",n.chartplotterModeInPortrait()?null:n.panelWidth(),"px"),sg("collapsed",n.panelCollapsed())("drag-disabled",!n.canResize()),EE(2),Mw(n.canResize()?4:-1),EE(),Bh("type",n.freeboardWidgetStub.type)("id",n.freeboardWidgetStub.uuid)("swipeDisabled",n.fskShellSwipeDisabled())("disableWidgetShell",true));},dependencies:[Qn,za,ae,qo,Op,Rp,yt,wt],styles:[".split-root[_ngcontent-%COMP%]{position:relative;width:100%;height:100%;display:flex;overflow:hidden}.split-root.side-left[_ngcontent-%COMP%]{flex-direction:row}.split-root.side-right[_ngcontent-%COMP%]{flex-direction:row-reverse}.split-root.portrait-column[_ngcontent-%COMP%]{flex-direction:column}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{width:100%!important;min-height:0}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{flex:0 0 calc(var(--panel-ratio, .3) * 100%)}.split-root.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:hidden}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:2}.split-root.side-left.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:1}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .fsk-shell[_ngcontent-%COMP%]{order:2}.split-root.side-right.portrait-column[_ngcontent-%COMP%] .dash-container[_ngcontent-%COMP%]{order:1}.split-root.portrait-column[_ngcontent-%COMP%] .fsk-shell.collapsed[_ngcontent-%COMP%]{flex:0 0 0!important}.split-root.portrait-column[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%], .split-root.portrait-column[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{display:none}.fsk-shell[_ngcontent-%COMP%]{position:relative;height:100%;display:flex;flex-direction:column;background:var(--mat-sys-surface-container, #111);transition:width .2s ease}.fsk-shell.collapsed[_ngcontent-%COMP%]{width:1px!important;visibility:hidden;opacity:0;pointer-events:none}.fsk-iframe[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0}.dash-container[_ngcontent-%COMP%]{flex:1 1 auto;min-width:0;height:100%}.drag-handle[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:3px;cursor:col-resize;background:var(--mat-sys-inverse-primary);z-index:5}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:28px;min-width:28px;cursor:col-resize;pointer-events:auto}.drag-handle[_ngcontent-%COMP%] .drag-fab[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;line-height:20px}.side-left[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{right:-2px}.side-right[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{left:-2px}.drag-handle[_ngcontent-%COMP%]:hover{background:var(--mat-sys-error-container)}.side-left[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{left:.25rem}.side-right[_ngcontent-%COMP%] .collapse-toggle[_ngcontent-%COMP%]{right:.25rem}.fsk-shell.drag-disabled[_ngcontent-%COMP%] .drag-handle[_ngcontent-%COMP%]{cursor:not-allowed;opacity:.4}.resize-ghost[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;width:2px;background:var(--mat-sys-error-container);opacity:.9;pointer-events:none;z-index:30;will-change:transform;transition:none}.side-left[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{left:0}.side-right[_ngcontent-%COMP%] .resize-ghost[_ngcontent-%COMP%]{right:0}"]})}return i})();export{pt as SplitShellComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {cv as G}from'./main-
|
|
1
|
+
import {cv as G}from'./main-YKDNK5VZ.js';var e={cardCornerRadius:4,stateBarCornerRadius:2.5,titleX:0,titleY:10,titleFontSize:12.5,primaryX:135,primaryY:48,primaryFontSize:34,primaryFontWeight:700,lineOneX:5,lineOneY:30,lineOneFontSize:20,lineTwoX:10,lineTwoY:93,lineTwoFontSize:8,idX:194,idY:26,idFontSize:7.5,metaLeftX:5,metaRightX:194,metaY:63,metaFontSize:8},C=G({},e);export{C,e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {O}from'./chunk-
|
|
1
|
+
import {O}from'./chunk-x7L6DXVK.js';import {w,G as Gi,aS as De$1,cu as T,aY as xe,v as vt,D as Dt,a_ as Gp,F as Fa,cv as G,cw as z,J as JD,cx as ut,cy as He,cz as ht,cA as Te,a2 as Jt,a3 as Xt,a4 as Zt,O as Op,cB as Mt,cC as Dt$1,p as R,y as yt,b as wt,c as $h,P as Pi,X as xw,cs as Sw,u as ul,_ as _w,B as Bh,e as EE,Y as Aw,M as Mw,T as TT,h as Fw,k as Qh,l as ud,g as qw,m as dd,s as sg,aA as gg}from'./main-YKDNK5VZ.js';var te=(n,a)=>a.id;function ie(n,a){if(n&1){let e=Fw();Pi(0,"button",9),Qh("click",function(){let t=ud(e).$implicit,o=qw();return dd(o.displayDashboards(t.displayId))}),TT(1),ul();}if(n&2){let e=a.$implicit,i=qw();sg("selected",i.selectedDisplayButtonId()===e.displayId),EE(),gg(e.displayName);}}function ne(n,a){n&1&&(Pi(0,"button",5)(1,"i"),TT(2,'"No Remote"'),ul()());}function se(n,a){n&1&&(Pi(0,"div",7),$h(1,"mat-progress-spinner",10),ul());}function oe(n,a){if(n&1){let e=Fw();Pi(0,"tile-large-icon",12,0),Qh("click",function(){let t=ud(e).$index,o=qw(2);return dd(o.setActiveScreen(t))}),ul();}if(n&2){let e=a.$implicit,i=a.$index,t=qw(2);Bh("active",t.activeScreenIdx()===i)("svgIcon",e.icon)("iconSize",72)("label",e.name);}}function ae(n,a){if(n&1&&xw(0,oe,2,4,"tile-large-icon",11,te),n&2){let e=qw();Aw(e.screens());}}function re(n,a){n&1&&(Pi(0,"div",8)(1,"mat-icon",13),TT(2,"cast"),ul(),Pi(3,"div",14)(4,"p"),TT(5,"Select an available remote KIP in the menu."),ul(),Pi(6,"p"),TT(7,"To allow remote control of a dashboard, on that KIP device open Options \u2192 Display \u2192 Remote Control and enable it."),ul()()());}var De=(()=>{class n{COMMAND_REQUEST_ACTIVE_SCREEN_PATH="self.kip.remote.requestActiveScreen";_settings=w(Gi);_data=w(De$1);_requests=w(T);_destroyRef=w(xe);pageTitle="Remote Control";appID=this._settings.KipUUID;displayId=vt(null);selectedDisplayButtonId=vt(null);screensLoading=vt(false);displaysMap=vt({});selectedDisplaySub=null;selectedScreenIndexSub=null;displays=Dt(()=>Object.values(this.displaysMap()).filter(i=>i.displayId!==this.appID).sort((i,t)=>{let o=(i.displayName??"").toLowerCase(),s=(t.displayName??"").toLowerCase();return o&&s?o.localeCompare(s):o?-1:s?1:i.displayId.localeCompare(t.displayId)}));screens=vt([]);activeScreenIdx=vt(null);constructor(){this._data.subscribePathTree("self.displays.*").pipe(Gp(this._destroyRef)).subscribe(({path:e,update:i})=>{this.updateDisplayCatalog(e,i.data.value);}),Fa(()=>{let e=this.displays(),i=this.selectedDisplayButtonId();if(!e.length){this.displayDashboards(null);return}(!i||!e.some(t=>t.displayId===i))&&this.displayDashboards(e[0].displayId);}),Fa(()=>{this.rebindSelectedDisplaySubscriptions(this.displayId());});}updateDisplayCatalog(e,i){let t=this.extractDisplayId(e);if(!t||t===this.appID)return;let o=`self.displays.${t}`;this.displaysMap.update(s=>{let r=G({},s);if(e===o&&(i===null||typeof i>"u"))return delete r[t],r;let _=(r[t]??{displayName:null}).displayName;if(e===o&&i&&typeof i=="object"){let x=i;typeof x.displayName=="string"?_=x.displayName:x.displayName===null&&(_=null);}return r[t]={displayId:t,displayName:_},r});}rebindSelectedDisplaySubscriptions(e){if(this.selectedDisplaySub?.unsubscribe(),this.selectedDisplaySub=null,this.selectedScreenIndexSub?.unsubscribe(),this.selectedScreenIndexSub=null,!e){this.screensLoading.set(false),this.screens.set([]),this.activeScreenIdx.set(null);return}this.screensLoading.set(true),this.selectedDisplaySub=this._data.subscribePath(`self.displays.${e}`,"default").pipe(Gp(this._destroyRef)).subscribe(i=>{this.screensLoading.set(false);let t=i.data.value,o=Array.isArray(t?.screens)?t.screens.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string"&&typeof s.name=="string"&&typeof s.icon=="string"):[];this.screens.set(o),t&&Object.prototype.hasOwnProperty.call(t,"displayName")&&this.displaysMap.update(s=>{let r=s[e];if(!r)return s;let h=typeof t.displayName=="string"?t.displayName:t.displayName===null?null:r.displayName;return h===r.displayName?s:z(G({},s),{[e]:z(G({},r),{displayName:h})})});}),this.selectedScreenIndexSub=this._data.subscribePath(`self.displays.${e}.screenIndex`,"default").pipe(Gp(this._destroyRef)).subscribe(i=>{let t=i.data.value;this.activeScreenIdx.set(typeof t=="number"?t:null);});}extractDisplayId(e){return e.match(/^self\.displays\.([^.]+)(?:\.|$)/)?.[1]??null}displayDashboards(e){this.displayId.set(e),this.selectedDisplayButtonId.set(e);}setActiveScreen(e){let i=this.activeScreenIdx(),t=this.displayId();if(!t)return;this.activeScreenIdx.set(e),this._requests.putRequest(this.COMMAND_REQUEST_ACTIVE_SCREEN_PATH,{displayId:t,screenIdx:e},this.appID)||(console.error("Failed to set active screen: request was not accepted"),this.activeScreenIdx.set(i));}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["remote-control"]],decls:11,vars:3,consts:[["tile",""],["svgIconId","remote-control",3,"pageTitle"],[1,"sidenav-remote-control-container"],["mode","side","opened",""],["mat-list-item","","tabindex","0",3,"selected"],["mat-list-item","","tabindex","0","disabled","true",2,"text-align","center"],[1,"sidenav-remote-control-content"],["aria-label","Loading screens",1,"loading-container"],["role","status","aria-live","polite",1,"empty-state-msg"],["mat-list-item","","tabindex","0",3,"click"],["mode","indeterminate","diameter","64","strokeWidth","5"],[3,"active","svgIcon","iconSize","label"],[3,"click","active","svgIcon","iconSize","label"],["aria-hidden","true","color","primary",1,"empty-state-icon"],[1,"copy"]],template:function(i,t){i&1&&($h(0,"page-header",1),Pi(1,"mat-sidenav-container",2)(2,"mat-sidenav",3)(3,"mat-action-list"),xw(4,ie,2,3,"button",4,Sw,false,ne,3,0,"button",5),ul()(),Pi(7,"mat-sidenav-content",6),_w(8,se,2,0,"div",7)(9,ae,2,0)(10,re,8,0,"div",8),ul()()),i&2&&(Bh("pageTitle",t.pageTitle),EE(4),Aw(t.displays()),EE(4),Mw(t.screensLoading()?8:t.screens().length?9:10));},dependencies:[O,ut,He,ht,Te,Jt,Xt,Zt,Op,Mt,Dt$1,R,yt,wt],styles:[".sidenav-remote-control-container[_ngcontent-%COMP%]{height:calc(100% - 87px);width:calc(100% - 48px);margin:0 24px 24px;border:1px solid var(--mat-sys-outline-variant)}mat-sidenav[_ngcontent-%COMP%]{width:150px;--mat-sidenav-container-shape: square}.selected[_ngcontent-%COMP%]{background-color:var(--mat-sys-inverse-on-surface)}.loading-container[_ngcontent-%COMP%]{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px}.sidenav-remote-control-content[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;height:100%;width:100%;padding:5px;gap:5px;overflow-y:auto;scrollbar-width:none;overflow-x:hidden;scroll-behavior:smooth;flex:1 1 auto;min-height:0}tile-large-icon[_ngcontent-%COMP%]{width:190px}.empty-state-msg[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;align-items:center;justify-content:center;height:100%;width:calc(100% - 150px);min-height:70vh;padding:2rem;text-align:center;color:var(--mat-sys-outline-variant);font-style:italic}.empty-state-icon[_ngcontent-%COMP%]{font-size:4rem;width:4rem;height:4rem;color:var(--mat-sys-outline-variant);margin-bottom:1rem}"]})}return n})();export{De as RemoteControlComponent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {d1 as Hj,w,du as p,dY as O,a as G,W as Wp,v as vt,D as Dt,F as Fa,dn as ge,cw as z,cv as G$1,J as JD,dC as x,dT as wg,_ as _w,P as Pi,k as Qh,X as xw,cs as Sw,u as ul,dU as NT,e as EE,M as Mw,t as pT,Y as Aw,dV as Vj,cn as wd,ci as dl,cp as Uh,cV as Td,T as TT,cj as fl,an as Hh,d as ig,bp as gl,s as sg,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,dx as n$1}from'./main-
|
|
1
|
+
import {d1 as Hj,w,du as p,dY as O,a as G,W as Wp,v as vt,D as Dt,F as Fa,dn as ge,cw as z,cv as G$1,J as JD,dC as x,dT as wg,_ as _w,P as Pi,k as Qh,X as xw,cs as Sw,u as ul,dU as NT,e as EE,M as Mw,t as pT,Y as Aw,dV as Vj,cn as wd,ci as dl,cp as Uh,cV as Td,T as TT,cj as fl,an as Hh,d as ig,bp as gl,s as sg,c as $h,g as qw,dX as xT,B as Bh,cS as pl,cT as hl,dx as n$1}from'./main-YKDNK5VZ.js';import {u}from'./chunk-CCfhzpE8.js';import {c}from'./chunk-BIb-xYiS.js';var ne=(()=>{class o{data=Hj(null,{alias:"controlData"});theme=Hj(null);dimensions=Hj.required();toggleClick=Vj();ctrlLabelColor=vt("");ctrlStateColor=vt("");messageTxtColor=vt("");shouldEmergencyBlink=Dt(()=>(this.data()?.notificationState??"").toLowerCase()==="emergency");shouldAlarmBlink=Dt(()=>(this.data()?.notificationState??"").toLowerCase()==="alarm");constructor(){Fa(()=>{let t=this.data(),e=this.theme();!t||!e||ge(()=>{switch(t.notificationState){case n$1.Emergency:this.ctrlStateColor.set(e.zoneEmergency),this.messageTxtColor.set(e.background);break;case n$1.Alarm:this.ctrlStateColor.set(e.zoneAlarm),this.messageTxtColor.set(e.background);break;case n$1.Warn:this.ctrlStateColor.set(e.zoneWarn),this.messageTxtColor.set(e.background);break;case n$1.Alert:this.ctrlStateColor.set(e.zoneAlert),this.messageTxtColor.set(e.background);break;default:this.ctrlStateColor.set(e.background),this.messageTxtColor.set(c(t.color,e).dim);break}this.ctrlLabelColor.set(c(t.color,e).color);});});}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["app-svg-zone-states"]],inputs:{data:[1,"controlData","data"],theme:[1,"theme"],dimensions:[1,"dimensions"]},outputs:{toggleClick:"toggleClick"},decls:12,vars:14,consts:[["viewBox","0 0 180 75","version","1.1","id","svg9","xmlns","http://www.w3.org/2000/svg",0,"xmlns","svg","http://www.w3.org/2000/svg"],["id","defs9"],["id","zoneStateCtrl"],["id","touchRect","width","180","height","75","x","0","y","0","pointer-events","all",2,"display","inline","opacity","1","fill","transparent","fill-opacity","1","stroke","none","stroke-width","0","stroke-dasharray","none","stroke-opacity","0"],["x","0","y","0","width","180","height","20"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","180px","height","20px","display","flex","align-items","center","justify-content","center","font-weight","bold","font-size","14px","line-height","1.1","text-align","center","overflow","hidden","word-break","break-word","white-space","normal"],["id","outlineRect","x","6","y","22","width","168","height","43","rx","3.5","fill","none",2,"display","inline","opacity","1","mix-blend-mode","normals","stroke-width","1","stroke-dasharray","none","stroke-opacity","0.65"],["id","innerRect","x","7","y","23","width","166","height","41","rx","3.5",2,"display","inline","opacity","1","mix-blend-mode","normal","stroke","none","stroke-width","0"],["x","7","y","23","width","166","height","41"],["xmlns","http://www.w3.org/1999/xhtml",2,"width","166px","height","41px","display","flex","align-items","center","justify-content","center","font-weight","regular","font-size","12px","line-height","1.1","text-align","center","overflow","hidden","word-break","break-word","white-space","normal","padding","2px"]],template:function(e,i){e&1&&(wd(),dl(0,"svg",0),Uh(1,"defs",1),dl(2,"g",2),Uh(3,"rect",3),dl(4,"foreignObject",4),Td(),dl(5,"div",5),TT(6),fl()(),wd(),Uh(7,"rect",6)(8,"rect",7),dl(9,"foreignObject",8),Td(),dl(10,"div",9),TT(11),fl()()()()),e&2&&(Hh("height",i.dimensions().height)("width",i.dimensions().width),EE(5),ig("color",i.ctrlLabelColor()),EE(),gl(" ",i.data()?.ctrlLabel," "),EE(),Hh("stroke",i.ctrlLabelColor()),EE(),sg("emergency-blink-fill",i.shouldEmergencyBlink())("alarm-blink-fill",i.shouldAlarmBlink()),Hh("fill",i.ctrlStateColor()),EE(2),ig("color",i.messageTxtColor()),EE(),gl(" ",i.data()?.notificationMessage," "));},styles:["@keyframes _ngcontent-%COMP%_AlarmBlinkFill{0%,49%{opacity:1}50%,to{opacity:.6}}.alarm-blink-fill[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_AlarmBlinkFill 1s step-end infinite}@keyframes _ngcontent-%COMP%_EmergencyBlinkFill{0%,49%{opacity:1}50%,to{opacity:.1}}.emergency-blink-fill[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_EmergencyBlinkFill .3s step-end infinite}"]})}return o})();function se(o,f){if(o&1&&$h(0,"widget-title",1),o&2){let t=qw(),e=xT(0);Bh("text",(e==null?null:e.displayName)??"")("color",t.labelColor());}}function re(o,f){if(o&1&&$h(0,"app-svg-zone-states",4),o&2){let t=qw().$implicit,e=qw();Bh("controlData",t)("theme",e.theme())("dimensions",e.ctrlDimensions());}}function le(o,f){if(o&1&&(pl(0),_w(1,re,1,3,"app-svg-zone-states",4),hl()),o&2){let e=f.$implicit;EE(),Mw((e.type)==="4"?1:-1);}}function ce(o,f){o&1&&$h(0,"div",3);}var _e=(()=>{class o{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={displayName:"Zones State Panel Label",showLabel:true,filterSelfPaths:true,paths:[],enableTimeout:false,dataTimeout:5,color:"contrast",putEnable:false,zonesOnlyPaths:true,putMomentary:false,multiChildCtrls:[]};runtime=w(p,{optional:true});notificationsService=w(O);dashboard=w(G);notifications=Wp(this.notificationsService.observeNotifications());zonesControls=vt([]);labelColor=vt("");noTitleClass=Dt(()=>this.runtime?.options()?.showLabel===false?"widgets-container-no-title":"widgets-container");pathIdToNotificationPath=new Map;hostSize=vt(null);ctrlDimensions=Dt(()=>{let t=this.hostSize();if(!t)return {width:0,height:0};let e=Math.max(1,this.zonesControls().length),i=t.height/e,n=75*t.width/180,s=Math.min(n,i);return {width:t.width,height:s}});constructor(){Fa(()=>{let t=this.theme(),e=this.runtime?.options();!t||!e||ge(()=>{this.labelColor.set(c(e.color??"contrast",t).dim);});}),Fa(()=>{let t=this.runtime?.options();t&&ge(()=>{let e=(t.multiChildCtrls||[]).map(n=>z(G$1({},n),{isNumeric:n.isNumeric??false}));this.zonesControls.set(e);let i=t.paths;if(i?.length){this.pathIdToNotificationPath.clear();for(let n of i){if(!n?.pathID||!n?.path)continue;let s=n.path.replace(/^self(\.|$)/,"notifications$1");this.pathIdToNotificationPath.set(n.pathID,s);}this.applyNotificationsSnapshot(this.notifications());}});}),Fa(()=>{let t=this.notifications();ge(()=>this.applyNotificationsSnapshot(t));});}applyNotificationsSnapshot(t){if(!this.pathIdToNotificationPath.size||!t?.length)return;let e=new Map;for(let i of t)i?.path&&e.set(i.path,i);this.zonesControls.update(i=>{let n=null;for(let s=0;s<i.length;s++){let u=i[s],B=this.pathIdToNotificationPath.get(u.pathID),_=B?e.get(B):void 0;if(!_)continue;let I=_.value?.state,A=_.value?.message;u.notificationState===I&&u.notificationMessage===A||(n||(n=[...i]),n[s]=z(G$1({},u),{notificationState:I,notificationMessage:A}));}return n??i});}onResized(t){this.hostSize.set({width:t.contentRect.width,height:t.contentRect.height});}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JD({type:o,selectors:[["widget-zones-state-panel"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:7,vars:5,consts:[["widgetContainer",""],[3,"text","color"],["kipResizeObserver","",3,"resizeChange"],[1,"widgetOverlay"],[1,"svg-widget",3,"controlData","theme","dimensions"]],template:function(e,i){if(e&1&&(wg(0),_w(1,se,1,2,"widget-title",1),Pi(2,"div",2,0),Qh("resizeChange",function(s){return i.onResized(s)}),xw(4,le,2,1,"ng-container",null,Sw),ul(),_w(6,ce,1,0,"div",3)),e&2){let n=NT(i.runtime==null?null:i.runtime.options());EE(),Mw(n?.showLabel?1:-1),EE(),pT(i.noTitleClass()),EE(2),Aw(i.zonesControls()),EE(2),Mw(i.dashboard.isDashboardStatic()?-1:6);}},dependencies:[u,ne,x],styles:[".widgets-container[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20}.widgets-container-no-title[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;padding:6px 0 0;height:100%;width:100%;overflow:hidden;z-index:20}.svg-widget[_ngcontent-%COMP%]{display:flex}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})}return o})();
|
|
2
2
|
export{_e as WidgetZonesStatePanelComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,D as Dt$1}from'./chunk-
|
|
1
|
+
import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,D as Dt$1}from'./chunk-q9NoPvcx.js';import {u}from'./chunk-CCfhzpE8.js';import {k}from'./chunk-B0eE4udE.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,bu as ut,$ as $j,a6 as Lr,v as vt,D as Dt,dx as n$1,cw as z,cv as G,F as Fa,dn as ge$1,J as JD,_ as _w,M as Mw,f as eg,K as Kw,h as Fw,P as Pi,k as Qh,u as ul,g as qw,B as Bh,an as Hh,l as ud,m as dd}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var Z=["linearGauge"];function Q(s,H){if(s&1){let t=Fw();Pi(0,"linear-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(s&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ge=(()=>{class s{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);unitsService=w(ut);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{lower:0,upper:100,type:"linear"},gauge:{type:"ngLinear",subType:"vertical",highlightsWidth:5,enableTicks:true,enableNeedle:false},numInt:1,numDecimal:0,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};ngGauge=$j("linearGauge");gauge=$j("linearGauge",{read:Lr});textValue=vt("--");value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);gaugeOptions={};viewReady=vt(false);gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());currentState=vt(n$1.Normal);normalizedConfig=Dt(()=>this.runtime.options()??s.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);normalizedScale=Dt(()=>{let t=this.normalizedConfig().displayScale??s.DEFAULT_CONFIG.displayScale;return z(G({},t),{lower:t.lower??0,upper:t.upper??100})});adjustedScale=Dt(()=>{let t=this.normalizedConfig(),i=this.normalizedScale();return t.gauge?.enableTicks?p$1(i.lower,i.upper):{min:i.lower,max:i.upper,majorTicks:[]}});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();return t?.length?a?i.ignoreZones?[]:e?k(t,a,e.convertUnitTo??"",this.unitsService,this.adjustedScale().min,this.adjustedScale().max):[]:[]:[]});displayName=Dt(()=>this.normalizedConfig().displayName||"Gauge Label");constructor(){Fa(()=>{this.normalizedConfig();let i=this.theme(),a=this.gaugePathConfig(),e=this.normalizedScale();!i||!a?.path||ge$1(()=>this.streams.observe("gaugePath",o=>{let n=o?.data?.value??null;if(n==null)this.value.set(e.lower),this.textValue.set("--");else {let r=Math.min(Math.max(n,e.lower),e.upper);this.value.set(r),this.textValue()==="--"&&this.textValue.set("");}o.state!==this.currentState()&&this.currentState.set(o.state);}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge$1(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge$1(()=>{try{if(!t.length)this.ngGauge()?.update({highlights:[]});else {let i=JSON.stringify(t);this.ngGauge()?.update({highlights:i,highlightsWidth:this.normalizedConfig().gauge?.highlightsWidth});}}catch(i){}});}),Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.adjustedScale();i&&ge$1(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions),this.applyInitialSize();}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge$1(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.currentState();this.viewReady()&&ge$1(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=i.gauge?.enableNeedle,n=c(i.color??"contrast",a);switch(t){case n$1.Alarm:o?(e.colorNeedle=a.zoneAlarm,e.colorValueText=a.zoneAlarm):(e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm);break;case n$1.Warn:o?(e.colorNeedle=a.zoneWarn,e.colorValueText=a.zoneWarn):(e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn);break;case n$1.Alert:o?(e.colorNeedle=a.zoneAlert,e.colorValueText=a.zoneAlert):(e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert);break;default:o?(e.colorNeedle=n.color,e.colorValueText=n.color):(e.colorBarProgress=n.color,e.colorValueText=n.color);}try{this.ngGauge()?.update(e);}catch(r){}});});}buildGaugeOptions(t,i,a){let e=this.gaugeOptions={},o=t.gauge?.subType==="vertical",n=t.gauge?.enableNeedle,r=t.gauge?.enableTicks,m=this.gaugePathConfig();e.minValue=a.min,e.maxValue=a.max,e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.title=this.displayName(),e.fontTitleSize=40,e.fontTitle="Roboto",e.fontTitleWeight="bold",e.barLength=o?80:90,e.barWidth=r?n?0:30:60,e.barProgress=true,e.barBeginCircle=0,e.barStrokeWidth=0,e.barShadow=0,e.needle=!!n,e.needleType=n?"arrow":"line",e.needleStart=n?o?200:155:-45,e.needleEnd=n?o?175:180:55,e.needleShadow=true,e.needleSide="both",e.units=m?.convertUnitTo??"",e.fontUnits="Roboto",e.fontUnitsWeight="normal",e.borders=false,e.borderOuterWidth=0,e.borderMiddleWidth=0,e.borderInnerWidth=0,e.borderShadowWidth=0,e.borderRadius=0,e.valueBox=true,e.valueBoxWidth=35,e.valueBoxStroke=0,e.valueBoxBorderRadius=10,e.colorValueBoxRect="",e.colorValueBoxRectEnd="",e.colorValueBoxShadow="",e.fontValueSize=50,e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.fontNumbers="Roboto",e.fontNumbersWeight="normal",e.fontUnitsSize=o?40:35,e.colorTitle=c("contrast",i).dim,e.colorUnits=c("contrast",i).dim,e.colorValueBoxBackground=i.background;let u=c(t.color??"contrast",i);e.colorValueText=u.color,n?(e.colorNeedle=u.color,e.colorNeedleEnd=u.color,e.needleWidth=45,e.colorNeedleShadowUp=u.color,e.colorNeedleShadowDown=u.color):(e.colorBarProgress=u.color,e.colorBarProgressEnd="",e.needleWidth=0),e.colorPlate=i.cardColor,e.colorBar=i.background,e.colorBarEnd="",e.colorBarStroke="0",e.colorMajorTicks=c("contrast",i).dim,e.colorMinorTicks=c("contrast",i).dim,e.colorNumbers=c("contrast",i).dim,e.majorTicks=r?a.majorTicks:[],e.majorTicksInt=t.numInt??1,e.majorTicksDec=t.numDecimal??2,e.strokeTicks=!!r,e.minorTicks=r?2:0,e.ticksWidthMinor=r?6:0,e.numberSide=n?"right":"left",e.fontNumbersSize=r?o?22:30:0,e.numbersMargin=o?n?-7:-3:n?-33:-5,e.ticksWidth=r?n&&o?15:10:0,e.ticksPadding=r?o?n?0:5:n?9:8:0,e.tickSide="left",e.animation=this.animationEnabled(),e.animationRule="linear",e.animatedValue=this.animationEnabled(),e.animateOnInit=false,e.animationDuration=(m?.sampleTime??500)-25,e.highlights=[],e.highlightsWidth=t.gauge?.highlightsWidth;let N=this.highlights();N.length&&(e.highlights=JSON.stringify(N));}ngAfterViewInit(){this.viewReady.set(true),this.applyInitialSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}applyInitialSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a=.3,e,o;this.normalizedConfig().gauge?.subType==="vertical"?(e=i.height,o=i.height*a):(o=i.width,e=i.width*a);let m={height:e,width:o};try{this.ngGauge()?.update(m);}catch(u){}}onResized(t){let i=this.normalizedConfig(),a=.3,e=i.gauge?.subType==="vertical",o=0,n=0;e?(n=t.contentRect.height,o=n*a,o>t.contentRect.width&&(o=t.contentRect.width,n=o/a)):(o=t.contentRect.width,n=o*a,n>t.contentRect.height&&(n=t.contentRect.height,o=n/a));let r={width:o,height:n-10};try{this.ngGauge()?.update(r);}catch(m){}}static \u0275fac=function(i){return new(i||s)};static \u0275cmp=JD({type:s,selectors:[["widget-gauge-ng-linear"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,Z,5)(a.gauge,Z,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["linearGauge",""],["kipResizeObserver","",1,"linearGauge",3,"options","value"],["kipResizeObserver","",1,"linearGauge",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,Q,2,3,"linear-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Dt$1],styles:["[_nghost-%COMP%]{width:100%;height:100%;display:block} linear-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} linear-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);margin-top:5px}"]})}return s})();export{ge as WidgetGaugeNgLinearComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {u}from'./chunk-BgyxBAyq.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,v as vt,D as Dt,F as Fa,dn as ge,J as JD,P as Pi,c as $h,u as ul,e as EE,B as Bh,bu as ut,aZ as R,$ as $j,dx as n$1,ay as lv,k as Qh,T as TT,dQ as AT,f as eg,K as Kw}from'./main-BNR44HGB.js';var Q=["gaugeCanvas"];typeof steelseries>"u"&&(globalThis.steelseries={BackgroundColor:{DARK_GRAY:"darkGray",SATIN_GRAY:"satinGray",LIGHT_GRAY:"lightGray",WHITE:"white",BLACK:"black",BEIGE:"beige",BROWN:"brown",RED:"red",GREEN:"green",BLUE:"blue",ANTHRACITE:"anthracite",MUD:"mud",PUNCHED_SHEET:"punchedSheet",CARBON:"carbon",STAINLESS:"stainless",BRUSHED_METAL:"brushedMetal",BRUSHED_STAINLESS:"brushedStainless",TURNED:"turned"},FrameDesign:{BLACK_METAL:"blackMetal",METAL:"metal",SHINY_METAL:"shinyMetal",BRASS:"brass",STEEL:"steel",CHROME:"chrome",GOLD:"gold",ANTHRACITE:"anthracite",TILTED_GRAY:"tiltedGray",TILTED_BLACK:"tiltedBlack",GLOSSY_METAL:"glossyMetal"}});var z={darkGray:steelseries.BackgroundColor.DARK_GRAY,satinGray:steelseries.BackgroundColor.SATIN_GRAY,lightGray:steelseries.BackgroundColor.LIGHT_GRAY,white:steelseries.BackgroundColor.WHITE,black:steelseries.BackgroundColor.BLACK,beige:steelseries.BackgroundColor.BEIGE,brown:steelseries.BackgroundColor.BROWN,red:steelseries.BackgroundColor.RED,green:steelseries.BackgroundColor.GREEN,blue:steelseries.BackgroundColor.BLUE,anthracite:steelseries.BackgroundColor.ANTHRACITE,mud:steelseries.BackgroundColor.MUD,punchedSheet:steelseries.BackgroundColor.PUNCHED_SHEET,carbon:steelseries.BackgroundColor.CARBON,stainless:steelseries.BackgroundColor.STAINLESS,brushedMetal:steelseries.BackgroundColor.BRUSHED_METAL,brushedStainless:steelseries.BackgroundColor.BRUSHED_STAINLESS,turned:steelseries.BackgroundColor.TURNED},k={blackMetal:steelseries.FrameDesign.BLACK_METAL,metal:steelseries.FrameDesign.METAL,shinyMetal:steelseries.FrameDesign.SHINY_METAL,brass:steelseries.FrameDesign.BRASS,steel:steelseries.FrameDesign.STEEL,chrome:steelseries.FrameDesign.CHROME,gold:steelseries.FrameDesign.GOLD,anthracite:steelseries.FrameDesign.ANTHRACITE,tiltedGray:steelseries.FrameDesign.TILTED_GRAY,tiltedBlack:steelseries.FrameDesign.TILTED_BLACK,glossyMetal:steelseries.FrameDesign.GLOSSY_METAL},q=(()=>{class l{unitsService=w(ut);canvasService=w(R);canvasRef=$j("gaugeCanvas");widgetUUID=Hj();subType=Hj();barGauge=Hj();radialSize=Hj();backgroundColor=Hj();frameColor=Hj();minValue=Hj();maxValue=Hj();decimals=Hj();zones=Hj();title=Hj();units=Hj();value=Hj();theme=Hj(void 0,{alias:"themeColors"});gaugeStarted=false;gauge=null;gaugeOptions={};latestSizeOptions={};paddingTop=0;lastSizeSignature="";resizeTimer=null;pendingStructuralRebuild=false;ngOnInit(){this.buildOptions();}buildOptions(){this.gaugeOptions={};let e=this.minValue()??0,i=this.maxValue()??100;this.gaugeOptions.minValue=e,this.gaugeOptions.maxValue=i;let t=this.decimals();this.gaugeOptions.lcdDecimals=t??2,this.gaugeOptions.titleString=this.title()??"",this.gaugeOptions.unitString=this.units()??"",this.subType()=="radial"&&(this.gaugeOptions.gaugeType=this.setGaugeType(this.radialSize()));let s=this.zones();if(s){let r=this.theme(),u={emergency:r?.zoneEmergency??"rgba(0,0,0,0)",alarm:r?.zoneAlarm??"rgba(0,0,0,0)",warn:r?.zoneWarn??"rgba(0,0,0,0)",alert:r?.zoneAlert??"rgba(0,0,0,0)",nominal:r?.zoneNominal??"rgba(0,0,0,0)"},d=[],b=[],D=[...s].sort((C,m)=>(C.lower??Number.NEGATIVE_INFINITY)-(m.lower??Number.NEGATIVE_INFINITY));for(let C of D){let m=C.lower,S=C.upper;if(m===void 0||S===void 0)continue;let c=m,p=S,g;switch(C.state){case n$1.Emergency:g=u.emergency;break;case n$1.Alarm:g=u.alarm;break;case n$1.Warn:g=u.warn;break;case n$1.Alert:g=u.alert;break;case n$1.Nominal:g=u.nominal;break;default:g="rgba(0,0,0,0)";}let G=this.units();if(G=="ratio"?(c=m,p=S):(c=this.unitsService.convertToUnit(G??"",m)??m,p=this.unitsService.convertToUnit(G??"",S)??S),!(p<e||c>i)){if(c=Math.max(c,e),p>i){p=i,d.push(steelseries.Section(c,p,g));break}d.push(steelseries.Section(c,p,g));}}this.gaugeOptions.section=d,this.gaugeOptions.area=b,this.gaugeOptions.useSectionColors=true;}let n=this.backgroundColor();n&&n in z&&(this.gaugeOptions.backgroundColor=z[n]);let o=this.frameColor();o&&o in k&&(this.gaugeOptions.frameDesign=k[o]),this.barGauge()&&(this.gaugeOptions.valueColor=steelseries.ColorDef.GREEN),this.gaugeOptions.lcdVisible=true,this.gaugeOptions.thresholdVisible=false,this.gaugeOptions.threshold=this.maxValue(),this.gaugeOptions.ledVisible=false,Object.assign(this.gaugeOptions,this.latestSizeOptions);}setGaugeType(e){switch(e){case "quarter":return steelseries.GaugeType.TYPE1;case "half":return steelseries.GaugeType.TYPE2;case "three-quarter":return steelseries.GaugeType.TYPE3;default:return steelseries.GaugeType.TYPE4}}startGauge(e=false){this.buildOptions();let i=this.widgetUUID();if(!i)return;let t=e||this.pendingStructuralRebuild;if(this.gauge&&!t){this.gauge.setValueAnimated&&this.value()!=null,this.gaugeStarted=true;return}this.pendingStructuralRebuild=false,this.gaugeStarted=true;let s=this.subType();s==="radial"?this.gauge=new steelseries.Radial(i,this.gaugeOptions):s==="linear"&&(this.barGauge()?this.gauge=new steelseries.LinearBargraph(i,this.gaugeOptions):this.gauge=new steelseries.Linear(i,this.gaugeOptions));}onResized(e){if(e.contentRect.height<50||e.contentRect.width<50)return;let i;if(this.subType()==="radial"){let t=Math.floor(Math.min(e.contentRect.height,e.contentRect.width));this.latestSizeOptions={size:t},this.gaugeOptions.size=t,i="radial:"+t;}else {let t=Math.floor(e.contentRect.width),s=Math.floor(e.contentRect.height);this.latestSizeOptions={width:t,height:s},this.gaugeOptions.width=t,this.gaugeOptions.height=s,i=`linear:${t}x${s}`;}i!==this.lastSizeSignature&&(this.lastSizeSignature=i,this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>{this.startGauge(true),this.resizeTimer=null;},120));}ngOnChanges(e){this.gaugeStarted&&(e.value&&!e.value.firstChange&&e.value.currentValue!=null&&this.gauge?.setValueAnimated?.(e.value.currentValue),e.zones&&(this.pendingStructuralRebuild=true,this.startGauge(true)),e.title&&this.gauge?.setTitleString?.(e.title.currentValue??""),e.backgroundColor&&e.backgroundColor.currentValue in z&&this.gauge?.setBackgroundColor?.(z[e.backgroundColor.currentValue]),e.frameColor&&e.frameColor.currentValue in k&&this.gauge?.setFrameDesign?.(k[e.frameColor.currentValue]),e.radialSize&&(this.pendingStructuralRebuild=true,this.startGauge(true)),e.minValue&&e.minValue.currentValue!=null&&this.gauge?.setMinValue?.(e.minValue.currentValue),e.maxValue&&e.maxValue.currentValue!=null&&this.gauge?.setMaxValue?.(e.maxValue.currentValue));}ngOnDestroy(){if(this.gauge&&this.gauge.setValue){let i=this.gauge.getValue?this.gauge.getValue():this.value();this.gauge.setValue(i??0);}let e=this.widgetUUID();if(e){let i=document.getElementById(e);this.canvasService.releaseCanvas(i,{clear:true,removeFromDom:true});}this.gauge=null;}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["gauge-steel"]],viewQuery:function(i,t){i&1&&eg(t.canvasRef,Q,5),i&2&&Kw();},inputs:{widgetUUID:[1,"widgetUUID"],subType:[1,"subType"],barGauge:[1,"barGauge"],radialSize:[1,"radialSize"],backgroundColor:[1,"backgroundColor"],frameColor:[1,"frameColor"],minValue:[1,"minValue"],maxValue:[1,"maxValue"],decimals:[1,"decimals"],zones:[1,"zones"],title:[1,"title"],units:[1,"units"],value:[1,"value"],theme:[1,"themeColors","theme"]},features:[lv],decls:4,vars:2,consts:[["gaugeCanvas",""],["kipResizeObserver","",1,"wrapper",3,"resizeChange"],[2,"z-index","inherit",3,"id"]],template:function(i,t){i&1&&(Pi(0,"div",1),Qh("resizeChange",function(n){return t.onResized(n)}),Pi(1,"canvas",2,0),TT(3," Browser does not support canvas element. "),ul()()),i&2&&(EE(),Bh("id",AT(t.widgetUUID())));},dependencies:[u],styles:[".sgWrapper[_ngcontent-%COMP%]{height:100%;width:100%;text-align:center}"]})}return l})();var ue=(()=>{class l{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{type:"linear",lower:0,upper:100},gauge:{type:"steel",subType:"radial",backgroundColor:"carbon",faceColor:"anthracite",radialSize:"full",rotateFace:false,digitalMeter:false},numDecimal:2,enableTimeout:false,dataTimeout:5,ignoreZones:false};dataValue=vt(0);zones=vt([]);normalizedConfig=Dt(()=>this.runtime.options()??l.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);displayName=Dt(()=>this.normalizedConfig().displayName||"Gauge Label");gaugeUnits=Dt(()=>this.gaugePathConfig()?.convertUnitTo??"");constructor(){Fa(()=>{let e=this.normalizedConfig();this.gaugePathConfig()?.path&&ge(()=>this.streams.observe("gaugePath",t=>{let s=t?.data?.value,n=e.displayScale?.lower??0,o=e.displayScale?.upper??n+100;if(s==null)this.dataValue.set(n);else {let r=Math.min(Math.max(s,n),o);this.dataValue.set(r);}}));}),Fa(()=>{if(this.normalizedConfig().ignoreZones){this.zones.set([]);return}if(!this.gaugePathConfig()?.path){this.zones.set([]);return}ge(()=>this.metadata.observe("gaugePath")),this.zones.set(this.metadata.zones());});}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-gauge-steel"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:14,consts:[[1,"wrapper"],[3,"widgetUUID","subType","barGauge","radialSize","backgroundColor","frameColor","minValue","maxValue","decimals","zones","title","units","value","themeColors"]],template:function(i,t){if(i&1&&(Pi(0,"div",0),$h(1,"gauge-steel",1),ul()),i&2){let s,n,o,r,u,d,b,D;EE(),Bh("widgetUUID",t.id())("subType",(s=t.runtime.options())==null||s.gauge==null?null:s.gauge.subType)("barGauge",(n=t.runtime.options())==null||n.gauge==null?null:n.gauge.digitalMeter)("radialSize",(o=t.runtime.options())==null||o.gauge==null?null:o.gauge.radialSize)("backgroundColor",(r=t.runtime.options())==null||r.gauge==null?null:r.gauge.backgroundColor)("frameColor",(u=t.runtime.options())==null||u.gauge==null?null:u.gauge.faceColor)("minValue",(d=t.runtime.options())==null||d.displayScale==null?null:d.displayScale.lower)("maxValue",(b=t.runtime.options())==null||b.displayScale==null?null:b.displayScale.upper)("decimals",(D=t.runtime.options())==null?null:D.numDecimal)("zones",t.zones())("title",t.displayName())("units",t.gaugeUnits())("value",t.dataValue())("themeColors",t.theme());}},dependencies:[q],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}gauge-steel[_ngcontent-%COMP%]{display:block;position:relative;width:100%;height:100%} .wrapper{display:block;position:relative;width:100%;height:100%;padding:10px} .wrapper>canvas{display:block;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}"]})}return l})();export{ue as WidgetSteelGaugeComponent};
|
|
1
|
+
import {u}from'./chunk-CCfhzpE8.js';import {d1 as Hj,w,du as p,dv as rt,dD as _,v as vt,D as Dt,F as Fa,dn as ge,J as JD,P as Pi,c as $h,u as ul,e as EE,B as Bh,bu as ut,aZ as R,$ as $j,dx as n$1,ay as lv,k as Qh,T as TT,dQ as AT,f as eg,K as Kw}from'./main-YKDNK5VZ.js';var Q=["gaugeCanvas"];typeof steelseries>"u"&&(globalThis.steelseries={BackgroundColor:{DARK_GRAY:"darkGray",SATIN_GRAY:"satinGray",LIGHT_GRAY:"lightGray",WHITE:"white",BLACK:"black",BEIGE:"beige",BROWN:"brown",RED:"red",GREEN:"green",BLUE:"blue",ANTHRACITE:"anthracite",MUD:"mud",PUNCHED_SHEET:"punchedSheet",CARBON:"carbon",STAINLESS:"stainless",BRUSHED_METAL:"brushedMetal",BRUSHED_STAINLESS:"brushedStainless",TURNED:"turned"},FrameDesign:{BLACK_METAL:"blackMetal",METAL:"metal",SHINY_METAL:"shinyMetal",BRASS:"brass",STEEL:"steel",CHROME:"chrome",GOLD:"gold",ANTHRACITE:"anthracite",TILTED_GRAY:"tiltedGray",TILTED_BLACK:"tiltedBlack",GLOSSY_METAL:"glossyMetal"}});var z={darkGray:steelseries.BackgroundColor.DARK_GRAY,satinGray:steelseries.BackgroundColor.SATIN_GRAY,lightGray:steelseries.BackgroundColor.LIGHT_GRAY,white:steelseries.BackgroundColor.WHITE,black:steelseries.BackgroundColor.BLACK,beige:steelseries.BackgroundColor.BEIGE,brown:steelseries.BackgroundColor.BROWN,red:steelseries.BackgroundColor.RED,green:steelseries.BackgroundColor.GREEN,blue:steelseries.BackgroundColor.BLUE,anthracite:steelseries.BackgroundColor.ANTHRACITE,mud:steelseries.BackgroundColor.MUD,punchedSheet:steelseries.BackgroundColor.PUNCHED_SHEET,carbon:steelseries.BackgroundColor.CARBON,stainless:steelseries.BackgroundColor.STAINLESS,brushedMetal:steelseries.BackgroundColor.BRUSHED_METAL,brushedStainless:steelseries.BackgroundColor.BRUSHED_STAINLESS,turned:steelseries.BackgroundColor.TURNED},k={blackMetal:steelseries.FrameDesign.BLACK_METAL,metal:steelseries.FrameDesign.METAL,shinyMetal:steelseries.FrameDesign.SHINY_METAL,brass:steelseries.FrameDesign.BRASS,steel:steelseries.FrameDesign.STEEL,chrome:steelseries.FrameDesign.CHROME,gold:steelseries.FrameDesign.GOLD,anthracite:steelseries.FrameDesign.ANTHRACITE,tiltedGray:steelseries.FrameDesign.TILTED_GRAY,tiltedBlack:steelseries.FrameDesign.TILTED_BLACK,glossyMetal:steelseries.FrameDesign.GLOSSY_METAL},q=(()=>{class l{unitsService=w(ut);canvasService=w(R);canvasRef=$j("gaugeCanvas");widgetUUID=Hj();subType=Hj();barGauge=Hj();radialSize=Hj();backgroundColor=Hj();frameColor=Hj();minValue=Hj();maxValue=Hj();decimals=Hj();zones=Hj();title=Hj();units=Hj();value=Hj();theme=Hj(void 0,{alias:"themeColors"});gaugeStarted=false;gauge=null;gaugeOptions={};latestSizeOptions={};paddingTop=0;lastSizeSignature="";resizeTimer=null;pendingStructuralRebuild=false;ngOnInit(){this.buildOptions();}buildOptions(){this.gaugeOptions={};let e=this.minValue()??0,i=this.maxValue()??100;this.gaugeOptions.minValue=e,this.gaugeOptions.maxValue=i;let t=this.decimals();this.gaugeOptions.lcdDecimals=t??2,this.gaugeOptions.titleString=this.title()??"",this.gaugeOptions.unitString=this.units()??"",this.subType()=="radial"&&(this.gaugeOptions.gaugeType=this.setGaugeType(this.radialSize()));let s=this.zones();if(s){let r=this.theme(),u={emergency:r?.zoneEmergency??"rgba(0,0,0,0)",alarm:r?.zoneAlarm??"rgba(0,0,0,0)",warn:r?.zoneWarn??"rgba(0,0,0,0)",alert:r?.zoneAlert??"rgba(0,0,0,0)",nominal:r?.zoneNominal??"rgba(0,0,0,0)"},d=[],b=[],D=[...s].sort((C,m)=>(C.lower??Number.NEGATIVE_INFINITY)-(m.lower??Number.NEGATIVE_INFINITY));for(let C of D){let m=C.lower,S=C.upper;if(m===void 0||S===void 0)continue;let c=m,p=S,g;switch(C.state){case n$1.Emergency:g=u.emergency;break;case n$1.Alarm:g=u.alarm;break;case n$1.Warn:g=u.warn;break;case n$1.Alert:g=u.alert;break;case n$1.Nominal:g=u.nominal;break;default:g="rgba(0,0,0,0)";}let G=this.units();if(G=="ratio"?(c=m,p=S):(c=this.unitsService.convertToUnit(G??"",m)??m,p=this.unitsService.convertToUnit(G??"",S)??S),!(p<e||c>i)){if(c=Math.max(c,e),p>i){p=i,d.push(steelseries.Section(c,p,g));break}d.push(steelseries.Section(c,p,g));}}this.gaugeOptions.section=d,this.gaugeOptions.area=b,this.gaugeOptions.useSectionColors=true;}let n=this.backgroundColor();n&&n in z&&(this.gaugeOptions.backgroundColor=z[n]);let o=this.frameColor();o&&o in k&&(this.gaugeOptions.frameDesign=k[o]),this.barGauge()&&(this.gaugeOptions.valueColor=steelseries.ColorDef.GREEN),this.gaugeOptions.lcdVisible=true,this.gaugeOptions.thresholdVisible=false,this.gaugeOptions.threshold=this.maxValue(),this.gaugeOptions.ledVisible=false,Object.assign(this.gaugeOptions,this.latestSizeOptions);}setGaugeType(e){switch(e){case "quarter":return steelseries.GaugeType.TYPE1;case "half":return steelseries.GaugeType.TYPE2;case "three-quarter":return steelseries.GaugeType.TYPE3;default:return steelseries.GaugeType.TYPE4}}startGauge(e=false){this.buildOptions();let i=this.widgetUUID();if(!i)return;let t=e||this.pendingStructuralRebuild;if(this.gauge&&!t){this.gauge.setValueAnimated&&this.value()!=null,this.gaugeStarted=true;return}this.pendingStructuralRebuild=false,this.gaugeStarted=true;let s=this.subType();s==="radial"?this.gauge=new steelseries.Radial(i,this.gaugeOptions):s==="linear"&&(this.barGauge()?this.gauge=new steelseries.LinearBargraph(i,this.gaugeOptions):this.gauge=new steelseries.Linear(i,this.gaugeOptions));}onResized(e){if(e.contentRect.height<50||e.contentRect.width<50)return;let i;if(this.subType()==="radial"){let t=Math.floor(Math.min(e.contentRect.height,e.contentRect.width));this.latestSizeOptions={size:t},this.gaugeOptions.size=t,i="radial:"+t;}else {let t=Math.floor(e.contentRect.width),s=Math.floor(e.contentRect.height);this.latestSizeOptions={width:t,height:s},this.gaugeOptions.width=t,this.gaugeOptions.height=s,i=`linear:${t}x${s}`;}i!==this.lastSizeSignature&&(this.lastSizeSignature=i,this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>{this.startGauge(true),this.resizeTimer=null;},120));}ngOnChanges(e){this.gaugeStarted&&(e.value&&!e.value.firstChange&&e.value.currentValue!=null&&this.gauge?.setValueAnimated?.(e.value.currentValue),e.zones&&(this.pendingStructuralRebuild=true,this.startGauge(true)),e.title&&this.gauge?.setTitleString?.(e.title.currentValue??""),e.backgroundColor&&e.backgroundColor.currentValue in z&&this.gauge?.setBackgroundColor?.(z[e.backgroundColor.currentValue]),e.frameColor&&e.frameColor.currentValue in k&&this.gauge?.setFrameDesign?.(k[e.frameColor.currentValue]),e.radialSize&&(this.pendingStructuralRebuild=true,this.startGauge(true)),e.minValue&&e.minValue.currentValue!=null&&this.gauge?.setMinValue?.(e.minValue.currentValue),e.maxValue&&e.maxValue.currentValue!=null&&this.gauge?.setMaxValue?.(e.maxValue.currentValue));}ngOnDestroy(){if(this.gauge&&this.gauge.setValue){let i=this.gauge.getValue?this.gauge.getValue():this.value();this.gauge.setValue(i??0);}let e=this.widgetUUID();if(e){let i=document.getElementById(e);this.canvasService.releaseCanvas(i,{clear:true,removeFromDom:true});}this.gauge=null;}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["gauge-steel"]],viewQuery:function(i,t){i&1&&eg(t.canvasRef,Q,5),i&2&&Kw();},inputs:{widgetUUID:[1,"widgetUUID"],subType:[1,"subType"],barGauge:[1,"barGauge"],radialSize:[1,"radialSize"],backgroundColor:[1,"backgroundColor"],frameColor:[1,"frameColor"],minValue:[1,"minValue"],maxValue:[1,"maxValue"],decimals:[1,"decimals"],zones:[1,"zones"],title:[1,"title"],units:[1,"units"],value:[1,"value"],theme:[1,"themeColors","theme"]},features:[lv],decls:4,vars:2,consts:[["gaugeCanvas",""],["kipResizeObserver","",1,"wrapper",3,"resizeChange"],[2,"z-index","inherit",3,"id"]],template:function(i,t){i&1&&(Pi(0,"div",1),Qh("resizeChange",function(n){return t.onResized(n)}),Pi(1,"canvas",2,0),TT(3," Browser does not support canvas element. "),ul()()),i&2&&(EE(),Bh("id",AT(t.widgetUUID())));},dependencies:[u],styles:[".sgWrapper[_ngcontent-%COMP%]{height:100%;width:100%;text-align:center}"]})}return l})();var ue=(()=>{class l{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);metadata=w(_);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",isPathConfigurable:true,showPathSkUnitsFilter:true,pathSkUnitsFilter:null,convertUnitTo:"unitless",sampleTime:500}},displayScale:{type:"linear",lower:0,upper:100},gauge:{type:"steel",subType:"radial",backgroundColor:"carbon",faceColor:"anthracite",radialSize:"full",rotateFace:false,digitalMeter:false},numDecimal:2,enableTimeout:false,dataTimeout:5,ignoreZones:false};dataValue=vt(0);zones=vt([]);normalizedConfig=Dt(()=>this.runtime.options()??l.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);displayName=Dt(()=>this.normalizedConfig().displayName||"Gauge Label");gaugeUnits=Dt(()=>this.gaugePathConfig()?.convertUnitTo??"");constructor(){Fa(()=>{let e=this.normalizedConfig();this.gaugePathConfig()?.path&&ge(()=>this.streams.observe("gaugePath",t=>{let s=t?.data?.value,n=e.displayScale?.lower??0,o=e.displayScale?.upper??n+100;if(s==null)this.dataValue.set(n);else {let r=Math.min(Math.max(s,n),o);this.dataValue.set(r);}}));}),Fa(()=>{if(this.normalizedConfig().ignoreZones){this.zones.set([]);return}if(!this.gaugePathConfig()?.path){this.zones.set([]);return}ge(()=>this.metadata.observe("gaugePath")),this.zones.set(this.metadata.zones());});}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-gauge-steel"]],inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:2,vars:14,consts:[[1,"wrapper"],[3,"widgetUUID","subType","barGauge","radialSize","backgroundColor","frameColor","minValue","maxValue","decimals","zones","title","units","value","themeColors"]],template:function(i,t){if(i&1&&(Pi(0,"div",0),$h(1,"gauge-steel",1),ul()),i&2){let s,n,o,r,u,d,b,D;EE(),Bh("widgetUUID",t.id())("subType",(s=t.runtime.options())==null||s.gauge==null?null:s.gauge.subType)("barGauge",(n=t.runtime.options())==null||n.gauge==null?null:n.gauge.digitalMeter)("radialSize",(o=t.runtime.options())==null||o.gauge==null?null:o.gauge.radialSize)("backgroundColor",(r=t.runtime.options())==null||r.gauge==null?null:r.gauge.backgroundColor)("frameColor",(u=t.runtime.options())==null||u.gauge==null?null:u.gauge.faceColor)("minValue",(d=t.runtime.options())==null||d.displayScale==null?null:d.displayScale.lower)("maxValue",(b=t.runtime.options())==null||b.displayScale==null?null:b.displayScale.upper)("decimals",(D=t.runtime.options())==null?null:D.numDecimal)("zones",t.zones())("title",t.displayName())("units",t.gaugeUnits())("value",t.dataValue())("themeColors",t.theme());}},dependencies:[q],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}gauge-steel[_ngcontent-%COMP%]{display:block;position:relative;width:100%;height:100%} .wrapper{display:block;position:relative;width:100%;height:100%;padding:10px} .wrapper>canvas{display:block;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}"]})}return l})();export{ue as WidgetSteelGaugeComponent};
|