"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__, {
    BlockTemplateDetails: ()=>BlockTemplateDetails
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const pro_layout_namespaceObject = require("@ant-design/pro-layout");
const external_antd_namespaceObject = require("antd");
const external_react_router_dom_namespaceObject = require("react-router-dom");
const external_index_js_namespaceObject = require("../index.js");
const index_js_namespaceObject = require("../schema-component/index.js");
const EditableTitle = (props)=>{
    const [title, setTitle] = (0, external_react_namespaceObject.useState)(props.title);
    const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
    const { refresh } = (0, external_index_js_namespaceObject.useSchemaTemplateManager)();
    const { run } = (0, external_index_js_namespaceObject.useRequest)({
        resource: 'uiSchemaTemplates',
        action: 'update',
        params: {
            filterByTk: props.filterByTk
        }
    }, {
        manual: true,
        debounceWait: 500,
        onSuccess () {
            refresh();
        }
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        children: visible ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Input, {
            defaultValue: title,
            size: 'large',
            onBlur: ()=>{
                setVisible(false);
            },
            onChange: (e)=>{
                setTitle(e.target.value);
                run({
                    filterByTk: props.filterByTk,
                    values: {
                        name: e.target.value
                    }
                });
            }
        }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
            onClick: ()=>{
                setVisible(true);
            },
            children: title || /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                style: {
                    color: '#bbb'
                },
                children: "未命名"
            })
        })
    });
};
const BlockTemplateDetails = ()=>{
    var _data_data, _data_data1;
    const navigate = (0, external_react_router_dom_namespaceObject.useNavigate)();
    const params = (0, external_react_router_dom_namespaceObject.useParams)();
    const key = null == params ? void 0 : params.key;
    const value = (0, external_react_namespaceObject.useContext)(index_js_namespaceObject.SchemaComponentContext);
    const { data, loading } = (0, external_index_js_namespaceObject.useRequest)({
        resource: 'uiSchemaTemplates',
        action: 'get',
        params: {
            filterByTk: key
        }
    });
    if (loading) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {});
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(pro_layout_namespaceObject.PageHeader, {
                style: {
                    backgroundColor: 'white'
                },
                onBack: ()=>{
                    navigate('/admin/plugins/block-templates');
                },
                ghost: false,
                title: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditableTitle, {
                    filterByTk: key,
                    title: null == data ? void 0 : null === (_data_data = data.data) || void 0 === _data_data ? void 0 : _data_data.name
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                style: {
                    margin: 'var(--tb-spacing)'
                },
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.SchemaComponentContext.Provider, {
                    value: {
                        ...value,
                        designable: true
                    },
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.RemoteSchemaComponent, {
                        uid: null == data ? void 0 : null === (_data_data1 = data.data) || void 0 === _data_data1 ? void 0 : _data_data1.uid
                    })
                })
            })
        ]
    });
};
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
});
