Files
op-packages/luci-app-honk/root/etc/honk/dashboard/assets/LoginShowcase-CwRzXrsa.js
T

2 lines
12 KiB
JavaScript

import{j as N,r as B}from"./vendor-react-Bf71BWbF.js";import{u as W1,f as j1,aJ as K1}from"./index-CXHBmSa5.js";function N1({label:r,className:a,isDisabled:m,ref:e,canvasRef:l}){return N.jsx("button",{ref:e,type:"button",className:a,"aria-label":r,disabled:m,children:N.jsx("canvas",{ref:l})})}const U1=[["ink","M657 1228c-12-4-23-14-28-26-1-4-2-4-4-4-22 4-36 3-49-3-11-6-18-16-20-27-2-11 3-23 12-34 3-3 6-6 6-6 0 0-7-1-15-1-34-2-70-7-100-14-49-12-98-36-134-67l-5-4-12 4c-20 7-36 9-60 9-21 0-43-4-57-10-13-5-25-16-30-25-5-10-4-23 3-34 4-6 16-18 24-22l6-4-3-8c-2-5-2-9-2-12 1-6 5-15 9-18 4-5 16-13 21-14 3-1 5-2 6-2 0-1-1-6-3-12-21-73-6-145 45-212l7-10-12-2c-15-1-23-3-34-7-24-9-40-29-40-49 0-19 7-34 36-72 15-21 27-39 35-54 11-19 10-17 5-28-2-4-5-11-6-14-2-8-3-32-1-43 4-28 18-59 42-90l3-5-6-4c-11-9-20-21-23-32-2-6-2-9-2-17 1-9 1-10 4-18 6-11 15-20 29-27 14-7 24-10 47-15 1 0 3-3 7-11 19-37 51-71 88-94 12-8 32-18 44-22 10-3 29-8 33-8 1 0 5-2 8-5 11-8 25-14 39-16 12-2 49-1 63 2 21 4 34 9 45 19 8 7 10 9 15 18 4 7 4 7 13 12 34 18 63 46 86 81 10 16 20 38 26 57 4 12 8 34 10 48 2 13 2 43 0 56l-1 10 6 7c8 8 14 19 18 28 3 9 4 24 2 33-3 14-14 27-29 35-9 5-19 7-31 8l-9 1 0 8c0 4 0 15 0 25 0 16-1 31-5 47l0 3 14 0c27 0 58 5 83 14 21 9 51 25 68 39 3 2 6 5 7 5 0 1 6-2 14-6 27-14 49-17 69-11 26 8 38 34 27 64-2 5-3 9-3 10 0 0 4 1 8 3 14 7 24 19 29 34 8 22 0 45-24 73l-5 6 3 9c6 26 8 63 5 89-2 14-7 33-12 48-9 22-26 52-43 72-10 13-34 36-47 46-28 22-59 39-93 52-16 7-44 16-47 16-1 0-1 1-1 3 9 31 7 61-3 81-8 16-19 27-33 34-9 4-14 5-25 5-15 0-28-4-39-13l-6-5-7 6c-9 7-18 13-26 16-9 3-27 4-35 1z"],["paper","M582 1098c-44-2-79-6-117-16-55-14-102-41-141-81-42-43-67-93-75-148-2-14-1-43 1-56 6-30 16-57 32-82 8-12 24-33 32-42 6-7 7-7 17-10 58-18 110-56 126-92 2-5 2-9 3-16 1-14-2-21-15-33-13-14-21-24-33-39-18-26-28-35-45-43-11-5-21-7-33-7-13 0-23 2-33 7-6 3-9 3-9 3-4-6-4-28-2-42 5-23 18-49 37-73 14-18 37-39 56-53 5-4 6-4 11-4 41 1 105 13 154 28 32 9 72 25 104 42 18 9 51 27 66 37 8 5 8 5 11 13 7 16 13 37 16 56 2 11 2 41 1 54-4 39-19 74-44 104-8 9-10 14-9 20 1 5 7 10 13 12 7 2 14-1 24-11 10-11 22-29 32-48 3-5 4-7 6-7 2-1 14-1 27-1 22 0 24 0 37 2 34 8 68 24 98 48 13 11 15 12 20 12 5 0 7-1 16-7 22-14 41-21 53-18 13 3 16 15 7 32-2 5-6 11-8 15-4 8-4 14 0 19 4 5 7 6 17 7 15 1 23 5 27 14 3 6 3 15 0 22-2 6-10 18-20 30-9 11-11 15-8 24 3 10 6 33 7 52 0 26-2 47-10 70-18 53-57 101-111 135-40 25-87 43-144 54-66 14-132 19-194 17z"],["ink","M517 445c-7-2-13-6-18-12-7-7-9-14-9-25 0-7 0-8 3-15 7-13 17-21 31-22 23-1 43 18 41 40-2 19-17 33-36 35-4 0-9-1-12-1z"],["yellow","M541 220c-13-3-27-7-41-9-6-1-14-3-17-3l-5-1 2-6c3-15 13-40 23-59 20-39 43-66 64-73 11-3 56-1 74 4 7 1 13 4 17 7 3 3 3 4-1 4-5 0-17 4-24 7-35 18-62 59-79 118-2 8-4 14-4 14 0 0-4-1-9-3z"],["yellow","M446 203c-4-1-19-1-35-2-16 0-29 0-29-1 0-1 6-12 12-20 22-34 53-62 87-78 10-5 32-13 33-12 0 0-2 3-6 8-19 27-38 69-47 102-1 4-1 4-5 4-3 0-7-1-10-1z"],["yellow","M569 226c13-58 39-102 70-119 14-7 21-6 40 1 53 23 96 73 113 132 9 29 11 67 7 95-71-43-149-81-230-109z"],["yellow","M780 426c-1-2-5-19-5-19 0-1 3 0 8 0 6 0 8 0 10-2 5-4 3-6-21-21-50-32-74-46-109-63-71-36-143-57-225-67-48-6-99-5-107 1-4 3-5 5-2 7 1 2 3 2 10 3l8 0-4 4c-3 3-9 8-13 12l-9 8-4-2c-6-4-13-11-16-17-3-5-4-12-3-17 2-8 11-17 22-22 22-10 60-14 101-12 63 3 121 16 167 36 71 31 145 67 214 105 17 10 27 31 23 45-1 5-6 12-10 15-6 4-15 6-25 7-8 0-10 0-10-1z"],["yellow","M251 640c-19-4-32-16-32-29 0-10 5-19 23-43 26-34 37-50 50-75 6-12 9-17 13-20 12-11 29-13 45-7 11 5 17 10 37 36 9 13 19 25 24 30 5 5 10 10 12 13 2 3 2 5 2 10 0 5-1 8-4 12-17 29-73 61-123 71-14 3-38 4-47 2z"],["yellow","M226 1028c-12-1-24-5-31-10-12-8-13-16-2-27 5-5 19-13 30-17 7-3 11-6 11-8 0-3-1-5-8-9-7-6-10-10-10-14 0-4 1-5 4-8 2-2 6-4 9-5 3-1 5-2 5-2 1 0 4 7 8 14 15 29 28 49 49 72 4 5 7 8 7 9-1 1-21 5-29 6-13 1-31 1-43-1z"],["yellow","M663 1201c-7-4-9-12-7-24 1-7 1-8 0-10-3-4-7-4-15-1-18 7-40 10-48 7-5-2-8-6-8-11 0-7 8-16 29-30l10-7 19 0c22-1 52-4 78-7 18-3 57-9 65-11 6-2 11-1 14 1 2 3 4 7 5 20 4 39-13 70-39 68-9-1-16-5-29-17-14-12-14-12-27 1-11 11-20 18-28 21-7 3-15 3-19 0z"]],U={width:940,height:1192},K=1.4,R=52,Z=72,f1=500,V1=250,F=22,Y=22,i1=Y+2,l1=16,u1=12,X1=56,A1=17,E=9,S1=18,q=1/120,h1=1500,e1=430,C=48,J1=e1*e1/(2*h1),H1=Math.max(2.2*R,R+J1+4),B1=200,_1=B1*h1/(2*e1),Q=.84*R*U.width/U.height/2,d1=.84*R/2;function G1(r,a,m){let e=0;for(;r>=1e3&&e<a.length-1;e++)r/=1e3;return(e?r.toFixed(m):r.toFixed(m>1?1:0))+" "+a[e]}function G(r){return G1(r,["MB","GB","TB","PB"],2)}function I1(r){return r<6?[100,150,200,300,450,650][r]:[1,1.5,2.5,4,6][(r-6)%5]*Math.pow(10,3+Math.floor((r-6)/5))}function q1(r){const a=I1(r);return a<1e3?a+" Mbps":G1(a,["Mbps","Gbps","Tbps","Pbps"],1).replace(".0 "," ")}function D1(r){const a=Math.pow(.9,r);return{speed:_1-(_1-110)*a,gap:H1+(205-H1)*a,space:B1+70*a,swing:r<6?0:34*(1-Math.pow(.8,r-5)),drift:r>=6}}function Q1(r){return(Math.floor(r*1e3/f1)+3)%4}function Y1(r,a,m={}){const e=Z*U.width/U.height,l=Math.max(X1,m.board??0),I=Math.floor(r-2*(u1+l1)-l-i1-Y-e),P=Math.max(120,m.row??0,Math.min(V1,I)),c=l+i1+P+Y+e,f=Math.min(1,(r/2-u1)/(c/2+l1)),g=-2*F,M=g-12,u=-Z,b=40,h=Math.round(a/2-(u+b+4)/2),v=Math.round(r/2),w=Math.round(v-c/2),A=w+l+i1;return{cx:v,post:w,board:l,x:A,bar:P,ground:h,top:h+g,label:h+M,head:h+u,sign:h+M-(m.cap??12)+.75,rail:h+g+(F-E)/2,start:h+b,duck:A+P+Y+e/2,reach:Math.round(c/2+l1),shrink:f,text:(r-2*u1)/f}}function Z1(r,a,m){const e=a.getContext("2d");if(!e)return{setText(){},destroy(){}};const l=matchMedia("(prefers-reduced-motion: reduce)"),I=document.documentElement,P=U1.map(([t,n])=>[t,new Path2D(n)]);let c,f="",g=g1(),M=1,u=0,b=0,h=0,v=0,w=0,A=0,S=0,y=[],H=0,V=0,_=0,p1=0,t1=0,z=!1,x=0,X=0,n1=0,$=0,J=0,o1=!0,s1=0,r1=0;const m1=performance.now();function g1(){const t=getComputedStyle(r),n=s=>t.getPropertyValue(s).trim();return f=t.fontFamily,{ink:n("--rp-mark-ink"),paper:n("--rp-mark-paper"),yellow:n("--rp-mark-yellow"),text:n("--rp-text"),sub:n("--rp-subtle"),accent:n("--rp-accent"),wall:n("--rp-negative"),base:n("--rp-base"),bar:n("--rp-positive")}}function w1(){M=(window.devicePixelRatio||1)*K,a.width=Math.round(a.clientWidth*M/K),a.height=Math.round(a.clientHeight*M/K),u=a.clientWidth/K,b=a.clientHeight/K,h=Math.round(b*.84),v=Math.round(u*.3)}function M1(t){const n=D1(_),s=40+n.gap/2+n.swing,i=h-30-n.gap/2-n.swing,d=y[y.length-1];let o=s+Math.random()*(i-s);if(d){const L=(n.gap-2*d1)/2+220*(n.space-C-2*Q)/n.speed-2*n.swing;n.drift&&Math.random()<.6&&(o=d.c0<(s+i)/2?i:s),o=Math.max(d.c0-L,Math.min(d.c0+L,o))}o=Math.max(s,Math.min(i,o));const p=n.swing*(Math.random()<.5?1:0);y.push({x:t,ox:t,gap:n.gap,c0:o,c:o,oc:o,a:p,f:p?Math.min(3,110/p):0,ph:Math.random()*6.3,done:!1})}function x1(){w=A=b*.42,S=H=_=p1=t1=x=$=0,y=[],M1(u+10)}function b1(){x=performance.now(),V=Math.max(V,H),m(G(H),G(V)),window.clearTimeout(s1),s1=window.setTimeout(()=>W(),950)}function z1(t){const n=D1(_);J+=t,A=w,S=Math.min(700,S+h1*t),w+=S*t,w<R/2&&(w=R/2,S=0),H+=I1(_)/8*t;for(const s of y)s.ox=s.x,s.oc=s.c,s.x-=n.speed*t,s.a&&(s.c=s.c0+s.a*Math.sin(s.f*J+s.ph)),!s.done&&s.x+C<v-Q&&(s.done=!0,++p1%3===2&&(_+=1,t1=J)),!x&&s.x<v+Q&&s.x+C>v-Q&&(w-d1<s.c-s.gap/2||w+d1>s.c+s.gap/2)&&b1();y[y.length-1].x<u-n.space&&M1(u+10),y=y.filter(s=>s.x>-C),!x&&w+R/2-3>h&&(w=h-R/2+3,b1())}function D(t,n){e.beginPath(),n(),e.fillStyle=t,e.fill(),e.stroke()}function y1(t,n,s,i,d=!1){const o=s/U.height;e.save(),e.translate(t,n),e.rotate(i),e.scale(d?o:-o,o),e.translate(-628,-634);for(const[p,L]of P)e.fillStyle=g[p],e.fill(L,"evenodd");e.restore()}function O1(t,n,s,i,d){for(const[o,p]of[[t+10,t+5],[t+n-10,t+n-5]])D(g.paper,()=>{e.moveTo(o-2.5,s),e.lineTo(o+2.5,s),e.lineTo(p+2.5,d),e.lineTo(p-2.5,d),e.closePath()});D(g.yellow,()=>e.roundRect(t,i,n,E,2)),e.save(),e.beginPath(),e.roundRect(t,i,n,E,2),e.clip(),e.fillStyle=g.ink;for(let o=t-E;o<t+n;o+=12)e.beginPath(),e.moveTo(o,i+E),e.lineTo(o+6,i+E),e.lineTo(o+6+E,i),e.lineTo(o+E,i),e.fill();e.restore(),e.beginPath(),e.roundRect(t,i,n,E,2),e.stroke(),D(g.yellow,()=>e.roundRect(t,s,n,A1,3))}function k(t,n,s,i,d,o){e.fillStyle=i,e.font=`${d?600:500} ${d??13}px ${f}`,e.fillText(t,n,s,o)}function C1(t){return Math.round(t*M)/M}function W(t=1){if(e.setTransform(M,0,0,M,0,0),e.clearRect(0,0,u,b),!c||!u)return;const n=g;if(e.lineWidth=1.5,e.strokeStyle=n.ink,e.lineJoin="round",e.textAlign="center",!z){e.font=`600 11px ${f}`;const s=Math.ceil(e.measureText(c.status).width)+16;e.font=`600 15px ${f}`;const i=e.measureText([...c.loading][0]??"").actualBoundingBoxAscent,d=e.measureText(c.progress).width,o=Y1(u,b,{board:s,row:Math.ceil(e.measureText(c.loading+"...").width+S1+d),cap:i});e.save(),e.translate(o.cx,b/2),e.scale(o.shrink,o.shrink),e.translate(-o.cx,-b/2),e.fillStyle=n.sub,e.fillRect(o.cx-o.reach,o.ground,2*o.reach,1.5),O1(o.post,o.board,o.sign,o.rail,o.ground),D(n.paper,()=>e.roundRect(o.x,o.top,o.bar,F,F/2)),e.fillStyle=n.bar,e.beginPath(),e.roundRect(o.x+4,o.top+4,(o.bar-8)*.97,F-8,(F-8)/2),e.fill();const p=Q1(l.matches?0:(performance.now()-m1)/1e3);e.textAlign="right",k(c.progress,o.x+o.bar,o.label,n.text,15),e.textAlign="left",k(c.loading+"...".slice(0,p),o.x,o.label,n.text,15,o.bar-S1-d),e.textAlign="center",e.textBaseline="middle",k(c.status,o.post+o.board/2,o.sign+A1/2+.5,n.ink,11,o.board-16),e.textBaseline="alphabetic",y1(o.duck,o.ground-Z/2,Z,-.06,!0),l.matches||k(c.start,o.cx,o.start,n.sub,void 0,Math.min(360,o.text)),e.restore();return}e.fillStyle=n.sub,e.fillRect(0,h,u,1.5);for(const s of y){const i=C1(s.ox+(s.x-s.ox)*t),d=s.oc+(s.c-s.oc)*t,o=d-s.gap/2,p=d+s.gap/2;for(const[L,$1]of[[0,o],[p,h]]){D(n.wall,()=>e.rect(i,L-2,C,$1-L+2)),e.fillStyle=n.base;const j=!L;for(let c1=1,O=(j?o:p)+(j?-12:12);O>1&&O<h-1;c1++,O=(j?o:p)+(j?-12:12)*c1)e.fillRect(i+1,O,C-2,1),e.fillRect(i+(c1%2?16:32),j?O+1:O-11,1,11)}}e.strokeStyle=n.sub,x?(D(n.base,()=>e.roundRect(u/2-150,16,300,92,8)),k(c.result(G(H)),u/2,46,n.text,16),k(c.best(G(Math.max(V,H))),u/2,70,n.sub),performance.now()-x>900&&k(c.restart,u/2,94,n.sub)):(D(n.base,()=>e.roundRect(u/2-70,18,140,52,8)),k(G(H),u/2,40,n.text,16),k(q1(_),u/2,60,J-t1<1.2&&_?n.accent:n.sub)),e.strokeStyle=n.ink,y1(v,A+(w-A)*t,R,Math.max(-.35,Math.min(.5,S/900)))}function F1(t){for(X=0,$+=Math.min(.1,(t-(n1||t))/1e3),n1=t;$>=q&&!x;)z1(q),$-=q;W(x?1:$/q),T()}function T(){if(window.clearTimeout(r1),l.matches&&(z=!1),!z||x||l.matches||document.hidden||!o1){n1=0,!z&&!l.matches&&!document.hidden&&o1&&(r1=window.setTimeout(T,f1-(performance.now()-m1)%f1+5)),W();return}X||(X=requestAnimationFrame(F1))}function a1(t){l.matches||x&&!t&&performance.now()-x<900||((!z||x||t)&&(z=!0,x1()),S=-e1,T())}const T1=t=>{t.button||(t.preventDefault(),r.focus({preventScroll:!0,focusVisible:!1}),a1(!1))},k1=t=>{t.ctrlKey||t.metaKey||t.altKey||(t.key===" "||t.key==="r"||t.key==="R")&&(t.preventDefault(),t.repeat||a1(t.key!==" "))},E1=t=>{t.detail===0&&a1(!1)},R1=()=>{g=g1(),W()};r.addEventListener("pointerdown",T1),r.addEventListener("keydown",k1),r.addEventListener("click",E1),document.addEventListener("visibilitychange",T),l.addEventListener("change",T);const v1=new ResizeObserver(()=>{w1(),T()});v1.observe(a);const L1=new IntersectionObserver(t=>{o1=t[t.length-1].isIntersecting,T()});L1.observe(a);const P1=new MutationObserver(R1);return P1.observe(I,{attributes:!0,attributeFilter:["data-scheme","data-family","data-flavour"]}),w1(),x1(),T(),{setText(t){c=t,R1();const n=[t.loading,".",t.progress,t.status,t.start,t.restart,t.result(G(0)),t.best(G(0))].join("");Promise.all([500,600].map(s=>document.fonts.load(`${s} 16px ${f}`,n))).then(()=>{c===t&&W()},()=>{})},destroy(){c=void 0,cancelAnimationFrame(X),window.clearTimeout(s1),window.clearTimeout(r1),r.removeEventListener("pointerdown",T1),r.removeEventListener("keydown",k1),r.removeEventListener("click",E1),document.removeEventListener("visibilitychange",T),l.removeEventListener("change",T),v1.disconnect(),L1.disconnect(),P1.disconnect()}}}function ne(){const r=W1(),a=j1("(prefers-reduced-motion: reduce)"),m=B.useRef(null),e=B.useRef(null),l=B.useRef(null),[I,P]=B.useState(null),c=B.useMemo(()=>({loading:r("login.gameLoading"),progress:r("login.gameProgress"),status:r("login.gameStatus"),start:r("login.gameStart"),restart:r("login.gameRestart"),result:f=>r("login.gameResult",{amount:f}),best:f=>r("login.gameBest",{amount:f})}),[r]);return B.useEffect(()=>{const f=Z1(m.current,e.current,(g,M)=>P({amount:g,best:M}));return l.current=f,()=>{f.destroy(),l.current=null}},[]),B.useEffect(()=>l.current?.setText(c),[c]),N.jsxs("aside",{className:"rp-login-showcase","aria-hidden":a||void 0,children:[N.jsx(N1,{ref:m,canvasRef:e,className:"rp-login-game",label:r("login.gameLabel"),isDisabled:a}),N.jsx(K1,{"aria-live":"polite",children:I&&r("login.gameOver",I)})]})}export{ne as default};