(()=>{var Wt=()=>{cubes=createCubes()},p={perspective:.8,isoY:0,isoX:0,cubeA:0,wx:-.616,wy:Math.PI/4,wz:-Math.PI/2,plugX:0,plugY:0,plugZ:0,iso:!0,debug:!1,speedup:1,replay:Wt,mouseRotationMultiplier:.1};function _t(J){let Ct="#fff",j="#555",v=document.querySelector(J);if(!v){console.log(`Unable to setup effect because "${J}" was not found`);return}let Mt=String(v.tagName).toLowerCase()==="canvas",b=v;Mt||(b=document.createElement("canvas"),v.appendChild(b));let r=b.getContext("2d"),H=b.parentElement,$=H.getBoundingClientRect(),i=window.devicePixelRatio,L=600,Q=$.width/L,C=Math.max($.width,L),x=Math.max($.height,L);b.width=C*i,b.height=x*i,b.style.width=C*Q+"px",b.style.height=x*Q+"px";let Bt=C*.8,Jt=C/2,jt=x/2,N=!1,q=[],At=e=>{q.push(e)};new IntersectionObserver(e=>{e.forEach(t=>{if(N=t.isIntersecting,N){for(let o of q)o();q=[]}})}).observe(H);let G=e=>{N?requestAnimationFrame(e):At(()=>requestAnimationFrame(e))},Pt=()=>{r.fillStyle="black",r.fillRect(0,0,C*i,x*i)},u=(e,t,o)=>({x:e,y:t,z:o}),yt=(e,t)=>({a:e,r:t}),xt=e=>{let t=e/2,o=[u(-t,-t,-t),u(t,-t,-t),u(-t,t,-t),u(t,t,-t)],n=[u(-t,-t,t),u(t,-t,t),u(-t,t,t),u(t,t,t)],s=[u(-t,-t,-t),u(t,-t,-t),u(-t,-t,t),u(t,-t,t)],a=[u(-t,t,-t),u(t,t,-t),u(-t,t,t),u(t,t,t)],c=[u(-t,-t,-t),u(-t,t,-t),u(-t,-t,t),u(-t,t,t)],l=[u(t,-t,-t),u(t,t,-t),u(t,-t,t),u(t,t,t)];return[o,n,s,a,c,l]},K=e=>{let t=0;return e.forEach((o,n)=>{let s=0,a=o.map(c=>c.z);for(let c of a)s+=c;o.zSum=s,t+=s}),t};function tt(e){var t=e+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}let W=e=>(tt(e*10)>.5?128:0)+Math.round(tt(e)*128),_=e=>`rgba(${W(1*e*10)},${W(2*e*100)}, ${W(3*e*1e3)}, 1)`;console.log(_(1));let Et=()=>{let e=document.createElement("canvas");e.setAttribute("width",P*i),e.setAttribute("height",P*i);let t=e.getContext("2d");return t.beginPath(),t.arc(z*i,z*i,z*i,0,Math.PI*2),t.fillStyle="#fff",t.fill(),e},P=4,z=P/2,It=Et(),k=(e,t,o=1)=>{r.drawImage(It,0,0,Math.round(P*i),Math.round(P*i),Math.round(e-z*i*o),Math.round(t-z*i*o),Math.round(P*i*o),Math.round(P*i*o))},St=(e,t,o=1)=>{let n=K(e);e.slice().sort((a,c)=>a.zSum-c.zSum).forEach((a,c)=>{let[l,f,M,D]=a.map(I=>[I.x*i,I.y*i]);r.beginPath(),r.fillStyle=p.debug?"#00000044":"#000",r.strokeStyle=p.debug?_(t):j,r.lineWidth=1*i,r.save(),r.translate(C/2*i,x/2*i),r.moveTo(...l),r.lineTo(...f),r.lineTo(...D),r.lineTo(...M),r.lineTo(...l),r.fill(),r.stroke(),k(...l,o),k(...f,o),k(...D,o),k(...M,o),c===0&&p.debug&&(r.fillStyle=_(t),r.font="40px Arial",r.fillText(`${Math.round(n)} ${t}`,l[0]+30,l[1])),r.restore()})},Qt=e=>{r.fillStyle="white",r.beginPath();let t=5;r.arc(e.x*i,e.y*i,t*i,0,Math.PI*2),r.fill()};function B(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2])}function X(e){var t=B(e);return[e[0]/t,e[1]/t,e[2]/t]}function Y(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Gt(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Kt(e,t){return Math.acos(Y(e,t)/(B(e)*B(t)))}function zt(e,t){return[Y(e[0],t),Y(e[1],t),Y(e[2],t)]}function Tt(e,t,o){var n=Math.cos(o),s=Math.sin(o),a=1-n,c=t[0],l=t[1],f=t[2],M=[[n+c*c*a,c*l*a-f*s,c*f*a+l*s],[c*l*a+f*s,n+l*l*a,l*f*a-c*s],[f*c*a-l*s,f*l*a+c*s,n+f*f*a]];return zt(M,e)}var Rt=[0,-1,0],te=[1,0,0],ee=[8,5,-30];let et=(e,t,o)=>{var n=Tt(e,t,o);return n},Vt=(e,t,o=0)=>{let n=C*(Math.pow(p.perspective,2)*10),s=n/(n+o);return[e*s+Xt,t*s+Yt]},Ft=(e,t,o=1)=>{o=1;let n=Math.cos(e+ct)*t,s=Math.sin(e+ct)*t;return[n*o,s*o]},ot=0,nt=0,oe=0,rt=0,st=0;document.addEventListener("mousemove",e=>{ot=e.clientX,nt=e.clientY;let t=window.innerWidth,o=window.innerHeight,n=t/2,s=o/2;rt=-(ot-n)/n*p.mouseRotationMultiplier,st=(nt-s)/s*p.mouseRotationMultiplier});let y=(e,t)=>{t=1;let[o,n]=Ft(e.a,e.r,t??i),[s,a,c]=et([o,n,e.z??0],Rt,Zt),[l,f]=Vt(s,a,c);return[l+(e.offsetX??0),f+(e.offsetY??0),c]},vt=e=>{e.lastPos=y(e,1)},ne=e=>{r.fillStyle="white",r.beginPath();let t=e.lastPos;vt(e);let[o,n,s]=y(e,1),a=Math.max(0,5-s*.01);r.arc(o*i,n*i,a*i,0,Math.PI*2),r.fill(),t&&(r.beginPath(),r.moveTo(t[0]*i,t[1]*i),r.lineTo(o*i,n*i),r.lineWidth=4*2*i,r.lineCap="round",r.strokeStyle=Ct,r.stroke())},re=100,at=1,ae=Math.PI*2/at,kt=[],Xt=C/2,Yt=x/2;for(let e=0;enew Promise(o=>{gsap.to(e,{...t,onComplete:o})}),ce=(e,t)=>{let o=Math.pow(e,t);return o/(o+Math.pow(1-e,t))},le=0,ue=.05,fe=0,Ut=(e,t,o)=>(o&&(e=g(e,...o.map(n=>-n))),e=e.map(n=>n.map(({x:s,y:a,z:c})=>({x:s*t,y:a*t,z:c*t}))),o&&(e=g(e,...o.map(n=>n))),e),g=(e,t,o,n)=>e.map(s=>s.map(({x:a,y:c,z:l})=>({x:a+t,y:c+o,z:l+n}))),E=(e,t,o,n)=>(n&&(e=g(e,...n.map(s=>-s))),e=e.map(s=>s.map(a=>{let[c,l,f]=et([a.x,a.y,a.z],t,o);return{x:c,y:l,z:f}})),n&&(e=g(e,...n)),e),m=(e,t,o)=>{let{offset:n=[0,0,0],transition:s=[0,0,0],rotationA:a=0,origin:c=[0,0,0],rotationVector:l=[0,0,0],rotationAxis:f=[0,0,0],plugin:M,startAt:D=0}=o??{},I=xt(e),w=e,O=p.speedup,d=0,ht=.001*O,T=0,mt=.01,R=0,dt=.001*O,V=0,gt=.01,Z=t,wt=.09*O,bt=.15*O,F=0,S={cube:I,update:()=>{S.hasUpdated=!0;let h=I;if(M&&(h=g(I,...Dt())),w<(Z-e)/2?F+=wt:(F-=wt,F=Z&&(w=Z),S.v=(w-e)/(Z-e),S.v>=1&&(s.every(A=>A===0)&&(d=1),d<.5?T+=ht:(T-=ht,T=1&&(d=1)),S.transitionV=d,d>=1&&a!==0){let A=f;R<.5?V+=dt:(V-=dt,V=1&&(R=1),h=E(h,X(l),a*R,n.map((we,qt)=>f[qt]))}h=g(h,...n.map(A=>A*t)),h=g(h,...c),h=Ut(h,w,n.map(A=>A*t)),h=g(h,...c.map(A=>-A*t)),h=g(h,s[0]*d*w,s[1]*d*w,s[2]*d*w),S.cube=h},startAt:D,hasUpdated:!1,v:0};return S},Dt=()=>[p.plugX,p.plugY,p.plugZ],it=(()=>[m(1,200,{startAt:0}),m(1,50,{startAt:1.35,origin:[-.5,0,0],offset:[-2.5,-.5,.5],transition:[0,0,0],rotationA:-Math.PI,rotationVector:[1,0,0],rotationAxis:[0,.5,-.5]}),m(1,100,{startAt:.5,offset:[-.5,-1.5,.5],origin:[.5,-.5,-.5],transition:[0,0,-1]}),m(1,100,{startAt:1,offset:[-1.5,-.5,-.5],origin:[-.5,.5,.5]}),m(1,100,{startAt:1.15,offset:[1.5,-.5,.5],origin:[.5,.5,-.5]}),m(1,100,{startAt:.95,offset:[1.5,.5,-.5],transition:[0,-2,0]}),m(1,50,{startAt:1.6,origin:[-.5,0,0],offset:[-2.5,-2.5,.5],transition:[0,0,0],rotationA:Math.PI/2,rotationVector:[0,1,0],rotationAxis:[.5,0,-.5]}),m(1,100,{startAt:1.05,offset:[.5,-.5,1.5],origin:[-.5,.5,.5]}),m(1,100,{startAt:1.4,origin:[.5,-.5,.5],offset:[-.5,.5,1.5],transition:[0,0,0],rotationA:-Math.PI,rotationVector:[1,0,0],rotationAxis:[0,.5,-.5]}),m(1,50,{startAt:1.71,origin:[.5,.5,.5],offset:[4.5,-1.5,.5],transition:[0,0,0],rotationA:-Math.PI,rotationVector:[0,0,1],rotationAxis:[-.5,-.5,0]}),m(1,50,{startAt:1.7,origin:[-.5,-.5,-.5],offset:[1.5,-2.5,3.5],rotationA:-Math.PI,rotationVector:[1,0,0],rotationAxis:[0,.5,.5],transition:[0,0,0]}),m(1,50,{startAt:2,origin:[.5,.5,-.5],offset:[.5,2.5,1.5],plugin:!0})])(),Ot=async()=>{let e=0,t=.011,o=()=>{e++;for(let n of it)e*p.speedup*t>=n.startAt&&n.update();G(o)};o()},Zt=0,ct=0,$t=0,he,me,U=e=>e.map(t=>t*i),de=e=>{let t=1/(e.length+1);r.strokeStyle=j,r.lineWidth=1*i,r.beginPath(),r.moveTo(...U(y(e[0])));let o=0,n=y(e[0]);e.slice().concat(e[0]).forEach((s,a)=>{let c=a*t,l=Math.max(0,Math.min(1,($t-o)/t));if(l===0)return;o=c;let f=y(s),M=[n[0]+(f[0]-n[0])*l,n[1]+(f[1]-n[1])*l];n=f,r.lineTo(...U(M))}),r.stroke(),e.forEach(s=>{let a=s.connectsTo;!a||(r.beginPath(),r.moveTo(...U(y(s))),r.lineTo(...U(y(a))),r.stroke())})},lt=X([1,0,0]),ut=X([0,1,0]),Lt=X([0,0,1]),Nt=e=>{let t=E(E(E(e,ut,p.wy),lt,p.wx),Lt,p.wz);return E(E(t,ut,rt),lt,st)},ft=()=>{Pt(),it.map((t,o)=>({...t,originalIndex:o,cube:p.iso?Nt(t.cube):t.cube})).sort((t,o)=>pt(t)-pt(o)).forEach((t,o)=>{!t.hasUpdated||St(t.cube,t.originalIndex,Math.max(0,(t.v-.5)*2))}),G(ft)},pt=e=>K(e.cube);Ot(),ft()}window.setupPortfolioEffect=_t;})();