'use client'; import { c as _c } from "react/compiler-runtime"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-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 $ = _c(8); const { count, selectAll, selectedIDs, toggleAll } = useSelection(); let t0; if ($[0] !== toggleAll) { t0 = () => toggleAll(); $[0] = toggleAll; $[1] = t0; } else { t0 = $[1]; } const t1 = selectAll === SelectAllStatus.AllAvailable; let t2; if ($[2] !== count || $[3] !== props || $[4] !== selectedIDs || $[5] !== t0 || $[6] !== t1) { t2 = _jsx(PublishMany_v4, { ...props, count, ids: selectedIDs, onSuccess: t0, selectAll: t1 }); $[2] = count; $[3] = props; $[4] = selectedIDs; $[5] = t0; $[6] = t1; $[7] = t2; } else { t2 = $[7]; } return t2; }; export const PublishMany_v4 = props => { const $ = _c(12); const { collection, collection: t0, count, ids, modalPrefix, onSuccess, selectAll, where } = props; const { slug, versions } = t0 === undefined ? {} : t0; 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; } let t1; if ($[0] !== collection || $[1] !== drawerSlug || $[2] !== ids || $[3] !== onSuccess || $[4] !== openModal || $[5] !== selectAll || $[6] !== t || $[7] !== where) { let t2; if ($[9] !== drawerSlug || $[10] !== openModal) { t2 = () => { openModal(drawerSlug); }; $[9] = drawerSlug; $[10] = openModal; $[11] = t2; } else { t2 = $[11]; } t1 = _jsxs(React.Fragment, { children: [_jsx(ListSelectionButton, { "aria-label": t("version:publish"), onClick: t2, children: t("version:publish") }), _jsx(PublishManyDrawerContent, { collection, drawerSlug, ids, onSuccess, selectAll, where })] }); $[0] = collection; $[1] = drawerSlug; $[2] = ids; $[3] = onSuccess; $[4] = openModal; $[5] = selectAll; $[6] = t; $[7] = where; $[8] = t1; } else { t1 = $[8]; } return t1; }; //# sourceMappingURL=index.js.map