import { DEBUG } from '@glimmer/env' ; export { tracked } from '@glimmer/tracking' ; import type { IWaitForPromise } from './-private/types' ; import type { getOwner as IGetOwner , setOwner as ISetOwner } from '@glimmer/owner' ; import type { setHelperManager as ISetHelperManager , helperCapabilities as IHelperCapabilities } from '@glimmer/manager' ; import type { isDestroying as IIsDestroying , isDestroyed as IIsDestroyed , destroy as IDestroy , registerDestructor as IRegisterDestructor , associateDestroyableChild as IAssociateDestroyableChild } from '@glimmer/destroyable' ; import type { invokeHelper as IInvokeHelper } from '@glimmer/runtime' ; import type { getValue as IGetValue , createCache as ICreateCache } from '@glimmer/validator' ; interface EnviromentContext { owner ? : object ; setOwner : typeof ISetOwner ; getOwner : typeof IGetOwner ; getValue : typeof IGetValue ; createCache : typeof ICreateCache ; invokeHelper : typeof IInvokeHelper ; isDestroying : typeof IIsDestroying ; isDestroyed : typeof IIsDestroyed ; destroy : typeof IDestroy ; registerDestructor : typeof IRegisterDestructor ; associateDestroyableChild : typeof IAssociateDestroyableChild ; waitForPromise : typeof IWaitForPromise ; setHelperManager : typeof ISetHelperManager ; helperCapabilities : typeof IHelperCapabilities ; } export let owner ; let _getOwner ; export let setOwner ; export let createCache ; export let getValue ; export let invokeHelper ; export let isDestroyed ; export let isDestroying ; export let destroy ; export let registerDestructor ; export let associateDestroyableChild ; export let waitForPromise ; export let setHelperManager ; export let helperCapabilities ; let environmentContextWasSet = false ; export function getOwner < O extends object > ( obj ) { if ( typeof owner !== 'undefined' && obj instanceof ( owner as any ) ) { return obj as O ; } return _getOwner ( obj ) ; } export function setEnviromentContext ( env ) { if ( DEBUG ) { if ( environmentContextWasSet ) { throw new Error ( 'Attempted to set the glimmer-apollo environment context twice. This should only be set once.' ) ; } environmentContextWasSet = true ; } owner = env . owner ; setOwner = env . setOwner ; _getOwner = env . getOwner ; createCache = env . createCache ; getValue = env . getValue ; invokeHelper = env . invokeHelper ; waitForPromise = env . waitForPromise ; setHelperManager = env . setHelperManager ; helperCapabilities = env . helperCapabilities ; isDestroying = env . isDestroying ; isDestroyed = env . isDestroyed ; destroy = env . destroy ; registerDestructor = env . registerDestructor ; associateDestroyableChild = env . associateDestroyableChild ; }