import { defineComponent, computed, createElementBlock, openBlock, Fragment, createCommentVNode, createBlock, unref, renderList } from "vue";
import { resolve } from "@scalar/workspace-store/resolve";
import { isTypeObject } from "./helpers/is-type-object.js";
import { sortPropertyNames } from "./helpers/sort-property-names.js";
import SchemaProperty from "./SchemaProperty.vue.js";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "SchemaObjectProperties",
  props: {
    schema: {},
    discriminator: {},
    compact: { type: Boolean },
    hideHeading: { type: Boolean },
    level: {},
    hideModelNames: { type: Boolean },
    breadcrumb: {},
    eventBus: {},
    options: {}
  },
  setup(__props) {
    const sortedProperties = computed(
      () => sortPropertyNames(__props.schema, __props.discriminator, __props.options)
    );
    const getAdditionalPropertiesName = (_additionalProperties) => {
      const additionalProperties = typeof _additionalProperties === "boolean" ? _additionalProperties : resolve.schema(_additionalProperties);
      if (typeof additionalProperties === "object" && typeof additionalProperties["x-additionalPropertiesName"] === "string" && additionalProperties["x-additionalPropertiesName"].trim().length > 0) {
        return `${additionalProperties["x-additionalPropertiesName"].trim()}`;
      }
      return "propertyName";
    };
    const getAdditionalPropertiesValue = (additionalProperties) => {
      if (additionalProperties === true || typeof additionalProperties === "object" && Object.keys(additionalProperties).length === 0 || typeof additionalProperties !== "object" || !("type" in additionalProperties)) {
        return {
          // @ts-expect-error - ask hans
          type: "anything",
          ...typeof additionalProperties === "object" ? additionalProperties : {}
        };
      }
      return additionalProperties;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock(Fragment, null, [
        unref(isTypeObject)(__props.schema) && __props.schema.properties ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(sortedProperties.value, (property) => {
          return openBlock(), createBlock(SchemaProperty, {
            key: property,
            breadcrumb: __props.breadcrumb,
            compact: __props.compact,
            discriminator: __props.discriminator,
            eventBus: __props.eventBus,
            hideHeading: __props.hideHeading,
            hideModelNames: __props.hideModelNames,
            level: __props.level,
            name: property,
            options: __props.options,
            required: __props.schema.required?.includes(property),
            schema: unref(resolve).schema(__props.schema.properties[property])
          }, null, 8, ["breadcrumb", "compact", "discriminator", "eventBus", "hideHeading", "hideModelNames", "level", "name", "options", "required", "schema"]);
        }), 128)) : createCommentVNode("", true),
        unref(isTypeObject)(__props.schema) && __props.schema.patternProperties ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(Object.entries(__props.schema.patternProperties), ([key, property]) => {
          return openBlock(), createBlock(SchemaProperty, {
            key,
            breadcrumb: __props.breadcrumb,
            compact: __props.compact,
            discriminator: __props.discriminator,
            eventBus: __props.eventBus,
            hideHeading: __props.hideHeading,
            hideModelNames: __props.hideModelNames,
            level: __props.level,
            name: key,
            options: __props.options,
            schema: unref(resolve).schema(property)
          }, null, 8, ["breadcrumb", "compact", "discriminator", "eventBus", "hideHeading", "hideModelNames", "level", "name", "options", "schema"]);
        }), 128)) : createCommentVNode("", true),
        unref(isTypeObject)(__props.schema) && __props.schema.additionalProperties ? (openBlock(), createBlock(SchemaProperty, {
          key: 2,
          breadcrumb: __props.breadcrumb,
          compact: __props.compact,
          discriminator: __props.discriminator,
          eventBus: __props.eventBus,
          hideHeading: __props.hideHeading,
          hideModelNames: __props.hideModelNames,
          level: __props.level,
          name: getAdditionalPropertiesName(__props.schema.additionalProperties),
          noncollapsible: "",
          options: __props.options,
          schema: getAdditionalPropertiesValue(__props.schema.additionalProperties),
          variant: "additionalProperties"
        }, null, 8, ["breadcrumb", "compact", "discriminator", "eventBus", "hideHeading", "hideModelNames", "level", "name", "options", "schema"])) : createCommentVNode("", true)
      ], 64);
    };
  }
});
export {
  _sfc_main as default
};
