import sortArrayOfObjects from"/js/modules/sortArrayOfObjects.min.js";import getDomain from"/js/modules/getDomain.min.js";import loadEmbedScript from"/js/modules/loadEmbedScript.min.js";import Cookie from"/js/cookies/main.min.js";const cookieManager=new Cookie,fileInput=document.getElementById("file-input"),introElement=document.getElementById("intro"),loadingAnimation=document.getElementById("loading-animation"),loadingText=document.getElementById("loading-text"),resultsElement=document.getElementById("results"),userInfo=document.getElementById("user-info"),userAvatar=document.getElementById("user-avatar"),userDescription=document.getElementById("user-description"),userDataBreakdown=document.getElementById("user-data-breakdown"),chartElement=document.getElementById("chart"),handleUpload=()=>{fileInput&&fileInput.addEventListener("change",async e=>{loadingAnimation.classList.remove("d-none"),loadingText.classList.remove("d-none"),fileInput.disabled=!0;var s=new FormData;s.set("archive",fileInput.files[0]);s=await(await fetch("/extract-data",{method:"POST",body:s})).json();if(s&&s.data){introElement.classList.add("d-none"),resultsElement.classList.remove("d-none");s=s.data;let e="",t="",r=(s.actor?(e+=`

${s.actor.name||s.actor.preferredUsername}

${s.actor.summary.replaceAll('class="invisible"',"")} `,s.actor.attachment&&(e+=` `),userDescription.innerHTML=`
${e}
`,s.avatar_url?userAvatar.innerHTML=` `:s.avatar&&(userAvatar.innerHTML=` `)):(userInfo.remove(),userDescription.remove()),[]),o;s?.outbox?.orderedItems?r=s.outbox.orderedItems:s?.outbox&&(r=s.outbox),i=r.length;let n=[],l={posts:0,replies:0,reblogs:0,total:0};if(i){const m=Math.ceil(Math.pow(r.length,.1));let s=0;o=r[0],r.forEach(t=>{let o=!1;if([...t.to,...t.cc].forEach(e=>{e.endsWith("/followers")&&(o=!0)}),o){if(s++,10<=r.length&&s<=m){const t=r[Math.pow(10,s)];var a=t.id.replace("/activity","");let e=!1;t.object.id||(e=!0),a={label:[Math.pow(10,s).toLocaleString()+"th post"],url:a,isBoost:e},n.push(a)}l.total++,"Create"===t.type?t.object.inReplyTo?l.replies++:l.posts++:l.reblogs++}})}var i={weekday:"long",year:"numeric",month:"long",day:"numeric"};s.actor&&(d=moment(s.actor.published),d=moment().diff(d,"days"),t+=`

You created your account on ${new Date(s.actor.published).toLocaleDateString(void 0,i)}, which is ${d.toLocaleString()} day(s) ago. Since then, you posted ${l.total.toLocaleString()} times, or about ${Math.round(l.total/d).toLocaleString()} time(s) a day on average.

`),(0 You have reblogged ${l.reblogs.toLocaleString()} post(s), replied ${l.replies.toLocaleString()} time(s), and posted ${l.posts.toLocaleString()} new post(s).

`);let a;if(o){let e;if(!["firefish","calckey","misskey"].includes(s.format)){i=o?.uri||o?.object?.id||o?.id;try{e=new URL(i)}catch(e){console.log("error parsing data file",e)}e&&e.protocol&&e.hostname&&(a=e.protocol+"//"+e.hostname),t+=`

Here's your first post!

`,"mastodon"===s.format&&(t+=` `),n&&n.length&&(t+=`

Here are more of your milestones:

`),t+=`

And this is what your posting history looks like.

`}}userDataBreakdown.innerHTML=t,"mastodon"===s.format&&loadEmbedScript(a);var d={labels:r.map(e=>moment(e.published||e.createdAt||e.created)),datasets:[{label:"Your posts in time",data:r.map((e,t)=>({x:moment(e.published||e.createdAt||e.created),y:new Date(e.published||e.createdAt||e.created).getHours()})),backgroundColor:["#ff6384"]}]};new Chart(chartElement,{type:"scatter",data:d,options:{scales:{x:{type:"time",position:"bottom",ticks:{beginAtZero:!1,stepSize:10}},y:{ticks:{beginAtZero:!1,display:!1},scaleLabel:{display:!1},minorTickInterval:null}},plugins:{tooltip:{callbacks:{label:e=>e.label}}}}})}else loadingAnimation.classList.add("d-none"),loadingText.classList.add("d-none"),fileInput.disabled=!1})};export default handleUpload; //# sourceMappingURL=handleUpload.min.js.map