var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  RenderContentPanel: () => RenderContentPanel
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_pro_utils = require("@antdv/pro-utils");
var import_ant_design_vue = require("ant-design-vue");
var import_vue2 = require("vue");
var import_HelpProvide = require("./HelpProvide");
var import_ProHelpPanel = require("./ProHelpPanel");
const HTMLRender = (props) => {
  return (0, import_vue.createVNode)("div", {
    "class": props.className || "inner-html",
    "innerHTML": props.content
  }, null);
};
HTMLRender.inheritAttrs = false;
const NavigationSwitch = (0, import_vue2.defineComponent)({
  name: "NavigationSwitch",
  props: {
    content: (0, import_pro_utils.stringType)().isRequired,
    selectKey: (0, import_pro_utils.stringType)().isRequired
  },
  setup(props, {
    slots
  }) {
    const context = import_ProHelpPanel.SelectKeyContext.useContext();
    return () => {
      return (0, import_vue.createVNode)(import_ant_design_vue.Typography.Text, null, {
        default: () => [(0, import_vue.createVNode)("a", {
          "data-testid": "navigation-switch",
          "onClick": () => {
            context.selectedKey = props.selectKey;
          }
        }, [props.content])]
      });
    };
  }
});
const RenderContentPanel = (0, import_vue2.defineComponent)({
  name: "RenderContentPanel",
  props: {
    dataSourceChildren: (0, import_pro_utils.arrayType)().isRequired,
    onInit: (0, import_pro_utils.funcType)()
  },
  setup(props) {
    const {
      valueTypeMap
    } = import_HelpProvide.ProHelpContext.useContext();
    const divRef = (0, import_vue2.ref)(null);
    (0, import_pro_utils.useEffect)(() => {
      var _a;
      (_a = props.onInit) == null ? void 0 : _a.call(props, divRef.value);
    }, (0, import_vue2.computed)(() => [props.dataSourceChildren]));
    return () => {
      var _a;
      const itemRender = (item, index) => {
        var _a2;
        if (valueTypeMap == null ? void 0 : valueTypeMap.has(item.valueType)) {
          return (0, import_vue.createVNode)(import_vue.Fragment, null, [(_a2 = valueTypeMap == null ? void 0 : valueTypeMap.get(item.valueType)) == null ? void 0 : _a2(item, index)]);
        }
        if (item.valueType === "html") {
          return (0, import_vue.createVNode)(HTMLRender, (0, import_vue.mergeProps)({
            "key": index
          }, item.valueChildren), null);
        }
        if (item.valueType === "h1") {
          return (0, import_vue.createVNode)(import_ant_design_vue.Typography.Title, {
            "key": index,
            "style": {
              marginTop: 0
            },
            "level": 3
          }, {
            default: () => [item.valueChildren]
          });
        }
        if (item.valueType === "h2") {
          return (0, import_vue.createVNode)(import_ant_design_vue.Typography.Title, {
            "key": index,
            "style": {
              marginTop: `20px`
            },
            "level": 5
          }, {
            default: () => [item.valueChildren]
          });
        }
        if (item.valueType === "image") {
          return (0, import_vue.createVNode)("div", {
            "key": index,
            "style": {
              marginBlock: `12px`
            }
          }, [(0, import_vue.createVNode)(import_ant_design_vue.Image, item.valueChildren, null)]);
        }
        if (item.valueType === "inlineLink") {
          return (0, import_vue.createVNode)(import_ant_design_vue.Typography.Text, {
            "key": index
          }, {
            default: () => [(0, import_vue.createVNode)("a", item.valueChildren, null)]
          });
        }
        if (item.valueType === "link") {
          return (0, import_vue.createVNode)("div", {
            "key": index
          }, [(0, import_vue.createVNode)(import_ant_design_vue.Typography.Text, {
            "key": index
          }, {
            default: () => [(0, import_vue.createVNode)("a", item.valueChildren, null)]
          })]);
        }
        if (item.valueType === "navigationSwitch") {
          return (0, import_vue.createVNode)(NavigationSwitch, (0, import_vue.mergeProps)({
            "key": index
          }, item.valueChildren), null);
        }
        return (0, import_vue.createVNode)(import_ant_design_vue.Typography.Text, {
          "key": index
        }, {
          default: () => [item.valueChildren]
        });
      };
      return (0, import_vue.createVNode)("div", {
        "ref": divRef
      }, [(_a = props.dataSourceChildren) == null ? void 0 : _a.map(itemRender)]);
    };
  }
});
