text: (()=>{"use strict";var e={8968:(e,t,a)=>{function l(e){try{var t=JSON.parse(localStorage.getItem(e));return t?{status:!0,list:t}:{status:!1}}catch(e){return console.log(e),{status:!1,error:e}}}function s(e,t){return e.filter((function(e){return e.player.id!==Number(t)}))}function n(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){window.alert(e.message)}}function o(e,t,a){t.innerText=e,a[0].show()}function i(e,t){return e.some((function(e){return e.player.id===Number(t)}))}a.d(t,{gp:()=>l,oM:()=>s,nV:()=>n,wp:()=>o,qx:()=>i})},2078:(e,t,a)=>{a.r(t)}},t={};function a(l){var s=t[l];if(void 0!==s)return s.exports;var n=t[l]={exports:{}};return e[l](n,n.exports,a),n.exports}a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e=a(8968),t={labels:["% On shoots","% Passes","% Key passes","% Won duels","% success dribbles"],datasets:[{label:"Radar Chart",data:[25,75,80,10,40],fill:!0,backgroundColor:"rgba(255, 99, 132, 0.2)",borderColor:"rgb(255, 99, 132)",pointBackgroundColor:"rgb(255, 99, 132)",pointBorderColor:"#fff",pointHoverBackgroundColor:"#fff",pointHoverBorderColor:"rgb(255, 99, 132)"}]},l={type:"radar",data:t,options:{elements:{line:{borderWidth:3}},scales:{r:{max:100}}}},s=null;function n(){try{s.destroy()}catch(e){console.log(e)}}function o(e){n(),t.datasets[0].data=e;var a=document.getElementById("playerRadarChart");s=new Chart(a,l)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,l=new Array(t);a<t;a++)l[a]=e[a];return l}a(2078);var r='\n<div class="$$COL-CLASS$$" draggable="true" style="text-align: center; background-color: rgba(255, 255, 255, 0.7);};">\n    <i class="bi bi-x"></i>\n    <img src="$$PLAYER_IMG$$" style="width: 65px; height: 65px;">\n    <p>$$PLAYER_NAME$$</p>\n    <p hidden>$$PLAYER_ID$$</p>\n</div>\n',u=document.getElementById("tableBody"),d=document.getElementById("noPlayers"),c=document.getElementById("chartNoData"),p=document.getElementById("playerModalTitle"),m=document.getElementById("modalPlayerImg"),g=document.getElementById("modalClubImg"),y=new bootstrap.Modal(document.getElementById("playerModal"),{keyboard:!1}),f=0,h=document.getElementById("dropZone"),b=(document.getElementById("toastAlert"),document.getElementById("toastBody")),$={list:[{player:{id:154,name:"L. Messi",firstname:"Lionel Andrés",lastname:"Messi Cuccittini",age:34,birth:{date:"1987-06-24",place:"Rosario",country:"Argentina"},nationality:"Argentina",height:"170 cm",weight:"72 kg",injured:!1,photo:"https://media.api-sports.io/football/players/154.png"},statistics:[{team:{id:529,name:"Barcelona",logo:"https://media.api-sports.io/football/teams/529.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:35,lineups:33,minutes:3022,number:null,position:"Attacker",rating:"8.342857",captain:!1},substitutes:{in:2,out:1,bench:2},shots:{total:141,on:91},goals:{total:30,conceded:0,assists:9,saves:null},passes:{total:2246,key:81,accuracy:54},tackles:{total:19,blocks:null,interceptions:6},duels:{total:501,won:286},dribbles:{attempts:247,success:160,past:null},fouls:{drawn:99,committed:22},cards:{yellow:4,yellowred:0,red:0},penalty:{won:null,commited:null,scored:3,missed:2,saved:null}}]},{player:{id:144,name:"Sergio Busquets",firstname:"Sergio",lastname:"Busquets i Burgos",age:33,birth:{date:"1988-07-16",place:"Sabadell",country:"Spain"},nationality:"Spain",height:"189 cm",weight:"76 kg",injured:!1,photo:"https://media.api-sports.io/football/players/144.png"},statistics:[{team:{id:529,name:"Barcelona",logo:"https://media.api-sports.io/football/teams/529.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:36,lineups:32,minutes:2529,number:null,position:"Midfielder",rating:"7.052777",captain:!1},substitutes:{in:4,out:19,bench:4},shots:{total:2,on:1},goals:{total:0,conceded:0,assists:5,saves:null},passes:{total:2682,key:30,accuracy:68},tackles:{total:63,blocks:4,interceptions:53},duels:{total:313,won:171},dribbles:{attempts:9,success:8,past:null},fouls:{drawn:60,committed:45},cards:{yellow:9,yellowred:0,red:0},penalty:{won:null,commited:null,scored:0,missed:0,saved:null}}]},{player:{id:143,name:"Carles Aleñá",firstname:"Carles",lastname:"Aleña Castillo",age:23,birth:{date:"1998-01-05",place:"Mataró",country:"Spain"},nationality:"Spain",height:"180 cm",weight:"73 kg",injured:!1,photo:"https://media.api-sports.io/football/players/143.png"},statistics:[{team:{id:546,name:"Getafe",logo:"https://media.api-sports.io/football/teams/546.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:22,lineups:15,minutes:1368,number:null,position:"Midfielder",rating:"6.500000",captain:!1},substitutes:{in:7,out:9,bench:7},shots:{total:1,on:null},goals:{total:2,conceded:0,assists:null,saves:null},passes:{total:38,key:null,accuracy:18},tackles:{total:1,blocks:null,interceptions:null},duels:{total:8,won:1},dribbles:{attempts:null,success:null,past:null},fouls:{drawn:null,committed:4},cards:{yellow:1,yellowred:0,red:0},penalty:{won:null,commited:null,scored:0,missed:0,saved:null}},{team:{id:529,name:"Barcelona",logo:"https://media.api-sports.io/football/teams/529.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:2,lineups:0,minutes:46,number:null,position:"Midfielder",rating:"6.500000",captain:!1},substitutes:{in:2,out:0,bench:16},shots:{total:1,on:null},goals:{total:0,conceded:0,assists:null,saves:null},passes:{total:38,key:null,accuracy:18},tackles:{total:1,blocks:null,interceptions:null},duels:{total:8,won:1},dribbles:{attempts:null,success:null,past:null},fouls:{drawn:null,committed:4},cards:{yellow:1,yellowred:0,red:0},penalty:{won:null,commited:null,scored:0,missed:0,saved:null}}]},{player:{id:196,name:"R. Nolan",firstname:"Ryan",lastname:"Patrick Nolan",age:22,birth:{date:"1999-02-17",place:"Limerick",country:"Republic of Ireland"},nationality:"Republic of Ireland",height:null,weight:null,injured:!1,photo:"https://media.api-sports.io/football/players/196.png"},statistics:[{team:{id:546,name:"Getafe",logo:"https://media.api-sports.io/football/teams/546.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:0,lineups:0,minutes:0,number:null,position:"Defender",rating:null,captain:!1},substitutes:{in:0,out:0,bench:2},shots:{total:null,on:null},goals:{total:0,conceded:0,assists:null,saves:null},passes:{total:null,key:null,accuracy:null},tackles:{total:null,blocks:null,interceptions:null},duels:{total:null,won:null},dribbles:{attempts:null,success:null,past:null},fouls:{drawn:null,committed:null},cards:{yellow:0,yellowred:0,red:0},penalty:{won:null,commited:null,scored:0,missed:0,saved:null}}]},{player:{id:46754,name:"Alberto Cifuentes Martínez",firstname:"Alberto",lastname:"Cifuentes Martínez",age:41,birth:{date:"1979-05-29",place:"Albacete",country:"Spain"},nationality:"Spain",height:"189 cm",weight:"80 kg",injured:!1,photo:"https://media.api-sports.io/football/players/46754.png"},statistics:[{team:{id:724,name:"Cadiz",logo:"https://media.api-sports.io/football/teams/724.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:2,lineups:2,minutes:180,number:null,position:"Goalkeeper",rating:"6.600000",captain:!1},substitutes:{in:0,out:0,bench:2},shots:{total:null,on:null},goals:{total:0,conceded:0,assists:null,saves:2},passes:{total:65,key:1,accuracy:12},tackles:{total:null,blocks:null,interceptions:null},duels:{total:1,won:1},dribbles:{attempts:null,success:null,past:null},fouls:{drawn:1,committed:null},cards:{yellow:0,yellowred:0,red:0},penalty:{won:null,commited:null,scored:0,missed:0,saved:0}}]},{player:{id:47193,name:"L. Quezada",firstname:"Luis Miguel",lastname:"Quezada Sánchez",age:25,birth:{date:"1996-02-11",place:"Madrid",country:"Spain"},nationality:"Dominican Republic",height:"171 cm",weight:"66 kg",injured:!1,photo:"https://media.api-sports.io/football/players/47193.png"},statistics:[{team:{id:724,name:"Cadiz",logo:"https://media.api-sports.io/football/teams/724.png"},league:{id:140,name:"La Liga",country:"Spain",logo:"https://media.api-sports.io/football/leagues/140.png",flag:"https://media.api-sports.io/flags/es.svg",season:2020},games:{appearences:0,lineups:0,minutes:0,number:null,position:"Midfielder",rating:null,captain:!1},substitutes:{in:0,out:0,bench:0},shots:{total:null,on:null},goals:{total:0,conceded:null,assists:null,saves:null},passes:{total:null,key:null,accuracy:null},tackles:{total:null,blocks:null,interceptions:null},duels:{total:null,won:null},dribbles:{attempts:null,success:null,past:null},fouls:{drawn:null,committed:null},cards:{yellow:0,yellowred:0,red:0},penalty:{won:null,commited:null,scored:null,missed:null,saved:null}}]}],status:!0},v=e.gp("myTeam").list?e.gp("myTeam").list:[];function E(e){return $.list.filter((function(t){return t.player.id===Number(e)}))[0]}function w(e,t){return 100*e/t}function L(){var e,t=document.getElementsByTagName("tbody");c.setAttribute("hidden","true"),(e=t,function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).forEach((function(e){e.addEventListener("click",(function(e){n();var t,a=E(e.target.closest("tr").getElementsByTagName("td")[5].innerText),l=[w((t=a.statistics[0]).shots.on,t.shots.total),t.passes.accuracy,w(t.passes.key,t.passes.total),w(t.duels.won,t.duels.total),w(t.dribbles.success,t.dribbles.attempts)];l.every((function(e,t,a){return void 0===e||isNaN(e)||null===e}))?c.removeAttribute("hidden"):o(l),p.innerText=a.player.name,m.src=a.player.photo,g.src=a.statistics[a.statistics.length-1].team.logo,y.toggle()})),e.addEventListener("dragstart",(function(e){console.log("Drag started");var t=e.target.closest("tr").getElementsByTagName("td")[5].innerText;f=t,event.dataTransfer.setData("Text",event.target.id)}))}))}function A(e){switch(e){case"Attacker":case"Midfielder":return Math.floor(4);case"Defender":return Math.floor(3);case"Goalkeeper":return Math.floor(12);default:return 12}}document.addEventListener("DOMContentLoaded",(function(){d.setAttribute("hidden","true"),!0===$.status&&$.list?$.list.forEach((function(e){var t="";t=(t=(t=(t=(t=(t='\n    <tr class="player" draggable="true" data-toggle="modal" data-target="#playerModal">\n        <td><img src="$$PLAYER_IMG$$" style="width: 75; height: 75px;"></td>\n        <td>$$PLAYER_NAME$$</td>\n        <td>$$PLAYER_LASTNAME$$</td>\n        <td>$$PLAYER_POSITION$$</td>\n        <td><img src="$$CLUB_IMG$$" style="width: 35; height: 35px;"></td>\n        <td hidden>$$PLAYER_ID$$</td>\n    </tr>\n'.replace("$$PLAYER_ID$$",e.player.id)).replace("$$PLAYER_NAME$$",e.player.firstname)).replace("$$PLAYER_IMG$$",e.player.photo)).replace("$$PLAYER_LASTNAME$$",e.player.lastname)).replace("$$PLAYER_POSITION$$",e.statistics[e.statistics.length-1].games.position)).replace("$$CLUB_IMG$$",e.statistics[e.statistics.length-1].team.logo),u.insertAdjacentHTML("beforeEnd",t)})):d.removeAttribute("hidden")})),h.addEventListener("dragover",(function(e){e.preventDefault(),h.style.borderColor="red"})),h.addEventListener("dragleave",(function(e){e.preventDefault(),h.style.borderColor="black"})),h.addEventListener("drop",(function(t){if(t.preventDefault(),v.length<11){var a=E(f);if(function(e){var t=v.filter((function(t){return t.statistics[t.statistics.length-1].games.position===e})).length;switch(e){case"Attacker":case"Midfielder":return t<3;case"Defender":return t<4;case"Goalkeeper":return t<1;default:return!1}}(a.statistics[a.statistics.length-1].games.position)){var l="";l=(l=(l=r.replace("$$PLAYER_ID$$",a.player.id)).replace("$$PLAYER_NAME$$",a.player.name)).replace("$$PLAYER_IMG$$",a.player.photo);var s=A(a.statistics[a.statistics.length-1].games.position);l=l.replace("$$COL-CLASS$$","col-".concat(s));var n=t.target.closest("div");e.qx(v,a.player.id)?e.wp("ERROR: This player is already in the team",b,k):(v.push(a),e.nV("myTeam",v),n.insertAdjacentHTML("beforeEnd",l)),h.style.borderColor="black",f=0}else e.wp("ERROR: Max number of ".concat(a.statistics[a.statistics.length-1].games.position,"s reached"),b,k)}else e.wp("ERROR: You have the max number of players in the team",b,k)})),h.addEventListener("click",(function(t){if(t.preventDefault(),t.target.matches("div *")){var a=t.target.closest("div"),l=a.getElementsByTagName("p")[1].innerText;v=e.oM(v,l),e.nV("myTeam",v),a.parentElement.removeChild(a)}})),document.addEventListener("DOMContentLoaded",(function(){L(),v.forEach((function(e){var t="";t=(t=(t=r.replace("$$PLAYER_ID$$",e.player.id)).replace("$$PLAYER_NAME$$",e.player.name)).replace("$$PLAYER_IMG$$",e.player.photo);var a=A(e.statistics[e.statistics.length-1].games.position);t=t.replace("$$COL-CLASS$$","col-".concat(a)),function(e){switch(e){case"Attacker":return document.getElementById("attackers");case"Midfielder":return document.getElementById("middlers");case"Defender":return document.getElementById("defenders");case"Goalkeeper":return document.getElementById("goalkeaper");default:return!1}}(e.statistics[e.statistics.length-1].games.position).insertAdjacentHTML("beforeEnd",t)}))}));var k=[].slice.call(document.querySelectorAll(".toast")).map((function(e){return new bootstrap.Toast(e)}))})()})();