import { jsx as _jsx } from "react/jsx-runtime";
import { DriveSettingsModal as ConnectDriveSettingsModal } from "@powerhousedao/design-system";
import { closePHModal, renameDrive, setDriveAvailableOffline, setDriveSharingType, showPHModal, getDriveAvailableOffline, useDriveById, getDriveSharingType, usePHModal, } from "@powerhousedao/reactor-browser";
export function DriveSettingsModal() {
    const phModal = usePHModal();
    const open = phModal?.type === "driveSettings";
    const driveId = open ? phModal.driveId : undefined;
    const [drive] = useDriveById(driveId);
    const sharingType = getDriveSharingType(drive);
    const availableOffline = getDriveAvailableOffline(drive);
    if (!driveId || !drive) {
        return null;
    }
    async function onRenameDrive(drive, newName) {
        await renameDrive(drive.header.id, newName);
    }
    async function onChangeSharingType(drive, newSharingType) {
        await setDriveSharingType(drive.header.id, newSharingType);
    }
    async function onChangeAvailableOffline(drive, newAvailableOffline) {
        await setDriveAvailableOffline(drive.header.id, newAvailableOffline);
    }
    return (_jsx(ConnectDriveSettingsModal, { drive: drive, sharingType: sharingType ?? "LOCAL", availableOffline: availableOffline, open: open, onRenameDrive: onRenameDrive, onDeleteDrive: () => showPHModal({ type: "deleteDrive", driveId }), onChangeAvailableOffline: onChangeAvailableOffline, onChangeSharingType: onChangeSharingType, onOpenChange: (status) => {
            if (!status)
                return closePHModal();
        } }));
}
//# sourceMappingURL=DriveSettingsModal.js.map