Build 533169stable
Module 234291
1,926 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>s,HL:()=>f,J$:()=>E,LO:()=>d,LV:()=>l,XU:()=>c,Xo:()=>p,aA:()=>h,eZ:()=>m,vW:()=>u});var r=n(643479),i=n(761799);let s={isPngFile:I,findPngOffsets:T},a="\x89PNG\r\n\x1a\n",o=4,l=4,u=0,c=4,d=8,_="XML:com.adobe.xmp\0",f="tEXt",p="iTXt",h="zTXt",m="pHYs",E="tIME",g="eXIf",A="iCCP";function I(e){return!!e&&(0,r.hT)(e,0,a.length)===a}function T(e,t){let n=4,s={hasAppMarkers:!1},_=a.length;for(;_+o+l<=e.byteLength;){if(i.A.USE_PNG_FILE&&S(e,_))s.hasAppMarkers=!0,s.pngHeaderOffset=_+d;else if(i.A.USE_XMP&&y(e,_)){let t=O(e,_);void 0!==t&&(s.hasAppMarkers=!0,s.xmpChunks=[{dataOffset:t,length:e.getUint32(_+u)-(t-(_+d))}])}else if(v(e,_,t)){s.hasAppMarkers=!0;let t=(0,r.hT)(e,_+c,l);s.pngTextChunks||(s.pngTextChunks=[]),s.pngTextChunks.push({length:e.getUint32(_+u),type:t,offset:_+d})}else if(N(e,_))s.hasAppMarkers=!0,s.tiffHeaderOffset=_+d;else if(i.A.USE_ICC&&t&&C(e,_)){s.hasAppMarkers=!0;let t=e.getUint32(_+u),n=_+d,{profileName:r,compressionMethod:i,compressedProfileOffset:a}=b(e,n);s.iccChunks||(s.iccChunks=[]),s.iccChunks.push({offset:a,length:t-(a-n),chunkNumber:1,chunksTotal:1,profileName:r,compressionMethod:i})}else R(e,_)&&(s.hasAppMarkers=!0,s.pngChunkOffsets||(s.pngChunkOffsets=[]),s.pngChunkOffsets.push(_+u));_+=e.getUint32(_+u)+o+l+n}return s}function S(e,t){let n="IHDR";return(0,r.hT)(e,t+c,l)===n}function y(e,t){return(0,r.hT)(e,t+c,l)===p&&(0,r.hT)(e,t+d,_.length)===_}function v(e,t,n){let i=(0,r.hT)(e,t+c,l);return i===f||i===p||i===h&&n}function N(e,t){return(0,r.hT)(e,t+c,l)===g}function C(e,t){return(0,r.hT)(e,t+c,l)===A}function R(e,t){return[m,E].includes((0,r.hT)(e,t+c,l))}function O(e,t){let n=1,r=1;t+=d+_.length+n+r;let i=0;for(;i<2&&t<e.byteLength;)0===e.getUint8(t)&&i++,t++;if(!(i<2))return t}function b(e,t){let n=1,i=1,s=(0,r.BD)(e,t);return t+=s.length+n,{profileName:s,compressionMethod:e.getUint8(t),compressedProfileOffset:t+=i}}}