"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[7941],{67941:(t,i,s)=>{s.r(i),s.d(i,{default:()=>k});var e=s(77361),n=s(26926);function h(t,i,s){return i in t?Object.defineProperty(t,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[i]=s,t}class r{constructor(t){this.worker=t,h(this,"requestStates",new Map),h(this,"requestStatesByCallback",new Map),this.subscribe()}request(t){const{worker:i,requestStates:s,requestStatesByCallback:e}=this,h=(0,n.Z)(s),r={type:"callMethod",messageId:h,...t},a={messageId:h},o=new Promise(((t,i)=>{Object.assign(a,{resolve:t,reject:i})}));if("function"==typeof r.args[r.args.length-1]){const t=r.args.pop();a.callback=t,e.set(t,a)}return s.set(h,a),o.catch((()=>{})).finally((()=>{s.delete(h),a.callback&&e.delete(a.callback)})),i.postMessage(r),o}cancelCallback(t){t.isCanceled=!0;const{messageId:i}=this.requestStatesByCallback.get(t)||{};i&&this.worker.postMessage({type:"cancelProgress",messageId:i})}subscribe(){const{worker:t,requestStates:i}=this;t.addEventListener("message",(t=>{let{data:s}=t;if("methodResponse"===s.type){const t=i.get(s.messageId);t&&(s.error?t.reject(s.error):t.resolve(s.response))}else if("methodCallback"===s.type){var e;const t=i.get(s.messageId);null==t||null===(e=t.callback)||void 0===e||e.call(t,...s.callbackArgs)}else if("unhandledError"===s.type){var n;throw new Error(null===(n=s.error)||void 0===n?void 0:n.message)}}))}}var a=s(9933),o=s(3570);function d(t,i,s){return i in t?Object.defineProperty(t,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[i]=s,t}const c=e.wB?.75:1,u=e.wZ?.5:.75,l=e.s$?2:4,m={},g=new Array(4).fill(void 0).map((()=>new r(new Worker(new URL(s.p+s.u(2993),s.b)))));let p=-1;const k=class{constructor(t,i,s={},e,h,r){this.container=t,this.tgsUrl=i,this.params=s,this.onLoad=e,this.customColor=h,this.onEnded=r,d(this,"imgSize",void 0),d(this,"key",(0,n.Z)(m)),d(this,"msPerFrame",1e3/60),d(this,"reduceFactor",1),d(this,"cacheModulo",void 0),d(this,"chunkSize",void 0),d(this,"workerIndex",void 0),d(this,"chunks",[]),d(this,"framesCount",void 0),d(this,"chunksCount",void 0),d(this,"canvas",document.createElement("canvas")),d(this,"ctx",this.canvas.getContext("2d")),d(this,"isAnimating",!1),d(this,"isWaiting",!0),d(this,"isEnded",!1),d(this,"isOnLoadFired",!1),d(this,"isDestroyed",!1),d(this,"approxFrameIndex",0),d(this,"prevFrameIndex",-1),d(this,"stopFrameIndex",0),d(this,"speed",1),d(this,"direction",1),d(this,"lastRenderAt",void 0),this.initContainer(),this.initConfig(),this.initRenderer()}isPlaying(){return this.isAnimating||this.isWaiting}play(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isEnded&&t&&(this.approxFrameIndex=Math.floor(0)),this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}pause(){this.isWaiting?this.stopFrameIndex=this.approxFrameIndex:this.isAnimating=!1;const t=this.getChunkIndex(this.approxFrameIndex);this.chunks=this.chunks.map(((i,s)=>s===t?i:void 0))}playSegment(t){let[i,s]=t;this.approxFrameIndex=Math.floor(i/this.reduceFactor),this.stopFrameIndex=Math.floor(s/this.reduceFactor),this.direction=i{if(this.isDestroyed)return!1;if(!this.isAnimating&&this.isOnLoadFired)return!1;const t=Math.round(this.approxFrameIndex),i=this.getChunkIndex(t),s=this.chunks[i];if(!s||0===s.length)return this.requestChunk(i),this.isAnimating=!1,this.isWaiting=!0,!1;if(this.cacheModulo&&i%this.cacheModulo==0&&this.cleanupPrevChunk(i),t!==this.prevFrameIndex){const i=this.getFrame(t);if(!i)return this.isAnimating=!1,this.isWaiting=!0,!1;const s=new Uint8ClampedArray(i);if(this.customColor)for(let t=0;t0&&(t===this.framesCount-1||r>this.framesCount-1)){var a;if(this.params.noLoop)return this.isAnimating=!1,this.isEnded=!0,null===(a=this.onEnded)||void 0===a||a.call(this),!1;this.approxFrameIndex=0}else if(h<0&&(0===t||r<0)){var o;if(this.params.noLoop)return this.isAnimating=!1,this.isEnded=!0,null===(o=this.onEnded)||void 0===o||o.call(this),!1;this.approxFrameIndex=this.framesCount-1}else{if(void 0!==this.stopFrameIndex&&(t===this.stopFrameIndex||h>0&&r>this.stopFrameIndex||h<0&&r{function e(t,i){return i-Math.floor(i/t)*t}s.d(i,{Z:()=>e})}}]); //# sourceMappingURL=7941.c16f7302196aa916c103.js.map