{this.registerTagMapper(e)})}mapTag(e,t){if(this.tagMappers[e])return this.tagMappers[e].mapGenericTag(t);throw new Error("No generic tag mapper defined for tag-format: "+e)}registerTagMapper(e){for(const t of e.tagTypes)this.tagMappers[t]=e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={title:"title",artist:"artist",album:"album",year:"year",comment:"comment",track:"track",genre:"genre"};t.ID3v1TagMapper=class extends n.CommonTagMapper{constructor(){super(["ID3v1"],i)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{static decode(e){let t="";for(const r in e)e.hasOwnProperty(r)&&(t+=n.codePointToString(n.singleByteDecoder(e[r])));return t}static inRange(e,t,r){return t<=e&&e<=r}static codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}static singleByteDecoder(e){if(n.inRange(e,0,127))return e;const t=n.windows1252[e-128];if(null===t)throw Error("invaliding encoding");return t}}n.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],t.Windows1292Decoder=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i=r(4),a={TIT2:"title",TPE1:"artist","TXXX:Artists":"artists",TPE2:"albumartist",TALB:"album",TDRV:"date",TORY:"originalyear",TPOS:"disk",TCON:"genre",APIC:"picture",TCOM:"composer","USLT:description":"lyrics",TSOA:"albumsort",TSOT:"titlesort",TOAL:"originalalbum",TSOP:"artistsort",TSO2:"albumartistsort",TSOC:"composersort",TEXT:"lyricist","TXXX:Writer":"writer",TPE3:"conductor",TPE4:"remixer","IPLS:arranger":"arranger","IPLS:engineer":"engineer","IPLS:producer":"producer","IPLS:DJ-mix":"djmixer","IPLS:mix":"mixer",TPUB:"label",TIT1:"grouping",TIT3:"subtitle",TRCK:"track",TCMP:"compilation",POPM:"rating",TBPM:"bpm",TMED:"media","TXXX:CATALOGNUMBER":"catalognumber","TXXX:MusicBrainz Album Status":"releasestatus","TXXX:MusicBrainz Album Type":"releasetype","TXXX:MusicBrainz Album Release Country":"releasecountry","TXXX:RELEASECOUNTRY":"releasecountry","TXXX:SCRIPT":"script",TLAN:"language",TCOP:"copyright",WCOP:"license",TENC:"encodedby",TSSE:"encodersettings","TXXX:BARCODE":"barcode",TSRC:"isrc","TXXX:ASIN":"asin","TXXX:originalyear":"originalyear","UFID:http://musicbrainz.org":"musicbrainz_recordingid","TXXX:MusicBrainz Release Track Id":"musicbrainz_trackid","TXXX:MusicBrainz Album Id":"musicbrainz_albumid","TXXX:MusicBrainz Artist Id":"musicbrainz_artistid","TXXX:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","TXXX:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","TXXX:MusicBrainz Work Id":"musicbrainz_workid","TXXX:MusicBrainz TRM Id":"musicbrainz_trmid","TXXX:MusicBrainz Disc Id":"musicbrainz_discid","TXXX:ACOUSTID_ID":"acoustid_id","TXXX:Acoustid Id":"acoustid_id","TXXX:Acoustid Fingerprint":"acoustid_fingerprint","TXXX:MusicIP PUID":"musicip_puid","TXXX:MusicMagic Fingerprint":"musicip_fingerprint",WOAR:"website",TDRC:"date",TYER:"year",TDOR:"originaldate","TIPL:arranger":"arranger","TIPL:engineer":"engineer","TIPL:producer":"producer","TIPL:DJ-mix":"djmixer","TIPL:mix":"mixer",TMOO:"mood",SYLT:"lyrics",TSST:"discsubtitle",TKEY:"key",COMM:"comment",TOPE:"originalartist","PRIV:AverageLevel":"averageLevel","PRIV:PeakLevel":"peakLevel","TXXX:DISCOGS_ARTIST_ID":"discogs_artist_id","TXXX:DISCOGS_ARTISTS":"artists","TXXX:DISCOGS_ARTIST_NAME":"artists","TXXX:DISCOGS_ALBUM_ARTISTS":"albumartist","TXXX:DISCOGS_CATALOG":"catalognumber","TXXX:DISCOGS_COUNTRY":"releasecountry","TXXX:DISCOGS_DATE":"originaldate","TXXX:DISCOGS_LABEL":"label","TXXX:DISCOGS_LABEL_ID":"discogs_label_id","TXXX:DISCOGS_MASTER_RELEASE_ID":"discogs_master_release_id","TXXX:DISCOGS_RATING":"discogs_rating","TXXX:DISCOGS_RELEASED":"date","TXXX:DISCOGS_RELEASE_ID":"discogs_release_id","TXXX:DISCOGS_VOTES":"discogs_votes","TXXX:CATALOGID":"catalognumber","TXXX:STYLE":"genre","TXXX:replaygain_track_peak":"replaygain_track_peak","TXXX:replaygain_track_gain":"replaygain_track_gain"};class s extends n.CommonTagMapper{static toRating(e){return{source:e.email,rating:e.rating>0?(e.rating-1)/254*n.CommonTagMapper.maxRatingScore:void 0}}constructor(){super(["ID3v2.3","ID3v2.4"],a)}postMap(e){switch(e.id){case"UFID":"http://musicbrainz.org"===e.value.owner_identifier&&(e.id+=":"+e.value.owner_identifier,e.value=i.default.decodeString(e.value.identifier,"iso-8859-1"));break;case"PRIV":switch(e.value.owner_identifier){case"AverageLevel":case"PeakValue":e.id+=":"+e.value.owner_identifier,e.value=4===e.value.data.length?e.value.data.readUInt32LE(0):null}break;case"COMM":e.value=e.value?e.value.text:null;break;case"POPM":e.value=s.toRating(e.value)}}}t.ID3v24TagMapper=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={Title:"title",Author:"artist","WM/AlbumArtist":"albumartist","WM/AlbumTitle":"album","WM/Year":"date","WM/OriginalReleaseTime":"originaldate","WM/OriginalReleaseYear":"originalyear",Description:"comment","WM/TrackNumber":"track","WM/PartOfSet":"disk","WM/Genre":"genre","WM/Composer":"composer","WM/Lyrics":"lyrics","WM/AlbumSortOrder":"albumsort","WM/TitleSortOrder":"titlesort","WM/ArtistSortOrder":"artistsort","WM/AlbumArtistSortOrder":"albumartistsort","WM/ComposerSortOrder":"composersort","WM/Writer":"lyricist","WM/Conductor":"conductor","WM/ModifiedBy":"remixer","WM/Engineer":"engineer","WM/Producer":"producer","WM/DJMixer":"djmixer","WM/Mixer":"mixer","WM/Publisher":"label","WM/ContentGroupDescription":"grouping","WM/SubTitle":"subtitle","WM/SetSubTitle":"discsubtitle","WM/IsCompilation":"compilation","WM/SharedUserRating":"rating","WM/BeatsPerMinute":"bpm","WM/Mood":"mood","WM/Media":"media","WM/CatalogNo":"catalognumber","MusicBrainz/Album Status":"releasestatus","MusicBrainz/Album Type":"releasetype","MusicBrainz/Album Release Country":"releasecountry","WM/Script":"script","WM/Language":"language",Copyright:"copyright",LICENSE:"license","WM/EncodedBy":"encodedby","WM/EncodingSettings":"encodersettings","WM/Barcode":"barcode","WM/ISRC":"isrc","MusicBrainz/Track Id":"musicbrainz_recordingid","MusicBrainz/Release Track Id":"musicbrainz_trackid","MusicBrainz/Album Id":"musicbrainz_albumid","MusicBrainz/Artist Id":"musicbrainz_artistid","MusicBrainz/Album Artist Id":"musicbrainz_albumartistid","MusicBrainz/Release Group Id":"musicbrainz_releasegroupid","MusicBrainz/Work Id":"musicbrainz_workid","MusicBrainz/TRM Id":"musicbrainz_trmid","MusicBrainz/Disc Id":"musicbrainz_discid","Acoustid/Id":"acoustid_id","Acoustid/Fingerprint":"acoustid_fingerprint","MusicIP/PUID":"musicip_puid","WM/ARTISTS":"artists","WM/InitialKey":"key",ASIN:"asin","WM/Work":"work","WM/AuthorURL":"website","WM/Picture":"picture"};class a extends n.CommonTagMapper{static toRating(e){return{rating:parseFloat(e+1)/5}}constructor(){super(["asf"],i)}postMap(e){switch(e.id){case"WM/SharedUserRating":const t=e.id.split(":");e.value=a.toRating(e.value),e.id=t[0]}}}t.AsfTagMapper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.id3v22TagMap={TT2:"title",TP1:"artist",TP2:"albumartist",TAL:"album",TYE:"year",COM:"comment",TRK:"track",TPA:"disk",TCO:"genre",PIC:"picture",TCM:"composer",TOR:"originaldate",TOT:"work",TXT:"lyricist",TP3:"conductor",TPB:"label",TT1:"grouping",TT3:"subtitle",TLA:"language",TCR:"copyright",WCP:"license",TEN:"encodedby",TSS:"encodersettings",WAR:"website","COM:iTunPGAP":"gapless"};t.ID3v22TagMapper=class extends n.CommonTagMapper{constructor(){super(["ID3v2.2"],t.id3v22TagMap)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={Title:"title",Artist:"artist",Artists:"artists","Album Artist":"albumartist",Album:"album",Year:"date",Originalyear:"originalyear",Originaldate:"originaldate",Comment:"comment",Track:"track",Disc:"disk",DISCNUMBER:"disk",Genre:"genre","Cover Art (Front)":"picture","Cover Art (Back)":"picture",Composer:"composer",Lyrics:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",Lyricist:"lyricist",Writer:"writer",Conductor:"conductor",MixArtist:"remixer",Arranger:"arranger",Engineer:"engineer",Producer:"producer",DJMixer:"djmixer",Mixer:"mixer",Label:"label",Grouping:"grouping",Subtitle:"subtitle",DiscSubtitle:"discsubtitle",Compilation:"compilation",BPM:"bpm",Mood:"mood",Media:"media",CatalogNumber:"catalognumber",MUSICBRAINZ_ALBUMSTATUS:"releasestatus",MUSICBRAINZ_ALBUMTYPE:"releasetype",RELEASECOUNTRY:"releasecountry",Script:"script",Language:"language",Copyright:"copyright",LICENSE:"license",EncodedBy:"encodedby",EncoderSettings:"encodersettings",Barcode:"barcode",ISRC:"isrc",ASIN:"asin",musicbrainz_trackid:"musicbrainz_recordingid",musicbrainz_releasetrackid:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",Acoustid_Id:"acoustid_id",ACOUSTID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",Weblink:"website"};t.APEv2TagMapper=class extends n.CommonTagMapper{constructor(){const e={};for(const t in i)e[t.toUpperCase()]=i[t];super(["APEv2"],e)}getCommonName(e){return this.tagMap[e.toUpperCase()]}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={"©nam":"title","©ART":"artist",aART:"albumartist","----:com.apple.iTunes:Band":"albumartist","©alb":"album","©day":"date","©cmt":"comment",trkn:"track",disk:"disk","©gen":"genre",covr:"picture","©wrt":"composer","©lyr":"lyrics",soal:"albumsort",sonm:"titlesort",soar:"artistsort",soaa:"albumartistsort",soco:"composersort","----:com.apple.iTunes:LYRICIST":"lyricist","----:com.apple.iTunes:CONDUCTOR":"conductor","----:com.apple.iTunes:REMIXER":"remixer","----:com.apple.iTunes:ENGINEER":"engineer","----:com.apple.iTunes:PRODUCER":"producer","----:com.apple.iTunes:DJMIXER":"djmixer","----:com.apple.iTunes:MIXER":"mixer","----:com.apple.iTunes:LABEL":"label","©grp":"grouping","----:com.apple.iTunes:SUBTITLE":"subtitle","----:com.apple.iTunes:DISCSUBTITLE":"discsubtitle",cpil:"compilation",tmpo:"bpm","----:com.apple.iTunes:MOOD":"mood","----:com.apple.iTunes:MEDIA":"media","----:com.apple.iTunes:CATALOGNUMBER":"catalognumber",tvsh:"tvShow",tvsn:"tvSeason",tves:"tvEpisode",sosn:"tvShowSort",tven:"tvEpisodeId",tvnn:"tvNetwork",pcst:"podcast",purl:"podcasturl","----:com.apple.iTunes:MusicBrainz Album Status":"releasestatus","----:com.apple.iTunes:MusicBrainz Album Type":"releasetype","----:com.apple.iTunes:MusicBrainz Album Release Country":"releasecountry","----:com.apple.iTunes:SCRIPT":"script","----:com.apple.iTunes:LANGUAGE":"language",cprt:"copyright","----:com.apple.iTunes:LICENSE":"license","©too":"encodedby",pgap:"gapless","----:com.apple.iTunes:BARCODE":"barcode","----:com.apple.iTunes:ISRC":"isrc","----:com.apple.iTunes:ASIN":"asin","----:com.apple.iTunes:NOTES":"comment","----:com.apple.iTunes:MusicBrainz Track Id":"musicbrainz_recordingid","----:com.apple.iTunes:MusicBrainz Release Track Id":"musicbrainz_trackid","----:com.apple.iTunes:MusicBrainz Album Id":"musicbrainz_albumid","----:com.apple.iTunes:MusicBrainz Artist Id":"musicbrainz_artistid","----:com.apple.iTunes:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","----:com.apple.iTunes:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","----:com.apple.iTunes:MusicBrainz Work Id":"musicbrainz_workid","----:com.apple.iTunes:MusicBrainz TRM Id":"musicbrainz_trmid","----:com.apple.iTunes:MusicBrainz Disc Id":"musicbrainz_discid","----:com.apple.iTunes:Acoustid Id":"acoustid_id","----:com.apple.iTunes:Acoustid Fingerprint":"acoustid_fingerprint","----:com.apple.iTunes:MusicIP PUID":"musicip_puid","----:com.apple.iTunes:fingerprint":"musicip_fingerprint",gnre:"genre","----:com.apple.iTunes:ALBUMARTISTSORT":"albumartistsort","----:com.apple.iTunes:ARTISTS":"artists","----:com.apple.iTunes:ORIGINALDATE":"originaldate","----:com.apple.iTunes:ORIGINALYEAR":"originalyear",desc:"description",ldes:"description"};t.tagType="iTunes";t.MP4TagMapper=class extends n.CommonTagMapper{constructor(){super([t.tagType],i)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={TITLE:"title",ARTIST:"artist",ARTISTS:"artists",ALBUMARTIST:"albumartist",ALBUM:"album",DATE:"date",ORIGINALDATE:"originaldate",ORIGINALYEAR:"originalyear",COMMENT:"comment",TRACKNUMBER:"track",DISCNUMBER:"disk",GENRE:"genre",METADATA_BLOCK_PICTURE:"picture",COMPOSER:"composer",LYRICS:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",LYRICIST:"lyricist",WRITER:"writer",CONDUCTOR:"conductor",REMIXER:"remixer",ARRANGER:"arranger",ENGINEER:"engineer",PRODUCER:"producer",DJMIXER:"djmixer",MIXER:"mixer",LABEL:"label",GROUPING:"grouping",SUBTITLE:"subtitle",DISCSUBTITLE:"discsubtitle",TRACKTOTAL:"totaltracks",DISCTOTAL:"totaldiscs",COMPILATION:"compilation",RATING:"rating",BPM:"bpm",MOOD:"mood",MEDIA:"media",CATALOGNUMBER:"catalognumber",RELEASESTATUS:"releasestatus",RELEASETYPE:"releasetype",RELEASECOUNTRY:"releasecountry",SCRIPT:"script",LANGUAGE:"language",COPYRIGHT:"copyright",LICENSE:"license",ENCODEDBY:"encodedby",ENCODERSETTINGS:"encodersettings",BARCODE:"barcode",ISRC:"isrc",ASIN:"asin",MUSICBRAINZ_TRACKID:"musicbrainz_recordingid",MUSICBRAINZ_RELEASETRACKID:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",ACOUSTID_ID:"acoustid_id",ACOUSTID_ID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",WEBSITE:"website",NOTES:"notes",TOTALTRACKS:"totaltracks",TOTALDISCS:"totaldiscs",DISCOGS_ARTIST_ID:"discogs_artist_id",DISCOGS_ARTISTS:"artists",DISCOGS_ARTIST_NAME:"artists",DISCOGS_ALBUM_ARTISTS:"albumartist",DISCOGS_CATALOG:"catalognumber",DISCOGS_COUNTRY:"releasecountry",DISCOGS_DATE:"originaldate",DISCOGS_LABEL:"label",DISCOGS_LABEL_ID:"discogs_label_id",DISCOGS_MASTER_RELEASE_ID:"discogs_master_release_id",DISCOGS_RATING:"discogs_rating",DISCOGS_RELEASED:"date",DISCOGS_RELEASE_ID:"discogs_release_id",DISCOGS_VOTES:"discogs_votes",CATALOGID:"catalognumber",STYLE:"genre",REPLAYGAIN_TRACK_GAIN:"replaygain_track_gain",REPLAYGAIN_TRACK_PEAK:"replaygain_track_peak"};class a extends n.CommonTagMapper{static toRating(e,t){return{source:e?e.toLowerCase():e,rating:parseFloat(t)*n.CommonTagMapper.maxRatingScore}}constructor(){super(["vorbis"],i)}postMap(e){if(0===e.id.indexOf("RATING:")){const t=e.id.split(":");e.value=a.toRating(t[1],e.value),e.id=t[0]}}}t.VorbisTagMapper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.riffInfoTagMap={IART:"artist",ICRD:"date",INAM:"title",TITL:"title",IPRD:"album",ITRK:"track",COMM:"comment",ICMT:"comment",ICNT:"releasecountry",GNRE:"genre",IWRI:"writer",RATE:"rating",YEAR:"year",ISFT:"encodedby",CODE:"encodedby",TURL:"website",IGNR:"genre",IENG:"engineer",ITCH:"technician",IMED:"media",IRPD:"album"};t.RiffInfoTagMapper=class extends n.CommonTagMapper{constructor(){super(["exif"],t.riffInfoTagMap)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(10),s=r(21),o=r(17),c=r(5),u=r(7),l=r(225),d=r(226),f=r(26),p=i("music-metadata:parser:aiff");t.AIFFParser=class extends u.BasicParser{async parse(){if("FORM"!==(await this.tokenizer.readToken(d.Header)).chunkID)throw new Error("Invalid Chunk-ID, expected 'FORM'");const e=await this.tokenizer.readToken(c.FourCcToken);switch(e){case"AIFF":this.metadata.setFormat("container",e),this.isCompressed=!1;break;case"AIFC":this.metadata.setFormat("container","AIFF-C"),this.isCompressed=!0;break;default:throw Error("Unsupported AIFF type: "+e)}this.metadata.setFormat("lossless",!this.isCompressed);try{for(;;){const e=await this.tokenizer.readToken(d.Header);p(`Chunk id=${e.chunkID}`);const t=2*Math.round(e.chunkSize/2),r=await this.readData(e);await this.tokenizer.ignore(t-r)}}catch(e){if(e.message!==a.endOfFile)throw e}}async readData(e){switch(e.chunkID){case"COMM":const t=await this.tokenizer.readToken(new l.Common(e,this.isCompressed));return this.metadata.setFormat("bitsPerSample",t.sampleSize),this.metadata.setFormat("sampleRate",t.sampleRate),this.metadata.setFormat("numberOfChannels",t.numChannels),this.metadata.setFormat("numberOfSamples",t.numSampleFrames),this.metadata.setFormat("duration",t.numSampleFrames/t.sampleRate),this.metadata.setFormat("codec",t.compressionName),e.chunkSize;case"ID3 ":const r=await this.tokenizer.readToken(new n.BufferType(e.chunkSize)),i=new f.ID3Stream(r),a=s.fromStream(i);return await(new o.ID3v2Parser).parse(this.metadata,a,this.options),e.chunkSize;case"SSND":return this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*e.chunkSize/this.metadata.format.duration),0;default:return 0}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(4),s=r(18),o=n("music-metadata:id3v2:frame-parser"),c="iso-8859-1";class u{static readData(t,r,n,l){const{encoding:d,bom:f}=s.TextEncodingToken.get(t,0),p=t.length;let h=0,m=[];const g=u.getNullTerminatorLength(d);let b;const y={};switch(o(`Parsing tag type=${r}, encoding=${d}, bom=${f}`),"TXXX"!==r&&"T"===r[0]?"T*":r){case"T*":case"IPLS":const w=a.default.decodeString(t.slice(1),d).replace(/\x00+$/,"");switch(r){case"TMCL":case"TIPL":case"IPLS":m=u.splitValue(4,w),m=u.functionList(m);break;case"TRK":case"TRCK":case"TPOS":m=w;break;case"TCOM":case"TEXT":case"TOLY":case"TOPE":case"TPE1":case"TSRC":m=u.splitValue(n,w);break;default:m=n>=4?u.splitValue(n,w):[w]}break;case"TXXX":m={description:(m=u.readIdentifierAndData(t,h+1,p,d)).id,text:u.splitValue(n,a.default.decodeString(m.data,d).replace(/\x00+$/,""))};break;case"PIC":case"APIC":if(l){const r={};switch(h+=1,n){case 2:r.format=a.default.decodeString(t.slice(h,h+3),d),h+=3;break;case 3:case 4:b=a.default.findZero(t,h,p,c),r.format=a.default.decodeString(t.slice(h,b),c),h=b+1;break;default:throw new Error("Warning: unexpected major versionIndex: "+n)}r.format=u.fixPictureMimeType(r.format),r.type=s.AttachedPictureType[t[h]],h+=1,b=a.default.findZero(t,h,p,d),r.description=a.default.decodeString(t.slice(h,b),d),h=b+g,r.data=e.from(t.slice(h,p)),m=r}break;case"CNT":case"PCNT":m=i.UINT32_BE.get(t,0);break;case"SYLT":for(h+=7,m=[];h=5?t.readUInt32BE(h+1):void 0};break;case"GEOB":{b=a.default.findZero(t,h+1,p,d);const e=a.default.decodeString(t.slice(h+1,b),c);h=b+1,b=a.default.findZero(t,h,p-h,d);const r=a.default.decodeString(t.slice(h+1,b),c);h=b+1,b=a.default.findZero(t,h,p-h,d),m={type:e,filename:r,description:a.default.decodeString(t.slice(h+1,b),c),data:t.slice(h+1,p)};break}case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":m=a.default.decodeString(t.slice(h,b),d);break;case"WXXX":{b=a.default.findZero(t,h+1,p,d);const e=a.default.decodeString(t.slice(h+1,b),c);h=b+1,m={description:e,url:a.default.decodeString(t.slice(h,p-h),d)};break}case"MCDI":m=t.slice(0,p);break;default:o("Warning: unsupported id3v2-tag-type: "+r)}return m}static fixPictureMimeType(e){switch(e=e.toLocaleLowerCase()){case"jpg":return"image/jpeg";case"png":return"image/png"}return e}static functionList(e){const t={};for(let r=0;r+1=4?/\x00/g:/\//g);return u.trimArray(r)}static trimArray(e){for(let t=0;t=r,`COMMON CHUNK size should always be at least ${r}`),this.len=e.chunkSize}get(e,t){const r=e.readUInt16BE(t+8)-16398,i=e.readUInt16BE(t+8+2),s={numChannels:e.readUInt16BE(t),numSampleFrames:e.readUInt32BE(t+2),sampleSize:e.readUInt16BE(t+6),sampleRate:r<0?i>>Math.abs(r):i<22){const r=e.readInt8(t+22);if(23+r+(r+1)%2!==this.len)throw new Error("Illegal pstring length");s.compressionName=new n.StringType(r,"binary").get(e,t+23)}}else s.compressionName="PCM";return s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5);t.Header={len:8,get:(e,t)=>({chunkID:n.FourCcToken.get(e,t),chunkSize:e.readUInt32BE(t+4)})}},function(e,t){},function(e,t,r){"use strict";var n=r(29).Buffer,i=r(229);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,a=n.allocUnsafe(e>>>0),s=this.head,o=0;s;)t=s.data,r=a,i=o,t.copy(r,i),o+=s.data.length,s=s.next;return a},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function a(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new a(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new a(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(231),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(12))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,a,s,o,c=1,u={},l=!1,d=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){h(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((a=new MessageChannel).port1.onmessage=function(e){h(e.data)},n=function(e){a.port2.postMessage(e)}):d&&"onreadystatechange"in d.createElement("script")?(i=d.documentElement,n=function(e){var t=d.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(h,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&h(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),n=function(t){e.postMessage(s+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r>1}}function s(e,t){return 0!=(e&1<({ID:i.FourCcToken.get(e,t),version:n.UINT32_LE.get(e,t+4)/1e3,descriptorBytes:n.UINT32_LE.get(e,t+8),headerBytes:n.UINT32_LE.get(e,t+12),seekTableBytes:n.UINT32_LE.get(e,t+16),headerDataBytes:n.UINT32_LE.get(e,t+20),apeFrameDataBytes:n.UINT32_LE.get(e,t+24),apeFrameDataBytesHigh:n.UINT32_LE.get(e,t+28),terminatingDataBytes:n.UINT32_LE.get(e,t+32),fileMD5:new n.BufferType(16).get(e,t+36)})},t.Header={len:24,get:(e,t)=>({compressionLevel:n.UINT16_LE.get(e,t),formatFlags:n.UINT16_LE.get(e,t+2),blocksPerFrame:n.UINT32_LE.get(e,t+4),finalFrameBlocks:n.UINT32_LE.get(e,t+8),totalFrames:n.UINT32_LE.get(e,t+12),bitsPerSample:n.UINT16_LE.get(e,t+16),channel:n.UINT16_LE.get(e,t+18),sampleRate:n.UINT32_LE.get(e,t+20)})},t.TagFooter={len:32,get:(e,t)=>({ID:new n.StringType(8,"ascii").get(e,t),version:n.UINT32_LE.get(e,t+8),size:n.UINT32_LE.get(e,t+12),fields:n.UINT32_LE.get(e,t+16),flags:a(n.UINT32_LE.get(e,t+20))})},t.TagItemHeader={len:8,get:(e,t)=>({size:n.UINT32_LE.get(e,t),flags:a(n.UINT32_LE.get(e,t+4))})},t.TagField=e=>new n.BufferType(e.size-t.TagFooter.len),t.parseTagFlags=a,t.isBitSet=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(42),i=r(241),a=r(2),s=r(7),o=a("music-metadata:parser:ASF"),c="asf";t.AsfParser=class extends s.BasicParser{async parse(){const e=await this.tokenizer.readToken(i.TopLevelHeaderObjectToken);if(!e.objectId.equals(n.default.HeaderObject))throw new Error("expected asf header; but was not found; got: "+e.objectId.str);try{await this.parseObjectHeader(e.numberOfHeaderObjects)}catch(e){o("Error while parsing ASF: %s",e)}}async parseObjectHeader(e){let t;do{const e=await this.tokenizer.readToken(i.HeaderObjectToken);switch(o("header GUID=%s",e.objectId.str),e.objectId.str){case i.FilePropertiesObject.guid.str:const r=await this.tokenizer.readToken(new i.FilePropertiesObject(e));this.metadata.setFormat("duration",r.playDuration/1e7),this.metadata.setFormat("bitrate",r.maximumBitrate);break;case i.StreamPropertiesObject.guid.str:const a=await this.tokenizer.readToken(new i.StreamPropertiesObject(e));this.metadata.setFormat("container","ASF/"+a.streamType);break;case i.HeaderExtensionObject.guid.str:const s=await this.tokenizer.readToken(new i.HeaderExtensionObject);await this.parseExtensionObject(s.extensionDataSize);break;case i.ContentDescriptionObjectState.guid.str:t=await this.tokenizer.readToken(new i.ContentDescriptionObjectState(e)),this.addTags(t);break;case i.ExtendedContentDescriptionObjectState.guid.str:t=await this.tokenizer.readToken(new i.ExtendedContentDescriptionObjectState(e)),this.addTags(t);break;case n.default.CodecListObject.str:case n.default.StreamBitratePropertiesObject.str:await this.tokenizer.ignore(e.objectSize-i.HeaderObjectToken.len);break;case n.default.PaddingObject.str:o("Padding: %s bytes",e.objectSize-i.HeaderObjectToken.len),await this.tokenizer.ignore(e.objectSize-i.HeaderObjectToken.len);break;default:this.warnings.push("Ignore ASF-Object-GUID: "+e.objectId.str),o("Ignore ASF-Object-GUID: %s",e.objectId.str),await this.tokenizer.readToken(new i.IgnoreObjectState(e))}}while(--e)}addTags(e){e.forEach(e=>{this.metadata.addTag(c,e.id,e.value)})}async parseExtensionObject(e){do{const t=await this.tokenizer.readToken(i.HeaderObjectToken);switch(t.objectId.str){case i.ExtendedStreamPropertiesObjectState.guid.str:await this.tokenizer.readToken(new i.ExtendedStreamPropertiesObjectState(t));break;case i.MetadataObjectState.guid.str:const e=await this.tokenizer.readToken(new i.MetadataObjectState(t));this.addTags(e);break;case i.MetadataLibraryObjectState.guid.str:const r=await this.tokenizer.readToken(new i.MetadataLibraryObjectState(t));this.addTags(r);break;case n.default.PaddingObject.str:await this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;case n.default.CompatibilityObject.str:this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;case n.default.ASF_Index_Placeholder_Object.str:await this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;default:this.warnings.push("Ignore ASF-Object-GUID: "+t.objectId.str),await this.tokenizer.readToken(new i.IgnoreObjectState(t))}e-=t.objectSize}while(e>0)}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),i=r(1),a=r(42),s=r(242),o=r(18);!function(e){e[e.UnicodeString=0]="UnicodeString",e[e.ByteArray=1]="ByteArray",e[e.Bool=2]="Bool",e[e.DWord=3]="DWord",e[e.QWord=4]="QWord",e[e.Word=5]="Word"}(t.DataType||(t.DataType={})),t.TopLevelHeaderObjectToken={len:30,get:(e,t)=>({objectId:a.default.fromBin(new i.BufferType(16).get(e,t)),objectSize:i.UINT64_LE.get(e,t+16),numberOfHeaderObjects:i.UINT32_LE.get(e,t+24)})},t.HeaderObjectToken={len:24,get:(e,t)=>({objectId:a.default.fromBin(new i.BufferType(16).get(e,t)),objectSize:i.UINT64_LE.get(e,t+16)})};class c{constructor(e){this.len=e.objectSize-t.HeaderObjectToken.len}postProcessTag(e,t,r,n){if("WM/Picture"===t)e.push({id:t,value:b.fromBuffer(n)});else{const i=s.AsfUtil.getParserForAttr(r);if(!i)throw new Error("unexpected value headerType: "+r);e.push({id:t,value:i(n)})}}}t.State=c;t.IgnoreObjectState=class extends c{constructor(e){super(e)}get(e,t){return null}};class u extends c{constructor(e){super(e)}get(e,t){return{fileId:a.default.fromBin(e,t),fileSize:i.UINT64_LE.get(e,t+16),creationDate:i.UINT64_LE.get(e,t+24),dataPacketsCount:i.UINT64_LE.get(e,t+32),playDuration:i.UINT64_LE.get(e,t+40),sendDuration:i.UINT64_LE.get(e,t+48),preroll:i.UINT64_LE.get(e,t+56),flags:{broadcast:n.default.strtokBITSET.get(e,t+64,24),seekable:n.default.strtokBITSET.get(e,t+64,25)},minimumDataPacketSize:i.UINT32_LE.get(e,t+68),maximumDataPacketSize:i.UINT32_LE.get(e,t+72),maximumBitrate:i.UINT32_LE.get(e,t+76)}}}u.guid=a.default.FilePropertiesObject,t.FilePropertiesObject=u;class l extends c{constructor(e){super(e)}get(e,t){return{streamType:a.default.decodeMediaType(a.default.fromBin(e,t)),errorCorrectionType:a.default.fromBin(e,t+8)}}}l.guid=a.default.StreamPropertiesObject,t.StreamPropertiesObject=l;class d{constructor(){this.len=22}get(e,t){return{reserved1:a.default.fromBin(e,t),reserved2:e.readUInt16LE(t+16),extensionDataSize:e.readUInt32LE(t+18)}}}d.guid=a.default.HeaderExtensionObject,t.HeaderExtensionObject=d;class f extends c{constructor(e){super(e)}get(e,t){const r=[];let n=t+10;for(let i=0;i0){const t=f.contentDescTags[i],o=n+a;r.push({id:t,value:s.AsfUtil.parseUnicodeAttr(e.slice(n,o))}),n=o}}return r}}f.guid=a.default.ContentDescriptionObject,f.contentDescTags=["Title","Author","Copyright","Description","Rating"],t.ContentDescriptionObjectState=f;class p extends c{constructor(e){super(e)}get(e,t){const r=[],n=e.readUInt16LE(t);let i=t+2;for(let t=0;t({lastBlock:n.default.strtokBITSET.get(e,t,7),type:n.default.getBitAllignedNumber(e,t,1,7),length:i.UINT24_BE.get(e,t+1)})},d.BlockStreamInfo={len:34,get:(e,t)=>({minimumBlockSize:i.UINT16_BE.get(e,t),maximumBlockSize:i.UINT16_BE.get(e,t+2)/1e3,minimumFrameSize:i.UINT24_BE.get(e,t+4),maximumFrameSize:i.UINT24_BE.get(e,t+7),sampleRate:i.UINT24_BE.get(e,t+10)>>4,channels:n.default.getBitAllignedNumber(e,t+12,4,3)+1,bitsPerSample:n.default.getBitAllignedNumber(e,t+12,7,5)+1,totalSamples:n.default.getBitAllignedNumber(e,t+13,4,36),fileMD5:new i.BufferType(16).get(e,t+18)})};class f{constructor(e){this.data=e,this.offset=0}readInt32(){const e=i.UINT32_LE.get(this.data,this.offset);return this.offset+=4,e}readStringUtf8(){const e=this.readInt32(),t=this.data.toString("utf8",this.offset,this.offset+e);return this.offset+=e,t}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(7),s=r(245),o=r(44),c=r(25),u=n("music-metadata:parser:MP4"),l="iTunes",d={raw:{lossy:!1,format:"raw"},MAC3:{lossy:!0,format:"MACE 3:1"},MAC6:{lossy:!0,format:"MACE 6:1"},ima4:{lossy:!0,format:"IMA 4:1"},ulaw:{lossy:!0,format:"uLaw 2:1"},alaw:{lossy:!0,format:"uLaw 2:1"},Qclp:{lossy:!0,format:"QUALCOMM PureVoice"},".mp3":{lossy:!0,format:"MPEG-1 layer 3"},alac:{lossy:!1,format:"ALAC"},"ac-3":{lossy:!0,format:"AC-3"},mp4a:{lossy:!0,format:"MPEG-4/AAC"},mp4s:{lossy:!0,format:"MP4S"},c608:{lossy:!0,format:"CEA-608"},c708:{lossy:!0,format:"CEA-708"}};function f(e,t,r){return r.indexOf(e)===t}class p extends a.BasicParser{static read_BE_Signed_Integer(e){return i.readIntBE(e,0,e.length)}static read_BE_Unsigned_Integer(e){return i.readUIntBE(e,0,e.length)}async parse(){this.formatList=[];const e=new s.Atom({name:"mp4",length:this.tokenizer.fileSize},!1,null);await e.readAtoms(this.tokenizer,async e=>{if(e.parent)switch(e.parent.header.name){case"ilst":case"":return this.parseMetadataItemData(e);case"stbl":switch(e.header.name){case"stsd":return this.parseAtom_stsd(e.dataLen);default:u(`Ignore: stbl/${e.header.name} atom`)}}switch(e.header.name){case"ftyp":const t=await this.parseAtom_ftyp(e.dataLen);u(`ftyp: ${t.join("/")}`);const r=t.filter(f).join("/");return void this.metadata.setFormat("container",r);case"mdhd":return this.parseAtom_mdhd(e);case"mvhd":return this.parseAtom_mvhd(e);case"mdat":this.audioLengthInBytes=e.dataLen,this.calculateBitRate()}await this.tokenizer.readToken(new i.IgnoreType(e.dataLen)),u(`Ignore atom data: path=${e.atomPath}, payload-len=${e.dataLen}`)},this.tokenizer.fileSize),this.metadata.setFormat("codec",this.formatList.filter(f).join("+"))}calculateBitRate(){this.audioLengthInBytes&&this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*this.audioLengthInBytes/this.metadata.format.duration)}addTag(e,t){this.metadata.addTag(l,e,t)}addWarning(e){u("Warning:"+e),this.warnings.push(e)}parseMetadataItemData(e){let t=e.header.name;return e.readAtoms(this.tokenizer,async e=>{switch(e.header.name){case"data":return this.parseValueAtom(t,e);case"name":const r=await this.tokenizer.readToken(new o.NameAtom(e.dataLen));t+=":"+r.name;break;case"mean":const n=await this.tokenizer.readToken(new o.NameAtom(e.dataLen));t+=":"+n.name;break;default:const a=await this.tokenizer.readToken(new i.BufferType(e.dataLen));this.addWarning("Unsupported meta-item: "+t+"["+e.header.name+"] => value="+a.toString("hex")+" ascii="+a.toString("ascii"))}},e.dataLen)}async parseValueAtom(t,r){const n=await this.tokenizer.readToken(new o.DataAtom(r.header.length-o.Header.len));if(0!==n.type.set)throw new Error("Unsupported type-set != 0: "+n.type.set);switch(n.type.type){case 0:switch(t){case"trkn":case"disk":const e=i.UINT8.get(n.value,3),r=i.UINT8.get(n.value,5);this.addTag(t,e+"/"+r);break;case"gnre":const a=i.UINT8.get(n.value,1),s=c.Genres[a-1];this.addTag(t,s)}break;case 1:case 18:this.addTag(t,n.value.toString("utf-8"));break;case 13:if(this.options.skipCovers)break;this.addTag(t,{format:"image/jpeg",data:e.from(n.value)});break;case 14:if(this.options.skipCovers)break;this.addTag(t,{format:"image/png",data:e.from(n.value)});break;case 21:this.addTag(t,p.read_BE_Signed_Integer(n.value));break;case 22:this.addTag(t,p.read_BE_Unsigned_Integer(n.value));break;case 65:this.addTag(t,n.value.readInt8(0));break;case 66:this.addTag(t,n.value.readInt16BE(0));break;case 67:this.addTag(t,n.value.readInt32BE(0));break;default:this.addWarning(`atom key=${t}, has unknown well-known-type (data-type): ${n.type.type}`)}}async parseAtom_mvhd(e){const t=await this.tokenizer.readToken(new o.MvhdAtom(e.dataLen));this.parse_mxhd(t)}async parseAtom_mdhd(e){const t=await this.tokenizer.readToken(new o.MdhdAtom(e.dataLen));this.parse_mxhd(t)}parse_mxhd(e){if(e.timeScale&&!this.metadata.format.duration){const t=e.duration/e.timeScale;this.metadata.setFormat("duration",t),this.calculateBitRate()}}async parseAtom_ftyp(e){const t=await this.tokenizer.readToken(o.ftyp);if((e-=o.ftyp.len)>0){const r=await this.parseAtom_ftyp(e),n=t.type.replace(/\W/g,"");return n.length>0&&r.push(n),r}return[]}async parseAtom_stsd(e){const t=await this.tokenizer.readToken(new o.StsdAtom(e)),r=[];for(const e of t.table){const t=d[e.dataFormat];t?(this.parseSoundSampleDescription(e),this.metadata.setFormat("lossless",!t.lossy),r.push(t.format)):u(`Warning: data-format '${e.dataFormat}' missing in MP4Parser.encoderDict`)}r.length>0&&this.formatList.push(r.join("/"))}parseSoundSampleDescription(e){let t=0;const r=o.SoundSampleDescriptionVersion.get(e.description,t);if(t+=o.SoundSampleDescriptionVersion.len,0===r.version||1===r.version){const r=o.SoundSampleDescriptionV0.get(e.description,t);this.metadata.setFormat("sampleRate",r.sampleRate),this.metadata.setFormat("bitsPerSample",r.sampleSize),this.metadata.setFormat("numberOfChannels",r.numAudioChannels)}else u(`Warning: sound-sample-description ${r} not implemented`)}}t.MP4Parser=p}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(2),a=r(1),s=r(44),o=i("music-metadata:parser:MP4:Atom");class c{constructor(e,t,r){this.header=e,this.extended=t,this.parent=r,this.children=[],this.atomPath=(this.parent?this.parent.atomPath+"/":"")+this.header.name,this.dataLen=this.header.length-(t?16:8)}async readAtoms(e,t,r){const i=await this.readAtom(e,t);return this.children.push(i),void 0===r?this.readAtoms(e,t,r).catch(e=>{if(e.message!==n.endOfFile)throw e;o("Reached end-of-file")}):(r-=i.header.length)>0?this.readAtoms(e,t,r):void 0}async readAtom(e,t){const r=e.position,n=await e.readToken(s.Header),i=1===n.length;i&&(n.length=await e.readToken(s.ExtendedSize));const a=new c(n,i,this);return o(`parse atom name=${a.atomPath}, extended=${a.extended}, offset=${r}, len=${a.header.length}`),await a.readData(e,t),a}async readData(e,t){switch(this.header.name){case"moov":case"udta":case"trak":case"mdia":case"minf":case"stbl":case"":case"ilst":return this.readAtoms(e,t,this.dataLen);case"meta":return await e.readToken(new a.IgnoreType(4)),this.readAtoms(e,t,this.dataLen-4);case"mdhd":case"mvhd":case"tkhd":case"stsz":case"mdat":default:return t(this)}}}t.Atom=c},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(1),a=r(10),s=r(2),o=r(4),c=r(24),u=r(247),l=s("music-metadata:parser:mpeg"),d=1024,f={AudioObjectTypes:["AAC Main","AAC LC","AAC SSR","AAC LTP"],SamplingFrequencies:[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,void 0,void 0,-1]},p=[void 0,["front-center"],["front-left","front-right"],["front-center","front-left","front-right"],["front-center","front-left","front-right","back-center"],["front-center","front-left","front-right","back-left","back-right"],["front-center","front-left","front-right","back-left","back-right","LFE-channel"],["front-center","front-left","front-right","side-left","side-right","back-left","back-right","LFE-channel"]];class h{constructor(e,t){this.versionIndex=o.default.getBitAllignedNumber(e,t+1,3,2),this.layer=h.LayerDescription[o.default.getBitAllignedNumber(e,t+1,5,2)],this.versionIndex>1&&0===this.layer?this.parseAdtsHeader(e,t):this.parseMpegHeader(e,t),this.isProtectedByCRC=!o.default.isBitSet(e,t+1,7)}calcDuration(e){return e*this.calcSamplesPerFrame()/this.samplingRate}calcSamplesPerFrame(){return h.samplesInFrameTable[1===this.version?0:1][this.layer]}calculateSideInfoLength(){if(3!==this.layer)return 2;if(3===this.channelModeIndex){if(1===this.version)return 17;if(2===this.version||2.5===this.version)return 9}else{if(1===this.version)return 32;if(2===this.version||2.5===this.version)return 17}}calcSlotSize(){return[null,4,1,1][this.layer]}parseMpegHeader(e,t){this.container="MPEG",this.bitrateIndex=o.default.getBitAllignedNumber(e,t+2,0,4),this.sampRateFreqIndex=o.default.getBitAllignedNumber(e,t+2,4,2),this.padding=o.default.isBitSet(e,t+2,6),this.privateBit=o.default.isBitSet(e,t+2,7),this.channelModeIndex=o.default.getBitAllignedNumber(e,t+3,0,2),this.modeExtension=o.default.getBitAllignedNumber(e,t+3,2,2),this.isCopyrighted=o.default.isBitSet(e,t+3,4),this.isOriginalMedia=o.default.isBitSet(e,t+3,5),this.emphasis=o.default.getBitAllignedNumber(e,t+3,7,2),this.version=h.VersionID[this.versionIndex],this.channelMode=h.ChannelMode[this.channelModeIndex],this.codec="MP"+this.layer;const r=this.calcBitrate();if(!r)throw new Error("Cannot determine bit-rate");if(this.bitrate=1e3*r,this.samplingRate=this.calcSamplingRate(),null==this.samplingRate)throw new Error("Cannot determine sampling-rate")}parseAdtsHeader(e,t){l("layer=0 => ADTS"),this.version=2===this.versionIndex?4:2,this.container="ADTS/MPEG-"+this.version;const r=o.default.getBitAllignedNumber(e,t+2,0,2);this.codec="AAC",this.codecProfile=f.AudioObjectTypes[r],l(`MPEG-4 audio-codec=${this.codec}`);const n=o.default.getBitAllignedNumber(e,t+2,2,4);this.samplingRate=f.SamplingFrequencies[n],l(`sampling-rate=${this.samplingRate}`);const i=o.default.getBitAllignedNumber(e,t+2,7,3);this.mp4ChannelConfig=p[i],l(`channel-config=${this.mp4ChannelConfig.join("+")}`),this.frameLength=o.default.getBitAllignedNumber(e,t+3,6,2)<<11}calcBitrate(){if(0===this.bitrateIndex)return null;if(15===this.bitrateIndex)return null;const e=this.version.toString()+this.layer;return h.bitrate_index[this.bitrateIndex][e]}calcSamplingRate(){return 3===this.sampRateFreqIndex?null:h.sampling_rate_freq_index[this.version][this.sampRateFreqIndex]}}h.SyncByte1=255,h.SyncByte2=224,h.VersionID=[2.5,null,2,1],h.LayerDescription=[0,3,2,1],h.ChannelMode=["stereo","joint_stereo","dual_channel","mono"],h.bitrate_index={1:{11:32,12:32,13:32,21:32,22:8,23:8},2:{11:64,12:48,13:40,21:48,22:16,23:16},3:{11:96,12:56,13:48,21:56,22:24,23:24},4:{11:128,12:64,13:56,21:64,22:32,23:32},5:{11:160,12:80,13:64,21:80,22:40,23:40},6:{11:192,12:96,13:80,21:96,22:48,23:48},7:{11:224,12:112,13:96,21:112,22:56,23:56},8:{11:256,12:128,13:112,21:128,22:64,23:64},9:{11:288,12:160,13:128,21:144,22:80,23:80},10:{11:320,12:192,13:160,21:160,22:96,23:96},11:{11:352,12:224,13:192,21:176,22:112,23:112},12:{11:384,12:256,13:224,21:192,22:128,23:128},13:{11:416,12:320,13:256,21:224,22:144,23:144},14:{11:448,12:384,13:320,21:256,22:160,23:160}},h.sampling_rate_freq_index={1:{0:44100,1:48e3,2:32e3},2:{0:22050,1:24e3,2:16e3},2.5:{0:11025,1:12e3,2:8e3}},h.samplesInFrameTable=[[0,384,1152,1152],[0,384,1152,576]];const m={len:4,get:(e,t)=>new h(e,t)};t.MpegParser=class extends c.AbstractID3Parser{constructor(){super(...arguments),this.frameCount=0,this.syncFrameCount=-1,this.countSkipFrameData=0,this.totalDataLength=0,this.bitrates=[],this.calculateEofDuration=!1,this.buf_frame_header=e.alloc(4),this.syncPeek={buf:e.alloc(d),len:0}}async _parse(){this.metadata.setFormat("lossless",!1);try{let e=!1;for(;!e;)await this.sync(),e=await this.parseCommonMpegHeader()}catch(e){if(e.message!==a.endOfFile)throw e;if(this.calculateEofDuration){const e=this.frameCount*this.samplesPerFrame;this.metadata.setFormat("numberOfSamples",e);const t=e/this.metadata.format.sampleRate;l(`Calculate duration at EOF: ${t} sec.`,t),this.metadata.setFormat("duration",t)}}}finalize(){const e=this.metadata.format,t=this.metadata.native.hasOwnProperty("ID3v1");if(e.duration&&this.tokenizer.fileSize){const r=this.tokenizer.fileSize-this.mpegOffset-(t?128:0);e.codecProfile&&"V"===e.codecProfile[0]&&this.metadata.setFormat("bitrate",8*r/e.duration)}else if(this.tokenizer.fileSize&&"CBR"===e.codecProfile){const r=this.tokenizer.fileSize-this.mpegOffset-(t?128:0),n=Math.round(r/this.frame_size)*this.samplesPerFrame;this.metadata.setFormat("numberOfSamples",n);const i=n/e.sampleRate;l("Calculate CBR duration based on file size: %s",i),this.metadata.setFormat("duration",i)}}async sync(){let e=!1;for(;;){let t=0;if(this.syncPeek.len=await this.tokenizer.peekBuffer(this.syncPeek.buf,0,d,this.tokenizer.position,!0),this.syncPeek.len<=256)throw new Error(a.endOfFile);if(0===this.syncPeek.len)throw new Error(a.endOfFile);for(;;){if(e&&224==(224&this.syncPeek.buf[t]))return this.buf_frame_header[0]=h.SyncByte1,this.buf_frame_header[1]=this.syncPeek.buf[t],await this.tokenizer.ignore(t),l(`Sync at offset=${this.tokenizer.position-1}, frameCount=${this.frameCount}`),this.syncFrameCount===this.frameCount&&(l(`Re-synced MPEG stream, frameCount=${this.frameCount}`),this.frameCount=0,this.frame_size=0),void(this.syncFrameCount=this.frameCount);if(e=!1,-1===(t=this.syncPeek.buf.indexOf(h.SyncByte1,t))){if(this.syncPeek.len=2&&0===e.layer?this.parseAdts(e):this.parseAudioFrameHeader(e)}async parseAudioFrameHeader(e){this.metadata.setFormat("numberOfChannels","mono"===e.channelMode?1:2),this.metadata.setFormat("bitrate",e.bitrate),this.frameCount<2e5&&l("offset=%s MP%s bitrate=%s sample-rate=%s",this.tokenizer.position-4,e.layer,e.bitrate,e.samplingRate);const t=e.calcSlotSize();if(null===t)throw new Error("invalid slot_size");const r=e.calcSamplesPerFrame();l(`samples_per_frame=${r}`);const n=r/8*e.bitrate/e.samplingRate+(e.padding?t:0);if(this.frame_size=Math.floor(n),this.audioFrameHeader=e,this.bitrates.push(e.bitrate),1===this.frameCount)return this.offset=m.len,await this.skipSideInformation(),!1;if(3===this.frameCount){if(this.areAllSame(this.bitrates)){if(this.samplesPerFrame=r,this.metadata.setFormat("codecProfile","CBR"),this.tokenizer.fileSize)return!0}else if(this.metadata.format.duration)return!0;if(!this.options.duration)return!0}return this.options.duration&&4===this.frameCount&&(this.samplesPerFrame=r,this.calculateEofDuration=!0),this.offset=4,e.isProtectedByCRC?(await this.parseCrc(),!1):(await this.skipSideInformation(),!1)}async parseAdts(t){const r=e.alloc(3);await this.tokenizer.readBuffer(r),t.frameLength+=o.default.getBitAllignedNumber(r,0,0,11),this.tokenizer.ignore(t.frameLength-7),this.totalDataLength+=t.frameLength,this.samplesPerFrame=1024;const n=t.samplingRate/this.samplesPerFrame,i=8*(0===this.frameCount?0:this.totalDataLength/this.frameCount)*n+.5;if(this.metadata.setFormat("codecProfile",t.codecProfile),this.metadata.setFormat("bitrate",i),t.mp4ChannelConfig&&this.metadata.setFormat("numberOfChannels",t.mp4ChannelConfig.length),l(`frame-count=${this.frameCount}, size=${t.frameLength} bytes, bit-rate=${i}`),3===this.frameCount){if(!this.options.duration)return!0;this.calculateEofDuration=!0}return!1}async parseCrc(){return this.crc=await this.tokenizer.readNumber(i.INT16_BE),this.offset+=2,this.skipSideInformation()}async skipSideInformation(){const e=this.audioFrameHeader.calculateSideInfoLength();await this.tokenizer.readToken(new i.BufferType(e)),this.offset+=e,await this.readXtraInfoHeader()}async readXtraInfoHeader(){const e=await this.tokenizer.readToken(u.InfoTagHeaderTag);switch(this.offset+=u.InfoTagHeaderTag.len,e){case"Info":return this.metadata.setFormat("codecProfile","CBR"),this.readXingInfoHeader();case"Xing":const t=await this.readXingInfoHeader(),r="V"+(100-t.vbrScale)/10;return this.metadata.setFormat("codecProfile",r),null;case"Xtra":break;case"LAME":const n=await this.tokenizer.readToken(u.LameEncoderVersion);return this.offset+=u.LameEncoderVersion.len,this.metadata.setFormat("tool","LAME "+n),await this.skipFrameData(this.frame_size-this.offset),null}const t=this.frame_size-this.offset;return t<0?this.warnings.push("Frame "+this.frameCount+"corrupt: negative frameDataLeft"):await this.skipFrameData(t),null}async readXingInfoHeader(){const e=await this.tokenizer.readToken(u.XingInfoTag);if(this.offset+=u.XingInfoTag.len,this.metadata.setFormat("tool",o.default.stripNulls(e.codec)),1==(1&e.headerFlags[3])){const t=this.audioFrameHeader.calcDuration(e.numFrames);return this.metadata.setFormat("duration",t),l("Get duration from Xing header: %s",this.metadata.format.duration),e}const t=this.frame_size-this.offset;return await this.skipFrameData(t),e}async skipFrameData(e){n.ok(e>=0,"frame-data-left cannot be negative"),await this.tokenizer.readToken(new i.IgnoreType(e)),this.countSkipFrameData+=e}areAllSame(e){const t=e[0];return e.every(e=>e===t)}}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.InfoTagHeaderTag=new n.StringType(4,"ascii"),t.LameEncoderVersion=new n.StringType(6,"ascii"),t.XingInfoTag={len:136,get:(e,t)=>({headerFlags:new n.BufferType(4).get(e,t),numFrames:n.UINT32_BE.get(e,t+4),streamSize:n.UINT32_BE.get(e,t+8),vbrScale:n.UINT32_BE.get(e,t+112),codec:new n.StringType(9,"ascii").get(e,t+116),infoTagRevision:n.UINT8.get(e,t+125)>>4,vbrMethod:15&n.UINT8.get(e,t+125)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(249),s=r(251),o=r(24),c=n("music-metadata:parser:musepack");t.default=class extends o.AbstractID3Parser{async _parse(){let e;switch(await this.tokenizer.peekToken(new i.StringType(3,"binary"))){case"MP+":c("Musepack stream-version 7"),e=new s.MpcSv7Parser;break;case"MPC":c("Musepack stream-version 8"),e=new a.MpcSv8Parser;break;default:throw new Error("Invalid Musepack signature prefix")}return e.init(this.metadata,this.tokenizer,this.options),e.parse()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(6),a=r(7),s=r(250),o=r(23),c=r(5),u=n("music-metadata:parser:musepack");t.MpcSv8Parser=class extends a.BasicParser{constructor(){super(...arguments),this.audioLength=0}async parse(){const e=await this.tokenizer.readToken(c.FourCcToken);return i.equal(e,"MPCK","Magic number"),this.metadata.setFormat("container","Musepack, SV8"),this.parsePacket()}async parsePacket(){const e=new s.StreamReader(this.tokenizer);for(;;){const t=await e.readPacketHeader();switch(u(`packet-header key=${t.key}, payloadLength=${t.payloadLength}`),t.key){case"SH":const r=await e.readStreamHeader(t.payloadLength);this.metadata.setFormat("numberOfSamples",r.sampleCount),this.metadata.setFormat("sampleRate",r.sampleFrequency),this.metadata.setFormat("duration",r.sampleCount/r.sampleFrequency),this.metadata.setFormat("numberOfChannels",r.channelCount);break;case"AP":this.audioLength+=t.payloadLength,await this.tokenizer.ignore(t.payloadLength);break;case"RG":case"EI":case"SO":case"ST":case"CT":await this.tokenizer.ignore(t.payloadLength);break;case"SE":return this.metadata.setFormat("bitrate",8*this.audioLength/this.metadata.format.duration),o.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options);default:throw new Error(`Unexpected header: ${t.key}`)}}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4),a=r(2)("music-metadata:parser:musepack:sv8"),s=new n.StringType(2,"binary"),o={len:5,get:(e,t)=>({crc:n.UINT32_LE.get(e,t),streamVersion:n.UINT8.get(e,t+4)})},c={len:2,get:(e,t)=>({sampleFrequency:[44100,48e3,37800,32e3][i.default.getBitAllignedNumber(e,t,0,3)],maxUsedBands:i.default.getBitAllignedNumber(e,t,3,5),channelCount:i.default.getBitAllignedNumber(e,t+1,0,4)+1,msUsed:i.default.isBitSet(e,t+1,4),audioBlockFrames:i.default.getBitAllignedNumber(e,t+1,5,3)})};t.StreamReader=class{constructor(e){this.tokenizer=e}async readPacketHeader(){const e=await this.tokenizer.readToken(s),t=await this.readVariableSizeField();return{key:e,payloadLength:t.value-2-t.len}}async readStreamHeader(e){const t={};a(`Reading SH at offset=${this.tokenizer.position}`);const r=await this.tokenizer.readToken(o);e-=o.len,Object.assign(t,r),a(`SH.streamVersion = ${r.streamVersion}`);const n=await this.readVariableSizeField();e-=n.len,t.sampleCount=n.value;const i=await this.readVariableSizeField();e-=i.len,t.beginningOfSilence=i.value;const s=await this.tokenizer.readToken(c);return e-=c.len,Object.assign(t,s),await this.tokenizer.ignore(e),t}async readVariableSizeField(e=1,t=0){let r=await this.tokenizer.readToken(n.UINT8);return 0==(128&r)?{len:e,value:t+r}:(r&=127,r+=t,this.readVariableSizeField(e+1,r<<7))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(6),a=r(7),s=r(252),o=r(23),c=r(253),u=n("music-metadata:parser:musepack");t.MpcSv7Parser=class extends a.BasicParser{constructor(){super(...arguments),this.audioLength=0}async parse(){const e=await this.tokenizer.readToken(s.Header);i.equal(e.signature,"MP+","Magic number"),u(`stream-version=${e.streamMajorVersion}.${e.streamMinorVersion}`),this.metadata.setFormat("container","Musepack, SV7"),this.metadata.setFormat("sampleRate",e.sampleFrequency);const t=1152*(e.frameCount-1)+e.lastFrameLength;this.metadata.setFormat("numberOfSamples",t),this.duration=t/e.sampleFrequency,this.metadata.setFormat("duration",this.duration),this.bitreader=new c.BitReader(this.tokenizer),this.metadata.setFormat("numberOfChannels",e.midSideStereo||e.intensityStereo?2:1);const r=await this.bitreader.read(8);return this.metadata.setFormat("codec",(r/100).toFixed(2)),await this.skipAudioData(e.frameCount),u(`End of audio stream, switching to APEv2, offset=${this.tokenizer.position}`),o.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options)}async skipAudioData(e){for(;e-- >0;){const e=await this.bitreader.read(20);this.audioLength+=20+e,await this.bitreader.ignore(e)}const t=await this.bitreader.read(11);this.audioLength+=t,this.metadata.setFormat("bitrate",this.audioLength/this.duration)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);t.Header={len:24,get:(e,t)=>{const r={signature:e.toString("binary",t,t+3),streamMinorVersion:i.default.getBitAllignedNumber(e,t+3,0,4),streamMajorVersion:i.default.getBitAllignedNumber(e,t+3,4,4),frameCount:n.UINT32_LE.get(e,t+4),maxLevel:n.UINT16_LE.get(e,t+8),sampleFrequency:[44100,48e3,37800,32e3][i.default.getBitAllignedNumber(e,t+10,0,2)],link:i.default.getBitAllignedNumber(e,t+10,2,2),profile:i.default.getBitAllignedNumber(e,t+10,4,4),maxBand:i.default.getBitAllignedNumber(e,t+11,0,6),intensityStereo:i.default.isBitSet(e,t+11,6),midSideStereo:i.default.isBitSet(e,t+11,7),titlePeak:n.UINT16_LE.get(e,t+12),titleGain:n.UINT16_LE.get(e,t+14),albumPeak:n.UINT16_LE.get(e,t+16),albumGain:n.UINT16_LE.get(e,t+18),lastFrameLength:n.UINT32_LE.get(e,t+20)>>>20&2047,trueGapless:i.default.isBitSet(e,t+23,0)};return r.lastFrameLength=r.trueGapless?n.UINT32_LE.get(e,20)>>>20&2047:0,r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.BitReader=class{constructor(e){this.tokenizer=e,this.pos=0,this.dword=void 0}async read(e){for(;void 0===this.dword;)this.dword=await this.tokenizer.readToken(n.UINT32_LE);let t=this.dword;return this.pos+=e,this.pos<32?(t>>>=32-this.pos)&(1<>>32-this.pos),t&(1<0){const t=32-this.pos;this.dword=void 0,e-=t,this.pos=0}const t=e%32,r=(e-t)/32;return await this.tokenizer.ignore(4*r),this.read(t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(6),s=r(4),o=r(5),c=r(31),u=r(255),l=r(257),d=r(7),f=r(259),p=i("music-metadata:parser:ogg");class h{static sum(e,t,r){let n=0;for(let i=t;i0)return this.warnings.push("Invalid FourCC ID, maybe last OGG-page is not marked with last-page flag"),this.pageConsumer.flush();throw e}}}m.Header={len:27,get:(e,t)=>({capturePattern:o.FourCcToken.get(e,t),version:e.readUInt8(t+4),headerType:{continued:s.default.strtokBITSET.get(e,t+5,0),firstPage:s.default.strtokBITSET.get(e,t+5,1),lastPage:s.default.strtokBITSET.get(e,t+5,2)},absoluteGranulePosition:e.readIntLE(t+6,6),streamSerialNumber:n.UINT32_LE.get(e,t+14),pageSequenceNo:n.UINT32_LE.get(e,t+18),pageChecksum:n.UINT32_LE.get(e,t+22),page_segments:e.readUInt8(t+26)})},t.OggParser=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(256),a=r(31);t.OpusParser=class extends a.VorbisParser{constructor(e,t,r){super(e,t),this.tokenizer=r,this.lastPos=-1}parseFirstPage(e,t){if(this.metadata.setFormat("codec","Opus"),this.idHeader=new i.IdHeader(t.length).get(t,0),"OpusHead"!==this.idHeader.magicSignature)throw new Error("Illegal ogg/Opus magic-signature");this.metadata.setFormat("sampleRate",this.idHeader.inputSampleRate),this.metadata.setFormat("numberOfChannels",this.idHeader.channelCount)}parseFullPage(e){switch(new n.StringType(8,"ascii").get(e,0)){case"OpusTags":this.parseUserCommentList(e,8),this.lastPos=this.tokenizer.position}}calculateDuration(e){if(this.metadata.format.sampleRate&&e.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",e.absoluteGranulePosition-this.idHeader.preSkip),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.idHeader.inputSampleRate),-1!==this.lastPos&&this.tokenizer.fileSize&&this.metadata.format.duration)){const e=this.tokenizer.fileSize-this.lastPos;this.metadata.setFormat("bitrate",8*e/this.metadata.format.duration)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.IdHeader=class{constructor(e){if(this.len=e,e<19)throw new Error("ID-header-page 0 should be at least 19 bytes long")}get(e,t){return{magicSignature:new n.StringType(8,"ascii").get(e,t+0),version:e.readUInt8(t+8),channelCount:e.readUInt8(t+9),preSkip:e.readInt16LE(t+10),inputSampleRate:e.readInt32LE(t+12),outputGain:e.readInt16LE(t+16),channelMapping:e.readUInt8(t+18)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(258),a=r(31),s=n("music-metadata:parser:ogg:speex");t.SpeexParser=class extends a.VorbisParser{constructor(e,t,r){super(e,t),this.tokenizer=r}parseFirstPage(e,t){s("First Ogg/Speex page");const r=i.Header.get(t,0);this.metadata.setFormat("codec",`Speex ${r.version}`),this.metadata.setFormat("numberOfChannels",r.nb_channels),this.metadata.setFormat("sampleRate",r.rate),-1!==r.bitrate&&this.metadata.setFormat("bitrate",r.bitrate)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);t.Header={len:80,get:(e,t)=>({speex:new n.StringType(8,"ascii").get(e,t+0),version:i.default.trimRightNull(new n.StringType(20,"ascii").get(e,t+8)),version_id:e.readInt32LE(t+28),header_size:e.readInt32LE(t+32),rate:e.readInt32LE(t+36),mode:e.readInt32LE(t+40),mode_bitstream_version:e.readInt32LE(t+44),nb_channels:e.readInt32LE(t+48),bitrate:e.readInt32LE(t+52),frame_size:e.readInt32LE(t+56),vbr:e.readInt32LE(t+60),frames_per_packet:e.readInt32LE(t+64),extra_headers:e.readInt32LE(t+68),reserved1:e.readInt32LE(t+72),reserved2:e.readInt32LE(t+76)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(260),a=n("music-metadata:parser:ogg:theora");t.TheoraParser=class{constructor(e,t,r){this.metadata=e,this.tokenizer=r}parsePage(e,t){e.headerType.firstPage&&this.parseFirstPage(e,t)}flush(){a("flush")}parseFirstPage(e,t){a("First Ogg/Theora page"),this.metadata.setFormat("codec","Theora");const r=i.IdentificationHeader.get(t,0);this.metadata.setFormat("bitrate",r.nombr)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.IdentificationHeader={len:42,get:(e,t)=>({id:new n.StringType(7,"ascii").get(e,t),vmaj:e.readUInt8(t+7),vmin:e.readUInt8(t+8),vrev:e.readUInt8(t+9),vmbw:e.readUInt16BE(t+10),vmbh:e.readUInt16BE(t+17),nombr:n.UINT24_BE.get(e,t+37),nqual:e.readUInt8(t+40)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(21),a=r(1),s=r(2),o=r(262),c=r(263),u=r(17),l=r(4),d=r(5),f=r(7),p=r(26),h=s("music-metadata:parser:RIFF");t.WaveParser=class extends f.BasicParser{async parse(){const e=await this.tokenizer.readToken(o.Header);if(h(`pos=${this.tokenizer.position}, parse: chunkID=${e.chunkID}`),"RIFF"===e.chunkID)return this.parseRiffChunk().catch(e=>{if(e.message!==n.endOfFile)throw e})}async parseRiffChunk(){const e=await this.tokenizer.readToken(d.FourCcToken);switch(this.metadata.setFormat("container",e),e){case"WAVE":return this.readWaveChunk();default:throw new Error(`Unsupported RIFF format: RIFF/${e}`)}}async readWaveChunk(){for(;;){const e=await this.tokenizer.readToken(o.Header);switch(this.header=e,h(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${e.chunkID}`),e.chunkID){case"LIST":await this.parseListTag(e);break;case"fact":this.metadata.setFormat("lossless",!1),this.fact=await this.tokenizer.readToken(new c.FactChunk(e));break;case"fmt ":const t=await this.tokenizer.readToken(new c.Format(e));let r=c.WaveFormat[t.wFormatTag];r||(h("WAVE/non-PCM format="+t.wFormatTag),r="non-PCM ("+t.wFormatTag+")"),this.metadata.setFormat("codec",r),this.metadata.setFormat("bitsPerSample",t.wBitsPerSample),this.metadata.setFormat("sampleRate",t.nSamplesPerSec),this.metadata.setFormat("numberOfChannels",t.nChannels),this.metadata.setFormat("bitrate",t.nBlockAlign*t.nSamplesPerSec*8),this.blockAlign=t.nBlockAlign;break;case"id3 ":case"ID3 ":const n=await this.tokenizer.readToken(new a.BufferType(e.chunkSize)),s=new p.ID3Stream(n),o=i.fromStream(s);await(new u.ID3v2Parser).parse(this.metadata,o,this.options);break;case"data":!1!==this.metadata.format.lossless&&this.metadata.setFormat("lossless",!0);const l=this.fact?this.fact.dwSampleLength:e.chunkSize/this.blockAlign;this.metadata.setFormat("numberOfSamples",l),this.metadata.setFormat("duration",l/this.metadata.format.sampleRate),this.metadata.setFormat("bitrate",this.metadata.format.numberOfChannels*this.blockAlign*this.metadata.format.sampleRate),await this.tokenizer.ignore(e.chunkSize);break;default:h(`Ignore chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.warnings.push("Ignore chunk: RIFF/"+e.chunkID),await this.tokenizer.ignore(e.chunkSize)}this.header.chunkSize%2==1&&(h("Read odd padding byte"),await this.tokenizer.ignore(1))}}async parseListTag(e){const t=await this.tokenizer.readToken(d.FourCcToken);switch(h("pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s",this.tokenizer.position,t),t){case"INFO":return this.parseRiffInfoTags(e.chunkSize-4);case"adtl":default:return this.warnings.push("Ignore chunk: RIFF/WAVE/LIST/"+t),h("Ignoring chunkID=RIFF/WAVE/LIST/"+t),this.tokenizer.ignore(e.chunkSize-4)}}async parseRiffInfoTags(e){for(;e>=8;){const t=await this.tokenizer.readToken(o.Header),r=new o.ListInfoTagValue(t),n=await this.tokenizer.readToken(r);this.addTag(t.chunkID,l.default.stripNulls(n)),e-=8+r.len}if(0!==e)throw Error("Illegal remaining size: "+e)}addTag(e,t){this.metadata.addTag("exif",e,t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.Header={len:8,get:(e,t)=>({chunkID:i.FourCcToken.get(e,t),chunkSize:e.readUInt32LE(t+4)})};t.ListInfoTagValue=class{constructor(e){this.tagHeader=e,this.len=e.chunkSize,this.len+=1&this.len}get(e,t){return new n.StringType(this.tagHeader.chunkSize,"ascii").get(e,t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6);!function(e){e[e.PCM=1]="PCM",e[e.ADPCM=2]="ADPCM",e[e.IEEE_FLOAT=3]="IEEE_FLOAT",e[e.MPEG_ADTS_AAC=5632]="MPEG_ADTS_AAC",e[e.MPEG_LOAS=5634]="MPEG_LOAS",e[e.RAW_AAC1=255]="RAW_AAC1",e[e.DOLBY_AC3_SPDIF=146]="DOLBY_AC3_SPDIF",e[e.DVM=8192]="DVM",e[e.RAW_SPORT=576]="RAW_SPORT",e[e.ESST_AC3=577]="ESST_AC3",e[e.DRM=9]="DRM",e[e.DTS2=8193]="DTS2",e[e.MPEG=80]="MPEG"}(t.WaveFormat||(t.WaveFormat={}));t.Format=class{constructor(e){n.ok(e.chunkSize>=16,"16 for PCM."),this.len=e.chunkSize}get(e,t){return{wFormatTag:e.readUInt16LE(t),nChannels:e.readUInt16LE(t+2),nSamplesPerSec:e.readUInt32LE(t+4),nAvgBytesPerSec:e.readUInt32LE(t+8),nBlockAlign:e.readUInt16LE(t+12),wBitsPerSample:e.readUInt16LE(t+14)}}};t.FactChunk=class{constructor(e){n.ok(e.chunkSize>=4,"minimum fact chunk size."),this.len=e.chunkSize}get(e,t){return{dwSampleLength:e.readUInt32LE(t)}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(6),a=r(23),s=r(5),o=r(7),c=r(265),u=r(2)("music-metadata:parser:WavPack");t.WavPackParser=class extends o.BasicParser{async parse(){return this.audioDataSize=0,await this.parseWavPackBlocks(),a.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options)}async parseWavPackBlocks(){do{if("wvpk"!==await this.tokenizer.peekToken(s.FourCcToken))break;const e=await this.tokenizer.readToken(c.WavPack.BlockHeaderToken);i.strictEqual(e.BlockID,"wvpk","WavPack Block-ID"),u(`WavPack header blockIndex=${e.blockIndex}, len=${c.WavPack.BlockHeaderToken.len}`),0!==e.blockIndex||this.metadata.format.container||(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!e.flags.isHybrid),this.metadata.setFormat("bitsPerSample",e.flags.bitsPerSample),e.flags.isDSD||(this.metadata.setFormat("sampleRate",e.flags.samplingRate),this.metadata.setFormat("duration",e.totalSamples/e.flags.samplingRate)),this.metadata.setFormat("numberOfChannels",e.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",e.totalSamples),this.metadata.setFormat("codec",e.flags.isDSD?"DSD":"PCM"));const t=e.blockSize-(c.WavPack.BlockHeaderToken.len-8);0===e.blockIndex?await this.parseMetadataSubBlock(e,t):await this.tokenizer.ignore(t),e.blockSamples>0&&(this.audioDataSize+=e.blockSize)}while(!this.tokenizer.fileSize||this.tokenizer.fileSize-this.tokenizer.position>=c.WavPack.BlockHeaderToken.len);this.metadata.setFormat("bitrate",8*this.audioDataSize/this.metadata.format.duration)}async parseMetadataSubBlock(t,r){for(;r>c.WavPack.MetadataIdToken.len;){const a=await this.tokenizer.readToken(c.WavPack.MetadataIdToken),s=await this.tokenizer.readNumber(a.largeBlock?n.UINT24_LE:n.UINT8),o=e.alloc(2*s-(a.isOddSize?1:0));switch(await this.tokenizer.readBuffer(o,0,o.length),u(`Metadata Sub-Blocks functionId=0x${a.functionId.toString(16)}, id.largeBlock=${a.largeBlock},data-size=${o.length}`),a.functionId){case 0:break;case 14:u("ID_DSD_BLOCK");const e=1<>>t&4294967295>>>32-r}}s.BlockHeaderToken={len:32,get:(e,t)=>{const r=n.UINT32_LE.get(e,t+24),o={BlockID:i.FourCcToken.get(e,t),blockSize:n.UINT32_LE.get(e,t+4),version:n.UINT16_LE.get(e,t+8),totalSamples:(n.UINT8.get(e,t+11)<<32)+n.UINT32_LE.get(e,t+12),blockIndex:(n.UINT8.get(e,t+10)<<32)+n.UINT32_LE.get(e,t+16),blockSamples:n.UINT32_LE.get(e,t+20),flags:{bitsPerSample:8*(1+s.getBitAllignedNumber(r,0,2)),isMono:s.isBitSet(r,2),isHybrid:s.isBitSet(r,3),isJointStereo:s.isBitSet(r,4),crossChannel:s.isBitSet(r,5),hybridNoiseShaping:s.isBitSet(r,6),floatingPoint:s.isBitSet(r,7),samplingRate:a[s.getBitAllignedNumber(r,23,4)],isDSD:s.isBitSet(r,31)},crc:new n.BufferType(4).get(e,t+28)};return o.flags.isDSD&&(o.totalSamples*=8),o}},s.MetadataIdToken={len:1,get:(e,t)=>({functionId:s.getBitAllignedNumber(e[t],0,6),isOptional:s.isBitSet(e[t],5),isOddSize:s.isBitSet(e[t],6),largeBlock:s.isBitSet(e[t],7)})},t.WavPack=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(24),i=r(6),a=r(2),s=r(267),o=r(17),c=a("music-metadata:parser:DSF");t.DsfParser=class extends n.AbstractID3Parser{async _parse(){const e=this.tokenizer.position,t=await this.tokenizer.readToken(s.ChunkHeader);i.strictEqual(t.id,"DSD ","Invalid chunk signature"),this.metadata.setFormat("container","DSF"),this.metadata.setFormat("lossless",!0);const r=await this.tokenizer.readToken(s.DsdChunk);if(0!==r.metadataPointer)return c(`expect ID3v2 at offset=${r.metadataPointer}`),await this.parseChunks(r.fileSize-t.size),await this.tokenizer.ignore(r.metadataPointer-this.tokenizer.position-e),(new o.ID3v2Parser).parse(this.metadata,this.tokenizer,this.options);c("No ID3v2 tag present")}async parseChunks(e){for(;e>=s.ChunkHeader.len;){const t=await this.tokenizer.readToken(s.ChunkHeader);switch(c(`Parsing chunk name=${t.id} size=${t.size}`),t.id){case"fmt ":const e=await this.tokenizer.readToken(s.FormatChunk);this.metadata.setFormat("numberOfChannels",e.channelNum),this.metadata.setFormat("sampleRate",e.samplingFrequency),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("numberOfSamples",e.sampleCount),this.metadata.setFormat("duration",e.sampleCount/e.samplingFrequency);const r=e.bitsPerSample*e.samplingFrequency*e.channelNum;return void this.metadata.setFormat("bitrate",r);default:this.tokenizer.ignore(t.size-s.ChunkHeader.len)}e-=t.size}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.ChunkHeader={len:12,get:(e,t)=>({id:i.FourCcToken.get(e,t),size:n.UINT64_LE.get(e,t+4)})},t.DsdChunk={len:16,get:(e,t)=>({fileSize:n.INT64_LE.get(e,t),metadataPointer:n.INT64_LE.get(e,t+8)})},function(e){e[e.mono=1]="mono",e[e.stereo=2]="stereo",e[e.channels=3]="channels",e[e.quad=4]="quad",e[e["4 channels"]=5]="4 channels",e[e["5 channels"]=6]="5 channels",e[e["5.1 channels"]=7]="5.1 channels"}(t.ChannelType||(t.ChannelType={})),t.FormatChunk={len:40,get:(e,t)=>({formatVersion:n.INT32_LE.get(e,t),formatID:n.INT32_LE.get(e,t+4),channelType:n.INT32_LE.get(e,t+8),channelNum:n.INT32_LE.get(e,t+12),samplingFrequency:n.INT32_LE.get(e,t+16),bitsPerSample:n.INT32_LE.get(e,t+20),sampleCount:n.INT64_LE.get(e,t+24),blockSizePerChannel:n.INT32_LE.get(e,t+32)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(1),a=r(2),s=r(5),o=r(7),c=r(26),u=r(269),l=r(21),d=r(17),f=a("music-metadata:parser:aiff");t.DsdiffParser=class extends o.BasicParser{async parse(){const e=await this.tokenizer.readToken(u.ChunkHeader);n.strictEqual(e.chunkID,"FRM8");const t=(await this.tokenizer.readToken(s.FourCcToken)).trim();switch(t){case"DSD":return this.metadata.setFormat("container",`DSDIFF/${t}`),this.metadata.setFormat("lossless",!0),this.readFmt8Chunks(e.chunkSize-s.FourCcToken.len);default:throw Error(`Unsupported DSDIFF type: ${t}`)}}async readFmt8Chunks(e){for(;e>=u.ChunkHeader.len;){const t=await this.tokenizer.readToken(u.ChunkHeader);f(`Chunk id=${t.chunkID}`),await this.readData(t),e-=u.ChunkHeader.len+t.chunkSize}}async readData(e){f(`Reading data of chunk[ID=${e.chunkID}, size=${e.chunkSize}]`);const t=this.tokenizer.position;switch(e.chunkID.trim()){case"FVER":const t=await this.tokenizer.readToken(i.UINT32_LE);f(`DSDIFF version=${t}`);break;case"PROP":const r=await this.tokenizer.readToken(s.FourCcToken);n.strictEqual(r,"SND "),await this.handleSoundPropertyChunks(e.chunkSize-s.FourCcToken.len);break;case"ID3":const a=await this.tokenizer.readToken(new i.BufferType(e.chunkSize)),o=new c.ID3Stream(a),u=l.fromStream(o);await(new d.ID3v2Parser).parse(this.metadata,u,this.options);break;default:f(`Ignore chunk[ID=${e.chunkID}, size=${e.chunkSize}]`);break;case"DSD":this.metadata.setFormat("numberOfSamples",8*e.chunkSize/this.metadata.format.numberOfChannels),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.metadata.format.sampleRate)}const r=e.chunkSize-(this.tokenizer.position-t);r>0&&(f(`After Parsing chunk, remaining ${r} bytes`),await this.tokenizer.ignore(r))}async handleSoundPropertyChunks(e){for(f(`Parsing sound-property-chunks, remainingSize=${e}`);e>0;){const t=await this.tokenizer.readToken(u.ChunkHeader);f(`Sound-property-chunk[ID=${t.chunkID}, size=${t.chunkSize}]`);const r=this.tokenizer.position;switch(t.chunkID.trim()){case"FS":const e=await this.tokenizer.readToken(i.UINT32_BE);this.metadata.setFormat("sampleRate",e);break;case"CHNL":const r=await this.tokenizer.readToken(i.UINT16_BE);this.metadata.setFormat("numberOfChannels",r),await this.handleChannelChunks(t.chunkSize-i.UINT16_BE.len);break;case"CMPR":const n=(await this.tokenizer.readToken(s.FourCcToken)).trim(),a=await this.tokenizer.readToken(i.UINT8),o=await this.tokenizer.readToken(new i.StringType(a,"ascii"));"DSD"===n&&(this.metadata.setFormat("lossless",!0),this.metadata.setFormat("bitsPerSample",1)),this.metadata.setFormat("codec",`${n} (${o})`);break;case"ABSS":const c=await this.tokenizer.readToken(i.UINT16_BE),u=await this.tokenizer.readToken(i.UINT8),l=await this.tokenizer.readToken(i.UINT8),d=await this.tokenizer.readToken(i.UINT32_BE);f(`ABSS ${c}:${u}:${l}.${d}`);break;case"LSCO":const p=await this.tokenizer.readToken(i.UINT16_BE);f(`LSCO lsConfig=${p}`);break;case"COMT":default:f(`Unknown sound-property-chunk[ID=${t.chunkID}, size=${t.chunkSize}]`),await this.tokenizer.ignore(t.chunkSize)}const n=t.chunkSize-(this.tokenizer.position-r);n>0&&(f(`After Parsing sound-property-chunk ${t.chunkSize}, remaining ${n} bytes`),await this.tokenizer.ignore(n)),e-=u.ChunkHeader.len+t.chunkSize,f(`Parsing sound-property-chunks, remainingSize=${e}`)}if(this.metadata.format.lossless&&this.metadata.format.sampleRate&&this.metadata.format.numberOfChannels&&this.metadata.format.bitsPerSample){const e=this.metadata.format.sampleRate*this.metadata.format.numberOfChannels*this.metadata.format.bitsPerSample;this.metadata.setFormat("bitrate",e)}}async handleChannelChunks(e){f(`Parsing channel-chunks, remainingSize=${e}`);const t=[];for(;e>=s.FourCcToken.len;){const r=await this.tokenizer.readToken(s.FourCcToken);f(`Channel[ID=${r}]`),t.push(r),e-=s.FourCcToken.len}return f(`Channels: ${t.join(", ")}`),t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.ChunkHeader={len:12,get:(e,t)=>({chunkID:i.FourCcToken.get(e,t),chunkSize:n.INT64_BE.get(e,t+4)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(36);t.ReadableWeToNodeStream=class extends n.Readable{constructor(e){super(),this.bytesRead=0,this.released=!1,this.reader=e.getReader()}async _read(){if(this.released)return void this.push(null);this.pendingRead=this.reader.read();const e=await this.pendingRead;delete this.pendingRead,e.done||this.released?this.push(null):(this.bytesRead+=e.value.length,this.push(e.value))}async waitForReadToComplete(){this.pendingRead&&await this.pendingRead}async close(){await this.syncAndRelease()}async syncAndRelease(){this.released=!0,await this.waitForReadToComplete(),await this.reader.releaseLock()}}},function(e,t,r){(function(t){var n=r(272).strict;e.exports=function(e){if(n(e)){var r=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(r=r.slice(e.byteOffset,e.byteOffset+e.byteLength)),r}return t.from(e)}}).call(this,r(3).Buffer)},function(e,t){e.exports=i,i.strict=a,i.loose=s;var r=Object.prototype.toString,n={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return n[r.call(e)]}}]);
\ No newline at end of file
diff --git a/public/js/ilab-media-grid.js b/public/js/ilab-media-grid.js
index 55656c91..b7865bf5 100755
--- a/public/js/ilab-media-grid.js
+++ b/public/js/ilab-media-grid.js
@@ -1 +1 @@
-!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=176)}({176:function(e,t,n){n(177),e.exports=n(319)},177:function(e,t){function n(e,t,n){return t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}!function(e){var t=function(){e(".info-panel-tabs").each(function(){var t=e(this),n=null,i=null;t.find("li").each(function(){var t=e(this),o=e("#"+t.data("tab-target"));t.hasClass("active")&&(n=t,i=o),t.on("click",function(e){n!=t&&(n.removeClass("active"),i.css({display:"none"}),t.addClass("active"),o.css({display:""}),n=t,i=o)})})});var t=null;e(".info-file-info-size").each(function(){t||(t=e(this))}),e("#ilab-other-sizes").on("change",function(n){var i=e("#info-size-"+e(this).val());i!=t&&(t.css({display:"none"}),i.css({display:""}),t=i)}),e(".ilab-info-regenerate-thumbnails").on("click",function(t){var n=e(this);return!(n.data("imgix-enabled")&&!confirm("You are currently using Imgix, which makes this function rather unnecessary. Are you sure you want to continue?"))&&(e(document).trigger("ilab-regeneration-started"),t.preventDefault(),n.css({display:"none"}),e("#ilab-info-regenerate-status").css({display:""}),e.post(ajaxurl,{action:"ilab_regenerate_thumbnails_manual",post_id:n.data("post-id")},function(t){n.css({display:""}),e("#ilab-info-regenerate-status").css({display:"none"}),"success"!=t.status&&alert("There was a problem trying to regenerate the thumbnails. Please try again."),e(document).trigger("ilab-regeneration-ended")}),!1)})};t();var i=!0,o=!0,a=e(''),s=e(''),r=e(''),l=e(''),u=e(''),d=null,c=!1,p=0,f=function(){if(i){var n=e(this),o=n.data("post-id");n.data("mime-type").startsWith("image")?s.removeClass("ilab-popup-document"):s.addClass("ilab-popup-document"),c=!1,e("li.attachment").each(function(){var t=e(this);t.data("id")==o?(t.removeClass("info-unfocused"),t.addClass("info-focused")):(t.removeClass("info-focused"),t.addClass("info-unfocused"))}),r.text(""),r.append(a);var p=this.getBoundingClientRect(),f=document.body.scrollTop+(p.top+p.height/2-s.height()/2);f-=28;var m=Math.max(document.documentElement.clientHeight,window.innerHeight||0),h=Math.max(document.documentElement.clientWidth,window.innerWidth||0),g=document.body.scrollTop+m-40,v=0;f+s.height()>g?(v=f+s.height()-g,f=g-s.height()):f=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}!function(e){var t=function(){e(".info-panel-tabs").each(function(){var t=e(this),n=null,i=null;t.find("li").each(function(){var t=e(this),o=e("#"+t.data("tab-target"));t.hasClass("active")&&(n=t,i=o),t.on("click",function(e){n!=t&&(n.removeClass("active"),i.css({display:"none"}),t.addClass("active"),o.css({display:""}),n=t,i=o)})})});var t=null;e(".info-file-info-size").each(function(){t||(t=e(this))}),e("#ilab-other-sizes").on("change",function(n){var i=e("#info-size-"+e(this).val());i!=t&&(t.css({display:"none"}),i.css({display:""}),t=i)}),e(".ilab-info-regenerate-thumbnails").on("click",function(t){var n=e(this);return!(n.data("imgix-enabled")&&!confirm("You are currently using Imgix, which makes this function rather unnecessary. Are you sure you want to continue?"))&&(e(document).trigger("ilab-regeneration-started"),t.preventDefault(),n.css({display:"none"}),e("#ilab-info-regenerate-status").css({display:""}),e.post(ajaxurl,{action:"ilab_regenerate_thumbnails_manual",post_id:n.data("post-id")},function(t){n.css({display:""}),e("#ilab-info-regenerate-status").css({display:"none"}),"success"!=t.status&&alert("There was a problem trying to regenerate the thumbnails. Please try again."),e(document).trigger("ilab-regeneration-ended")}),!1)})};t();var i=!0,o=!0,a=e(''),s=e(''),r=e(''),l=e(''),u=e(''),d=null,c=!1,p=0,f=function(){if(i){var n=e(this),o=n.data("post-id");n.data("mime-type").startsWith("image")?s.removeClass("ilab-popup-document"):s.addClass("ilab-popup-document"),c=!1,e("li.attachment").each(function(){var t=e(this);t.data("id")==o?(t.removeClass("info-unfocused"),t.addClass("info-focused")):(t.removeClass("info-focused"),t.addClass("info-unfocused"))}),r.text(""),r.append(a);var p=this.getBoundingClientRect(),f=document.body.scrollTop+(p.top+p.height/2-s.height()/2);f-=28;var m=Math.max(document.documentElement.clientHeight,window.innerHeight||0),h=Math.max(document.documentElement.clientWidth,window.innerWidth||0),g=document.body.scrollTop+m-40,v=0;f+s.height()>g?(v=f+s.height()-g,f=g-s.height()):f>4&15]+e[15&t]}}}},286:function(t,e,i){t.exports=i(287)},287:function(t,e,i){"use strict";i(288),i(290),jQuery(document).ready(function(t){t("ul#adminmenu a[href$='https://talk.mediacloud.press']").attr("target","_blank"),t("ul#adminmenu a[href$='https://help.mediacloud.press']").attr("target","_blank"),t(".ilab_ajax_admin_item").each(function(){var e=t(this).find("input[name=nonce]").val(),i=t(this).find("input[name=action]").val();t(this).on("click",function(a){a.preventDefault();var n={action:i,nonce:e};return t.post(ajaxurl,n,function(t){t.hasOwnProperty("message")?alert(t.message):document.location.reload()}),!1})})})},288:function(t,e,i){"use strict";i(289),window.ILabCrop=function(t,e){this.settings=e,this.modalContainer=t("#ilabm-container-"+e.modal_id),this.cropper=this.modalContainer.find(".ilabc-cropper"),this.cropperData={},this.modal_id=e.modal_id,this.aspectCheckboxContainer=t("#ilab-crop-aspect-checkbox-container"),this.aspectCheckboxContainer.css({visibility:"hidden"});var i=this;t("#ilab-crop-aspect-checkbox").on("change",function(t){i.settings.isCrop||(this.checked?i.cropper.cropper("setAspectRatio",i.settings.aspect_ratio):i.cropper.cropper("setAspectRatio",Number.NaN))}),this.modalContainer.find(".ilabm-editor-tabs").ilabTabs({currentValue:this.settings.size,tabSelected:function(t){ILabModal.loadURL(t.data("url"),!0,function(t){this.bindUI(t)}.bind(this))}.bind(this)}),this.modalContainer.find(".ilabc-button-crop").on("click",function(t){return t.preventDefault(),this.crop(),!1}.bind(this)),this.modalContainer.find(".ilabc-button-reset-crop").on("click",function(t){return t.preventDefault(),this.resetCrop(),!1}.bind(this)),this.updatePreviewWidth=function(){var t=this.modalContainer.find(".ilab-crop-preview-title").width();this.modalContainer.find(".ilab-crop-preview").css({height:t/this.settings.aspect_ratio+"px",width:t+"px"})}.bind(this),this.bindUI=function(e){if(this.settings=e,e.isCrop?this.aspectCheckboxContainer.css({visibility:"hidden"}):this.aspectCheckboxContainer.css({visibility:"visible"}),this.cropper.cropper("destroy"),this.cropper.off("built.cropper"),e.hasOwnProperty("cropped_src")&&null!==e.cropped_src&&this.modalContainer.find(".ilab-current-crop-img").attr("src",e.cropped_src),e.hasOwnProperty("size_title")&&null!==e.size_title&&this.modalContainer.find(".ilabc-crop-size-title").text("Current "+e.size_title+" ("+e.min_width+" x "+e.min_height+")"),void 0!==e.aspect_ratio){if(this.updatePreviewWidth(),void 0!==e.prev_crop_x&&null!==e.prev_crop_x)this.cropperData={x:e.prev_crop_x,y:e.prev_crop_y,width:e.prev_crop_width,height:e.prev_crop_height};else if(2==e.crop_axis.length){var i=0,a=0;"center"==e.crop_axis[0]?i=e.image_width/2-e.real_crop_width/2:"right"==e.crop_axis[0]&&(i=e.image_width-e.real_crop_width),"center"==e.crop_axis[1]?a=e.image_height/2-e.real_crop_height/2:"right"==e.crop_axis[1]&&(a=e.image_height-e.real_crop_height),this.cropperData={x:i,y:a,width:e.real_crop_width,height:e.real_crop_height}}var n=e.aspect_ratio;e.isCrop||t("#ilab-crop-aspect-checkbox")[0].checked||(n=Number.NaN),this.cropper.on("built.cropper",function(){this.updatePreviewWidth()}.bind(this)).on("crop.cropper",function(t){}).cropper({viewMode:1,dragMode:"none",aspectRatio:n,minWidth:e.min_width,minHeight:e.min_height,modal:!0,movable:!1,cropBoxMovable:!0,zoomable:!1,zoomOnWheel:!1,zoomOnTouch:!1,autoCropArea:1,data:this.cropperData,checkImageOrigin:!1,checkCrossOrigin:!1,responsive:!0,restore:!0,preview:"#ilabm-container-"+this.modal_id+" .ilab-crop-preview"})}}.bind(this),this.crop=function(){this.displayStatus("Saving crop ...");var t=this.cropper.cropper("getData");t.action="ilab_perform_crop",t.post=this.settings.image_id,t.size=this.settings.size,jQuery.post(ajaxurl,t,function(t){var e=this.modalContainer.find(".ilab-current-crop-img");"ok"==t.status?e.attr("src")==t.src?this.hideStatus():(e.one("load",function(){this.hideStatus()}.bind(this)),e.attr("src",t.src),wp.media.model.Attachments.all._byId[this.settings.image_id].get("sizes")[this.settings.size].url=t.src):this.hideStatus()}.bind(this))}.bind(this),this.resetCrop=function(){this.displayStatus("Resetting crop ..."),this.cropper.cropper("reset");var t=this.cropper.cropper("getData");t.action="ilab_reset_crop",t.post=this.settings.image_id,t.size=this.settings.size,jQuery.post(ajaxurl,t,function(t){var e=this.modalContainer.find(".ilab-current-crop-img");"ok"==t.status?e.attr("src")==t.src?this.hideStatus():(e.one("load",function(){this.hideStatus()}.bind(this)),e.attr("src",t.src),wp.media.model.Attachments.all._byId[this.settings.image_id].get("sizes")[this.settings.size].url=t.src):this.hideStatus()}.bind(this))}.bind(this),this.displayStatus=function(t){this.modalContainer.find(".ilabm-status-label").text(t),this.modalContainer.find(".ilabm-status-container").removeClass("is-hidden")}.bind(this),this.hideStatus=function(){this.modalContainer.find(".ilabm-status-container").addClass("is-hidden")}.bind(this),this.bindUI(e)}},289:function(t,e,i){var a,n,o,s;function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t){return(h="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}s=function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof window,i=e?window:{},a="cropper-hidden",n=i.PointerEvent?"pointerdown":"touchstart mousedown",o=i.PointerEvent?"pointermove":"touchmove mousemove",s=i.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",r=/^(?:e|w|s|n|se|sw|ne|nw|all|crop|move|zoom)$/,c=/^data:/,l=/^data:image\/jpeg;base64,/,d=/^(?:img|canvas)$/i,p={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},u="function"==typeof Symbol&&"symbol"===h(Symbol.iterator)?function(t){return h(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":h(t)},m=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},f=function(){function t(t,e){for(var i=0;i1?e-1:0),a=1;a0&&i.forEach(function(e){x(e)&&Object.keys(e).forEach(function(i){t[i]=e[i]})}),t},I=/\.\d*(?:0|9){12}\d*$/i;function S(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return I.test(t)?Math.round(t*e)/e:t}var B=/^(?:width|height|left|top|marginLeft|marginTop)$/;function P(t,e){var i=t.style;k(e,function(t,e){B.test(e)&&b(t)&&(t+="px"),i[e]=t})}function O(t,e){if(e)if(b(t.length))k(t,function(t){O(t,e)});else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className=i+" "+e):t.className=e}}function _(t,e){e&&(b(t.length)?k(t,function(t){_(t,e)}):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function T(t,e,i){e&&(b(t.length)?k(t,function(t){T(t,e,i)}):i?O(t,e):_(t,e))}var E=/([a-z\d])([A-Z])/g;function z(t){return t.replace(E,"$1-$2").toLowerCase()}function L(t,e){return x(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-"+z(e))}function W(t,e,i){x(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-"+z(e),i)}function A(t,e){if(x(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-"+z(e))}var N=/\s\s*/,j=function(){var t=!1;if(e){var a=!1,n=function(){},o=Object.defineProperty({},"once",{get:function(){return t=!0,a},set:function(t){a=t}});i.addEventListener("test",n,o),i.removeEventListener("test",n,o)}return t}();function H(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(N).forEach(function(e){if(!j){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)})}function R(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(N).forEach(function(e){if(a.once&&!j){var o=t.listeners,s=void 0===o?{}:o;n=function(){for(var o=arguments.length,r=Array(o),h=0;h1&&void 0!==arguments[1]?arguments[1]:"contain",o=function(t){return K(t)&&t>0};if(o(a)&&o(i)){var s=i*e;"contain"===n&&s>a||"cover"===n&&s=8&&(o=h+l)}}}if(o){var d=e.getUint16(o,a),p=void 0,u=void 0;for(u=0;ut.width?3===i?r=t.height*s:h=t.width/s:3===i?h=t.width/s:r=t.height*s;var c={aspectRatio:s,naturalWidth:n,naturalHeight:o,width:r,height:h};c.left=(t.width-r)/2,c.top=(t.height-h)/2,c.oldLeft=c.left,c.oldTop=c.top,this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),this.initialImageData=D({},e),this.initialCanvasData=D({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,s=i.viewMode,r=n.aspectRatio,h=this.cropped&&o;if(t){var c=Number(i.minCanvasWidth)||0,l=Number(i.minCanvasHeight)||0;s>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===s&&(l*r>c?c=l*r:l=c/r)):s>0&&(c?c=Math.max(c,h?o.width:0):l?l=Math.max(l,h?o.height:0):h&&(c=o.width,(l=o.height)*r>c?c=l*r:l=c/r));var d=Z({aspectRatio:r,width:c,height:l});c=d.width,l=d.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(s){var p=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,u),h&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===s&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=function(t){var e=t.width,i=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),s=Math.cos(n),r=e*s+i*o,h=e*o+i*s;return a>90?{width:h,height:r}:{width:r,height:h}}({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,s=n.height,r=i.width*(o/i.naturalWidth),h=i.height*(s/i.naturalHeight);i.left-=(r-i.width)/2,i.top-=(h-i.height)/2,i.width=r,i.height=h,i.aspectRatio=o/s,i.naturalWidth=o,i.naturalHeight=s,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.widthi.maxHeight||i.heighte.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=D({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,s=this.limited,r=i.aspectRatio;if(t){var h=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,l=Math.min(a.width,s?n.width:a.width),d=Math.min(a.height,s?n.height:a.height);h=Math.min(h,a.width),c=Math.min(c,a.height),r&&(h&&c?c*r>h?c=h/r:h=c*r:h?c=h/r:c&&(h=c*r),d*r>l?d=l/r:l=d*r),o.minWidth=Math.min(h,l),o.minHeight=Math.min(c,d),o.maxWidth=l,o.maxHeight=d}e&&(s?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.widthi.maxHeight||i.height=e.width&&i.height>=e.height?"move":"all"),P(this.cropBox,D({width:i.width,height:i.height},Q({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),X(this.element,"crop",this.getData())}},at={initPreview:function(){var t=this.crossOrigin,e=this.options.preview,i=t?this.crossOriginUrl:this.url,a=document.createElement("img");if(t&&(a.crossOrigin=t),a.src=i,this.viewBox.appendChild(a),this.viewBoxImage=a,e){var n=e;"string"==typeof e?n=this.element.ownerDocument.querySelectorAll(e):e.querySelector&&(n=[e]),this.previews=n,k(n,function(e){var a=document.createElement("img");W(e,"preview",{width:e.offsetWidth,height:e.offsetHeight,html:e.innerHTML}),t&&(a.crossOrigin=t),a.src=i,a.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',e.innerHTML="",e.appendChild(a)})}},resetPreview:function(){k(this.previews,function(t){var e=L(t,"preview");P(t,{width:e.width,height:e.height}),t.innerHTML=e.html,A(t,"preview")})},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,s=t.height,r=i.left-e.left-t.left,h=i.top-e.top-t.top;this.cropped&&!this.disabled&&(P(this.viewBoxImage,D({width:o,height:s},Q(D({translateX:-r,translateY:-h},t)))),k(this.previews,function(e){var i=L(e,"preview"),c=i.width,l=i.height,d=c,p=l,u=1;a&&(p=n*(u=c/a)),n&&p>l&&(d=a*(u=l/n),p=l),P(e,{width:d,height:p}),P(e.getElementsByTagName("img")[0],D({width:o*u,height:s*u},Q(D({translateX:-r*u,translateY:-h*u},t))))}))}},nt={bind:function(){var t=this.element,e=this.options,i=this.cropper;M(e.cropstart)&&R(t,"cropstart",e.cropstart),M(e.cropmove)&&R(t,"cropmove",e.cropmove),M(e.cropend)&&R(t,"cropend",e.cropend),M(e.crop)&&R(t,"crop",e.crop),M(e.zoom)&&R(t,"zoom",e.zoom),R(i,n,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&R(i,"wheel mousewheel DOMMouseScroll",this.onWheel=this.wheel.bind(this)),e.toggleDragModeOnDblclick&&R(i,"dblclick",this.onDblclick=this.dblclick.bind(this)),R(t.ownerDocument,o,this.onCropMove=this.cropMove.bind(this)),R(t.ownerDocument,s,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&R(window,"resize",this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;M(e.cropstart)&&H(t,"cropstart",e.cropstart),M(e.cropmove)&&H(t,"cropmove",e.cropmove),M(e.cropend)&&H(t,"cropend",e.cropend),M(e.crop)&&H(t,"crop",e.crop),M(e.zoom)&&H(t,"zoom",e.zoom),H(i,n,this.onCropStart),e.zoomable&&e.zoomOnWheel&&H(i,"wheel mousewheel DOMMouseScroll",this.onWheel),e.toggleDragModeOnDblclick&&H(i,"dblclick",this.onDblclick),H(t.ownerDocument,o,this.onCropMove),H(t.ownerDocument,s,this.onCropEnd),e.responsive&&H(window,"resize",this.onResize)}},ot={resize:function(){var t=this.options,e=this.container,i=this.containerData,a=Number(t.minContainerWidth)||200,n=Number(t.minContainerHeight)||100;if(!(this.disabled||i.width<=a||i.height<=n)){var o=e.offsetWidth/i.width;if(1!==o||e.offsetHeight!==i.height){var s=void 0,r=void 0;t.restore&&(s=this.getCanvasData(),r=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(k(s,function(t,e){s[e]=t*o})),this.setCropBoxData(k(r,function(t,e){r[e]=t*o})))}}},dblclick:function(){var t,e;this.disabled||"none"===this.options.dragMode||this.setDragMode((t=this.dragBox,e="cropper-crop",(t.classList?t.classList.contains(e):t.className.indexOf(e)>-1)?"move":"crop"))},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*i,t)))},cropStart:function(t){if(!this.disabled){var e=this.options,i=this.pointers,a=void 0;t.changedTouches?k(t.changedTouches,function(t){i[t.identifier]=$(t)}):i[t.pointerId||0]=$(t),a=Object.keys(i).length>1&&e.zoomable&&e.zoomOnTouch?"zoom":L(t.target,"action"),r.test(a)&&!1!==X(this.element,"cropstart",{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,"crop"===a&&(this.cropping=!0,O(this.dragBox,"cropper-modal")))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==X(this.element,"cropmove",{originalEvent:t,action:e})&&(t.changedTouches?k(t.changedTouches,function(t){D(i[t.identifier],$(t,!0))}):D(i[t.pointerId||0],$(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?k(t.changedTouches,function(t){delete i[t.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,T(this.dragBox,"cropper-modal",this.cropped&&this.options.modal)),X(this.element,"cropend",{originalEvent:t,action:e}))}}},st={change:function(t){var e=this.options,i=this.canvasData,n=this.containerData,o=this.cropBoxData,s=this.pointers,r=this.action,h=e.aspectRatio,c=o.left,l=o.top,d=o.width,p=o.height,u=c+d,m=l+p,f=0,g=0,v=n.width,b=n.height,w=!0,x=void 0;!h&&t.shiftKey&&(h=d&&p?d/p:1),this.limited&&(f=o.minLeft,g=o.minTop,v=f+Math.min(n.width,i.width,i.left+i.width),b=g+Math.min(n.height,i.height,i.top+i.height));var y=s[Object.keys(s)[0]],C={x:y.endX-y.startX,y:y.endY-y.startY},M=function(t){switch(t){case"e":u+C.x>v&&(C.x=v-u);break;case"w":c+C.xb&&(C.y=b-m)}};switch(r){case"all":c+=C.x,l+=C.y;break;case"e":if(C.x>=0&&(u>=v||h&&(l<=g||m>=b))){w=!1;break}M("e"),d+=C.x,h&&(p=d/h,l-=C.x/h/2),d<0&&(r="w",d=0);break;case"n":if(C.y<=0&&(l<=g||h&&(c<=f||u>=v))){w=!1;break}M("n"),p-=C.y,l+=C.y,h&&(d=p*h,c+=C.y*h/2),p<0&&(r="s",p=0);break;case"w":if(C.x<=0&&(c<=f||h&&(l<=g||m>=b))){w=!1;break}M("w"),d-=C.x,c+=C.x,h&&(p=d/h,l+=C.x/h/2),d<0&&(r="e",d=0);break;case"s":if(C.y>=0&&(m>=b||h&&(c<=f||u>=v))){w=!1;break}M("s"),p+=C.y,h&&(d=p*h,c-=C.y*h/2),p<0&&(r="n",p=0);break;case"ne":if(h){if(C.y<=0&&(l<=g||u>=v)){w=!1;break}M("n"),p-=C.y,l+=C.y,d=p*h}else M("n"),M("e"),C.x>=0?ug&&(p-=C.y,l+=C.y):(p-=C.y,l+=C.y);d<0&&p<0?(r="sw",p=0,d=0):d<0?(r="nw",d=0):p<0&&(r="se",p=0);break;case"nw":if(h){if(C.y<=0&&(l<=g||c<=f)){w=!1;break}M("n"),p-=C.y,l+=C.y,d=p*h,c+=C.y*h}else M("n"),M("w"),C.x<=0?c>f?(d-=C.x,c+=C.x):C.y<=0&&l<=g&&(w=!1):(d-=C.x,c+=C.x),C.y<=0?l>g&&(p-=C.y,l+=C.y):(p-=C.y,l+=C.y);d<0&&p<0?(r="se",p=0,d=0):d<0?(r="ne",d=0):p<0&&(r="sw",p=0);break;case"sw":if(h){if(C.x<=0&&(c<=f||m>=b)){w=!1;break}M("w"),d-=C.x,c+=C.x,p=d/h}else M("s"),M("w"),C.x<=0?c>f?(d-=C.x,c+=C.x):C.y>=0&&m>=b&&(w=!1):(d-=C.x,c+=C.x),C.y>=0?m=0&&(u>=v||m>=b)){w=!1;break}M("e"),p=(d+=C.x)/h}else M("s"),M("e"),C.x>=0?u=0&&m>=b&&(w=!1):d+=C.x,C.y>=0?m0?r=C.y>0?"se":"ne":C.x<0&&(c-=d,r=C.y>0?"sw":"nw"),C.y<0&&(l-=p),this.cropped||(_(this.cropBox,a),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}w&&(o.width=d,o.height=p,o.left=c,o.top=l,this.action=r,this.renderCropBox()),k(s,function(t){t.startX=t.endX,t.startY=t.endY})}},rt={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&O(this.dragBox,"cropper-modal"),_(this.cropBox,a),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=D({},this.initialImageData),this.canvasData=D({},this.initialCanvasData),this.cropBoxData=D({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(D(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),_(this.dragBox,"cropper-modal"),O(this.cropBox,a)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,k(this.previews,function(e){e.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,_(this.cropper,"cropper-disabled")),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,O(this.cropper,"cropper-disabled")),this},destroy:function(){var t=this.element;return L(t,"cropper")?(this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),A(t,"cropper"),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(w(t)?t:a+Number(t),w(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(b(t)&&(i.left=t,a=!0),b(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a=this.options,n=this.canvasData,o=n.width,s=n.height,r=n.naturalWidth,h=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var c=r*t,l=h*t;if(!1===X(this.element,"zoom",{originalEvent:i,oldRatio:o/r,ratio:c/r}))return this;if(i){var d=this.pointers,p=Y(this.cropper),u=d&&Object.keys(d).length?function(t){var e=0,i=0,a=0;return k(t,function(t){var n=t.startX,o=t.startY;e+=n,i+=o,a+=1}),{pageX:e/=a,pageY:i/=a}}(d):{pageX:i.pageX,pageY:i.pageY};n.left-=(c-o)*((u.pageX-p.left-n.left)/o),n.top-=(l-s)*((u.pageY-p.top-n.top)/s)}else C(e)&&b(e.x)&&b(e.y)?(n.left-=(c-o)*((e.x-n.left)/o),n.top-=(l-s)*((e.y-n.top)/s)):(n.left-=(c-o)/2,n.top-=(l-s)/2);n.width=c,n.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return b(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,b(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(b(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(b(t)&&(i.scaleX=t,a=!0),b(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.options,i=this.imageData,a=this.canvasData,n=this.cropBoxData,o=void 0;if(this.ready&&this.cropped){o={x:n.left-a.left,y:n.top-a.top,width:n.width,height:n.height};var s=i.width/i.naturalWidth;k(o,function(e,i){e/=s,o[i]=t?Math.round(e):e})}else o={x:0,y:0,width:0,height:0};return e.rotatable&&(o.rotate=i.rotate||0),e.scalable&&(o.scaleX=i.scaleX||1,o.scaleY=i.scaleY||1),o},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&C(t)){var o=!1;e.rotatable&&b(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(b(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),b(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var s=i.width/i.naturalWidth;b(t.x)&&(n.left=t.x*s+a.left),b(t.y)&&(n.top=t.y*s+a.top),b(t.width)&&(n.width=t.width*s),b(t.height)&&(n.height=t.height*s),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?D({},this.containerData):{}},getImageData:function(){return this.sized?D({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&k(["left","top","width","height","naturalWidth","naturalHeight"],function(i){e[i]=t[i]}),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&C(t)&&(b(t.left)&&(e.left=t.left),b(t.top)&&(e.top=t.top),b(t.width)?(e.width=t.width,e.height=t.width/i):b(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t=this.cropBoxData,e=void 0;return this.ready&&this.cropped&&(e={left:t.left,top:t.top,width:t.width,height:t.height}),e||{}},setCropBoxData:function(t){var e=this.cropBoxData,i=this.options.aspectRatio,a=void 0,n=void 0;return this.ready&&this.cropped&&!this.disabled&&C(t)&&(b(t.left)&&(e.left=t.left),b(t.top)&&(e.top=t.top),b(t.width)&&t.width!==e.width&&(a=!0,e.width=t.width),b(t.height)&&t.height!==e.height&&(n=!0,e.height=t.height),i&&(a?e.height=e.width/i:n&&(e.width=e.height*i)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=J(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(),n=a.x,o=a.y,s=a.width,r=a.height,h=i.width/Math.floor(e.naturalWidth);1!==h&&(n*=h,o*=h,s*=h,r*=h);var c=s/r,l=Z({aspectRatio:c,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),d=Z({aspectRatio:c,width:t.minWidth||0,height:t.minHeight||0},"cover"),p=Z({aspectRatio:c,width:t.width||(1!==h?i.width:s),height:t.height||(1!==h?i.height:r)}),u=p.width,m=p.height;u=Math.min(l.width,Math.max(d.width,u)),m=Math.min(l.height,Math.max(d.height,m));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=S(u),f.height=S(m),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,u,m);var b=t.imageSmoothingEnabled,w=void 0===b||b,x=t.imageSmoothingQuality;v.imageSmoothingEnabled=w,x&&(v.imageSmoothingQuality=x);var y=i.width,C=i.height,M=n,k=o,D=void 0,I=void 0,B=void 0,P=void 0,O=void 0,_=void 0;M<=-s||M>y?(M=0,D=0,B=0,O=0):M<=0?(B=-M,M=0,O=D=Math.min(y,s+M)):M<=y&&(B=0,O=D=Math.min(s,y-M)),D<=0||k<=-r||k>C?(k=0,I=0,P=0,_=0):k<=0?(P=-k,k=0,_=I=Math.min(C,r+k)):k<=C&&(P=0,_=I=Math.min(r,C-k));var T=[M,k,D,I];if(O>0&&_>0){var E=u/s;T.push(B*E,P*E,O*E,_*E)}return v.drawImage.apply(v,[i].concat(g(T.map(function(t){return Math.floor(S(t))})))),f},setAspectRatio:function(t){var e=this.options;return this.disabled||w(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n="crop"===t,o=e.movable&&"move"===t;t=n||o?t:"none",e.dragMode=t,W(i,"action",t),T(i,"cropper-crop",n),T(i,"cropper-move",o),e.cropBoxMovable||(W(a,"action",t),T(a,"cropper-crop",n),T(a,"cropper-move",o))}return this}},ht=i.Cropper,ct=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(m(this,t),!e||!d.test(e.tagName))throw new Error("The first argument is required and must be an or