From 62c0f30ee2ab6e76336fed814329169456bdd85a Mon Sep 17 00:00:00 2001 From: camdendotlol Date: Sat, 7 Sep 2024 21:45:20 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20camdendo?= =?UTF-8?q?tlol/topstersorg@19406b0497ce38861d174d652bfd9adbca5870c3=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/{index-CZ7L4NLy.js => index-C9um7C3L.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-CZ7L4NLy.js => index-C9um7C3L.js} (99%) diff --git a/assets/index-CZ7L4NLy.js b/assets/index-C9um7C3L.js similarity index 99% rename from assets/index-CZ7L4NLy.js rename to assets/index-C9um7C3L.js index 8dac223..7423827 100644 --- a/assets/index-CZ7L4NLy.js +++ b/assets/index-C9um7C3L.js @@ -18,7 +18,7 @@ * vuex v4.1.0 * (c) 2022 Evan You * @license MIT - */var Wo="store";function _c(t){return t===void 0&&(t=null),tn(t!==null?t:Wo)}function Be(t,e){Object.keys(t).forEach(function(n){return e(t[n],n)})}function bc(t){return t!==null&&typeof t=="object"}function yc(t){return t&&typeof t.then=="function"}function wc(t,e){return function(){return t(e)}}function Ko(t,e,n){return e.indexOf(t)<0&&(n&&n.prepend?e.unshift(t):e.push(t)),function(){var r=e.indexOf(t);r>-1&&e.splice(r,1)}}function Jo(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var n=t.state;Hn(t,n,[],t._modules.root,!0),Nr(t,n,e)}function Nr(t,e,n){var r=t._state,s=t._scope;t.getters={},t._makeLocalGettersCache=Object.create(null);var o=t._wrappedGetters,i={},l={},a=ki(!0);a.run(function(){Be(o,function(d,c){i[c]=wc(d,t),l[c]=Bn(function(){return i[c]()}),Object.defineProperty(t.getters,c,{get:function(){return l[c].value},enumerable:!0})})}),t._state=Ln({data:e}),t._scope=a,t.strict&&Tc(t),r&&n&&t._withCommit(function(){r.data=null}),s&&s.stop()}function Hn(t,e,n,r,s){var o=!n.length,i=t._modules.getNamespace(n);if(r.namespaced&&(t._modulesNamespaceMap[i],t._modulesNamespaceMap[i]=r),!o&&!s){var l=Br(e,n.slice(0,-1)),a=n[n.length-1];t._withCommit(function(){l[a]=r.state})}var d=r.context=xc(t,i,n);r.forEachMutation(function(c,h){var p=i+h;Cc(t,p,c,d)}),r.forEachAction(function(c,h){var p=c.root?h:i+h,_=c.handler||c;Ic(t,p,_,d)}),r.forEachGetter(function(c,h){var p=i+h;Sc(t,p,c,d)}),r.forEachChild(function(c,h){Hn(t,e,n.concat(h),c,s)})}function xc(t,e,n){var r=e==="",s={dispatch:r?t.dispatch:function(o,i,l){var a=Mn(o,i,l),d=a.payload,c=a.options,h=a.type;return(!c||!c.root)&&(h=e+h),t.dispatch(h,d)},commit:r?t.commit:function(o,i,l){var a=Mn(o,i,l),d=a.payload,c=a.options,h=a.type;(!c||!c.root)&&(h=e+h),t.commit(h,d,c)}};return Object.defineProperties(s,{getters:{get:r?function(){return t.getters}:function(){return qo(t,e)}},state:{get:function(){return Br(t.state,n)}}}),s}function qo(t,e){if(!t._makeLocalGettersCache[e]){var n={},r=e.length;Object.keys(t.getters).forEach(function(s){if(s.slice(0,r)===e){var o=s.slice(r);Object.defineProperty(n,o,{get:function(){return t.getters[s]},enumerable:!0})}}),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}function Cc(t,e,n,r){var s=t._mutations[e]||(t._mutations[e]=[]);s.push(function(i){n.call(t,r.state,i)})}function Ic(t,e,n,r){var s=t._actions[e]||(t._actions[e]=[]);s.push(function(i){var l=n.call(t,{dispatch:r.dispatch,commit:r.commit,getters:r.getters,state:r.state,rootGetters:t.getters,rootState:t.state},i);return yc(l)||(l=Promise.resolve(l)),t._devtoolHook?l.catch(function(a){throw t._devtoolHook.emit("vuex:error",a),a}):l})}function Sc(t,e,n,r){t._wrappedGetters[e]||(t._wrappedGetters[e]=function(o){return n(r.state,r.getters,o.state,o.getters)})}function Tc(t){en(function(){return t._state.data},function(){},{deep:!0,flush:"sync"})}function Br(t,e){return e.reduce(function(n,r){return n[r]},t)}function Mn(t,e,n){return bc(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}var Ec="vuex bindings",Es="vuex:mutations",nr="vuex:actions",Se="vuex",Oc=0;function Mc(t,e){vc({id:"org.vuejs.vuex",app:t,label:"Vuex",homepage:"https://next.vuex.vuejs.org/",logo:"https://vuejs.org/images/icons/favicon-96x96.png",packageName:"vuex",componentStateTypes:[Ec]},function(n){n.addTimelineLayer({id:Es,label:"Vuex Mutations",color:Os}),n.addTimelineLayer({id:nr,label:"Vuex Actions",color:Os}),n.addInspector({id:Se,label:"Vuex",icon:"storage",treeFilterPlaceholder:"Filter stores..."}),n.on.getInspectorTree(function(r){if(r.app===t&&r.inspectorId===Se)if(r.filter){var s=[];Zo(s,e._modules.root,r.filter,""),r.rootNodes=s}else r.rootNodes=[Xo(e._modules.root,"")]}),n.on.getInspectorState(function(r){if(r.app===t&&r.inspectorId===Se){var s=r.nodeId;qo(e,s),r.state=kc(Dc(e._modules,s),s==="root"?e.getters:e._makeLocalGettersCache,s)}}),n.on.editInspectorState(function(r){if(r.app===t&&r.inspectorId===Se){var s=r.nodeId,o=r.path;s!=="root"&&(o=s.split("/").filter(Boolean).concat(o)),e._withCommit(function(){r.set(e._state.data,o,r.state.value)})}}),e.subscribe(function(r,s){var o={};r.payload&&(o.payload=r.payload),o.state=s,n.notifyComponentUpdate(),n.sendInspectorTree(Se),n.sendInspectorState(Se),n.addTimelineEvent({layerId:Es,event:{time:Date.now(),title:r.type,data:o}})}),e.subscribeAction({before:function(r,s){var o={};r.payload&&(o.payload=r.payload),r._id=Oc++,r._time=Date.now(),o.state=s,n.addTimelineEvent({layerId:nr,event:{time:r._time,title:r.type,groupId:r._id,subtitle:"start",data:o}})},after:function(r,s){var o={},i=Date.now()-r._time;o.duration={_custom:{type:"duration",display:i+"ms",tooltip:"Action duration",value:i}},r.payload&&(o.payload=r.payload),o.state=s,n.addTimelineEvent({layerId:nr,event:{time:Date.now(),title:r.type,groupId:r._id,subtitle:"end",data:o}})}})})}var Os=8702998,Rc=6710886,$c=16777215,Yo={label:"namespaced",textColor:$c,backgroundColor:Rc};function Qo(t){return t&&t!=="root"?t.split("/").slice(-2,-1)[0]:"Root"}function Xo(t,e){return{id:e||"root",label:Qo(e),tags:t.namespaced?[Yo]:[],children:Object.keys(t._children).map(function(n){return Xo(t._children[n],e+n+"/")})}}function Zo(t,e,n,r){r.includes(n)&&t.push({id:r||"root",label:r.endsWith("/")?r.slice(0,r.length-1):r||"Root",tags:e.namespaced?[Yo]:[]}),Object.keys(e._children).forEach(function(s){Zo(t,e._children[s],n,r+s+"/")})}function kc(t,e,n){e=n==="root"?e:e[n];var r=Object.keys(e),s={state:Object.keys(t.state).map(function(i){return{key:i,editable:!0,value:t.state[i]}})};if(r.length){var o=Ac(e);s.getters=Object.keys(o).map(function(i){return{key:i.endsWith("/")?Qo(i):i,editable:!1,value:gr(function(){return o[i]})}})}return s}function Ac(t){var e={};return Object.keys(t).forEach(function(n){var r=n.split("/");if(r.length>1){var s=e,o=r.pop();r.forEach(function(i){s[i]||(s[i]={_custom:{value:{},display:i,tooltip:"Module",abstract:!0}}),s=s[i]._custom.value}),s[o]=gr(function(){return t[n]})}else e[n]=gr(function(){return t[n]})}),e}function Dc(t,e){var n=e.split("/").filter(function(r){return r});return n.reduce(function(r,s,o){var i=r[s];if(!i)throw new Error('Missing module "'+s+'" for path "'+e+'".');return o===n.length-1?i:i._children},e==="root"?t:t.root._children)}function gr(t){try{return t()}catch(e){return e}}var jt=function(e,n){this.runtime=n,this._children=Object.create(null),this._rawModule=e;var r=e.state;this.state=(typeof r=="function"?r():r)||{}},ti={namespaced:{configurable:!0}};ti.namespaced.get=function(){return!!this._rawModule.namespaced};jt.prototype.addChild=function(e,n){this._children[e]=n};jt.prototype.removeChild=function(e){delete this._children[e]};jt.prototype.getChild=function(e){return this._children[e]};jt.prototype.hasChild=function(e){return e in this._children};jt.prototype.update=function(e){this._rawModule.namespaced=e.namespaced,e.actions&&(this._rawModule.actions=e.actions),e.mutations&&(this._rawModule.mutations=e.mutations),e.getters&&(this._rawModule.getters=e.getters)};jt.prototype.forEachChild=function(e){Be(this._children,e)};jt.prototype.forEachGetter=function(e){this._rawModule.getters&&Be(this._rawModule.getters,e)};jt.prototype.forEachAction=function(e){this._rawModule.actions&&Be(this._rawModule.actions,e)};jt.prototype.forEachMutation=function(e){this._rawModule.mutations&&Be(this._rawModule.mutations,e)};Object.defineProperties(jt.prototype,ti);var we=function(e){this.register([],e,!1)};we.prototype.get=function(e){return e.reduce(function(n,r){return n.getChild(r)},this.root)};we.prototype.getNamespace=function(e){var n=this.root;return e.reduce(function(r,s){return n=n.getChild(s),r+(n.namespaced?s+"/":"")},"")};we.prototype.update=function(e){ei([],this.root,e)};we.prototype.register=function(e,n,r){var s=this;r===void 0&&(r=!0);var o=new jt(n,r);if(e.length===0)this.root=o;else{var i=this.get(e.slice(0,-1));i.addChild(e[e.length-1],o)}n.modules&&Be(n.modules,function(l,a){s.register(e.concat(a),l,r)})};we.prototype.unregister=function(e){var n=this.get(e.slice(0,-1)),r=e[e.length-1],s=n.getChild(r);s&&s.runtime&&n.removeChild(r)};we.prototype.isRegistered=function(e){var n=this.get(e.slice(0,-1)),r=e[e.length-1];return n?n.hasChild(r):!1};function ei(t,e,n){if(e.update(n),n.modules)for(var r in n.modules){if(!e.getChild(r))return;ei(t.concat(r),e.getChild(r),n.modules[r])}}function Lc(t){return new Ct(t)}var Ct=function(e){var n=this;e===void 0&&(e={});var r=e.plugins;r===void 0&&(r=[]);var s=e.strict;s===void 0&&(s=!1);var o=e.devtools;this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new we(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._makeLocalGettersCache=Object.create(null),this._scope=null,this._devtools=o;var i=this,l=this,a=l.dispatch,d=l.commit;this.dispatch=function(p,_){return a.call(i,p,_)},this.commit=function(p,_,S){return d.call(i,p,_,S)},this.strict=s;var c=this._modules.root.state;Hn(this,c,[],this._modules.root),Nr(this,c),r.forEach(function(h){return h(n)})},Hr={state:{configurable:!0}};Ct.prototype.install=function(e,n){e.provide(n||Wo,this),e.config.globalProperties.$store=this;var r=this._devtools!==void 0?this._devtools:!1;r&&Mc(e,this)};Hr.state.get=function(){return this._state.data};Hr.state.set=function(t){};Ct.prototype.commit=function(e,n,r){var s=this,o=Mn(e,n,r),i=o.type,l=o.payload,a={type:i,payload:l},d=this._mutations[i];d&&(this._withCommit(function(){d.forEach(function(h){h(l)})}),this._subscribers.slice().forEach(function(c){return c(a,s.state)}))};Ct.prototype.dispatch=function(e,n){var r=this,s=Mn(e,n),o=s.type,i=s.payload,l={type:o,payload:i},a=this._actions[o];if(a){try{this._actionSubscribers.slice().filter(function(c){return c.before}).forEach(function(c){return c.before(l,r.state)})}catch{}var d=a.length>1?Promise.all(a.map(function(c){return c(i)})):a[0](i);return new Promise(function(c,h){d.then(function(p){try{r._actionSubscribers.filter(function(_){return _.after}).forEach(function(_){return _.after(l,r.state)})}catch{}c(p)},function(p){try{r._actionSubscribers.filter(function(_){return _.error}).forEach(function(_){return _.error(l,r.state,p)})}catch{}h(p)})})}};Ct.prototype.subscribe=function(e,n){return Ko(e,this._subscribers,n)};Ct.prototype.subscribeAction=function(e,n){var r=typeof e=="function"?{before:e}:e;return Ko(r,this._actionSubscribers,n)};Ct.prototype.watch=function(e,n,r){var s=this;return en(function(){return e(s.state,s.getters)},n,Object.assign({},r))};Ct.prototype.replaceState=function(e){var n=this;this._withCommit(function(){n._state.data=e})};Ct.prototype.registerModule=function(e,n,r){r===void 0&&(r={}),typeof e=="string"&&(e=[e]),this._modules.register(e,n),Hn(this,this.state,e,this._modules.get(e),r.preserveState),Nr(this,this.state)};Ct.prototype.unregisterModule=function(e){var n=this;typeof e=="string"&&(e=[e]),this._modules.unregister(e),this._withCommit(function(){var r=Br(n.state,e.slice(0,-1));delete r[e[e.length-1]]}),Jo(this)};Ct.prototype.hasModule=function(e){return typeof e=="string"&&(e=[e]),this._modules.isRegistered(e)};Ct.prototype.hotUpdate=function(e){this._modules.update(e),Jo(this,!0)};Ct.prototype._withCommit=function(e){var n=this._committing;this._committing=!0,e(),this._committing=n};Object.defineProperties(Ct.prototype,Hr);var Rt=(t=>(t.Color="color",t.Image="image",t))(Rt||{}),ot=(t=>(t.Music="music",t.Books="books",t.Games="games",t.Movies="movies",t.Shows="shows",t.Custom="custom",t))(ot||{}),ut=(t=>(t.AddItems="Add Items",t.Options="Options",t.ImportsExports="Import / Export",t.Info="Info",t))(ut||{});const ni=Symbol("store"),je={popupText:null,chart:{title:"",items:Array.from({length:144}).fill(null),size:{x:5,y:5},background:{type:Rt.Color,value:"#000000",img:null},showNumbers:!1,showTitles:!0,gap:20,font:"monospace",textColor:"#ffffff",shadows:!1}},Pc=Lc({state(){return{...je}},mutations:{setPopup(t,e){t.popupText=e},addItem(t,e){const n=t.chart.items;n[e.index]=e.item,t.chart={...t.chart,items:[...n]}},moveItem(t,e){const n=[...t.chart.items];n.splice(e.oldIndex,1),n.splice(e.newIndex,0,e.item),t.chart={...t.chart,items:[...n]}},changeTitle(t,e){t.chart={...t.chart,title:e}},changeBackgroundColor(t,e){t.chart={...t.chart,background:{type:Rt.Color,value:e,img:null}}},setBackgroundImage(t,e){const n=new Image;n.src=e,t.chart={...t.chart,background:{type:Rt.Image,value:e,img:n}}},changeSize(t,e){switch(e.axis){case"x":t.chart={...t.chart,size:{y:t.chart.size.y,x:e.value}};break;case"y":t.chart={...t.chart,size:{x:t.chart.size.x,y:e.value}};break;default:t.chart={...t.chart}}},changeGap(t,e){t.chart={...t.chart,gap:e}},changeFont(t,e){t.chart={...t.chart,font:e}},changeTextColor(t,e){t.chart={...t.chart,textColor:e}},toggleTitles(t,e){t.chart={...t.chart,showTitles:e}},toggleNumbers(t,e){t.chart={...t.chart,showNumbers:e}},toggleShadows(t,e){t.chart={...t.chart,shadows:e}},setEntireChart(t,e){t.chart=e},hydrateImages(t){t.chart={...t.chart,background:t.chart.background.type==="image"?{...t.chart.background,img:(()=>{const e=new Image;return e.src=t.chart.background.value,e})()}:t.chart.background,items:t.chart.items.map(e=>{if(e&&e.coverURL){const n=new Image;return n.src=e.coverURL,{...e,coverImg:n}}return e})}},reset(t){t.chart={...je.chart}}}});function Ft(){return _c(ni)}function Kt(t){return localStorage.setItem("activeChart",t),Le()}function Fe(){return localStorage.getItem("activeChart")}function Le(){return Ut()[Fe()]}function ri(){return Object.entries(Ut()).sort((e,n)=>n[1].timestamp-e[1].timestamp)[0][0]}function Uc(t){const e=Ut();delete e[t],zn(e)}function Ms(){const t=Ut();return Object.keys(t)}function zn(t){return localStorage.setItem("charts",JSON.stringify(t))}function Ut(){return JSON.parse(localStorage.getItem("charts")||"{}")}function si(t,e){const n=Ut();n[e]={...t},zn(n)}function jc(t){const e=Ut(),n=Object.entries(e).find(r=>r[0]===t);return n?n[1]:null}function He(t,e){const n=Ut(),r=e||crypto.randomUUID();return n[r]=t,zn(n),r}function Fc(){const t=Ut();if(Array.isArray(t)){localStorage.setItem("oldChartsBackup",JSON.stringify(t));const e={};let n=null;t.forEach(r=>{const s=crypto.randomUUID();e[s]={timestamp:r.timestamp,data:r.data},r.currentlyActive&&(n=s)}),zn(e),Kt(n||Object.keys(e)[0])}}function Nc(t){return!!t.cover_edition_key}function Bc(t){return!!t.artist}function Hc(t){return!!t.cover}function zc(t){return!!(t.title&&t.poster_path)}function Vc(t){return!!(t.name&&t.poster_path)}function Gc(t){return t.type==="custom"}function Wc(t){return["music","books","games","movies","shows","custom"].includes(t)}function oi(t){const e=t.items.map(n=>{if(!n)return null;const r=new Image;return r.src=n.coverURL,n.coverImg=r,n});return{...t,items:e}}function ii(){const t=He({timestamp:new Date().getTime(),data:je.chart});Kt(t)}function ge(t){const e=new Image;return e.src=t,e}function Rs(t){if(Nc(t))return{title:t.title,coverImg:ge(`https://covers.openlibrary.org/b/olid/${t.cover_edition_key}-L.jpg`),coverURL:`https://covers.openlibrary.org/b/olid/${t.cover_edition_key}-L.jpg`,creator:t.author_name[0]};if(Bc(t)){const e=t.image.length-1;return{title:t.name,coverImg:ge(t.image[e]["#text"]),coverURL:t.image[e]["#text"],creator:t.artist}}else{if(Hc(t))return{title:t.name,coverImg:ge(t.cover),coverURL:t.cover};if(zc(t))return{title:t.title,coverImg:ge(`https://image.tmdb.org/t/p/w185/${t.poster_path}`),coverURL:`https://image.tmdb.org/t/p/w185/${t.poster_path}`};if(Vc(t))return{title:t.name,coverImg:ge(`https://image.tmdb.org/t/p/w185/${t.poster_path}`),coverURL:`https://image.tmdb.org/t/p/w185/${t.poster_path}`};if(Gc(t))return{title:t.title,creator:t.creator,coverImg:ge(t.imageURL),coverURL:t.imageURL};throw new Error("Invalid chart item")}}async function li(t){const e={...t},r=(await Jc(e)).toDataURL();qc(r)}async function Kc(t){const e=[];if(t.background.type===Rt.Image&&t.background.value){const r=await Ss(t.background.value);e.push(new Promise(s=>{const o=new Image;o.src=r,o.onload=()=>{s()},o.onerror=()=>{console.log(`Error downloading image from ${r}`),s()},t.background.img=o}))}const n=t.items.slice(0,t.size.x*t.size.y);for(const r of n)if(r){const s=await Ss(r.coverURL);e.push(new Promise(o=>{r.coverImg.src=s,r.coverImg.onload=()=>{o()}}))}return await Promise.all(e),t}async function Jc(t){const e=document.createElement("canvas"),n=await Kc(t);return Vo(e,n),e}function qc(t){const e=document.createElement("a");e.download="chart.png",e.href=t,document.body.appendChild(e),e.click(),document.body.removeChild(e)}function Yc(){const t=He({timestamp:new Date().getTime(),data:je.chart});Kt(t)}function vr(t){const e=Le();t.commit("setEntireChart",e.data)}const Qc={overall:"All-Time","7day":"Weekly","1month":"Monthly","3month":"3 Month","6month":"6 Month","12month":"Yearly"},Xc={id:"home-button",type:"button",class:"toggle-button"},Zc=et({__name:"Download",setup(t){const e=F(!1),n=Ft();async function r(){e.value=!0,await li(n.state.chart),e.value=!1}return(s,o)=>(R(),D("button",Xc,[e.value?(R(),ft(P(No),{key:1,id:"loading-icon"})):(R(),ft(P(Bo),{key:0,onClick:r}))]))}}),ct=(t,e)=>{const n=t.__vccOpts||t;for(const[r,s]of e)n[r]=s;return n},tu=ct(Zc,[["__scopeId","data-v-af0e2aaa"]]),Ye=260;function rr(t,e){const n=e.title===""?0:60,r=t.clientHeight/t.height;return{scaleRatio:r,scaledGap:e.gap*r,scaledTitleHeight:n*r,scaledItemSize:Ye*r,scaledPixelDimensions:{x:t.width*r,y:t.height*r}}}function eu(t,e,n){const r=o=>o%(t.scaledItemSize+t.scaledGap)>t.scaledGap&&o<(t.scaledItemSize+t.scaledGap)*e.size.x+t.scaledGap,s=o=>(o-t.scaledTitleHeight)%(t.scaledItemSize+t.scaledGap)>t.scaledGap&&o<(t.scaledItemSize+t.scaledGap)*e.size.y+t.scaledTitleHeight;return!!(r(n.x)&&s(n.y))}function _r(t,e,n){if(!t)throw new Error("Rendering context not found!");const r={x:n%e.size.x,y:Math.floor(n/e.size.x)},s=e.title===""?0:60;t.fillStyle="rgb(230, 230, 230)",t.fillRect(r.x*(Ye+e.gap)+e.gap,r.y*(Ye+e.gap)+e.gap+s,Ye,Ye)}function bn(t){return!!t.touches}function nu(t){return!!t.dataTransfer}const ru=et({__name:"ChartCanvas",setup(t){const e=F(null),n=Ft(),r=Bn(()=>{const i=e.value.getContext("2d");return i||null});n.watch(i=>i.chart,()=>{n.state.chart.background.type==="image"&&!n.state.chart.background.img.complete&&(n.state.chart.background.img.onload=()=>{o()}),o()}),Ne(()=>{if(!e.value)throw new Error("Couldn't find canvas. Something must have gone wrong with page loading, please refresh.");if(n.state.chart){if(n.state.chart.background.type===Rt.Image){const i=new Image;i.src=n.state.chart.background.value,i.onload=()=>{o()},n.state.chart.background.img=i}s(n.state.chart)}});function s(i){for(const l of i.items)l&&!l.coverImg.complete&&(l.coverImg.onload=()=>{o()})}function o(){if(!e.value)return console.log("The canvas doesn'nt exist! Maybe it tried to re-render after being unmounted.");s(n.state.chart),Vo(e.value,n.state.chart),n.state.chart.items.slice(0,n.state.chart.size.x*n.state.chart.size.y).forEach((i,l)=>{i||_r(r.value,n.state.chart,l)})}return(i,l)=>(R(),D("canvas",{id:"chart-canvas",ref_key:"canvas",ref:e},null,512))}}),su=ct(ru,[["__scopeId","data-v-77fea93c"]]),ou=et({__name:"InteractionCanvas",setup(t){const e=F(null),n=F(null),r=F({x:0,y:0}),s=F({x:0,y:0}),o=Ft();o.watch(x=>x.chart,()=>{l()});const i=Bn(()=>{const x=n.value.getContext("2d");return x||null});function l(){const x=document.getElementById("chart-canvas");if(!x)return console.log("The canvas doesn'nt exist! Maybe it tried to re-render after being unmounted.");n.value.width=x.width,n.value.height=x.height}function a(x){const C=rr(n.value,o.state.chart);return!!eu(C,o.state.chart,p(x,{x:n.value.offsetLeft,y:n.value.offsetTop}))}function d(x,C){if(!i.value)throw new Error("Canvas context not found, the canvas must have loaded incorrectly.");const H=rr(n.value,o.state.chart),V=Ho(x,260);i.value.drawImage(x,Math.floor(C.x/H.scaleRatio-V.width/2),Math.floor(C.y/H.scaleRatio-V.height/2),V.width,V.height)}function c(x){const C=a(x);if(!bn(x)){const V={x:n.value.offsetLeft,y:n.value.offsetTop};s.value={x:x.clientX-V.x+window.scrollX,y:x.clientY-V.y+window.scrollY},C?document.body.style.cursor="pointer":!C&&!e.value&&(document.body.style.cursor="default")}if(bn(x)&&x.type!=="touchend"){r.value={x:x.touches[0].clientX,y:x.touches[0].clientY};const V=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop}),st=n.value.getBoundingClientRect();(V.x<0||V.x>st.width||V.y<0||V.y>st.height)&&h(x)}if(e.value){document.body.style.cursor="grab",l(),_r(i.value,o.state.chart,e.value.originalIndex);const V=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop});d(e.value.itemObject.coverImg,V)}}function h(x){document.body.style.cursor="default",e.value&&o.commit("addItem",{item:null,index:e.value.originalIndex}),z(x),e.value=null}function p(x,C){return bn(x)?x.type==="touchend"?{x:r.value.x-C.x+window.scrollX,y:r.value.y-C.y+window.scrollY}:{x:x.touches[0].clientX-C.x+window.scrollX,y:x.touches[0].clientY-C.y+window.scrollY}:{x:x.clientX-C.x+window.scrollX,y:x.clientY-C.y+window.scrollY}}function _(x){const C=rr(n.value,o.state.chart),H=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop}),V=o.state.chart.title?60*C.scaleRatio:0,st=Math.floor(H.x/(C.scaledItemSize+C.scaledGap));return Math.floor((H.y-V)/(C.scaledItemSize+C.scaledGap))*o.state.chart.size.x+st}function S(x){if(!a(x))return null;const C=_(x),H=o.state.chart.items[C];if(!H)return null;bn(x)&&(r.value={x:x.touches[0].clientX,y:x.touches[0].clientY}),e.value={originalIndex:C,itemObject:H},c(x),l(),_r(i.value,o.state.chart,C);const V=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop});d(e.value.itemObject.coverImg,V)}function A(x){var H;if(!((H=x.dataTransfer)==null?void 0:H.getData("application/json")))return null;z(x)}function Q(x){if(!e.value)return null;z(x)}function z(x){var H;if(!a(x))return e.value=null,l(),null;const C=_(x);if(nu(x)){const V=JSON.parse(((H=x.dataTransfer)==null?void 0:H.getData("application/json"))||"null");if(!V)return null;V.coverImg=ge(V.coverURL),o.commit("addItem",{item:V,index:C})}else{if(!e.value)return null;o.state.chart.items[C]?o.commit("moveItem",{item:e.value.itemObject,oldIndex:e.value.originalIndex,newIndex:C}):(o.commit("addItem",{item:e.value.itemObject,index:C}),o.commit("addItem",{item:null,index:e.value.originalIndex}))}e.value=null,c(x)}function K(x){x.preventDefault()}return(x,C)=>(R(),D("canvas",{id:"interaction-canvas",ref_key:"canvas",ref:n,onMousemove:c,onMouseleave:h,onMousedown:On(S,["left"]),onMouseup:On(Q,["left"]),onDragover:K,onDrop:A,onTouchstart:S,onTouchmove:c,onTouchend:z,onTouchleave:h},null,544))}}),iu=ct(ou,[["__scopeId","data-v-f4221a32"]]),lu=["value","selected"],au=et({__name:"Switcher",setup(t){const e=Ft(),n=F(Fe()),r=F(Ut()),s=F(Ms());e.watch(a=>a.chart,()=>{i()});function o(a){return a.toSorted((d,c)=>r.value[c].timestamp-r.value[d].timestamp)}function i(){n.value=Fe(),r.value=Ut(),s.value=o(Ms())}function l(a){const d=a.target.value,c=Kt(d),h=oi(c.data);n.value=d,e.commit("setEntireChart",h)}return(a,d)=>(R(),D("div",null,[m("select",{id:"chart-switcher",name:"chart-switcher",onChange:l},[(R(!0),D(it,null,se(s.value,(c,h)=>{var p,_,S,A;return R(),D("option",{key:h,value:c,selected:c===n.value},Dt((_=(p=r.value[c])==null?void 0:p.data)!=null&&_.title?(S=r.value[c])==null?void 0:S.data.title:`Untitled (${new Date((A=r.value[c])==null?void 0:A.timestamp).toUTCString()})`),9,lu)}),128))],32)]))}}),cu={id:"top-bar"},uu={class:"switcher-menu"},fu={key:1,class:"download-button"},du=et({__name:"TopBar",setup(t){const e=Ft(),n=F(!1);async function r(){n.value=!0,await li(e.state.chart),n.value=!1}function s(){const i={timestamp:new Date().getTime(),data:je.chart},l=He(i);Kt(l),e.commit("reset")}function o(){const i=Fe();if(window.confirm("Are you sure you want to delete this chart? There's no way to recover it!")){Uc(i);const l=Ut();if(Object.keys(l).length<1)ii(),e.commit("reset");else{const a=Kt(ri());oi(a.data),e.commit("setEntireChart",a.data)}}}return(i,l)=>(R(),D("div",cu,[m("div",uu,[m("button",{onClick:o}," - "),k(au),m("button",{onClick:s}," + ")]),n.value?(R(),D("button",fu,[k(P(No),{id:"loading-icon"}),l[1]||(l[1]=De(" loading... "))])):(R(),D("button",{key:0,class:"download-button",onClick:r},[k(P(Bo),{id:"save-icon"}),l[0]||(l[0]=De(" Download "))]))]))}}),hu={class:"chart-builder"},pu={class:"chart-builder-contents"},mu={class:"canvas-container"},gu=et({__name:"index",setup(t){return(e,n)=>(R(),D("div",hu,[m("div",pu,[k(du),m("div",mu,[k(su,{id:"chart-canvas"}),k(iu,{id:"interaction-canvas"})])])]))}}),vu=ct(gu,[["__scopeId","data-v-7dde5efe"]]),_u=et({__name:"LocalStorageWatcher",setup(t){const e=Ft();return Ne(()=>{Fc();const n=Le();n?e.commit("setEntireChart",n.data):(ii(),e.commit("setEntireChart",Le().data))}),e.subscribe((n,r)=>{if(n.type==="setEntireChart")e.commit("hydrateImages");else{const s=Fe(),o=Le();if(o){const i={...o,data:r.chart};si(i,s)}else{const i=He({timestamp:new Date().getTime(),data:r.chart});Kt(i)}}}),(n,r)=>Tl(n.$slots,"default")}}),bu={key:0,id:"popup"},yu=et({__name:"Popup",setup(t){const e=Ft();return e.watch(n=>n.popupText,()=>{const n=e.state.popupText;setTimeout(()=>{e.state.popupText===n&&e.commit("setPopup",null)},1500)}),(n,r)=>P(e).state.popupText?(R(),D("div",bu,[m("p",null,Dt(P(e).state.popupText),1)])):Ue("",!0)}}),wu={};function xu(t,e){return R(),D("h1",null,"Topsters 3")}const ai=ct(wu,[["render",xu],["__scopeId","data-v-4e93a5a4"]]),ci="/lastfm_logo.svg",Cu="/ia_logo.svg",Iu="/igdb_logo.png",Su="/tmdb.svg",Tu={},Eu={id:"credits"};function Ou(t,e){return R(),D("div",Eu,e[0]||(e[0]=[Po('

Data credits

Last.fm

Topsters 3 is not affiliated with or endorsed by any of the above services.

',3)]))}const ui=ct(Tu,[["render",Ou],["__scopeId","data-v-67d21f69"]]);async function fi(t){const e=new Response(t).body.pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(e).arrayBuffer())}async function Mu(t){const e=new Response(t).body.pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(e).arrayBuffer())}function Ru(t,e,n){const r=new Blob([t]),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`${e||`Untitled ${n}`}.topster`,document.body.appendChild(o),o.click(),o.remove()}async function $s(){const t=Fe(),e={[t]:Le()},n=JSON.stringify(e),r=new TextEncoder().encode(n),s=await Mu(r),o=btoa(s.toString());Ru(o,e[t].data.title,e[t].timestamp)}async function $u(t){const e=Uint8Array.from(atob(t).split(",").map(o=>Number.parseInt(o))),n=new TextDecoder,r=await fi(e);return n.decode(r)}async function ku(t,e){const n=t.target.files;try{const r=await n[0].text(),s=await $u(r),o=JSON.parse(s),i=Object.keys(o)[0],l=jc(i),a=o[i];let d=!1;l?window.confirm("This chart already exists locally. Do you want to overwrite it?")&&(d=!0,si(a,i),Kt(i),vr(e)):(d=!0,He(a,i),Kt(i),vr(e)),d&&alert(`"${a.data.title}" imported successfully!`)}catch(r){console.error(r),alert(`Failed to import charts: ${r}`)}}async function Au(t,e){if(t.target===null)return;const n=t.target.files;if(n===null)return;const r=new FileReader;r.addEventListener("load",async()=>{try{const s=atob(r.result.split("").map(d=>String.fromCharCode(d.charCodeAt(0)-17)).join("")),o=JSON.parse(s)[0],i=JSON.parse(o.options),l=[],a=[];for(const d of Object.entries(i.charts)){let c=`${d[0]}-`;c==="cards-"&&(c="");const h=d[1];try{const p=JSON.parse(o[`${c}custom`]),_=o[`${c}size`],S={x:3,y:3};switch(_){case"25":S.x=p.columns,S.y=p.rows;break;case"40":S.x=5,S.y=8;break;case"42":S.x=6,S.y=7;break;case"100":S.x=10,S.y=10;break;default:S.x=12,S.y=12;break}let A=o[`${c}background`],Q=null;if(!A.startsWith("#"))try{const at=A.match(/url\("(.+?)"\)/);if(at===null)throw new Error("image URL is empty");A=at[1],Q=new Image,Q.src=A}catch(at){console.log(at),A="#000000"}const z=new TextDecoder,K=o[`${c}cards`],x=Uint8Array.from(atob(K.substring(1,K.length-1)),at=>at.charCodeAt(0)),C=await fi(x),H=z.decode(C),V=JSON.parse(H),st=[];for(const at of V){if(at.src===""){st.push(null);continue}const kt=new Image;kt.src=at.src;const qt={title:at.title,coverURL:at.src,coverImg:kt};st.push(qt)}const It={timestamp:new Date().getTime(),data:{title:"",items:st,size:S,background:{type:A.startsWith("#")?Rt.Color:Rt.Image,value:A,img:Q},shadows:p.shadowed,showNumbers:o[`${c}numbered`]==="true",showTitles:o[`${c}titled`]==="true",gap:p.padding*5,font:p.fontFamily}};l.push(It)}catch(p){console.error(p),a.push(h)}}a.length>0?alert(`Failed to import the following charts: ${a.join(", ")}`):alert("Charts imported successfully!"),l.forEach(d=>He(d)),Kt(ri()),vr(e)}catch(s){console.error(s),alert(`The file selected is not a valid Topsters 2 backup: ${s}`)}}),r.readAsText(n[0])}const Jt={NoConnection:"Unable to reach search servers.",BadStatusCode:"The search servers returned an error.",NoResults:"No results found."};async function Du(t){if(t==="")return[];const e=encodeURIComponent(t),n=await fetch(`https://api.topsters.org/api/lastfm/search/${e}`);if(!n)throw new Error(Jt.NoConnection);if(n.status!==200)throw new Error(Jt.BadStatusCode);const r=await n.json();return r.results.albummatches.album.length===0?[]:r.results.albummatches.album}async function Lu(t,e,n){if(t==="")return[];const r=await fetch(`https://api.topsters.org/api/lastfm/user/top?${new URLSearchParams({user:encodeURIComponent(t),type:e,period:n?encodeURIComponent(n):""})}`);if(!r)throw new Error(Jt.NoConnection);if(r.status!==200)throw new Error(Jt.BadStatusCode);return await r.json()}const Pu={class:"form-item"},Uu={class:"form-item"},ju=et({__name:"LastFmImport",setup(t){const e=Ft(),n=F(null),r=F(null);async function s(){const o=n.value.value;if(!o)return null;const i=r.value,l=i.options[i.selectedIndex].value;let a;try{a=await Lu(o,"albums",l)}catch{return alert("Something went wrong when downloading your Last.fm data! Is your username spelled correctly?"),null}const d=[],h=a.filter(_=>_.image.find(A=>A.size==="extralarge")["#text"]===""?(d.push(`${_.artist.name} - ${_.name}`),!1):!0).map(_=>{const S=_.image.find(Q=>Q.size==="extralarge")["#text"],A=new Image;return A.src=S,{title:_.name,creator:_.artist.name,coverImg:A,coverURL:S}});Yc();const p=_=>{for(let S=1;S<=10;S++)if(_0&&alert(`Couldn't add the following albums because they're missing cover art on Last.fm: + */var Wo="store";function _c(t){return t===void 0&&(t=null),tn(t!==null?t:Wo)}function Be(t,e){Object.keys(t).forEach(function(n){return e(t[n],n)})}function bc(t){return t!==null&&typeof t=="object"}function yc(t){return t&&typeof t.then=="function"}function wc(t,e){return function(){return t(e)}}function Ko(t,e,n){return e.indexOf(t)<0&&(n&&n.prepend?e.unshift(t):e.push(t)),function(){var r=e.indexOf(t);r>-1&&e.splice(r,1)}}function Jo(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var n=t.state;Hn(t,n,[],t._modules.root,!0),Nr(t,n,e)}function Nr(t,e,n){var r=t._state,s=t._scope;t.getters={},t._makeLocalGettersCache=Object.create(null);var o=t._wrappedGetters,i={},l={},a=ki(!0);a.run(function(){Be(o,function(d,c){i[c]=wc(d,t),l[c]=Bn(function(){return i[c]()}),Object.defineProperty(t.getters,c,{get:function(){return l[c].value},enumerable:!0})})}),t._state=Ln({data:e}),t._scope=a,t.strict&&Tc(t),r&&n&&t._withCommit(function(){r.data=null}),s&&s.stop()}function Hn(t,e,n,r,s){var o=!n.length,i=t._modules.getNamespace(n);if(r.namespaced&&(t._modulesNamespaceMap[i],t._modulesNamespaceMap[i]=r),!o&&!s){var l=Br(e,n.slice(0,-1)),a=n[n.length-1];t._withCommit(function(){l[a]=r.state})}var d=r.context=xc(t,i,n);r.forEachMutation(function(c,h){var p=i+h;Cc(t,p,c,d)}),r.forEachAction(function(c,h){var p=c.root?h:i+h,_=c.handler||c;Ic(t,p,_,d)}),r.forEachGetter(function(c,h){var p=i+h;Sc(t,p,c,d)}),r.forEachChild(function(c,h){Hn(t,e,n.concat(h),c,s)})}function xc(t,e,n){var r=e==="",s={dispatch:r?t.dispatch:function(o,i,l){var a=Mn(o,i,l),d=a.payload,c=a.options,h=a.type;return(!c||!c.root)&&(h=e+h),t.dispatch(h,d)},commit:r?t.commit:function(o,i,l){var a=Mn(o,i,l),d=a.payload,c=a.options,h=a.type;(!c||!c.root)&&(h=e+h),t.commit(h,d,c)}};return Object.defineProperties(s,{getters:{get:r?function(){return t.getters}:function(){return qo(t,e)}},state:{get:function(){return Br(t.state,n)}}}),s}function qo(t,e){if(!t._makeLocalGettersCache[e]){var n={},r=e.length;Object.keys(t.getters).forEach(function(s){if(s.slice(0,r)===e){var o=s.slice(r);Object.defineProperty(n,o,{get:function(){return t.getters[s]},enumerable:!0})}}),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}function Cc(t,e,n,r){var s=t._mutations[e]||(t._mutations[e]=[]);s.push(function(i){n.call(t,r.state,i)})}function Ic(t,e,n,r){var s=t._actions[e]||(t._actions[e]=[]);s.push(function(i){var l=n.call(t,{dispatch:r.dispatch,commit:r.commit,getters:r.getters,state:r.state,rootGetters:t.getters,rootState:t.state},i);return yc(l)||(l=Promise.resolve(l)),t._devtoolHook?l.catch(function(a){throw t._devtoolHook.emit("vuex:error",a),a}):l})}function Sc(t,e,n,r){t._wrappedGetters[e]||(t._wrappedGetters[e]=function(o){return n(r.state,r.getters,o.state,o.getters)})}function Tc(t){en(function(){return t._state.data},function(){},{deep:!0,flush:"sync"})}function Br(t,e){return e.reduce(function(n,r){return n[r]},t)}function Mn(t,e,n){return bc(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}var Ec="vuex bindings",Es="vuex:mutations",nr="vuex:actions",Se="vuex",Oc=0;function Mc(t,e){vc({id:"org.vuejs.vuex",app:t,label:"Vuex",homepage:"https://next.vuex.vuejs.org/",logo:"https://vuejs.org/images/icons/favicon-96x96.png",packageName:"vuex",componentStateTypes:[Ec]},function(n){n.addTimelineLayer({id:Es,label:"Vuex Mutations",color:Os}),n.addTimelineLayer({id:nr,label:"Vuex Actions",color:Os}),n.addInspector({id:Se,label:"Vuex",icon:"storage",treeFilterPlaceholder:"Filter stores..."}),n.on.getInspectorTree(function(r){if(r.app===t&&r.inspectorId===Se)if(r.filter){var s=[];Zo(s,e._modules.root,r.filter,""),r.rootNodes=s}else r.rootNodes=[Xo(e._modules.root,"")]}),n.on.getInspectorState(function(r){if(r.app===t&&r.inspectorId===Se){var s=r.nodeId;qo(e,s),r.state=kc(Dc(e._modules,s),s==="root"?e.getters:e._makeLocalGettersCache,s)}}),n.on.editInspectorState(function(r){if(r.app===t&&r.inspectorId===Se){var s=r.nodeId,o=r.path;s!=="root"&&(o=s.split("/").filter(Boolean).concat(o)),e._withCommit(function(){r.set(e._state.data,o,r.state.value)})}}),e.subscribe(function(r,s){var o={};r.payload&&(o.payload=r.payload),o.state=s,n.notifyComponentUpdate(),n.sendInspectorTree(Se),n.sendInspectorState(Se),n.addTimelineEvent({layerId:Es,event:{time:Date.now(),title:r.type,data:o}})}),e.subscribeAction({before:function(r,s){var o={};r.payload&&(o.payload=r.payload),r._id=Oc++,r._time=Date.now(),o.state=s,n.addTimelineEvent({layerId:nr,event:{time:r._time,title:r.type,groupId:r._id,subtitle:"start",data:o}})},after:function(r,s){var o={},i=Date.now()-r._time;o.duration={_custom:{type:"duration",display:i+"ms",tooltip:"Action duration",value:i}},r.payload&&(o.payload=r.payload),o.state=s,n.addTimelineEvent({layerId:nr,event:{time:Date.now(),title:r.type,groupId:r._id,subtitle:"end",data:o}})}})})}var Os=8702998,Rc=6710886,$c=16777215,Yo={label:"namespaced",textColor:$c,backgroundColor:Rc};function Qo(t){return t&&t!=="root"?t.split("/").slice(-2,-1)[0]:"Root"}function Xo(t,e){return{id:e||"root",label:Qo(e),tags:t.namespaced?[Yo]:[],children:Object.keys(t._children).map(function(n){return Xo(t._children[n],e+n+"/")})}}function Zo(t,e,n,r){r.includes(n)&&t.push({id:r||"root",label:r.endsWith("/")?r.slice(0,r.length-1):r||"Root",tags:e.namespaced?[Yo]:[]}),Object.keys(e._children).forEach(function(s){Zo(t,e._children[s],n,r+s+"/")})}function kc(t,e,n){e=n==="root"?e:e[n];var r=Object.keys(e),s={state:Object.keys(t.state).map(function(i){return{key:i,editable:!0,value:t.state[i]}})};if(r.length){var o=Ac(e);s.getters=Object.keys(o).map(function(i){return{key:i.endsWith("/")?Qo(i):i,editable:!1,value:gr(function(){return o[i]})}})}return s}function Ac(t){var e={};return Object.keys(t).forEach(function(n){var r=n.split("/");if(r.length>1){var s=e,o=r.pop();r.forEach(function(i){s[i]||(s[i]={_custom:{value:{},display:i,tooltip:"Module",abstract:!0}}),s=s[i]._custom.value}),s[o]=gr(function(){return t[n]})}else e[n]=gr(function(){return t[n]})}),e}function Dc(t,e){var n=e.split("/").filter(function(r){return r});return n.reduce(function(r,s,o){var i=r[s];if(!i)throw new Error('Missing module "'+s+'" for path "'+e+'".');return o===n.length-1?i:i._children},e==="root"?t:t.root._children)}function gr(t){try{return t()}catch(e){return e}}var jt=function(e,n){this.runtime=n,this._children=Object.create(null),this._rawModule=e;var r=e.state;this.state=(typeof r=="function"?r():r)||{}},ti={namespaced:{configurable:!0}};ti.namespaced.get=function(){return!!this._rawModule.namespaced};jt.prototype.addChild=function(e,n){this._children[e]=n};jt.prototype.removeChild=function(e){delete this._children[e]};jt.prototype.getChild=function(e){return this._children[e]};jt.prototype.hasChild=function(e){return e in this._children};jt.prototype.update=function(e){this._rawModule.namespaced=e.namespaced,e.actions&&(this._rawModule.actions=e.actions),e.mutations&&(this._rawModule.mutations=e.mutations),e.getters&&(this._rawModule.getters=e.getters)};jt.prototype.forEachChild=function(e){Be(this._children,e)};jt.prototype.forEachGetter=function(e){this._rawModule.getters&&Be(this._rawModule.getters,e)};jt.prototype.forEachAction=function(e){this._rawModule.actions&&Be(this._rawModule.actions,e)};jt.prototype.forEachMutation=function(e){this._rawModule.mutations&&Be(this._rawModule.mutations,e)};Object.defineProperties(jt.prototype,ti);var we=function(e){this.register([],e,!1)};we.prototype.get=function(e){return e.reduce(function(n,r){return n.getChild(r)},this.root)};we.prototype.getNamespace=function(e){var n=this.root;return e.reduce(function(r,s){return n=n.getChild(s),r+(n.namespaced?s+"/":"")},"")};we.prototype.update=function(e){ei([],this.root,e)};we.prototype.register=function(e,n,r){var s=this;r===void 0&&(r=!0);var o=new jt(n,r);if(e.length===0)this.root=o;else{var i=this.get(e.slice(0,-1));i.addChild(e[e.length-1],o)}n.modules&&Be(n.modules,function(l,a){s.register(e.concat(a),l,r)})};we.prototype.unregister=function(e){var n=this.get(e.slice(0,-1)),r=e[e.length-1],s=n.getChild(r);s&&s.runtime&&n.removeChild(r)};we.prototype.isRegistered=function(e){var n=this.get(e.slice(0,-1)),r=e[e.length-1];return n?n.hasChild(r):!1};function ei(t,e,n){if(e.update(n),n.modules)for(var r in n.modules){if(!e.getChild(r))return;ei(t.concat(r),e.getChild(r),n.modules[r])}}function Lc(t){return new Ct(t)}var Ct=function(e){var n=this;e===void 0&&(e={});var r=e.plugins;r===void 0&&(r=[]);var s=e.strict;s===void 0&&(s=!1);var o=e.devtools;this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new we(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._makeLocalGettersCache=Object.create(null),this._scope=null,this._devtools=o;var i=this,l=this,a=l.dispatch,d=l.commit;this.dispatch=function(p,_){return a.call(i,p,_)},this.commit=function(p,_,S){return d.call(i,p,_,S)},this.strict=s;var c=this._modules.root.state;Hn(this,c,[],this._modules.root),Nr(this,c),r.forEach(function(h){return h(n)})},Hr={state:{configurable:!0}};Ct.prototype.install=function(e,n){e.provide(n||Wo,this),e.config.globalProperties.$store=this;var r=this._devtools!==void 0?this._devtools:!1;r&&Mc(e,this)};Hr.state.get=function(){return this._state.data};Hr.state.set=function(t){};Ct.prototype.commit=function(e,n,r){var s=this,o=Mn(e,n,r),i=o.type,l=o.payload,a={type:i,payload:l},d=this._mutations[i];d&&(this._withCommit(function(){d.forEach(function(h){h(l)})}),this._subscribers.slice().forEach(function(c){return c(a,s.state)}))};Ct.prototype.dispatch=function(e,n){var r=this,s=Mn(e,n),o=s.type,i=s.payload,l={type:o,payload:i},a=this._actions[o];if(a){try{this._actionSubscribers.slice().filter(function(c){return c.before}).forEach(function(c){return c.before(l,r.state)})}catch{}var d=a.length>1?Promise.all(a.map(function(c){return c(i)})):a[0](i);return new Promise(function(c,h){d.then(function(p){try{r._actionSubscribers.filter(function(_){return _.after}).forEach(function(_){return _.after(l,r.state)})}catch{}c(p)},function(p){try{r._actionSubscribers.filter(function(_){return _.error}).forEach(function(_){return _.error(l,r.state,p)})}catch{}h(p)})})}};Ct.prototype.subscribe=function(e,n){return Ko(e,this._subscribers,n)};Ct.prototype.subscribeAction=function(e,n){var r=typeof e=="function"?{before:e}:e;return Ko(r,this._actionSubscribers,n)};Ct.prototype.watch=function(e,n,r){var s=this;return en(function(){return e(s.state,s.getters)},n,Object.assign({},r))};Ct.prototype.replaceState=function(e){var n=this;this._withCommit(function(){n._state.data=e})};Ct.prototype.registerModule=function(e,n,r){r===void 0&&(r={}),typeof e=="string"&&(e=[e]),this._modules.register(e,n),Hn(this,this.state,e,this._modules.get(e),r.preserveState),Nr(this,this.state)};Ct.prototype.unregisterModule=function(e){var n=this;typeof e=="string"&&(e=[e]),this._modules.unregister(e),this._withCommit(function(){var r=Br(n.state,e.slice(0,-1));delete r[e[e.length-1]]}),Jo(this)};Ct.prototype.hasModule=function(e){return typeof e=="string"&&(e=[e]),this._modules.isRegistered(e)};Ct.prototype.hotUpdate=function(e){this._modules.update(e),Jo(this,!0)};Ct.prototype._withCommit=function(e){var n=this._committing;this._committing=!0,e(),this._committing=n};Object.defineProperties(Ct.prototype,Hr);var Rt=(t=>(t.Color="color",t.Image="image",t))(Rt||{}),ot=(t=>(t.Music="music",t.Books="books",t.Games="games",t.Movies="movies",t.Shows="shows",t.Custom="custom",t))(ot||{}),ut=(t=>(t.AddItems="Add Items",t.Options="Options",t.ImportsExports="Import / Export",t.Info="Info",t))(ut||{});const ni=Symbol("store"),je={popupText:null,chart:{title:"",items:Array.from({length:144}).fill(null),size:{x:5,y:5},background:{type:Rt.Color,value:"#000000",img:null},showNumbers:!1,showTitles:!0,gap:20,font:"monospace",textColor:"#ffffff",shadows:!0}},Pc=Lc({state(){return{...je}},mutations:{setPopup(t,e){t.popupText=e},addItem(t,e){const n=t.chart.items;n[e.index]=e.item,t.chart={...t.chart,items:[...n]}},moveItem(t,e){const n=[...t.chart.items];n.splice(e.oldIndex,1),n.splice(e.newIndex,0,e.item),t.chart={...t.chart,items:[...n]}},changeTitle(t,e){t.chart={...t.chart,title:e}},changeBackgroundColor(t,e){t.chart={...t.chart,background:{type:Rt.Color,value:e,img:null}}},setBackgroundImage(t,e){const n=new Image;n.src=e,t.chart={...t.chart,background:{type:Rt.Image,value:e,img:n}}},changeSize(t,e){switch(e.axis){case"x":t.chart={...t.chart,size:{y:t.chart.size.y,x:e.value}};break;case"y":t.chart={...t.chart,size:{x:t.chart.size.x,y:e.value}};break;default:t.chart={...t.chart}}},changeGap(t,e){t.chart={...t.chart,gap:e}},changeFont(t,e){t.chart={...t.chart,font:e}},changeTextColor(t,e){t.chart={...t.chart,textColor:e}},toggleTitles(t,e){t.chart={...t.chart,showTitles:e}},toggleNumbers(t,e){t.chart={...t.chart,showNumbers:e}},toggleShadows(t,e){t.chart={...t.chart,shadows:e}},setEntireChart(t,e){t.chart=e},hydrateImages(t){t.chart={...t.chart,background:t.chart.background.type==="image"?{...t.chart.background,img:(()=>{const e=new Image;return e.src=t.chart.background.value,e})()}:t.chart.background,items:t.chart.items.map(e=>{if(e&&e.coverURL){const n=new Image;return n.src=e.coverURL,{...e,coverImg:n}}return e})}},reset(t){t.chart={...je.chart}}}});function Ft(){return _c(ni)}function Kt(t){return localStorage.setItem("activeChart",t),Le()}function Fe(){return localStorage.getItem("activeChart")}function Le(){return Ut()[Fe()]}function ri(){return Object.entries(Ut()).sort((e,n)=>n[1].timestamp-e[1].timestamp)[0][0]}function Uc(t){const e=Ut();delete e[t],zn(e)}function Ms(){const t=Ut();return Object.keys(t)}function zn(t){return localStorage.setItem("charts",JSON.stringify(t))}function Ut(){return JSON.parse(localStorage.getItem("charts")||"{}")}function si(t,e){const n=Ut();n[e]={...t},zn(n)}function jc(t){const e=Ut(),n=Object.entries(e).find(r=>r[0]===t);return n?n[1]:null}function He(t,e){const n=Ut(),r=e||crypto.randomUUID();return n[r]=t,zn(n),r}function Fc(){const t=Ut();if(Array.isArray(t)){localStorage.setItem("oldChartsBackup",JSON.stringify(t));const e={};let n=null;t.forEach(r=>{const s=crypto.randomUUID();e[s]={timestamp:r.timestamp,data:r.data},r.currentlyActive&&(n=s)}),zn(e),Kt(n||Object.keys(e)[0])}}function Nc(t){return!!t.cover_edition_key}function Bc(t){return!!t.artist}function Hc(t){return!!t.cover}function zc(t){return!!(t.title&&t.poster_path)}function Vc(t){return!!(t.name&&t.poster_path)}function Gc(t){return t.type==="custom"}function Wc(t){return["music","books","games","movies","shows","custom"].includes(t)}function oi(t){const e=t.items.map(n=>{if(!n)return null;const r=new Image;return r.src=n.coverURL,n.coverImg=r,n});return{...t,items:e}}function ii(){const t=He({timestamp:new Date().getTime(),data:je.chart});Kt(t)}function ge(t){const e=new Image;return e.src=t,e}function Rs(t){if(Nc(t))return{title:t.title,coverImg:ge(`https://covers.openlibrary.org/b/olid/${t.cover_edition_key}-L.jpg`),coverURL:`https://covers.openlibrary.org/b/olid/${t.cover_edition_key}-L.jpg`,creator:t.author_name[0]};if(Bc(t)){const e=t.image.length-1;return{title:t.name,coverImg:ge(t.image[e]["#text"]),coverURL:t.image[e]["#text"],creator:t.artist}}else{if(Hc(t))return{title:t.name,coverImg:ge(t.cover),coverURL:t.cover};if(zc(t))return{title:t.title,coverImg:ge(`https://image.tmdb.org/t/p/w185/${t.poster_path}`),coverURL:`https://image.tmdb.org/t/p/w185/${t.poster_path}`};if(Vc(t))return{title:t.name,coverImg:ge(`https://image.tmdb.org/t/p/w185/${t.poster_path}`),coverURL:`https://image.tmdb.org/t/p/w185/${t.poster_path}`};if(Gc(t))return{title:t.title,creator:t.creator,coverImg:ge(t.imageURL),coverURL:t.imageURL};throw new Error("Invalid chart item")}}async function li(t){const e={...t},r=(await Jc(e)).toDataURL();qc(r)}async function Kc(t){const e=[];if(t.background.type===Rt.Image&&t.background.value){const r=await Ss(t.background.value);e.push(new Promise(s=>{const o=new Image;o.src=r,o.onload=()=>{s()},o.onerror=()=>{console.log(`Error downloading image from ${r}`),s()},t.background.img=o}))}const n=t.items.slice(0,t.size.x*t.size.y);for(const r of n)if(r){const s=await Ss(r.coverURL);e.push(new Promise(o=>{r.coverImg.src=s,r.coverImg.onload=()=>{o()}}))}return await Promise.all(e),t}async function Jc(t){const e=document.createElement("canvas"),n=await Kc(t);return Vo(e,n),e}function qc(t){const e=document.createElement("a");e.download="chart.png",e.href=t,document.body.appendChild(e),e.click(),document.body.removeChild(e)}function Yc(){const t=He({timestamp:new Date().getTime(),data:je.chart});Kt(t)}function vr(t){const e=Le();t.commit("setEntireChart",e.data)}const Qc={overall:"All-Time","7day":"Weekly","1month":"Monthly","3month":"3 Month","6month":"6 Month","12month":"Yearly"},Xc={id:"home-button",type:"button",class:"toggle-button"},Zc=et({__name:"Download",setup(t){const e=F(!1),n=Ft();async function r(){e.value=!0,await li(n.state.chart),e.value=!1}return(s,o)=>(R(),D("button",Xc,[e.value?(R(),ft(P(No),{key:1,id:"loading-icon"})):(R(),ft(P(Bo),{key:0,onClick:r}))]))}}),ct=(t,e)=>{const n=t.__vccOpts||t;for(const[r,s]of e)n[r]=s;return n},tu=ct(Zc,[["__scopeId","data-v-af0e2aaa"]]),Ye=260;function rr(t,e){const n=e.title===""?0:60,r=t.clientHeight/t.height;return{scaleRatio:r,scaledGap:e.gap*r,scaledTitleHeight:n*r,scaledItemSize:Ye*r,scaledPixelDimensions:{x:t.width*r,y:t.height*r}}}function eu(t,e,n){const r=o=>o%(t.scaledItemSize+t.scaledGap)>t.scaledGap&&o<(t.scaledItemSize+t.scaledGap)*e.size.x+t.scaledGap,s=o=>(o-t.scaledTitleHeight)%(t.scaledItemSize+t.scaledGap)>t.scaledGap&&o<(t.scaledItemSize+t.scaledGap)*e.size.y+t.scaledTitleHeight;return!!(r(n.x)&&s(n.y))}function _r(t,e,n){if(!t)throw new Error("Rendering context not found!");const r={x:n%e.size.x,y:Math.floor(n/e.size.x)},s=e.title===""?0:60;t.fillStyle="rgb(230, 230, 230)",t.fillRect(r.x*(Ye+e.gap)+e.gap,r.y*(Ye+e.gap)+e.gap+s,Ye,Ye)}function bn(t){return!!t.touches}function nu(t){return!!t.dataTransfer}const ru=et({__name:"ChartCanvas",setup(t){const e=F(null),n=Ft(),r=Bn(()=>{const i=e.value.getContext("2d");return i||null});n.watch(i=>i.chart,()=>{n.state.chart.background.type==="image"&&!n.state.chart.background.img.complete&&(n.state.chart.background.img.onload=()=>{o()}),o()}),Ne(()=>{if(!e.value)throw new Error("Couldn't find canvas. Something must have gone wrong with page loading, please refresh.");if(n.state.chart){if(n.state.chart.background.type===Rt.Image){const i=new Image;i.src=n.state.chart.background.value,i.onload=()=>{o()},n.state.chart.background.img=i}s(n.state.chart)}});function s(i){for(const l of i.items)l&&!l.coverImg.complete&&(l.coverImg.onload=()=>{o()})}function o(){if(!e.value)return console.log("The canvas doesn'nt exist! Maybe it tried to re-render after being unmounted.");s(n.state.chart),Vo(e.value,n.state.chart),n.state.chart.items.slice(0,n.state.chart.size.x*n.state.chart.size.y).forEach((i,l)=>{i||_r(r.value,n.state.chart,l)})}return(i,l)=>(R(),D("canvas",{id:"chart-canvas",ref_key:"canvas",ref:e},null,512))}}),su=ct(ru,[["__scopeId","data-v-77fea93c"]]),ou=et({__name:"InteractionCanvas",setup(t){const e=F(null),n=F(null),r=F({x:0,y:0}),s=F({x:0,y:0}),o=Ft();o.watch(x=>x.chart,()=>{l()});const i=Bn(()=>{const x=n.value.getContext("2d");return x||null});function l(){const x=document.getElementById("chart-canvas");if(!x)return console.log("The canvas doesn'nt exist! Maybe it tried to re-render after being unmounted.");n.value.width=x.width,n.value.height=x.height}function a(x){const C=rr(n.value,o.state.chart);return!!eu(C,o.state.chart,p(x,{x:n.value.offsetLeft,y:n.value.offsetTop}))}function d(x,C){if(!i.value)throw new Error("Canvas context not found, the canvas must have loaded incorrectly.");const H=rr(n.value,o.state.chart),V=Ho(x,260);i.value.drawImage(x,Math.floor(C.x/H.scaleRatio-V.width/2),Math.floor(C.y/H.scaleRatio-V.height/2),V.width,V.height)}function c(x){const C=a(x);if(!bn(x)){const V={x:n.value.offsetLeft,y:n.value.offsetTop};s.value={x:x.clientX-V.x+window.scrollX,y:x.clientY-V.y+window.scrollY},C?document.body.style.cursor="pointer":!C&&!e.value&&(document.body.style.cursor="default")}if(bn(x)&&x.type!=="touchend"){r.value={x:x.touches[0].clientX,y:x.touches[0].clientY};const V=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop}),st=n.value.getBoundingClientRect();(V.x<0||V.x>st.width||V.y<0||V.y>st.height)&&h(x)}if(e.value){document.body.style.cursor="grab",l(),_r(i.value,o.state.chart,e.value.originalIndex);const V=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop});d(e.value.itemObject.coverImg,V)}}function h(x){document.body.style.cursor="default",e.value&&o.commit("addItem",{item:null,index:e.value.originalIndex}),z(x),e.value=null}function p(x,C){return bn(x)?x.type==="touchend"?{x:r.value.x-C.x+window.scrollX,y:r.value.y-C.y+window.scrollY}:{x:x.touches[0].clientX-C.x+window.scrollX,y:x.touches[0].clientY-C.y+window.scrollY}:{x:x.clientX-C.x+window.scrollX,y:x.clientY-C.y+window.scrollY}}function _(x){const C=rr(n.value,o.state.chart),H=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop}),V=o.state.chart.title?60*C.scaleRatio:0,st=Math.floor(H.x/(C.scaledItemSize+C.scaledGap));return Math.floor((H.y-V)/(C.scaledItemSize+C.scaledGap))*o.state.chart.size.x+st}function S(x){if(!a(x))return null;const C=_(x),H=o.state.chart.items[C];if(!H)return null;bn(x)&&(r.value={x:x.touches[0].clientX,y:x.touches[0].clientY}),e.value={originalIndex:C,itemObject:H},c(x),l(),_r(i.value,o.state.chart,C);const V=p(x,{x:n.value.offsetLeft,y:n.value.offsetTop});d(e.value.itemObject.coverImg,V)}function A(x){var H;if(!((H=x.dataTransfer)==null?void 0:H.getData("application/json")))return null;z(x)}function Q(x){if(!e.value)return null;z(x)}function z(x){var H;if(!a(x))return e.value=null,l(),null;const C=_(x);if(nu(x)){const V=JSON.parse(((H=x.dataTransfer)==null?void 0:H.getData("application/json"))||"null");if(!V)return null;V.coverImg=ge(V.coverURL),o.commit("addItem",{item:V,index:C})}else{if(!e.value)return null;o.state.chart.items[C]?o.commit("moveItem",{item:e.value.itemObject,oldIndex:e.value.originalIndex,newIndex:C}):(o.commit("addItem",{item:e.value.itemObject,index:C}),o.commit("addItem",{item:null,index:e.value.originalIndex}))}e.value=null,c(x)}function K(x){x.preventDefault()}return(x,C)=>(R(),D("canvas",{id:"interaction-canvas",ref_key:"canvas",ref:n,onMousemove:c,onMouseleave:h,onMousedown:On(S,["left"]),onMouseup:On(Q,["left"]),onDragover:K,onDrop:A,onTouchstart:S,onTouchmove:c,onTouchend:z,onTouchleave:h},null,544))}}),iu=ct(ou,[["__scopeId","data-v-f4221a32"]]),lu=["value","selected"],au=et({__name:"Switcher",setup(t){const e=Ft(),n=F(Fe()),r=F(Ut()),s=F(Ms());e.watch(a=>a.chart,()=>{i()});function o(a){return a.toSorted((d,c)=>r.value[c].timestamp-r.value[d].timestamp)}function i(){n.value=Fe(),r.value=Ut(),s.value=o(Ms())}function l(a){const d=a.target.value,c=Kt(d),h=oi(c.data);n.value=d,e.commit("setEntireChart",h)}return(a,d)=>(R(),D("div",null,[m("select",{id:"chart-switcher",name:"chart-switcher",onChange:l},[(R(!0),D(it,null,se(s.value,(c,h)=>{var p,_,S,A;return R(),D("option",{key:h,value:c,selected:c===n.value},Dt((_=(p=r.value[c])==null?void 0:p.data)!=null&&_.title?(S=r.value[c])==null?void 0:S.data.title:`Untitled (${new Date((A=r.value[c])==null?void 0:A.timestamp).toUTCString()})`),9,lu)}),128))],32)]))}}),cu={id:"top-bar"},uu={class:"switcher-menu"},fu={key:1,class:"download-button"},du=et({__name:"TopBar",setup(t){const e=Ft(),n=F(!1);async function r(){n.value=!0,await li(e.state.chart),n.value=!1}function s(){const i={timestamp:new Date().getTime(),data:je.chart},l=He(i);Kt(l),e.commit("reset")}function o(){const i=Fe();if(window.confirm("Are you sure you want to delete this chart? There's no way to recover it!")){Uc(i);const l=Ut();if(Object.keys(l).length<1)ii(),e.commit("reset");else{const a=Kt(ri());oi(a.data),e.commit("setEntireChart",a.data)}}}return(i,l)=>(R(),D("div",cu,[m("div",uu,[m("button",{onClick:o}," - "),k(au),m("button",{onClick:s}," + ")]),n.value?(R(),D("button",fu,[k(P(No),{id:"loading-icon"}),l[1]||(l[1]=De(" loading... "))])):(R(),D("button",{key:0,class:"download-button",onClick:r},[k(P(Bo),{id:"save-icon"}),l[0]||(l[0]=De(" Download "))]))]))}}),hu={class:"chart-builder"},pu={class:"chart-builder-contents"},mu={class:"canvas-container"},gu=et({__name:"index",setup(t){return(e,n)=>(R(),D("div",hu,[m("div",pu,[k(du),m("div",mu,[k(su,{id:"chart-canvas"}),k(iu,{id:"interaction-canvas"})])])]))}}),vu=ct(gu,[["__scopeId","data-v-7dde5efe"]]),_u=et({__name:"LocalStorageWatcher",setup(t){const e=Ft();return Ne(()=>{Fc();const n=Le();n?e.commit("setEntireChart",n.data):(ii(),e.commit("setEntireChart",Le().data))}),e.subscribe((n,r)=>{if(n.type==="setEntireChart")e.commit("hydrateImages");else{const s=Fe(),o=Le();if(o){const i={...o,data:r.chart};si(i,s)}else{const i=He({timestamp:new Date().getTime(),data:r.chart});Kt(i)}}}),(n,r)=>Tl(n.$slots,"default")}}),bu={key:0,id:"popup"},yu=et({__name:"Popup",setup(t){const e=Ft();return e.watch(n=>n.popupText,()=>{const n=e.state.popupText;setTimeout(()=>{e.state.popupText===n&&e.commit("setPopup",null)},1500)}),(n,r)=>P(e).state.popupText?(R(),D("div",bu,[m("p",null,Dt(P(e).state.popupText),1)])):Ue("",!0)}}),wu={};function xu(t,e){return R(),D("h1",null,"Topsters 3")}const ai=ct(wu,[["render",xu],["__scopeId","data-v-4e93a5a4"]]),ci="/lastfm_logo.svg",Cu="/ia_logo.svg",Iu="/igdb_logo.png",Su="/tmdb.svg",Tu={},Eu={id:"credits"};function Ou(t,e){return R(),D("div",Eu,e[0]||(e[0]=[Po('

Data credits

Last.fm

Topsters 3 is not affiliated with or endorsed by any of the above services.

',3)]))}const ui=ct(Tu,[["render",Ou],["__scopeId","data-v-67d21f69"]]);async function fi(t){const e=new Response(t).body.pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(e).arrayBuffer())}async function Mu(t){const e=new Response(t).body.pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(e).arrayBuffer())}function Ru(t,e,n){const r=new Blob([t]),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`${e||`Untitled ${n}`}.topster`,document.body.appendChild(o),o.click(),o.remove()}async function $s(){const t=Fe(),e={[t]:Le()},n=JSON.stringify(e),r=new TextEncoder().encode(n),s=await Mu(r),o=btoa(s.toString());Ru(o,e[t].data.title,e[t].timestamp)}async function $u(t){const e=Uint8Array.from(atob(t).split(",").map(o=>Number.parseInt(o))),n=new TextDecoder,r=await fi(e);return n.decode(r)}async function ku(t,e){const n=t.target.files;try{const r=await n[0].text(),s=await $u(r),o=JSON.parse(s),i=Object.keys(o)[0],l=jc(i),a=o[i];let d=!1;l?window.confirm("This chart already exists locally. Do you want to overwrite it?")&&(d=!0,si(a,i),Kt(i),vr(e)):(d=!0,He(a,i),Kt(i),vr(e)),d&&alert(`"${a.data.title}" imported successfully!`)}catch(r){console.error(r),alert(`Failed to import charts: ${r}`)}}async function Au(t,e){if(t.target===null)return;const n=t.target.files;if(n===null)return;const r=new FileReader;r.addEventListener("load",async()=>{try{const s=atob(r.result.split("").map(d=>String.fromCharCode(d.charCodeAt(0)-17)).join("")),o=JSON.parse(s)[0],i=JSON.parse(o.options),l=[],a=[];for(const d of Object.entries(i.charts)){let c=`${d[0]}-`;c==="cards-"&&(c="");const h=d[1];try{const p=JSON.parse(o[`${c}custom`]),_=o[`${c}size`],S={x:3,y:3};switch(_){case"25":S.x=p.columns,S.y=p.rows;break;case"40":S.x=5,S.y=8;break;case"42":S.x=6,S.y=7;break;case"100":S.x=10,S.y=10;break;default:S.x=12,S.y=12;break}let A=o[`${c}background`],Q=null;if(!A.startsWith("#"))try{const at=A.match(/url\("(.+?)"\)/);if(at===null)throw new Error("image URL is empty");A=at[1],Q=new Image,Q.src=A}catch(at){console.log(at),A="#000000"}const z=new TextDecoder,K=o[`${c}cards`],x=Uint8Array.from(atob(K.substring(1,K.length-1)),at=>at.charCodeAt(0)),C=await fi(x),H=z.decode(C),V=JSON.parse(H),st=[];for(const at of V){if(at.src===""){st.push(null);continue}const kt=new Image;kt.src=at.src;const qt={title:at.title,coverURL:at.src,coverImg:kt};st.push(qt)}const It={timestamp:new Date().getTime(),data:{title:"",items:st,size:S,background:{type:A.startsWith("#")?Rt.Color:Rt.Image,value:A,img:Q},shadows:p.shadowed,showNumbers:o[`${c}numbered`]==="true",showTitles:o[`${c}titled`]==="true",gap:p.padding*5,font:p.fontFamily}};l.push(It)}catch(p){console.error(p),a.push(h)}}a.length>0?alert(`Failed to import the following charts: ${a.join(", ")}`):alert("Charts imported successfully!"),l.forEach(d=>He(d)),Kt(ri()),vr(e)}catch(s){console.error(s),alert(`The file selected is not a valid Topsters 2 backup: ${s}`)}}),r.readAsText(n[0])}const Jt={NoConnection:"Unable to reach search servers.",BadStatusCode:"The search servers returned an error.",NoResults:"No results found."};async function Du(t){if(t==="")return[];const e=encodeURIComponent(t),n=await fetch(`https://api.topsters.org/api/lastfm/search/${e}`);if(!n)throw new Error(Jt.NoConnection);if(n.status!==200)throw new Error(Jt.BadStatusCode);const r=await n.json();return r.results.albummatches.album.length===0?[]:r.results.albummatches.album}async function Lu(t,e,n){if(t==="")return[];const r=await fetch(`https://api.topsters.org/api/lastfm/user/top?${new URLSearchParams({user:encodeURIComponent(t),type:e,period:n?encodeURIComponent(n):""})}`);if(!r)throw new Error(Jt.NoConnection);if(r.status!==200)throw new Error(Jt.BadStatusCode);return await r.json()}const Pu={class:"form-item"},Uu={class:"form-item"},ju=et({__name:"LastFmImport",setup(t){const e=Ft(),n=F(null),r=F(null);async function s(){const o=n.value.value;if(!o)return null;const i=r.value,l=i.options[i.selectedIndex].value;let a;try{a=await Lu(o,"albums",l)}catch{return alert("Something went wrong when downloading your Last.fm data! Is your username spelled correctly?"),null}const d=[],h=a.filter(_=>_.image.find(A=>A.size==="extralarge")["#text"]===""?(d.push(`${_.artist.name} - ${_.name}`),!1):!0).map(_=>{const S=_.image.find(Q=>Q.size==="extralarge")["#text"],A=new Image;return A.src=S,{title:_.name,creator:_.artist.name,coverImg:A,coverURL:S}});Yc();const p=_=>{for(let S=1;S<=10;S++)if(_0&&alert(`Couldn't add the following albums because they're missing cover art on Last.fm: ${d.join(` diff --git a/index.html b/index.html index 701a985..6e8c432 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ gtag('config', "G-4GL8BY0YV1"); - +