const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-BS8VHoxo.js","./index-D_pphaE2.js","./envs-CRUy-_iG.js","./index-DeQqyExs.css","./RecallRemove-7fIq6cXH.js","./DashboardFeatureWrapper-C-FPOAcu.js","./startCase-BsTKbnbP.js","./DisplayValue-Bn_kSwDb.js","./isObject--vsEa_js.js","./_createCompounder-DD7kMWdY.js","./isObjectLike-DDO0-ybB.js","./index-BhIhHSRV.js","./InputField-B0SBdaHi.js","./extends-CF3RwP-h.js","./react-select.esm-OUcOCR-x.js","./defineProperty-CegpTSss.js","./floating-ui.dom-CFVCCol6.js","./DevicePicker-CfFlp6BC.js","./EndpointPicker-DHX3IgJS.js","./SelectField-J0vaqEIK.js","./useColumnCount-DEJxZKlH.js","./DeviceCard-BYpnrqUB.js","./LastSeen-BL74QqOr.js","./TimeAgo-Dep0UUfO.js","./Lqi-BwD2Y3RL.js","./PowerSource-C95koaHH.js","./snakeCase-DwtuZqse.js","./DeviceImage-DUp2lC9c.js","./index-DgIuNtLX.js","./Exposes-CyXAr_mo.js","./FeatureWrapper-DRy_rS6q.js","./GroupSettings-zDVYSvGL.js","./InfoAlert-BjFk5zJ1.js","./SettingsList-CwQILOJa.js","./CheckboxField-Bp87NFVr.js","./NumberField-Dq3HyXeU.js"])))=>i.map(i=>d[i]);
import{dq as l,dG as j,dB as b,dD as h,a as N,dm as e,a0 as v,V as E,dE as S,dj as $,dF as y,R as T,S as p,o as x,bX as f,aX as A,aa as _}from"./index-D_pphaE2.js";import{a as w}from"./react-select.esm-OUcOCR-x.js";import"./envs-CRUy-_iG.js";import"./defineProperty-CegpTSss.js";import"./extends-CF3RwP-h.js";import"./floating-ui.dom-CFVCCol6.js";const P=l.memo(({currentSourceIdx:t,currentGroup:i,tab:o="devices"})=>{const{t:n}=j("common"),m=b(s=>s.groups),r=h(),d=l.useCallback(s=>{s&&r(s.link)},[r]),u=l.useMemo(()=>{const s=[];for(let a=0;a<N.length;a++)for(const c of m[a])a===t&&c.id===i?.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},[m,t,i,o]);return e.jsx(w,{unstyled:!0,placeholder:i&&t!==void 0?e.jsxs(e.Fragment,{children:[e.jsx(v,{idx:t,autoHide:!0,namePostfix:" – "})," ",i.friendly_name]}):n(s=>s.select_group),"aria-label":n(s=>s.select_group),options:u,isSearchable:!0,onChange:d,className:"min-w-48 sm:w-auto me-2",classNames:E})}),C=l.lazy(async()=>await _(()=>import("./Devices-BS8VHoxo.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)),I=l.lazy(async()=>await _(()=>import("./Exposes-CyXAr_mo.js"),__vite__mapDeps([29,1,2,3,6,7,8,9,10,11,30]),import.meta.url)),L=l.lazy(async()=>await _(()=>import("./GroupSettings-zDVYSvGL.js"),__vite__mapDeps([31,1,2,3,32,33,34,12,35,19]),import.meta.url));function k(t,i,o){const n=`${t}-${o.id}`;switch(i){case"devices":return e.jsx(C,{sourceIdx:t,group:o},n);case"exposes":return e.jsx(I,{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:i}=j(["groups","common"]),{sourceIdx:o,groupId:n,tab:m}=S(),[r,d]=$(o),u=Number.parseInt(n,10),s=b(y(a=>n?a.groups[r].find(c=>c.id===u):void 0));return l.useEffect(()=>{o&&d&&s?m||t(`/group/${o}/${s.id}/devices`,{replace:!0}):t("/groups",{replace:!0})},[o,d,m,s,t]),e.jsxs(e.Fragment,{children:[e.jsx(T,{children:e.jsx(P,{currentSourceIdx:r,currentGroup:s,tab:m})}),e.jsxs("div",{className:"tabs tabs-border mt-2",children:[e.jsxs(p,{to:`/group/${r}/${n}/devices`,className:g,children:[e.jsx(x,{icon:f,className:"me-2"}),i(a=>a.devices,{ns:"common"})]}),e.jsxs(p,{to:`/group/${r}/${n}/exposes`,className:g,children:[e.jsx(x,{icon:f,className:"me-2"}),i(a=>a.exposes,{ns:"common"})]}),e.jsxs(p,{to:`/group/${r}/${n}/settings`,className:g,children:[e.jsx(x,{icon:A,className:"me-2"}),i(a=>a.settings)]})]}),e.jsx("div",{className:"tab-content block h-full bg-base-100 p-3",children:m&&s?k(r,m,s):e.jsx("div",{className:"flex-auto justify-center items-center",children:i(a=>a.unknown_group,{ns:"common"})})})]})}export{z as default};
