{"version":3,"sources":["jsdelivr-header.js","/npm/react-native-background-actions-shipzzer@3.0.9/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,SAAU,gBAAmB,sBAC7B,oBAAqB,uBAA0B,qCACjD,iBAAkB,gBAazB,MAAM,yBAAyB,aAC3B,WAAA,GACI,QAEA,KAAK,aAAe,EAEpB,KAAK,UAAY,OAEjB,KAAK,YAAa,EAElB,KAAK,gBACL,KAAK,eACT,CAKA,aAAA,GACI,mBAAmB,YAAY,cAAc,IAAM,KAAK,KAAK,eACjE,CAgBA,wBAAM,CAAmB,GACrB,GAAoB,YAAhB,SAAS,GAAb,CACA,IAAK,KAAK,YACN,MAAM,IAAI,MAAM,uEACpB,KAAK,gBAAkB,KAAK,kBAAkB,IAAK,KAAK,mBAAoB,UACtE,oBAAoB,mBAAmB,KAAK,gBAJb,CAKzC,CASA,SAAA,GACI,OAAO,KAAK,UAChB,CASA,WAAM,CAAM,EAAM,GACd,KAAK,eACL,KAAK,gBAAkB,KAAK,kBAAkB,GAC9C,MAAM,EAAY,KAAK,cAAc,EAAM,EAAQ,YAC/B,YAAhB,SAAS,IACT,YAAY,qBAAqB,KAAK,gBAAgB,UAAU,IAAM,UAChE,oBAAoB,MAAM,KAAK,iBACrC,KAAK,YAAa,UAEZ,oBAAoB,MAAM,KAAK,iBACrC,KAAK,YAAa,EAClB,IAER,CAQA,aAAA,CAAc,EAAM,GAChB,MAAM,EAAO,KACb,OAAO,gBACG,IAAI,SAAS,IACf,EAAK,UAAY,EACjB,EAAK,GAAY,MAAK,IAAM,EAAK,QAAO,GAC1C,CAEV,CAMA,iBAAA,CAAkB,GACd,MAAO,CACH,SAAU,EAAQ,SAAW,KAAK,aAClC,UAAW,EAAQ,UACnB,SAAU,EAAQ,SAClB,SAAU,IAAK,EAAQ,UACvB,MAAO,EAAQ,OAAS,UACxB,WAAY,EAAQ,WACpB,YAAa,EAAQ,YAE7B,CAOA,UAAM,GACF,KAAK,kBACC,oBAAoB,OAC1B,KAAK,YAAa,CACtB,EAGJ,MAAM,iBAAmB,IAAI,gCAEd","file":"/npm/react-native-background-actions-shipzzer@3.0.9/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-native-background-actions-shipzzer@3.0.9/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { Platform, AppRegistry } from 'react-native';\nimport { RNBackgroundActions, nativeEventEmitter } from './RNBackgroundActionsModule';\nimport EventEmitter from 'eventemitter3';\n\n/**\n * @typedef {{taskName: string,\n *            taskTitle: string,\n *            taskDesc: string,\n *            taskIcon: {name: string, type: string, package?: string},\n *            color?: string\n *            linkingURI?: string,\n *            progressBar?: {max: number, value: number, indeterminate?: boolean}\n *            }} BackgroundTaskOptions\n * @extends EventEmitter<'expiration',any>\n */\nclass BackgroundServer extends EventEmitter {\n    constructor() {\n        super();\n        /** @private */\n        this._runnedTasks = 0;\n        /** @private @type {(arg0?: any) => void} */\n        this._stopTask = () => {};\n        /** @private */\n        this._isRunning = false;\n        /** @private @type {BackgroundTaskOptions} */\n        this._currentOptions;\n        this._addListeners();\n    }\n\n    /**\n     * @private\n     */\n    _addListeners() {\n        nativeEventEmitter.addListener('expiration', () => this.emit('expiration'));\n    }\n\n    /**\n     * **ANDROID ONLY**\n     *\n     * Updates the task notification.\n     *\n     * *On iOS this method will return immediately*\n     *\n     * @param {{taskTitle?: string,\n     *          taskDesc?: string,\n     *          taskIcon?: {name: string, type: string, package?: string},\n     *          color?: string,\n     *          linkingURI?: string,\n     *          progressBar?: {max: number, value: number, indeterminate?: boolean}}} taskData\n     */\n    async updateNotification(taskData) {\n        if (Platform.OS !== 'android') return;\n        if (!this.isRunning())\n            throw new Error('A BackgroundAction must be running before updating the notification');\n        this._currentOptions = this._normalizeOptions({ ...this._currentOptions, ...taskData });\n        await RNBackgroundActions.updateNotification(this._currentOptions);\n    }\n\n    /**\n     * Returns if the current background task is running.\n     *\n     * It returns `true` if `start()` has been called and the task has not finished.\n     *\n     * It returns `false` if `stop()` has been called, **even if the task has not finished**.\n     */\n    isRunning() {\n        return this._isRunning;\n    }\n\n    /**\n     * @template T\n     *\n     * @param {(taskData?: T) => Promise<void>} task\n     * @param {BackgroundTaskOptions & {parameters?: T}} options\n     * @returns {Promise<void>}\n     */\n    async start(task, options) {\n        this._runnedTasks++;\n        this._currentOptions = this._normalizeOptions(options);\n        const finalTask = this._generateTask(task, options.parameters);\n        if (Platform.OS === 'android') {\n            AppRegistry.registerHeadlessTask(this._currentOptions.taskName, () => finalTask);\n            await RNBackgroundActions.start(this._currentOptions);\n            this._isRunning = true;\n        } else {\n            await RNBackgroundActions.start(this._currentOptions);\n            this._isRunning = true;\n            finalTask();\n        }\n    }\n\n    /**\n     * @private\n     * @template T\n     * @param {(taskData?: T) => Promise<void>} task\n     * @param {T} [parameters]\n     */\n    _generateTask(task, parameters) {\n        const self = this;\n        return async () => {\n            await new Promise((resolve) => {\n                self._stopTask = resolve;\n                task(parameters).then(() => self.stop());\n            });\n        };\n    }\n\n    /**\n     * @private\n     * @param {BackgroundTaskOptions} options\n     */\n    _normalizeOptions(options) {\n        return {\n            taskName: options.taskName + this._runnedTasks,\n            taskTitle: options.taskTitle,\n            taskDesc: options.taskDesc,\n            taskIcon: { ...options.taskIcon },\n            color: options.color || '#ffffff',\n            linkingURI: options.linkingURI,\n            progressBar: options.progressBar,\n        };\n    }\n\n    /**\n     * Stops the background task.\n     *\n     * @returns {Promise<void>}\n     */\n    async stop() {\n        this._stopTask();\n        await RNBackgroundActions.stop();\n        this._isRunning = false;\n    }\n}\n\nconst backgroundServer = new BackgroundServer();\n\nexport default backgroundServer;\n"]}