'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { useModal } from '@faceless-ui/modal';
import React from 'react';
import { useAuth } from '../../providers/Auth/index.js';
import { SelectAllStatus, useSelection } from '../../providers/Selection/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { ListSelectionButton } from '../ListSelection/index.js';
import { PublishManyDrawerContent } from './DrawerContent.js';
export const PublishMany = (props)=>{
    const { count, selectAll, selectedIDs, toggleAll } = useSelection();
    return /*#__PURE__*/ _jsxDEV(PublishMany_v4, {
        ...props,
        count: count,
        ids: selectedIDs,
        onSuccess: ()=>toggleAll(),
        selectAll: selectAll === SelectAllStatus.AllAvailable
    }, void 0, false, {
        fileName: "src/elements/PublishMany/index.tsx",
        lineNumber: 21,
        columnNumber: 5
    }, this);
};
/**
   * When multiple PublishMany components are rendered on the page, this will differentiate them.
   */ export const PublishMany_v4 = (props)=>{
    const { collection, collection: { slug, versions } = {}, count, ids, modalPrefix, onSuccess, selectAll, where } = props;
    const { permissions } = useAuth();
    const { t } = useTranslation();
    const { openModal } = useModal();
    const collectionPermissions = permissions?.collections?.[slug];
    const hasPermission = collectionPermissions?.update;
    const drawerSlug = `${modalPrefix ? `${modalPrefix}-` : ''}publish-${slug}`;
    if (!versions?.drafts || count === 0 || !hasPermission) {
        return null;
    }
    return /*#__PURE__*/ _jsxDEV(React.Fragment, {
        children: [
            /*#__PURE__*/ _jsxDEV(ListSelectionButton, {
                "aria-label": t('version:publish'),
                onClick: ()=>{
                    openModal(drawerSlug);
                },
                children: t('version:publish')
            }, void 0, false, {
                fileName: "src/elements/PublishMany/index.tsx",
                lineNumber: 71,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV(PublishManyDrawerContent, {
                collection: collection,
                drawerSlug: drawerSlug,
                ids: ids,
                onSuccess: onSuccess,
                selectAll: selectAll,
                where: where
            }, void 0, false, {
                fileName: "src/elements/PublishMany/index.tsx",
                lineNumber: 79,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/elements/PublishMany/index.tsx",
        lineNumber: 70,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map