import { computed, createBlock, createElementBlock, defineComponent, openBlock, unref } from "vue";
import { ScalarCodeBlock, ScalarVirtualText } from "@scalar/components";
import { getExampleFromSchema } from "@scalar/workspace-store/request-example";
import { getResolvedRefDeep } from "@scalar/api-client/blocks/operation-code-sample";
import { prettyPrintJson } from "@scalar/helpers/json/pretty-print-json";
//#region src/features/example-responses/ExampleResponse.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = {
	key: 2,
	class: "empty-state"
};
var VIRTUALIZATION_THRESHOLD = 2e4;
var ExampleResponse_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "ExampleResponse",
	props: {
		response: {},
		example: {}
	},
	setup(__props) {
		/** Get content from the appropriate source */
		const getContent = () => {
			if (__props.example !== void 0) return getResolvedRefDeep(__props.example)?.value ?? "";
			if (__props.response?.schema) return getExampleFromSchema(getResolvedRefDeep(__props.response.schema), {
				emptyString: "string",
				mode: "read"
			});
		};
		/** Pre-pretty printed content string, avoids multiple pretty prints*/
		const prettyPrintedContent = computed(() => {
			const content = getContent();
			if (content === void 0) return;
			return prettyPrintJson(content);
		});
		const shouldVirtualize = computed(() => {
			if (prettyPrintedContent.value === void 0) return false;
			return prettyPrintedContent.value.length > VIRTUALIZATION_THRESHOLD;
		});
		return (_ctx, _cache) => {
			return prettyPrintedContent.value !== void 0 && !shouldVirtualize.value ? (openBlock(), createBlock(unref(ScalarCodeBlock), {
				key: 0,
				class: "bg-b-2",
				lang: "json",
				prettyPrintedContent: prettyPrintedContent.value
			}, null, 8, ["prettyPrintedContent"])) : prettyPrintedContent.value !== void 0 && shouldVirtualize.value ? (openBlock(), createBlock(unref(ScalarVirtualText), {
				key: 1,
				containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
				contentClass: "language-plaintext whitespace-pre font-code text-base p-2",
				lineHeight: 20,
				text: prettyPrintedContent.value
			}, null, 8, ["text"])) : (openBlock(), createElementBlock("div", _hoisted_1, " No Body "));
		};
	}
});
//#endregion
export { ExampleResponse_vue_vue_type_script_setup_true_lang_default as default };

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