"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    Amplifier: ()=>Amplifier,
    ActionModal: ()=>ActionModal,
    default: ()=>Action_Modal_rslib_entry_
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const icons_namespaceObject = require("@ant-design/icons");
const css_namespaceObject = require("@emotion/css");
const external_antd_namespaceObject = require("antd");
const external_antd_style_namespaceObject = require("antd-style");
const external_classnames_namespaceObject = require("classnames");
var external_classnames_default = /*#__PURE__*/ __webpack_require__.n(external_classnames_namespaceObject);
const external_index_js_namespaceObject = require("./index.js");
require("./hooks/useSetAriaLabelForModal.js");
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n      &.tb-action-popup {\n        .ant-modal-header {\n          // TODO: theme variables\n          margin-top: -20px;\n          margin-left: -24px;\n          margin-right: -24px;\n          padding-top: 20px;\n          padding-left: 24px;\n          padding-right: 24px;\n          padding-bottom: 20px;\n        }\n        .ant-modal-content {\n          background: var(--tb-box-bg);\n        }\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
function _templateObject1() {
    const data = _tagged_template_literal([
        "\n                  background: none;\n                  border: none;\n                "
    ]);
    _templateObject1 = function() {
        return data;
    };
    return data;
}
function _templateObject2() {
    const data = _tagged_template_literal([
        "\n        background: none;\n        border: none;\n      "
    ]);
    _templateObject2 = function() {
        return data;
    };
    return data;
}
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css } = param;
    return {
        container: css(_templateObject())
    };
});
const openSizeWidthMap = new Map([
    [
        'small',
        '40%'
    ],
    [
        'middle',
        '60%'
    ],
    [
        'large',
        '80%'
    ]
]);
const ActionModal = (0, schema_namespaceObject.observer)((props)=>{
    const { footerNodeName = 'Action.Modal.Footer', width, ...others } = props;
    const { styles } = useStyles();
    const { visible, setVisible, openSize = 'middle', modalProps } = (0, external_index_js_namespaceObject.useActionContext)();
    const actualWidth = null != width ? width : openSizeWidthMap.get(openSize);
    const schema = (0, schema_namespaceObject.useFieldSchema)();
    const field = (0, schema_namespaceObject.useField)();
    const footerSchema = schema.reduceProperties((buf, s)=>{
        if (s['x-component'] === footerNodeName) return s;
        return buf;
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Modal, {
        width: actualWidth,
        title: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
            style: {
                display: 'flex'
            },
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                    style: {
                        flex: 1
                    },
                    children: field.title
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Amplifier, {}),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
                            type: "text",
                            icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CloseOutlined, {}),
                            className: (0, css_namespaceObject.css)(_templateObject1()),
                            onClick: ()=>setVisible(false, true)
                        })
                    ]
                })
            ]
        }),
        ...others,
        ...modalProps,
        style: {
            ...null == modalProps ? void 0 : modalProps.style,
            ...null == others ? void 0 : others.style
        },
        destroyOnClose: true,
        open: visible,
        closable: false,
        className: external_classnames_default()(others.className, null == modalProps ? void 0 : modalProps.className, styles.container, 'amplifier-block'),
        footer: !!footerSchema && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
            basePath: field.address,
            schema: schema,
            onlyRenderProperties: true,
            filterProperties: (s)=>s['x-component'] === footerNodeName
        }),
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
            basePath: field.address,
            schema: schema,
            onlyRenderProperties: true,
            filterProperties: (s)=>s['x-component'] !== footerNodeName
        })
    });
}, {
    displayName: 'ActionModal'
});
ActionModal.Footer = (0, schema_namespaceObject.observer)(()=>{
    const field = (0, schema_namespaceObject.useField)();
    const schema = (0, schema_namespaceObject.useFieldSchema)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
        basePath: field.address,
        schema: schema,
        onlyRenderProperties: true
    });
}, {
    displayName: 'ActionModal.Footer'
});
const Action_Modal_rslib_entry_ = ActionModal;
const Amplifier = ()=>{
    const [isAmplifier, setIsAmplifier] = (0, external_react_namespaceObject.useState)(false);
    const [blockWidth, setBlockWidth] = (0, external_react_namespaceObject.useState)('');
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
        icon: isAmplifier ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.FullscreenExitOutlined, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.FullscreenOutlined, {}),
        type: "text",
        className: (0, css_namespaceObject.css)(_templateObject2()),
        onClick: (e)=>{
            const element = e.target.closest('.ant-modal-content');
            const modal = document.querySelector('.ant-modal');
            const mask = document.querySelector('.ant-modal-mask');
            if (isAmplifier) {
                modal.style.width = blockWidth;
                element.style.width = '';
                modal.style.top = '';
                modal.style.padding = '';
                modal.style.margin = '';
                mask.style.backgroundColor = '';
            } else {
                setBlockWidth(modal.getBoundingClientRect().width + 'px');
                element.style.width = '100vw';
                modal.style.width = '100%';
                modal.style.top = '0';
                modal.style.padding = '0';
                modal.style.margin = '0';
                mask.style.backgroundColor = '#f3f3f3';
            }
            setIsAmplifier(!isAmplifier);
        }
    });
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
