{"ast":null,"code":"import invariant from 'invariant';\nimport NativeEventEmitter from \"react-native-web/dist/exports/NativeEventEmitter\";\nimport Platform from \"react-native-web/dist/exports/Platform\";\nconst nativeEmitterSubscriptionKey = '@@nativeEmitterSubscription@@';\nexport class LegacyEventEmitter {\n  _listenerCount = 0;\n  constructor(nativeModule) {\n    if (nativeModule.__expo_module_name__) {\n      return nativeModule;\n    }\n    this._nativeModule = nativeModule;\n    this._eventEmitter = new NativeEventEmitter(nativeModule);\n  }\n  addListener(eventName, listener) {\n    if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.startObserving) {\n      this._nativeModule.startObserving();\n    }\n    this._listenerCount++;\n    const nativeEmitterSubscription = this._eventEmitter.addListener(eventName, listener);\n    const subscription = {\n      [nativeEmitterSubscriptionKey]: nativeEmitterSubscription,\n      remove: () => {\n        this.removeSubscription(subscription);\n      }\n    };\n    return subscription;\n  }\n  removeAllListeners(eventName) {\n    const removedListenerCount = this._eventEmitter.listenerCount ? this._eventEmitter.listenerCount(eventName) : this._eventEmitter.listeners(eventName).length;\n    this._eventEmitter.removeAllListeners(eventName);\n    this._listenerCount -= removedListenerCount;\n    invariant(this._listenerCount >= 0, `EventEmitter must have a non-negative number of listeners`);\n    if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n      this._nativeModule.stopObserving();\n    }\n  }\n  removeSubscription(subscription) {\n    const state = subscription;\n    const nativeEmitterSubscription = state[nativeEmitterSubscriptionKey];\n    if (!nativeEmitterSubscription) {\n      return;\n    }\n    if ('remove' in nativeEmitterSubscription) {\n      nativeEmitterSubscription.remove?.();\n    }\n    this._listenerCount--;\n    delete state[nativeEmitterSubscriptionKey];\n    subscription.remove = () => {};\n    if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n      this._nativeModule.stopObserving();\n    }\n  }\n  emit(eventName, ...params) {\n    this._eventEmitter.emit(eventName, ...params);\n  }\n}","map":{"version":3,"names":["invariant","NativeEventEmitter","Platform","nativeEmitterSubscriptionKey","LegacyEventEmitter","_listenerCount","constructor","nativeModule","__expo_module_name__","_nativeModule","_eventEmitter","addListener","eventName","listener","OS","startObserving","nativeEmitterSubscription","subscription","remove","removeSubscription","removeAllListeners","removedListenerCount","listenerCount","listeners","length","stopObserving","state","emit","params"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/expo-modules-core/src/LegacyEventEmitter.ts"],"sourcesContent":["import invariant from 'invariant';\nimport { NativeEventEmitter, Platform } from 'react-native';\n\nimport { EventSubscription } from './EventEmitter';\n\nconst nativeEmitterSubscriptionKey = '@@nativeEmitterSubscription@@' as const;\n\ntype SubscriptionState = {\n  // NOTE(@kitten): Since this is legacy/deprecated, we don't need to be exact about types here\n  [Key in typeof nativeEmitterSubscriptionKey]?: {\n    remove?(): void;\n  };\n} & EventSubscription;\n\ntype NativeModule = {\n  __expo_module_name__?: string;\n  startObserving?: () => void;\n  stopObserving?: () => void;\n\n  // Erase these types as they would conflict with the new NativeModule type.\n  // This EventEmitter is deprecated anyway.\n  addListener?: any;\n  removeListeners?: any;\n};\n\n/**\n * @deprecated Deprecated in favor of `EventEmitter`.\n */\nexport class LegacyEventEmitter {\n  _listenerCount = 0;\n\n  // @ts-expect-error\n  _nativeModule: NativeModule;\n\n  // @ts-expect-error\n  _eventEmitter: NativeEventEmitter;\n\n  constructor(nativeModule: NativeModule) {\n    // If the native module is a new module, just return it back as it's already an event emitter.\n    // This is for backwards compatibility until we stop using this legacy class in other packages.\n    if (nativeModule.__expo_module_name__) {\n      // @ts-expect-error\n      return nativeModule;\n    }\n    this._nativeModule = nativeModule;\n    this._eventEmitter = new NativeEventEmitter(nativeModule as any);\n  }\n\n  addListener<T>(eventName: string, listener: (event: T) => void): EventSubscription {\n    if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.startObserving) {\n      this._nativeModule.startObserving();\n    }\n\n    this._listenerCount++;\n    const nativeEmitterSubscription = this._eventEmitter.addListener(eventName, listener);\n    const subscription: SubscriptionState = {\n      [nativeEmitterSubscriptionKey]: nativeEmitterSubscription,\n      remove: () => {\n        this.removeSubscription(subscription);\n      },\n    };\n    return subscription;\n  }\n\n  removeAllListeners(eventName: string): void {\n    // @ts-ignore: the EventEmitter interface has been changed in react-native@0.64.0\n    const removedListenerCount = this._eventEmitter.listenerCount\n      ? // @ts-ignore: this is available since 0.64\n        this._eventEmitter.listenerCount(eventName)\n      : // @ts-ignore: this is available in older versions\n        this._eventEmitter.listeners(eventName).length;\n    this._eventEmitter.removeAllListeners(eventName);\n    this._listenerCount -= removedListenerCount;\n    invariant(\n      this._listenerCount >= 0,\n      `EventEmitter must have a non-negative number of listeners`\n    );\n\n    if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n      this._nativeModule.stopObserving();\n    }\n  }\n\n  removeSubscription(subscription: EventSubscription): void {\n    const state = subscription as SubscriptionState;\n    const nativeEmitterSubscription = state[nativeEmitterSubscriptionKey];\n    if (!nativeEmitterSubscription) {\n      return;\n    }\n\n    if ('remove' in nativeEmitterSubscription) {\n      nativeEmitterSubscription.remove?.();\n    }\n    this._listenerCount--;\n\n    // Ensure that the emitter's internal state remains correct even if `removeSubscription` is\n    // called again with the same subscription\n    delete state[nativeEmitterSubscriptionKey];\n\n    // Release closed-over references to the emitter\n    subscription.remove = () => {};\n\n    if (!this._listenerCount && Platform.OS !== 'ios' && this._nativeModule.stopObserving) {\n      this._nativeModule.stopObserving();\n    }\n  }\n\n  emit(eventName: string, ...params: any[]): void {\n    this._eventEmitter.emit(eventName, ...params);\n  }\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAAC,OAAAC,kBAAA;AAAA,OAAAC,QAAA;AAKlC,MAAMC,4BAA4B,GAAG,+BAAwC;AAuB7E,OAAO,MAAMC,kBAAkB,CAAC;EAC9BC,cAAc,GAAG,CAAC;EAQlBC,WAAWA,CAACC,YAA0B,EAAE;IAGtC,IAAIA,YAAY,CAACC,oBA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EAN,kBAAkBA,CAACF,YAA+B,EAAQ;IACxD,MAAMS,KAAK,GAAGT,YAAiC;IAC/C,MAAMD,yBAAyB,GAAGU,KAAK,CAACvB,4BAA4B,CAAC;IACrE,IAAI,CAACa,yBAAyB,EAAE;MAC9B;IACF;IAEA,IAAI,QAAQ,IAAIA,yBAAyB,EAAE;MACzCA,yBAAyB,CAACE,MAAM,GAAG,CAAC;IACtC;IACA,IAAI,CAACb,cAAc,EAAE;IAIrB,OAAOqB,KAAK,CAACvB,4BAA4B,CAAC;IAG1Cc,YAAY,CAACC,MAAM,GAAG,MAAM,CAAC,CAAC;IAE9B,IAAI,CAAC,IAAI,CAACb,cAAc,IAAIH,QAAQ,CAACY,EAAE,KAAK,KAAK,IAAI,IAAI,CAACL,aAAa,CAACgB,aAAa,EAAE;MACrF,IAAI,CAAChB,aAAa,CAACgB,aAAa,CAAC,CAAC;IACpC;EACF;EAEAE,IAAIA,CAACf,SAAiB,EAAE,GAAGgB,MAAa,EAAQ;IAC9C,IAAI,CAAClB,aAAa,CAACiB,IAAI,CAACf,SAAS,EAAE,GAAGgB,MAAM,CAAC;EAC/C;AACF","ignoreList":[]},"metadata":{"hasCjsExports":false},"sourceType":"module","externalDependencies":[]}