import { jsx as _jsx } from "react/jsx-runtime";
import { withRequiredCommonProps, } from '../../../../lib/seam/components/common-props.js';
import { LockDeviceDetails } from '../../../../lib/seam/components/DeviceDetails/LockDeviceDetails.js';
import { NoiseSensorDeviceDetails } from '../../../../lib/seam/components/DeviceDetails/NoiseSensorDeviceDetails.js';
import { ThermostatDeviceDetails } from '../../../../lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js';
import { useDevice } from '../../../../lib/seam/devices/use-device.js';
import { useUpdateDeviceName } from '../../../../lib/seam/devices/use-update-device-name.js';
import { isLockDevice } from '../../../../lib/seam/locks/lock-device.js';
import { isNoiseSensorDevice } from '../../../../lib/seam/noise-sensors/noise-sensor-device.js';
import { isThermostatDevice } from '../../../../lib/seam/thermostats/thermostat-device.js';
import { useComponentTelemetry } from '../../../../lib/telemetry/index.js';
export const NestedDeviceDetails = withRequiredCommonProps(DeviceDetails);
export function DeviceDetails({ deviceId, errorFilter = () => true, warningFilter = () => true, disableLockUnlock = false, disableDeleteAccessCode = false, disableResourceIds = false, disableConnectedAccountInformation = false, disableCreateAccessCode = false, disableEditAccessCode = false, onBack, className, }) {
    useComponentTelemetry('DeviceDetails');
    const { device } = useDevice({
        device_id: deviceId,
    });
    const { mutate: setDeviceName } = useUpdateDeviceName({
        device_id: deviceId,
    });
    const updateDeviceName = (newName) => {
        if (device != null) {
            setDeviceName({
                device_id: device.device_id,
                name: newName,
            });
        }
    };
    if (device == null) {
        return null;
    }
    const props = {
        errorFilter,
        warningFilter,
        disableLockUnlock,
        disableDeleteAccessCode,
        disableResourceIds,
        disableConnectedAccountInformation,
        disableCreateAccessCode,
        disableEditAccessCode,
        onBack,
        className,
    };
    if (isLockDevice(device)) {
        return (_jsx(LockDeviceDetails, { device: device, onEditName: updateDeviceName, ...props }));
    }
    if (isThermostatDevice(device)) {
        return (_jsx(ThermostatDeviceDetails, { device: device, onEditName: updateDeviceName, ...props }));
    }
    if (isNoiseSensorDevice(device)) {
        return (_jsx(NoiseSensorDeviceDetails, { device: device, onEditName: updateDeviceName, ...props }));
    }
    return null;
}
//# sourceMappingURL=DeviceDetails.js.map