import CommandActionForm_default from "../../../../components/CommandPalette/CommandActionForm.vue.js";
import CommandActionInput_default from "../../../../components/CommandPalette/CommandActionInput.vue.js";
import { computed, createBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, unref, watch, withCtx } from "vue";
import { ScalarModal } from "@scalar/components";
//#region src/v2/features/app/components/CreateWorkspaceModal.vue?vue&type=script&setup=true&lang.ts
var CreateWorkspaceModal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "CreateWorkspaceModal",
	props: { state: {} },
	emits: ["create:workspace"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		/** Name input for the new workspace. Resets whenever the modal opens. */
		const name = ref("");
		/** Trimmed version of the name to avoid repeating .trim() in multiple places. */
		const trimmedName = computed(() => name.value.trim());
		/** Disable submit when the name is empty after trimming. */
		const isDisabled = computed(() => trimmedName.value.length === 0);
		/**
		* Ensure the form is reset whenever the modal opens.
		* Avoids stale state if the modal is reopened.
		*/
		watch(() => __props.state.open, (isOpen) => {
			if (isOpen) name.value = "";
		});
		/** Emits an event to create the workspace with the provided name */
		const handleSubmit = () => {
			if (!trimmedName.value) return;
			emit("create:workspace", { name: trimmedName.value });
			__props.state.hide();
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarModal), {
				bodyClass: "border-t-0 rounded-t-lg",
				size: "xs",
				state: __props.state
			}, {
				default: withCtx(() => [createVNode(CommandActionForm_default, {
					disabled: isDisabled.value,
					onSubmit: handleSubmit
				}, {
					submit: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("Add Workspace", -1)])]),
					default: withCtx(() => [createVNode(CommandActionInput_default, {
						modelValue: name.value,
						"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => name.value = $event),
						class: "-mt-[.5px] !p-0",
						placeholder: "Workspace name"
					}, null, 8, ["modelValue"])]),
					_: 1
				}, 8, ["disabled"])]),
				_: 1
			}, 8, ["state"]);
		};
	}
});
//#endregion
export { CreateWorkspaceModal_vue_vue_type_script_setup_true_lang_default as default };

//# sourceMappingURL=CreateWorkspaceModal.vue.script.js.map