@mxtommy/kip 4.8.4 → 4.8.5
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 +1 -1
- package/plugin/history-series.service.js +637 -0
- package/plugin/index.js +1322 -0
- package/plugin/kip-series-contract.js +31 -0
- package/plugin/openApi.json +855 -0
- package/plugin/sqlite-history-storage.service.js +1124 -0
- package/public/assets/help-docs/ais-radar.md +261 -0
- package/public/assets/help-docs/dashboards.md +1 -1
- package/public/assets/help-docs/menu.json +17 -2
- package/public/{chunk-Co2wVrD6.js → chunk-0ijGpqkR.js} +1 -1
- package/public/{chunk-JhFkJS7i.js → chunk-6MiGh2Ts.js} +1 -1
- package/public/{chunk-DIl1k00y.js → chunk-7QXXQf2h.js} +1 -1
- package/public/{chunk-CYYBxjrc.js → chunk-B4Wxwb2y.js} +1 -1
- package/public/{chunk-q9NoPvcx.js → chunk-BAVmyVwG.js} +1 -1
- package/public/{chunk-BfiyH3nV.js → chunk-BOlUTHo6.js} +1 -1
- package/public/{chunk-x7L6DXVK.js → chunk-BTv5PhTr.js} +1 -1
- package/public/{chunk-BeM64etA.js → chunk-BZG04c3j.js} +1 -1
- package/public/{chunk-0z3nIRXw.js → chunk-BaGEtCmz.js} +1 -1
- package/public/{chunk-otzyItXL.js → chunk-Bbyk4dOu.js} +1 -1
- package/public/{chunk-CCfhzpE8.js → chunk-Be5KcT7R.js} +1 -1
- package/public/{chunk-BFpzxIIT.js → chunk-Bp1YVCJL.js} +1 -1
- package/public/{chunk-CLs_NL1y.js → chunk-BwYOFdBA.js} +1 -1
- package/public/{chunk-D-_-GUVr.js → chunk-Bx77STup.js} +1 -1
- package/public/{chunk-COI6IBXH.js → chunk-ByC_hFSP.js} +1 -1
- package/public/{chunk-CIGP2YJm.js → chunk-ByFzHU1s.js} +1 -1
- package/public/{chunk-CXvWM_vF.js → chunk-BzH86te1.js} +1 -1
- package/public/{chunk-CxPx4NZv.js → chunk-C7ax8Sqz.js} +1 -1
- package/public/{chunk-CoCQ3DW2.js → chunk-C89yhdsn.js} +1 -1
- package/public/{chunk-BTOTKeBo.js → chunk-CJhkckXA.js} +1 -1
- package/public/{chunk-BUguZ7cK.js → chunk-CLIWxVhS.js} +1 -1
- package/public/{chunk-eQ1pa34Q.js → chunk-CQtqkz1Y.js} +1 -1
- package/public/{chunk-BIb-xYiS.js → chunk-CRy9Da7a.js} +1 -1
- package/public/{chunk-Do8wqING.js → chunk-CcaPRVAZ.js} +1 -1
- package/public/{chunk-BjINKQ03.js → chunk-CdNfAZ0G.js} +1 -1
- package/public/{chunk-CLTHuhlN.js → chunk-Cj0AJQ8U.js} +1 -1
- package/public/{chunk-B9nVBlGj.js → chunk-CkFpNfxN.js} +1 -1
- package/public/{chunk-B09jfNia.js → chunk-Cn9j0-tJ.js} +1 -1
- package/public/{chunk-_zRMMvCu.js → chunk-Co8V0LUu.js} +1 -1
- package/public/{chunk-ibauGmSP.js → chunk-CteyWXZ_.js} +1 -1
- package/public/{chunk-C6b8CVno.js → chunk-CuPmfpgh.js} +1 -1
- package/public/{chunk-DmkAKXR1.js → chunk-CwGTKplC.js} +1 -1
- package/public/{chunk-DPnbM-aB.js → chunk-CzEDfe2A.js} +1 -1
- package/public/{chunk-DUEKoZhd.js → chunk-D1Yncgg5.js} +1 -1
- package/public/{chunk-DTN-sa1K.js → chunk-D63LEt5t.js} +1 -1
- package/public/{chunk-BpcNrtxJ.js → chunk-DN39qO63.js} +1 -1
- package/public/{chunk-szQs8fiq.js → chunk-DNbLx4NZ.js} +1 -1
- package/public/{chunk-D1HYfaL_.js → chunk-DRPjASjZ.js} +1 -1
- package/public/{chunk-CyVRpGoJ.js → chunk-Dddd8rAh.js} +1 -1
- package/public/{chunk-C_OZJltF.js → chunk-DiDkZnhZ.js} +1 -1
- package/public/{chunk-CHAFm_nM.js → chunk-DonRL_4T.js} +1 -1
- package/public/{chunk-BJ-wyixK.js → chunk-DufX2AHa.js} +1 -1
- package/public/{chunk-07zHjmg-.js → chunk-DxS7HN4G.js} +1 -1
- package/public/{chunk-BLEZOsfR.js → chunk-Fy40z1B2.js} +1 -1
- package/public/{chunk-OeQDZKFO.js → chunk-MO2v041V.js} +1 -1
- package/public/{chunk-BuvyF0y5.js → chunk-MakCt36b.js} +1 -1
- package/public/{chunk-BZx964-p.js → chunk-TdI_E-cf.js} +1 -1
- package/public/{chunk-B0D54iJs.js → chunk-TneLdWrI.js} +1 -1
- package/public/{chunk-BN7A4g6c.js → chunk-YZWhRxa9.js} +1 -1
- package/public/{chunk-CQMVIDcp.js → chunk-_toW-rHA.js} +1 -1
- package/public/{chunk-B0eE4udE.js → chunk-tbyiK3Ur.js} +1 -1
- package/public/{chunk-D2953Rfp.js → chunk-urAQA4U_.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-YKDNK5VZ.js → main-F7NMHHV4.js} +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import {C,e}from'./chunk-DPnbM-aB.js';import {g as ge$2}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$1,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}from'./chunk-BIb-xYiS.js';var ge=["chargerSvg"];function me(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K charger paths or select chargers in widget settings."),ul()());}function fe(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var le=class c$1{static CHARGER_DESCRIPTOR=a("widget-charger");static SELF_ROOT_PATH=(()=>{let e=c$1.CHARGER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${fe(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 CHARGER_DISPLAY_BASE_WIDTH=145;static CHARGER_DISPLAY_BASE_HEIGHT=37;static CHARGER_DISPLAY_HORIZONTAL_MARGIN=40;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,charger:{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("chargerSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredChargerIds=vt([]);trackedDevices=vt([]);chargersByKey=vt({});visibleChargerKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(s=>s.key);let r=this.chargersByKey(),t=new Set(this.discoveredChargerIds()),i=Object.keys(r).filter(s=>{let o=r[s];return !!o&&t.has(o.id)}).sort((s,o)=>s.localeCompare(o)),a=new Map;return i.forEach(s=>{let o=r[s];o&&s!==o.id&&a.set(o.id,true);}),i.filter(s=>{let o=r[s];return o?s!==o.id?true:!a.get(o.id):false})});visibleChargers=Dt(()=>{let e=this.visibleChargerKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasChargers=Dt(()=>this.visibleChargers().length>0);isCompactCardMode=Dt(()=>this.renderMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleChargers();return e.length!==1?"Chargers":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=this.visibleChargers(),r=new Map;e.forEach(a=>r.set(a.id,(r.get(a.id)??0)+1));let t=new Set([...r.entries()].filter(([,a])=>a>1).map(([a])=>a)),i={};for(let a of e){let s=a.deviceKey??a.id,o=!!a.source&&t.has(a.id),[n,m,p,h]=this.buildMetricRows(a);i[s]={id:a.id,source:a.source??null,deviceKey:a.deviceKey,titleText:this.resolveTitleText(a,o),modeText:this.isCompactCardMode()?"":this.resolveModeText(a),voltageText:n,currentText:m,powerText:p,temperatureText:h};}return i});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge$1(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleChargers(),a=this.widgetColors();!this.svg||!a||this.requestRender({chargers:i,displayModels:t,widgetColors:a});});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$2(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","Charger View"),this.layer=this.svg.append("g").attr("class","charger-layer");}applyConfig(e){let r=this.normalizeTrackedDevices(e.charger?.trackedDevices);this.trackedDevices.set(r),this.reprojectSnapshotsToDeviceKeys(r);}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,a=this.normalizeOptionalString(i.id),s=this.normalizeOptionalString(i.source);if(!a||!s)return;let o=this.normalizeOptionalString(i.key)??`${a}||${s}`;r.set(o,{id:a,source:s,key:o});}),[...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}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map,t=new Map;e.forEach(i=>{let a=r.get(i.id)??[];a.push(i.key),r.set(i.id,a),t.set(i.key,i);}),this.chargersByKey.update(i=>{let a=i,s=false;return r.forEach((o,n)=>{let m=i[n];if(m){for(let p of o){if(i[p])continue;let h=t.get(p);s||(a=G({},i),s=true),a[p]=z(G({},m),{source:h?.source??null,deviceKey:p});}a[n]&&(a[n].deviceKey===void 0||a[n].deviceKey===n)&&(s||(a=G({},i),s=true),delete a[n]);}}),s?a:i});}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,a=e.update?.state??null,s=this.extractUpdateSource(e),o=`${t.id}::${s??"*"}::${t.key}`;if(this.pendingPathUpdates.set(o,{id:t.id,key:t.key,source:s,value:i,state:a}),!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(a=>a.id)).forEach(a=>this.trackDiscoveredCharger(a));let t=this.buildIdToDeviceKeysMap(),i=new Map;this.trackedDevices().forEach(a=>i.set(a.key,a)),this.chargersByKey.update(a=>{let s=a,o=false;for(let n of e){let m=t.get(n.id),p=!!m?.length,h=[];if(p)if(n.source){let y=`${n.id}||${n.source}`;h=m?.includes(y)?[y]:[];}else h=m??[];else h=[n.source?`${n.id}||${n.source}`:n.id];for(let y of h){let b=p?i.get(y):null,f=s[y]??{id:n.id,source:b?.source??n.source??null,deviceKey:p||n.source?y:void 0},d=G({},f);if(!this.applyValue(d,n.key,n.value,n.state))continue;let M=d.rawPower!=null?d.rawPower:d.voltage!=null&&d.current!=null?d.voltage*d.current:null;M!=null?d.power=Number.isFinite(M)?M:null:d.power=null,d.rawPower==null&&(d.powerState=this.resolveMostSevereState(d.voltageState??null,d.currentState??null)),o||(s=G({},s),o=true),s[y]=d;}}return o?s:a});}extractUpdateSource(e){let r=this.normalizeOptionalString(e.source);return r||(this.normalizeOptionalString(e.update?.data?.source)??null)}trackDiscoveredCharger(e){let r=this.discoveredChargerIds();r.includes(e)||this.discoveredChargerIds.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 "state":return this.setMetricValue(e,"state","stateState",this.toStringValue(t),i);case "offReason":return this.setMetricValue(e,"offReason","offReasonState",this.toStringValue(t),i);case "error":return this.setMetricValue(e,"error","errorState",this.toStringValue(t),i);case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),i);case "modeState":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),i);case "modeNumber":return this.setMetricValue(e,"modeNumber","modeNumberState",this.toNumber(t,""),i);case "chargingMode":return this.setMetricValue(e,"chargingMode","chargingModeState",this.toStringValue(t),i);case "chargingModeNumber":return this.setMetricValue(e,"chargingModeNumber","chargingModeNumberState",this.toNumber(t,""),i);case "output.voltage":{let a=this.toNumber(t,"V"),s=this.setMetricValue(e,"outputVoltage","outputVoltageState",a,i),o=this.setMetricValue(e,"voltage","voltageState",a,i);return s||o}case "input.voltage":return this.setMetricValue(e,"inputVoltage","inputVoltageState",this.toNumber(t,"V"),i);case "voltage":return this.setMetricValue(e,"voltage","voltageState",this.toNumber(t,"V"),i);case "current":return this.setMetricValue(e,"current","currentState",this.toNumber(t,"A"),i);case "power":return this.setMetricValue(e,"rawPower","powerState",this.toNumber(t,"W"),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);case "leds.absorption":return this.setMetricValue(e,"ledsAbsorption","ledsAbsorptionState",this.toBoolean(t),i);case "leds.bulk":return this.setMetricValue(e,"ledsBulk","ledsBulkState",this.toBoolean(t),i);case "leds.float":return this.setMetricValue(e,"ledsFloat","ledsFloatState",this.toBoolean(t),i);case "leds.inverter":return this.setMetricValue(e,"ledsInverter","ledsInverterState",this.toBoolean(t),i);case "leds.lowBattery":return this.setMetricValue(e,"ledsLowBattery","ledsLowBatteryState",this.toBoolean(t),i);case "leds.mains":return this.setMetricValue(e,"ledsMains","ledsMainsState",this.toBoolean(t),i);case "leds.overload":return this.setMetricValue(e,"ledsOverload","ledsOverloadState",this.toBoolean(t),i);case "leds.temperature":return this.setMetricValue(e,"ledsTemperature","ledsTemperatureState",this.toBoolean(t),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,a){let s=!Object.is(e[r],i),o=!Object.is(e[t],a);return !s&&!o?false:(e[r]=i,e[t]=a,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{chargers:this.visibleChargers(),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$1){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,a=c$1.VIEWBOX_WIDTH-c$1.CHARGER_DISPLAY_HORIZONTAL_MARGIN,s=a/c$1.CHARGER_DISPLAY_BASE_WIDTH,o=a,n=(c$1.VIEWBOX_WIDTH-o)/2,m=r?8:t.titleY,p=r?33:60,h=e$1.chargers.map((l,P)=>({key:l.deviceKey??l.id,id:l.id,charger:l,y:P*(i+c$1.CARD_GAP)})),y=h.length?h[h.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${y}`);let b=this.layer.selectAll("g.charger-card").data(h,l=>l.key),f=b.enter().append("g").attr("class","charger-card"),d=f.append("g").attr("class","charger-display-group");d.append("path").attr("class","charger-shape-bulk").attr("d","m 39.280608,10.70371 1.604609,-3.7808024 c 0.06926,-0.1631805 0.314475,-0.553581 0.314475,-0.4368876 v 27.475177 c 0,0.116694 -0.142713,0.210638 -0.319983,0.210638 H 9.2681756 c -0.1772706,0 -0.3711555,-0.105758 -0.319983,-0.210638 l 1.2797184,-2.622833 c 1.150699,-2.358403 3.86281,-5.455024 6.286778,-6.406312 3.251217,-1.275942 7.834296,-2.821704 11.746419,-4.103315 4.312764,-1.412861 9.246151,-5.946636 11.0195,-10.125027 z").attr("transform","matrix(1.1068428,0,0,1.1601894,-8.804611,-6.1382561)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("rect").attr("class","charger-shape-absorption").attr("width",19.67485).attr("height",32.383526).attr("x",40.545158).attr("y",1.1331999).attr("rx",.19520389).attr("ry",.24451913).attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linecap","butt").attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("path").attr("class","charger-shape-float").attr("d","m 66.03898,6.4101715 4.16646,3.2472635 c 1.876083,1.462185 5.139444,3.529899 7.448846,4.069504 5.055358,1.181215 11.386089,1.251612 11.38595,1.349059 l -0.02667,18.73082 c 0,0.127151 -0.103075,0.230227 -0.230226,0.230227 H 66.03898 c -0.127151,0 -0.230226,-0.103076 -0.230226,-0.230227 V 6.6403978 c 0,-0.1271504 0.103076,-0.2302261 0.230226,-0.2302263 z").attr("transform","matrix(1.1068428,0,0,1.1601894,-8.7228087,-6.1382561)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linecap","butt").attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("path").attr("class","charger-shape-storage").attr("d","m 93.39395,15.253553 c 2.347866,2.587905 8.59059,4.802212 13.94479,4.852641 11.92289,0.112298 30.60094,0.205911 30.60096,0.259031 l 0.006,13.361558 c 3e-5,0.07786 -0.19912,0.140548 -0.44645,0.140548 h -44.1053 c -0.247332,0 -0.446448,-0.06269 -0.446448,-0.140548 V 15.394101 c 0,-0.07786 0.280259,-0.323728 0.446448,-0.140548 z").attr("transform","matrix(1.1077284,0,0,1.1178939,-8.9068494,-4.6850995)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),f.append("text").attr("class","charger-title"),f.append("text").attr("class","charger-mode");let E=f.append("text").attr("class","charger-voltage");E.append("tspan").attr("class","voltage-metric-value"),E.append("tspan").attr("class","voltage-metric-unit");let M=f.append("text").attr("class","charger-current");M.append("tspan").attr("class","current-metric-value"),M.append("tspan").attr("class","current-metric-unit");let L=f.append("text").attr("class","charger-power");L.append("tspan").attr("class","power-metric-value"),L.append("tspan").attr("class","power-metric-unit");let z=f.append("text").attr("class","charger-temperature");z.append("tspan").attr("class","temperature-metric-value"),z.append("tspan").attr("class","temperature-metric-unit");let u=f.merge(b);u.attr("transform",l=>`translate(0, ${l.y})`),u.select("g.charger-display-group").attr("transform",`translate(${n}, ${p}) scale(${s})`).each((l,P,ce)=>{let v=this.resolveShapeMode(l.charger),S=this.isShapeMode(v,"power supply"),D=e$1.widgetColors.dim,x="var(--mat-sys-background)",R=this.isShapeMode(v,"sustain")||S?"none":this.isShapeMode(v,"equalization")?"var(--kip-zone-alert-color)":this.isShapeMode(v,"overload")?"var(--kip-zone-alarm-color)":e$1.widgetColors.color,I=ge$2(ce[P]);I.select("path.charger-shape-bulk").attr("fill",this.isShapeMode(v,"bulk")||this.isShapeMode(v,"boost")||S?D:x).attr("stroke",R),I.select("rect.charger-shape-absorption").attr("fill",this.isShapeMode(v,"absorption")||S?D:x).attr("stroke",R),I.select("path.charger-shape-float").attr("fill",this.isShapeMode(v,"float")||S?D:x).attr("stroke",R),I.select("path.charger-shape-storage").attr("fill",this.isShapeMode(v,"storage")||S?D:x).attr("stroke",R);}),e$1.chargers.length>1?u.select("text.charger-title").attr("x",t.titleX).attr("y",m).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(l=>e$1.displayModels[l.key]?.titleText??this.resolveTitleText(l.charger)):u.select("text.charger-title").text(""),u.select("text.charger-voltage").attr("x",197).attr("y",25).attr("text-anchor","end").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("fill","var(--kip-contrast-color)"),u.select("tspan.voltage-metric-value").text(l=>e$1.displayModels[l.key]?.voltageText??""),u.select("tspan.voltage-metric-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text("V"),u.select("text.charger-current").attr("x",197).attr("y",48).attr("text-anchor","end").attr("font-size",t.lineOneFontSize).attr("fill","var(--kip-contrast-color)"),u.select("tspan.current-metric-value").text(l=>e$1.displayModels[l.key]?.currentText??""),u.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),u.select("text.charger-power").attr("x",5).attr("y",22).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",10),u.select("tspan.power-metric-value").text(l=>e$1.displayModels[l.key]?.powerText??""),u.select("tspan.power-metric-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text("W"),u.select("text.charger-temperature").attr("x",5).attr("y",34).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",10),u.select("tspan.temperature-metric-value").text(l=>e$1.displayModels[l.key]?.temperatureText??""),u.select("tspan.temperature-metric-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(`${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`),u.select("text.charger-mode").attr("x",5).attr("y",46).attr("font-size",10).attr("fill","var(--kip-contrast-dim-color)").text(l=>e$1.displayModels[l.key]?.modeText??""),b.exit().remove();}resolveTitleText(e,r=false){let t=e.name||`Charger ${e.id}`;return !r||!e.source?t:`${t} [${e.source}]`}resolveModeText(e){if(e.chargingMode)return `Mode: ${e.chargingMode.charAt(0).toUpperCase()+e.chargingMode.slice(1)}`;if(e.mode)return `Mode: ${e.mode}`;let t=[{active:e.ledsAbsorption,label:"Absorption"},{active:e.ledsBulk,label:"Bulk"},{active:e.ledsFloat,label:"Float"},{active:e.ledsInverter,label:"Inverter"},{active:e.ledsLowBattery,label:"Low Battery"},{active:e.ledsMains,label:"Mains"},{active:e.ledsOverload,label:"Overload"},{active:e.ledsTemperature,label:"Temperature"}].filter(i=>i.active===true).map(i=>i.label);return t.length?`Mode: ${t.join(" / ")}`:"Mode --"}resolveShapeMode(e){return (e.chargingMode??e.mode??"").trim().toLowerCase()}isShapeMode(e,r){return !e||!r?false:e===r||e.includes(r)}buildMetricRows(e){return this.renderMode()==="full"||this.renderMode()===null?[`${this.formatValue(e.voltage,1)}`,`${this.formatValue(e.current,1)}`,`Power: ${this.formatValue(e.power,0)}`,`Temp: ${this.formatTemperature(e.temperature)}`]:[`${this.formatValue(e.voltage,1)}`,`${this.formatValue(e.current,1)}`,`P: ${this.formatValue(e.power,0)}`,`T: ${this.formatTemperature(e.temperature)}`]}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(r)}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(0)}`}toStringValue(e){return typeof e=="string"?e: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}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 Number.isFinite(i)?i:t}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,ge,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["chargerSvg",""],[3,"text","color"],["aria-hidden","false",1,"charger-svg"],[1,"charger-empty"],[1,"charger-empty-title"],[1,"charger-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.charger-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}.charger-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)}.charger-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.charger-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{le as WidgetChargerComponent};
|
|
1
|
+
import {C,e}from'./chunk-CzEDfe2A.js';import {g as ge$2}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$1,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-F7NMHHV4.js';import {c}from'./chunk-CRy9Da7a.js';var ge=["chargerSvg"];function me(c,e){c&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K charger paths or select chargers in widget settings."),ul()());}function fe(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var le=class c$1{static CHARGER_DESCRIPTOR=a("widget-charger");static SELF_ROOT_PATH=(()=>{let e=c$1.CHARGER_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${c$1.SELF_ROOT_PATH}.*`;static PATH_REGEX=new RegExp(`^${fe(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 CHARGER_DISPLAY_BASE_WIDTH=145;static CHARGER_DISPLAY_BASE_HEIGHT=37;static CHARGER_DISPLAY_HORIZONTAL_MARGIN=40;static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,charger:{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("chargerSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredChargerIds=vt([]);trackedDevices=vt([]);chargersByKey=vt({});visibleChargerKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(s=>s.key);let r=this.chargersByKey(),t=new Set(this.discoveredChargerIds()),i=Object.keys(r).filter(s=>{let o=r[s];return !!o&&t.has(o.id)}).sort((s,o)=>s.localeCompare(o)),a=new Map;return i.forEach(s=>{let o=r[s];o&&s!==o.id&&a.set(o.id,true);}),i.filter(s=>{let o=r[s];return o?s!==o.id?true:!a.get(o.id):false})});visibleChargers=Dt(()=>{let e=this.visibleChargerKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});hasChargers=Dt(()=>this.visibleChargers().length>0);isCompactCardMode=Dt(()=>this.renderMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);displayLabel=Dt(()=>{let e=this.visibleChargers();return e.length!==1?"Chargers":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=this.visibleChargers(),r=new Map;e.forEach(a=>r.set(a.id,(r.get(a.id)??0)+1));let t=new Set([...r.entries()].filter(([,a])=>a>1).map(([a])=>a)),i={};for(let a of e){let s=a.deviceKey??a.id,o=!!a.source&&t.has(a.id),[n,m,p,h]=this.buildMetricRows(a);i[s]={id:a.id,source:a.source??null,deviceKey:a.deviceKey,titleText:this.resolveTitleText(a,o),modeText:this.isCompactCardMode()?"":this.resolveModeText(a),voltageText:n,currentText:m,powerText:p,temperatureText:h};}return i});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge$1(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),i=this.visibleChargers(),a=this.widgetColors();!this.svg||!a||this.requestRender({chargers:i,displayModels:t,widgetColors:a});});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$2(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","Charger View"),this.layer=this.svg.append("g").attr("class","charger-layer");}applyConfig(e){let r=this.normalizeTrackedDevices(e.charger?.trackedDevices);this.trackedDevices.set(r),this.reprojectSnapshotsToDeviceKeys(r);}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let i=t,a=this.normalizeOptionalString(i.id),s=this.normalizeOptionalString(i.source);if(!a||!s)return;let o=this.normalizeOptionalString(i.key)??`${a}||${s}`;r.set(o,{id:a,source:s,key:o});}),[...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}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map,t=new Map;e.forEach(i=>{let a=r.get(i.id)??[];a.push(i.key),r.set(i.id,a),t.set(i.key,i);}),this.chargersByKey.update(i=>{let a=i,s=false;return r.forEach((o,n)=>{let m=i[n];if(m){for(let p of o){if(i[p])continue;let h=t.get(p);s||(a=G({},i),s=true),a[p]=z(G({},m),{source:h?.source??null,deviceKey:p});}a[n]&&(a[n].deviceKey===void 0||a[n].deviceKey===n)&&(s||(a=G({},i),s=true),delete a[n]);}}),s?a:i});}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,a=e.update?.state??null,s=this.extractUpdateSource(e),o=`${t.id}::${s??"*"}::${t.key}`;if(this.pendingPathUpdates.set(o,{id:t.id,key:t.key,source:s,value:i,state:a}),!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(a=>a.id)).forEach(a=>this.trackDiscoveredCharger(a));let t=this.buildIdToDeviceKeysMap(),i=new Map;this.trackedDevices().forEach(a=>i.set(a.key,a)),this.chargersByKey.update(a=>{let s=a,o=false;for(let n of e){let m=t.get(n.id),p=!!m?.length,h=[];if(p)if(n.source){let y=`${n.id}||${n.source}`;h=m?.includes(y)?[y]:[];}else h=m??[];else h=[n.source?`${n.id}||${n.source}`:n.id];for(let y of h){let b=p?i.get(y):null,f=s[y]??{id:n.id,source:b?.source??n.source??null,deviceKey:p||n.source?y:void 0},d=G({},f);if(!this.applyValue(d,n.key,n.value,n.state))continue;let M=d.rawPower!=null?d.rawPower:d.voltage!=null&&d.current!=null?d.voltage*d.current:null;M!=null?d.power=Number.isFinite(M)?M:null:d.power=null,d.rawPower==null&&(d.powerState=this.resolveMostSevereState(d.voltageState??null,d.currentState??null)),o||(s=G({},s),o=true),s[y]=d;}}return o?s:a});}extractUpdateSource(e){let r=this.normalizeOptionalString(e.source);return r||(this.normalizeOptionalString(e.update?.data?.source)??null)}trackDiscoveredCharger(e){let r=this.discoveredChargerIds();r.includes(e)||this.discoveredChargerIds.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 "state":return this.setMetricValue(e,"state","stateState",this.toStringValue(t),i);case "offReason":return this.setMetricValue(e,"offReason","offReasonState",this.toStringValue(t),i);case "error":return this.setMetricValue(e,"error","errorState",this.toStringValue(t),i);case "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),i);case "modeState":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),i);case "modeNumber":return this.setMetricValue(e,"modeNumber","modeNumberState",this.toNumber(t,""),i);case "chargingMode":return this.setMetricValue(e,"chargingMode","chargingModeState",this.toStringValue(t),i);case "chargingModeNumber":return this.setMetricValue(e,"chargingModeNumber","chargingModeNumberState",this.toNumber(t,""),i);case "output.voltage":{let a=this.toNumber(t,"V"),s=this.setMetricValue(e,"outputVoltage","outputVoltageState",a,i),o=this.setMetricValue(e,"voltage","voltageState",a,i);return s||o}case "input.voltage":return this.setMetricValue(e,"inputVoltage","inputVoltageState",this.toNumber(t,"V"),i);case "voltage":return this.setMetricValue(e,"voltage","voltageState",this.toNumber(t,"V"),i);case "current":return this.setMetricValue(e,"current","currentState",this.toNumber(t,"A"),i);case "power":return this.setMetricValue(e,"rawPower","powerState",this.toNumber(t,"W"),i);case "temperature":return this.setMetricValue(e,"temperature","temperatureState",this.toNumber(t,this.units.getDefaults().Temperature),i);case "leds.absorption":return this.setMetricValue(e,"ledsAbsorption","ledsAbsorptionState",this.toBoolean(t),i);case "leds.bulk":return this.setMetricValue(e,"ledsBulk","ledsBulkState",this.toBoolean(t),i);case "leds.float":return this.setMetricValue(e,"ledsFloat","ledsFloatState",this.toBoolean(t),i);case "leds.inverter":return this.setMetricValue(e,"ledsInverter","ledsInverterState",this.toBoolean(t),i);case "leds.lowBattery":return this.setMetricValue(e,"ledsLowBattery","ledsLowBatteryState",this.toBoolean(t),i);case "leds.mains":return this.setMetricValue(e,"ledsMains","ledsMainsState",this.toBoolean(t),i);case "leds.overload":return this.setMetricValue(e,"ledsOverload","ledsOverloadState",this.toBoolean(t),i);case "leds.temperature":return this.setMetricValue(e,"ledsTemperature","ledsTemperatureState",this.toBoolean(t),i);default:return false}}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}setMetricValue(e,r,t,i,a){let s=!Object.is(e[r],i),o=!Object.is(e[t],a);return !s&&!o?false:(e[r]=i,e[t]=a,true)}requestRender(e){let r=this.widgetColors();!this.svg||!r||(this.pendingRenderSnapshot=e??{chargers:this.visibleChargers(),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$1){if(!this.layer||!this.svg)return;let r=this.isCompactCardMode(),t=r?C:e,i=r?c$1.COMPACT_CARD_HEIGHT:c$1.CARD_HEIGHT,a=c$1.VIEWBOX_WIDTH-c$1.CHARGER_DISPLAY_HORIZONTAL_MARGIN,s=a/c$1.CHARGER_DISPLAY_BASE_WIDTH,o=a,n=(c$1.VIEWBOX_WIDTH-o)/2,m=r?8:t.titleY,p=r?33:60,h=e$1.chargers.map((l,P)=>({key:l.deviceKey??l.id,id:l.id,charger:l,y:P*(i+c$1.CARD_GAP)})),y=h.length?h[h.length-1].y+i:i;this.svg.attr("viewBox",`0 0 ${c$1.VIEWBOX_WIDTH} ${y}`);let b=this.layer.selectAll("g.charger-card").data(h,l=>l.key),f=b.enter().append("g").attr("class","charger-card"),d=f.append("g").attr("class","charger-display-group");d.append("path").attr("class","charger-shape-bulk").attr("d","m 39.280608,10.70371 1.604609,-3.7808024 c 0.06926,-0.1631805 0.314475,-0.553581 0.314475,-0.4368876 v 27.475177 c 0,0.116694 -0.142713,0.210638 -0.319983,0.210638 H 9.2681756 c -0.1772706,0 -0.3711555,-0.105758 -0.319983,-0.210638 l 1.2797184,-2.622833 c 1.150699,-2.358403 3.86281,-5.455024 6.286778,-6.406312 3.251217,-1.275942 7.834296,-2.821704 11.746419,-4.103315 4.312764,-1.412861 9.246151,-5.946636 11.0195,-10.125027 z").attr("transform","matrix(1.1068428,0,0,1.1601894,-8.804611,-6.1382561)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("rect").attr("class","charger-shape-absorption").attr("width",19.67485).attr("height",32.383526).attr("x",40.545158).attr("y",1.1331999).attr("rx",.19520389).attr("ry",.24451913).attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linecap","butt").attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("path").attr("class","charger-shape-float").attr("d","m 66.03898,6.4101715 4.16646,3.2472635 c 1.876083,1.462185 5.139444,3.529899 7.448846,4.069504 5.055358,1.181215 11.386089,1.251612 11.38595,1.349059 l -0.02667,18.73082 c 0,0.127151 -0.103075,0.230227 -0.230226,0.230227 H 66.03898 c -0.127151,0 -0.230226,-0.103076 -0.230226,-0.230227 V 6.6403978 c 0,-0.1271504 0.103076,-0.2302261 0.230226,-0.2302263 z").attr("transform","matrix(1.1068428,0,0,1.1601894,-8.7228087,-6.1382561)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linecap","butt").attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),d.append("path").attr("class","charger-shape-storage").attr("d","m 93.39395,15.253553 c 2.347866,2.587905 8.59059,4.802212 13.94479,4.852641 11.92289,0.112298 30.60094,0.205911 30.60096,0.259031 l 0.006,13.361558 c 3e-5,0.07786 -0.19912,0.140548 -0.44645,0.140548 h -44.1053 c -0.247332,0 -0.446448,-0.06269 -0.446448,-0.140548 V 15.394101 c 0,-0.07786 0.280259,-0.323728 0.446448,-0.140548 z").attr("transform","matrix(1.1077284,0,0,1.1178939,-8.9068494,-4.6850995)").attr("fill","var(--mat-sys-background)").attr("stroke",e$1.widgetColors.color).attr("stroke-width",2).attr("stroke-linejoin","miter").attr("stroke-miterlimit",0).attr("paint-order","markers stroke fill"),f.append("text").attr("class","charger-title"),f.append("text").attr("class","charger-mode");let E=f.append("text").attr("class","charger-voltage");E.append("tspan").attr("class","voltage-metric-value"),E.append("tspan").attr("class","voltage-metric-unit");let M=f.append("text").attr("class","charger-current");M.append("tspan").attr("class","current-metric-value"),M.append("tspan").attr("class","current-metric-unit");let L=f.append("text").attr("class","charger-power");L.append("tspan").attr("class","power-metric-value"),L.append("tspan").attr("class","power-metric-unit");let z=f.append("text").attr("class","charger-temperature");z.append("tspan").attr("class","temperature-metric-value"),z.append("tspan").attr("class","temperature-metric-unit");let u=f.merge(b);u.attr("transform",l=>`translate(0, ${l.y})`),u.select("g.charger-display-group").attr("transform",`translate(${n}, ${p}) scale(${s})`).each((l,P,ce)=>{let v=this.resolveShapeMode(l.charger),S=this.isShapeMode(v,"power supply"),D=e$1.widgetColors.dim,x="var(--mat-sys-background)",R=this.isShapeMode(v,"sustain")||S?"none":this.isShapeMode(v,"equalization")?"var(--kip-zone-alert-color)":this.isShapeMode(v,"overload")?"var(--kip-zone-alarm-color)":e$1.widgetColors.color,I=ge$2(ce[P]);I.select("path.charger-shape-bulk").attr("fill",this.isShapeMode(v,"bulk")||this.isShapeMode(v,"boost")||S?D:x).attr("stroke",R),I.select("rect.charger-shape-absorption").attr("fill",this.isShapeMode(v,"absorption")||S?D:x).attr("stroke",R),I.select("path.charger-shape-float").attr("fill",this.isShapeMode(v,"float")||S?D:x).attr("stroke",R),I.select("path.charger-shape-storage").attr("fill",this.isShapeMode(v,"storage")||S?D:x).attr("stroke",R);}),e$1.chargers.length>1?u.select("text.charger-title").attr("x",t.titleX).attr("y",m).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(l=>e$1.displayModels[l.key]?.titleText??this.resolveTitleText(l.charger)):u.select("text.charger-title").text(""),u.select("text.charger-voltage").attr("x",197).attr("y",25).attr("text-anchor","end").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("fill","var(--kip-contrast-color)"),u.select("tspan.voltage-metric-value").text(l=>e$1.displayModels[l.key]?.voltageText??""),u.select("tspan.voltage-metric-unit").attr("dx",1).attr("font-size",22).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").text("V"),u.select("text.charger-current").attr("x",197).attr("y",48).attr("text-anchor","end").attr("font-size",t.lineOneFontSize).attr("fill","var(--kip-contrast-color)"),u.select("tspan.current-metric-value").text(l=>e$1.displayModels[l.key]?.currentText??""),u.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),u.select("text.charger-power").attr("x",5).attr("y",22).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",10),u.select("tspan.power-metric-value").text(l=>e$1.displayModels[l.key]?.powerText??""),u.select("tspan.power-metric-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text("W"),u.select("text.charger-temperature").attr("x",5).attr("y",34).attr("fill","var(--kip-contrast-dim-color)").attr("font-size",10),u.select("tspan.temperature-metric-value").text(l=>e$1.displayModels[l.key]?.temperatureText??""),u.select("tspan.temperature-metric-unit").attr("dx",1).attr("font-size",6).attr("fill","var(--kip-contrast-dim-color)").text(`${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`),u.select("text.charger-mode").attr("x",5).attr("y",46).attr("font-size",10).attr("fill","var(--kip-contrast-dim-color)").text(l=>e$1.displayModels[l.key]?.modeText??""),b.exit().remove();}resolveTitleText(e,r=false){let t=e.name||`Charger ${e.id}`;return !r||!e.source?t:`${t} [${e.source}]`}resolveModeText(e){if(e.chargingMode)return `Mode: ${e.chargingMode.charAt(0).toUpperCase()+e.chargingMode.slice(1)}`;if(e.mode)return `Mode: ${e.mode}`;let t=[{active:e.ledsAbsorption,label:"Absorption"},{active:e.ledsBulk,label:"Bulk"},{active:e.ledsFloat,label:"Float"},{active:e.ledsInverter,label:"Inverter"},{active:e.ledsLowBattery,label:"Low Battery"},{active:e.ledsMains,label:"Mains"},{active:e.ledsOverload,label:"Overload"},{active:e.ledsTemperature,label:"Temperature"}].filter(i=>i.active===true).map(i=>i.label);return t.length?`Mode: ${t.join(" / ")}`:"Mode --"}resolveShapeMode(e){return (e.chargingMode??e.mode??"").trim().toLowerCase()}isShapeMode(e,r){return !e||!r?false:e===r||e.includes(r)}buildMetricRows(e){return this.renderMode()==="full"||this.renderMode()===null?[`${this.formatValue(e.voltage,1)}`,`${this.formatValue(e.current,1)}`,`Power: ${this.formatValue(e.power,0)}`,`Temp: ${this.formatTemperature(e.temperature)}`]:[`${this.formatValue(e.voltage,1)}`,`${this.formatValue(e.current,1)}`,`P: ${this.formatValue(e.power,0)}`,`T: ${this.formatTemperature(e.temperature)}`]}formatValue(e,r){return e==null||Number.isNaN(e)?"-":`${e.toFixed(r)}`}formatTemperature(e){return e==null||Number.isNaN(e)?"-":`${e.toFixed(0)}`}toStringValue(e){return typeof e=="string"?e: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}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 Number.isFinite(i)?i:t}static \u0275fac=function(r){return new(r||c$1)};static \u0275cmp=JD({type:c$1,selectors:[["widget-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,ge,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["chargerSvg",""],[3,"text","color"],["aria-hidden","false",1,"charger-svg"],[1,"charger-empty"],[1,"charger-empty-title"],[1,"charger-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,me,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.charger-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}.charger-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)}.charger-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.charger-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{le as WidgetChargerComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {G as Gt,L as Lt}from'./chunk-
|
|
1
|
+
import {G as Gt,L as Lt}from'./chunk-BAVmyVwG.js';import {u}from'./chunk-Be5KcT7R.js';import {c}from'./chunk-CRy9Da7a.js';import {d1 as Hj,w,du as p,dv as rt,v as vt,D as Dt,$ as $j,a6 as Lr,dx as n$1,F as Fa,dn as ge,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-F7NMHHV4.js';var O=["compassGauge"];function L(n,p){if(n&1){let a=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(e){ud(a);let o=qw();return dd(o.onResized(e))}),ul();}if(n&2){let a=qw();Bh("options",a.gaugeOptions)("value",a.displayValue()),Hh("value-text",a.textValue())("color-stroke-ticks",a.colorStrokeTicks);}}function z(n){let p=n.match(/(\d+(\.\d+)?|\.\d+)/g);if(!p||p.length<3)throw new Error("Invalid RGBA format");let[a,t,e,o=1]=p.map(Number),s=o===1?"":Math.round(o*255).toString(16).padStart(2,"0").toUpperCase();return "#"+((1<<24)+(a<<16)+(t<<8)+e).toString(16).slice(1).toUpperCase()+s}function U(n){return n<0&&(n=360+n),n}var $=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);static DEFAULT_CONFIG={displayName:"Gauge Label",filterSelfPaths:true,paths:{gaugePath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,showPathSkUnitsFilter:false,pathSkUnitsFilter:"rad",showConvertUnitTo:false,convertUnitTo:"deg",sampleTime:500}},supportAutomaticHistoricalSeries:true,gauge:{type:"ngRadial",subType:"baseplateCompass",enableTicks:true,compassUseNumbers:false,showValueBox:false},enableTimeout:false,color:"contrast",dataTimeout:5};LINE="line";NEEDLE_START=40;NEEDLE_END=100;NEEDLE_CIRCLE_SIZE=15;BORDER_MIDDLE_WIDTH=2;BORDER_INNER_WIDTH=2;ANIMATION_TARGET_PLATE="plate";ANIMATION_TARGET_NEEDLE="needle";textValue=vt("--");value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());ngGauge=$j("compassGauge");gauge=$j("compassGauge",{read:Lr});viewReady=vt(false);gaugeOptions={};colorStrokeTicks="";currentState=vt(n$1.Normal);lastAppliedState=null;negToPortPaths=["self.environment.wind.angleApparent","self.environment.wind.angleTrueGround","self.environment.wind.angleTrueWater","self.environment.wind.angleTrueWaterDamped","self.performance.beatAngle","self.performance.gybeAngle","self.performance.targetAngle","self.performance.optimumWindAngle"];displayName=Dt(()=>this.runtime.options()?.displayName);constructor(){Fa(()=>{let a=this.runtime.options(),t=this.theme();if(!a||!t)return;let e=a.paths?.gaugePath;e?.path&&ge(()=>this.streams.observe("gaugePath",o=>{let s=o?.data?.value??null;if(s==null)this.value.set(0),this.textValue.set("--");else {let r=e.path;r&&this.negToPortPaths.includes(r)&&(s=U(s));let T=Math.min(Math.max(s,0),360);this.value.set(T),this.textValue.set(T.toFixed(0));}let i=o?.state??n$1.Normal;i!==this.currentState()&&this.currentState.set(i);}));}),Fa(()=>{let a=this.runtime.options(),t=this.theme();!a||!t||ge(()=>{if(this.buildGaugeOptions(a,t),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let a=this.ngGauge();!a||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{a.update({animation:!0,animatedValue:!0});}catch(t){}});}catch(t){}});}),Fa(()=>{let a=this.runtime.options(),t=this.theme(),e=this.currentState();!a||!t||this.viewReady()&&e!==this.lastAppliedState&&ge(()=>{let o={};switch(e){case n$1.Emergency:o.colorValueText=t.zoneEmergency;break;case n$1.Alarm:o.colorValueText=t.zoneAlarm;break;case n$1.Warn:o.colorValueText=t.zoneWarn;break;case n$1.Alert:o.colorValueText=t.zoneAlert;break;default:o.colorValueText=t.contrast;break}try{this.ngGauge()?.update(o);}catch(s){}this.lastAppliedState=e;});});}buildGaugeOptions(a,t){let e=this.gaugeOptions={},o=a.paths?.gaugePath;e.title=this.displayName(),e.minValue=0,e.maxValue=360,e.units=o?.convertUnitTo||"",e.valueDec=a.numDecimal??0,e.valueInt=a.numInt??1,e.barProgress=false,e.barWidth=0,e.valueBox=!!a.gauge?.showValueBox,e.fontValueSize=60,e.valueBoxWidth=30,e.valueBoxBorderRadius=10,e.valueBoxStroke=0,e.ticksAngle=360,e.startAngle=180,e.exactTicks=false,e.strokeTicks="",e.majorTicks=a.gauge?.compassUseNumbers?["N","30","60","E","120","150","S","210","240","W","300","330","N"]:["N","NE","E","SE","S","SW","W","NW","N"],e.majorTicksDec=0,e.majorTicksInt=1,e.numbersMargin=5,e.fontNumbersSize=25,e.minorTicks=a.gauge?.compassUseNumbers?3:2,e.needle=true,e.needleType=this.LINE,e.needleStart=this.NEEDLE_START,e.needleEnd=this.NEEDLE_END,e.needleCircleSize=this.NEEDLE_CIRCLE_SIZE,e.needleWidth=4,e.needleShadow=false,e.needleCircleInner=false,e.needleCircleOuter=false,e.borders=true,e.borderOuterWidth=0,e.borderMiddleWidth=this.BORDER_MIDDLE_WIDTH,e.borderInnerWidth=this.BORDER_INNER_WIDTH,e.borderShadowWidth=0,e.highlights=[],e.highlightsWidth=0,e.fontTitle="Roboto",e.fontTitleWeight="normal",e.fontTitleSize=25,e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",a.gauge?.subType==="marineCompass"?(e.animationTarget=this.ANIMATION_TARGET_PLATE,e.useMinPath=true):(e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=true),e.animateOnInit=false,e.animation=this.animationEnabled(),e.animatedValue=this.animationEnabled(),e.animationRule="linear",e.animationDuration=(o?.sampleTime??500)-50;let s=c(a.color??"contrast",t),i=z(s.dim),r=z(c("contrast",t).dim);e.colorBarProgress=s.color,e.colorBorderMiddle=i,e.colorBorderMiddleEnd=i,e.colorNeedle=s.color,e.colorNeedleEnd=s.color,e.colorTitle=r,e.colorUnits=r,e.colorValueText=s.color,e.colorMinorTicks=r,e.colorNumbers=a.gauge?.compassUseNumbers?[t.port,r,r,i,r,r,i,r,r,i,r,r,t.port]:[t.port,i,i,i,i,i,i,i,t.port],e.colorMajorTicks=a.gauge?.compassUseNumbers?[t.port,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.port]:[t.port,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.contrast,t.port],e.colorPlate=e.colorPlateEnd=e.colorBorderInner=e.colorBorderInnerEnd=t.cardColor,e.colorBar=t.background,e.colorBarStroke="",e.colorValueBoxBackground=t.background,e.colorNeedleShadowUp="",e.colorNeedleShadowDown="",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate;}setCanvasSize(){let a=this.gauge()?.nativeElement;if(!a)return;let t=a.getBoundingClientRect(),e={height:t.height,width:t.width};try{this.ngGauge()?.update(e);}catch(o){}}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(a){}}onResized(a){let t={height:a.contentRect.height,width:a.contentRect.width};try{this.ngGauge()?.update(t);}catch(e){}}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-compass"]],viewQuery:function(t,e){t&1&&eg(e.ngGauge,O,5)(e.gauge,O,5,Lr),t&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["compassGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(t,e){t&1&&_w(0,L,2,4,"radial-gauge",1),t&2&&Mw(e.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:10px}"]})}return n})();export{$ as WidgetGaugeNgCompassComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d1 as Hj,w,du as p,dv as rt,aZ as R,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
|
|
1
|
+
import {d1 as Hj,w,du as p,dv as rt,aZ as R,a as G,cu as T,aY as xe,$ as $j,v as vt,F as Fa,dn as ge,a_ as Gp,J as JD,O as Op,bh as xp,y as yt,b as wt,cR as zt,bg as mt,P as Pi,c as $h,u as ul,k as Qh,cn as wd,T as TT,_ as _w,e as EE,M as Mw,f as eg,K as Kw,h as Fw,cV as Td,g as qw,t as pT,dE as RT,B as Bh,aA as gg,l as ud,m as dd,bp as gl}from'./main-F7NMHHV4.js';import {c}from'./chunk-CRy9Da7a.js';var J=["canvasMainRef"];function Z(o,e){if(o&1&&(Pi(0,"div",10),wd(),Pi(1,"svg",11)(2,"text",12),TT(3),ul()()(),Td(),Pi(4,"div",13),wd(),Pi(5,"svg",14)(6,"text",15)(7,"tspan",16),TT(8,"\u2691"),ul(),TT(9),Pi(10,"tspan",17),TT(11,"\u2691"),ul()()()(),Td(),Pi(12,"div",18),wd(),Pi(13,"svg",19)(14,"text",12),TT(15),ul()()()),o&2){let t=qw();EE(3),gg(t.portBiasValue()),EE(6),gl(" ",t.lineLengthValue()," "),EE(6),gg(t.stbBiasValue());}}function K(o,e){if(o&1){let t=Fw();Pi(0,"button",20),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("port"))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",21)(3,"text",22),TT(4,"Port End"),ul()()()(),Td(),Pi(5,"button",23),Qh("click",function(){ud(t);let i=qw();return dd(i.setLineEnd("stb"))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",21)(8,"text",22),TT(9,"Stbd End"),ul()()()();}}function X(o,e){if(o&1){let t=Fw();Pi(0,"button",24),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",5,0))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"+5m"),ul()()()(),Td(),Pi(5,"button",27),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",-5,0))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"-5m"),ul()()()(),Td(),Pi(10,"button",28),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",-5,0))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"-5m"),ul()()()(),Td(),Pi(15,"button",29),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",5,0))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"+5m"),ul()()()();}}function tt(o,e){if(o&1){let t=Fw();Pi(0,"button",30),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(1)))}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"\u21911\xB0"),ul()()()(),Td(),Pi(5,"button",31),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("port",0,i.toRadians(-1)))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",25)(8,"text",26),TT(9,"\u21931\xB0"),ul()()()(),Td(),Pi(10,"button",32),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(1)))}),Pi(11,"mat-icon",6),wd(),Pi(12,"svg",25)(13,"text",26),TT(14,"\u21931\xB0"),ul()()()(),Td(),Pi(15,"button",33),Qh("click",function(){ud(t);let i=qw();return dd(i.adjustLineEnd("stb",0,i.toRadians(-1)))}),Pi(16,"mat-icon",6),wd(),Pi(17,"svg",25)(18,"text",26),TT(19,"\u21911\xB0"),ul()()()();}}function et(o,e){if(o&1){let t=Fw();Pi(0,"button",34),Qh("click",function(){ud(t);let i=qw();return dd(i.nextDisplayLineName())}),Pi(1,"mat-icon",6),wd(),Pi(2,"svg",25)(3,"text",26),TT(4,"Line"),ul()()()(),Td(),Pi(5,"button",35),Qh("click",function(){ud(t);let i=qw();return dd(i.setStartLine(i.getDisplayLineName()))}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",36)(8,"text",37),TT(9),ul()()()();}if(o&2){let t=qw();EE(5),pT(RT("button ",t.isDisplayLineCurrent()?"line-button-current":"line-button")),Bh("matTooltip",RT("Set the ",t.getDisplayLineName()," line as the current line")),EE(4),gg(t.getDisplayLineName());}}function it(o,e){o&1&&$h(0,"div",9);}var Q=class o{id=Hj.required();type=Hj.required();theme=Hj.required();runtime=w(p);streams=w(rt);canvas=w(R);dashboard=w(G);signalk=w(T);destroyRef=w(xe);static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:false,displayName:"DTS",filterSelfPaths:true,playBeeps:true,convertUnitTo:"m",convertUnitToGroup:"Length",numDecimal:0,ignoreZones:true,color:"contrast",enableTimeout:false,dataTimeout:5,paths:{dtsPath:{description:"Distance to Start Line",path:"self.navigation.racing.distanceStartline",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:500},lineLengthPath:{description:"Length of the start line",path:"self.navigation.racing.startLineLength",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},lineBiasPath:{description:"Bias of the start line to starboard end",path:"self.navigation.racing.stbLineBias",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"m",showPathSkUnitsFilter:true,pathSkUnitsFilter:"m",sampleTime:1e3},startLineNamePath:{description:"The current named start line",path:"self.navigation.racing.lines.startLineName",source:"default",pathType:"string",pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},linesPath:{description:"The known named lines",path:"self.navigation.racing.lines.lines",source:"default",pathType:null,pathRequired:false,isPathConfigurable:false,convertUnitTo:void 0,showPathSkUnitsFilter:false,pathSkUnitsFilter:null,sampleTime:1e3},ttlPath:{description:"Time to sail to the start line in seconds",path:"self.navigation.racing.timeToLine",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500},ttbPath:{description:"Time to delay before sailing to the start line in seconds",path:"self.navigation.racing.timeToBurn",source:"default",pathType:"number",pathRequired:false,isPathConfigurable:false,convertUnitTo:"s",showConvertUnitTo:false,showPathSkUnitsFilter:false,pathSkUnitsFilter:"s",sampleTime:500}}};canvasRef=$j.required("canvasMainRef");canvasElement=null;ctx=null;cssWidth=0;cssHeight=0;titleBitmap=null;titleBitmapText=null;titleBitmapColor=null;dtsValue=null;lengthValue=null;biasValue=null;ttlValue=null;ttbValue=null;labelColor=vt("");valueColor="";dtsColor="";maxValueTextWidth=0;maxValueTextHeight=0;displayLineIndex=0;lines=[];startLineName=null;portBiasValue=vt("");lineLengthValue=vt("");stbBiasValue=vt("");mode=vt(0);normalizedConfig=vt(o.DEFAULT_CONFIG);get pathsRecord(){return (this.runtime.options()??o.DEFAULT_CONFIG).paths??{}}constructor(){Fa(()=>{let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.theme();t&&ge(()=>{let a=c(e.color??"contrast",t);this.labelColor.set(a.dim),this.valueColor=a.color,this.draw();});}),Fa(()=>{this.pathsRecord.dtsPath?.path&&ge(()=>this.streams.observe("dtsPath",t=>{this.dtsValue=t?.data?.value??null,this.updateDtsColor(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineLengthPath?.path&&ge(()=>this.streams.observe("lineLengthPath",t=>{this.lengthValue=t?.data?.value??null,this.setLenBias(),this.draw();}));}),Fa(()=>{this.pathsRecord.lineBiasPath?.path&&ge(()=>this.streams.observe("lineBiasPath",t=>{this.biasValue=t?.data?.value??null,this.setLenBias();}));}),Fa(()=>{this.pathsRecord.startLineNamePath?.path&&ge(()=>this.streams.observe("startLineNamePath",t=>{console.log("startLineName: "+JSON.stringify(t??"no data")),this.startLineName=t?.data?.value??null,this.displayLineIndex=0;for(let a=0;a<this.lines.length;a++)if(this.lines[a]===this.startLineName){this.displayLineIndex=a;break}this.draw();}));}),Fa(()=>{this.pathsRecord.linesPath?.path&&ge(()=>this.streams.observe("linesPath",t=>{if(console.log("lines: "+JSON.stringify(t??"no data")),this.lines=["Default"],this.displayLineIndex=0,t?.data?.value&&Array.isArray(t.data.value))for(let a of t.data.value)a.startLineName&&(a.startLineName===this.startLineName&&(this.displayLineIndex=this.lines.length),this.lines.push(a.startLineName));}));}),Fa(()=>{this.pathsRecord.ttlPath?.path&&ge(()=>this.streams.observe("ttlPath",t=>{this.ttlValue=t?.data?.value??null,this.draw();}));}),Fa(()=>{this.pathsRecord.ttbPath?.path&&ge(()=>this.streams.observe("ttbPath",t=>{this.ttbValue=t?.data?.value??null,this.draw();}));}),this.signalk.subscribeRequest().pipe(Gp(this.destroyRef)).subscribe(e=>{e.widgetUUID===this.id()&&e.statusCode===200&&this.beep(600,20);});}ngAfterViewInit(){this.canvasElement=this.canvasRef().nativeElement,this.ctx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(e,t)=>{this.cssWidth=e,this.cssHeight=t,this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}}),this.cssHeight=Math.round(this.canvasElement.getBoundingClientRect().height),this.cssWidth=Math.round(this.canvasElement.getBoundingClientRect().width),this.maxValueTextWidth=Math.floor(this.cssWidth*.95),this.maxValueTextHeight=Math.floor(this.cssHeight*.95),this.draw();}toggleMode(){this.mode.update(e=>(e+1)%5),this.draw();}setLineEnd(e){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,position:"bow"},this.id())??""}adjustLineEnd(e,t,a){return this.signalk.putRequest("navigation.racing.setStartLine",{end:e,delta:t,rotate:a},this.id())??""}nextDisplayLineName(){++this.displayLineIndex>=this.lines.length&&(this.displayLineIndex=0);}getDisplayLineName(){return this.lines[this.displayLineIndex]||"Default"}isDisplayLineCurrent(){return this.getDisplayLineName()===(this.startLineName||"Default")}setStartLine(e){let t=e==="Default"||!e?null:e;this.signalk.putRequest("navigation.racing.setStartLineName",{startLineName:t},this.id()),this.mode.set(0),this.draw();}toRadians(e){return e*(Math.PI/180)}draw(){if(!this.ctx||!this.canvasElement)return;let e=this.runtime.options()??o.DEFAULT_CONFIG,t=e?.displayName||"DTS",a=this.labelColor();(!this.titleBitmap||!e||this.titleBitmap.width!==this.canvasElement.width||this.titleBitmap.height!==this.canvasElement.height||this.titleBitmapText!==t||this.titleBitmapColor!==a)&&(this.titleBitmap=this.canvas.createTitleBitmap(t,a,"normal",this.cssWidth,this.cssHeight),this.titleBitmapText=t,this.titleBitmapColor=a),this.canvas.clearCanvas(this.ctx,this.cssWidth,this.cssHeight),this.titleBitmap&&this.ctx.drawImage(this.titleBitmap,0,0,this.cssWidth,this.cssHeight),this.canvas.drawText(this.ctx,this.getValueText(),Math.floor(this.cssWidth*.5),Math.floor(this.cssHeight*.325),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.55),"bold",this.dtsColor,"center","middle"),this.canvas.drawText(this.ctx,this.pathsRecord.dtsPath?.convertUnitTo||"m",Math.floor(this.cssWidth*.975),Math.floor(this.cssHeight*.6),Math.floor(this.cssWidth*.95),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"right","bottom"),this.canvas.drawText(this.ctx,"TTL",Math.floor(this.cssWidth*.025),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToLineText(),Math.floor(this.cssWidth*.15),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.canvas.drawText(this.ctx,"TTB",Math.floor(this.cssWidth*.525),Math.floor(this.cssHeight*.7),Math.floor(this.cssWidth*.1),Math.floor(this.cssHeight*.15),"normal",this.dtsColor,"left","middle"),this.canvas.drawText(this.ctx,this.getTimeToBurnText(),Math.floor(this.cssWidth*.65),Math.floor(this.cssHeight-.8),Math.floor(this.cssWidth*.35),Math.floor(this.cssHeight*.35),"bold",this.dtsColor,"left","bottom"),this.setLenBias();}getValueText(){if(this.dtsValue===null)return "--";let e=this.runtime.options()??o.DEFAULT_CONFIG;return this.dtsValue.toFixed(e?.numDecimal??0)}toHHMMSS(e){if(e==null||isNaN(e))return "-:--";let t=e<0;t&&(e=-e);let a=Math.floor(e/3600),i=Math.floor(e%3600/60),f=Math.floor(e%60),C=t?"-":"";return a===0?`${C}${i.toString().padStart(1,"0")}:${f.toString().padStart(2,"0")}`:`${C}${a.toString().padStart(1,"0")}:${i.toString().padStart(2,"0")}:${f.toString().padStart(2,"0")}`}getTimeToLineText(){return this.toHHMMSS(this.ttlValue??0)}getTimeToBurnText(){return this.toHHMMSS(this.ttbValue??0)}setLenBias(){let e=this.runtime.options()??o.DEFAULT_CONFIG,t=this.pathsRecord.lineLengthPath,a=this.pathsRecord.lineBiasPath;if(t?.path&&this.lengthValue!=null){let i=t.convertUnitTo;i==="feet"&&(i="\u2032"),this.lineLengthValue.set(`\u2015${this.applyDecorations(this.lengthValue.toFixed(e.numDecimal??0))}${i??""}\u2015`);}if(a?.path&&this.biasValue!=null){let i=a.convertUnitTo;i==="feet"&&(i="\u2032"),this.biasValue<0?(this.portBiasValue.set("+"+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(this.biasValue.toFixed(e.numDecimal??0)+(i??""))):(this.portBiasValue.set(" "+(-this.biasValue).toFixed(e.numDecimal??0)+(i??"")),this.stbBiasValue.set(" +"+this.biasValue.toFixed(e.numDecimal??0)+(i??"")));}}applyDecorations(e){switch(this.pathsRecord.dtsPath?.convertUnitTo){case "percent":case "percentraw":return e+"%";default:return e}}updateDtsColor(){let e=this.theme(),t=this.runtime.options()??o.DEFAULT_CONFIG;e&&(t.ignoreZones?this.dtsValue?this.dtsValue<0?this.dtsColor=e.zoneAlarm:this.dtsValue<10?this.dtsColor=e.zoneWarn:this.dtsValue<20?this.dtsColor=e.zoneAlert:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor:this.dtsColor=this.valueColor);}beep(e=440,t=100){if(!this.runtime.options()?.playBeeps)return;let a=window.AudioContext||window.webkitAudioContext,i=new a,f=i.createOscillator(),C=i.createGain();f.connect(C),C.connect(i.destination),f.type="sine",f.frequency.value=e,C.gain.value=.1,f.start(),f.stop(i.currentTime+t/1e3);}ngOnDestroy(){try{this.canvasElement&&this.canvas.unregisterCanvas(this.canvasElement);}catch(e){}}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=JD({type:o,selectors:[["widget-racer-line"]],viewQuery:function(t,a){t&1&&eg(a.canvasRef,J,5),t&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:16,vars:2,consts:[["canvasMainRef",""],[1,"line-wrapper"],[1,"filler"],[1,"line-canvas"],[1,"buttons-container"],["mat-flat-button","","matTooltip","Select the control mode",1,"button","select-button",3,"click"],[1,"buttons-svg-icon"],["width","100%","height","100%","viewBox","0 0 80 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","40","y","9"],[1,"widgetOverlay"],[1,"pin-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","pin"],["x","33","y","14"],[1,"len-bias-container"],["width","100%","height","100%","viewBox","0 0 90 12","preserveAspectRatio","xMidYMid meet",1,"svg-content","len-bias"],["x","45","y","9"],[1,"pin"],[1,"boat"],[1,"boat-container"],["width","100%","height","100%","viewBox","0 0 70 18","preserveAspectRatio","xMidYMid meet",1,"svg-content","boat"],["mat-flat-button","","matTooltip","Set the port(pin) end of the line to the current position",1,"button","port-button",3,"click"],["width","100%","height","100%","viewBox","0 0 100 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","50","y","11"],["mat-flat-button","","matTooltip","Set the starboard(boat) end of the line to the current position",1,"button","starboard-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["width","100%","height","100%","viewBox","0 0 50 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","25","y","11"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the port(pin) end",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Decrease the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Increase the line length by 5m at the starboard(boat) end",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the port(pin) end 1\xB0 counter-clockwise",1,"button","port-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 counter-clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Rotate the line by moving the starboard(boat) end 1\xB0 clockwise",1,"button","starboard-small-button",3,"click"],["mat-flat-button","","matTooltip","Display the next named line",1,"button","select-button",3,"click"],["mat-flat-button","",3,"click","matTooltip"],["width","100%","height","100%","viewBox","0 0 150 14","preserveAspectRatio","xMidYMid meet",1,"svg-content"],["x","75","y","11"]],template:function(t,a){if(t&1&&(Pi(0,"div",1)(1,"div",2),$h(2,"canvas",3,0),ul(),Pi(4,"div",4)(5,"button",5),Qh("click",function(){return a.toggleMode()}),Pi(6,"mat-icon",6),wd(),Pi(7,"svg",7)(8,"text",8),TT(9,"\u22EE"),ul()()()(),_w(10,Z,16,3)(11,K,10,0)(12,X,20,0)(13,tt,20,0)(14,et,10,6),ul(),_w(15,it,1,0,"div",9),ul()),t&2){let i;EE(10),Mw((i=a.mode())===0?10:i===1?11:i===2?12:i===3?13:i===4?14:-1),EE(5),Mw(a.dashboard.isDashboardStatic()?-1:15);}},dependencies:[Op,xp,yt,wt,zt,mt],styles:["[_nghost-%COMP%]{overflow:clip;display:block;height:100%;width:100%}.line-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.line-canvas[_ngcontent-%COMP%]{position:absolute;width:100%!important;height:76%!important;display:block;top:0;left:0}.filler[_ngcontent-%COMP%]{width:100%;height:76%}.buttons-container[_ngcontent-%COMP%]{display:flex;flex-wrap:nowrap;justify-content:space-between;column-gap:2%;position:relative;height:24%;width:100%;padding:0 10px 14px;z-index:20;pointer-events:auto;align-items:center}.button[_ngcontent-%COMP%]{min-width:0px;width:100%;border-radius:12px;align-items:center;justify-content:center;cursor:pointer;--mat-button-filled-container-height: 100%;--mat-button-filled-horizontal-padding: 0px;--mat-button-filled-icon-spacing: 0px}.select-button[_ngcontent-%COMP%]{flex:none;width:18%;--mat-button-filled-container-color: var(--kip-blue-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-grey-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.line-button-current[_ngcontent-%COMP%]{flex:none;width:58%;--mat-button-filled-container-color: var(--kip-orange-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.port-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-port-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.starboard-small-button[_ngcontent-%COMP%]{flex:1 1 auto;--mat-button-filled-container-color: var(--kip-starboard-color);--mat-button-filled-label-text-color: var(--kip-contrast-color)}.buttons-svg-icon[_ngcontent-%COMP%]{width:100%;height:100%;margin:0;padding:0}.svg-content[_ngcontent-%COMP%]{width:100%;height:100%;padding:0;margin:0}.svg-content[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-family:Roboto;font-size:15px;font-weight:700;text-align:center;text-anchor:middle;font-style:normal;font-variant:normal;font-stretch:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;stroke:none}.pin-container[_ngcontent-%COMP%]{flex-basis:18%}.pin[_ngcontent-%COMP%]{fill:var(--kip-port-color)}.pin[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.len-bias-container[_ngcontent-%COMP%]{flex-basis:35%}.len-bias[_ngcontent-%COMP%]{fill:var(--kip-contrast-color)}.len-bias[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:12px}.boat-container[_ngcontent-%COMP%]{flex-basis:18%}.boat[_ngcontent-%COMP%]{fill:var(--kip-starboard-color)}.boat[_ngcontent-%COMP%] text[_ngcontent-%COMP%]{font-size:19px}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;right:0;bottom:0;color:transparent;z-index:21}"]})};export{Q as WidgetRacerLineComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-BTOTKeBo.js';import {d1 as Hj,w,du as p,dv as rt,aZ as R,dw as S,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,J as JD,_ as _w,c as $h,M as Mw,f as eg,K as Kw,bu as ut,dy as K,ao as ue,a6 as Lr,b0 as Wl,cp as Uh,g as qw,B as Bh}from'./main-YKDNK5VZ.js';import {c}from'./chunk-BIb-xYiS.js';var H=["widgetDataChart"],C=(()=>{class n{theme=Hj.required();color=null;dataPath=null;dataSource=null;convertUnitTo=null;numDecimal=null;yScaleMin=null;yScaleMax=null;inverseYAxis=false;verticalChart=null;datasetUUID=null;unitsService=w(ut);dsService=w(K);ngZone=w(ue);canvasService=w(R);widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.4}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;dsServiceSub=null;datasetConfig=null;dataSourceInfo=null;isDestroyed=false;lastChartSignature=null;config={datasetAverageArray:"sma",showAverageData:false,trackAgainstAverage:false,startScaleAtZero:false,yScaleSuggestedMin:null,yScaleSuggestedMax:null,enableMinMaxScaleLimit:false};constructor(){Fa(()=>{this.theme()&&ge(()=>{this.datasetConfig&&(this.setChartOptions(),this.setDatasetsColors());});});}startChart(){if(!(this.isDestroyed||!this.datasetUUID)&&(this.datasetConfig=this.dsService.getDatasetConfig(this.datasetUUID)??null,this.dataSourceInfo=this.dsService.getDataSourceInfo(this.datasetUUID)??null,this.datasetConfig&&this.dataSourceInfo)){let t=this.buildChartSignature();if(this.chart&&t===this.lastChartSignature)return;this.chart&&t!==this.lastChartSignature&&this.destroyChart(),this.setChartOptions(),this.createDatasets();let i=this.widgetDataChart()?.nativeElement?.getContext("2d");if(!i)return;this.chart=new Wl(i,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions}),this.lastChartSignature=t,this.startStreaming();}}buildChartSignature(){return [this.datasetUUID,this.dataPath,this.dataSource,this.convertUnitTo,this.numDecimal,this.yScaleMin,this.yScaleMax,this.inverseYAxis?"1":"0",this.verticalChart?"1":"0",this.color].join("|")}setChartOptions(){let t=this.datasetConfig,e=this.dataSourceInfo;!t||!e||(this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis=this.verticalChart?"y":"x",this.verticalChart?this.lineChartOptions.scales={x:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}}:this.lineChartOptions.scales={x:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}},this.lineChartOptions.plugins={legend:{display:false},annotation:{annotations:{}},streaming:{duration:e.maxDataPoints*e.sampleTime,delay:e.sampleTime,frameRate:t.timeScaleFormat==="day"?5:t.timeScaleFormat==="hour"?8:t.timeScaleFormat==="minute"?15:30}});}numberOrUndefined(t){return t??void 0}createDatasets(){let t=this.lineChartOptions.scales?.y?.reverse?"start":true;this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:0,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.lineChartData.datasets.push({label:"Average",data:[],order:1,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.setDatasetsColors();}setDatasetsColors(){this.lineChartData.datasets.forEach(t=>{t.borderColor=this.getThemeColors().averageLine,t.backgroundColor=this.getThemeColors().averageFill;});}getThemeColors(){let t=this.color,e={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(t){case "contrast":this.config.trackAgainstAverage?(e.valueLine=this.theme().contrastDimmer,e.valueFill=this.theme().contrastDimmer,e.averageLine=this.theme().contrast,e.averageFill=this.theme().contrast,e.chartValue=e.averageLine):(e.valueLine=this.theme().contrast,e.valueFill=this.theme().contrast,e.averageLine=this.theme().contrastDimmer,e.averageFill=this.theme().contrastDimmer,e.chartValue=this.theme().contrast),e.averageChartLine=this.theme().contrastDim,e.chartLabel=this.theme().contrastDim;break;case "blue":this.config.trackAgainstAverage?(e.valueLine=this.theme().blueDimmer,e.valueFill=this.theme().blueDimmer,e.averageLine=this.theme().blue,e.averageFill=this.theme().blue,e.chartValue=e.averageLine):(e.valueLine=this.theme().blue,e.valueFill=this.theme().blue,e.averageLine=this.theme().blueDimmer,e.averageFill=this.theme().blueDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().blueDim,e.chartLabel=this.theme().contrastDim;break;case "green":this.config.trackAgainstAverage?(e.valueLine=this.theme().greenDimmer,e.valueFill=this.theme().greenDimmer,e.averageLine=this.theme().green,e.averageFill=this.theme().green,e.chartValue=e.averageLine):(e.valueLine=this.theme().green,e.valueFill=this.theme().green,e.averageLine=this.theme().greenDimmer,e.averageFill=this.theme().greenDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greenDim,e.chartLabel=this.theme().contrastDim;break;case "pink":this.config.trackAgainstAverage?(e.valueLine=this.theme().pinkDimmer,e.valueFill=this.theme().pinkDimmer,e.averageLine=this.theme().pink,e.averageFill=this.theme().pink,e.chartValue=e.averageLine):(e.valueLine=this.theme().pink,e.valueFill=this.theme().pink,e.averageLine=this.theme().pinkDimmer,e.averageFill=this.theme().pinkDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().pinkDim,e.chartLabel=this.theme().contrastDim;break;case "orange":this.config.trackAgainstAverage?(e.valueLine=this.theme().orangeDimmer,e.valueFill=this.theme().orangeDimmer,e.averageLine=this.theme().orange,e.averageFill=this.theme().orange,e.chartValue=e.averageLine):(e.valueLine=this.theme().orange,e.valueFill=this.theme().orange,e.averageLine=this.theme().orangeDimmer,e.averageFill=this.theme().orangeDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().orangeDim,e.chartLabel=this.theme().contrastDim;break;case "purple":this.config.trackAgainstAverage?(e.valueLine=this.theme().purpleDimmer,e.valueFill=this.theme().purpleDimmer,e.averageLine=this.theme().purple,e.averageFill=this.theme().purple,e.chartValue=e.averageLine):(e.valueLine=this.theme().purple,e.valueFill=this.theme().purple,e.averageLine=this.theme().purpleDimmer,e.averageFill=this.theme().purpleDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().purpleDim,e.chartLabel=this.theme().contrastDim;break;case "grey":this.config.trackAgainstAverage?(e.valueLine=this.theme().greyDimmer,e.valueFill=this.theme().greyDimmer,e.averageLine=this.theme().grey,e.averageFill=this.theme().grey,e.chartValue=e.averageLine):(e.valueLine=this.theme().grey,e.valueFill=this.theme().grey,e.averageLine=this.theme().greyDimmer,e.averageFill=this.theme().greyDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greyDim,e.chartLabel=this.theme().contrastDim;break;case "yellow":this.config.trackAgainstAverage?(e.valueLine=this.theme().yellowDimmer,e.valueFill=this.theme().yellowDimmer,e.averageLine=this.theme().yellow,e.averageFill=this.theme().yellow,e.chartValue=e.averageLine):(e.valueLine=this.theme().yellow,e.valueFill=this.theme().yellow,e.averageLine=this.theme().yellowDimmer,e.averageFill=this.theme().yellowDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().yellowDim,e.chartLabel=this.theme().contrastDim;break}return e}startStreaming(){if(this.dsServiceSub?.unsubscribe(),!this.datasetUUID||!this.chart)return;let t=this.dsService.getDatasetBatchThenLiveObservable(this.datasetUUID);t&&(this.dsServiceSub=t.subscribe(e=>{if(!(this.isDestroyed||!this.chart||!this.chart.ctx)){if(Array.isArray(e)){let s=this.transformDatasetRows(e,0);if(this.chart.data.datasets[0].data.push(...s),this.config.showAverageData){let r=this.transformDatasetRows(e,this.config.datasetAverageArray);this.chart.data.datasets[1].data.push(...r);}}else {let s=this.transformDatasetRows([e],0)[0];if(this.chart.data.datasets[0].data.push(s),this.config.showAverageData){let r=this.transformDatasetRows([e],this.config.datasetAverageArray)[0];this.chart.data.datasets[1].data.push(r);}}this.ngZone.runOutsideAngular(()=>{if(this.isDestroyed||!this.chart)return;let s=this.chart;s.ctx&&s.update("none");});}}));}destroyChart(){this.dsServiceSub?.unsubscribe(),this.dsServiceSub=null,this.chart?.destroy(),this.chart=null,this.lastChartSignature=null;}transformDatasetRows(t,e){let i=a=>this.unitsService.convertToUnit(this.convertUnitTo??"",a)??a,s=this.verticalChart===true,r=this.config.datasetAverageArray;return t.map(a=>{if(s){if(e===0)return {x:i(a.data.value),y:a.timestamp};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:i(D[r]??a.data.value),y:a.timestamp}}}else {if(e===0)return {x:a.timestamp,y:i(a.data.value)};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:a.timestamp,y:i(D[r]??a.data.value)}}}})}ngOnDestroy(){this.isDestroyed=true,this.destroyChart();let t=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(t,{clear:true,removeFromDom:true});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["minichart"]],viewQuery:function(e,i){e&1&&eg(i.widgetDataChart,H,5,Lr),e&2&&Kw();},inputs:{theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:calc(90% - 10px);position:absolute;bottom:0;border-radius:12px;overflow:hidden}"]})}return n})();var I=["canvasMainRef"];function E(n,P){if(n&1&&$h(0,"minichart",1),n&2){let t=qw();Bh("theme",t.theme());}}var se=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{numericPath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,convertUnitTo:"unitless",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},showMax:false,showMin:false,numDecimal:1,showMiniChart:false,yScaleMin:0,yScaleMax:10,inverseYAxis:false,verticalChart:false,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};runtime=w(p);stream=w(rt);canvas=w(R);datasetLifecycle=w(S);miniChart=$j(C);canvasMainRef=$j.required("canvasMainRef");showMiniChart=vt(false);labelColor=vt("");canvasElement;canvasCtx=null;cssWidth=0;cssHeight=0;backgroundBitmap=null;backgroundBitmapText=null;dataValue=null;maxValue=null;minValue=null;valueColor="";valueStateColor="";maxValueTextWidth=0;maxValueTextHeight=0;maxMinMaxTextWidth=0;maxMinMaxTextHeight=0;streamRegistered=false;pathDataState=null;isDestroyed=false;lastSubscriptionSignature=null;normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);numericPathConfig=Dt(()=>this.normalizedConfig().paths?.numericPath);subscriptionSignature=Dt(()=>{this.normalizedConfig();let e=this.numericPathConfig();if(!e?.path)return null;let i=e.source?.trim()||"default";return [e.path,e.pathType,e.sampleTime,e.convertUnitTo,i,e.suppressBootstrapNull?"1":"0"].join("|")});onNumericValue=t=>{if(this.dataValue=t.data.value,this.minValue===null||this.dataValue<this.minValue?this.minValue=this.dataValue:(this.maxValue===null||this.dataValue>this.maxValue)&&(this.maxValue=this.dataValue),!this.normalizedConfig().ignoreZones&&this.pathDataState!==t.state)switch(this.pathDataState=t.state,t.state){case n$1.Alarm:this.valueStateColor=this.theme().zoneAlarm;break;case n$1.Warn:this.valueStateColor=this.theme().zoneWarn;break;case n$1.Alert:this.valueStateColor=this.theme().zoneAlert;break;default:this.valueStateColor=this.valueColor;break}this.drawWidget();};constructor(){this.showMiniChart.set(this.normalizedConfig().showMiniChart??false),Fa(()=>{let t=this.theme(),e=this.normalizedConfig().color;ge(()=>{t&&e!==void 0&&(this.setColors(),this.drawWidget());});}),Fa(()=>{let t=this.subscriptionSignature();ge(()=>{this.isDestroyed||!this.canvasCtx||t===this.lastSubscriptionSignature&&this.streamRegistered||(this.minValue=null,this.maxValue=null,this.dataValue=null,this.pathDataState=null,this.lastSubscriptionSignature=t,t&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart()));});}),Fa(()=>{let t=this.showMiniChart(),e=this.miniChart(),i=this.normalizedConfig(),s=this.numericPathConfig();[i?.showMiniChart?"1":"0",s?.path??"",s?.source??"default",s?.convertUnitTo??"",i?.numDecimal??"",i?.yScaleMin??"",i?.yScaleMax??"",i?.inverseYAxis?"1":"0",i?.verticalChart?"1":"0",i?.color??""].join("|")&&t&&e&&(this.setMiniChart(),e.startChart());});}ngOnInit(){this.setColors(),this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.calculateMaxMinTextDimensions(),this.drawWidget();}});}ngAfterViewInit(){this.isDestroyed||!this.streamRegistered&&this.subscriptionSignature()&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart());}calculateMaxMinTextDimensions(){this.maxValueTextWidth=Math.floor(this.cssWidth*.85),this.maxValueTextHeight=Math.floor(this.cssHeight*.7),this.maxMinMaxTextWidth=Math.floor(this.cssWidth*.57),this.maxMinMaxTextHeight=Math.floor(this.cssHeight*.1);}manageDatasetAndChart(){let t=this.normalizedConfig(),e=this.numericPathConfig(),i=!!t.showMiniChart;if(this.showMiniChart.set(i),!i){this.datasetLifecycle.removeDatasetIfExists(this.id(),false);return}if(!e||!e.path)return;let s=e.source??"default";this.datasetLifecycle.syncNumericMiniChartDataset(this.id(),e.path,s);}setMiniChart(){let t=this.miniChart(),e=this.normalizedConfig(),i=this.numericPathConfig();t&&(t.dataPath=i?.path??null,t.dataSource=i?.source??"default",t.color=e.color??"contrast",t.convertUnitTo=i?.convertUnitTo??null,t.numDecimal=e.numDecimal??null,t.yScaleMin=e.yScaleMin??null,t.yScaleMax=e.yScaleMax??null,t.inverseYAxis=e.inverseYAxis??false,t.verticalChart=e.verticalChart??null,t.datasetUUID=this.id());}setColors(){let t=this.normalizedConfig(),e=this.theme(),i=t.color??"contrast";this.labelColor.set(c(i,e).dim),this.valueStateColor=this.valueColor=c(i,e).color,this.backgroundBitmap=null,this.backgroundBitmapText=null;}drawWidget(){if(!this.canvasCtx)return;let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"",i=10*this.canvas.scaleFactor,s=5*this.canvas.scaleFactor,r=(t.displayName??"")+"|"+e;(!this.backgroundBitmap||this.backgroundBitmap.width!==this.canvasElement.width||this.backgroundBitmap.height!==this.canvasElement.height||this.backgroundBitmapText!==r)&&(this.backgroundBitmap=this.canvas.renderStaticToBitmap(this.canvasCtx,this.cssWidth,this.cssHeight,a=>{this.canvas.drawTitleInternal(a,t.displayName??"",this.labelColor(),"normal",this.cssWidth,this.cssHeight,.1),["unitless","percent","ratio","latitudeSec","latitudeMin","longitudeSec","longitudeMin"].includes(e)||this.canvas.drawText(a,e,this.cssWidth-i,this.cssHeight-s,Math.floor(this.cssWidth*.25),Math.floor(this.cssHeight*.15),"bold",this.valueColor,"end","bottom");}),this.backgroundBitmapText=r),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.backgroundBitmap&&this.backgroundBitmap.width>0&&this.backgroundBitmap.height>0&&this.canvasCtx.drawImage(this.backgroundBitmap,0,0,this.cssWidth,this.cssHeight),this.drawValue(),(t.showMax||t.showMin)&&this.drawMinMax();}drawValue(){let t=this.getValueText(),e=this.canvasCtx;e&&this.canvas.drawText(e,t,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2*1.15),this.maxValueTextWidth,this.maxValueTextHeight,"bold",this.valueStateColor);}getValueText(){if(this.dataValue===null)return "--";let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"";return ["latitudeSec","latitudeMin","longitudeSec","longitudeMin","D HH:MM:SS"].includes(e)?this.dataValue.toString():this.applyDecorations(this.dataValue.toFixed(t.numDecimal??1))}drawMinMax(){let t=this.normalizedConfig();if(!t.showMin&&!t.showMax)return;let e=t.numDecimal??1,i="";t.showMin&&(i=this.minValue!=null?` Min: ${this.applyDecorations(this.minValue.toFixed(e))}`:" Min: --"),t.showMax&&(i+=this.maxValue!=null?` Max: ${this.applyDecorations(this.maxValue.toFixed(e))}`:" Max: --"),i=i.trim();let s=10*this.canvas.scaleFactor,r=5*this.canvas.scaleFactor,a=this.canvasCtx;a&&this.canvas.drawText(a,i,s,Math.floor(this.cssHeight-r),this.maxMinMaxTextWidth,this.maxMinMaxTextHeight,"normal",this.valueColor,"start","bottom");}applyDecorations(t){switch(this.numericPathConfig()?.convertUnitTo??""){case "percent":case "percentraw":t+="%";break}return t}ngOnDestroy(){this.isDestroyed=true,this.datasetLifecycle.removeDatasetIfExists(this.id(),false);try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["widget-numeric"]],viewQuery:function(e,i){e&1&&eg(i.miniChart,C,5)(i.canvasMainRef,I,5),e&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:1,consts:[["canvasMainRef",""],[3,"theme"],[1,"numeric-canvas"]],template:function(e,i){e&1&&(_w(0,E,1,1,"minichart",1),$h(1,"canvas",2,0)),e&2&&Mw(i.showMiniChart()?0:-1);},dependencies:[C],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.numeric-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.numeric-canvas[_ngcontent-%COMP%]{position:relative;width:100%!important;height:100%!important;display:block}"]})}return n})();export{se as WidgetNumericComponent};
|
|
1
|
+
import'./chunk-CJhkckXA.js';import {d1 as Hj,w,du as p,dv as rt,aZ as R,dw as S,$ as $j,v as vt,D as Dt,dx as n$1,F as Fa,dn as ge,J as JD,_ as _w,c as $h,M as Mw,f as eg,K as Kw,bu as ut,dy as K,ao as ue,a6 as Lr,b0 as Wl,cp as Uh,g as qw,B as Bh}from'./main-F7NMHHV4.js';import {c}from'./chunk-CRy9Da7a.js';var H=["widgetDataChart"],C=(()=>{class n{theme=Hj.required();color=null;dataPath=null;dataSource=null;convertUnitTo=null;numDecimal=null;yScaleMin=null;yScaleMax=null;inverseYAxis=false;verticalChart=null;datasetUUID=null;unitsService=w(ut);dsService=w(K);ngZone=w(ue);canvasService=w(R);widgetDataChart=$j("widgetDataChart",{read:Lr});lineChartData={datasets:[]};lineChartOptions={parsing:false,datasets:{line:{pointRadius:0,pointHoverRadius:0,tension:.4}},animations:{tension:{easing:"easeInOutCubic"}}};lineChartType="line";chart=null;dsServiceSub=null;datasetConfig=null;dataSourceInfo=null;isDestroyed=false;lastChartSignature=null;config={datasetAverageArray:"sma",showAverageData:false,trackAgainstAverage:false,startScaleAtZero:false,yScaleSuggestedMin:null,yScaleSuggestedMax:null,enableMinMaxScaleLimit:false};constructor(){Fa(()=>{this.theme()&&ge(()=>{this.datasetConfig&&(this.setChartOptions(),this.setDatasetsColors());});});}startChart(){if(!(this.isDestroyed||!this.datasetUUID)&&(this.datasetConfig=this.dsService.getDatasetConfig(this.datasetUUID)??null,this.dataSourceInfo=this.dsService.getDataSourceInfo(this.datasetUUID)??null,this.datasetConfig&&this.dataSourceInfo)){let t=this.buildChartSignature();if(this.chart&&t===this.lastChartSignature)return;this.chart&&t!==this.lastChartSignature&&this.destroyChart(),this.setChartOptions(),this.createDatasets();let i=this.widgetDataChart()?.nativeElement?.getContext("2d");if(!i)return;this.chart=new Wl(i,{type:this.lineChartType,data:this.lineChartData,options:this.lineChartOptions}),this.lastChartSignature=t,this.startStreaming();}}buildChartSignature(){return [this.datasetUUID,this.dataPath,this.dataSource,this.convertUnitTo,this.numDecimal,this.yScaleMin,this.yScaleMax,this.inverseYAxis?"1":"0",this.verticalChart?"1":"0",this.color].join("|")}setChartOptions(){let t=this.datasetConfig,e=this.dataSourceInfo;!t||!e||(this.lineChartOptions.maintainAspectRatio=false,this.lineChartOptions.animation=false,this.lineChartOptions.indexAxis=this.verticalChart?"y":"x",this.verticalChart?this.lineChartOptions.scales={x:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}}:this.lineChartOptions.scales={x:{type:"realtime",display:false,title:{display:false},time:{unit:t.timeScaleFormat,minUnit:"second",round:"second",displayFormats:{hour:"k:mm''",minute:"mm''",second:'ss"',millisecond:"SSS"}},ticks:{autoSkip:false,color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}},y:{display:false,position:"right",suggestedMin:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMin),suggestedMax:this.config.enableMinMaxScaleLimit?void 0:this.numberOrUndefined(this.yScaleMax),min:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMin):void 0,max:this.config.enableMinMaxScaleLimit?this.numberOrUndefined(this.yScaleMax):void 0,beginAtZero:this.config.startScaleAtZero,reverse:this.inverseYAxis,title:{display:false,text:"Value Axis",align:"center"},ticks:{maxTicksLimit:8,precision:this.numberOrUndefined(this.numDecimal),color:this.getThemeColors().averageChartLine,major:{enabled:true}},grid:{display:false,color:this.theme().contrastDimmer}}},this.lineChartOptions.plugins={legend:{display:false},annotation:{annotations:{}},streaming:{duration:e.maxDataPoints*e.sampleTime,delay:e.sampleTime,frameRate:t.timeScaleFormat==="day"?5:t.timeScaleFormat==="hour"?8:t.timeScaleFormat==="minute"?15:30}});}numberOrUndefined(t){return t??void 0}createDatasets(){let t=this.lineChartOptions.scales?.y?.reverse?"start":true;this.lineChartData.datasets=[],this.lineChartData.datasets.push({label:"Value",data:[],order:0,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.lineChartData.datasets.push({label:"Average",data:[],order:1,parsing:false,tension:.4,pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:3,fill:t}),this.setDatasetsColors();}setDatasetsColors(){this.lineChartData.datasets.forEach(t=>{t.borderColor=this.getThemeColors().averageLine,t.backgroundColor=this.getThemeColors().averageFill;});}getThemeColors(){let t=this.color,e={valueLine:"",valueFill:"",averageLine:"",averageFill:"",averageChartLine:"",chartLabel:"",chartValue:""};switch(t){case "contrast":this.config.trackAgainstAverage?(e.valueLine=this.theme().contrastDimmer,e.valueFill=this.theme().contrastDimmer,e.averageLine=this.theme().contrast,e.averageFill=this.theme().contrast,e.chartValue=e.averageLine):(e.valueLine=this.theme().contrast,e.valueFill=this.theme().contrast,e.averageLine=this.theme().contrastDimmer,e.averageFill=this.theme().contrastDimmer,e.chartValue=this.theme().contrast),e.averageChartLine=this.theme().contrastDim,e.chartLabel=this.theme().contrastDim;break;case "blue":this.config.trackAgainstAverage?(e.valueLine=this.theme().blueDimmer,e.valueFill=this.theme().blueDimmer,e.averageLine=this.theme().blue,e.averageFill=this.theme().blue,e.chartValue=e.averageLine):(e.valueLine=this.theme().blue,e.valueFill=this.theme().blue,e.averageLine=this.theme().blueDimmer,e.averageFill=this.theme().blueDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().blueDim,e.chartLabel=this.theme().contrastDim;break;case "green":this.config.trackAgainstAverage?(e.valueLine=this.theme().greenDimmer,e.valueFill=this.theme().greenDimmer,e.averageLine=this.theme().green,e.averageFill=this.theme().green,e.chartValue=e.averageLine):(e.valueLine=this.theme().green,e.valueFill=this.theme().green,e.averageLine=this.theme().greenDimmer,e.averageFill=this.theme().greenDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greenDim,e.chartLabel=this.theme().contrastDim;break;case "pink":this.config.trackAgainstAverage?(e.valueLine=this.theme().pinkDimmer,e.valueFill=this.theme().pinkDimmer,e.averageLine=this.theme().pink,e.averageFill=this.theme().pink,e.chartValue=e.averageLine):(e.valueLine=this.theme().pink,e.valueFill=this.theme().pink,e.averageLine=this.theme().pinkDimmer,e.averageFill=this.theme().pinkDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().pinkDim,e.chartLabel=this.theme().contrastDim;break;case "orange":this.config.trackAgainstAverage?(e.valueLine=this.theme().orangeDimmer,e.valueFill=this.theme().orangeDimmer,e.averageLine=this.theme().orange,e.averageFill=this.theme().orange,e.chartValue=e.averageLine):(e.valueLine=this.theme().orange,e.valueFill=this.theme().orange,e.averageLine=this.theme().orangeDimmer,e.averageFill=this.theme().orangeDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().orangeDim,e.chartLabel=this.theme().contrastDim;break;case "purple":this.config.trackAgainstAverage?(e.valueLine=this.theme().purpleDimmer,e.valueFill=this.theme().purpleDimmer,e.averageLine=this.theme().purple,e.averageFill=this.theme().purple,e.chartValue=e.averageLine):(e.valueLine=this.theme().purple,e.valueFill=this.theme().purple,e.averageLine=this.theme().purpleDimmer,e.averageFill=this.theme().purpleDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().purpleDim,e.chartLabel=this.theme().contrastDim;break;case "grey":this.config.trackAgainstAverage?(e.valueLine=this.theme().greyDimmer,e.valueFill=this.theme().greyDimmer,e.averageLine=this.theme().grey,e.averageFill=this.theme().grey,e.chartValue=e.averageLine):(e.valueLine=this.theme().grey,e.valueFill=this.theme().grey,e.averageLine=this.theme().greyDimmer,e.averageFill=this.theme().greyDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().greyDim,e.chartLabel=this.theme().contrastDim;break;case "yellow":this.config.trackAgainstAverage?(e.valueLine=this.theme().yellowDimmer,e.valueFill=this.theme().yellowDimmer,e.averageLine=this.theme().yellow,e.averageFill=this.theme().yellow,e.chartValue=e.averageLine):(e.valueLine=this.theme().yellow,e.valueFill=this.theme().yellow,e.averageLine=this.theme().yellowDimmer,e.averageFill=this.theme().yellowDimmer,e.chartValue=e.valueFill),e.averageChartLine=this.theme().yellowDim,e.chartLabel=this.theme().contrastDim;break}return e}startStreaming(){if(this.dsServiceSub?.unsubscribe(),!this.datasetUUID||!this.chart)return;let t=this.dsService.getDatasetBatchThenLiveObservable(this.datasetUUID);t&&(this.dsServiceSub=t.subscribe(e=>{if(!(this.isDestroyed||!this.chart||!this.chart.ctx)){if(Array.isArray(e)){let s=this.transformDatasetRows(e,0);if(this.chart.data.datasets[0].data.push(...s),this.config.showAverageData){let r=this.transformDatasetRows(e,this.config.datasetAverageArray);this.chart.data.datasets[1].data.push(...r);}}else {let s=this.transformDatasetRows([e],0)[0];if(this.chart.data.datasets[0].data.push(s),this.config.showAverageData){let r=this.transformDatasetRows([e],this.config.datasetAverageArray)[0];this.chart.data.datasets[1].data.push(r);}}this.ngZone.runOutsideAngular(()=>{if(this.isDestroyed||!this.chart)return;let s=this.chart;s.ctx&&s.update("none");});}}));}destroyChart(){this.dsServiceSub?.unsubscribe(),this.dsServiceSub=null,this.chart?.destroy(),this.chart=null,this.lastChartSignature=null;}transformDatasetRows(t,e){let i=a=>this.unitsService.convertToUnit(this.convertUnitTo??"",a)??a,s=this.verticalChart===true,r=this.config.datasetAverageArray;return t.map(a=>{if(s){if(e===0)return {x:i(a.data.value),y:a.timestamp};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:i(D[r]??a.data.value),y:a.timestamp}}}else {if(e===0)return {x:a.timestamp,y:i(a.data.value)};{let D={sma:a.data.sma,ema:a.data.ema,dema:a.data.doubleEma,avg:a.data.lastAverage};return {x:a.timestamp,y:i(D[r]??a.data.value)}}}})}ngOnDestroy(){this.isDestroyed=true,this.destroyChart();let t=this.widgetDataChart?.()?.nativeElement;this.canvasService.releaseCanvas(t,{clear:true,removeFromDom:true});}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["minichart"]],viewQuery:function(e,i){e&1&&eg(i.widgetDataChart,H,5,Lr),e&2&&Kw();},inputs:{theme:[1,"theme"]},decls:2,vars:0,consts:[["widgetDataChart",""],[2,"z-index","inherit"]],template:function(e,i){e&1&&Uh(0,"canvas",1,0);},styles:["[_nghost-%COMP%]{display:block;width:100%;height:calc(90% - 10px);position:absolute;bottom:0;border-radius:12px;overflow:hidden}"]})}return n})();var I=["canvasMainRef"];function E(n,P){if(n&1&&$h(0,"minichart",1),n&2){let t=qw();Bh("theme",t.theme());}}var se=(()=>{class n{id=Hj.required();type=Hj.required();theme=Hj.required();static DEFAULT_CONFIG={supportAutomaticHistoricalSeries:true,displayName:"Gauge Label",filterSelfPaths:true,paths:{numericPath:{description:"Numeric Data",path:null,source:null,pathType:"number",suppressBootstrapNull:true,isPathConfigurable:true,convertUnitTo:"unitless",showPathSkUnitsFilter:true,pathSkUnitsFilter:null,sampleTime:500}},showMax:false,showMin:false,numDecimal:1,showMiniChart:false,yScaleMin:0,yScaleMax:10,inverseYAxis:false,verticalChart:false,color:"contrast",enableTimeout:false,dataTimeout:5,ignoreZones:false};runtime=w(p);stream=w(rt);canvas=w(R);datasetLifecycle=w(S);miniChart=$j(C);canvasMainRef=$j.required("canvasMainRef");showMiniChart=vt(false);labelColor=vt("");canvasElement;canvasCtx=null;cssWidth=0;cssHeight=0;backgroundBitmap=null;backgroundBitmapText=null;dataValue=null;maxValue=null;minValue=null;valueColor="";valueStateColor="";maxValueTextWidth=0;maxValueTextHeight=0;maxMinMaxTextWidth=0;maxMinMaxTextHeight=0;streamRegistered=false;pathDataState=null;isDestroyed=false;lastSubscriptionSignature=null;normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);numericPathConfig=Dt(()=>this.normalizedConfig().paths?.numericPath);subscriptionSignature=Dt(()=>{this.normalizedConfig();let e=this.numericPathConfig();if(!e?.path)return null;let i=e.source?.trim()||"default";return [e.path,e.pathType,e.sampleTime,e.convertUnitTo,i,e.suppressBootstrapNull?"1":"0"].join("|")});onNumericValue=t=>{if(this.dataValue=t.data.value,this.minValue===null||this.dataValue<this.minValue?this.minValue=this.dataValue:(this.maxValue===null||this.dataValue>this.maxValue)&&(this.maxValue=this.dataValue),!this.normalizedConfig().ignoreZones&&this.pathDataState!==t.state)switch(this.pathDataState=t.state,t.state){case n$1.Alarm:this.valueStateColor=this.theme().zoneAlarm;break;case n$1.Warn:this.valueStateColor=this.theme().zoneWarn;break;case n$1.Alert:this.valueStateColor=this.theme().zoneAlert;break;default:this.valueStateColor=this.valueColor;break}this.drawWidget();};constructor(){this.showMiniChart.set(this.normalizedConfig().showMiniChart??false),Fa(()=>{let t=this.theme(),e=this.normalizedConfig().color;ge(()=>{t&&e!==void 0&&(this.setColors(),this.drawWidget());});}),Fa(()=>{let t=this.subscriptionSignature();ge(()=>{this.isDestroyed||!this.canvasCtx||t===this.lastSubscriptionSignature&&this.streamRegistered||(this.minValue=null,this.maxValue=null,this.dataValue=null,this.pathDataState=null,this.lastSubscriptionSignature=t,t&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart()));});}),Fa(()=>{let t=this.showMiniChart(),e=this.miniChart(),i=this.normalizedConfig(),s=this.numericPathConfig();[i?.showMiniChart?"1":"0",s?.path??"",s?.source??"default",s?.convertUnitTo??"",i?.numDecimal??"",i?.yScaleMin??"",i?.yScaleMax??"",i?.inverseYAxis?"1":"0",i?.verticalChart?"1":"0",i?.color??""].join("|")&&t&&e&&(this.setMiniChart(),e.startChart());});}ngOnInit(){this.setColors(),this.canvasElement=this.canvasMainRef().nativeElement,this.canvasCtx=this.canvasElement.getContext("2d"),this.canvas.registerCanvas(this.canvasElement,{autoRelease:true,onResize:(t,e)=>{this.cssWidth=t,this.cssHeight=e,this.calculateMaxMinTextDimensions(),this.drawWidget();}});}ngAfterViewInit(){this.isDestroyed||!this.streamRegistered&&this.subscriptionSignature()&&(this.stream?.observe("numericPath",this.onNumericValue),this.streamRegistered=true,this.manageDatasetAndChart());}calculateMaxMinTextDimensions(){this.maxValueTextWidth=Math.floor(this.cssWidth*.85),this.maxValueTextHeight=Math.floor(this.cssHeight*.7),this.maxMinMaxTextWidth=Math.floor(this.cssWidth*.57),this.maxMinMaxTextHeight=Math.floor(this.cssHeight*.1);}manageDatasetAndChart(){let t=this.normalizedConfig(),e=this.numericPathConfig(),i=!!t.showMiniChart;if(this.showMiniChart.set(i),!i){this.datasetLifecycle.removeDatasetIfExists(this.id(),false);return}if(!e||!e.path)return;let s=e.source??"default";this.datasetLifecycle.syncNumericMiniChartDataset(this.id(),e.path,s);}setMiniChart(){let t=this.miniChart(),e=this.normalizedConfig(),i=this.numericPathConfig();t&&(t.dataPath=i?.path??null,t.dataSource=i?.source??"default",t.color=e.color??"contrast",t.convertUnitTo=i?.convertUnitTo??null,t.numDecimal=e.numDecimal??null,t.yScaleMin=e.yScaleMin??null,t.yScaleMax=e.yScaleMax??null,t.inverseYAxis=e.inverseYAxis??false,t.verticalChart=e.verticalChart??null,t.datasetUUID=this.id());}setColors(){let t=this.normalizedConfig(),e=this.theme(),i=t.color??"contrast";this.labelColor.set(c(i,e).dim),this.valueStateColor=this.valueColor=c(i,e).color,this.backgroundBitmap=null,this.backgroundBitmapText=null;}drawWidget(){if(!this.canvasCtx)return;let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"",i=10*this.canvas.scaleFactor,s=5*this.canvas.scaleFactor,r=(t.displayName??"")+"|"+e;(!this.backgroundBitmap||this.backgroundBitmap.width!==this.canvasElement.width||this.backgroundBitmap.height!==this.canvasElement.height||this.backgroundBitmapText!==r)&&(this.backgroundBitmap=this.canvas.renderStaticToBitmap(this.canvasCtx,this.cssWidth,this.cssHeight,a=>{this.canvas.drawTitleInternal(a,t.displayName??"",this.labelColor(),"normal",this.cssWidth,this.cssHeight,.1),["unitless","percent","ratio","latitudeSec","latitudeMin","longitudeSec","longitudeMin"].includes(e)||this.canvas.drawText(a,e,this.cssWidth-i,this.cssHeight-s,Math.floor(this.cssWidth*.25),Math.floor(this.cssHeight*.15),"bold",this.valueColor,"end","bottom");}),this.backgroundBitmapText=r),this.canvas.clearCanvas(this.canvasCtx,this.cssWidth,this.cssHeight),this.backgroundBitmap&&this.backgroundBitmap.width>0&&this.backgroundBitmap.height>0&&this.canvasCtx.drawImage(this.backgroundBitmap,0,0,this.cssWidth,this.cssHeight),this.drawValue(),(t.showMax||t.showMin)&&this.drawMinMax();}drawValue(){let t=this.getValueText(),e=this.canvasCtx;e&&this.canvas.drawText(e,t,Math.floor(this.cssWidth/2),Math.floor(this.cssHeight/2*1.15),this.maxValueTextWidth,this.maxValueTextHeight,"bold",this.valueStateColor);}getValueText(){if(this.dataValue===null)return "--";let t=this.normalizedConfig(),e=this.numericPathConfig()?.convertUnitTo??"";return ["latitudeSec","latitudeMin","longitudeSec","longitudeMin","D HH:MM:SS"].includes(e)?this.dataValue.toString():this.applyDecorations(this.dataValue.toFixed(t.numDecimal??1))}drawMinMax(){let t=this.normalizedConfig();if(!t.showMin&&!t.showMax)return;let e=t.numDecimal??1,i="";t.showMin&&(i=this.minValue!=null?` Min: ${this.applyDecorations(this.minValue.toFixed(e))}`:" Min: --"),t.showMax&&(i+=this.maxValue!=null?` Max: ${this.applyDecorations(this.maxValue.toFixed(e))}`:" Max: --"),i=i.trim();let s=10*this.canvas.scaleFactor,r=5*this.canvas.scaleFactor,a=this.canvasCtx;a&&this.canvas.drawText(a,i,s,Math.floor(this.cssHeight-r),this.maxMinMaxTextWidth,this.maxMinMaxTextHeight,"normal",this.valueColor,"start","bottom");}applyDecorations(t){switch(this.numericPathConfig()?.convertUnitTo??""){case "percent":case "percentraw":t+="%";break}return t}ngOnDestroy(){this.isDestroyed=true,this.datasetLifecycle.removeDatasetIfExists(this.id(),false);try{this.canvas.unregisterCanvas(this.canvasElement);}catch(t){}}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JD({type:n,selectors:[["widget-numeric"]],viewQuery:function(e,i){e&1&&eg(i.miniChart,C,5)(i.canvasMainRef,I,5),e&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:3,vars:1,consts:[["canvasMainRef",""],[3,"theme"],[1,"numeric-canvas"]],template:function(e,i){e&1&&(_w(0,E,1,1,"minichart",1),$h(1,"canvas",2,0)),e&2&&Mw(i.showMiniChart()?0:-1);},dependencies:[C],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.numeric-wrapper[_ngcontent-%COMP%]{width:100%;height:100%;min-height:1px}.numeric-canvas[_ngcontent-%COMP%]{position:relative;width:100%!important;height:100%!important;display:block}"]})}return n})();export{se as WidgetNumericComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {w as w$1,n as G$1,N,i as ir,W as Wp,E as Em,D as Dt,J as JD,y as yt,b as wt,O as Op,o as eu,p as R,r as f,P as Pi,k as Qh,u as ul,T as TT,c as $h,e as EE,t as pT,B as Bh,x as DA,a as G$2,A as re,C as Ff,H as Dr,I as zA,L as Fp,S as ca,U as Kh,V as L,X as xw,Y as Aw,Z as TI,a0 as _,a1 as vA,a2 as Jt,a3 as Xt$1,a4 as Zt$1,a5 as st,_ as _w,M as Mw,a6 as Lr,a7 as Gj,a8 as H,a9 as ru,aa as N$1,ab as te,ac as Mr,ad as Qe,ae as be,af as Tu,ag as bu,ah as nn,ai as Ar,aj as zm,ak as nw,al as Zj,am as LT,an as Hh,s as sg,ao as ue,ap as Ki,aq as Bn,ar as S,as as ke$1,at as Tp,au as be$1,av as _t,aw as Cu,ax as ry,ay as lv,az as Yj,h as Fw,l as ud,g as qw,m as dd,aA as gg,d as ig,aB as gr,aC as L$1,aD as Ce$1,aE as Sr,v as vt,aF as Pr,aG as tD,aH as j,aI as ms,aJ as wm,aK as wr,aL as me,aM as At$1,aN as wt$1}from'./main-
|
|
1
|
+
import {w as w$1,n as G$1,N,i as ir,W as Wp,E as Em,D as Dt,J as JD,y as yt,b as wt,O as Op,o as eu,p as R,r as f,P as Pi,k as Qh,u as ul,T as TT,c as $h,e as EE,t as pT,B as Bh,x as DA,a as G$2,A as re,C as Ff,H as Dr,I as zA,L as Fp,S as ca,U as Kh,V as L,X as xw,Y as Aw,Z as TI,a0 as _,a1 as vA,a2 as Jt,a3 as Xt$1,a4 as Zt$1,a5 as st,_ as _w,M as Mw,a6 as Lr,a7 as Gj,a8 as H,a9 as ru,aa as N$1,ab as te,ac as Mr,ad as Qe,ae as be,af as Tu,ag as bu,ah as nn,ai as Ar,aj as zm,ak as nw,al as Zj,am as LT,an as Hh,s as sg,ao as ue,ap as Ki,aq as Bn,ar as S,as as ke$1,at as Tp,au as be$1,av as _t,aw as Cu,ax as ry,ay as lv,az as Yj,h as Fw,l as ud,g as qw,m as dd,aA as gg,d as ig,aB as gr,aC as L$1,aD as Ce$1,aE as Sr,v as vt,aF as Pr,aG as tD,aH as j,aI as ms,aJ as wm,aK as wr,aL as me,aM as At$1,aN as wt$1}from'./main-F7NMHHV4.js';function Pe(o){let t=o.cloneNode(true),e=t.querySelectorAll("[id]"),i=o.nodeName.toLowerCase();t.removeAttribute("id");for(let n=0;n<e.length;n++)e[n].removeAttribute("id");return i==="canvas"?Tt(o,t):(i==="input"||i==="select"||i==="textarea")&&It(o,t),Rt("canvas",o,t,Tt),Rt("input, textarea, select",o,t,It),t}function Rt(o,t,e,i){let n=t.querySelectorAll(o);if(n.length){let s=e.querySelectorAll(o);for(let r=0;r<n.length;r++)i(n[r],s[r]);}}var si=0;function It(o,t){t.type!=="file"&&(t.value=o.value),t.type==="radio"&&t.name&&(t.name=`mat-clone-${t.name}-${si++}`);}function Tt(o,t){let e=t.getContext("2d");if(e)try{e.drawImage(o,0,0);}catch(i){}}function Te(o){let t=o.getBoundingClientRect();return {top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height,x:t.x,y:t.y}}function ye(o,t,e){let{top:i,bottom:n,left:s,right:r}=o;return e>=i&&e<=n&&t>=s&&t<=r}function oi(o,t){let e=t.left<o.left,i=t.left+t.width>o.right,n=t.top<o.top,s=t.top+t.height>o.bottom;return e||i||n||s}function G(o,t,e){o.top+=t,o.bottom=o.top+o.height,o.left+=e,o.right=o.left+o.width;}function kt(o,t,e,i){let{top:n,right:s,bottom:r,left:a,width:l,height:d}=o,h=l*t,v=d*t;return i>n-v&&i<r+v&&e>a-h&&e<s+h}var X=class{_document;positions=new Map;constructor(t){this._document=t;}clear(){this.positions.clear();}cache(t){this.clear(),this.positions.set(this._document,{scrollPosition:this.getViewportScrollPosition()}),t.forEach(e=>{this.positions.set(e,{scrollPosition:{top:e.scrollTop,left:e.scrollLeft},clientRect:Te(e)});});}handleScroll(t){let e=me(t),i=this.positions.get(e);if(!i)return null;let n=i.scrollPosition,s,r;if(e===this._document){let d=this.getViewportScrollPosition();s=d.top,r=d.left;}else s=e.scrollTop,r=e.scrollLeft;let a=n.top-s,l=n.left-r;return this.positions.forEach((d,h)=>{d.clientRect&&e!==h&&e.contains(h)&&G(d.clientRect,a,l);}),n.top=s,n.left=r,{top:a,left:l}}getViewportScrollPosition(){return {top:window.scrollY,left:window.scrollX}}};function Wt(o,t){let e=o.rootNodes;if(e.length===1&&e[0].nodeType===t.ELEMENT_NODE)return e[0];let i=t.createElement("div");return e.forEach(n=>i.appendChild(n)),i}function ke(o,t,e){for(let i in t)if(t.hasOwnProperty(i)){let n=t[i];n?o.setProperty(i,n,e?.has(i)?"important":""):o.removeProperty(i);}return o}function A(o,t){let e=t?"":"none";ke(o.style,{"touch-action":t?"":"none","-webkit-user-drag":t?"":"none","-webkit-tap-highlight-color":t?"":"transparent","user-select":e,"-ms-user-select":e,"-webkit-user-select":e,"-moz-user-select":e});}function Ot(o,t,e){ke(o.style,{position:t?"":"fixed",top:t?"":"0",opacity:t?"":"0",left:t?"":"-999em"},e);}function J(o,t){return t&&t!="none"?o+" "+t:o}function Mt(o,t){o.style.width=`${t.width}px`,o.style.height=`${t.height}px`,o.style.transform=$(t.left,t.top);}function $(o,t){return `translate3d(${Math.round(o)}px, ${Math.round(t)}px, 0)`}var V={capture:true},we={passive:false,capture:true},ri=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275cmp=JD({type:o,selectors:[["ng-component"]],hostAttrs:["cdk-drag-resets-container",""],decls:0,vars:0,template:function(i,n){},styles:[`@layer cdk-resets {
|
|
2
2
|
.cdk-drag-preview {
|
|
3
3
|
background: none;
|
|
4
4
|
border: none;
|
|
@@ -1 +1 @@
|
|
|
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 ie=["acSvg"];function re(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No AC buses detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K AC paths or select buses in widget settings."),ul()());}var Y=class l{static AC_DESCRIPTOR=a("widget-ac");static SELF_ROOT_PATH=(()=>{let e=l.AC_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAcComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;static ROOT_PREFIX=`${l.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 RESERVED_AC_AGGREGATE_IDS=new Set(["totalCurrent","totalPower"]);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,ac:{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("acSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredBusIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["line1Voltage","line1Current","line1Frequency","line2Voltage"]});busesByKey=vt({});visibleBusKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(r=>r.key);let i=this.busesByKey(),t=new Set(this.discoveredBusIds());return Object.keys(i).filter(r=>{let s=i[r];return !!s&&t.has(s.id)}).sort((r,s)=>r.localeCompare(s))});visibleBuses=Dt(()=>{let e=this.visibleBusKeys(),i=this.busesByKey();return e.map(t=>i[t]).filter(t=>!!t)});hasBuses=Dt(()=>this.visibleBuses().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.visibleBuses();return e.length!==1?"AC Buses":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.visibleBuses(),i=this.theme(),t=this.widgetColors(),r=this.ignoreZones(),s=new Map;e$1.forEach(n=>s.set(n.id,(s.get(n.id)??0)+1));let c=new Set([...s.entries()].filter(([,n])=>n>1).map(([n])=>n)),a={};for(let n of e$1){let d=n.deviceKey??n.id,o=!!n.source&&c.has(n.id),h=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null,n.modeState??null),v=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line1FrequencyState??null),T=this.resolveMostSevereState(n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null),[M,I]=this.buildMetricRows(n);a[d]={id:n.id,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":this.resolveModeText(n),busText:this.isCompactCardMode()?"":o?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:M,metricsLineTwo:I,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",i,r),titleTextColor:e(h,"var(--kip-contrast-color)",i,r),metaTextColor:e(n.modeState??null,"var(--kip-contrast-dim-color)",i,r),primaryMetricsTextColor:e(v,"var(--kip-contrast-color)",i,r),secondaryMetricsTextColor:e(T,"var(--kip-contrast-color)",i,r)};}return a});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),r=this.visibleBuses(),s=this.widgetColors();!this.svg||!s||this.requestRender({buses:r,displayModels:t,widgetColors:s});});let e=[this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN)],i=false;for(let t of e)if(t.initial.length){i=true;for(let r of t.initial)this.enqueuePathUpdate(r,true);}i&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(r=>this.enqueuePathUpdate(r));}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 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","AC View"),this.layer=this.svg.append("g").attr("class","ac-layer");}applyConfig(e){let i=this.resolveAcConfig(e);this.trackedDevices.set(i.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(i.trackedDevices??[]),this.optionsById.set(i.optionsById),this.cardMode.set(this.normalizeCardMode(i.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let i=new Map;e.forEach(t=>{let r=i.get(t.id)??[];r.push(t.key),i.set(t.id,r);}),this.busesByKey.update(t=>{let r=t,s=false;return i.forEach((c,a)=>{let n=t[a];if(n){for(let d of c){if(t[d])continue;let o=e.find(h=>h.key===d);s||(r=G({},t),s=true),r[d]=z(G({},n),{source:o?.source??null,deviceKey:d});}s&&r[a]?.deviceKey===void 0&&delete r[a];}}),s?r:t});}resolveAcConfig(e){let i=e.ac;return {trackedDevices:this.normalizeAcTrackedDevices(i?.trackedDevices),optionsById:this.normalizeOptionsById(i?.optionsById),cardMode:this.normalizeCardMode(i?.cardMode)}}normalizeAcTrackedDevices(e){if(!Array.isArray(e))return [];let i=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let r=t,s=this.normalizeOptionalString(r.id),c=this.normalizeOptionalString(r.source);if(!s||!c||l.RESERVED_AC_AGGREGATE_IDS.has(s))return;let a=this.normalizeOptionalString(r.key)??`${s}||${c}`;i.set(a,{id:s,source:c,key:a});}),[...i.values()].sort((t,r)=>t.key.localeCompare(r.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(i=>{let t=e.get(i.id)??[];t.push(i.key),e.set(i.id,t);}),e}normalizeCardMode(e){let i=e&&typeof e=="object"?e:null,t=this.normalizeStringList(i?.metrics);return {displayMode:i?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["line1Voltage","line1Current","line1Frequency","line2Voltage"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let i=new Set;return e.forEach(t=>{if(typeof t!="string")return;let r=t.trim();r.length>0&&i.add(r);}),[...i].sort((t,r)=>t.localeCompare(r))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let i={};return Object.entries(e).forEach(([t])=>{let r=this.normalizeOptionalString(t);r&&(i[r]={});}),i}normalizeOptionalString(e){if(typeof e!="string")return null;let i=e.trim();return i.length>0?i:null}enqueuePathUpdate(e,i=false){let t=this.parsePath(e.path);if(!t)return;let r=e.update?.data?.value??null,s=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:r,state:s}),!i){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(r=>r.id)).forEach(r=>this.trackDiscoveredBus(r));let t=this.buildIdToDeviceKeysMap();this.busesByKey.update(r=>{let s=r,c=false;for(let a of e){let n=t.get(a.id),d=n?.length?n:[a.id];for(let o of d){let h=!!n?.length,v=h?this.trackedDevices().find(Z=>Z.key===o):null,T=s[o]??{id:a.id,source:v?.source??null,deviceKey:h?o:void 0},M=G({},T);this.applyValue(M,a.key,a.value,a.state)&&(c||(s=G({},s),c=true),s[o]=M);}}return c?s:r});}parsePath(e){if(!e.startsWith(l.ROOT_PREFIX))return null;let i=e.slice(l.ROOT_PREFIX.length),t=i.indexOf(".");return t<=0||t===i.length-1?null:{id:i.slice(0,t),key:i.slice(t+1)}}normalizeMetricKey(e){let i=e.match(/^phase\.([^.]+)\.(current|frequency|lineNeutralVoltage|realPower)$/);if(i){let t=this.resolveLineKey(i[1]);if(!t)return null;let r=i[2];return r==="current"?`${t}.current`:r==="frequency"?`${t}.frequency`:r==="lineNeutralVoltage"?`${t}.voltage`:`${t}.realPower`}return e==="total.realPower"?"power":e}resolveLineKey(e){let i=e.trim().toLowerCase();return ["0","1","l1","line1","phase1","a"].includes(i)?"line1":["2","l2","line2","phase2","b"].includes(i)?"line2":["3","l3","line3","phase3","c"].includes(i)?"line3":null}trackDiscoveredBus(e){let i=this.discoveredBusIds();i.includes(e)||this.discoveredBusIds.set([...i,e].sort((t,r)=>t.localeCompare(r)));}applyValue(e,i,t,r){let s=this.normalizeMetricKey(i);if(!s)return false;switch(s){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 "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),r);case "voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "line1.current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "line1.frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.realPower":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);case "line2.voltage":return this.setMetricValue(e,"line2Voltage","line2VoltageState",this.toNumber(t,"V"),r);case "line2.current":return this.setMetricValue(e,"line2Current","line2CurrentState",this.toNumber(t,"A"),r);case "line2.frequency":return this.setMetricValue(e,"line2Frequency","line2FrequencyState",this.toNumber(t,"Hz"),r);case "line2.realPower":return this.setMetricValue(e,"power","line2CurrentState",this.toNumber(t,"W"),r);case "line3.voltage":return this.setMetricValue(e,"line3Voltage","line3VoltageState",this.toNumber(t,"V"),r);case "line3.current":return this.setMetricValue(e,"line3Current","line3CurrentState",this.toNumber(t,"A"),r);case "line3.frequency":return this.setMetricValue(e,"line3Frequency","line3FrequencyState",this.toNumber(t,"Hz"),r);case "line3.realPower":return this.setMetricValue(e,"power","line3CurrentState",this.toNumber(t,"W"),r);case "power":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);default:return false}}setValue(e,i,t){return Object.is(e[i],t)?false:(e[i]=t,true)}setMetricValue(e,i,t,r,s){let c=!Object.is(e[i],r),a=!Object.is(e[t],s);return !c&&!a?false:(e[i]=r,e[t]=s,true)}requestRender(e){let i=this.widgetColors();!this.svg||!i||(this.pendingRenderSnapshot=e??{buses:this.visibleBuses(),displayModels:this.displayModels(),widgetColors:i},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 i=this.isCompactCardMode(),t=i?C:e$1,r=i?l.COMPACT_CARD_HEIGHT:l.CARD_HEIGHT,s=e.buses.map((o,h)=>({key:o.deviceKey??o.id,bus:o,y:h*(r+l.CARD_GAP)})),c=s.length?s[s.length-1].y+r:r;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${c}`);let a=this.layer.selectAll("g.ac-card").data(s,o=>o.key),n=a.enter().append("g").attr("class","ac-card");n.append("rect").attr("class","ac-state-bar"),n.append("text").attr("class","ac-title"),n.append("text").attr("class","ac-id"),n.append("text").attr("class","ac-mode"),n.append("text").attr("class","ac-bus"),n.append("text").attr("class","ac-metrics-1"),n.append("text").attr("class","ac-metrics-2");let d=n.merge(a);d.attr("transform",o=>`translate(0, ${o.y})`),d.select("rect.ac-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",r-3).attr("fill",o=>e.displayModels[o.key]?.stateBarColor??e.widgetColors.dim),e.buses.length>1?d.select("text.ac-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",o=>e.displayModels[o.key]?.titleTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.titleText??this.resolveTitleText(o.bus)):d.select("text.ac-title").text(""),d.select("text.ac-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(o=>o.bus.id),d.select("text.ac-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.modeText??""),d.select("text.ac-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.busText??""),d.select("text.ac-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>e.displayModels[o.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineOne??""),d.select("text.ac-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",o=>e.displayModels[o.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineTwo??""),a.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`AC ${e.id}`}resolveModeText(e){return e.mode?`Mode ${e.mode}`:"Mode -"}buildMetricRows(e){let i=this.cardMode(),t=(i.metrics.length?i.metrics:l.DEFAULT_CONFIG.ac?.cardMode?.metrics??[]).map(c=>this.toMetricLabel(c,e)).filter(c=>!!c);if(!t.length)return ["L1 - - -","L2 - - L3 - -"];let r=t.slice(0,2).join(" "),s=t.slice(2,4).join(" ");return [r||" ",s||" "]}toMetricLabel(e,i){switch(e){case "line1Voltage":return `L1V ${this.formatValue(i.line1Voltage,"V")}`;case "line1Current":return `L1A ${this.formatValue(i.line1Current,"A")}`;case "line1Frequency":return `L1Hz ${this.formatValue(i.line1Frequency,"Hz")}`;case "line2Voltage":return `L2V ${this.formatValue(i.line2Voltage,"V")}`;case "line2Current":return `L2A ${this.formatValue(i.line2Current,"A")}`;case "line2Frequency":return `L2Hz ${this.formatValue(i.line2Frequency,"Hz")}`;case "line3Voltage":return `L3V ${this.formatValue(i.line3Voltage,"V")}`;case "line3Current":return `L3A ${this.formatValue(i.line3Current,"A")}`;case "line3Frequency":return `L3Hz ${this.formatValue(i.line3Frequency,"Hz")}`;default:return null}}formatValue(e,i){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${i}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(i=>i===n$1.Alert)?n$1.Alert:e.some(i=>i===n$1.Alarm)?n$1.Alarm:e.some(i=>i===n$1.Warn)?n$1.Warn:e.some(i=>i===n$1.Normal)?n$1.Normal:null}toNumber(e,i){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let r=this.units.convertToUnit(i,t);return typeof r=="number"&&Number.isFinite(r)?r:null}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ac"]],viewQuery:function(i,t){i&1&&eg(t.svgRef,ie,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["acSvg",""],[3,"text","color"],["aria-hidden","false",1,"ac-svg"],[1,"ac-empty"],[1,"ac-empty-title"],[1,"ac-empty-sub"]],template:function(i,t){i&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,re,5,0,"div",3)),i&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasBuses()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ac-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}.ac-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)}.ac-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.ac-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Y as WidgetAcComponent};
|
|
1
|
+
import {C,e as e$1}from'./chunk-CzEDfe2A.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-F7NMHHV4.js';import {c,e}from'./chunk-CRy9Da7a.js';var ie=["acSvg"];function re(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No AC buses detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K AC paths or select buses in widget settings."),ul()());}var Y=class l{static AC_DESCRIPTOR=a("widget-ac");static SELF_ROOT_PATH=(()=>{let e=l.AC_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetAcComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;static ROOT_PREFIX=`${l.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 RESERVED_AC_AGGREGATE_IDS=new Set(["totalCurrent","totalPower"]);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,ac:{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("acSvg");svg;layer;pendingPathUpdates=new Map;pathBatchTimerId=null;initialPathPaintDone=false;renderFrameId=null;pendingRenderSnapshot=null;discoveredBusIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["line1Voltage","line1Current","line1Frequency","line2Voltage"]});busesByKey=vt({});visibleBusKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(r=>r.key);let i=this.busesByKey(),t=new Set(this.discoveredBusIds());return Object.keys(i).filter(r=>{let s=i[r];return !!s&&t.has(s.id)}).sort((r,s)=>r.localeCompare(s))});visibleBuses=Dt(()=>{let e=this.visibleBusKeys(),i=this.busesByKey();return e.map(t=>i[t]).filter(t=>!!t)});hasBuses=Dt(()=>this.visibleBuses().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.visibleBuses();return e.length!==1?"AC Buses":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.visibleBuses(),i=this.theme(),t=this.widgetColors(),r=this.ignoreZones(),s=new Map;e$1.forEach(n=>s.set(n.id,(s.get(n.id)??0)+1));let c=new Set([...s.entries()].filter(([,n])=>n>1).map(([n])=>n)),a={};for(let n of e$1){let d=n.deviceKey??n.id,o=!!n.source&&c.has(n.id),h=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null,n.modeState??null),v=this.resolveMostSevereState(n.line1VoltageState??null,n.line1CurrentState??null,n.line1FrequencyState??null),T=this.resolveMostSevereState(n.line2VoltageState??null,n.line2CurrentState??null,n.line3VoltageState??null,n.line3CurrentState??null),[M,I]=this.buildMetricRows(n);a[d]={id:n.id,titleText:this.resolveTitleText(n),modeText:this.isCompactCardMode()?"":this.resolveModeText(n),busText:this.isCompactCardMode()?"":o?n.source??"-":n.associatedBus||n.location||"-",metricsLineOne:M,metricsLineTwo:I,stateBarColor:e(h,t?.dim??"var(--kip-contrast-color)",i,r),titleTextColor:e(h,"var(--kip-contrast-color)",i,r),metaTextColor:e(n.modeState??null,"var(--kip-contrast-dim-color)",i,r),primaryMetricsTextColor:e(v,"var(--kip-contrast-color)",i,r),secondaryMetricsTextColor:e(T,"var(--kip-contrast-color)",i,r)};}return a});constructor(){Fa(()=>{let t=this.runtime.options();t&&ge(()=>this.applyConfig(t));}),Fa(()=>{let t=this.displayModels(),r=this.visibleBuses(),s=this.widgetColors();!this.svg||!s||this.requestRender({buses:r,displayModels:t,widgetColors:s});});let e=[this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN)],i=false;for(let t of e)if(t.initial.length){i=true;for(let r of t.initial)this.enqueuePathUpdate(r,true);}i&&(this.flushPendingPathUpdates(),this.initialPathPaintDone=true);for(let t of e)t.live$.pipe(Gp(this.destroyRef)).subscribe(r=>this.enqueuePathUpdate(r));}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 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","AC View"),this.layer=this.svg.append("g").attr("class","ac-layer");}applyConfig(e){let i=this.resolveAcConfig(e);this.trackedDevices.set(i.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(i.trackedDevices??[]),this.optionsById.set(i.optionsById),this.cardMode.set(this.normalizeCardMode(i.cardMode));}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let i=new Map;e.forEach(t=>{let r=i.get(t.id)??[];r.push(t.key),i.set(t.id,r);}),this.busesByKey.update(t=>{let r=t,s=false;return i.forEach((c,a)=>{let n=t[a];if(n){for(let d of c){if(t[d])continue;let o=e.find(h=>h.key===d);s||(r=G({},t),s=true),r[d]=z(G({},n),{source:o?.source??null,deviceKey:d});}s&&r[a]?.deviceKey===void 0&&delete r[a];}}),s?r:t});}resolveAcConfig(e){let i=e.ac;return {trackedDevices:this.normalizeAcTrackedDevices(i?.trackedDevices),optionsById:this.normalizeOptionsById(i?.optionsById),cardMode:this.normalizeCardMode(i?.cardMode)}}normalizeAcTrackedDevices(e){if(!Array.isArray(e))return [];let i=new Map;return e.forEach(t=>{if(!t||typeof t!="object")return;let r=t,s=this.normalizeOptionalString(r.id),c=this.normalizeOptionalString(r.source);if(!s||!c||l.RESERVED_AC_AGGREGATE_IDS.has(s))return;let a=this.normalizeOptionalString(r.key)??`${s}||${c}`;i.set(a,{id:s,source:c,key:a});}),[...i.values()].sort((t,r)=>t.key.localeCompare(r.key))}buildIdToDeviceKeysMap(){let e=new Map;return this.trackedDevices().forEach(i=>{let t=e.get(i.id)??[];t.push(i.key),e.set(i.id,t);}),e}normalizeCardMode(e){let i=e&&typeof e=="object"?e:null,t=this.normalizeStringList(i?.metrics);return {displayMode:i?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["line1Voltage","line1Current","line1Frequency","line2Voltage"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let i=new Set;return e.forEach(t=>{if(typeof t!="string")return;let r=t.trim();r.length>0&&i.add(r);}),[...i].sort((t,r)=>t.localeCompare(r))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let i={};return Object.entries(e).forEach(([t])=>{let r=this.normalizeOptionalString(t);r&&(i[r]={});}),i}normalizeOptionalString(e){if(typeof e!="string")return null;let i=e.trim();return i.length>0?i:null}enqueuePathUpdate(e,i=false){let t=this.parsePath(e.path);if(!t)return;let r=e.update?.data?.value??null,s=e.update?.state??null;if(this.pendingPathUpdates.set(`${t.id}::${t.key}`,{id:t.id,key:t.key,value:r,state:s}),!i){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(r=>r.id)).forEach(r=>this.trackDiscoveredBus(r));let t=this.buildIdToDeviceKeysMap();this.busesByKey.update(r=>{let s=r,c=false;for(let a of e){let n=t.get(a.id),d=n?.length?n:[a.id];for(let o of d){let h=!!n?.length,v=h?this.trackedDevices().find(Z=>Z.key===o):null,T=s[o]??{id:a.id,source:v?.source??null,deviceKey:h?o:void 0},M=G({},T);this.applyValue(M,a.key,a.value,a.state)&&(c||(s=G({},s),c=true),s[o]=M);}}return c?s:r});}parsePath(e){if(!e.startsWith(l.ROOT_PREFIX))return null;let i=e.slice(l.ROOT_PREFIX.length),t=i.indexOf(".");return t<=0||t===i.length-1?null:{id:i.slice(0,t),key:i.slice(t+1)}}normalizeMetricKey(e){let i=e.match(/^phase\.([^.]+)\.(current|frequency|lineNeutralVoltage|realPower)$/);if(i){let t=this.resolveLineKey(i[1]);if(!t)return null;let r=i[2];return r==="current"?`${t}.current`:r==="frequency"?`${t}.frequency`:r==="lineNeutralVoltage"?`${t}.voltage`:`${t}.realPower`}return e==="total.realPower"?"power":e}resolveLineKey(e){let i=e.trim().toLowerCase();return ["0","1","l1","line1","phase1","a"].includes(i)?"line1":["2","l2","line2","phase2","b"].includes(i)?"line2":["3","l3","line3","phase3","c"].includes(i)?"line3":null}trackDiscoveredBus(e){let i=this.discoveredBusIds();i.includes(e)||this.discoveredBusIds.set([...i,e].sort((t,r)=>t.localeCompare(r)));}applyValue(e,i,t,r){let s=this.normalizeMetricKey(i);if(!s)return false;switch(s){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 "mode":return this.setMetricValue(e,"mode","modeState",this.toStringValue(t),r);case "voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.voltage":return this.setMetricValue(e,"line1Voltage","line1VoltageState",this.toNumber(t,"V"),r);case "line1.current":return this.setMetricValue(e,"line1Current","line1CurrentState",this.toNumber(t,"A"),r);case "line1.frequency":return this.setMetricValue(e,"line1Frequency","line1FrequencyState",this.toNumber(t,"Hz"),r);case "line1.realPower":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);case "line2.voltage":return this.setMetricValue(e,"line2Voltage","line2VoltageState",this.toNumber(t,"V"),r);case "line2.current":return this.setMetricValue(e,"line2Current","line2CurrentState",this.toNumber(t,"A"),r);case "line2.frequency":return this.setMetricValue(e,"line2Frequency","line2FrequencyState",this.toNumber(t,"Hz"),r);case "line2.realPower":return this.setMetricValue(e,"power","line2CurrentState",this.toNumber(t,"W"),r);case "line3.voltage":return this.setMetricValue(e,"line3Voltage","line3VoltageState",this.toNumber(t,"V"),r);case "line3.current":return this.setMetricValue(e,"line3Current","line3CurrentState",this.toNumber(t,"A"),r);case "line3.frequency":return this.setMetricValue(e,"line3Frequency","line3FrequencyState",this.toNumber(t,"Hz"),r);case "line3.realPower":return this.setMetricValue(e,"power","line3CurrentState",this.toNumber(t,"W"),r);case "power":return this.setMetricValue(e,"power","line1CurrentState",this.toNumber(t,"W"),r);default:return false}}setValue(e,i,t){return Object.is(e[i],t)?false:(e[i]=t,true)}setMetricValue(e,i,t,r,s){let c=!Object.is(e[i],r),a=!Object.is(e[t],s);return !c&&!a?false:(e[i]=r,e[t]=s,true)}requestRender(e){let i=this.widgetColors();!this.svg||!i||(this.pendingRenderSnapshot=e??{buses:this.visibleBuses(),displayModels:this.displayModels(),widgetColors:i},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 i=this.isCompactCardMode(),t=i?C:e$1,r=i?l.COMPACT_CARD_HEIGHT:l.CARD_HEIGHT,s=e.buses.map((o,h)=>({key:o.deviceKey??o.id,bus:o,y:h*(r+l.CARD_GAP)})),c=s.length?s[s.length-1].y+r:r;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${c}`);let a=this.layer.selectAll("g.ac-card").data(s,o=>o.key),n=a.enter().append("g").attr("class","ac-card");n.append("rect").attr("class","ac-state-bar"),n.append("text").attr("class","ac-title"),n.append("text").attr("class","ac-id"),n.append("text").attr("class","ac-mode"),n.append("text").attr("class","ac-bus"),n.append("text").attr("class","ac-metrics-1"),n.append("text").attr("class","ac-metrics-2");let d=n.merge(a);d.attr("transform",o=>`translate(0, ${o.y})`),d.select("rect.ac-state-bar").attr("x",1.5).attr("y",1.5).attr("rx",t.stateBarCornerRadius).attr("ry",t.stateBarCornerRadius).attr("width",3).attr("height",r-3).attr("fill",o=>e.displayModels[o.key]?.stateBarColor??e.widgetColors.dim),e.buses.length>1?d.select("text.ac-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill",o=>e.displayModels[o.key]?.titleTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.titleText??this.resolveTitleText(o.bus)):d.select("text.ac-title").text(""),d.select("text.ac-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(o=>o.bus.id),d.select("text.ac-mode").attr("x",t.metaLeftX).attr("y",t.metaY).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.modeText??""),d.select("text.ac-bus").attr("x",t.metaRightX).attr("y",t.metaY).attr("text-anchor","end").attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>e.displayModels[o.key]?.metaTextColor??"var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.busText??""),d.select("text.ac-metrics-1").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>e.displayModels[o.key]?.primaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineOne??""),d.select("text.ac-metrics-2").attr("x",t.lineTwoX).attr("y",t.lineTwoY).attr("font-size",t.lineTwoFontSize).attr("opacity",.85).attr("fill",o=>e.displayModels[o.key]?.secondaryMetricsTextColor??"var(--kip-contrast-color)").text(o=>e.displayModels[o.key]?.metricsLineTwo??""),a.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`AC ${e.id}`}resolveModeText(e){return e.mode?`Mode ${e.mode}`:"Mode -"}buildMetricRows(e){let i=this.cardMode(),t=(i.metrics.length?i.metrics:l.DEFAULT_CONFIG.ac?.cardMode?.metrics??[]).map(c=>this.toMetricLabel(c,e)).filter(c=>!!c);if(!t.length)return ["L1 - - -","L2 - - L3 - -"];let r=t.slice(0,2).join(" "),s=t.slice(2,4).join(" ");return [r||" ",s||" "]}toMetricLabel(e,i){switch(e){case "line1Voltage":return `L1V ${this.formatValue(i.line1Voltage,"V")}`;case "line1Current":return `L1A ${this.formatValue(i.line1Current,"A")}`;case "line1Frequency":return `L1Hz ${this.formatValue(i.line1Frequency,"Hz")}`;case "line2Voltage":return `L2V ${this.formatValue(i.line2Voltage,"V")}`;case "line2Current":return `L2A ${this.formatValue(i.line2Current,"A")}`;case "line2Frequency":return `L2Hz ${this.formatValue(i.line2Frequency,"Hz")}`;case "line3Voltage":return `L3V ${this.formatValue(i.line3Voltage,"V")}`;case "line3Current":return `L3A ${this.formatValue(i.line3Current,"A")}`;case "line3Frequency":return `L3Hz ${this.formatValue(i.line3Frequency,"Hz")}`;default:return null}}formatValue(e,i){return e==null||Number.isNaN(e)?"-":`${e.toFixed(1)} ${i}`}toStringValue(e){return typeof e=="string"?e:null}resolveMostSevereState(...e){return e.some(i=>i===n$1.Alert)?n$1.Alert:e.some(i=>i===n$1.Alarm)?n$1.Alarm:e.some(i=>i===n$1.Warn)?n$1.Warn:e.some(i=>i===n$1.Normal)?n$1.Normal:null}toNumber(e,i){if(e==null||typeof e=="boolean")return null;let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return null;let r=this.units.convertToUnit(i,t);return typeof r=="number"&&Number.isFinite(r)?r:null}static \u0275fac=function(i){return new(i||l)};static \u0275cmp=JD({type:l,selectors:[["widget-ac"]],viewQuery:function(i,t){i&1&&eg(t.svgRef,ie,5),i&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["acSvg",""],[3,"text","color"],["aria-hidden","false",1,"ac-svg"],[1,"ac-empty"],[1,"ac-empty-title"],[1,"ac-empty-sub"]],template:function(i,t){i&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,re,5,0,"div",3)),i&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasBuses()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.ac-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}.ac-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)}.ac-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.ac-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{Y as WidgetAcComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-
|
|
1
|
+
import {p as p$1}from'./chunk-CaD3zVfK.js';import {G as Gt,L as Lt}from'./chunk-BAVmyVwG.js';import {u}from'./chunk-Be5KcT7R.js';import {k}from'./chunk-tbyiK3Ur.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,F as Fa,dn as ge,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,dx as n$1}from'./main-F7NMHHV4.js';import {c}from'./chunk-CRy9Da7a.js';var L=["radialGauge"];function F(n,q){if(n&1){let t=Fw();Pi(0,"radial-gauge",2,0),Qh("resizeChange",function(a){ud(t);let e=qw();return dd(e.onResized(a))}),ul();}if(n&2){let t=qw();Bh("options",t.gaugeOptions)("value",t.displayValue()),Hh("value-text",t.textValue());}}var ne=(()=>{class n{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:"ngRadial",subType:"measuring",highlightsWidth:5,scaleStart:180,barStartPosition:"left",enableTicks:true,enableProgressbar:true,enableNeedle:true},numInt:1,numDecimal:0,enableTimeout:false,color:"contrast",dataTimeout:5,ignoreZones:false};LINE="line";ANIMATION_TARGET_NEEDLE="needle";ngGauge=$j("radialGauge");gauge=$j("radialGauge",{read:Lr});value=vt(void 0);displayValue=Dt(()=>this.value()??0);shouldRenderGauge=Dt(()=>this.value()!==void 0);textValue=vt("--");colorStrokeTicks=vt("");gaugeBootstrapped=vt(false);animationEnabled=Dt(()=>this.gaugeBootstrapped());normalizedConfig=Dt(()=>this.runtime.options()??n.DEFAULT_CONFIG);gaugePathConfig=Dt(()=>this.normalizedConfig().paths?.gaugePath);adjustedScale=Dt(()=>{let t=this.normalizedConfig();return t.gauge?.subType==="capacity"?{min:t.displayScale?.lower??0,max:t.displayScale?.upper??100,majorTicks:[]}:p$1(t.displayScale?.lower??0,t.displayScale?.upper??100,t.gauge?.barStartPosition==="right")});highlights=Dt(()=>{let t=this.metadata.zones(),i=this.normalizedConfig(),a=this.theme(),e=this.gaugePathConfig();if(!t?.length)return [];if(!a)return [];if(i.ignoreZones)return [];if(i.gauge?.subType!=="measuring")return [];if(!e)return [];let o=this.adjustedScale(),r=i.gauge?.barStartPosition==="right";return k(t,a,e.convertUnitTo??"",this.unitsService,o.min,o.max,r)});displayName=Dt(()=>this.normalizedConfig().displayName??"Gauge Label");pathDataState=vt(null);viewReady=vt(false);gaugeOptions={};constructor(){Fa(()=>{let t=this.normalizedConfig(),i=this.theme(),a=this.gaugePathConfig();!i||!a?.path||ge(()=>this.streams.observe("gaugePath",e=>{e.state!==this.pathDataState()&&this.pathDataState.set(e.state||null);let o=e?.data?.value??null;if(o==null)this.value.set(t.displayScale?.lower??0),this.textValue.set("--");else {let r=t.displayScale?.lower??0,h=t.displayScale?.upper??100,f=Math.min(Math.max(o,r),h);this.value.set(f),this.textValue()==="--"&&this.textValue.set("");}}));}),Fa(()=>{this.normalizedConfig().ignoreZones||ge(()=>this.metadata.observe("gaugePath"));}),Fa(()=>{let t=this.highlights();this.viewReady()&&ge(()=>{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(()=>{if(this.buildGaugeOptions(t,i,a),this.viewReady())try{this.ngGauge()?.update(this.gaugeOptions);}catch(e){}});}),Fa(()=>{let t=this.ngGauge();!t||this.gaugeBootstrapped()||ge(()=>{try{requestAnimationFrame(()=>{this.gaugeBootstrapped.set(!0);try{t.update({animation:!0,animatedValue:!0});}catch(i){}});}catch(i){}});}),Fa(()=>{let t=this.pathDataState();this.viewReady()&&ge(()=>{let i=this.normalizedConfig(),a=this.theme();if(!a||i.ignoreZones)return;let e={},o=c(i.color??"contrast",a);switch(t){case n$1.Alarm:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlarm,e.colorValueText=a.zoneAlarm;break;case n$1.Warn:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneWarn,e.colorValueText=a.zoneWarn;break;case n$1.Alert:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=a.zoneAlert,e.colorValueText=a.zoneAlert;break;default:e.colorBorderMiddle=a.cardColor,e.colorBarProgress=i.gauge?.subType==="measuring"?o.color:o.dim,e.colorValueText=o.color;}try{this.ngGauge()?.update(e);}catch(r){}});});}ngAfterViewInit(){this.viewReady.set(true),this.setCanvasSize();try{this.ngGauge()?.update(this.gaugeOptions);}catch(t){}}onResized(t){let i={height:t.contentRect.height,width:t.contentRect.width};try{this.ngGauge()?.update(i);}catch(a){}}setCanvasSize(){let t=this.gauge()?.nativeElement;if(!t)return;let i=t.getBoundingClientRect(),a={height:i.height,width:i.width};try{this.ngGauge()?.update(a);}catch(e){}}buildGaugeOptions(t,i,a){let e={},o=this.gaugePathConfig(),r=t.gauge??n.DEFAULT_CONFIG.gauge;e.title=this.displayName(),e.minValue=a.min,e.maxValue=a.max,e.units=o?.convertUnitTo??"",e.highlights=[];let h=this.highlights();h.length&&(e.highlights=JSON.stringify(h),e.highlightsWidth=t.gauge?.highlightsWidth),e.fontTitle="Roboto",e.fontTitleWeight="bold",e.fontUnits="Roboto",e.fontUnitsSize=25,e.fontUnitsWeight="normal",e.barStrokeWidth=0,e.barShadow=0,e.colorBarStroke="",e.fontValue="Roboto",e.fontValueWeight="bold",e.valueTextShadow=false,e.colorValueBoxShadow="",e.fontNumbers="Roboto",e.fontNumbersWeight="bold",e.valueInt=t.numInt??1,e.valueDec=t.numDecimal??2,e.majorTicksInt=e.valueInt,e.majorTicksDec=e.valueDec,e.highlightsWidth=t.gauge?.highlightsWidth,e.animation=this.animationEnabled(),e.animateOnInit=false,e.animatedValue=this.animationEnabled(),e.animationRule="linear";let f=o?.sampleTime??500;e.animationDuration=f-25,e.colorBorderShadow=false,e.colorBorderOuter=i.cardColor,e.colorBorderOuterEnd="",e.colorBorderMiddle=i.cardColor,e.colorBorderMiddleEnd="",e.colorPlate=e.colorPlateEnd=i.cardColor,e.colorBar=i.background;let g=c(t.color??"contrast",i);e.barProgress=t.gauge?.enableProgressbar,e.colorBarProgress=g.color,e.colorNeedle=g.color,e.colorNeedleEnd=g.color,e.needleShadow=true,e.colorNeedleShadowUp="black",e.colorNeedleShadowDown="black",e.colorNeedleCircleInner=e.colorPlate,e.colorNeedleCircleInnerEnd=e.colorPlate,e.colorNeedleCircleOuter=e.colorPlate,e.colorNeedleCircleOuterEnd=e.colorPlate,e.colorTitle=i.contrastDim,e.colorUnits=i.contrastDim,e.colorValueText=g.color,this.colorStrokeTicks.set(i.contrastDim),e.colorMinorTicks=i.contrastDim,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false,r.subType==="capacity"?(e.fontTitleSize=40,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=10,e.valueBoxBorderRadius=5,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks="",e.barWidth=20,e.colorBarProgress=g.dim,e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=75,e.needleEnd=95,e.needleCircleSize=1,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=360,e.startAngle=r.scaleStart||180,e.majorTicks=0,e.exactTicks=true,e.strokeTicks=false,e.minorTicks=0,e.numbersMargin=0,e.fontNumbersSize=0,e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0):(e.fontTitleSize=24,e.barWidth=15,e.valueBox=true,e.fontValueSize=60,e.valueBoxWidth=100,e.valueBoxBorderRadius=0,e.valueBoxStroke=0,e.colorValueBoxBackground="",e.needle=r.enableNeedle,e.needleType=this.LINE,e.needleWidth=2,e.needleStart=0,e.needleEnd=95,e.needleCircleSize=10,e.needleCircleInner=false,e.needleCircleOuter=false,e.ticksAngle=270,e.startAngle=45,e.barStartPosition=r.barStartPosition||"left",r.enableTicks?(e.strokeTicks=true,e.majorTicks=a.majorTicks,e.minorTicks=2,e.exactTicks=false,e.numbersMargin=3,e.fontNumbersSize=15,e.colorMajorTicks=i.contrastDim,e.colorNumbers=i.contrastDim):(e.strokeTicks=false,e.majorTicks=0,e.minorTicks=0,e.exactTicks=true,e.numbersMargin=0,e.fontNumbersSize=0,e.colorMajorTicks=e.colorPlate,e.colorNumbers=e.colorMinorTicks=""),e.borders=true,e.borderOuterWidth=2,e.borderMiddleWidth=1,e.borderInnerWidth=0,e.borderShadowWidth=0,e.animationTarget=this.ANIMATION_TARGET_NEEDLE,e.useMinPath=false),this.gaugeOptions=e;}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=JD({type:n,selectors:[["widget-gauge-ng-radial"]],viewQuery:function(i,a){i&1&&eg(a.ngGauge,L,5)(a.gauge,L,5,Lr),i&2&&Kw(2);},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"]},decls:1,vars:1,consts:[["radialGauge",""],["kipResizeObserver","",3,"options","value"],["kipResizeObserver","",3,"resizeChange","options","value"]],template:function(i,a){i&1&&_w(0,F,2,3,"radial-gauge",1),i&2&&Mw(a.shouldRenderGauge()?0:-1);},dependencies:[u,Gt,Lt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%} radial-gauge{display:block;position:relative;width:100%;min-width:8px;height:100%;overflow:clip} radial-gauge>canvas{display:block;position:absolute;height:100%;width:100%;left:50%;top:50%;transform:translate(-50%,-50%);padding:0}"]})}return n})();export{ne as WidgetGaugeNgRadialComponent};
|