import { useNuxtApp } from "#imports";
const fallbackGraphqlState = {
  scalarType: [
    "Boolean",
    "Date",
    "DateTime",
    "Float",
    "ID",
    "Int",
    "JSON",
    "String",
    "Upload"
  ],
  graphqlType: {},
  graphqlInputType: {},
  graphqlOperation: {}
};
export function useGraphqlBridge() {
  const nuxtApp = useNuxtApp();
  const injected = nuxtApp.$appGraphql;
  return {
    ...fallbackGraphqlState,
    ...injected,
    scalarType: injected?.scalarType?.length ? [.../* @__PURE__ */ new Set([...fallbackGraphqlState.scalarType, ...injected.scalarType])] : fallbackGraphqlState.scalarType,
    graphqlType: injected?.graphqlType ?? fallbackGraphqlState.graphqlType,
    graphqlInputType: injected?.graphqlInputType ?? fallbackGraphqlState.graphqlInputType,
    graphqlOperation: injected?.graphqlOperation ?? fallbackGraphqlState.graphqlOperation
  };
}
export function registerGraphqlObject(input) {
  const nuxtApp = useNuxtApp();
  const bridge = nuxtApp.$appGraphql ?? fallbackGraphqlState;
  const scalarType = bridge.scalarType ?? fallbackGraphqlState.scalarType;
  const graphqlType = bridge.graphqlType ?? fallbackGraphqlState.graphqlType;
  const graphqlInputType = bridge.graphqlInputType ?? fallbackGraphqlState.graphqlInputType;
  const graphqlOperation = bridge.graphqlOperation ?? fallbackGraphqlState.graphqlOperation;
  if (input.scalarType?.length) {
    for (const scalar of input.scalarType) {
      if (!scalarType.includes(scalar)) scalarType.push(scalar);
    }
  }
  if (input.graphqlType) Object.assign(graphqlType, input.graphqlType);
  if (input.graphqlInputType) Object.assign(graphqlInputType, input.graphqlInputType);
  if (input.graphqlOperation) Object.assign(graphqlOperation, input.graphqlOperation);
}
