import{$ as e,A as t,B as n,K as r,N as i,Q as a,T as o,X as s,_ as c,m as l,p as u,x as d,z as f}from"./vendor-vue-D9nMs6_1.js";import{t as p}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{a as m,n as h,o as g}from"./styleDecoder-BtKxnsm0.js";function _(e,t){let n=document.createElement(`canvas`),r=n.getContext(`2d`);if(!r)return[0,0,0];n.width=e.naturalWidth,n.height=e.naturalHeight,r.drawImage(e,0,0);let i=n.width,a=n.height,o=Math.floor(i/2-t/2),s=Math.floor(a/2-t/2),c=Math.min(o+t,i),l=Math.min(s+t,a),u=r.getImageData(o,s,c-o,l-s).data,d=0,f=0,p=0,m=0;for(let e=0;e<l-s;e+=2)for(let t=0;t<c-o;t+=2){let n=(e*(c-o)+t)*4;d+=u[n],f+=u[n+1],p+=u[n+2],m++}return[Math.round(d/m),Math.round(f/m),Math.round(p/m)]}function v(e,t){let n=document.createElement(`canvas`),r=n.getContext(`2d`);if(!r)return[0,0,0];n.width=e.naturalWidth,n.height=e.naturalHeight,r.drawImage(e,0,0);let i=n.width,a=n.height,o=Math.floor(i/2-t/2),s=Math.floor(a/2-t/2),c=Math.min(o+t,i),l=Math.min(s+t,a),u=r.getImageData(o,s,c-o,l-s).data,d=[],f=c-o;for(let e=0;e<l-s;e+=2)for(let t=0;t<f;t+=2){let n=(e*f+t)*4,r=u[n],i=u[n+1],a=u[n+2],o=.2126*r+.7152*i+.0722*a;d.push({r,g:i,b:a,lum:o})}d.sort((e,t)=>e.lum-t.lum);let p=Math.max(1,Math.floor(d.length*.3)),m=0,h=0,g=0;for(let e=0;e<p;e++)m+=d[e].r,h+=d[e].g,g+=d[e].b;return[Math.round(m/p),Math.round(h/p),Math.round(g/p)]}var y={class:`relative w-full h-full overflow-hidden`},b={class:`absolute m-10 z-200 flex flex-col items-start w-[90%]`},x={class:`absolute inset-0 w-full h-full`},S=[`src`],C=p(d({__name:`ChampionInfo`,props:o({playerName:{},championName:{},championImageSrc:{},team:{}},{bgColor:{required:!0},bgColorModifiers:{},secondColor:{required:!0},secondColorModifiers:{},style:{required:!0},styleModifiers:{},useCustomBackground:{required:!0},useCustomBackgroundModifiers:{},customBackground:{required:!0},customBackgroundModifiers:{}}),emits:[`update:bgColor`,`update:secondColor`,`update:style`,`update:useCustomBackground`,`update:customBackground`],setup(o){let d=f(o,`bgColor`),p=f(o,`secondColor`),C=f(o,`style`),w=f(o,`useCustomBackground`),T=r(null),E=f(o,`customBackground`);function D(e,t,n){return`#`+[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function O(e){if(/gradient/i.test(e)){let t=e.match(/#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/);if(t)return t[0];let n=e.match(/rgba?\([^)]+\)/);if(n)return n[0];let r=e.match(/\b[a-z]+\b/i);return r?r[0]:`#000000`}return e}n([w,C],()=>{w.value===!0?d.value=O(h(E.value,o.team)?.background??``):k()},{deep:!0});function k(){if(w.value===!1&&T.value&&T.value.complete)try{let e=v(T.value,20),t=_(T.value,20),n=D(t[0],t[1],t[2]);p.value=n,d.value=D(e[0],e[1],e[2])}catch(e){console.error(`Error extracting colors from champion image:`,e),d.value=`rgba(0,0,0,0.7)`,p.value=`rgba(0,0,0,0.7)`}}t(()=>{n(()=>o.championImageSrc,()=>{d.value=`rgba(0,0,0,0.7)`})});let A=u(()=>(1/(1-30/500)).toFixed(3)),j=r(null),M=r(null),N=r(8);function P(){if(!j.value)return;let e=j.value.parentElement;if(!e)return;let t=8;for(j.value.style.fontSize=t+`em`;j.value.scrollWidth>e.clientWidth&&t>1.5;)t-=.6,j.value.style.fontSize=t+`em`;N.value=t}function F(){if(!M.value||!j.value||!M.value.parentElement)return;let e=j.value.offsetWidth,t=window.getComputedStyle(M.value),n=parseFloat(t.fontSize),r=n;for(M.value.style.fontSize=r+`px`;M.value.scrollWidth>e&&r>n*.3;)r-=n*.05,M.value.style.fontSize=r+`px`}return t(()=>{P(),window.addEventListener(`resize`,()=>{P(),F()})}),n(()=>o.championName,()=>{setTimeout(F,0)}),n(()=>o.playerName,()=>{P(),setTimeout(F,0)}),(t,n)=>(i(),c(`div`,y,[l(`div`,b,[l(`p`,{ref_key:`titleRef`,ref:j,class:`font-bold uppercase drop-shadow-lg leading-none inline-block`,style:a(s(g)(C.value.heading,o.team))},e(o.playerName),5),l(`p`,{ref_key:`championRef`,ref:M,class:`uppercase drop-shadow-lg leading-none whitespace-nowrap self-start`,style:a([s(g)(C.value.subHeading,o.team),{width:j.value?.offsetWidth?`${j.value.offsetWidth}px`:`auto`}])},e(o.championName),5)]),l(`div`,x,[l(`img`,{src:o.championImageSrc,ref_key:`imgRef`,ref:T,class:`inset-0 w-[99%] h-full object-cover z-0 rounded-xl`,crossorigin:`anonymous`,onLoad:k,style:a({...s(m)(C.value.championImage),transform:`scale(`+A.value+`)`,transformOrigin:`center`,marginRight:`-`+(parseFloat(A.value)-1)*50+`%`,marginLeft:`-`+(parseFloat(A.value)-1)*50+`%`,WebkitMaskImage:`radial-gradient(ellipse 105% 150% at 15% 50%, black 35%, black 45%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.3) 72%, transparent 82%), linear-gradient(to right, black, transparent)`,maskImage:` radial-gradient(ellipse 105% 150% at 15% 50%, black 35%, black 45%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.3) 72%, transparent 82%)`})},null,44,S)])]))}}),[[`__scopeId`,`data-v-8516372e`]]);export{C as t};