import{r as g,j as s,R as S,u as w,b as P}from"./index-fb4a4614.js";import{A as E,b as v}from"./index-361b7a42.js";const _="_img_1qsqd_1",j={img:_};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 N(r,e){if(p(r)!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(p(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function A(r){var e=N(r,"string");return p(e)=="symbol"?e:String(e)}function L(r,e,t){return e=A(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var D=function(r){var e=r.decode,t=e===void 0?!0:e,n=r.crossOrigin,o=n===void 0?"":n;return function(u){return new Promise(function(l,f){var a=new Image;o&&(a.crossOrigin=o),a.onload=function(){t&&a.decode?a.decode().then(l).catch(f):l()},a.onerror=f,a.src=u})}};function y(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,n)}return t}function d(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?y(Object(t),!0).forEach(function(n){L(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):y(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var I=function(e){return e.filter(function(t){return t})},R=function(e){return Array.isArray(e)?e:[e]},c={},B=function(e,t){var n=!1;return new Promise(function(o,u){var l=function(a){return t(a).then(function(){n=!0,o(a)})};e.reduce(function(f,a){return f.catch(function(){if(!n)return l(a)})},l(e.shift())).catch(u)})};function T(r){var e=r.srcList,t=r.imgPromise,n=t===void 0?D({decode:!0}):t,o=r.useSuspense,u=o===void 0?!0:o,l=g.useState(!1),f=l[1],a=I(R(e)),i=a.join("");if(c[i]||(c[i]={promise:B(a,n),cache:"pending",error:null}),c[i].cache==="resolved")return{src:c[i].src,isLoading:!1,error:null};if(c[i].cache==="rejected"){if(u)throw c[i].error;return{isLoading:!1,error:c[i].error,src:void 0}}if(c[i].promise.then(function(m){c[i]=d(d({},c[i]),{},{cache:"resolved",src:m}),u||f(i)}).catch(function(m){c[i]=d(d({},c[i]),{},{cache:"rejected",error:m}),u||f(i)}),u)throw c[i].promise;return{isLoading:!0,src:void 0,error:null}}function h(r){const{device:e,type:t,...n}=r,{src:o}=T({srcList:E.map(u=>u(e)).filter(Boolean)});return t==="svg"?s.jsx("image",{crossOrigin:"anonymous",...n,href:o}):s.jsx("img",{alt:"",crossOrigin:"anonymous",src:o,className:j.img})}class b extends S.Component{constructor(e){super(e),this.state={hasError:!1}}componentDidCatch(){this.setState({hasError:!0})}render(){return this.state.hasError?s.jsx(s.Fragment,{children:"ERROR"}):this.props.children}}function $(r){const{t:e}=w("zigbee"),{device:t={},disabled:n,deviceStatus:o,type:u="img",className:l,...f}=r;if(u==="svg")return s.jsx(g.Suspense,{fallback:s.jsx("image",{crossOrigin:"anonymous",...f,href:v}),children:s.jsx(b,{children:s.jsx(h,{type:"svg",device:t,...f})})});const i=((o==null?void 0:o.update)??{}).state==="updating"?s.jsx("i",{title:e("updating_firmware"),className:"fa fa-sync fa-spin position-absolute bottom-0 right-0"}):null,m=t.interviewing?s.jsx("i",{title:e("interviewing"),className:"fa fa-spinner fa-spin position-absolute bottom-0 right-0"}):null,O=!t.interviewing&&!t.interview_completed,x=n?s.jsx("i",{title:e("device_disabled"),className:"fa fa-ban position-absolute bottom-0 right-0"}):null;return s.jsxs("div",{className:P(l,"position-relative"),...f,children:[s.jsx(g.Suspense,{fallback:s.jsx("img",{alt:"",src:v,className:j.img}),children:s.jsx(b,{children:s.jsx(h,{device:t})})}),m,i,x,O&&s.jsx("i",{title:e("interview_failed"),className:"fa fa-exclamation-triangle position-absolute top-0 right-0 text-danger"})]})}export{$ as D};
