import { defineComponent, ref, watch, resolveComponent, openBlock, createBlock, withCtx, createVNode, createTextVNode, createElementBlock, createElementVNode, unref, useCssVars, toRefs, computed, createCommentVNode, Fragment, renderList, normalizeClass, toDisplayString, pushScopeId, popScopeId, reactive, nextTick, toRaw, watchEffect, onBeforeUnmount } from "vue";
import { d as goDialog, _ as _export_sfc, y as useDesignStore, i as icon, b3 as RequestParamsTypeEnum, ba as RequestContentTypeEnum, a_ as SettingItemBox, b4 as SettingItem, b0 as SelectHttpTimeNameObj, bd as RequestBodyEnum, g as getUUID, l as lodashExports, bf as requestConfig, b2 as RequestDataTypeEnum, b8 as customizeHttp, bb as newFunctionHandle } from "./index-67bc0910.js";
import { n as noData } from "./noData-b19667d9.js";
import { u as useTargetData } from "./useTargetData.hook-83638ed4.js";
import "./index-904b39c1.js";
import { R as RequestGlobalConfig, a as RequestTargetConfig } from "./pondIndex.vue_vue_type_style_index_0_scoped_de860d6d_lang-3714dc2f.js";
import "./EditorWorker-e8a74551.js";
import { C as ChartDataMatchingAndShow } from "./index-ef0ff8e6.js";
import "./fileTypeEnum-d13b2cef.js";
const _hoisted_1$5 = { class: "go-pr-3" };
const _hoisted_2$4 = { key: 1 };
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  __name: "pondIndex",
  props: {
    modelShow: Boolean,
    targetDataRequest: Object
  },
  emits: ["update:modelShow", "editSaveHandle"],
  setup(__props, { emit }) {
    const props = __props;
    ref();
    const inputInstRef = ref();
    const modelShowRef = ref(false);
    watch(() => props.modelShow, (newValue) => {
      modelShowRef.value = newValue;
    });
    const closeHandle = () => {
      emit("update:modelShow", false);
    };
    const closeAndSendHandle = () => {
      var _a, _b;
      if (!((_a = props.targetDataRequest) == null ? void 0 : _a.dataPondName)) {
        window.$message.warning("请在左下角输入名称！");
        (_b = inputInstRef.value) == null ? void 0 : _b.focus();
        return;
      }
      goDialog({
        message: "保存内容将同步修改所有使用此接口的组件, 是否继续?",
        isMaskClosable: true,
        transformOrigin: "center",
        onPositiveCallback: () => {
          emit("update:modelShow", false);
          emit("editSaveHandle", props.targetDataRequest);
        }
      });
    };
    return (_ctx, _cache) => {
      const _component_n_space = resolveComponent("n-space");
      const _component_n_scrollbar = resolveComponent("n-scrollbar");
      const _component_n_tag = resolveComponent("n-tag");
      const _component_n_input = resolveComponent("n-input");
      const _component_n_button = resolveComponent("n-button");
      const _component_n_card = resolveComponent("n-card");
      const _component_n_modal = resolveComponent("n-modal");
      return openBlock(), createBlock(_component_n_modal, {
        class: "go-chart-data-request",
        show: modelShowRef.value,
        "onUpdate:show": _cache[1] || (_cache[1] = ($event) => modelShowRef.value = $event),
        "mask-closable": false,
        closeOnEsc: false
      }, {
        default: withCtx(() => [
          createVNode(_component_n_card, {
            bordered: false,
            role: "dialog",
            size: "small",
            "aria-modal": "true",
            style: { "width": "1000px", "height": "800px" }
          }, {
            header: withCtx(() => []),
            "header-extra": withCtx(() => []),
            action: withCtx(() => [
              createVNode(_component_n_space, { justify: "space-between" }, {
                default: withCtx(() => [
                  __props.targetDataRequest ? (openBlock(), createBlock(_component_n_space, { key: 0 }, {
                    default: withCtx(() => [
                      createVNode(_component_n_tag, {
                        bordered: false,
                        type: "primary"
                      }, {
                        default: withCtx(() => [
                          createTextVNode("名称：")
                        ]),
                        _: 1
                      }),
                      createVNode(_component_n_input, {
                        value: __props.targetDataRequest.dataPondName,
                        "onUpdate:value": _cache[0] || (_cache[0] = ($event) => __props.targetDataRequest.dataPondName = $event),
                        ref_key: "inputInstRef",
                        ref: inputInstRef,
                        type: "text",
                        size: "small",
                        autofocus: true,
                        clearable: true,
                        minlength: 1,
                        maxlength: 16,
                        placeholder: "请输入名称"
                      }, null, 8, ["value"])
                    ]),
                    _: 1
                  })) : (openBlock(), createElementBlock("span", _hoisted_2$4)),
                  createVNode(_component_n_space, null, {
                    default: withCtx(() => [
                      createVNode(_component_n_button, { onClick: closeHandle }, {
                        default: withCtx(() => [
                          createTextVNode("取消")
                        ]),
                        _: 1
                      }),
                      createVNode(_component_n_button, {
                        type: "primary",
                        onClick: closeAndSendHandle
                      }, {
                        default: withCtx(() => [
                          createTextVNode("保存")
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            default: withCtx(() => [
              createVNode(_component_n_scrollbar, { style: { "max-height": "718px" } }, {
                default: withCtx(() => [
                  createElementVNode("div", _hoisted_1$5, [
                    createVNode(_component_n_space, { vertical: "" }, {
                      default: withCtx(() => {
                        var _a;
                        return [
                          createVNode(unref(RequestGlobalConfig)),
                          createVNode(unref(RequestTargetConfig), {
                            "target-data-request": (_a = __props.targetDataRequest) == null ? void 0 : _a.dataPondRequestConfig
                          }, null, 8, ["target-data-request"])
                        ];
                      }),
                      _: 1
                    })
                  ])
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["show"]);
    };
  }
});
const PondDataRequest = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-de860d6d"]]);
const _withScopeId = (n) => (pushScopeId("data-v-43dfb7fe"), n = n(), popScopeId(), n);
const _hoisted_1$4 = { class: "go-chart-data-pond-list" };
const _hoisted_2$3 = { class: "pond-item-box" };
const _hoisted_3$2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", null, " 创建 ", -1));
const _hoisted_4$1 = ["onClick"];
const _hoisted_5$1 = { class: "item-content" };
const _hoisted_6$1 = { class: "item-content-body" };
const _hoisted_7$1 = ["onClick"];
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  __name: "index",
  emits: ["createPond", "deletePond"],
  setup(__props, { emit }) {
    useCssVars((_ctx) => ({
      "1013e1a5": themeColor.value
    }));
    const { DuplicateOutlineIcon, TrashIcon } = icon.ionicons5;
    const designStore = useDesignStore();
    const { chartEditStore, targetData } = useTargetData();
    const { requestDataPond } = toRefs(chartEditStore.getRequestGlobalConfig);
    const selectPondId = computed(() => {
      return targetData.value.request.requestDataPondId;
    });
    const themeColor = computed(() => {
      return designStore.getAppTheme;
    });
    const createPond = () => {
      emit("createPond", true);
    };
    const deletePond = (target, targetData2) => {
      target.stopPropagation();
      target.preventDefault();
      emit("deletePond", targetData2);
    };
    const clickHandle = (item) => {
      targetData.value.request.requestDataPondId = item.dataPondId;
    };
    return (_ctx, _cache) => {
      const _component_n_timeline_item = resolveComponent("n-timeline-item");
      const _component_n_timeline = resolveComponent("n-timeline");
      const _component_n_icon = resolveComponent("n-icon");
      const _component_n_button = resolveComponent("n-button");
      const _component_n_divider = resolveComponent("n-divider");
      const _component_n_a = resolveComponent("n-a");
      const _component_n_text = resolveComponent("n-text");
      const _component_n_space = resolveComponent("n-space");
      const _component_n_tag = resolveComponent("n-tag");
      const _component_n_ellipsis = resolveComponent("n-ellipsis");
      const _component_n_scrollbar = resolveComponent("n-scrollbar");
      return openBlock(), createElementBlock("div", _hoisted_1$4, [
        createVNode(_component_n_timeline, {
          class: "pond-item-timeline",
          style: { "width": "20px" }
        }, {
          default: withCtx(() => [
            createVNode(_component_n_timeline_item, { type: "info" }),
            createVNode(_component_n_timeline_item, { type: "success" })
          ]),
          _: 1
        }),
        createElementVNode("div", _hoisted_2$3, [
          createVNode(_component_n_button, {
            class: "create-btn go-py-4",
            ghost: "",
            onClick: createPond
          }, {
            icon: withCtx(() => [
              createVNode(_component_n_icon, null, {
                default: withCtx(() => [
                  createVNode(unref(DuplicateOutlineIcon))
                ]),
                _: 1
              })
            ]),
            default: withCtx(() => [
              _hoisted_3$2
            ]),
            _: 1
          }),
          createVNode(_component_n_divider, { style: { "margin": "10px 0" } }),
          !unref(requestDataPond).length ? (openBlock(), createBlock(_component_n_space, {
            key: 0,
            justify: "center"
          }, {
            default: withCtx(() => [
              createVNode(_component_n_text, {
                class: "not-layer-text",
                depth: 3
              }, {
                default: withCtx(() => [
                  createTextVNode(" 暂无数据内容， "),
                  createVNode(_component_n_a, { onClick: createPond }, {
                    default: withCtx(() => [
                      createTextVNode("立即创建")
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            _: 1
          })) : createCommentVNode("", true),
          createVNode(_component_n_scrollbar, { style: { "max-height": "490px" } }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(Fragment, null, renderList(unref(requestDataPond), (item) => {
                return openBlock(), createElementBlock("div", {
                  key: item.dataPondId,
                  class: normalizeClass([{ select: item.dataPondId === selectPondId.value }, "pond-item"]),
                  onClick: ($event) => clickHandle(item)
                }, [
                  createElementVNode("div", _hoisted_5$1, [
                    createElementVNode("div", _hoisted_6$1, [
                      createElementVNode("div", null, [
                        createVNode(_component_n_tag, {
                          class: "go-mr-1",
                          type: item.dataPondId === selectPondId.value ? "warning" : "",
                          bordered: false
                        }, {
                          default: withCtx(() => [
                            createTextVNode(" 名称 ")
                          ]),
                          _: 2
                        }, 1032, ["type"]),
                        createVNode(_component_n_ellipsis, { style: { "max-width": "180px" } }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(item.dataPondName || "暂无"), 1)
                          ]),
                          _: 2
                        }, 1024)
                      ]),
                      createElementVNode("div", null, [
                        createVNode(_component_n_tag, {
                          class: "go-mr-1",
                          type: item.dataPondId === selectPondId.value ? "warning" : "",
                          bordered: false
                        }, {
                          default: withCtx(() => [
                            createTextVNode(" 地址 ")
                          ]),
                          _: 2
                        }, 1032, ["type"]),
                        createVNode(_component_n_ellipsis, { style: { "max-width": "180px" } }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(item.dataPondRequestConfig.requestUrl || "暂无"), 1)
                          ]),
                          _: 2
                        }, 1024)
                      ])
                    ]),
                    createElementVNode("div", {
                      class: "item-content-icon go-transition-quick",
                      onClick: ($event) => deletePond($event, item)
                    }, [
                      createVNode(_component_n_icon, null, {
                        default: withCtx(() => [
                          createVNode(unref(TrashIcon))
                        ]),
                        _: 1
                      })
                    ], 8, _hoisted_7$1)
                  ]),
                  createElementVNode("div", {
                    class: normalizeClass({ "select-modal": item.dataPondId === selectPondId.value })
                  }, null, 2)
                ], 10, _hoisted_4$1);
              }), 128))
            ]),
            _: 1
          })
        ])
      ]);
    };
  }
});
const index_vue_vue_type_style_index_0_scoped_43dfb7fe_lang = "";
const ChartDataPondList = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-43dfb7fe"]]);
const _hoisted_1$3 = /* @__PURE__ */ createElementVNode("thead", null, [
  /* @__PURE__ */ createElementVNode("tr", null, [
    /* @__PURE__ */ createElementVNode("th", null, "key"),
    /* @__PURE__ */ createElementVNode("th", null, "value")
  ])
], -1);
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "displayTable",
  props: {
    target: Object
  },
  setup(__props) {
    const props = __props;
    const defaultItem = {
      key: "",
      value: ""
    };
    const tableArray = reactive({ content: [] });
    watch(
      () => props.target,
      (target) => {
        tableArray.content = [];
        for (const k in target) {
          tableArray.content.push({
            key: k,
            value: target[k]
          });
        }
        if (!tableArray.content.length)
          tableArray.content = [JSON.parse(JSON.stringify(defaultItem))];
      },
      {
        immediate: true,
        deep: true
      }
    );
    return (_ctx, _cache) => {
      const _component_n_table = resolveComponent("n-table");
      return openBlock(), createBlock(_component_n_table, {
        bordered: false,
        "single-line": false,
        size: "small",
        style: { "border-bottom-right-radius": "7px", "border-bottom-left-radius": "7px" }
      }, {
        default: withCtx(() => [
          _hoisted_1$3,
          createElementVNode("tbody", null, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(tableArray.content, (item, index2) => {
              return openBlock(), createElementBlock("tr", { key: index2 }, [
                createElementVNode("td", null, toDisplayString(item.key || "暂无"), 1),
                createElementVNode("td", null, toDisplayString(item.value || "暂无"), 1)
              ]);
            }), 128))
          ])
        ]),
        _: 1
      });
    };
  }
});
const _hoisted_1$2 = { class: "go-chart-data-display" };
const _hoisted_2$2 = { class: "go-mr-3" };
const _hoisted_3$1 = { key: 0 };
const _hoisted_4 = { class: "go-mt-3" };
const _hoisted_5 = { key: 0 };
const _hoisted_6 = { key: 1 };
const _hoisted_7 = { key: 1 };
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    globalData: Object,
    targetData: Object
  },
  setup(__props) {
    const props = __props;
    const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5;
    const {
      requestUrl,
      requestInterval,
      requestHttpType,
      requestContentType,
      requestSQLContent,
      requestParams,
      requestParamsBodyType,
      requestIntervalUnit
    } = toRefs(props.targetData.dataPondRequestConfig);
    [RequestParamsTypeEnum.HEADER];
    const requestContentTypeObj = {
      [RequestContentTypeEnum.DEFAULT]: "普通请求",
      [RequestContentTypeEnum.SQL]: "SQL 请求"
    };
    const tabValue = ref(RequestParamsTypeEnum.PARAMS);
    return (_ctx, _cache) => {
      const _component_n_input = resolveComponent("n-input");
      const _component_n_icon = resolveComponent("n-icon");
      const _component_n_divider = resolveComponent("n-divider");
      const _component_n_tab = resolveComponent("n-tab");
      const _component_n_tabs = resolveComponent("n-tabs");
      const _component_n_text = resolveComponent("n-text");
      const _component_n_card = resolveComponent("n-card");
      const _component_n_code = resolveComponent("n-code");
      const _component_n_scrollbar = resolveComponent("n-scrollbar");
      return openBlock(), createElementBlock("div", _hoisted_1$2, [
        createVNode(_component_n_scrollbar, { style: { "max-height": "570px" } }, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_2$2, [
              createElementVNode("div", null, [
                createVNode(unref(SettingItemBox), { name: "主体信息" }, {
                  default: withCtx(() => [
                    createVNode(unref(SettingItem), { name: "接口名称" }, {
                      default: withCtx(() => {
                        var _a;
                        return [
                          createVNode(_component_n_input, {
                            size: "small",
                            placeholder: ((_a = __props.targetData) == null ? void 0 : _a.dataPondName) || "暂无",
                            disabled: true
                          }, null, 8, ["placeholder"])
                        ];
                      }),
                      _: 1
                    }),
                    createVNode(unref(SettingItem), { name: "接口类型" }, {
                      default: withCtx(() => [
                        createVNode(_component_n_input, {
                          size: "small",
                          placeholder: unref(requestHttpType) || "暂无",
                          disabled: true
                        }, null, 8, ["placeholder"])
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                }),
                createVNode(unref(SettingItemBox), null, {
                  default: withCtx(() => [
                    createVNode(unref(SettingItem), { name: "组件间隔" }, {
                      default: withCtx(() => [
                        createVNode(_component_n_input, {
                          size: "small",
                          placeholder: `${unref(requestInterval) || "暂无"}`,
                          disabled: true
                        }, {
                          suffix: withCtx(() => [
                            createTextVNode(toDisplayString(__props.targetData && unref(SelectHttpTimeNameObj)[unref(requestIntervalUnit)]), 1)
                          ]),
                          _: 1
                        }, 8, ["placeholder"])
                      ]),
                      _: 1
                    }),
                    createVNode(unref(SettingItem), { name: "全局间隔（默认）" }, {
                      default: withCtx(() => {
                        var _a;
                        return [
                          createVNode(_component_n_input, {
                            size: "small",
                            placeholder: `${((_a = __props.globalData) == null ? void 0 : _a.requestInterval) || "暂无"}`,
                            disabled: true
                          }, {
                            suffix: withCtx(() => [
                              createTextVNode(toDisplayString(__props.globalData && unref(SelectHttpTimeNameObj)[__props.globalData.requestIntervalUnit]), 1)
                            ]),
                            _: 1
                          }, 8, ["placeholder"])
                        ];
                      }),
                      _: 1
                    })
                  ]),
                  _: 1
                }),
                createVNode(unref(SettingItemBox), {
                  name: "源地址",
                  alone: true
                }, {
                  default: withCtx(() => {
                    var _a;
                    return [
                      createVNode(_component_n_input, {
                        size: "small",
                        placeholder: ((_a = __props.globalData) == null ? void 0 : _a.requestOriginUrl) || "暂无",
                        disabled: true
                      }, {
                        prefix: withCtx(() => [
                          createVNode(_component_n_icon, { component: unref(PulseIcon) }, null, 8, ["component"])
                        ]),
                        _: 1
                      }, 8, ["placeholder"])
                    ];
                  }),
                  _: 1
                }),
                createVNode(unref(SettingItemBox), {
                  name: "接口地址",
                  alone: true
                }, {
                  default: withCtx(() => [
                    createVNode(_component_n_input, {
                      size: "small",
                      placeholder: unref(requestUrl) || "暂无",
                      disabled: true
                    }, {
                      prefix: withCtx(() => [
                        createVNode(_component_n_icon, { component: unref(FlashIcon) }, null, 8, ["component"])
                      ]),
                      _: 1
                    }, 8, ["placeholder"])
                  ]),
                  _: 1
                })
              ]),
              createVNode(_component_n_divider),
              createVNode(unref(SettingItemBox), { name: "类型" }, {
                default: withCtx(() => [
                  createVNode(unref(SettingItem), { name: "配置类型" }, {
                    default: withCtx(() => [
                      createVNode(_component_n_input, {
                        size: "small",
                        placeholder: __props.targetData && requestContentTypeObj[unref(requestContentType)],
                        disabled: true
                      }, null, 8, ["placeholder"])
                    ]),
                    _: 1
                  }),
                  unref(requestContentType) === unref(RequestContentTypeEnum).DEFAULT ? (openBlock(), createBlock(unref(SettingItem), {
                    key: 0,
                    name: "body 类型"
                  }, {
                    default: withCtx(() => [
                      createVNode(_component_n_input, {
                        size: "small",
                        placeholder: __props.targetData && unref(requestParamsBodyType),
                        disabled: true
                      }, null, 8, ["placeholder"])
                    ]),
                    _: 1
                  })) : createCommentVNode("", true)
                ]),
                _: 1
              }),
              unref(requestContentType) === unref(RequestContentTypeEnum).DEFAULT ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
                createVNode(_component_n_tabs, {
                  type: "line",
                  animated: "",
                  value: tabValue.value,
                  "onUpdate:value": _cache[0] || (_cache[0] = ($event) => tabValue.value = $event)
                }, {
                  default: withCtx(() => [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(RequestParamsTypeEnum), (item) => {
                      return openBlock(), createBlock(_component_n_tab, {
                        key: item,
                        name: item,
                        tab: item
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(item), 1)
                        ]),
                        _: 2
                      }, 1032, ["name", "tab"]);
                    }), 128))
                  ]),
                  _: 1
                }, 8, ["value"]),
                createElementVNode("div", _hoisted_4, [
                  tabValue.value !== unref(RequestParamsTypeEnum).BODY ? (openBlock(), createElementBlock("div", _hoisted_5, [
                    createVNode(_sfc_main$3, {
                      class: "go-my-3",
                      target: unref(requestParams)[tabValue.value]
                    }, null, 8, ["target"])
                  ])) : (openBlock(), createElementBlock("div", _hoisted_6, [
                    unref(requestParamsBodyType) === unref(RequestBodyEnum)["NONE"] ? (openBlock(), createBlock(_component_n_card, {
                      key: 0,
                      class: "go-mt-3 go-pb-3"
                    }, {
                      default: withCtx(() => [
                        createVNode(_component_n_text, { depth: "3" }, {
                          default: withCtx(() => [
                            createTextVNode("该接口没有 Body 体")
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })) : unref(requestParamsBodyType) === unref(RequestBodyEnum)["FORM_DATA"] || unref(requestParamsBodyType) === unref(RequestBodyEnum)["X_WWW_FORM_URLENCODED"] ? (openBlock(), createBlock(_sfc_main$3, {
                      key: 1,
                      class: "go-my-3",
                      target: unref(requestParams)[unref(RequestParamsTypeEnum).BODY][unref(requestParamsBodyType)]
                    }, null, 8, ["target"])) : unref(requestParamsBodyType) === unref(RequestBodyEnum)["JSON"] ? (openBlock(), createBlock(_component_n_card, {
                      key: 2,
                      size: "small",
                      style: { "padding-bottom": "7px" }
                    }, {
                      default: withCtx(() => [
                        createVNode(_component_n_code, {
                          code: unref(requestParams)[unref(RequestParamsTypeEnum).BODY][unref(requestParamsBodyType)] || "暂无内容",
                          language: "json"
                        }, null, 8, ["code"])
                      ]),
                      _: 1
                    })) : unref(requestParamsBodyType) === unref(RequestBodyEnum)["XML"] ? (openBlock(), createBlock(_component_n_code, {
                      key: 3,
                      code: unref(requestParams)[unref(RequestParamsTypeEnum).BODY][unref(requestParamsBodyType)] || "",
                      language: "html"
                    }, null, 8, ["code"])) : createCommentVNode("", true)
                  ]))
                ])
              ])) : (openBlock(), createElementBlock("div", _hoisted_7, [
                createVNode(unref(SettingItemBox), { name: "键名" }, {
                  default: withCtx(() => [
                    createVNode(_component_n_text, null, {
                      default: withCtx(() => [
                        createTextVNode("sql")
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                }),
                createVNode(unref(SettingItemBox), { name: "键值" }, {
                  default: withCtx(() => [
                    createVNode(_component_n_code, {
                      code: unref(requestSQLContent).sql || "",
                      language: "sql"
                    }, null, 8, ["code"])
                  ]),
                  _: 1
                })
              ]))
            ])
          ]),
          _: 1
        })
      ]);
    };
  }
});
const index_vue_vue_type_style_index_0_scoped_cc877db2_lang = "";
const ChartDataDisplay = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-cc877db2"]]);
const _hoisted_1$1 = { class: "pond-content" };
const _hoisted_2$1 = {
  key: 1,
  class: "no-data go-flex-center"
};
const _hoisted_3 = ["src"];
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    modelShow: Boolean
  },
  emits: ["update:modelShow", "sendHandle"],
  setup(__props, { emit }) {
    const props = __props;
    const { PencilIcon } = icon.ionicons5;
    const { chartEditStore, targetData } = useTargetData();
    const { requestDataPond } = toRefs(chartEditStore.getRequestGlobalConfig);
    const requestShow = ref(false);
    const modelShowRef = ref(false);
    const loading = ref(false);
    const isEdit = ref(false);
    const editData = ref();
    const pondData = computed(() => {
      var _a, _b;
      const selectId = (_b = (_a = targetData == null ? void 0 : targetData.value) == null ? void 0 : _a.request) == null ? void 0 : _b.requestDataPondId;
      if (!selectId)
        return void 0;
      const data = requestDataPond.value.filter((item) => {
        return selectId === item.dataPondId;
      });
      return data[0];
    });
    watch(() => props.modelShow, (newValue) => {
      modelShowRef.value = newValue;
    });
    watch(
      () => pondData.value,
      (newValue) => {
        loading.value = true;
        editData.value = newValue;
        nextTick(() => {
          loading.value = false;
        });
      },
      {
        immediate: true
      }
    );
    const openPond = (isEditFlag = false) => {
      isEdit.value = !!isEditFlag;
      requestShow.value = true;
    };
    const createPond = () => {
      const id = getUUID();
      editData.value = {
        dataPondId: id,
        dataPondName: id,
        dataPondRequestConfig: lodashExports.cloneDeep({ ...requestConfig, requestDataType: RequestDataTypeEnum.Pond })
      };
      openPond();
    };
    const saveHandle = (newData) => {
      if (isEdit.value) {
        editSaveHandle(newData);
      } else {
        createSaveHandle(newData);
      }
      isEdit.value = false;
      requestShow.value = false;
    };
    const editSaveHandle = (newData) => {
      try {
        const targetIndex = requestDataPond.value.findIndex((item) => item.dataPondId === newData.dataPondId);
        if (targetIndex !== -1) {
          requestDataPond.value.splice(targetIndex, 1, newData);
          chartEditStore.getComponentList.forEach((item) => {
            if (item.request.requestDataType === RequestDataTypeEnum.Pond && item.request.requestDataPondId === newData.dataPondId) {
              item.request = {
                ...toRaw(newData.dataPondRequestConfig),
                requestDataPondId: newData.dataPondId
              };
            }
          });
          window.$message.success("保存成功！");
        } else {
          window.$message.error("编辑失败，请稍后重试！");
        }
      } catch (error) {
        window.$message.error("编辑失败，请稍后重试！");
      }
    };
    const createSaveHandle = (newData) => {
      try {
        if (editData.value) {
          requestDataPond.value.unshift(newData);
          window.$message.success("创建成功!");
        } else {
          window.$message.error("创建失败，请稍后重试!");
        }
      } catch (error) {
        window.$message.error("创建失败，请稍后重试!");
      }
    };
    const deletePond = (targetData2) => {
      goDialog({
        message: "删除数据后，需手动处理使用改接口的组件，是否继续？",
        isMaskClosable: true,
        transformOrigin: "center",
        onPositiveCallback: () => {
          const targetIndex = requestDataPond.value.findIndex((item) => item.dataPondId === targetData2.dataPondId);
          if (targetIndex !== -1) {
            requestDataPond.value.splice(targetIndex, 1);
            window.$message.success("删除成功!");
          } else {
            window.$message.error("删除失败，请稍后重试！");
          }
        }
      });
    };
    const closeHandle = () => {
      if (pondData.value) {
        targetData.value.request = {
          ...toRaw(pondData.value.dataPondRequestConfig),
          requestDataPondId: pondData.value.dataPondId
        };
      }
      emit("update:modelShow", false);
      emit("sendHandle");
    };
    return (_ctx, _cache) => {
      const _component_n_text = resolveComponent("n-text");
      const _component_n_icon = resolveComponent("n-icon");
      const _component_n_button = resolveComponent("n-button");
      const _component_n_space = resolveComponent("n-space");
      const _component_n_card = resolveComponent("n-card");
      const _component_n_modal = resolveComponent("n-modal");
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_n_modal, {
          class: "go-chart-data-pond-control",
          show: modelShowRef.value,
          "onUpdate:show": _cache[1] || (_cache[1] = ($event) => modelShowRef.value = $event),
          "mask-closable": false
        }, {
          default: withCtx(() => [
            createVNode(_component_n_card, {
              bordered: false,
              role: "dialog",
              size: "small",
              "aria-modal": "true",
              style: { "width": "900px", "height": "650px" }
            }, {
              header: withCtx(() => []),
              "header-extra": withCtx(() => []),
              action: withCtx(() => [
                createVNode(_component_n_space, { justify: "space-between" }, {
                  default: withCtx(() => [
                    createVNode(_component_n_button, {
                      type: "info",
                      secondary: "",
                      disabled: !pondData.value,
                      onClick: _cache[0] || (_cache[0] = ($event) => openPond(true))
                    }, {
                      icon: withCtx(() => [
                        createVNode(_component_n_icon, null, {
                          default: withCtx(() => [
                            createVNode(unref(PencilIcon))
                          ]),
                          _: 1
                        })
                      ]),
                      default: withCtx(() => [
                        createTextVNode(" 编辑内容 ")
                      ]),
                      _: 1
                    }, 8, ["disabled"]),
                    createVNode(_component_n_button, {
                      type: "primary",
                      onClick: closeHandle
                    }, {
                      default: withCtx(() => [
                        createTextVNode("保存 & 发送请求")
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                })
              ]),
              default: withCtx(() => [
                createElementVNode("div", _hoisted_1$1, [
                  pondData.value && !loading.value ? (openBlock(), createBlock(unref(ChartDataDisplay), {
                    key: 0,
                    targetData: pondData.value,
                    globalData: unref(chartEditStore).getRequestGlobalConfig
                  }, null, 8, ["targetData", "globalData"])) : (openBlock(), createElementBlock("div", _hoisted_2$1, [
                    createElementVNode("img", {
                      src: unref(noData),
                      alt: "暂无数据"
                    }, null, 8, _hoisted_3),
                    createVNode(_component_n_text, { depth: 3 }, {
                      default: withCtx(() => [
                        createTextVNode("暂未选择公共接口")
                      ]),
                      _: 1
                    })
                  ])),
                  createVNode(unref(ChartDataPondList), {
                    onCreatePond: createPond,
                    onDeletePond: deletePond
                  })
                ])
              ]),
              _: 1
            })
          ]),
          _: 1
        }, 8, ["show"]),
        createVNode(unref(PondDataRequest), {
          modelShow: requestShow.value,
          "onUpdate:modelShow": _cache[2] || (_cache[2] = ($event) => requestShow.value = $event),
          targetDataRequest: editData.value,
          isEdit: isEdit.value,
          onEditSaveHandle: saveHandle
        }, null, 8, ["modelShow", "targetDataRequest", "isEdit"])
      ], 64);
    };
  }
});
const index_vue_vue_type_style_index_0_scoped_f251a5df_lang = "";
const ChartDataPondControl = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-f251a5df"]]);
const _hoisted_1 = { class: "go-chart-data-pond" };
const _hoisted_2 = { class: "go-absolute-center" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    useCssVars((_ctx) => ({
      "5189590e": themeColor.value
    }));
    const designStore = useDesignStore();
    const { HelpOutlineIcon, FlashIcon, PulseIcon, FishIcon } = icon.ionicons5;
    const { targetData, chartEditStore } = useTargetData();
    const {
      requestDataPond,
      requestInterval: GlobalRequestInterval,
      requestIntervalUnit: GlobalRequestIntervalUnit
    } = toRefs(chartEditStore.getRequestGlobalConfig);
    const loading = ref(false);
    const controlModel = ref(false);
    const showMatching = ref(false);
    let firstFocus = 0;
    let lastFilter = void 0;
    const pondData = computed(() => {
      const selectId = targetData.value.request.requestDataPondId;
      if (!selectId)
        return void 0;
      const data = requestDataPond.value.filter((item) => {
        return selectId === item.dataPondId;
      });
      return data[0];
    });
    const themeColor = computed(() => {
      return designStore.getAppTheme;
    });
    const controlModelHandle = () => {
      controlModel.value = true;
    };
    const sendHandle = async () => {
      var _a;
      if (!((_a = targetData.value) == null ? void 0 : _a.request)) {
        window.$message.warning("请选择一个公共接口！");
        return;
      }
      loading.value = true;
      try {
        const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig));
        loading.value = false;
        if (res) {
          if (!(res == null ? void 0 : res.data) && !targetData.value.filter) {
            window["$message"].warning("您的数据不符合默认格式，请配置过滤器！");
            showMatching.value = true;
            return;
          }
          targetData.value.option.dataset = newFunctionHandle(res == null ? void 0 : res.data, res, targetData.value.filter);
          showMatching.value = true;
          return;
        }
        window["$message"].warning("没有拿到返回值，请检查接口！");
      } catch (error) {
        console.error(error);
        loading.value = false;
        window["$message"].warning("数据异常，请检查参数！");
      }
    };
    watchEffect(() => {
      var _a;
      const filter = (_a = targetData.value) == null ? void 0 : _a.filter;
      if (lastFilter !== filter && firstFocus) {
        lastFilter = filter;
        sendHandle();
      }
      firstFocus++;
    });
    onBeforeUnmount(() => {
      lastFilter = null;
    });
    return (_ctx, _cache) => {
      const _component_n_icon = resolveComponent("n-icon");
      const _component_n_input = resolveComponent("n-input");
      const _component_n_button = resolveComponent("n-button");
      const _component_n_card = resolveComponent("n-card");
      const _component_n_tooltip = resolveComponent("n-tooltip");
      const _component_go_skeleton = resolveComponent("go-skeleton");
      return openBlock(), createElementBlock(Fragment, null, [
        createElementVNode("div", _hoisted_1, [
          createVNode(_component_n_card, { class: "n-card-shallow" }, {
            default: withCtx(() => [
              createVNode(unref(SettingItemBox), {
                name: "请求名称",
                alone: true
              }, {
                default: withCtx(() => {
                  var _a;
                  return [
                    createVNode(_component_n_input, {
                      size: "small",
                      placeholder: ((_a = pondData.value) == null ? void 0 : _a.dataPondName) || "暂无",
                      disabled: true
                    }, {
                      prefix: withCtx(() => [
                        createVNode(_component_n_icon, { component: unref(FishIcon) }, null, 8, ["component"])
                      ]),
                      _: 1
                    }, 8, ["placeholder"])
                  ];
                }),
                _: 1
              }),
              createVNode(unref(SettingItemBox), {
                name: "接口地址",
                alone: true
              }, {
                default: withCtx(() => {
                  var _a;
                  return [
                    createVNode(_component_n_input, {
                      size: "small",
                      placeholder: ((_a = pondData.value) == null ? void 0 : _a.dataPondRequestConfig.requestUrl) || "暂无",
                      disabled: true
                    }, {
                      prefix: withCtx(() => [
                        createVNode(_component_n_icon, { component: unref(FlashIcon) }, null, 8, ["component"])
                      ]),
                      _: 1
                    }, 8, ["placeholder"])
                  ];
                }),
                _: 1
              }),
              createElementVNode("div", {
                class: "edit-text",
                onClick: controlModelHandle
              }, [
                createElementVNode("div", _hoisted_2, [
                  createVNode(_component_n_button, {
                    type: "primary",
                    secondary: ""
                  }, {
                    default: withCtx(() => [
                      createTextVNode("编辑配置")
                    ]),
                    _: 1
                  })
                ])
              ])
            ]),
            _: 1
          })
        ]),
        createVNode(unref(SettingItemBox), { alone: true }, {
          name: withCtx(() => [
            createTextVNode(" 测试 "),
            createVNode(_component_n_tooltip, { trigger: "hover" }, {
              trigger: withCtx(() => [
                createVNode(_component_n_icon, {
                  size: "21",
                  depth: 3
                }, {
                  default: withCtx(() => [
                    createVNode(unref(HelpOutlineIcon))
                  ]),
                  _: 1
                })
              ]),
              default: withCtx(() => [
                createTextVNode(" 默认赋值给 dataset 字段 ")
              ]),
              _: 1
            })
          ]),
          default: withCtx(() => [
            createVNode(_component_n_button, {
              type: "primary",
              ghost: "",
              onClick: sendHandle
            }, {
              icon: withCtx(() => [
                createVNode(_component_n_icon, null, {
                  default: withCtx(() => [
                    createVNode(unref(FlashIcon))
                  ]),
                  _: 1
                })
              ]),
              default: withCtx(() => [
                createTextVNode(" 发送请求 ")
              ]),
              _: 1
            })
          ]),
          _: 1
        }),
        createVNode(unref(ChartDataMatchingAndShow), {
          show: showMatching.value && !loading.value,
          ajax: true
        }, null, 8, ["show"]),
        createVNode(_component_go_skeleton, {
          load: loading.value,
          repeat: 3
        }, null, 8, ["load"]),
        createVNode(unref(ChartDataPondControl), {
          modelShow: controlModel.value,
          "onUpdate:modelShow": _cache[0] || (_cache[0] = ($event) => controlModel.value = $event),
          onSendHandle: sendHandle
        }, null, 8, ["modelShow"])
      ], 64);
    };
  }
});
const index_vue_vue_type_style_index_0_scoped_19fefd48_lang = "";
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-19fefd48"]]);
export {
  index as default
};
