Files
HomeAssistantVS/custom_components/maintenance_supporter/frontend/strategy/chunks/chunk-HYTKA5KV.js
T

3 lines
1.9 KiB
JavaScript

/*! maintenance_supporter frontend 2.80.0 */
function l(i){if(!i)return[];let n=[],o=i.photo_doc_id;typeof o=="string"&&n.push(o);let r=i.photo_doc_ids;Array.isArray(r)&&n.push(...r);let e=[];for(let t of n){if(typeof t!="string")continue;let a=t.trim();if(!(!a||e.includes(a))&&(e.push(a),e.length>=10))break}return e}function c(){let i=new Uint8Array(4);return(globalThis.crypto??{getRandomValues:n=>n.map(()=>Math.floor(Math.random()*256))}).getRandomValues(i),Array.from(i,n=>n.toString(16).padStart(2,"0")).join("")}function s(i){let n=i?.reading_values;if(!Array.isArray(n))return[];let o=[],r=new Set;for(let e of n){if(!e||typeof e!="object")continue;let t=e;typeof t.id!="string"||!t.id||r.has(t.id)||typeof t.value!="number"||!Number.isFinite(t.value)||(r.add(t.id),o.push({id:t.id,name:typeof t.name=="string"?t.name:t.id,unit:typeof t.unit=="string"?t.unit:null,value:t.value}))}return o}function u(i){return i.filter(n=>n.type==="completed"&&(n.reading_value!=null||s(n).length>0)).sort((n,o)=>n.timestamp.localeCompare(o.timestamp))}function g(i){return u(i??[]).map(n=>({timestamp:n.timestamp,values:s(n)})).filter(n=>n.values.length>0)}function y(i,n,o){let r;for(let e of i){if(o!==void 0){let a=new Date(e.timestamp).getTime();if(!isNaN(a)&&a>=o)break}let t=e.values.find(a=>a.id===n);t&&(r=t)}return r}function p(i,n,o){let r=s(n).find(t=>t.id===o);if(!r)return null;let e=null;for(let t of u(i)){if(t.timestamp>=n.timestamp)break;let a=s(t).find(d=>d.id===o);a&&(e=a.value)}return e==null?null:r.value-e}function m(i){let n=new Set,o=new Set;for(let r of i){let e=(r.name||"").trim().toLowerCase();e&&(n.has(e)?o.add(r.id):n.add(e))}return o}function R(i){let n=[],o=new Set,r=new Set;for(let e of i){let t=(e.name||"").trim();if(!(!t||o.has(e.id)||r.has(t.toLowerCase()))&&(o.add(e.id),r.add(t.toLowerCase()),n.push({id:e.id,name:t,unit:(e.unit||"").trim()||null}),n.length>=20))break}return n}export{l as a,c as b,s as c,g as d,y as e,p as f,m as g,R as h};