"use strict";(()=>{function t(n,t,i){if(n!==undefined&&t!==undefined&&i!==undefined){if(n<t)return"text-danger";if(n===t)return"text-warning";if(n<=i)return"text-success"}return""}const n=sh.model,i=document.getElementById("completionistTimesForm");i===null||i===void 0?void 0:i.addEventListener("response",i=>__awaiter(void 0,void 0,void 0,function*(){var e;const l=i.detail,o=yield l.json(),s=n.steamUser.steamId===((e=sh.identity)===null||e===void 0?void 0:e.steamId),u=n.steamUser.canImportCompletionistTimes===!0&&s,h=n.steamUser.canImportCompletionistTimes===!1&&!s&&n.steamUser.submittedCompletionistAppIds!==undefined&&sh.settings.enableModTools,c=s?"your":"their",a=o.length===0?`Could not find completion times on ${c} completionist.me profile that are lower than ${c} current playtime.`+(u?" If this is expected, click Submit to confirm no completion times should be submitted. After submitting, the option to submit games will stop appearing on your profile.":""):createElement("fragment",null,u?createElement("p",null,"Select the games below that have completion times you can justify being accurate.",createElement("div",{"class":"alert alert-icon alert-danger"}," If you updated your completionist.me profile after completing a game while it was still running, the completion time is inaccurate."),"A moderator will review your completion times from games that you have submitted. After submitting, the option to submit games will stop appearing on your profile."):"",createElement("div",{"class":"row"},createElement("div",{"class":"table-responsive"},createElement("table",{"class":"table table-col table-condensed table-inverse table-middle text-nowrap"},createElement("thead",null,createElement("tr",null,createElement("th",{"class":"th-xs"},createElement("span",{"class":"check-item"},createElement("label",{"class":"checkbox-custom checkbox-icon"},createElement("input",{type:"checkbox"}),createElement("i",{"class":"fa","aria-hidden":"true"}),createElement("span",{"class":"sr-only"},"Select All")))),createElement("th",{"class":"th-xs"}),createElement("th",null,"Title"),createElement("th",{"class":"text-right"},"Current Time"),createElement("th",{"class":"text-center"},createElement("i",{"class":"fa fa-arrow-right","aria-hidden":"true"})),createElement("th",{"class":"text-right th-xs"},"New Time"),createElement("th",{"class":"text-right"},"Fastest"),createElement("th",{"class":"text-right"},"Median"),createElement("th",{"class":"text-right"}))),createElement("tbody",null,o.map(i=>createElement("tr",{"class":"check-item"},createElement("td",{"class":"check-toggle"},createElement("label",{"class":"checkbox-custom checkbox-icon"},createElement("input",{type:"checkbox",name:"appIds",value:i.appId,checked:i.isSubmitted}),createElement("i",{"class":"fa","aria-hidden":"true"}),createElement("span",{"class":"sr-only"},"Select"))),createElement("td",{"class":"check-toggle"},createElement("span",{"class":"image image-32px image-rounded"},i.icon===undefined?"":createElement("img",{src:`https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/${i.appId}/${i.icon}.jpg`,sizes:"32px",alt:"",loading:"lazy"}))),createElement("td",{"class":"check-toggle"},createElement("div",{"class":"text-ellipsis",style:"max-width: 400px;"},i.name)),createElement("td",{"class":"check-toggle text-right "+t(i.completionTime,i.fastestCompletionTime,i.medianCompletionTime)},i.completionTime!==undefined?getTimeSpan(i.completionTime):""),createElement("td",{"class":"check-toggle text-center"},createElement("i",{"class":"fa fa-arrow-right","aria-hidden":"true"})),createElement("td",{"class":"check-toggle text-right "+t(i.newCompletionTime,i.fastestCompletionTime,i.medianCompletionTime)},getTimeSpan(i.newCompletionTime),i.completionTime===undefined||i.completionTime>i.newCompletionTime?"":createElement("i",{"class":"fa fa-exclamation text-danger after","aria-hidden":"true",title:"This new completion time is larger than your current completion time."})),createElement("td",{"class":"check-toggle text-right "+(i.fastestCompletionTime!==undefined&&i.fastestCompletionTime>=i.newCompletionTime?t(i.fastestCompletionTime,i.fastestCompletionTime,i.medianCompletionTime):"")},i.fastestCompletionTime!==undefined?getTimeSpan(i.fastestCompletionTime):""),createElement("td",{"class":"check-toggle text-right "+(i.medianCompletionTime!==undefined&&i.medianCompletionTime>=i.newCompletionTime?t(i.medianCompletionTime,i.fastestCompletionTime,i.medianCompletionTime):"")},i.medianCompletionTime!==undefined?getTimeSpan(i.medianCompletionTime):""),createElement("td",{"class":"td-anchor text-right"},createElement("a",{href:(n.steamUser.vanityId!==undefined?`/id/${n.steamUser.vanityId}`:`/profiles/${n.steamUser.steamId}`)+`/apps/${i.appId}/users?sort=completiontime&state=completed`,target:"_blank"},createElement("span",null,createElement("i",{"class":"fa fa-external-link","aria-hidden":"true"}),createElement("span",{"class":"sr-only"},"View Game"))))))))))),v=createElement("div",{"class":"media"},createElement("div",{"class":"media-body text-left"},u?createElement("button",{type:"submit","class":"btn btn-primary","data-loading-text":"Submitting"},"Submit"):h?createElement("fragment",null,createElement("button",{type:"submit","class":"btn btn-primary","data-loading-text":"Approving",name:"isApproved",value:"true","data-prompt":"Are you sure you want to approve the selected completionist.me completion times? Optionally, enter an approval note for the moderators. To approve without a note, leave the textbox empty and press OK.","data-prompt-key":"reason"},"Approve"),createElement("button",{type:"submit","class":"btn btn-primary","data-loading-text":"Rejecting",name:"isApproved",value:"false","data-prompt":"Are you sure you want to reject the completionist.me completion times? Please enter the reason for rejecting.","data-prompt-key":"reason","data-prompt-required":!0},"Reject")):"",o.length!==0?createElement("span",{"class":"after check-count"}," game(s) selected"):""),createElement("div",{"class":"media-right"},createElement("button",{type:"button","class":"btn btn-default","data-dismiss":"modal"},"Close")));let r;if(u||h){const t=createElement("form",{id:"completionistTimesModal","class":"check-list","data-api-url":`steam-users/${n.steamUser.steamId}/completionist-times`,"data-api-method":"post","data-reload":!0});u?t.addEventListener("submit",n=>{confirm("You can only submit completion times once. Are you sure you want to continue?")||(n.preventDefault(),n.stopImmediatePropagation())}):h&&t.setAttribute("data-api-url",`steam-users/${n.steamUser.steamId}/completionist-times/review`);r=t}else r=createElement("div",{id:"completionistTimesModal","class":"check-list"});appendModalDialog(r,"Completionist.me Completion Times",a,v,ModalSize.Large);initializeNodes(createElement("fragment",null,r));const f=r.querySelector("table");f!==null&&Table.initializeCheckboxes(f.tHead,f.tHead,f.tBodies[0]);$(r).modal({backdrop:"static",keyboard:!1})}))})()