import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
import {
  MasterDetailTable,
  PanelContainer
} from "./chunk-DWYIZZUB.mjs";

// src/panels/halo/DeviceListPanel/DeviceListPanel.tsx
import React, { useMemo } from "react";
import { Format } from "@dxos/echo/internal";
import { Device, DeviceKind, DeviceType, useDevices } from "@dxos/react-client/halo";
var DeviceListPanel = () => {
  const devices = useDevices();
  const properties = useMemo(() => [
    {
      name: "key",
      format: Format.TypeFormat.DID
    },
    {
      name: "state",
      format: Format.TypeFormat.SingleSelect,
      size: 150,
      config: {
        options: [
          {
            id: "THIS DEVICE",
            title: "THIS DEVICE",
            color: "green"
          },
          {
            id: "ONLINE",
            title: "ONLINE",
            color: "green"
          },
          {
            id: "OFFLINE",
            title: "OFFLINE",
            color: "neutral"
          }
        ]
      }
    },
    {
      name: "type",
      format: Format.TypeFormat.SingleSelect,
      size: 180,
      config: {
        options: Object.entries(DeviceType).filter(([key]) => isNaN(Number(key))).map(([key]) => ({
          id: key,
          title: key,
          color: "neutral"
        }))
      }
    },
    {
      name: "label",
      format: Format.TypeFormat.String,
      size: 180
    }
  ], []);
  const data = useMemo(() => devices.map((device) => ({
    id: device.deviceKey.toString(),
    key: device.deviceKey.toString(),
    state: device.kind === DeviceKind.CURRENT ? "THIS DEVICE" : Device.PresenceState[device.presence],
    type: DeviceType[device.profile?.type || DeviceType.UNKNOWN],
    label: device.profile?.label,
    _original: device
  })), [
    devices
  ]);
  return /* @__PURE__ */ React.createElement(PanelContainer, null, /* @__PURE__ */ React.createElement(MasterDetailTable, {
    properties,
    data,
    detailsTransform: (d) => d._original,
    detailsPosition: "bottom"
  }));
};

// src/panels/halo/DeviceListPanel/index.ts
var DeviceListPanel_default = DeviceListPanel;
export {
  DeviceListPanel_default as default
};
//# sourceMappingURL=DeviceListPanel-5X2FUIAZ.mjs.map
