// src/features/contracts-registry.ts
import {
  OperationSpecRegistry,
  EventRegistry
} from "@contractspec/lib.contracts-spec";
import {
  PresentationRegistry
} from "@contractspec/lib.contracts-spec/presentations";
import {
  DataViewRegistry
} from "@contractspec/lib.contracts-spec/data-views";
import { FormRegistry } from "@contractspec/lib.contracts-spec/forms";
import {
  serializeOperationSpec,
  serializeEventSpec,
  serializePresentationSpec,
  serializeDataViewSpec,
  serializeFormSpec
} from "@contractspec/lib.contracts-spec/serialization";
import {
  ContractReferenceDataView,
  ContractReferenceQuery,
  DocsGeneratedEvent,
  DocsGenerateCommand,
  DocsIndexDataView,
  DocsIndexQuery,
  DocsLayoutPresentation,
  DocsPublishedEvent,
  DocsPublishCommand,
  DocsReferencePagePresentation,
  DocsSearchForm,
  ExampleCatalogDataView
} from "@contractspec/lib.contracts-spec/docs";
var operationRegistry = null;
function createContractSpecOperationRegistry() {
  const registry = new OperationSpecRegistry;
  registry.register(DocsIndexQuery).register(ContractReferenceQuery).register(DocsGenerateCommand).register(DocsPublishCommand);
  return registry;
}
function getContractSpecOperationRegistry() {
  if (!operationRegistry) {
    operationRegistry = createContractSpecOperationRegistry();
  }
  return operationRegistry;
}
function resolveOperationSpec(key, version) {
  return getContractSpecOperationRegistry().get(key, version);
}
var eventRegistry = null;
function createContractSpecEventRegistry() {
  const registry = new EventRegistry;
  registry.register(DocsGeneratedEvent).register(DocsPublishedEvent);
  return registry;
}
function getContractSpecEventRegistry() {
  if (!eventRegistry) {
    eventRegistry = createContractSpecEventRegistry();
  }
  return eventRegistry;
}
function resolveEventSpec(key, version) {
  return getContractSpecEventRegistry().get(key, version);
}
var presentationRegistry = null;
function createContractSpecPresentationRegistry() {
  const registry = new PresentationRegistry;
  registry.register(DocsLayoutPresentation).register(DocsReferencePagePresentation);
  return registry;
}
function getContractSpecPresentationRegistry() {
  if (!presentationRegistry) {
    presentationRegistry = createContractSpecPresentationRegistry();
  }
  return presentationRegistry;
}
function resolvePresentationSpec(key, version) {
  return getContractSpecPresentationRegistry().get(key, version);
}
var dataViewRegistry = null;
function createContractSpecDataViewRegistry() {
  const registry = new DataViewRegistry;
  registry.register(DocsIndexDataView).register(ContractReferenceDataView).register(ExampleCatalogDataView);
  return registry;
}
function getContractSpecDataViewRegistry() {
  if (!dataViewRegistry) {
    dataViewRegistry = createContractSpecDataViewRegistry();
  }
  return dataViewRegistry;
}
function resolveDataViewSpec(key, version) {
  return getContractSpecDataViewRegistry().get(key, version);
}
var formRegistry = null;
function createContractSpecFormRegistry() {
  const registry = new FormRegistry;
  registry.register(DocsSearchForm);
  return registry;
}
function getContractSpecFormRegistry() {
  if (!formRegistry) {
    formRegistry = createContractSpecFormRegistry();
  }
  return formRegistry;
}
function resolveFormSpec(key, _version) {
  return getContractSpecFormRegistry().get(key);
}
function resolveSerializedOperationSpec(key, version) {
  const spec = resolveOperationSpec(key, version);
  return serializeOperationSpec(spec) ?? undefined;
}
function resolveSerializedEventSpec(key, version) {
  const spec = resolveEventSpec(key, version);
  return serializeEventSpec(spec) ?? undefined;
}
function resolveSerializedPresentationSpec(key, version) {
  const spec = resolvePresentationSpec(key, version);
  return serializePresentationSpec(spec) ?? undefined;
}
function resolveSerializedDataViewSpec(key, version) {
  const spec = resolveDataViewSpec(key, version);
  return serializeDataViewSpec(spec) ?? undefined;
}
function resolveSerializedFormSpec(key, version) {
  const spec = resolveFormSpec(key, version);
  return serializeFormSpec(spec) ?? undefined;
}
function resetContractSpecOperationRegistry() {
  operationRegistry = null;
}
function resetContractSpecEventRegistry() {
  eventRegistry = null;
}
function resetContractSpecPresentationRegistry() {
  presentationRegistry = null;
}
function resetContractSpecDataViewRegistry() {
  dataViewRegistry = null;
}
function resetContractSpecFormRegistry() {
  formRegistry = null;
}
function resetAllContractSpecRegistries() {
  resetContractSpecOperationRegistry();
  resetContractSpecEventRegistry();
  resetContractSpecPresentationRegistry();
  resetContractSpecDataViewRegistry();
  resetContractSpecFormRegistry();
}

// src/presentation/features/organisms/FeatureOperationsList.tsx
import { EntityCard } from "@contractspec/lib.design-system";
import { Zap } from "lucide-react";
import { jsx } from "react/jsx-runtime";
"use client";
function FeatureOperationsList({
  feature
}) {
  if (!feature.operations?.length)
    return null;
  return /* @__PURE__ */ jsx("div", {
    className: "grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",
    children: feature.operations.map((op) => {
      const spec = resolveSerializedOperationSpec(op.key, op.version);
      return /* @__PURE__ */ jsx(EntityCard, {
        cardTitle: op.key,
        cardSubtitle: `v${op.version}`,
        footer: spec?.meta.description,
        icon: /* @__PURE__ */ jsx(Zap, {
          className: "h-4 w-4"
        }),
        href: `/features/${feature.meta.key}/operations/${op.key}`
      }, op.key);
    })
  });
}

// src/presentation/features/templates/FeatureOperationsTemplate/FeatureOperationsTemplate.tsx
import {
  Breadcrumbs,
  PageHeaderResponsive
} from "@contractspec/lib.design-system";
import { VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
"use client";
function FeatureOperationsTemplate({
  feature,
  className
}) {
  return /* @__PURE__ */ jsxs(VStack, {
    gap: "lg",
    className: cn("mx-auto w-full max-w-5xl p-6", className),
    children: [
      /* @__PURE__ */ jsx2(PageHeaderResponsive, {
        title: "Operations",
        subtitle: `Operations defined in ${feature.meta.title ?? feature.meta.key}`,
        breadcrumb: /* @__PURE__ */ jsx2(Breadcrumbs, {
          items: [
            { label: "Features", href: "/features" },
            {
              label: feature.meta.title || feature.meta.key,
              href: `/features/${feature.meta.key}`
            },
            { label: "Operations" }
          ]
        })
      }),
      /* @__PURE__ */ jsx2(FeatureOperationsList, {
        feature
      })
    ]
  });
}
export {
  FeatureOperationsTemplate
};
