'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "ListSelection", {
    enumerable: true,
    get: function() {
        return ListSelection;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _SelectionProvider = require("../../providers/SelectionProvider");
const _Translation = require("../../providers/Translation");
require("./index.scss");
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const baseClass = 'list-selection';
const ListSelection = ({ label })=>{
    const { count, selectAll, toggleAll, totalDocs } = (0, _SelectionProvider.useSelection)();
    const { t } = (0, _Translation.useTranslation)();
    if (count === 0) {
        return null;
    }
    return /*#__PURE__*/ _react.default.createElement("div", {
        className: baseClass
    }, /*#__PURE__*/ _react.default.createElement("span", null, t('general:selectedCount', {
        count,
        label
    })), selectAll !== _SelectionProvider.SelectAllStatus.AllAvailable && /*#__PURE__*/ _react.default.createElement(_react.Fragment, null, ' ', "—", /*#__PURE__*/ _react.default.createElement("button", {
        "aria-label": t('general:selectAll', {
            count,
            label
        }),
        className: `${baseClass}__button`,
        onClick: ()=>toggleAll(true),
        type: "button"
    }, t('general:selectAll', {
        count: totalDocs,
        label
    }))));
};

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9lbGVtZW50cy9MaXN0U2VsZWN0aW9uL2luZGV4LnRzeCJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIGNsaWVudCdcbmltcG9ydCBSZWFjdCwgeyBGcmFnbWVudCB9IGZyb20gJ3JlYWN0J1xuXG5pbXBvcnQgeyBTZWxlY3RBbGxTdGF0dXMsIHVzZVNlbGVjdGlvbiB9IGZyb20gJy4uLy4uL3Byb3ZpZGVycy9TZWxlY3Rpb25Qcm92aWRlcidcbmltcG9ydCB7IHVzZVRyYW5zbGF0aW9uIH0gZnJvbSAnLi4vLi4vcHJvdmlkZXJzL1RyYW5zbGF0aW9uJ1xuaW1wb3J0ICcuL2luZGV4LnNjc3MnXG5cbmNvbnN0IGJhc2VDbGFzcyA9ICdsaXN0LXNlbGVjdGlvbidcblxudHlwZSBQcm9wcyA9IHtcbiAgbGFiZWw6IHN0cmluZ1xufVxuZXhwb3J0IGNvbnN0IExpc3RTZWxlY3Rpb246IFJlYWN0LkZDPFByb3BzPiA9ICh7IGxhYmVsIH0pID0+IHtcbiAgY29uc3QgeyBjb3VudCwgc2VsZWN0QWxsLCB0b2dnbGVBbGwsIHRvdGFsRG9jcyB9ID0gdXNlU2VsZWN0aW9uKClcbiAgY29uc3QgeyB0IH0gPSB1c2VUcmFuc2xhdGlvbigpXG5cbiAgaWYgKGNvdW50ID09PSAwKSB7XG4gICAgcmV0dXJuIG51bGxcbiAgfVxuXG4gIHJldHVybiAoXG4gICAgPGRpdiBjbGFzc05hbWU9e2Jhc2VDbGFzc30+XG4gICAgICA8c3Bhbj57dCgnZ2VuZXJhbDpzZWxlY3RlZENvdW50Jywg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