/* @license https://github.com/lydell/resolve-url/blob/master/resolve-url.js Copyright 2014 Simon Lydell X11 ("MIT") Licensed. (See LICENSE.) */ /* @license Extracted from pdf.js https://github.com/andreasgal/pdf.js Copyright (c) 2011 Mozilla Foundation Contributors: Andreas Gal Chris G Jones Shaon Barman Vivien Nicolas <21@vingtetun.org> Justin D'Arcangelo Yury Delendik Modified and adapted in 2017 by Georg Fischer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* # @license # # MIT LICENSE # Copyright (c) 2011 Devon Govett, 2017 Georg Fischer # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons # to whom the Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).png={})}(this,function(e){"use strict";function h(e,t,r){r=r||e.pixels||e.decodePixels();var a,i=e.hasAlphaChannel,n=e.colors,s=null,o=(e.palette.length&&(s=e.decodedPalette||e.decodePalette(),n=4,i=!0),t.data||t),h=o.length,f=s||r,d=0,c=0,u=0;if(1===n)for(;d>t,this.codeSize=r-=t,this.bytesPos=i,e},t.prototype.getCode=function(t){for(var e=t[0],r=t[1],s=this.bytes,i=this.codeSize,a=this.codeBuf,n=this.bytesPos;i>16,t&=65535;return(0==i||i>e,this.codeSize=i-e,this.bytesPos=n,t},t.prototype.generateHuffmanTable=function(t){for(var e=t.length,r=0,s=0;sr&&(r=t[s]);for(var i=1<>=1;for(l=d;l>=1)){var i,a=this.bytes,o=this.bytesPos,h=(void 0===(i=a[o++])&&error("Bad block header in flate stream"),i),f=(void 0===(i=a[o++])&&error("Bad block header in flate stream"),h|=i<<8,void 0===(i=a[o++])&&error("Bad block header in flate stream"),i),f=(void 0===(i=a[o++])&&error("Bad block header in flate stream"),(f|=i<<8)!=(65535&~h)&&error("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0,this.bufferLength),d=this.ensureBuffer(f+h),c=f+h;this.bufferLength=c;for(var l=f;l>16,k=(65535&D)+(P=0>16)?this.getBits(P):P));U<=w+k&&(U=(B=this.ensureBuffer(w+k)).length);for(var C=0;Cthis.data.length&&error("Incomplete or corrupt PNG file")}};function sendMessage(t,e,r){t={type:t,message:e,id:r,time:Date.now()};self.postMessage(t)}function fromURL(t){return loadPNG(t)}function fromImageData(r){return new Promise(function(t,e){try{t(new PNG(r.data||r))}catch(t){e(t)}})}PNG.prototype.read=function(t){for(var e=[],r=0;0<=t?r=t.animation.numPlays?i=!1:t.animation.currentFrameIndex=0);i?(i=t.animation.frames[t.animation.currentFrameIndex].delay||1e3/60,l(t,a,t.animation.currentFrameIndex),r.timeoutId=setTimeout(function(){e(t,r,a)},i)):f(r)}(e,t,r)});throw new Error("Cannot animate png: no animation data available")}function f(e){clearTimeout(e.timeoutId)}var d=1,c=2,u=0;function l(e,t,r){var a=e.animation.frames,i=a[r],a=a[0===r?a.length-1:r-1];return 0===r&&t.clearRect(0,0,e.width,e.height),null!=a.disposeOp&&a.disposeOp===d?t.clearRect(a.xOffset,a.yOffset,a.width,a.height):null!=a.disposeOp&&a.disposeOp===c&&t.putImageData(a.imageData,a.xOffset,a.yOffset),(null!=a?a.disposeOp:void 0)===d?t.clearRect(a.xOffset,a.yOffset,a.width,a.height):(null!=a?a.disposeOp:void 0)===c&&t.putImageData(a.imageData,a.xOffset,a.yOffset),i.blendOp===u&&t.clearRect(i.xOffset,i.yOffset,i.width,i.height),t.drawImage(i.image,i.xOffset,i.yOffset)}e.animateOnContext=o,e.fromImageData=function(e){return t("fromImageData",e)},e.fromURL=function(e){return t("fromURL",function(e){var t=arguments,r=arguments.length;if(0===r)throw new Error("resolveUrl requires at least one argument; got none.");var a=document.createElement("base");if(a.href=e,1===r)return a.href;for(var i,e=document.getElementsByTagName("head")[0],n=(e.insertBefore(a,e.firstChild),document.createElement("a")),s=1;s