javascript-ampache 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var e=Object.prototype.hasOwnProperty;function t(e){try{return encodeURIComponent(e)}catch(e){return null}}var s=function(s,r){r=r||"";var n,a,i=[];for(a in"string"!=typeof r&&(r="?"),s)if(e.call(s,a)){if((n=s[a])||null!=n&&!isNaN(n)||(n=""),a=t(a),n=t(n),null===a||null===n)continue;i.push(a+"="+n)}return i.length?r+i.join("&"):""},r={__proto__:null,default:function(e,t){return t=t||{},new Promise(function(s,r){var n=new XMLHttpRequest,a=[],i=[],u={},o=function(){return{ok:2==(n.status/100|0),statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:o,headers:{keys:function(){return a},entries:function(){return i},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var l in n.open(t.method||"get",e,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,s){a.push(t=t.toLowerCase()),i.push([t,s]),u[t]=u[t]?u[t]+","+s:s}),s(o())},n.onerror=r,n.withCredentials="include"==t.credentials,t.headers)n.setRequestHeader(l,t.headers[l]);n.send(t.body||null)})}},n=self.fetch||(self.fetch=r.default||r);class a{constructor(e){this.sessionKey=void 0,this.url=void 0,this.version="6.3.0",this.debug=void 0,this.sessionKey=e.sessionKey||null,this.url=e.url,this.debug=e.debug||!1}request(e){let t=this.url+"/server/json.server.php?action="+e+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+t,"color: black; font-style: italic; background-color: orange;padding: 2px"),n(t,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(e=>{if(e.ok)return e.json();throw new Error(e.statusText)})}binary(e){let t=this.url+"/server/json.server.php?action="+e+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+t,"color: black; font-style: italic; background-color: orange;padding: 2px"),n(t,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(e=>e.blob()).then(e=>e)}setSessionKey(e){this.sessionKey=e}}const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="ARRAYBUFFER not supported by this environment",o="UINT8ARRAY not supported by this environment";function l(e,t,s,r){let n,a,i;const u=t||[0],o=(s=s||0)>>>3,l=-1===r?3:0;for(n=0;n<e.length;n+=1)i=n+o,a=i>>>2,u.length<=a&&u.push(0),u[a]|=e[n]<<8*(l+r*(i%4));return{value:u,binLen:8*e.length+s}}function h(e,t,s){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,s,r){let n,a,i,u;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const o=t||[0],l=(s=s||0)>>>3,h=-1===r?3:0;for(n=0;n<e.length;n+=2){if(a=parseInt(e.substr(n,2),16),isNaN(a))throw new Error("String of HEX type contains invalid characters");for(u=(n>>>1)+l,i=u>>>2;o.length<=i;)o.push(0);o[i]|=a<<8*(h+r*(u%4))}return{value:o,binLen:4*e.length+s}}(e,t,r,s)};case"TEXT":return function(e,r,n){return function(e,t,s,r,n){let a,i,u,o,l,h,c,d,p=0;const f=s||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(c=-1===n?3:0,u=0;u<e.length;u+=1)for(a=e.charCodeAt(u),i=[],128>a?i.push(a):2048>a?(i.push(192|a>>>6),i.push(128|63&a)):55296>a||57344<=a?i.push(224|a>>>12,128|a>>>6&63,128|63&a):(u+=1,a=65536+((1023&a)<<10|1023&e.charCodeAt(u)),i.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|63&a)),o=0;o<i.length;o+=1){for(h=p+g,l=h>>>2;f.length<=l;)f.push(0);f[l]|=i[o]<<8*(c+n*(h%4)),p+=1}else for(c=-1===n?2:0,d="UTF16LE"===t&&1!==n||"UTF16LE"!==t&&1===n,u=0;u<e.length;u+=1){for(a=e.charCodeAt(u),!0===d&&(o=255&a,a=o<<8|a>>>8),h=p+g,l=h>>>2;f.length<=l;)f.push(0);f[l]|=a<<8*(c+n*(h%4)),p+=2}return{value:f,binLen:8*p+r}}(e,t,r,n,s)};case"B64":return function(e,t,r){return function(e,t,s,r){let n,a,u,o,l,h,c,d=0;const p=t||[0],f=(s=s||0)>>>3,g=-1===r?3:0,y=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==y&&y<e.length)throw new Error("Invalid '=' found in base-64 string");for(a=0;a<e.length;a+=4){for(l=e.substr(a,4),o=0,u=0;u<l.length;u+=1)n=i.indexOf(l.charAt(u)),o|=n<<18-6*u;for(u=0;u<l.length-1;u+=1){for(c=d+f,h=c>>>2;p.length<=h;)p.push(0);p[h]|=(o>>>16-8*u&255)<<8*(g+r*(c%4)),d+=1}}return{value:p,binLen:8*d+s}}(e,t,r,s)};case"BYTES":return function(e,t,r){return function(e,t,s,r){let n,a,i,u;const o=t||[0],l=(s=s||0)>>>3,h=-1===r?3:0;for(a=0;a<e.length;a+=1)n=e.charCodeAt(a),u=a+l,i=u>>>2,o.length<=i&&o.push(0),o[i]|=n<<8*(h+r*(u%4));return{value:o,binLen:8*e.length+s}}(e,t,r,s)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error(u)}return function(e,t,r){return function(e,t,s,r){return l(new Uint8Array(e),t,s,r)}(e,t,r,s)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error(o)}return function(e,t,r){return l(e,t,r,s)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function c(e,t,s,r){switch(e){case"HEX":return function(e){return function(e,t,s,r){const n="0123456789abcdef";let a,i,u="";const o=t/8,l=-1===s?3:0;for(a=0;a<o;a+=1)i=e[a>>>2]>>>8*(l+s*(a%4)),u+=n.charAt(i>>>4&15)+n.charAt(15&i);return r.outputUpper?u.toUpperCase():u}(e,t,s,r)};case"B64":return function(e){return function(e,t,s,r){let n,a,u,o,l,h="";const c=t/8,d=-1===s?3:0;for(n=0;n<c;n+=3)for(o=n+1<c?e[n+1>>>2]:0,l=n+2<c?e[n+2>>>2]:0,u=(e[n>>>2]>>>8*(d+s*(n%4))&255)<<16|(o>>>8*(d+s*((n+1)%4))&255)<<8|l>>>8*(d+s*((n+2)%4))&255,a=0;a<4;a+=1)h+=8*n+6*a<=t?i.charAt(u>>>6*(3-a)&63):r.b64Pad;return h}(e,t,s,r)};case"BYTES":return function(e){return function(e,t,s){let r,n,a="";const i=t/8,u=-1===s?3:0;for(r=0;r<i;r+=1)n=e[r>>>2]>>>8*(u+s*(r%4))&255,a+=String.fromCharCode(n);return a}(e,t,s)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error(u)}return function(e){return function(e,t,s){let r;const n=t/8,a=new ArrayBuffer(n),i=new Uint8Array(a),u=-1===s?3:0;for(r=0;r<n;r+=1)i[r]=e[r>>>2]>>>8*(u+s*(r%4))&255;return a}(e,t,s)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error(o)}return function(e){return function(e,t,s){let r;const n=t/8,a=-1===s?3:0,i=new Uint8Array(n);for(r=0;r<n;r+=1)i[r]=e[r>>>2]>>>8*(a+s*(r%4))&255;return i}(e,t,s)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],p=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],f=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function g(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},s=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=s.outputUpper||!1,s.b64Pad&&(t.b64Pad=s.b64Pad),s.outputLen){if(s.outputLen%8!=0)throw new Error(r);t.outputLen=s.outputLen}else if(s.shakeLen){if(s.shakeLen%8!=0)throw new Error(r);t.outputLen=s.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}class y{constructor(e,t,s){const r=s||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.U=[],this.R=[]}update(e){let t,s=0;const r=this.T>>>5,n=this.F(e,this.h,this.u),a=n.binLen,i=n.value,u=a>>>5;for(t=0;t<u;t+=r)s+this.T<=a&&(this.m=this.g(i.slice(t,t+r),this.m),s+=this.T);return this.A+=s,this.h=i.slice(s>>>5),this.u=a%this.T,this.l=!0,this}getHash(e,t){let s,r,n=this.H;const a=g(t);if(this.B){if(-1===a.outputLen)throw new Error("Output length must be specified in options");n=a.outputLen}const i=c(e,n,this.v,a);if(this.p&&this.C)return i(this.C(a));for(r=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),n),s=1;s<this.numRounds;s+=1)this.B&&n%32!=0&&(r[r.length-1]&=16777215>>>24-n%32),r=this.Y(r,n,0,this.I(this.o),n);return i(r)}setHMACKey(e,t,s){if(!this.L)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=h(t,(s||{}).encoding||"UTF8",this.v);this.M(r(e))}M(e){const t=this.T>>>3,s=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.Y(e.value,e.binLen,0,this.I(this.o),this.H));e.value.length<=s;)e.value.push(0);for(r=0;r<=s;r+=1)this.U[r]=909522486^e.value[r],this.R[r]=1549556828^e.value[r];this.m=this.g(this.U,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const s=g(t);return c(e,this.H,this.v,s)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),this.H);return e=this.g(this.R,this.I(this.o)),e=this.Y(t,this.H,this.T,e,this.H),e}}function w(e,t){return e>>>t|e<<32-t}function m(e,t){return e>>>t}function q(e,t,s){return e&t^~e&s}function _(e,t,s){return e&t^e&s^t&s}function b(e){return w(e,2)^w(e,13)^w(e,22)}function v(e,t){const s=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(s>>>16))<<16|65535&s}function A(e,t,s,r){const n=(65535&e)+(65535&t)+(65535&s)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(s>>>16)+(r>>>16)+(n>>>16))<<16|65535&n}function E(e,t,s,r,n){const a=(65535&e)+(65535&t)+(65535&s)+(65535&r)+(65535&n);return(65535&(e>>>16)+(t>>>16)+(s>>>16)+(r>>>16)+(n>>>16)+(a>>>16))<<16|65535&a}function R(e){return w(e,7)^w(e,18)^m(e,3)}function T(e){return w(e,6)^w(e,11)^w(e,25)}function U(e){let t;return t="SHA-224"==e?p.slice():f.slice(),t}function k(e,t){let s,r,n,a,i,u,o,l,h,c,p;const f=[];for(s=t[0],r=t[1],n=t[2],a=t[3],i=t[4],u=t[5],o=t[6],l=t[7],p=0;p<64;p+=1)f[p]=p<16?e[p]:A(w(g=f[p-2],17)^w(g,19)^m(g,10),f[p-7],R(f[p-15]),f[p-16]),h=E(l,T(i),q(i,u,o),d[p],f[p]),c=v(b(s),_(s,r,n)),l=o,o=u,u=i,i=v(a,h),a=n,n=r,r=s,s=v(h,c);var g;return t[0]=v(s,t[0]),t[1]=v(r,t[1]),t[2]=v(n,t[2]),t[3]=v(a,t[3]),t[4]=v(i,t[4]),t[5]=v(u,t[5]),t[6]=v(o,t[6]),t[7]=v(l,t[7]),t}class S extends y{constructor(e,t,s){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,s);const r=s||{};this.C=this.N,this.L=!0,this.v=-1,this.F=h(this.t,this.i,this.v),this.g=k,this.S=function(e){return e.slice()},this.I=U,this.Y=function(t,s,r,n){return function(e,t,s,r,n){let a,i;const u=15+(t+65>>>9<<4),o=t+s;for(;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&o,e[u-1]=o/4294967296|0,a=0;a<e.length;a+=16)r=k(e.slice(a,a+16),r);return i="SHA-224"===n?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,i}(t,s,r,n,e)},this.m=U(e),this.T=512,this.H="SHA-224"===e?224:256,this.B=!1,r.hmacKey&&this.M(function(e,t,s,r){const n="hmacKey must include a value and format";if(!t)throw new Error(n);if(void 0===t.value||!t.format)throw new Error(n);return h(t.format,t.encoding||"UTF8",s)(t.value)}(0,r.hmacKey,this.v))}}class x extends a{}var C,L;C=x,L=[class extends a{async albums(e){let t="albums";t+=s(e,"&");let r=await this.request(t);return r.album?r.album:r}album(e){let t="album";return t+=s(e,"&"),this.request(t)}async artistAlbums(e){let t="artist_albums";t+=s(e,"&");let r=await this.request(t);return r.album?r.album:r}async genreAlbums(e){let t="genre_albums";t+=s(e,"&");let r=await this.request(t);return r.album?r.album:r}},class extends a{async artists(e){let t="artists";t+=s(e,"&");let r=await this.request(t);return r.artist?r.artist:r}artist(e){let t="artist";return t+=s(e,"&"),this.request(t)}async genreArtists(e){let t="genre_artists";t+=s(e,"&");let r=await this.request(t);return r.artist?r.artist:r}async labelArtists(e){let t="label_artists";t+=s(e,"&");let r=await this.request(t);return r.artist?r.artist:r}},class extends a{handshake(e){e.timestamp||(e.timestamp=Math.floor((new Date).getTime()/1e3)),e.version&&(this.version=e.version),e.user||delete e.timestamp;let t=this.url+"/server/json.server.php?action=handshake";return t+=s(e,"&"),n(t).then(e=>e.json()).then(e=>(e.auth&&(this.sessionKey=e.auth),e))}ping(e){let t="ping";return t+=s(e,"&"),this.request(t)}goodbye(e){let t="goodbye";return t+=s(e,"&"),this.request(t)}lostPassword(e){let t="lost_password";return t+=s(e,"&"),this.request(t)}encryptPassword(e){let t=s(e.password);return s(e.time+t);function s(e){let t=new S("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("HEX")}}},class extends a{async bookmark(e){let t="bookmark";return t+=s(e,"&"),this.request(t)}async bookmarks(e){let t="bookmarks";t+=s(e,"&");let r=await this.request(t);return r.bookmark?r.bookmark:r}getBookmark(e){let t="get_bookmark";return t+=s(e,"&"),this.request(t)}bookmarkCreate(e){let t="bookmark_create";return t+=s(e,"&"),this.request(t)}bookmarkEdit(e){let t="bookmark_edit";return t+=s(e,"&"),this.request(t)}bookmarkDelete(e){let t="bookmark_delete";return t+=s(e,"&"),this.request(t)}},class extends a{async catalogs(e){let t="catalogs";t+=s(e,"&");let r=await this.request(t);return r.catalog?r.catalog:r}catalog(e){let t="catalog";return t+=s(e,"&"),this.request(t)}catalogAction(e){let t="catalog_action";return t+=s(e,"&"),this.request(t)}catalogFile(e){let t="catalog_file";return t+=s(e,"&"),this.request(t)}catalogAdd(e){let t="catalog_add";return t+=s(e,"&"),this.request(t)}catalogDelete(e){let t="catalog_delete";return t+=s(e,"&"),this.request(t)}},class extends a{async genres(e){let t="genres";t+=s(e,"&");let r=await this.request(t);return r.genre?r.genre:r}async genre(e){let t="genre";return t+=s(e,"&"),this.request(t)}},class extends a{async labels(e){let t="labels";t+=s(e,"&");let r=await this.request(t);return r.label?r.label:r}label(e){let t="label";return t+=s(e,"&"),this.request(t)}},class extends a{async licenses(e){let t="licenses";t+=s(e,"&");let r=await this.request(t);return r.license?r.license:r}license(e){let t="license";return t+=s(e,"&"),this.request(t)}},class extends a{async liveStreams(e){let t="live_streams";t+=s(e,"&");let r=await this.request(t);return r.live_stream?r.live_stream:r}liveStream(e){let t="live_stream";return t+=s(e,"&"),this.request(t)}liveStreamCreate(e){let t="live_stream_create";return t+=s(e,"&"),this.request(t)}liveStreamEdit(e){let t="live_stream_edit";return t+=s(e,"&"),this.request(t)}liveStreamDelete(e){let t="live_stream_delete";return t+=s(e,"&"),this.request(t)}},class extends a{async playlists(e){let t="playlists";t+=s(e,"&");let r=await this.request(t);return r.playlist?r.playlist:r}async smartlists(e){let t="playlists";t+=s(e,"&");let r=await this.request(t),n=r.playlist?r.playlist:r;return Array.isArray(n)&&(n=n.filter(function(e){return e.id.toString().match(/^smart_/)})),n}playlist(e){let t="playlist";return t+=s(e,"&"),this.request(t)}async userPlaylists(e){let t="user_playlists";t+=s(e,"&");let r=await this.request(t);return r.playlist?r.playlist:r}async userSmartlists(e){let t="user_smartlists";t+=s(e,"&");let r=await this.request(t);return r.playlist?r.playlist:r}playlistCreate(e){let t="playlist_create";return t+=s(e,"&"),this.request(t)}playlistAdd(e){let t="playlist_add";return t+=s(e,"&"),this.request(t)}playlistEdit(e){let t="playlist_edit";return t+=s(e,"&"),this.request(t)}playlistDelete(e){let t="playlist_delete";return t+=s(e,"&"),this.request(t)}playlistAddSong(e){let t="playlist_add_song";return t+=s(e,"&"),this.request(t)}playlistRemoveSong(e){let t="playlist_remove_song";return t+=s(e,"&"),this.request(t)}async playlistGenerate(e){let t="playlist_generate";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}},class extends a{async podcasts(e){let t="podcasts";t+=s(e,"&");let r=await this.request(t);return r.podcast?r.podcast:r}async podcast(e){let t="podcast";return t+=s(e,"&"),this.request(t)}podcastCreate(e){let t="podcast_create";return t+=s(e,"&"),this.request(t)}podcastEdit(e){let t="podcast_edit";return t+=s(e,"&"),this.request(t)}podcastDelete(e){let t="podcast_delete";return t+=s(e,"&"),this.request(t)}async podcastEpisodes(e){let t="podcast_episodes";t+=s(e,"&");let r=await this.request(t);return r.podcast_episode?r.podcast_episode:r}podcastEpisode(e){let t="podcast_episode";return t+=s(e,"&"),this.request(t)}podcastEpisodeDelete(e){let t="podcast_episode_delete";return t+=s(e,"&"),this.request(t)}updatePodcast(e){let t="update_podcast";return t+=s(e,"&"),this.request(t)}async deletedPodcastEpisodes(e){let t="deleted_podcast_episodes";t+=s(e,"&");let r=await this.request(t);return r.deleted_podcast_episode?r.deleted_podcast_episode:r}},class extends a{async systemPreferences(){let e=await this.request("system_preferences");return e.preference?e.preference:e}async systemPreference(e){let t="system_preference";return t+=s(e,"&"),await this.request(t)}async userPreferences(){let e=await this.request("user_preferences");return e.preference?e.preference:e}async userPreference(e){let t="user_preference";return t+=s(e,"&"),await this.request(t)}preferenceCreate(e){let t="preference_create";return t+=s(e,"&"),this.request(t)}preferenceEdit(e){let t="preference_edit";return t+=s(e,"&"),this.request(t)}preferenceDelete(e){let t="preference_delete";return t+=s(e,"&"),this.request(t)}},class extends a{async shares(e){let t="shares";t+=s(e,"&");let r=await this.request(t);return r.share?r.share:r}share(e){let t="share";return t+=s(e,"&"),this.request(t)}shareCreate(e){let t="share_create";return t+=s(e,"&"),this.request(t)}shareEdit(e){let t="share_edit";return t+=s(e,"&"),this.request(t)}shareDelete(e){let t="share_delete";return t+=s(e,"&"),this.request(t)}},class extends a{async last_shouts(e){let t="last_shouts";t+=s(e,"&");let r=await this.request(t);return r.shout?r.shout:r}},class extends a{async songs(e){let t="songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}song(e){let t="song";return t+=s(e,"&"),this.request(t)}async artistSongs(e){let t="artist_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async albumSongs(e){let t="album_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async genreSongs(e){let t="genre_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async playlistSongs(e){let t="playlist_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async licenseSongs(e){let t="license_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}songDelete(e){let t="song_delete";return t+=s(e,"&"),this.request(t)}urlToSong(e){let t="url_to_song";return e.url=encodeURIComponent(e.url),t+=s(e,"&"),this.request(t)}async searchSongs(e){let t="search_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async deletedSongs(e){let t="deleted_songs";t+=s(e,"&");let r=await this.request(t);return r.deleted_song?r.deleted_song:r}},class extends a{systemUpdate(){return this.request("system_update")}async getIndexes(e){let t,r="get_indexes";switch(r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"album":return t=await this.request(r),t.album?t.album:t;case"artist":case"album_artist":return t=await this.request(r),t.artist?t.artist:t;case"playlist":return t=await this.request(r),t.playlist?t.playlist:t;case"podcast":return t=await this.request(r),t.podcast?t.podcast:t;case"podcast_episode":return t=await this.request(r),t.podcast_episode?t.podcast_episode:t;case"live_stream":return t=await this.request(r),t.live_stream?t.live_stream:t;default:return!1}}async list(e){let t="list";return t+=s(e,"&"),this.request(t)}async index(e){let t="index";return t+=s(e,"&"),this.request(t)}async browse(e){let t="browse";return t+=s(e,"&"),this.request(t)}async getSimilar(e){let t,r="get_similar";switch(r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"artist":return t=await this.request(r),t.artist?t.artist:t;default:return!1}}async stats(e){let t,r="stats";switch(r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"album":return t=await this.request(r),t.album?t.album:t;case"artist":return t=await this.request(r),t.artist?t.artist:t;case"video":return t=await this.request(r),t.video?t.video:t;case"playlist":return t=await this.request(r),t.playlist?t.playlist:t;case"podcast":return t=await this.request(r),t.podcast?t.podcast:t;case"podcast_episode":return t=await this.request(r),t.podcast_episode?t.podcast_episode:t;default:return!1}}rate(e){let t="rate";return t+=s(e,"&"),this.request(t)}flag(e){let t="flag";return t+=s(e,"&"),this.request(t)}recordPlay(e){let t="record_play";return t+=s(e,"&"),this.request(t)}scrobble(e){let t="scrobble";return t+=s(e,"&"),this.request(t)}updateFromTags(e){let t="update_from_tags";return t+=s(e,"&"),this.request(t)}updateArtistInfo(e){let t="update_artist_info";return t+=s(e,"&"),this.request(t)}updateArt(e){let t="update_art";return t+=s(e,"&"),this.request(t)}stream(e){let t="stream";return t+=s(e,"&"),this.binary(t)}download(e){let t="download";return t+=s(e,"&"),this.binary(t)}getArt(e){let t="get_art";return t+=s(e,"&"),this.binary(t)}localplay(e){let t="localplay";return t+=s(e,"&"),this.request(t)}localplaySongs(){return this.request("localplay_songs")}democratic(e){let t="democratic";return t+=s(e,"&"),this.request(t)}async advancedSearch(e){let t,r="advanced_search";for(let t=0;t<e.rules.length;t++){const s=e.rules[t],r=t+1;e["rule_"+r]=s[0],e["rule_"+r+"_operator"]=s[1],e["rule_"+r+"_input"]=s[2],"metadata"===s[0]&&(e["rule_"+r+"_subtype"]=s[3])}switch(delete e.rules,r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"album":return t=await this.request(r),t.album?t.album:t;case"artist":case"album_artist":case"song_artist":return t=await this.request(r),t.artist?t.artist:t;case"label":return t=await this.request(r),t.label?t.label:t;case"playlist":return t=await this.request(r),t.playlist?t.playlist:t;case"podcast":return t=await this.request(r),t.podcast?t.podcast:t;case"podcast_episode":return t=await this.request(r),t.podcast_episode?t.podcast_episode:t;case"genre":return t=await this.request(r),t.genre?t.genre:t;case"user":return t=await this.request(r),t.user?t.user:t;case"video":return t=await this.request(r),t.video?t.video:t;default:return!1}}},class extends a{async users(){let e=await this.request("users");return e.user?e.user:e}async user(e){let t="user";return t+=s(e,"&"),await this.request(t)}userCreate(e){let t="user_create";return t+=s(e,"&"),this.request(t)}register(e){let t="register";return t+=s(e,"&"),this.request(t)}userUpdate(e){let t="user_update";return t+=s(e,"&"),this.request(t)}userEdit(e){let t="user_edit";return t+=s(e,"&"),this.request(t)}userDelete(e){let t="user_delete";return t+=s(e,"&"),this.request(t)}async followers(e){let t="followers";t+=s(e,"&");let r=await this.request(t);return r.user?r.user:r}async following(e){let t="following";t+=s(e,"&");let r=await this.request(t);return r.user?r.user:r}toggleFollow(e){let t="toggle_follow";return t+=s(e,"&"),this.request(t)}async timeline(e){let t="timeline";t+=s(e,"&");let r=await this.request(t);return r.activity?r.activity:r}async friendsTimeline(e){let t="friends_timeline";t+=s(e,"&");let r=await this.request(t);return r.activity?r.activity:r}},class extends a{async videos(e){let t="videos";t+=s(e,"&");let r=await this.request(t);return r.video?r.video:r}video(e){let t="video";return t+=s(e,"&"),this.request(t)}async deletedVideos(e){let t="deleted_videos";t+=s(e,"&");let r=await this.request(t);return r.deleted_video?r.deleted_video:r}}],L.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(t=>{Object.defineProperty(C.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t))})});export{x as default};
1
+ var e=Object.prototype.hasOwnProperty;function t(e){try{return encodeURIComponent(e)}catch(e){return null}}var s=function(s,r){r=r||"";var n,i,a=[];for(i in"string"!=typeof r&&(r="?"),s)if(e.call(s,i)){if((n=s[i])||null!=n&&!isNaN(n)||(n=""),i=t(i),n=t(n),null===i||null===n)continue;a.push(i+"="+n)}return a.length?r+a.join("&"):""},r={__proto__:null,default:function(e,t){return t=t||{},new Promise(function(s,r){var n=new XMLHttpRequest,i=[],a=[],u={},o=function(){return{ok:2==(n.status/100|0),statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:o,headers:{keys:function(){return i},entries:function(){return a},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var l in n.open(t.method||"get",e,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,s){i.push(t=t.toLowerCase()),a.push([t,s]),u[t]=u[t]?u[t]+","+s:s}),s(o())},n.onerror=r,n.withCredentials="include"==t.credentials,t.headers)n.setRequestHeader(l,t.headers[l]);n.send(t.body||null)})}},n=self.fetch||(self.fetch=r.default||r);class i{constructor(e){this.sessionKey=void 0,this.url=void 0,this.version="6.3.0",this.debug=void 0,this.sessionKey=e.sessionKey||null,this.url=e.url,this.debug=e.debug||!1}request(e){let t=this.url+"/server/json.server.php?action="+e+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+t+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),n(t,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(e=>{if(e.ok)return e.json();throw new Error(e.statusText)})}binary(e){let t=this.url+"/server/json.server.php?action="+e+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+t+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),n(t,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(e=>e.blob()).then(e=>e)}setSessionKey(e){this.sessionKey=e}}const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="ARRAYBUFFER not supported by this environment",o="UINT8ARRAY not supported by this environment";function l(e,t,s,r){let n,i,a;const u=t||[0],o=(s=s||0)>>>3,l=-1===r?3:0;for(n=0;n<e.length;n+=1)a=n+o,i=a>>>2,u.length<=i&&u.push(0),u[i]|=e[n]<<8*(l+r*(a%4));return{value:u,binLen:8*e.length+s}}function h(e,t,s){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,s,r){let n,i,a,u;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const o=t||[0],l=(s=s||0)>>>3,h=-1===r?3:0;for(n=0;n<e.length;n+=2){if(i=parseInt(e.substr(n,2),16),isNaN(i))throw new Error("String of HEX type contains invalid characters");for(u=(n>>>1)+l,a=u>>>2;o.length<=a;)o.push(0);o[a]|=i<<8*(h+r*(u%4))}return{value:o,binLen:4*e.length+s}}(e,t,r,s)};case"TEXT":return function(e,r,n){return function(e,t,s,r,n){let i,a,u,o,l,h,c,d,p=0;const f=s||[0],g=(r=r||0)>>>3;if("UTF8"===t)for(c=-1===n?3:0,u=0;u<e.length;u+=1)for(i=e.charCodeAt(u),a=[],128>i?a.push(i):2048>i?(a.push(192|i>>>6),a.push(128|63&i)):55296>i||57344<=i?a.push(224|i>>>12,128|i>>>6&63,128|63&i):(u+=1,i=65536+((1023&i)<<10|1023&e.charCodeAt(u)),a.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),o=0;o<a.length;o+=1){for(h=p+g,l=h>>>2;f.length<=l;)f.push(0);f[l]|=a[o]<<8*(c+n*(h%4)),p+=1}else for(c=-1===n?2:0,d="UTF16LE"===t&&1!==n||"UTF16LE"!==t&&1===n,u=0;u<e.length;u+=1){for(i=e.charCodeAt(u),!0===d&&(o=255&i,i=o<<8|i>>>8),h=p+g,l=h>>>2;f.length<=l;)f.push(0);f[l]|=i<<8*(c+n*(h%4)),p+=2}return{value:f,binLen:8*p+r}}(e,t,r,n,s)};case"B64":return function(e,t,r){return function(e,t,s,r){let n,i,u,o,l,h,c,d=0;const p=t||[0],f=(s=s||0)>>>3,g=-1===r?3:0,y=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==y&&y<e.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<e.length;i+=4){for(l=e.substr(i,4),o=0,u=0;u<l.length;u+=1)n=a.indexOf(l.charAt(u)),o|=n<<18-6*u;for(u=0;u<l.length-1;u+=1){for(c=d+f,h=c>>>2;p.length<=h;)p.push(0);p[h]|=(o>>>16-8*u&255)<<8*(g+r*(c%4)),d+=1}}return{value:p,binLen:8*d+s}}(e,t,r,s)};case"BYTES":return function(e,t,r){return function(e,t,s,r){let n,i,a,u;const o=t||[0],l=(s=s||0)>>>3,h=-1===r?3:0;for(i=0;i<e.length;i+=1)n=e.charCodeAt(i),u=i+l,a=u>>>2,o.length<=a&&o.push(0),o[a]|=n<<8*(h+r*(u%4));return{value:o,binLen:8*e.length+s}}(e,t,r,s)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error(u)}return function(e,t,r){return function(e,t,s,r){return l(new Uint8Array(e),t,s,r)}(e,t,r,s)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error(o)}return function(e,t,r){return l(e,t,r,s)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function c(e,t,s,r){switch(e){case"HEX":return function(e){return function(e,t,s,r){const n="0123456789abcdef";let i,a,u="";const o=t/8,l=-1===s?3:0;for(i=0;i<o;i+=1)a=e[i>>>2]>>>8*(l+s*(i%4)),u+=n.charAt(a>>>4&15)+n.charAt(15&a);return r.outputUpper?u.toUpperCase():u}(e,t,s,r)};case"B64":return function(e){return function(e,t,s,r){let n,i,u,o,l,h="";const c=t/8,d=-1===s?3:0;for(n=0;n<c;n+=3)for(o=n+1<c?e[n+1>>>2]:0,l=n+2<c?e[n+2>>>2]:0,u=(e[n>>>2]>>>8*(d+s*(n%4))&255)<<16|(o>>>8*(d+s*((n+1)%4))&255)<<8|l>>>8*(d+s*((n+2)%4))&255,i=0;i<4;i+=1)h+=8*n+6*i<=t?a.charAt(u>>>6*(3-i)&63):r.b64Pad;return h}(e,t,s,r)};case"BYTES":return function(e){return function(e,t,s){let r,n,i="";const a=t/8,u=-1===s?3:0;for(r=0;r<a;r+=1)n=e[r>>>2]>>>8*(u+s*(r%4))&255,i+=String.fromCharCode(n);return i}(e,t,s)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error(u)}return function(e){return function(e,t,s){let r;const n=t/8,i=new ArrayBuffer(n),a=new Uint8Array(i),u=-1===s?3:0;for(r=0;r<n;r+=1)a[r]=e[r>>>2]>>>8*(u+s*(r%4))&255;return i}(e,t,s)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error(o)}return function(e){return function(e,t,s){let r;const n=t/8,i=-1===s?3:0,a=new Uint8Array(n);for(r=0;r<n;r+=1)a[r]=e[r>>>2]>>>8*(i+s*(r%4))&255;return a}(e,t,s)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const d=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],p=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],f=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function g(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},s=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=s.outputUpper||!1,s.b64Pad&&(t.b64Pad=s.b64Pad),s.outputLen){if(s.outputLen%8!=0)throw new Error(r);t.outputLen=s.outputLen}else if(s.shakeLen){if(s.shakeLen%8!=0)throw new Error(r);t.outputLen=s.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}class y{constructor(e,t,s){const r=s||{};if(this.t=t,this.i=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=e,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.U=[],this.R=[]}update(e){let t,s=0;const r=this.T>>>5,n=this.F(e,this.h,this.u),i=n.binLen,a=n.value,u=i>>>5;for(t=0;t<u;t+=r)s+this.T<=i&&(this.m=this.g(a.slice(t,t+r),this.m),s+=this.T);return this.A+=s,this.h=a.slice(s>>>5),this.u=i%this.T,this.l=!0,this}getHash(e,t){let s,r,n=this.H;const i=g(t);if(this.B){if(-1===i.outputLen)throw new Error("Output length must be specified in options");n=i.outputLen}const a=c(e,n,this.v,i);if(this.p&&this.C)return a(this.C(i));for(r=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),n),s=1;s<this.numRounds;s+=1)this.B&&n%32!=0&&(r[r.length-1]&=16777215>>>24-n%32),r=this.Y(r,n,0,this.I(this.o),n);return a(r)}setHMACKey(e,t,s){if(!this.L)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const r=h(t,(s||{}).encoding||"UTF8",this.v);this.M(r(e))}M(e){const t=this.T>>>3,s=t/4-1;let r;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.Y(e.value,e.binLen,0,this.I(this.o),this.H));e.value.length<=s;)e.value.push(0);for(r=0;r<=s;r+=1)this.U[r]=909522486^e.value[r],this.R[r]=1549556828^e.value[r];this.m=this.g(this.U,this.m),this.A=this.T,this.p=!0}getHMAC(e,t){const s=g(t);return c(e,this.H,this.v,s)(this.N())}N(){let e;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),this.H);return e=this.g(this.R,this.I(this.o)),e=this.Y(t,this.H,this.T,e,this.H),e}}function w(e,t){return e>>>t|e<<32-t}function m(e,t){return e>>>t}function q(e,t,s){return e&t^~e&s}function _(e,t,s){return e&t^e&s^t&s}function b(e){return w(e,2)^w(e,13)^w(e,22)}function v(e,t){const s=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(s>>>16))<<16|65535&s}function A(e,t,s,r){const n=(65535&e)+(65535&t)+(65535&s)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(s>>>16)+(r>>>16)+(n>>>16))<<16|65535&n}function E(e,t,s,r,n){const i=(65535&e)+(65535&t)+(65535&s)+(65535&r)+(65535&n);return(65535&(e>>>16)+(t>>>16)+(s>>>16)+(r>>>16)+(n>>>16)+(i>>>16))<<16|65535&i}function R(e){return w(e,7)^w(e,18)^m(e,3)}function T(e){return w(e,6)^w(e,11)^w(e,25)}function U(e){let t;return t="SHA-224"==e?p.slice():f.slice(),t}function k(e,t){let s,r,n,i,a,u,o,l,h,c,p;const f=[];for(s=t[0],r=t[1],n=t[2],i=t[3],a=t[4],u=t[5],o=t[6],l=t[7],p=0;p<64;p+=1)f[p]=p<16?e[p]:A(w(g=f[p-2],17)^w(g,19)^m(g,10),f[p-7],R(f[p-15]),f[p-16]),h=E(l,T(a),q(a,u,o),d[p],f[p]),c=v(b(s),_(s,r,n)),l=o,o=u,u=a,a=v(i,h),i=n,n=r,r=s,s=v(h,c);var g;return t[0]=v(s,t[0]),t[1]=v(r,t[1]),t[2]=v(n,t[2]),t[3]=v(i,t[3]),t[4]=v(a,t[4]),t[5]=v(u,t[5]),t[6]=v(o,t[6]),t[7]=v(l,t[7]),t}class S extends y{constructor(e,t,s){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error("Chosen SHA variant is not supported");super(e,t,s);const r=s||{};this.C=this.N,this.L=!0,this.v=-1,this.F=h(this.t,this.i,this.v),this.g=k,this.S=function(e){return e.slice()},this.I=U,this.Y=function(t,s,r,n){return function(e,t,s,r,n){let i,a;const u=15+(t+65>>>9<<4),o=t+s;for(;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&o,e[u-1]=o/4294967296|0,i=0;i<e.length;i+=16)r=k(e.slice(i,i+16),r);return a="SHA-224"===n?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,a}(t,s,r,n,e)},this.m=U(e),this.T=512,this.H="SHA-224"===e?224:256,this.B=!1,r.hmacKey&&this.M(function(e,t,s,r){const n="hmacKey must include a value and format";if(!t)throw new Error(n);if(void 0===t.value||!t.format)throw new Error(n);return h(t.format,t.encoding||"UTF8",s)(t.value)}(0,r.hmacKey,this.v))}}class x extends i{}var C,L;C=x,L=[class extends i{async albums(e){let t="albums";t+=s(e,"&");let r=await this.request(t);return r.album?r.album:r}album(e){let t="album";return t+=s(e,"&"),this.request(t)}async artistAlbums(e){let t="artist_albums";t+=s(e,"&");let r=await this.request(t);return r.album?r.album:r}async genreAlbums(e){let t="genre_albums";t+=s(e,"&");let r=await this.request(t);return r.album?r.album:r}},class extends i{async artists(e){let t="artists";t+=s(e,"&");let r=await this.request(t);return r.artist?r.artist:r}artist(e){let t="artist";return t+=s(e,"&"),this.request(t)}async genreArtists(e){let t="genre_artists";t+=s(e,"&");let r=await this.request(t);return r.artist?r.artist:r}async labelArtists(e){let t="label_artists";t+=s(e,"&");let r=await this.request(t);return r.artist?r.artist:r}},class extends i{handshake(e){e.timestamp||(e.timestamp=Math.floor((new Date).getTime()/1e3)),e.version&&(this.version=e.version),e.user||delete e.timestamp;let t=this.url+"/server/json.server.php?action=handshake";return t+=s(e,"&"),n(t).then(e=>e.json()).then(e=>(e.auth&&(this.sessionKey=e.auth),e))}ping(e){let t="ping";return t+=s(e,"&"),this.request(t)}goodbye(e){let t="goodbye";return t+=s(e,"&"),this.request(t)}lostPassword(e){let t="lost_password";return t+=s(e,"&"),this.request(t)}encryptPassword(e){let t=s(e.password);return s(e.time+t);function s(e){let t=new S("SHA-256","TEXT",{encoding:"UTF8"});return t.update(e),t.getHash("HEX")}}},class extends i{async bookmark(e){let t="bookmark";return t+=s(e,"&"),this.request(t)}async bookmarks(e){let t="bookmarks";t+=s(e,"&");let r=await this.request(t);return r.bookmark?r.bookmark:r}getBookmark(e){let t="get_bookmark";return t+=s(e,"&"),this.request(t)}bookmarkCreate(e){let t="bookmark_create";return t+=s(e,"&"),this.request(t)}bookmarkEdit(e){let t="bookmark_edit";return t+=s(e,"&"),this.request(t)}bookmarkDelete(e){let t="bookmark_delete";return t+=s(e,"&"),this.request(t)}},class extends i{async catalogs(e){let t="catalogs";t+=s(e,"&");let r=await this.request(t);return r.catalog?r.catalog:r}catalog(e){let t="catalog";return t+=s(e,"&"),this.request(t)}catalogAction(e){let t="catalog_action";return t+=s(e,"&"),this.request(t)}catalogFile(e){let t="catalog_file";return t+=s(e,"&"),this.request(t)}catalogAdd(e){let t="catalog_add";return t+=s(e,"&"),this.request(t)}catalogDelete(e){let t="catalog_delete";return t+=s(e,"&"),this.request(t)}},class extends i{async genres(e){let t="genres";t+=s(e,"&");let r=await this.request(t);return r.genre?r.genre:r}async genre(e){let t="genre";return t+=s(e,"&"),this.request(t)}},class extends i{async labels(e){let t="labels";t+=s(e,"&");let r=await this.request(t);return r.label?r.label:r}label(e){let t="label";return t+=s(e,"&"),this.request(t)}},class extends i{async licenses(e){let t="licenses";t+=s(e,"&");let r=await this.request(t);return r.license?r.license:r}license(e){let t="license";return t+=s(e,"&"),this.request(t)}},class extends i{async liveStreams(e){let t="live_streams";t+=s(e,"&");let r=await this.request(t);return r.live_stream?r.live_stream:r}liveStream(e){let t="live_stream";return t+=s(e,"&"),this.request(t)}liveStreamCreate(e){let t="live_stream_create";return t+=s(e,"&"),this.request(t)}liveStreamEdit(e){let t="live_stream_edit";return t+=s(e,"&"),this.request(t)}liveStreamDelete(e){let t="live_stream_delete";return t+=s(e,"&"),this.request(t)}},class extends i{async playlists(e){let t="playlists";t+=s(e,"&");let r=await this.request(t);return r.playlist?r.playlist:r}async smartlists(e){let t="playlists";t+=s(e,"&");let r=await this.request(t),n=r.playlist?r.playlist:r;return Array.isArray(n)&&(n=n.filter(function(e){return e.id.toString().match(/^smart_/)})),n}playlist(e){let t="playlist";return t+=s(e,"&"),this.request(t)}async userPlaylists(e){let t="user_playlists";t+=s(e,"&");let r=await this.request(t);return r.playlist?r.playlist:r}async userSmartlists(e){let t="user_smartlists";t+=s(e,"&");let r=await this.request(t);return r.playlist?r.playlist:r}playlistCreate(e){let t="playlist_create";return t+=s(e,"&"),this.request(t)}playlistAdd(e){let t="playlist_add";return t+=s(e,"&"),this.request(t)}playlistEdit(e){let t="playlist_edit";return t+=s(e,"&"),this.request(t)}playlistDelete(e){let t="playlist_delete";return t+=s(e,"&"),this.request(t)}playlistAddSong(e){let t="playlist_add_song";return t+=s(e,"&"),this.request(t)}playlistRemoveSong(e){let t="playlist_remove_song";return t+=s(e,"&"),this.request(t)}async playlistGenerate(e){let t="playlist_generate";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}},class extends i{async podcasts(e){let t="podcasts";t+=s(e,"&");let r=await this.request(t);return r.podcast?r.podcast:r}async podcast(e){let t="podcast";return t+=s(e,"&"),this.request(t)}podcastCreate(e){let t="podcast_create";return t+=s(e,"&"),this.request(t)}podcastEdit(e){let t="podcast_edit";return t+=s(e,"&"),this.request(t)}podcastDelete(e){let t="podcast_delete";return t+=s(e,"&"),this.request(t)}async podcastEpisodes(e){let t="podcast_episodes";t+=s(e,"&");let r=await this.request(t);return r.podcast_episode?r.podcast_episode:r}podcastEpisode(e){let t="podcast_episode";return t+=s(e,"&"),this.request(t)}podcastEpisodeDelete(e){let t="podcast_episode_delete";return t+=s(e,"&"),this.request(t)}updatePodcast(e){let t="update_podcast";return t+=s(e,"&"),this.request(t)}async deletedPodcastEpisodes(e){let t="deleted_podcast_episodes";t+=s(e,"&");let r=await this.request(t);return r.deleted_podcast_episode?r.deleted_podcast_episode:r}},class extends i{async systemPreferences(){let e=await this.request("system_preferences");return e.preference?e.preference:e}async systemPreference(e){let t="system_preference";return t+=s(e,"&"),await this.request(t)}async userPreferences(){let e=await this.request("user_preferences");return e.preference?e.preference:e}async userPreference(e){let t="user_preference";return t+=s(e,"&"),await this.request(t)}preferenceCreate(e){let t="preference_create";return t+=s(e,"&"),this.request(t)}preferenceEdit(e){let t="preference_edit";return t+=s(e,"&"),this.request(t)}preferenceDelete(e){let t="preference_delete";return t+=s(e,"&"),this.request(t)}},class extends i{async shares(e){let t="shares";t+=s(e,"&");let r=await this.request(t);return r.share?r.share:r}share(e){let t="share";return t+=s(e,"&"),this.request(t)}shareCreate(e){let t="share_create";return t+=s(e,"&"),this.request(t)}shareEdit(e){let t="share_edit";return t+=s(e,"&"),this.request(t)}shareDelete(e){let t="share_delete";return t+=s(e,"&"),this.request(t)}},class extends i{async last_shouts(e){let t="last_shouts";t+=s(e,"&");let r=await this.request(t);return r.shout?r.shout:r}},class extends i{async songs(e){let t="songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}song(e){let t="song";return t+=s(e,"&"),this.request(t)}async artistSongs(e){let t="artist_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async albumSongs(e){let t="album_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async genreSongs(e){let t="genre_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async playlistSongs(e){let t="playlist_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async licenseSongs(e){let t="license_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}songDelete(e){let t="song_delete";return t+=s(e,"&"),this.request(t)}urlToSong(e){let t="url_to_song";return e.url=encodeURIComponent(e.url),t+=s(e,"&"),this.request(t)}async searchSongs(e){let t="search_songs";t+=s(e,"&");let r=await this.request(t);return r.song?r.song:r}async deletedSongs(e){let t="deleted_songs";t+=s(e,"&");let r=await this.request(t);return r.deleted_song?r.deleted_song:r}},class extends i{systemUpdate(){return this.request("system_update")}async getIndexes(e){let t,r="get_indexes";switch(r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"album":return t=await this.request(r),t.album?t.album:t;case"artist":case"album_artist":return t=await this.request(r),t.artist?t.artist:t;case"playlist":return t=await this.request(r),t.playlist?t.playlist:t;case"podcast":return t=await this.request(r),t.podcast?t.podcast:t;case"podcast_episode":return t=await this.request(r),t.podcast_episode?t.podcast_episode:t;case"live_stream":return t=await this.request(r),t.live_stream?t.live_stream:t;default:return!1}}async list(e){let t="list";return t+=s(e,"&"),this.request(t)}async index(e){let t="index";return t+=s(e,"&"),this.request(t)}async browse(e){let t="browse";return t+=s(e,"&"),this.request(t)}async getSimilar(e){let t,r="get_similar";switch(r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"artist":return t=await this.request(r),t.artist?t.artist:t;default:return!1}}async stats(e){let t,r="stats";switch(r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"album":return t=await this.request(r),t.album?t.album:t;case"artist":return t=await this.request(r),t.artist?t.artist:t;case"video":return t=await this.request(r),t.video?t.video:t;case"playlist":return t=await this.request(r),t.playlist?t.playlist:t;case"podcast":return t=await this.request(r),t.podcast?t.podcast:t;case"podcast_episode":return t=await this.request(r),t.podcast_episode?t.podcast_episode:t;default:return!1}}rate(e){let t="rate";return t+=s(e,"&"),this.request(t)}flag(e){let t="flag";return t+=s(e,"&"),this.request(t)}recordPlay(e){let t="record_play";return t+=s(e,"&"),this.request(t)}scrobble(e){let t="scrobble";return t+=s(e,"&"),this.request(t)}updateFromTags(e){let t="update_from_tags";return t+=s(e,"&"),this.request(t)}updateArtistInfo(e){let t="update_artist_info";return t+=s(e,"&"),this.request(t)}updateArt(e){let t="update_art";return t+=s(e,"&"),this.request(t)}stream(e){let t="stream";return t+=s(e,"&"),this.binary(t)}download(e){let t="download";return t+=s(e,"&"),this.binary(t)}getArt(e){let t="get_art";return t+=s(e,"&"),this.binary(t)}localplay(e){let t="localplay";return t+=s(e,"&"),this.request(t)}localplaySongs(){return this.request("localplay_songs")}democratic(e){let t="democratic";return t+=s(e,"&"),this.request(t)}async advancedSearch(e){let t,r="advanced_search";for(let t=0;t<e.rules.length;t++){const s=e.rules[t],r=t+1;e["rule_"+r]=s[0],e["rule_"+r+"_operator"]=s[1],e["rule_"+r+"_input"]=s[2],"metadata"===s[0]&&(e["rule_"+r+"_subtype"]=s[3])}switch(delete e.rules,r+=s(e,"&"),e.type){case"song":return t=await this.request(r),t.song?t.song:t;case"album":return t=await this.request(r),t.album?t.album:t;case"artist":case"album_artist":case"song_artist":return t=await this.request(r),t.artist?t.artist:t;case"label":return t=await this.request(r),t.label?t.label:t;case"playlist":return t=await this.request(r),t.playlist?t.playlist:t;case"podcast":return t=await this.request(r),t.podcast?t.podcast:t;case"podcast_episode":return t=await this.request(r),t.podcast_episode?t.podcast_episode:t;case"genre":return t=await this.request(r),t.genre?t.genre:t;case"user":return t=await this.request(r),t.user?t.user:t;case"video":return t=await this.request(r),t.video?t.video:t;default:return!1}}},class extends i{async users(){let e=await this.request("users");return e.user?e.user:e}async user(e){let t="user";return t+=s(e,"&"),await this.request(t)}userCreate(e){let t="user_create";return t+=s(e,"&"),this.request(t)}register(e){let t="register";return t+=s(e,"&"),this.request(t)}userUpdate(e){let t="user_update";return t+=s(e,"&"),this.request(t)}userEdit(e){let t="user_edit";return t+=s(e,"&"),this.request(t)}userDelete(e){let t="user_delete";return t+=s(e,"&"),this.request(t)}async followers(e){let t="followers";t+=s(e,"&");let r=await this.request(t);return r.user?r.user:r}async following(e){let t="following";t+=s(e,"&");let r=await this.request(t);return r.user?r.user:r}toggleFollow(e){let t="toggle_follow";return t+=s(e,"&"),this.request(t)}async timeline(e){let t="timeline";t+=s(e,"&");let r=await this.request(t);return r.activity?r.activity:r}async friendsTimeline(e){let t="friends_timeline";t+=s(e,"&");let r=await this.request(t);return r.activity?r.activity:r}},class extends i{async videos(e){let t="videos";t+=s(e,"&");let r=await this.request(t);return r.video?r.video:r}video(e){let t="video";return t+=s(e,"&"),this.request(t)}async deletedVideos(e){let t="deleted_videos";t+=s(e,"&");let r=await this.request(t);return r.deleted_video?r.deleted_video:r}}],L.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(t=>{Object.defineProperty(C.prototype,t,Object.getOwnPropertyDescriptor(e.prototype,t))})});export{x as default};
2
2
  //# sourceMappingURL=index.modern.mjs.map