var e=Object.defineProperty,t=(t,i,n)=>(((t,i,n)=>{i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n})(t,"symbol"!=typeof i?i+"":i,n),n);import{c as i,D as n,h as a,t as l,n as r,i as s,z as o}from"./T3Data.cbe80363.js";import{t as u,aF as v}from"./index.3938ccd1.js";const d=class{static setDependencies(e,t,i){d.webClient=e,d.deviceOpt=t,d.wsClient=i}static getLinkedEntries(){return 0===i.value.items.length?[]:u(i.value).items.filter((e=>e.t3Entry))}static refreshMoveableGuides(){i.value.elementGuidelines=[];const e=document.querySelectorAll(`.moveable-item-wrapper:not(moveable-item-index-${i.value.activeItemIndex}) .moveable-item`);Array.from(e).forEach((function(e){i.value.elementGuidelines.push(e)}))}static getEntryRange(e){if(null==e?void 0:e.range){const t=e.type.toLowerCase();let i=e.digital_analog?n.analog[t].find((t=>t.id===e.range)):n.digital.find((t=>t.id===e.range));if(!i){const t=a.value.panelsRanges.filter((t=>t.pid===e.pid));i=e.digital_analog?t.find((t=>"analog"===t.type&&t.index===e.range)):t.find((t=>"digital"===t.type&&t.index===e.range)),!i&&e.range>100&&(i=t.find((t=>"MSV"===t.type&&t.index===e.range)))}if(i)return i}return{label:"Unused",unit:""}}static getObjectActiveValue(e){var t,i,n,a;let l=!1;if(!e.t3Entry||void 0===(null==(t=e.settings)?void 0:t.active))return!1;if("OUTPUT"===e.t3Entry.type&&1===e.t3Entry.hw_switch_status)l=!!e.t3Entry.hw_switch_status;else if(e.t3Entry.range){const t=e.t3Entry.digital_analog,r=d.getEntryRange(e.t3Entry);r&&(l=!!(!t&&(1===(null==(i=e.t3Entry)?void 0:i.control)&&!r.direct||0===(null==(n=e.t3Entry)?void 0:n.control)&&r.direct)||t&&(null==(a=e.t3Entry)?void 0:a.value)>0))}else"PROGRAM"===e.t3Entry.type?l=!!e.t3Entry.status:"SCHEDULE"===e.t3Entry.type?l=!!e.t3Entry.output:"HOLIDAY"===e.t3Entry.type&&(l=!!e.t3Entry.value);return l}static refreshLinkedEntries(e){e.find((e=>"TRL11111"===e.label)),i.value.items.filter((e=>{var t;return null==(t=e.t3Entry)?void 0:t.type})).forEach(((t,i)=>{const n=e.find((e=>e.index===t.t3Entry.index&&e.type===t.t3Entry.type&&e.pid===t.t3Entry.pid));if(n&&n.id){n.value;let e=n.value>=1e3?n.value/1e3:n.value;n.value=e,t.t3Entry=n,d.refreshObjectStatus(t)}}))}static refreshLinkedEntries2(e){l.value.items.filter((e=>{var t;return null==(t=e.t3Entry)?void 0:t.type})).forEach((t=>{const i=e.find((e=>e.index===t.t3Entry.index&&e.type===t.t3Entry.type&&e.pid===t.t3Entry.pid));if(i&&i.id){let e=i.value>=1e3?i.value/1e3:i.value;i.value=e,t.t3Entry=i,d.refreshObjectStatus(t)}}))}static refreshObjectStatus(e){var t,i;e.t3Entry&&void 0!==(null==(t=e.settings)?void 0:t.active)&&(e.settings.active=d.getObjectActiveValue(e)),e.t3Entry&&void 0!==e.t3Entry.decom&&void 0!==(null==(i=e.settings)?void 0:i.inAlarm)&&(e.settings.inAlarm=!!e.t3Entry.decom)}static saveLib(){const e=u(r.value.images.filter((e=>!e.online))),t=u(r.value.objLib.filter((e=>!e.online)));if(s.value)d.webClient.SaveLibraryData(null,null,{...u(r.value),images:e,objLib:t});else{const i=d.deviceOpt.getCurrentDevice(),n=null==i?void 0:i.panelId,a=null==i?void 0:i.graphicId;d.wsClient.SaveLibraryData(n,a,{...u(r.value),images:e,objLib:t})}}static saveNewLib(){const e=u(r.value.images.filter((e=>!e.online))),t=u(r.value.objLib.filter((e=>!e.online)));if(s.value)d.webClient.SaveNewLibraryData(null,null,{...u(r.value),images:e,objLib:t});else{const i=d.deviceOpt.getCurrentDevice(),n=null==i?void 0:i.panelId,a=null==i?void 0:i.graphicId;d.wsClient.SaveNewLibraryData(n,a,{...u(r.value),images:e,objLib:t})}}static saveGraphicData(e,t){var i,n,a;if(!0===(null==(i=e.data)?void 0:i.status)){if(!o.value)return;v.Debug("= IdxUtils Saved successfully."),null==(n=d.deviceOpt)||n.refreshCurrentDevice(),null==(a=d.deviceOpt)||a.refreshCurrentDeviceCount()}else t.notify({message:"Error, not saved!",color:"negative",icon:"error",actions:[{label:"Dismiss",color:"white",handler:()=>{}}]})}static getUnitText(e){var t;const i=d.getEntryRange(e);let n="";if(e.range>100){const a=null==(t=i.options)?void 0:t.find((t=>t.value===e.value));n=(null==a?void 0:a.name)||""}else 1===e.digital_analog?n=(null==i?void 0:i.unit)||"":0===e.digital_analog&&(n=e.control?(null==i?void 0:i.on)||"":(null==i?void 0:i.off)||"");return n}};let c=d;t(c,"webClient"),t(c,"deviceOpt"),t(c,"wsClient");export{c as I};
