"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    InternaPopoverNester: ()=>InternaPopoverNester
});
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 external_antd_style_namespaceObject = require("antd-style");
const external_react_i18next_namespaceObject = require("react-i18next");
const context_js_namespaceObject = require("../action/context.js");
const useGetAriaLabelOfPopover_js_namespaceObject = require("../action/hooks/useGetAriaLabelOfPopover.js");
require("../action/hooks/useSetAriaLabelForPopover.js");
const index_js_namespaceObject = require("../popover/index.js");
const external_hooks_js_namespaceObject = require("./hooks.js");
const external_InternalNester_js_namespaceObject = require("./InternalNester.js");
const external_InternalViewer_js_namespaceObject = require("./InternalViewer.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      max-width: 95%;\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
function _templateObject1() {
    const data = _tagged_template_literal([
        "\n      position: fixed;\n      top: 0;\n      left: 0;\n      width: 100%;\n      height: 100%;\n      background-color: transparent;\n      z-index: 9999;\n    "
    ]);
    _templateObject1 = function() {
        return data;
    };
    return data;
}
function _templateObject2() {
    const data = _tagged_template_literal([
        "\n      min-width: 600px;\n      max-width: 800px;\n      max-height: 440px;\n      overflow: auto;\n      .ant-card {\n        border: 0px;\n      }\n    "
    ]);
    _templateObject2 = function() {
        return data;
    };
    return data;
}
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css } = param;
    return {
        pretty: css(_templateObject()),
        mask: css(_templateObject1()),
        container: css(_templateObject2())
    };
});
const InternaPopoverNester = (0, schema_namespaceObject.observer)((props)=>{
    var _options_uiSchema;
    const { styles } = useStyles();
    const { options } = (0, external_hooks_js_namespaceObject.useAssociationFieldContext)();
    const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const schema = (0, schema_namespaceObject.useFieldSchema)();
    schema['x-component-props'].enableLink = false;
    const ref = (0, external_react_namespaceObject.useRef)();
    const nesterProps = {
        ...props,
        shouldMountElement: true
    };
    const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        ref: ref,
        className: styles.container,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_InternalNester_js_namespaceObject.InternalNester, {
            ...nesterProps
        })
    });
    const getContainer = ()=>ref.current;
    const ctx = (0, external_react_namespaceObject.useContext)(context_js_namespaceObject.ActionContext);
    const modalProps = {
        getContainer: getContainer
    };
    const { getAriaLabel } = (0, useGetAriaLabelOfPopover_js_namespaceObject.useGetAriaLabelOfPopover)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(context_js_namespaceObject.ActionContextProvider, {
        value: {
            ...ctx,
            modalProps
        },
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.StablePopover, {
                overlayStyle: {
                    padding: '0px'
                },
                content: content,
                trigger: "click",
                placement: "topLeft",
                open: visible,
                onOpenChange: (open)=>setVisible(open),
                title: t(null == options ? void 0 : null === (_options_uiSchema = options.uiSchema) || void 0 === _options_uiSchema ? void 0 : _options_uiSchema.rawTitle),
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
                    style: {
                        cursor: 'pointer',
                        display: 'flex'
                    },
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                            className: styles.pretty,
                            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_InternalViewer_js_namespaceObject.ReadPrettyInternalViewer, {
                                ...props
                            })
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.EditOutlined, {
                            style: {
                                display: 'inline-flex',
                                margin: '5px'
                            }
                        })
                    ]
                })
            }),
            visible && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                role: "button",
                "aria-label": getAriaLabel('mask'),
                onClick: ()=>setVisible(false),
                className: styles.mask
            })
        ]
    });
}, {
    displayName: 'InternaPopoverNester'
});
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
});
