const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-DQM58oru.js","./index-a36IMXuN.js","./envs-CRUy-_iG.js","./index-CwXNofQJ.css","./RecallRemove-DYqjMF_w.js","./DashboardFeatureWrapper-DGHjt4Ah.js","./startCase-K7WbZvzP.js","./DisplayValue-D9Ja0Su_.js","./isObject--vsEa_js.js","./_createCompounder-BuXEc9F7.js","./isObjectLike-BQssIl0N.js","./index-CCf1BEwD.js","./InputField-IMyvy6Mz.js","./extends-CF3RwP-h.js","./react-select.esm-s6La4tfe.js","./defineProperty-CegpTSss.js","./floating-ui.dom-DbzrgdRQ.js","./DevicePicker-BzI6-dAt.js","./EndpointPicker-C6CQyxjG.js","./SelectField-BQBsNhlB.js","./useColumnCount-BMdgoihj.js","./DeviceCard-vHwXtt-g.js","./LastSeen-sm0titIc.js","./TimeAgo-DVPpOI6f.js","./Lqi-BErKiqkS.js","./PowerSource-CSWJpU_d.js","./snakeCase-BMb4_GjJ.js","./DeviceImage-DIhbuI22.js","./index-CsCgDwc5.js","./Exposes-DjP2xuHo.js","./FeatureWrapper-BGeGFgyv.js","./GroupSettings-B3BpgADM.js","./InfoAlert-DFbRmsjR.js","./SettingsList-CNu-T855.js","./CheckboxField-CwZ6yoAm.js","./NumberField-RWSAKGZO.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-a36IMXuN.js";import{S as w}from"./react-select.esm-s6La4tfe.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-DQM58oru.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-DjP2xuHo.js"),__vite__mapDeps([29,1,2,3,6,7,8,9,10,11,30]),import.meta.url)),L=m.lazy(async()=>await _(()=>import("./GroupSettings-B3BpgADM.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};
