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,KAAK,KAAK;QACrB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE;QAC/C,wBAAwB,CACzB,CAAC;AACJ,CAAC;AAED,OAAO,EAAsB,gBAAgB,EAAwB,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\nimport { PermissionResponse, PermissionStatus, PermissionExpiration } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoTrackingTransparency from './ExpoTrackingTransparency';\n\nconst androidAndWebPermissionsResponse: PermissionResponse = {\n  granted: true,\n  expires: 'never',\n  canAskAgain: true,\n  status: PermissionStatus.GRANTED,\n};\n\n/**\n * Requests the user to authorize or deny access to app-related data that can be used for tracking\n * the user or the device. Examples of data used for tracking include email address, device ID,\n * advertising ID, etc. On iOS 14.5 and above, if the user denies this permission, any attempt to\n * collect the IDFA will return a string of 0s.\n *\n * The system remembers the user’s choice and doesn’t prompt again unless a user uninstalls and then\n * reinstalls the app on the device.\n *\n * On Android, web, and iOS 13 and below, this method always returns that the permission was\n * granted.\n * @example\n * ```typescript\n * const { granted } = await requestTrackingPermissionsAsync();\n *\n * if (granted) {\n *   // Your app is authorized to track the user or their device\n * }\n * ```\n */\nexport async function requestTrackingPermissionsAsync(): Promise<PermissionResponse> {\n  if (Platform.OS !== 'ios') {\n    return Promise.resolve(androidAndWebPermissionsResponse);\n  }\n\n  if (!ExpoTrackingTransparency.requestPermissionsAsync) {\n    throw new UnavailabilityError('TrackingTransparency', 'requestPermissionsAsync');\n  }\n  return await ExpoTrackingTransparency.requestPermissionsAsync();\n}\n\n/**\n * Checks whether or not the user has authorized the app to access app-related data that can be used\n * for tracking the user or the device. See `requestPermissionsAsync` for more details.\n *\n * On Android, web, and iOS 13 and below, this method always returns that the permission was\n * granted.\n *\n * @example\n * ```typescript\n * const { granted } = await getTrackingPermissionsAsync();\n *\n * if (granted) {\n *   // Your app is authorized to track the user or their device\n * }\n * ```\n */\nexport async function getTrackingPermissionsAsync(): Promise<PermissionResponse> {\n  if (Platform.OS !== 'ios') {\n    return Promise.resolve(androidAndWebPermissionsResponse);\n  }\n\n  if (!ExpoTrackingTransparency.getPermissionsAsync) {\n    throw new UnavailabilityError('TrackingTransparency', 'getPermissionsAsync');\n  }\n  return await ExpoTrackingTransparency.getPermissionsAsync();\n}\n\n/**\n * Returns whether the TrackingTransparency API is available on the current device.\n *\n * @returns Currently this is `true` on iOS 14 and above only. On devices where the\n * Tracking Transparency API is unavailable, the get and request permissions methods will always\n * resolve to `granted`.\n */\nexport function isAvailable(): boolean {\n  return (\n    Platform.OS === 'ios' &&\n    parseInt(Platform.Version.toString(), 10) >= 14 &&\n    ExpoTrackingTransparency\n  );\n}\n\nexport { PermissionResponse, PermissionStatus, PermissionExpiration };\n"]}