parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"tQUs":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=e=>parseInt(new URLSearchParams(e).get("id"));exports.default=e;
},{}],"dSAr":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=t(require("../utils/getIDFromURL"));function t(e){return e&&e.__esModule?e:{default:e}}class r{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.dom=(new DOMParser).parseFromString(e,"text/html"),this.trs=this.dom.querySelectorAll("#in_a_day_ranking_table tbody tr"),this.filters=t}isValidRow(e){return!!e&&((!this.filters.playerID||e.playerID===this.filters.playerID)&&!(this.filters.tribes&&Array.isArray(this.filters.tribes)&&!this.filters.tribes.some(t=>t===e.tribe)))}parseRow(t){if(!t||!t instanceof HTMLTableRowElement)return;let r={};return r.rank=parseInt(t.children[0].innerText.trim()),r.name=t.children[1].innerText.trim(),r.playerID=(0,e.default)(t.children[1].querySelector("a").getAttribute("href")),r.tribe=t.children[2].innerText.trim(),r.tribeID=0,r.tribe&&(r.tribeID=(0,e.default)(t.children[2].querySelector("a").getAttribute("href"))),r.score=parseInt(t.children[3].innerText.trim().replace(/\./g,"")),r.date=t.children[4].innerText.trim(),r}parse(){const e=[];for(let t=1;t<this.trs.length;t++){const r=this.trs[t],i=this.parseRow(r);this.isValidRow(i)&&e.push(i)}return e}}exports.default=r;
},{"../utils/getIDFromURL":"tQUs"}],"Ph2E":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.API_URI=void 0;const e="https://api.tribalwarshelp.com/graphql";exports.API_URI=e;var r=function(){let{query:r,variables:t={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return fetch(e,{method:"POST",body:JSON.stringify({query:r,variables:t}),headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{let{data:r,errors:t}=e;if(t&&Array.isArray(t)&&t.length>0)throw new Error(t[0].message);return new Promise(e=>e(r))})};exports.default=r;
},{}],"I8dv":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;const e={pl_PL:{date:"Data",newTribe:"Nowe plemię",oldTribe:"Poprzednie plemię",joinedAt:"Dołączył",dailyGrowth:"Dzienny przyrost",bestRank:"Najlepszy ranking",mostPoints:"Najwięcej punktów",mostVillages:"Najwięcej wiosek",oldName:"Poprzedni nick",newName:"Nowy nick",playerServers:"Serwery gracza",inADayBestScores:"Dzienne rankingi",unitsDefeatedWhileAttacking:"Jako atakujący",unitsDefeatedWhileDefending:"Jako obrońca",unitsDefeatedWhileSupporting:"Jako wspierający",resourcesPlundered:"Sfarmione surowce",villagesPlundered:"Splądrowane wioski",resourcesGathered:"Zebrane surowce",villagesConquered:"Podbite wioski",exportedVillages:"Wyeksportowane wioski",tribeChanges:"Zmiany plemion",action:{linkToTWHelp:"Akta gracza (TWHelp)",showTribeChanges:"Pokaż zmiany plemion",showEnnoblements:"Pokaż przejęcia",exportVillages:"Wyeksportuj wioski",showHistory:"Pokaż historię"}},en_DK:{date:"Date",newTribe:"New tribe",oldTribe:"Old tribe",joinedAt:"Joined at",dailyGrowth:"Daily growth",bestRank:"Best rank",mostPoints:"Most points",mostVillages:"Most villages",oldName:"Old name",newName:"New name",playerServers:"Player's servers",inADayBestScores:"'In a day' best scores",unitsDefeatedWhileAttacking:"Units defeated while attacking",unitsDefeatedWhileDefending:"Units defeated while defending",unitsDefeatedWhileSupporting:"Units defeated while supporting",resourcesPlundered:"Resources plundered",villagesPlundered:"Villages plundered",resourcesGathered:"Resources gathered",villagesConquered:"Villages conquered",exportedVillages:"Exported villages",tribeChanges:"Tribe changes",action:{linkToTWHelp:"User file (TWHelp)",showTribeChanges:"Show tribe changes",showEnnoblements:"Show ennoblements",exportVillages:"Export villages",showHistory:"Show history"}}};var i=()=>e[window.game_data.locale]||e.en_DK;exports.default=i;
},{}],"l9PO":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;const a={pl_PL:{title:"Dzisiejsze zmiany w statystykach",points:"Punkty",rank:"Ranking",villages:"Liczba wiosek",members:"Liczba członków",oda:"Pokonani przeciwnicy jako agresor",odaRank:"RA",odd:"Pokonani przeciwnicy jako obrońca",oddRank:"RO",ods:"Pokonani przeciwnicy jako wspierający",odsRank:"RW",od:"Pokonani przeciwnicy",odRank:"Pokonani przeciwnicy razem ranking"},en_DK:{title:"Today's stat changes",points:"Points",rank:"Rank",villages:"Villages",members:"Members",oda:"ODA",odaRank:"ODA Rank",odd:"ODD",oddRank:"ODD Rank",ods:"ODS",odsRank:"ODS Rank",od:"OD",odRank:"OD Rank"}};var o=()=>a[window.game_data.locale]||a.en_DK;exports.default=o;
},{}],"yQib":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=e=>null==e;exports.default=e;
},{}],"yrCm":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=a(require("../i18n/renderTodaysStats")),n=a(require("../utils/isNil"));function a(t){return t&&t.__esModule?t:{default:t}}const c=(0,t.default)(),o=t=>{return t>0?"color: #000; background-color: #0f0":t<0?"color: #000; background-color: #f00":"color: #000; background-color: #808080"};var r=(t,a)=>{let r=t.querySelector("#todaysStats");r||((r=document.createElement("div")).id="todaysStats",r.width="100%",t.prepend(r));const d=!(0,n.default)(a.rankSup);r.innerHTML='\n      <table width="100%" class="vis">\n        <tbody>\n          <tr>\n            <th colspan="2">\n              '.concat(c.title,"\n            </th>\n          </tr>\n            <tr>\n              <td>\n                ").concat(c.points,':\n              </td>\n              <td style="').concat(o(a.points),'">\n                ').concat(Math.abs(a.points).toLocaleString(),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.rank,':\n              </td>\n              <td style="').concat(o(a.rank),'">\n                ').concat(Math.abs(a.rank),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.villages,':\n              </td>\n              <td style="').concat(o(a.villages),'">\n                ').concat(Math.abs(a.villages).toLocaleString(),"\n              </td>\n            </tr>\n            ").concat(d?"":"<tr>\n              <td>\n                ".concat(c.members,':\n              </td>\n              <td style="').concat(o(a.members),'">\n                ').concat(Math.abs(a.members),"\n              </td>\n            </tr>"),"\n            <tr>\n              <td>\n                ").concat(c.oda,':\n              </td>\n              <td style="').concat(o(a.scoreAtt),'">\n                ').concat(Math.abs(a.scoreAtt).toLocaleString(),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.odaRank,':\n              </td>\n              <td style="').concat(o(a.rankAtt),'">\n                ').concat(Math.abs(a.rankAtt),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.odd,':\n              </td>\n              <td style="').concat(o(a.scoreDef),'">\n                ').concat(Math.abs(a.scoreDef).toLocaleString(),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.oddRank,':\n              </td>\n              <td style="').concat(o(a.rankDef),'">\n                ').concat(Math.abs(a.rankDef),"\n              </td>\n            </tr>\n            ").concat(d?"<tr>\n              <td>\n                ".concat(c.ods,':\n              </td>\n              <td style="').concat(o(a.scoreSup),'">\n                ').concat(Math.abs(a.scoreSup).toLocaleString(),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.odsRank,':\n              </td>\n              <td style="').concat(o(a.rankSup),'">\n                ').concat(Math.abs(a.rankSup),"\n              </td>\n            </tr>"):"","\n            <tr>\n              <td>\n                ").concat(c.od,':\n              </td>\n              <td style="').concat(o(a.scoreTotal),'">\n                ').concat(Math.abs(a.scoreTotal).toLocaleString(),"\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(c.odRank,':\n              </td>\n              <td style="').concat(o(a.rankTotal),'">\n                ').concat(Math.abs(a.rankTotal),"\n              </td>\n            </tr>\n      </tbody>\n      </table>\n  ")};exports.default=r;
},{"../i18n/renderTodaysStats":"l9PO","../utils/isNil":"yQib"}],"chDM":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.POPUP_SELECTOR=void 0;const t=".popup_box";exports.POPUP_SELECTOR=".popup_box";const o=function(){let{html:t,id:o,title:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Dialog.show(o,"<h3>".concat(e,"</h3>")+t);const p=document.querySelector(".popup_box");p&&(p.style.width="auto",p.style.maxWidth="1000px")};var e=o;exports.default=e;
},{}],"tKRp":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;const e={pl_PL:{date:"Data",newOwner:"Nowy właściciel",oldOwner:"Poprzedni właściciel",village:"Wioska",title:"Przejęcia"},en_DK:{date:"Date",newOwner:"New owner",oldOwner:"Old owner",village:"Village",title:"Ennoblements"}};var l=()=>e[window.game_data.locale]||e.en_DK;exports.default=l;
},{}],"fCHX":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generatePaginationItems=exports.calcNumberOfPages=exports.getPage=exports.setPage=exports.getContainerStyles=void 0;const e="data-page",t=()=>"display: flex; flex-direction: row; flex-wrap: wrap;";exports.getContainerStyles=t;const r=function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(!t instanceof HTMLElement)throw new Error("Expected HTMLElement as the first argument");if("number"!=typeof(r=parseInt(r))||isNaN(r))throw new Error("Expected number or string as the second argument");t.setAttribute(e,r+"")};exports.setPage=r;const n=t=>!t instanceof HTMLElement?0:parseInt(t.getAttribute(e));exports.getPage=n;const o=(e,t)=>{if("number"!=typeof e)throw new Error("Expected number as the first argument");if("number"!=typeof t)throw new Error("Expected number as the second argument");return e>0?Math.ceil(e/t):1};exports.calcNumberOfPages=o;const a=function(){let{total:t,limit:r,marginRight:n=3,currentPage:a=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s=o(t,r),c=[];for(let o=1;o<=s;o++)o===a?c.push('<strong style="margin-right: '.concat(n,'px">>').concat(o,"<</strong>")):c.push('<a style="margin-right: '.concat(n,'px" href="#" ').concat(e,'="').concat(o,'">').concat(o,"</a>"));return c};exports.generatePaginationItems=a;
},{}],"ZbyX":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDate=exports.inUTC=exports.inTZ=void 0;const t=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"UTC";return new Date(new Date(t).toLocaleString("en-US",{timeZone:e}))};exports.inTZ=t;const e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return t(e)};exports.inUTC=e;const n=(t,e)=>new Date(t).toLocaleDateString(void 0,e||{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});exports.formatDate=n;
},{}],"fHHP":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildImgURL=exports.calcAttackDuration=exports.buildVillageName=exports.buildVillageURL=exports.buildPlayerURL=exports.buildTribeURL=void 0;const i=i=>window.location.origin+TribalWars.buildURL("",{screen:"info_ally",id:i});exports.buildTribeURL=i;const o=i=>window.location.origin+TribalWars.buildURL("",{screen:"info_player",id:i});exports.buildPlayerURL=o;const e=i=>window.location.origin+TribalWars.buildURL("",{screen:"info_village",id:i});exports.buildVillageURL=e;const t=function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;const t="K"+String(e)[0]+String(o)[0];return"".concat(i," (").concat(o,"|").concat(e,") ").concat(t)};exports.buildVillageName=t;const l=(i,o)=>Math.round(i*o);exports.calcAttackDuration=l;const r=i=>image_base+i;exports.buildImgURL=r;
},{}],"vNT1":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=l(require("../i18n/showEnnoblementsPopup")),t=require("../utils/pagination"),n=l(require("../utils/showPopup")),r=require("../utils/date"),a=i(require("../utils/tribalwars"));function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}function i(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=r?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,t&&t.set(e,n),n}function l(e){return e&&e.__esModule?e:{default:e}}const c="ennoblementsPagination",d=(0,e.default)(),u=(e,t)=>e?'<td><a href="'.concat(a.buildPlayerURL(e.id),'">').concat(e.name," (").concat(t?'<a href="'.concat(a.buildTribeURL(t.id),'">').concat(t.tag,"</a>"):"-",")</a></td>"):"<td>-</td>";var s=function(e,o){let{limit:i=0,currentPage:l=1,onPageChange:s=(()=>{})}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const f=(0,t.generatePaginationItems)({total:o.total,limit:i,currentPage:l}),p='\n    <div style="'.concat((0,t.getContainerStyles)(),'" id="').concat(c,'">\n      ').concat(f.join(""),'\n    </div>\n    <table class="vis" style="border-collapse: separate; border-spacing: 2px; width: 100%;">\n      <tbody>\n        <tr>\n          <th>\n            ').concat(d.date,"\n          </th>\n          <th>\n            ").concat(d.village,"\n          </th>\n          <th>\n            ").concat(d.newOwner,"\n          </th>\n          <th>\n            ").concat(d.oldOwner,"\n          </th>\n        </tr>\n        ").concat(o.items.map(e=>{let t="<tr>"+"<td>".concat((0,r.formatDate)(e.ennobledAt),"</td>");return e.village?t+='<td><a href="'.concat(a.buildVillageURL(e.village.id),'">').concat(a.buildVillageName(e.village.name,e.village.x,e.village.y),"</a></td>"):t+="<td>-</td>",t+=u(e.newOwner,e.newOwnerTribe),(t+=u(e.oldOwner,e.oldOwnerTribe))+"</tr>"}).join(""),"\n      </tbody>\n    </table>\n  ");(0,n.default)({e:e,title:d.title,id:"ennoblements",html:p}),document.querySelectorAll("#ennoblementsPagination a").forEach(e=>{e.addEventListener("click",s)})};exports.default=s;
},{"../i18n/showEnnoblementsPopup":"tKRp","../utils/pagination":"fCHX","../utils/showPopup":"chDM","../utils/date":"ZbyX","../utils/tribalwars":"fHHP"}],"VYL5":[function(require,module,exports) {
"use strict";function e(e){if(null===e||!0===e||!1===e)return NaN;var r=Number(e);return isNaN(r)?r:r<0?Math.ceil(r):Math.floor(r)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;
},{}],"kK6Q":[function(require,module,exports) {
"use strict";function e(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;
},{}],"KYJg":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var e=t(require("../_lib/requiredArgs/index.js"));function t(e){return e&&e.__esModule?e:{default:e}}function r(t){(0,e.default)(1,arguments);var r=Object.prototype.toString.call(t);return t instanceof Date||"object"==typeof t&&"[object Date]"===r?new Date(t.getTime()):"number"==typeof t||"[object Number]"===r?new Date(t):("string"!=typeof t&&"[object String]"!==r||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn((new Error).stack)),new Date(NaN))}
},{"../_lib/requiredArgs/index.js":"kK6Q"}],"lQIY":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=a;var e=u(require("../_lib/toInteger/index.js")),t=u(require("../toDate/index.js")),r=u(require("../_lib/requiredArgs/index.js"));function u(e){return e&&e.__esModule?e:{default:e}}function a(u,a){(0,r.default)(2,arguments);var i=(0,t.default)(u),d=(0,e.default)(a);return isNaN(d)?new Date(NaN):d?(i.setDate(i.getDate()+d),i):i}
},{"../_lib/toInteger/index.js":"VYL5","../toDate/index.js":"KYJg","../_lib/requiredArgs/index.js":"kK6Q"}],"mRRL":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=d;var e=u(require("../_lib/toInteger/index.js")),r=u(require("../addDays/index.js")),t=u(require("../_lib/requiredArgs/index.js"));function u(e){return e&&e.__esModule?e:{default:e}}function d(u,d){(0,t.default)(2,arguments);var i=(0,e.default)(d);return(0,r.default)(u,-i)}
},{"../_lib/toInteger/index.js":"VYL5","../addDays/index.js":"lQIY","../_lib/requiredArgs/index.js":"kK6Q"}],"hNDe":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;const e={pl_PL:{title:"Historia",date:"Data",tribe:"Plemię",points:"Punkty",rank:"Ranking",villages:"Liczba wiosek",members:"Liczba członków",oda:"Pokonani przeciwnicy jako agresor",odd:"Pokonani przeciwnicy jako obrońca",ods:"Pokonani przeciwnicy jako wspierający",od:"Pokonani przeciwnicy"},en_DK:{title:"History",date:"Date",tribe:"Tribe",points:"Points",villages:"Villages",members:"Members",oda:"ODA",odd:"ODD",ods:"ODS",od:"OD"}};var o=()=>e[window.game_data.locale]||e.en_DK;exports.default=o;
},{}],"kEDU":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=s(require("date-fns/subDays")),n=s(require("../i18n/showHistoryPopup")),e=s(require("../utils/showPopup")),o=require("../utils/pagination"),a=require("../utils/date"),r=i(require("../utils/tribalwars"));function c(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return c=function(){return t},t}function i(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c();if(n&&n.has(t))return n.get(t);var e={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){var r=o?Object.getOwnPropertyDescriptor(t,a):null;r&&(r.get||r.set)?Object.defineProperty(e,a,r):e[a]=t[a]}return e.default=t,n&&n.set(t,e),e}function s(t){return t&&t.__esModule?t:{default:t}}const l="historyPagination",d=(0,n.default)(),u=t=>t>0?"+"+t:t;var g=function(n,c,i){let{currentPage:s=1,limit:l=0,onPageChange:g=(()=>{}),tribe:f=!1}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const p=(0,o.generatePaginationItems)({total:c.total,limit:l,currentPage:s}),h='\n    <div style="'.concat((0,o.getContainerStyles)(),'" id="').concat("historyPagination",'">\n      ').concat(p.join(""),'\n    </div>\n    <table class="vis" style="border-collapse: separate; border-spacing: 2px; width: 100%;">\n      <tbody>\n        <tr>\n          <th>\n            ').concat(d.date,"\n          </th>\n          ").concat(f?"":"<th>".concat(d.tribe,"</th>"),"\n          <th>\n          ").concat(d.points,"\n          </th>\n          <th>\n          ").concat(d.villages,"\n          </th>\n          ").concat(f?"<th>".concat(d.members,"</th>"):"","\n          <th>\n            ").concat(d.od,"\n          </th>\n          <th>\n            ").concat(d.oda,"\n          </th>\n          <th>\n            ").concat(d.odd,"\n          </th>\n          ").concat(f?"":"<th>".concat(d.ods,"</th>"),"\n        </tr>\n        ").concat(c.items.map(n=>{const e=(0,t.default)(new Date(n.createDate),1).toISOString().split(".")[0]+"Z",o=i.items.find(t=>t.createDate===e);let c="<tr>"+"<td>".concat((0,a.formatDate)(n.createDate,{year:"numeric",month:"2-digit",day:"2-digit"}),"</td>");return!f&&n.tribe?c+='<td><a href="'.concat(r.buildTribeURL(n.tribe.id),'">').concat(n.tribe.tag,"</a></td>"):f||(c+="<td>-</td>"),c+='\n              <td title="'.concat(o?u(o.points):"",'">\n                ').concat(n.points.toLocaleString()," (<strong>").concat(n.rank,'</strong>)\n              </td>\n              <td title="').concat(o?u(o.villages):"",'">\n                ').concat(n.totalVillages.toLocaleString(),"\n              </td>\n              ").concat(f?'\n                  <td title="'.concat(o?u(o.members):"",'">\n                    ').concat(n.totalMembers,"\n                </td>\n              "):"",'\n              <td title="').concat(o?u(o.scoreTotal):"",'">\n                ').concat(n.scoreTotal.toLocaleString()," (<strong>").concat(n.rankTotal,'</strong>)\n              </td>\n              <td title="').concat(o?u(o.scoreAtt):"",'">\n                ').concat(n.scoreAtt.toLocaleString()," (<strong>").concat(n.rankAtt,'</strong>)\n              </td>\n              <td title="').concat(o?u(o.scoreDef):"",'">\n                ').concat(n.scoreDef.toLocaleString()," (<strong>").concat(n.rankDef,"</strong>)\n              </td>\n              ").concat(f?"":'\n                  <td title="'.concat(o?u(o.scoreSup):"",'">\n                    ').concat(n.scoreSup.toLocaleString()," (<strong>").concat(n.rankSup,"</strong>)\n                </td>\n              "),"\n            ")+"</tr>"}).join(""),"\n      </tbody>\n    </table>\n  ");(0,e.default)({e:n,title:d.title,id:"history",html:h}),document.querySelectorAll("#historyPagination a").forEach(t=>{t.addEventListener("click",g)})};exports.default=g;
},{"date-fns/subDays":"mRRL","../i18n/showHistoryPopup":"hNDe","../utils/showPopup":"chDM","../utils/pagination":"fCHX","../utils/date":"ZbyX","../utils/tribalwars":"fHHP"}],"GxsT":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=e=>{const t=e.split(/[_-]/);let r="";for(let s=1;s<t.length;s++)r+=t[s].charAt(0).toUpperCase()+t[s].slice(1);return t[0]+r};exports.default=e;
},{}],"DMkL":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=()=>window.location.host.split(".")[0];exports.default=e;
},{}],"J1Ly":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").substr(0,2)};exports.default=e;
},{}],"gvXE":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildVillageURL=exports.buildTribeURL=exports.buildPlayerURL=exports.buildURLToProfile=exports.buildURLToServerPage=exports.BASE_URL=void 0;const e="tribalwarshelp.com";exports.BASE_URL=e;const t=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"https://".concat(t,".").concat(e,"/server/").concat(o)};exports.buildURLToServerPage=t;const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return"".concat(t(e,o),"/").concat(n,"/").concat(l)};exports.buildURLToProfile=o;const l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return o(e,t,l,"player")};exports.buildPlayerURL=l;const n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return o(e,t,l,"tribe")};exports.buildTribeURL=n;const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return o(e,t,l,"village")};exports.buildVillageURL=i;
},{}],"KWxH":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setItem=exports.getItem=void 0;const e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=localStorage.getItem(e);let s=t;return o&&(s=JSON.parse(o)),s};exports.getItem=e;const t=(e,t)=>{localStorage.setItem(e,JSON.stringify(t))};exports.setItem=t;
},{}],"yRop":[function(require,module,exports) {
"use strict";var e=b(require("./libs/InADayParser")),t=b(require("./libs/requestCreator")),n=b(require("./i18n/extendedPlayerProfile")),r=b(require("./common/renderTodaysStats")),a=b(require("./utils/showPopup")),i=b(require("./common/showEnnoblementsPopup")),o=b(require("./common/showHistoryPopup")),l=b(require("./utils/hyphensToCamelCase")),s=require("./utils/pagination"),c=b(require("./utils/getIDFromURL")),d=b(require("./utils/getCurrentServer")),u=b(require("./utils/getServerVersionCode")),y=require("./utils/date"),f=h(require("./utils/tribalwars")),m=h(require("./utils/twhelp")),p=require("./utils/localStorage");function g(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return g=function(){return e},e}function h(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=g();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=r?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,t&&t.set(e,n),n}function b(e){return e&&e.__esModule?e:{default:e}}function v(e,t){if(null==e)return{};var n,r,a=D(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function D(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}const S=(0,d.default)(),w=(0,u.default)(S);let P=(0,c.default)(window.location.search);const $=parseInt(game_data.player.id);!isNaN(P)&&P||(P=$);const k="kichiyaki_extended_player_profile"+P,A="\n    query player($server: String!, $id: Int!, $limit: Int, $sort: [String!], $filter: DailyPlayerStatsFilter) {\n        player(server: $server, id: $id) {\n            id\n            name\n            bestRank\n            bestRankAt\n            mostPoints\n            mostPointsAt\n            mostVillages\n            mostVillagesAt\n            servers\n            joinedAt\n            nameChanges {\n                oldName\n                newName\n                changeDate\n            }\n            dailyGrowth\n        }\n        dailyPlayerStats(server: $server, limit: $limit, sort: $sort, filter: $filter) {\n            items {\n              rank\n              rankAtt\n              rankDef\n              rankSup\n              rankTotal\n              points\n              scoreAtt\n              scoreAtt\n              scoreDef\n              scoreSup\n              scoreTotal\n              villages\n            }\n        }\n    }\n",q="\n    query tribeChanges($server: String!, $limit: Int, $offset: Int, $sort: [String!], $filter: TribeChangeFilter!) {\n      tribeChanges(server: $server, limit: $limit, offset: $offset, sort: $sort, filter: $filter) {\n        total\n        items {\n          oldTribe {\n            id\n            tag\n          }\n          newTribe {\n            id\n            tag\n          }\n          createdAt\n        }\n      }\n    }\n",T="tribeChangesPagination",C=15,L="\nquery playerHistoryAndPlayerDailyStats($server: String!,\n     $playerHistoryFilter: PlayerHistoryFilter!,\n     $dailyPlayerStatsFilter: DailyPlayerStatsFilter!,\n     $limit: Int,\n     $offset: Int,\n     $sort: [String!]) {\n  playerHistory(server: $server, limit: $limit, offset: $offset, sort: $sort, filter: $playerHistoryFilter) {\n    total\n    items {\n      totalVillages\n      points\n      rank\n      scoreAtt\n      rankAtt\n      scoreDef\n      rankDef\n      scoreSup\n      rankSup\n      scoreTotal\n      rankTotal\n      tribe {\n        id\n        tag\n      }\n      createDate\n    }\n  }\n  dailyPlayerStats(server: $server, limit: $limit, offset: $offset, sort: $sort, filter: $dailyPlayerStatsFilter) {\n    items {\n        points\n        scoreAtt\n        scoreAtt\n        scoreDef\n        scoreSup\n        scoreTotal\n        villages\n        createDate\n      }\n    }\n}\n",E=15,_="\n    query ennoblements($server: String!, $limit: Int, $offset: Int, $sort: [String!], $filter: EnnoblementFilter!) {\n      ennoblements(server: $server, limit: $limit, offset: $offset, sort: $sort, filter: $filter) {\n        total\n        items {\n          village {\n            id\n            name\n            x\n            y\n          }\n          oldOwner {\n            id\n            name\n          }\n          oldOwnerTribe {\n            id\n            tag\n          }\n          newOwner {\n            id\n            name\n          }\n          newOwnerTribe {\n            id\n            tag\n          }\n          ennobledAt\n        }\n      }\n    }\n",O=15,I=document.querySelector("#player_info > tbody"),H=P===$?I:document.querySelector("#content_value > table > tbody > tr > td:nth-child(1) > table:nth-child(2) > tbody"),j=document.querySelector(P===$?"#content_value > table:nth-child(7) > tbody > tr > td:nth-child(2)":"#content_value > table > tbody > tr > td:nth-child(2)"),M=(0,n.default)(),N=()=>(0,p.getItem)(k),R=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,p.setItem)(k,e)},x=async function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{name:r}=n,a=v(n,["name"]);try{const n=await fetch(TribalWars.buildURL("",{screen:"ranking",mode:"in_a_day",type:t,name:r||""})),o=await n.text();if(!o)throw new Error;const l=new e.default(o,a).parse();if(0===l.length)throw new Error;return l[0]}catch(i){return{rank:0,playerID:0,score:0,tribeID:0,tribe:"",date:new Date}}},F=async()=>{const e=await(0,t.default)({query:A,variables:{server:S,id:P,limit:1,sort:["createDate DESC"],filter:{playerID:[P]}}});if(e.player){const t={},n={name:e.player.name,playerID:e.player.id};for(let e of["kill_att","kill_def","kill_sup","loot_res","loot_vil","scavenge","conquer"])t[(0,l.default)(e.replace("kill_",""))]=await x(e,n);e.player.inADay=t}return R(e),e},V=e=>{let{title:t,data:n,id:r}=e,a=document.querySelector("#"+r);a||((a=document.createElement("tr")).id=r,a.appendChild(document.createElement("td")),a.appendChild(document.createElement("td")),I.append(a)),a.children[0].innerHTML=t,a.children[1].innerHTML=n},W=e=>{let t=document.querySelector("#playerServers");t||((t=document.createElement("table")).id="playerServers",t.classList.add("vis"),t.width="100%",t.innerHTML="\n     <tbody>\n        <tr>\n          <th>\n            ".concat(M.playerServers,"\n          </th>\n        </tr>\n        <tr>\n          <td>\n          </td>\n        </tr>\n     </tbody>\n    "),j.prepend(t)),t.querySelector("td").innerHTML=e.servers.sort().map(t=>'<a target="_blank" style="margin-right: 5px" href="'.concat(m.buildPlayerURL(w,t,e.id),'">').concat(t,"</a>")).join("")},U=e=>{let t=document.querySelector("#playerOtherNames");t||((t=document.createElement("div")).id="playerOtherNames",t.width="100%",j.prepend(t)),t.innerHTML='\n      <table width="100%" class="vis">\n        <tbody>\n          <tr>\n            <th>\n            '.concat(M.oldName,"\n            </th>\n            <th>\n            ").concat(M.newName,"\n            </th>\n            <th>\n            ").concat(M.date,"\n            </th>\n          </tr>\n        ").concat(e.nameChanges.map(e=>"\n            <tr>\n              <td>\n                ".concat(e.oldName,"\n              </td>\n              <td>\n                ").concat(e.newName,"\n              </td>\n              <td>\n                ").concat((0,y.formatDate)(e.changeDate,{year:"numeric",month:"2-digit",day:"2-digit"}),"\n              </td>\n            </tr>\n          ")).join(""),"\n      </tbody>\n      </table>\n  ")},G=e=>{let t=document.querySelector("#inADayRanks");t||((t=document.createElement("div")).id="inADayRanks",t.width="100%",j.prepend(t)),t.innerHTML='\n      <table width="100%" class="vis">\n        <tbody>\n          <tr>\n            <th colspan="2">\n              '.concat(M.inADayBestScores,"\n            </th>\n          </tr>\n            <tr>\n              <td>\n                ").concat(M.unitsDefeatedWhileAttacking,"\n              </td>\n              <td>\n                ").concat(e.inADay.att.score.toLocaleString()," (").concat(e.inADay.att.rank,".)\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(M.unitsDefeatedWhileDefending,"\n              </td>\n              <td>\n                ").concat(e.inADay.def.score.toLocaleString()," (").concat(e.inADay.def.rank,".)\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(M.unitsDefeatedWhileSupporting,"\n              </td>\n              <td>\n                ").concat(e.inADay.sup.score.toLocaleString()," (").concat(e.inADay.sup.rank,".)\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(M.resourcesPlundered,"\n              </td>\n              <td>\n                ").concat(e.inADay.lootRes.score.toLocaleString()," (").concat(e.inADay.lootRes.rank,".)\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(M.villagesPlundered,"\n              </td>\n              <td>\n                ").concat(e.inADay.lootVil.score.toLocaleString()," (").concat(e.inADay.lootVil.rank,".)\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(M.resourcesGathered,"\n              </td>\n              <td>\n                ").concat(e.inADay.scavenge.score.toLocaleString()," (").concat(e.inADay.scavenge.rank,".)\n              </td>\n            </tr>\n            <tr>\n              <td>\n                ").concat(M.villagesConquered,"\n              </td>\n              <td>\n                ").concat(e.inADay.conquer.score.toLocaleString()," (").concat(e.inADay.conquer.rank,".)\n              </td>\n            </tr>\n      </tbody>\n      </table>\n  ")},B=e=>{let{player:t,dailyPlayerStats:n}=e;[{title:M.joinedAt+":",data:(0,y.formatDate)(t.joinedAt),id:"joined_at"},{title:M.dailyGrowth+":",data:t.dailyGrowth.toLocaleString(),id:"dg"},{title:M.bestRank+":",data:t.bestRank+" "+"(".concat((0,y.formatDate)(t.bestRankAt),")"),id:"best_rank"},{title:M.mostPoints+":",data:t.mostPoints.toLocaleString()+" "+"(".concat((0,y.formatDate)(t.mostPointsAt),")"),id:"most_points"},{title:M.mostVillages+":",data:t.mostVillages+" "+"(".concat((0,y.formatDate)(t.mostVillagesAt),")"),id:"most_villages"}].forEach(e=>{V(e)}),G(t),n&&n.items.length>0&&(0,r.default)(j,n.items[0]),t.nameChanges.length>0&&U(t),t.servers.length>0&&W(t)},z=(e,t,n)=>{const r=(0,s.generatePaginationItems)({total:n.total,limit:15,currentPage:t}),i='\n    <div style="'.concat((0,s.getContainerStyles)(),'" id="').concat("tribeChangesPagination",'">\n      ').concat(r.join(""),'\n    </div>\n    <table class="vis" style="border-collapse: separate; border-spacing: 2px; width: 100%;">\n      <tbody>\n        <tr>\n          <th>\n            ').concat(M.date,"\n          </th>\n          <th>\n            ").concat(M.newTribe,"\n          </th>\n          <th>\n            ").concat(M.oldTribe,"\n          </th>\n        </tr>\n        ").concat(n.items.map(e=>{let t="<tr>"+"<td>".concat((0,y.formatDate)(e.createdAt),"</td>");return e.newTribe?t+='<td><a href="'.concat(f.buildTribeURL(e.newTribe.id),'">').concat(e.newTribe.tag,"</a></td>"):t+="<td>-</td>",e.oldTribe?t+='<td><a href="'.concat(f.buildTribeURL(e.oldTribe.id),'">').concat(e.oldTribe.tag,"</a></td>"):t+="<td>-</td>",t+"</tr>"}).join(""),"\n      </tbody>\n    </table>\n  ");(0,a.default)({e:e,title:M.tribeChanges,id:"tribeChanges",html:i}),document.querySelectorAll("#tribeChangesPagination a").forEach(e=>{e.addEventListener("click",J)})},J=async e=>{e.preventDefault();const n=(0,s.getPage)(e.target);if(!isNaN(n)){const r=await(0,t.default)({query:q,variables:{filter:{playerID:[P]},sort:["createdAt DESC"],offset:15*(n-1),limit:15,server:S}});z(e,n,r.tribeChanges)}},K=async e=>{e.preventDefault();const n=(0,s.getPage)(e.target);if(!isNaN(n))try{const a={playerID:[P]},{playerHistory:i,dailyPlayerStats:l}=await(0,t.default)({query:L,variables:{server:S,playerHistoryFilter:a,offset:15*(n-1),limit:15,sort:["createDate DESC"],dailyPlayerStatsFilter:a}});(0,o.default)(e,i,l,{currentPage:n,limit:15,onPageChange:K,tribe:!1})}catch(r){console.log("cannot load player history",r)}},Q=async e=>{e.preventDefault();const n=(0,s.getPage)(e.target);if(!isNaN(n)){const r=await(0,t.default)({query:_,variables:{filter:{or:{oldOwnerID:[P],newOwnerID:[P]}},offset:15*(n-1),limit:15,sort:["ennobledAt DESC"],server:S}});(0,i.default)(e,r.ennoblements,{currentPage:n,limit:15,onPageChange:Q})}},X=e=>{e.preventDefault(),Dialog.show(M.exportedVillages,"<textarea cols=30 rows=8 readonly>".concat(document.querySelector("#villages_list").innerHTML.match(/(\d+)\|(\d+)/g).join(" "),"</textarea>"))},Y=e=>{const t=document.createElement("td");t.colSpan="2",t.append(e);const n=document.createElement("tr");return n.appendChild(t),n},Z=()=>{const e=document.createElement("a");e.href=m.buildPlayerURL(w,S,P),e.innerHTML=M.action.linkToTWHelp,H.appendChild(Y(e));const t=document.createElement("a");t.href="#",(0,s.setPage)(t,"1"),t.innerHTML=M.action.showTribeChanges,t.addEventListener("click",J),H.appendChild(Y(t));const n=document.createElement("a");n.href="#",(0,s.setPage)(n,"1"),n.innerHTML=M.action.showHistory,n.addEventListener("click",K),H.appendChild(Y(n));const r=document.createElement("a");r.href="#",(0,s.setPage)(r,"1"),r.innerHTML=M.action.showEnnoblements,r.addEventListener("click",Q),H.appendChild(Y(r));const a=document.createElement("a");a.href="#",a.innerHTML=M.action.exportVillages,a.addEventListener("click",X),H.appendChild(Y(a))};!async function(){try{Z();const t=N();t&&t.player&&B(t);const n=await F();n&&B(n)}catch(e){console.log("extended player profile",e)}}();
},{"./libs/InADayParser":"dSAr","./libs/requestCreator":"Ph2E","./i18n/extendedPlayerProfile":"I8dv","./common/renderTodaysStats":"yrCm","./utils/showPopup":"chDM","./common/showEnnoblementsPopup":"vNT1","./common/showHistoryPopup":"kEDU","./utils/hyphensToCamelCase":"GxsT","./utils/pagination":"fCHX","./utils/getIDFromURL":"tQUs","./utils/getCurrentServer":"DMkL","./utils/getServerVersionCode":"J1Ly","./utils/date":"ZbyX","./utils/tribalwars":"fHHP","./utils/twhelp":"gvXE","./utils/localStorage":"KWxH"}]},{},["yRop"], null)