"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
const utils = require("../../../../utils/utils.js");
require("../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
const router = require("../../../../utils/router.js");
require("../../../../store/modules/designStore/designStore.js");
require("../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
require("../../../../components/GoSkeleton/index.vue.js");
require("../../../../components/GoLoading/index.js");
const icon = require("../../../../plugins/icon.js");
require("../../../../settings/designSetting.js");
const chartEditStore = require("../../../../store/modules/chartEditStore/chartEditStore.js");
const chartEditStore_d = require("../../../../store/modules/chartEditStore/chartEditStore.d.js");
const runtimeDom_esmBundler = require("../../../../../node_modules/.pnpm/@vue_runtime-dom@3.3.4/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js");
const runtimeCore_esmBundler = require("../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");
const reactivity_esmBundler = require("../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js");
const shared_esmBundler = require("../../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.js");
const _hoisted_1 = { class: "title" };
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  setup(__props) {
    const { FishIcon } = icon.icon.ionicons5;
    const chartEditStore$1 = chartEditStore.useChartEditStore();
    const focus = reactivity_esmBundler.ref(false);
    const inputInstRef = reactivity_esmBundler.ref(null);
    const fetchProhectInfoById = () => {
      const id = router.fetchRouteParamsLocation();
      if (id.length) {
        return id[0];
      }
      return "";
    };
    const title = reactivity_esmBundler.ref(fetchProhectInfoById() || "");
    const comTitle = runtimeCore_esmBundler.computed(() => {
      title.value = title.value.replace(/\s/g, "");
      const newTitle = title.value.length ? title.value : "新项目";
      utils.setTitle(`工作空间-${newTitle}`);
      chartEditStore$1.setEditCanvasConfig(chartEditStore_d.EditCanvasConfigEnum.PROJECT_NAME, newTitle);
      return newTitle;
    });
    const handleFocus = () => {
      focus.value = true;
      runtimeCore_esmBundler.nextTick(() => {
        inputInstRef.value && inputInstRef.value.focus();
      });
    };
    const handleBlur = () => {
      focus.value = false;
    };
    return (_ctx, _cache) => {
      const _component_n_icon = runtimeCore_esmBundler.resolveComponent("n-icon");
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      const _component_n_text = runtimeCore_esmBundler.resolveComponent("n-text");
      const _component_n_input = runtimeCore_esmBundler.resolveComponent("n-input");
      const _component_n_space = runtimeCore_esmBundler.resolveComponent("n-space");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_space, null, {
        default: runtimeCore_esmBundler.withCtx(() => [
          runtimeCore_esmBundler.createVNode(_component_n_icon, {
            size: "20",
            depth: 3
          }, {
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(FishIcon))
            ]),
            _: 1
          }),
          runtimeCore_esmBundler.createVNode(_component_n_text, { onClick: handleFocus }, {
            default: runtimeCore_esmBundler.withCtx(() => [
              runtimeCore_esmBundler.createTextVNode(" 工作空间 - "),
              runtimeCore_esmBundler.withDirectives(runtimeCore_esmBundler.createVNode(_component_n_button, {
                secondary: "",
                size: "tiny"
              }, {
                default: runtimeCore_esmBundler.withCtx(() => [
                  runtimeCore_esmBundler.createElementVNode("span", _hoisted_1, shared_esmBundler.toDisplayString(comTitle.value), 1)
                ]),
                _: 1
              }, 512), [
                [runtimeDom_esmBundler.vShow, !focus.value]
              ])
            ]),
            _: 1
          }),
          runtimeCore_esmBundler.withDirectives(runtimeCore_esmBundler.createVNode(_component_n_input, {
            ref_key: "inputInstRef",
            ref: inputInstRef,
            size: "small",
            type: "text",
            maxlength: "16",
            "show-count": "",
            placeholder: "请输入项目名称",
            value: title.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => title.value = $event),
            valueModifiers: { trim: true },
            onKeyup: runtimeDom_esmBundler.withKeys(handleBlur, ["enter"]),
            onBlur: handleBlur
          }, null, 8, ["value", "onKeyup"]), [
            [runtimeDom_esmBundler.vShow, focus.value]
          ])
        ]),
        _: 1
      });
    };
  }
});
exports.default = _sfc_main;
