import{j as i,F as f,an as b,r as l,u as w,aj as x,b4 as y,bE as O,bF as P,a5 as S,c as N}from"./index-VJpwYvBU.js";import{g as _,a as j}from"./index-RbRX26AQ.js";import{_ as D}from"./defineProperty-CegpTSss.js";function I({error:t,children:e}){return t?i.jsx(f,{icon:b,size:"3x",className:"text-error"}):e}var E=(function(t){var e=t.crossOrigin,r=e===void 0?"":e;return function(n){return new Promise(function(o,a){var u=new Image;r&&(u.crossOrigin=r),u.onload=function(){u.decode?u.decode().then(o).catch(a):o()},u.onerror=a,u.src=n})}});function h(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?h(Object(r),!0).forEach(function(n){D(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}var A=function(e){return e.filter(function(r){return r})},L=function(e){return Array.isArray(e)?e:[e]},d={},$=function(e,r){var n=!1;return new Promise(function(o,a){var u=function(s){return r(s).then(function(){n=!0,o(s)})};e.reduce(function(m,s){return m.catch(function(){if(!n)return u(s)})},u(e.shift())).catch(a)})};function F(t){var e=t.srcList,r=t.imgPromise,n=r===void 0?E({}):r,o=t.useSuspense,a=o===void 0?!0:o,u=l.useState(!1),m=u[1],s=A(L(e)),c=s.join("");if(d[c]||(d[c]={promise:$(s,n),cache:"pending",error:null}),d[c].cache==="resolved")return{src:d[c].src,isLoading:!1,error:null};if(d[c].cache==="rejected"){if(a)throw d[c].error;return{isLoading:!1,error:d[c].error,src:void 0}}if(d[c].promise.then(function(g){d[c]=p(p({},d[c]),{},{cache:"resolved",src:g}),a||m(c)}).catch(function(g){d[c]=p(p({},d[c]),{},{cache:"rejected",error:g}),a||m(c)}),a)throw d[c].promise;return{isLoading:!0,src:void 0,error:null}}const v=l.memo(({device:t={},className:e})=>{const r=t.definition?.icon,n=_(t),o=[];r&&o.push(r),n&&o.push(n),n!==j&&o.push(j);const{src:a}=F({srcList:o});return i.jsx("img",{alt:t.ieee_address,src:a,className:`object-contain ${e??""}`})}),k=l.memo(t=>{const{t:e}=w(["zigbee","common"]),{device:r={},disabled:n,otaState:o,className:a,noIndicator:u}=t,m=l.useMemo(()=>r.interview_state===x.InProgress?i.jsx("span",{title:e(s=>s.interviewing),children:i.jsx(f,{icon:y,spin:!0,className:"indicator-item indicator-bottom indicator-end text-info"})}):r.interview_state===x.Failed?i.jsx("span",{title:e(s=>s.interview_failed),children:i.jsx(f,{icon:b,beat:!0,className:"indicator-item indicator-bottom indicator-end text-error"})}):r.definition?.source==="generated"?i.jsx("span",{title:e(s=>s.unsupported),children:i.jsx(f,{icon:O,beat:!0,className:"indicator-item indicator-bottom indicator-end text-warning"})}):r.definition?.source==="external"?i.jsx("span",{title:e(s=>s.unsupported),children:i.jsx(f,{icon:P,className:"indicator-item indicator-bottom indicator-end text-info"})}):null,[r.interview_state,r.definition,e]);return i.jsx(l.Suspense,{fallback:i.jsx("img",{alt:r.ieee_address,src:j}),children:i.jsx(I,{children:u?i.jsx(v,{device:r,className:`grid place-items-center${a?` ${a}`:""}`}):i.jsxs("div",{className:"indicator w-full",children:[o==="updating"&&i.jsx("span",{title:e(s=>s.updating_firmware),children:i.jsx(f,{icon:S,spin:!0,className:"indicator-item indicator-top indicator-end text-info"})}),m,n&&i.jsx("span",{title:e(s=>s.disabled,{ns:"common"}),children:i.jsx(f,{icon:N,className:"indicator-item indicator-middle indicator-center text-error",size:"2xl"})}),i.jsx(v,{device:r,className:`grid place-items-center${a?` ${a}`:""}`})]})})})});export{k as D};
