const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-DB35XIGg.js","./index-VJpwYvBU.js","./envs-CRUy-_iG.js","./index-DZ314hCQ.css","./RecallRemove-B8kK-jlT.js","./DashboardFeatureWrapper-C5cTX2Yd.js","./startCase-DNIChZAc.js","./DisplayValue-BX0bcoSg.js","./isObject--vsEa_js.js","./_createCompounder-JrZUBxnL.js","./isObjectLike-CKrHmw-v.js","./index-C1LTvZEM.js","./InputField-B_6Ee4_m.js","./extends-CF3RwP-h.js","./react-select.esm-DM_HiCZr.js","./defineProperty-CegpTSss.js","./floating-ui.dom-DbzrgdRQ.js","./DevicePicker-BQE6PtnK.js","./EndpointPicker-DlYDImDR.js","./SelectField-BkTP72p-.js","./useColumnCount-BNJ8FuYE.js","./DeviceCard-Jno_2bki.js","./LastSeen-YOzeyMXj.js","./TimeAgo-CeXmHrG4.js","./Lqi-BLanrDho.js","./PowerSource-B4Kn6y4z.js","./snakeCase-BPMTuOlK.js","./DeviceImage-DAL8fj7m.js","./index-RbRX26AQ.js","./Exposes-A_bjwSNo.js","./FeatureWrapper-5iLBJB0_.js","./GroupSettings-BvE_j6Ig.js","./InfoAlert-5ZrJ0C3a.js","./SettingsList-dKrzLqZS.js","./CheckboxField-CBqKSuiA.js","./NumberField-DL6vGGqp.js"])))=>i.map(i=>d[i]);
import{r as m,u as j,a as b,C as h,A as N,j as e,S as v,D as S,E as $,G as E,I as y,N as T,J as p,F as x,X as f,T as A,$ as _}from"./index-VJpwYvBU.js";import{S as w}from"./react-select.esm-DM_HiCZr.js";import"./envs-CRUy-_iG.js";import"./defineProperty-CegpTSss.js";import"./extends-CF3RwP-h.js";import"./floating-ui.dom-DbzrgdRQ.js";const C=m.memo(({currentSourceIdx:t,currentGroup:r,tab:o="devices"})=>{const{t:n}=j("common"),l=b(s=>s.groups),i=h(),u=m.useCallback(s=>{s&&i(s.link)},[i]),d=m.useMemo(()=>{const s=[];for(let a=0;a<N.length;a++)for(const c of l[a])a===t&&c.id===r?.id||s.push({value:c.friendly_name,label:e.jsxs(e.Fragment,{children:[e.jsx(v,{idx:a,autoHide:!0,namePostfix:" – "})," ",c.friendly_name]}),name:`${a} ${c.friendly_name}`,link:`/group/${a}/${c.id}/${o}`});return s.sort((a,c)=>a.name.localeCompare(c.name)),s},[l,t,r,o]);return e.jsx(w,{unstyled:!0,placeholder:r&&t!==void 0?e.jsxs(e.Fragment,{children:[e.jsx(v,{idx:t,autoHide:!0,namePostfix:" – "})," ",r.friendly_name]}):n(s=>s.select_group),"aria-label":n(s=>s.select_group),options:d,isSearchable:!0,onChange:u,className:"min-w-48 sm:w-auto me-2",classNames:S})}),I=m.lazy(async()=>await _(()=>import("./Devices-DB35XIGg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]),import.meta.url)),P=m.lazy(async()=>await _(()=>import("./Exposes-A_bjwSNo.js"),__vite__mapDeps([29,1,2,3,6,7,8,9,10,11,30]),import.meta.url)),L=m.lazy(async()=>await _(()=>import("./GroupSettings-BvE_j6Ig.js"),__vite__mapDeps([31,1,2,3,32,33,34,12,35,19]),import.meta.url));function k(t,r,o){const n=`${t}-${o.id}`;switch(r){case"devices":return e.jsx(I,{sourceIdx:t,group:o},n);case"exposes":return e.jsx(P,{sourceIdx:t,group:o},n);case"settings":return e.jsx(L,{sourceIdx:t,group:o},n)}}const g=({isActive:t})=>t?"tab tab-active":"tab";function z(){const t=h(),{t:r}=j(["groups","common"]),{sourceIdx:o,groupId:n,tab:l}=$(),[i,u]=E(o),d=Number.parseInt(n,10),s=b(y(a=>n?a.groups[i].find(c=>c.id===d):void 0));return m.useEffect(()=>{o&&u&&s?l||t(`/group/${o}/${s.id}/devices`,{replace:!0}):t("/groups",{replace:!0})},[o,u,l,s,t]),e.jsxs(e.Fragment,{children:[e.jsx(T,{children:e.jsx(C,{currentSourceIdx:i,currentGroup:s,tab:l})}),e.jsxs("div",{className:"tabs tabs-border mt-2",children:[e.jsxs(p,{to:`/group/${i}/${n}/devices`,className:g,children:[e.jsx(x,{icon:f,className:"me-2"}),r(a=>a.devices,{ns:"common"})]}),e.jsxs(p,{to:`/group/${i}/${n}/exposes`,className:g,children:[e.jsx(x,{icon:f,className:"me-2"}),r(a=>a.exposes,{ns:"common"})]}),e.jsxs(p,{to:`/group/${i}/${n}/settings`,className:g,children:[e.jsx(x,{icon:A,className:"me-2"}),r(a=>a.settings)]})]}),e.jsx("div",{className:"tab-content block h-full bg-base-100 p-3",children:l&&s?k(i,l,s):e.jsx("div",{className:"flex-auto justify-center items-center",children:r(a=>a.unknown_group,{ns:"common"})})})]})}export{z as default};
