1import{a as _}from"./chunk-IUTJLVK4.js";import"./chunk-OYOXAY44.js";import"./chunk-IO44HIO6.js";import"./chunk-FDN33MRG.js";import{n as M,y as V}from"./chunk-F45KP72J.js";import{Cc as m,Dc as d,Ec as l,Fc as S,Lb as s,Qd as I,Vc as p,Xb as f,bd as h,cc as y,d as C,fd as u,gd as v,hc as g,hd as x,jb as w,sa as b}from"./chunk-Z5YOIIAC.js";import{l as e,t as q}from"./chunk-ATLPHYUF.js";function P(n,a){if(n&1&&(d(0,"div",9),u(1),l()),n&2){let c=p();s(),v(c.sublabel)}}function T(n,a){if(n&1&&(d(0,"span",10),u(1),l()),n&2){let c=p();s(),v(c.unit)}}function E(n,a){if(n&1&&(d(0,"div",11),S(1,"div",12),l()),n&2){let c=p();s(),h("width",c.progressPercent,"%")("background-color",c.currentColor)}}function F(n,a){if(n&1&&(d(0,"div",13),u(1),l()),n&2){let c=p();h("color",c.currentColor),s(),x(" ",c.currentStatus," ")}}function z(n,a){n&1&&(d(0,"div",14),u(1," Verbindung wird hergestellt... "),l())}var A="mqtt-value",O=["url","user","password","broker","topic","label","sublabel","unit","decimals","thresholds","show-progress","progress-min","progress-max","format"],J=(()=>{let a=class a{constructor(r,o,t){e(this,"elementRef");e(this,"cdr");e(this,"mqttService");e(this,"url");e(this,"user","");e(this,"password","");e(this,"broker","");e(this,"topic");e(this,"label","");e(this,"sublabel","");e(this,"unit","");e(this,"decimals","2");e(this,"thresholds","[]");e(this,"showProgress","false");e(this,"progressMin","0");e(this,"progressMax","100");e(this,"format","");e(this,"currentValue",null);e(this,"currentColor","#333");e(this,"currentStatus","");e(this,"connected",!1);e(this,"formattedValue","--");e(this,"showProgressBar",!1);e(this,"progressPercent",0);e(this,"destroy$",new C);e(this,"parsedThresholds",[]);e(this,"connectionConfig");this.elementRef=r,this.cdr=o,this.mqttService=t}ngOnInit(){return q(this,null,function*(){this.elementRef.nativeElement.removeAttribute("ng-version");try{this.parsedThresholds=JSON.parse(this.thresholds)}catch(r){console.error("[mqtt-value] Failed to parse thresholds:",r)}this.showProgressBar=this.showProgress==="true";try{this.connectionConfig=yield this.mqttService.resolveConfig({url:this.url,username:this.user||void 0,password:this.password||void 0,broker:this.broker||void 0})}catch(r){console.error("[mqtt-value] Failed to resolve MQTT auth:",r);return}this.mqttService.connect(this.connectionConfig,this.topic).pipe(b(this.destroy$)).subscribe({next:r=>{this.processValue(r.payload),this.cdr.markForCheck()},error:r=>{console.error("[mqtt-value] Connection error:",r)}}),this.mqttService.connectionStatus$(this.connectionConfig).pipe(b(this.destroy$)).subscribe(r=>{this.connected=r,this.cdr.markForCheck()})})}processValue(r){if(this.format==="text"){let i=r;for(;i.length>0&&i.charCodeAt(i.length-1)===0;)i=i.slice(0,-1);this.formattedValue=i.trim()||"--",this.currentValue=null;return}let o=parseFloat(r);if(isNaN(o)){this.formattedValue=r,this.currentValue=null;return}this.currentValue=o;let t=parseInt(this.decimals,10)||2;if(this.formattedValue=o.toFixed(t),this.applyThresholds(o),this.showProgressBar){let i=parseFloat(this.progressMin)||0,k=parseFloat(this.progressMax)||100;this.progressPercent=Math.min(100,Math.max(0,(o-i)/(k-i)*100))}}applyThresholds(r){var o;this.currentColor="#333",this.currentStatus="";for(let t of this.parsedThresholds){let i=!1;if(t.max!==void 0&&t.min!==void 0?i=r>=t.min&&r<=t.max:t.max!==void 0?i=r<=t.max:t.min!==void 0?i=r>=t.min:t.above!==void 0?i=r>t.above:t.below!==void 0&&(i=r<t.below),i){this.currentColor=this.getColor(t.color),this.currentStatus=(o=t.status)!=null?o:"";break}}}getColor(r){return{red:"#db2828",green:"#21ba45",orange:"#f2711c",yellow:"#fbbd08",blue:"#2185d0",grey:"#767676",gray:"#767676"}[r.toLowerCase()]||r}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),this.connectionConfig&&this.mqttService.disconnect(this.connectionConfig,this.topic)}};e(a,"\u0275fac",function(o){return new(o||a)(f(w),f(I),f(_))}),e(a,"\u0275cmp",y({type:a,selectors:[["hz-mqtt-value"]],inputs:{url:"url",user:"user",password:"password",broker:"broker",topic:"topic",label:"label",sublabel:"sublabel",unit:"unit",decimals:"decimals",thresholds:"thresholds",showProgress:"showProgress",progressMin:"progressMin",progressMax:"progressMax",format:"format"},decls:11,vars:11,consts:[[1,"mqtt-value-card"],[1,"mqtt-value-label"],["class","mqtt-value-sublabel",4,"ngIf"],[1,"mqtt-value-content"],[1,"mqtt-value-number"],["class","mqtt-value-unit",4,"ngIf"],["class","mqtt-value-progress",4,"ngIf"],["class","mqtt-value-status",3,"color",4,"ngIf"],["class","mqtt-value-disconnected",4,"ngIf"],[1,"mqtt-value-sublabel"],[1,"mqtt-value-unit"],[1,"mqtt-value-progress"],[1,"mqtt-value-progress-bar"],[1,"mqtt-value-status"],[1,"mqtt-value-disconnected"]],template:function(o,t){o&1&&(d(0,"div",0)(1,"div",1),u(2),l(),g(3,P,2,1,"div",2),d(4,"div",3)(5,"span",4),u(6),l(),g(7,T,2,1,"span",5),l(),g(8,E,2,4,"div",6)(9,F,2,3,"div",7)(10,z,2,0,"div",8),l()),o&2&&(h("border-left-color",t.currentColor),s(2),v(t.label),s(),m("ngIf",t.sublabel),s(2),h("color",t.currentColor),s(),x(" ",t.formattedValue," "),s(),m("ngIf",t.unit),s(),m("ngIf",t.showProgressBar),s(),m("ngIf",t.currentStatus),s(),m("ngIf",!t.connected))},dependencies:[V,M],styles:[":host{display:block}.mqtt-value-card{background:#f8f9fa;border-radius:8px;padding:16px;min-width:150px;border-left:4px solid #2185d0}.mqtt-value-label{color:#666;font-size:12px;text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.mqtt-value-sublabel{font-size:11px;color:#888;margin-bottom:4px}.mqtt-value-content{display:flex;align-items:baseline;gap:4px}.mqtt-value-number{font-size:24px;font-weight:700;line-height:1.2}.mqtt-value-unit{font-size:14px;font-weight:400;color:#666}.mqtt-value-progress{height:6px;background:#e0e0e0;border-radius:3px;margin-top:12px;overflow:hidden}.mqtt-value-progress-bar{height:100%;border-radius:3px;transition:width .3s ease}.mqtt-value-status{font-size:11px;margin-top:8px;text-transform:uppercase;letter-spacing:.3px}.mqtt-value-disconnected{font-size:11px;color:#999;font-style:italic;margin-top:8px}\n"],encapsulation:3,changeDetection:0}));let n=a;return n})();export{J as MqttValueComponent,O as webComponentAttributes,A as webComponentName};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.