import{j as u,F as l,a1 as w,r as d,b as x,ao as b,bS as O,bT as S,K as P,bU as N}from"./index-DtyjNqrf.js";import{g as _,a as y}from"./index-Q3KOJDn9.js";function D({error:r,children:e}){return r?u.jsx(l,{icon:w,size:"3x",className:"text-error",title:"Missing image"}):e}function p(r){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(r)}function I(r,e){if(p(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e);if(p(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function E(r){var e=I(r,"string");return p(e)=="symbol"?e:e+""}function L(r,e,t){return(e=E(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var A=function(r){var e=r.crossOrigin,t=e===void 0?"":e;return function(i){return new Promise(function(n,o){var a=new Image;t&&(a.crossOrigin=t),a.onload=function(){a.decode?a.decode().then(n).catch(o):n()},a.onerror=o,a.src=i})}};function j(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function g(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?j(Object(t),!0).forEach(function(i){L(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):j(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}var $=function(e){return e.filter(function(t){return t})},F=function(e){return Array.isArray(e)?e:[e]},c={},T=function(e,t){var i=!1;return new Promise(function(n,o){var a=function(m){return t(m).then(function(){i=!0,n(m)})};e.reduce(function(f,m){return f.catch(function(){if(!i)return a(m)})},a(e.shift())).catch(o)})};function z(r){var e=r.srcList,t=r.imgPromise,i=t===void 0?A({}):t,n=r.useSuspense,o=n===void 0?!0:n,a=d.useState(!1),f=a[1],m=$(F(e)),s=m.join("");if(c[s]||(c[s]={promise:T(m,i),cache:"pending",error:null}),c[s].cache==="resolved")return{src:c[s].src,isLoading:!1,error:null};if(c[s].cache==="rejected"){if(o)throw c[s].error;return{isLoading:!1,error:c[s].error,src:void 0}}if(c[s].promise.then(function(v){c[s]=g(g({},c[s]),{},{cache:"resolved",src:v}),o||f(s)}).catch(function(v){c[s]=g(g({},c[s]),{},{cache:"rejected",error:v}),o||f(s)}),o)throw c[s].promise;return{isLoading:!0,src:void 0,error:null}}const h=d.memo(({device:r={},className:e})=>{const t=r.definition?.icon,i=_(r),n=[];t&&n.push(t),i&&n.push(i),i!==y&&n.push(y);const{src:o}=z({srcList:n});return u.jsx("img",{alt:r.ieee_address,crossOrigin:"anonymous",src:o,className:e})}),M=d.memo(r=>{const{t:e}=x("zigbee"),{device:t={},disabled:i,otaState:n,className:o,noIndicator:a}=r,f=d.useMemo(()=>t.interview_state===b.InProgress?u.jsx(l,{icon:O,spin:!0,title:e("interviewing"),className:"indicator-item indicator-bottom indicator-end text-info"}):t.interview_state===b.Failed?u.jsx(l,{icon:w,beat:!0,title:e("interview_failed"),className:"indicator-item indicator-bottom indicator-end text-error"}):t.supported?null:u.jsx(l,{icon:S,beat:!0,title:e("unsupported"),className:"indicator-item indicator-bottom indicator-end text-warning"}),[t.interview_state,t.supported,e]);return u.jsx(d.Suspense,{fallback:u.jsx("img",{alt:t.ieee_address,src:y}),children:u.jsx(D,{children:a?u.jsx(h,{device:t,className:`grid place-items-center${o?` ${o}`:""}`}):u.jsxs("div",{className:"indicator w-full",children:[n==="updating"&&u.jsx(l,{icon:P,spin:!0,title:e("updating_firmware"),className:"indicator-item indicator-top indicator-end text-info"}),f,i&&u.jsx(l,{icon:N,title:e("common:disabled"),className:"indicator-item indicator-middle indicator-center text-error",size:"2xl"}),u.jsx(h,{device:t,className:`grid place-items-center${o?` ${o}`:""}`})]})})})});export{M as D};
