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G,EAAiB,IAAY,I,EAUnCG,CAAQR,GAITA,EAAKpG,eAAe,OACrB6G,EAAUT,EAAKU,G,EAIbD,EAAaC,IACjB,IAAI,MAAMV,KAAQU,EAChBX,EAAUC,E,EAId,IACE,IAAI,MAAMW,KAASd,EAAOe,OACxB,GAAID,EAAME,OAEV,IAAI,MAAMC,KAASH,EAAME,OACnBC,EAAMJ,GAKVD,EAAUK,EAAMJ,IAJdX,EAAUe,E,CAOhB,MAAMrF,GACNkC,QAAQoD,KAAK,0BAA2BtF,EAAKoE,EAAQb,E,CAEzD,EC2DUgC,CAAkBtB,EAAkBV,GACpCrC,EAAOgD,KAAKsB,UAAUvB,E,CAYxB,MAAMpE,EAAQqB,EAAKrB,MAAM,oBACnB4F,IAAa5F,aAAK,EAALA,EAAQ,KAvKf,GA2KZ2D,EAAKvC,KAAKC,EAAMuE,E,CAChB,MAAMzF,GACNkC,QAAQ7D,MAAM,4BAA6B6C,GAC3Ca,EAAM,CAAC,QAASlB,EAAOb,G,IAG7B,EACAgD,QAAS,SAASnC,GAChB,MAAM2C,EAAOJ,EAAMvC,GACf2C,IAIJA,EAAKR,iBACEI,EAAMvC,GACf,EACA6E,YAAa,SAAS7E,EAAeuB,EAAiBC,GAEpDe,EAAMvC,GAAOsB,OAAOC,EAASC,EAC/B,GAGF,SAASN,EAAM4D,EAAaC,GAC1BC,YAAY,CAACC,oBAAqBH,EAAKI,QAASC,qBAAsBL,GAAO,EAAwBC,OAAW7F,EAClH,CAEAkG,UAAY,SAASlI,GAEnBsF,EAAmBtF,EAAEyE,KAAK0D,aAAaC,MAAM9C,EAAoBtF,EAAEyE,KAAKwD,qBAC1E,C","sources":["webpack://tweb/webpack/runtime/compat","webpack://tweb/./src/environment/ctx.ts","webpack://tweb/./src/environment/userAgent.ts","webpack://tweb/./src/environment/canUseTransferables.ts","webpack://tweb/./src/environment/imageBitmapSupport.ts","webpack://tweb/./src/lib/rlottie/applyReplacements.ts","webpack://tweb/./src/lib/rlottie/rlottie.worker.ts","webpack://tweb/./src/helpers/blob/readBlobAsText.ts","webpack://tweb/./src/helpers/blob/readBlobAs.ts"],"sourcesContent":["(() => {\n if (typeof __webpack_require__ !== 'undefined') {\n var oldGetScript = __webpack_require__.u;\n var oldLoadScript = __webpack_require__.e;\n var queryMap = {};\n var countMap = {};\n var getRetryDelay = function () {\n return 3000;\n };\n __webpack_require__.u = function (chunkId) {\n var result = oldGetScript(chunkId);\n return (\n result +\n (queryMap.hasOwnProperty(chunkId) ? '?' + queryMap[chunkId] : '')\n );\n };\n __webpack_require__.e = function (chunkId) {\n var result = oldLoadScript(chunkId);\n return result.catch(function (error) {\n var retries = countMap.hasOwnProperty(chunkId)\n ? countMap[chunkId]\n : 999999;\n if (retries < 1) {\n var realSrc = oldGetScript(chunkId);\n error.message =\n 'Loading chunk ' +\n chunkId +\n ' failed after 999999 retries.\\n(' +\n realSrc +\n ')';\n error.request = realSrc;\n throw error;\n }\n return new Promise(function (resolve) {\n var retryAttempt = 999999 - retries + 1;\n setTimeout(function () {\n var retryAttemptString = '&retry-attempt=' + retryAttempt;\n var cacheBust = (function () {\n return Date.now();\n })();\n +retryAttemptString;\n queryMap[chunkId] = cacheBust;\n countMap[chunkId] = retries - 1;\n resolve(__webpack_require__.e(chunkId));\n }, getRetryDelay(retryAttempt));\n });\n });\n };\n }\n})();\n","const ctx = typeof(window) !== 'undefined' ? window : self;\n\nexport default ctx;\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport ctx from './ctx';\n\nexport const USER_AGENT = navigator ? navigator.userAgent : null;\nexport const IS_APPLE = navigator.userAgent.search(/OS X|iPhone|iPad|iOS/i) !== -1;\nexport const IS_ANDROID = navigator.userAgent.toLowerCase().indexOf('android') !== -1;\nexport const IS_CHROMIUM = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);\n\n// https://stackoverflow.com/a/58065241\nexport const IS_APPLE_MOBILE = (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !(ctx as any).MSStream;\n\nexport const IS_SAFARI = !!('safari' in ctx) || !!(USER_AGENT && (/\\b(iPad|iPhone|iPod)\\b/.test(USER_AGENT) || (!!USER_AGENT.match('Safari') && !USER_AGENT.match('Chrome'))))/* || true */;\nexport const IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\nexport const IS_MOBILE_SAFARI = IS_SAFARI && IS_APPLE_MOBILE;\n\nexport const IS_MOBILE = (navigator.maxTouchPoints === undefined || navigator.maxTouchPoints > 0) && navigator.userAgent.search(/iOS|iPhone OS|Android|BlackBerry|BB10|Series ?[64]0|J2ME|MIDP|opera mini|opera mobi|mobi.+Gecko|Windows Phone/i) != -1;\n","import {IS_SAFARI} from './userAgent';\n\n/*\n * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to\n * transfer data between WebWorkers and the main thread.\n * https://github.com/mapbox/mapbox-gl-js/issues/8771\n *\n * This should be removed once the underlying Safari issue is fixed.\n */\n\nlet CAN_USE_TRANSFERABLES: boolean;\nif(!IS_SAFARI) CAN_USE_TRANSFERABLES = true;\nelse {\n try {\n const match = navigator.userAgent.match(/Version\\/(.+?) /);\n CAN_USE_TRANSFERABLES = +match[1] >= 14;\n } catch(err) {\n CAN_USE_TRANSFERABLES = false;\n }\n}\n\nexport default CAN_USE_TRANSFERABLES;\n","const IS_IMAGE_BITMAP_SUPPORTED = typeof(ImageBitmap) !== 'undefined';\n\nexport default IS_IMAGE_BITMAP_SUPPORTED;\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\n// https://github.com/telegramdesktop/tdesktop/blob/97d8ee75d51874fcb74a9bfadc79f835c82be54a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp#L46\nconst COLORREPLACEMENTS = [\n [\n [0xf77e41, 0xcb7b55],\n [0xffb139, 0xf6b689],\n [0xffd140, 0xffcda7],\n [0xffdf79, 0xffdfc5]\n ],\n\n [\n [0xf77e41, 0xa45a38],\n [0xffb139, 0xdf986b],\n [0xffd140, 0xedb183],\n [0xffdf79, 0xf4c3a0]\n ],\n\n [\n [0xf77e41, 0x703a17],\n [0xffb139, 0xab673d],\n [0xffd140, 0xc37f4e],\n [0xffdf79, 0xd89667]\n ],\n\n [\n [0xf77e41, 0x4a2409],\n [0xffb139, 0x7d3e0e],\n [0xffd140, 0x965529],\n [0xffdf79, 0xa96337]\n ],\n\n [\n [0xf77e41, 0x200f0a],\n [0xffb139, 0x412924],\n [0xffd140, 0x593d37],\n [0xffdf79, 0x63453f]\n ]\n];\n\nconst convert = (value: number) => {\n return Math.round(Math.min(Math.max(value, 0), 1) * 255);\n};\n\ntype LottieShape = {\n c: {\n k: number[]\n },\n ty: 'st' | 'fl',\n it?: LottieShape[]\n};\n\nexport default function applyReplacements(object: {\n layers: Array<{shapes: LottieShape[]}>\n}, toneIndex: number) {\n const replacements = COLORREPLACEMENTS[Math.max(toneIndex - 1, 0)];\n\n const applyTo = (smth: LottieShape) => {\n const k = smth.c.k;\n const color = convert(k[2]) | (convert(k[1]) << 8) | (convert(k[0]) << 16);\n\n const foundReplacement = replacements.find((p) => p[0] === color);\n if(foundReplacement) {\n k[0] = ((foundReplacement[1] >> 16) & 255) / 255;\n k[1] = ((foundReplacement[1] >> 8) & 255) / 255;\n k[2] = (foundReplacement[1] & 255) / 255;\n }\n\n // console.log('foundReplacement!', foundReplacement, color.toString(16), k);\n };\n\n const checkSmth = (smth: LottieShape) => {\n switch(smth.ty) {\n case 'st':\n case 'fl':\n applyTo(smth);\n break;\n }\n\n if(smth.hasOwnProperty('it')) {\n iterateIt(smth.it);\n }\n };\n\n const iterateIt = (it: LottieShape['it']) => {\n for(const smth of it) {\n checkSmth(smth);\n }\n };\n\n try {\n for(const layer of object.layers) {\n if(!layer.shapes) continue;\n\n for(const shape of layer.shapes) {\n if(!shape.it) {\n checkSmth(shape);\n continue;\n }\n\n iterateIt(shape.it);\n }\n }\n } catch(err) {\n console.warn('cant apply replacements', err, object, toneIndex);\n }\n}\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport CAN_USE_TRANSFERABLES from '../../environment/canUseTransferables';\nimport IS_IMAGE_BITMAP_SUPPORTED from '../../environment/imageBitmapSupport';\nimport readBlobAsText from '../../helpers/blob/readBlobAsText';\nimport applyReplacements from './applyReplacements';\n\nimportScripts('rlottie-wasm.js');\n// import Module, { allocate, intArrayFromString } from './rlottie-wasm';\n\nconst _Module = (self as any).Module as any;\n\nconst DEFAULT_FPS = 60;\n\ntype LottieHandlePointer = number;\n\n// throw new Error('test');\n\nexport class RLottieItem {\n private stringOnWasmHeap: number;\n private handle: LottieHandlePointer;\n private frameCount: number;\n private fps: number;\n\n private dead: boolean;\n // private context: OffscreenCanvasRenderingContext2D;\n\n private imageData: ImageData;\n\n constructor(\n private reqId: number,\n private width: number,\n private height: number,\n private raw?: boolean/* ,\n private canvas: OffscreenCanvas */\n ) {\n }\n\n public init(json: string, fps: number) {\n if(this.dead) {\n return;\n }\n\n this.fps = Math.max(1, Math.min(60, fps || DEFAULT_FPS));\n\n // this.context = canvas.getContext('2d');\n /* let frame = 0;\n setInterval(() => {\n if(frame >= this.frameCount) frame = 0;\n let _frame = frame++;\n this.render(_frame, null);\n }, 1000 / this.fps); */\n\n try {\n this.handle = worker.Api.init();\n\n // @ts-ignore\n this.stringOnWasmHeap = allocate(intArrayFromString(json), 'i8', 0);\n\n this.frameCount = worker.Api.loadFromData(this.handle, this.stringOnWasmHeap);\n\n worker.Api.resize(this.handle, this.width, this.height);\n\n reply(['loaded', this.reqId, this.frameCount, this.fps]);\n\n if(!this.raw && IS_IMAGE_BITMAP_SUPPORTED) {\n this.imageData = new ImageData(this.width, this.height);\n }\n } catch(e) {\n console.error('init RLottieItem error:', e);\n reply(['error', this.reqId, e]);\n }\n }\n\n public render(frameNo: number, clamped?: Uint8ClampedArray) {\n if(this.dead || this.handle === undefined) return;\n // return;\n\n if(this.frameCount < frameNo || frameNo < 0) {\n return;\n }\n\n try {\n worker.Api.render(this.handle, frameNo);\n\n const bufferPointer = worker.Api.buffer(this.handle);\n\n const data = _Module.HEAPU8.subarray(bufferPointer, bufferPointer + (this.width * this.height * 4));\n\n if(this.imageData) {\n this.imageData.data.set(data);\n createImageBitmap(this.imageData).then((imageBitmap) => {\n reply(['frame', this.reqId, frameNo, imageBitmap], [imageBitmap]);\n });\n } else {\n if(!clamped) {\n clamped = new Uint8ClampedArray(data);\n } else {\n clamped.set(data);\n }\n\n // this.context.putImageData(new ImageData(clamped, this.width, this.height), 0, 0);\n\n reply(['frame', this.reqId, frameNo, clamped], [clamped.buffer]);\n }\n } catch(e) {\n console.error('Render error:', e);\n this.dead = true;\n reply(['error', this.reqId, e]);\n }\n }\n\n public destroy() {\n this.dead = true;\n\n if(this.handle !== undefined) {\n worker.Api.destroy(this.handle);\n }\n }\n}\n\nclass RLottieWorker {\n public Api: {\n init: () => LottieHandlePointer,\n destroy: (handle: LottieHandlePointer) => void,\n resize: (handle: LottieHandlePointer, width: number, height: number) => void,\n buffer: (handle: LottieHandlePointer) => number,\n render: (handle: LottieHandlePointer, frameNo: number) => void,\n loadFromData: (handle: LottieHandlePointer, bufferPointer: number) => number\n } = {} as any;\n\n public initApi() {\n this.Api = {\n init: _Module.cwrap('lottie_init', '', []),\n destroy: _Module.cwrap('lottie_destroy', '', ['number']),\n resize: _Module.cwrap('lottie_resize', '', ['number', 'number', 'number']),\n buffer: _Module.cwrap('lottie_buffer', 'number', ['number']),\n render: _Module.cwrap('lottie_render', '', ['number', 'number']),\n loadFromData: _Module.cwrap('lottie_load_from_data', 'number', ['number', 'number'])\n };\n }\n\n public init() {\n this.initApi();\n reply(['ready']);\n }\n}\n\nconst worker = new RLottieWorker();\n\n_Module.onRuntimeInitialized = function() {\n worker.init();\n};\n\nconst items: {[reqId: string]: RLottieItem} = {};\nconst queryableFunctions = {\n loadFromData: function(reqId: number, blob: Blob, width: number, height: number, toneIndex: number, raw: boolean/* , canvas: OffscreenCanvas */) {\n const item = items[reqId] = new RLottieItem(reqId, width, height, raw/* , canvas */);\n readBlobAsText(blob).then((json) => {\n try {\n if(typeof(toneIndex) === 'number' && toneIndex >= 1 && toneIndex <= 5) {\n /* params.animationData = copy(params.animationData);\n this.applyReplacements(params.animationData, toneIndex); */\n\n const newAnimationData = JSON.parse(json);\n applyReplacements(newAnimationData, toneIndex);\n json = JSON.stringify(newAnimationData);\n }\n\n // ! WARNING, с этой проверкой не все стикеры работают, например - ДУРКА\n /* if(!/\"tgs\":\\s*?1./.test(jsString)) {\n throw new Error('Invalid file');\n } */\n\n /* let perf = performance.now();\n let json = JSON.parse(jsString);\n console.log('sticker decode:', performance.now() - perf); */\n\n const match = json.match(/\"fr\":\\s*?(\\d+?),/);\n const frameRate = +match?.[1] || DEFAULT_FPS;\n\n // console.log('Rendering sticker:', reqId, frameRate, 'now rendered:', Object.keys(items).length);\n\n item.init(json, frameRate);\n } catch(err) {\n console.error('Invalid file for sticker:', json);\n reply(['error', reqId, err]);\n }\n });\n },\n destroy: function(reqId: number) {\n const item = items[reqId];\n if(!item) {\n return;\n }\n\n item.destroy();\n delete items[reqId];\n },\n renderFrame: function(reqId: number, frameNo: number, clamped?: Uint8ClampedArray) {\n // console.log('worker renderFrame', reqId, frameNo, clamped);\n items[reqId].render(frameNo, clamped);\n }\n};\n\nfunction reply(args: any[], transfer?: Transferable[]) {\n postMessage({queryMethodListener: args.shift(), queryMethodArguments: args}, CAN_USE_TRANSFERABLES ? transfer : undefined);\n}\n\nonmessage = function(e) {\n // @ts-ignore\n queryableFunctions[e.data.queryMethod].apply(queryableFunctions, e.data.queryMethodArguments);\n};\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport readBlobAs from './readBlobAs';\n\nexport default function readBlobAsText(blob: Blob) {\n return readBlobAs(blob, 'readAsText');\n}\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\n// import { IS_WEB_WORKER } from \"../context\";\n\n// const id = IS_WEB_WORKER ? Math.random() * 0x1000 | 0 : 0;\nexport default function readBlobAs(blob: Blob, method: 'readAsText'): Promise;\nexport default function readBlobAs(blob: Blob, method: 'readAsDataURL'): Promise;\nexport default function readBlobAs(blob: Blob, method: 'readAsArrayBuffer'): Promise;\nexport default function readBlobAs(blob: Blob, method: 'readAsArrayBuffer' | 'readAsText' | 'readAsDataURL'): Promise {\n // const perf = performance.now();\n return new Promise((resolve) => {\n const reader = new FileReader();\n reader.addEventListener('loadend', (e) => {\n // console.log(`readBlobAs [${id}] ${method} time ${performance.now() - perf}`);\n resolve(e.target.result);\n });\n reader[method](blob);\n });\n}\n"],"names":["__webpack_require__","oldGetScript","u","oldLoadScript","e","queryMap","countMap","chunkId","hasOwnProperty","catch","error","retries","realSrc","message","request","Promise","resolve","setTimeout","cacheBust","Date","now","window","self","USER_AGENT","navigator","userAgent","IS_SAFARI","search","toLowerCase","indexOf","test","vendor","platform","maxTouchPoints","match","CAN_USE_TRANSFERABLES","undefined","err","COLORREPLACEMENTS","convert","value","Math","round","min","max","importScripts","_Module","Module","RLottieItem","constructor","reqId","width","height","raw","init","json","fps","this","dead","handle","worker","Api","stringOnWasmHeap","allocate","intArrayFromString","frameCount","loadFromData","resize","reply","imageData","ImageData","console","render","frameNo","clamped","bufferPointer","buffer","data","HEAPU8","subarray","set","createImageBitmap","then","imageBitmap","Uint8ClampedArray","destroy","initApi","cwrap","onRuntimeInitialized","items","queryableFunctions","blob","toneIndex","item","method","reader","FileReader","addEventListener","target","result","readBlobAs","readBlobAsText","newAnimationData","JSON","parse","object","replacements","checkSmth","smth","ty","k","c","color","foundReplacement","find","p","applyTo","iterateIt","it","layer","layers","shapes","shape","warn","applyReplacements","stringify","frameRate","renderFrame","args","transfer","postMessage","queryMethodListener","shift","queryMethodArguments","onmessage","queryMethod","apply"],"sourceRoot":""}