asciify-engine 4.23.0 → 4.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +315 -0
- package/README.md +71 -711
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/field.cjs +1 -1
- package/dist/field.d.cts +4 -1
- package/dist/field.d.ts +4 -1
- package/dist/field.js +1 -1
- package/dist/hover.cjs +1 -1
- package/dist/hover.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/kit/chunk-2D2SG6FW.js +1 -0
- package/dist/kit/chunk-2JQ4MRIP.js +1 -0
- package/dist/kit/chunk-2KFBIOVS.js +1 -0
- package/dist/kit/chunk-2TQW2PIG.js +1 -0
- package/dist/kit/chunk-3F6FTBMN.js +1 -0
- package/dist/kit/chunk-4SHQA3CO.js +1 -0
- package/dist/kit/chunk-4XT5IKM3.js +1 -0
- package/dist/kit/chunk-6L2GAV5C.js +1 -0
- package/dist/kit/chunk-6XNIZ52V.js +1 -0
- package/dist/kit/chunk-6YVZZ3DO.js +1 -0
- package/dist/kit/chunk-A6EDU3UT.js +1 -0
- package/dist/kit/chunk-A73S2BCE.js +1 -0
- package/dist/kit/chunk-ANLBW5RI.js +1 -0
- package/dist/kit/chunk-B6GZ645M.js +1 -0
- package/dist/kit/chunk-BBOSHBZK.js +1 -0
- package/dist/kit/chunk-BJRPY7UB.js +1 -0
- package/dist/kit/chunk-CA5J25SV.js +1 -0
- package/dist/kit/chunk-CR7QS3B3.js +1 -0
- package/dist/kit/chunk-D4KCZSIP.js +1 -0
- package/dist/kit/chunk-EHXSXMBE.js +1 -0
- package/dist/kit/chunk-EHYFSX5K.js +1 -0
- package/dist/kit/chunk-EJ3W4FN6.js +1 -0
- package/dist/kit/chunk-EK4GIXIO.js +1 -0
- package/dist/kit/chunk-EPVZIGEZ.js +1 -0
- package/dist/kit/chunk-EWPT56TR.js +1 -0
- package/dist/kit/chunk-FIWIUXNV.js +1 -0
- package/dist/kit/chunk-G4BQYQJ6.js +1 -0
- package/dist/kit/chunk-GCIZKMJL.js +1 -0
- package/dist/kit/chunk-H4DBJULW.js +1 -0
- package/dist/kit/chunk-HMW5NRUV.js +1 -0
- package/dist/kit/chunk-IUX46UDR.js +1 -0
- package/dist/kit/chunk-JAM46FF6.js +1 -0
- package/dist/kit/chunk-JRSCTMFM.js +1 -0
- package/dist/kit/chunk-KBXVIAWS.js +1 -0
- package/dist/kit/chunk-KJJJORN6.js +1 -0
- package/dist/kit/chunk-KS3TL3S2.js +1 -0
- package/dist/kit/chunk-KTYCGGRO.js +1 -0
- package/dist/kit/chunk-L3P7ZDSK.js +1 -0
- package/dist/kit/chunk-LUOIH2EM.js +1 -0
- package/dist/kit/chunk-MIA6TUQC.js +1 -0
- package/dist/kit/chunk-MRDEO5HZ.js +1 -0
- package/dist/kit/chunk-NPJ77LDC.js +1 -0
- package/dist/kit/chunk-ODMQERGZ.js +1 -0
- package/dist/kit/chunk-ONVONNUH.js +1 -0
- package/dist/kit/chunk-OVCIHOOS.js +1 -0
- package/dist/kit/chunk-P6S6HSN3.js +1 -0
- package/dist/kit/chunk-PCGRRX5P.js +1 -0
- package/dist/kit/chunk-PDNKLLBI.js +1 -0
- package/dist/kit/chunk-PFNFW4ZI.js +1 -0
- package/dist/kit/chunk-PFQBEWCF.js +1 -0
- package/dist/kit/chunk-PND73YEV.js +1 -0
- package/dist/kit/chunk-PZAQLUAS.js +1 -0
- package/dist/kit/chunk-QKZYCROD.js +1 -0
- package/dist/kit/chunk-QTVMD62E.js +1 -0
- package/dist/kit/chunk-QZHZWO7N.js +1 -0
- package/dist/kit/chunk-SAQJAH2I.js +1 -0
- package/dist/kit/chunk-SE6MQQLB.js +1 -0
- package/dist/kit/chunk-SQGJ263V.js +1 -0
- package/dist/kit/chunk-SVXRMHUJ.js +1 -0
- package/dist/kit/chunk-UO4U32P7.js +1 -0
- package/dist/kit/chunk-V6GEQ5Y5.js +1 -0
- package/dist/kit/chunk-VFV7HZ3G.js +1 -0
- package/dist/kit/chunk-WT3XOWAI.js +1 -0
- package/dist/kit/chunk-XDNCXCR7.js +1 -0
- package/dist/kit/chunk-XPXMCXYI.js +1 -0
- package/dist/kit/chunk-XVB3B3FV.js +1 -0
- package/dist/kit/chunk-XXPDXJMQ.js +1 -0
- package/dist/kit/chunk-XYLLL2PQ.js +1 -0
- package/dist/kit/chunk-YBBYCUFP.js +1 -0
- package/dist/kit/chunk-YDP6566E.js +1 -0
- package/dist/kit/chunk-YL2AXWRA.js +1 -0
- package/dist/kit/chunk-ZCHGV2CV.js +1 -0
- package/dist/kit/chunk-ZYYLWSPY.js +1 -0
- package/dist/kit.cjs +1 -1
- package/dist/kit.d.cts +3 -1
- package/dist/kit.d.ts +3 -1
- package/dist/kit.js +1 -1
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +1 -1
- package/package.json +3 -2
- package/skills/asciify-engine/SKILL.md +3 -3
- package/skills/asciify-engine/references/applying-asciify.md +1 -1
- package/skills/asciify-engine/references/kit.md +2 -2
- package/skills/asciify-engine/references/performance.md +33 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{styleKeeper as t,mountSurface as e,handle as r,hash as n,prefersReduced as o,clamp as a,house as i}from"./chunk-PFQBEWCF.js";var s={length:6,accept:"digits",cells:"[data-cell]"},l=560,c=t=>{const e=Math.round(255*a(t));return`rgb(${e} ${e} ${e})`},u=(t,e,r="digits")=>("digits"===r?t.replace(/\D/g,""):t.replace(/[^a-z\d]/gi,"").toUpperCase()).slice(0,e);function d(d,h={}){const p={current:{...s,...h}},f=t(),m=t(),g=[],v=()=>!!(p.current.reducedMotion??o()),b=()=>Math.max(1,Math.round(p.current.length));let y="",x="idle",M=!1,A=[],w="",E=-1e9,k="",S=-1e9,C=[],$=[],L=0,P=null;const T=new Map;"static"===getComputedStyle(d).position&&f.set(d,"position","relative");let B=d.querySelector("input");B||(B=document.createElement("input"),B.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;border:0;opacity:0;font-size:16px;cursor:text"),d.appendChild(B),g.push(B));const q=B;q.setAttribute("inputmode","digits"===p.current.accept?"numeric":"text"),q.setAttribute("autocomplete","one-time-code"),q.setAttribute("maxlength",String(b())),"digits"===p.current.accept&&q.setAttribute("pattern","[0-9]*"),q.hasAttribute("aria-label")||q.hasAttribute("aria-labelledby")||q.setAttribute("aria-label",`Verification code, ${b()} ${"digits"===p.current.accept?"digits":"characters"}`);const z=()=>{const t=[...d.querySelectorAll(p.current.cells)];for(;t.length<b();){const e=document.createElement("span");e.dataset.cell="",e.setAttribute("aria-hidden","true"),q.parentElement===d?d.insertBefore(e,q):d.appendChild(e),g.push(e),t.push(e)}return t.slice(0,b())},F=t=>{let e=t.querySelector("[data-digit]");return e||(e=document.createElement("span"),e.dataset.digit="",t.appendChild(e),g.push(e)),e},W=(t,e,r,o,a,i,s,l=1,c=0,u=0,d=1)=>{const h=((t,e,r,n)=>{const o=`${t}|${Math.round(e)}x${Math.round(r)}|${n}`;let a=T.get(o);if(!a){a=document.createElement("canvas"),a.width=Math.max(2,Math.round(2*e)),a.height=Math.max(2,Math.round(2*r));const i=a.getContext("2d");i&&(i.scale(2,2),i.fillStyle="#fff",i.shadowColor="#fff",i.shadowBlur=3,i.font=`600 ${Math.round(.6*r)}px ${n}`,i.textAlign="center",i.textBaseline="middle",i.fillText(t,e/2,r/2+1)),T.set(o,a)}return a})(e,r.w,r.h,s);t.globalAlpha=l;const p=r.w*d,f=r.h*d,m=r.x+(r.w-p)/2+c,g=r.y+(r.h-f)/2+u;for(let e=0;e<r.h;e+=4)for(let s=0;s<r.w;s+=3){if(n(s+31*i,e)>1.3*o-.12)continue;const r=3*(1-o);t.drawImage(h,2*s,2*e,6,8,m+s*d+(n(s,e+a)-.5)*r,g+e*d+(n(e,s+a)-.5)*r,3*d,4*d)}t.globalAlpha=1},I=(t,e)=>{t.toggleAttribute("data-shown",e),m.set(F(t),"opacity",e?"1":"0")};P=e({host:d,outset:16,look:()=>({mark:"glyph",charset:" .:-=+*#%@",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:4,cellAspect:.62,glyphScale:.92,...p.current.look}),ink:()=>p.current.ink??"--ascii-ink-strong",kit:p,reducedMotion:()=>p.current.reducedMotion,resolution:2,onFail:()=>{P=null,m.restore(),z().forEach(t=>I(t,!0))},paint:({pen:t,w:e,h:r,now:n,still:o,box:s})=>{t.setTransform(2,0,0,2,0,0);const u=z(),h=o?0:Math.floor(n/110),p=getComputedStyle(d).fontFamily||"sans-serif";if("success"===x){const s=o?1:(n-S)/700,l=e/2,d=r/2;if(u.forEach(t=>I(t,!1)),s<.55){const e=(s/.55)**2;C.forEach((r,n)=>k[n]&&W(t,k[n],r,1,h,n,p,1-e**3,(l-r.x-r.w/2)*e,(d-r.y-r.h/2)*e,1-.65*e))}const f=a((s-.45)/.55);return f>0&&f<1&&(t.strokeStyle=c(.55*(1-f)),t.lineWidth=3,t.beginPath(),t.arc(l,d,18+44*(t=>1-(1-a(t))**3)(f),0,2*Math.PI),t.stroke()),((t,e,r,n)=>{if(n<=0)return;const o=[[e-20,r+1],[e-7,r+14],[e+21,r-14]],a=Math.hypot(13,13),i=Math.hypot(28,28);let s=n*(a+i);t.strokeStyle="#fff",t.lineWidth=8,t.lineCap="round",t.lineJoin="round",t.shadowColor="#fff",t.shadowBlur=4,t.beginPath(),t.moveTo(o[0][0],o[0][1]);const l=Math.min(1,s/a);if(t.lineTo(o[0][0]+(o[1][0]-o[0][0])*l,o[0][1]+(o[1][1]-o[0][1])*l),s-=a,s>0){const e=Math.min(1,s/i);t.lineTo(o[1][0]+(o[2][0]-o[1][0])*e,o[1][1]+(o[2][1]-o[1][1])*e)}t.stroke(),t.shadowBlur=0})(t,l,d+1,i(a((s-.4)/.45))),s<1}let f=!1;const m=n-E;return u.forEach((e,r)=>{const a=s(e),i=y[r];if(m<l&&w[r])return I(e,!1),W(t,w[r],a,1-m/l,h,r,p),void(f=!0);if(i){const s=o?1:(n-A[r])/300;if(I(e,s>=.7),s>=1)return;return f=!0,void(s>0&&W(t,i,a,s,h,r,p,s>.7?1-(s-.7)/.3:1))}if(I(e,!1),M&&r===y.length&&m>=l){const e=o?.6:.5-.5*Math.cos(n/1600*Math.PI*2);t.fillStyle=c(.2+.26*e),t.beginPath(),t.roundRect(a.x+a.w/2-1.5,a.y+a.h/2-11,3,22,1.5),t.fill(),f=!0}}),f}});const j=(t,e)=>{$.push(setTimeout(e,t))},D=()=>{$.forEach(clearTimeout),$=[]},G=()=>{d.dataset.state=x,"error"===x?q.setAttribute("aria-invalid","true"):q.removeAttribute("aria-invalid");const t=M&&"success"!==x?Math.min(y.length,b()-1):-1;z().forEach((e,r)=>{F(e).textContent=y[r]??"",e.toggleAttribute("data-active",r===t),P||I(e,!0),"success"===x&&P?(f.set(e,"transition","opacity 200ms, scale 240ms cubic-bezier(.16, 1, .3, 1)"),f.set(e,"opacity","0"),f.set(e,"scale",".86")):(e.style.removeProperty("opacity"),e.style.removeProperty("scale"))}),q.value!==y&&(q.value=y),P?.kick()},J=t=>{D(),"idle"!==x&&(x="idle",S=-1e9),w="",E=-1e9;const e=u(t,b(),p.current.accept),r=performance.now();let n=0;for(let t=0;t<e.length;t++)e[t]!==y[t]&&(A[t]=v()?-1e9:r+L*n++);y=e,G(),e.length===b()&&j(v()||!P?0:300+L*Math.max(0,n-1)+80,()=>p.current.onComplete?.(e)),L=0},Q=()=>J(q.value),R=()=>{L=55},U=()=>{M=!0,G()},V=()=>{M=!1,G()};return q.addEventListener("input",Q),q.addEventListener("paste",R),q.addEventListener("focus",U),q.addEventListener("blur",V),q.value?J(q.value):G(),r(()=>P,p,()=>{q.setAttribute("maxlength",String(b())),G(),P?.refresh()},{verify:t=>{D();const e=performance.now();if(t)return k=y,C=P?z().map(t=>P.box(t)):[],S=e,x="success",void G();w=y,E=v()||!P?e-l:e,x="error",G(),v()||"function"!=typeof d.animate||d.animate([{translate:"0"},{translate:"-9px"},{translate:"7px"},{translate:"-4px"},{translate:"2px"},{translate:"0"}],{duration:380,easing:"ease-out"});const r=y;j(v()||!P?0:l,()=>{w===r&&(w="",y="",G())})},clear:()=>{D(),w="",E=-1e9,S=-1e9,y="",x="idle",G()},fill(t){L=55,J(t)},get value(){return y},get state(){return x}},()=>{D(),q.removeEventListener("input",Q),q.removeEventListener("paste",R),q.removeEventListener("focus",U),q.removeEventListener("blur",V),m.restore(),f.restore();for(const t of g)t.remove();for(const t of d.querySelectorAll(p.current.cells))t.removeAttribute("data-shown"),t.removeAttribute("data-active");delete d.dataset.state})}var h=s;export{h as CODE_INPUT_DEFAULTS,u as cleanCode,d as codeInput};//# sourceMappingURL=chunk-YBBYCUFP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{styleKeeper as t,mountSurface as e,easeOut as n,srOnly as o,handle as r,isDark as a}from"./chunk-PFQBEWCF.js";var i={tone:"neutral",live:!1,indicator:!0,sheen:!0},l={light:{green:[22,150,82],amber:[214,138,8],red:[214,52,52],neutral:[120,120,114],new:[255,255,255]},dark:{green:[120,240,170],amber:[255,206,110],red:[255,156,156],neutral:[200,200,192],new:[255,255,255]}},s={light:[[.03," "],[.08,"·"],[.13,"•"],[.18,"○"],[.5,"●"],[.56,"◐"],[.62,"◓"],[.68,"◑"],[.74,"◒"],[.8,"●"],[.88,"✧"],[2,"✦"]],dark:[[.02," "],[.06,"✦"],[.1,"✧"],[.2,"·"],[.3,"•"],[.38,"○"],[.64,"●"],[.68,"◐"],[.72,"◓"],[.76,"◑"],[.8,"◒"],[2,"●"]]},c=t=>Array.from({length:96},(e,n)=>t.find(([t])=>n/95<t)[1]).join(""),d={light:c(s.light),dark:c(s.dark)},h=["◐","◓","◑","◒"],u=["✧","·","✧","✦","✧","✦"],f=12;var p=(t,e)=>{return"green"===(n=t.dataset.tone)||"amber"===n||"red"===n||"neutral"===n||"new"===n?t.dataset.tone:e;var n};function m(t,e,n){return{x:t.x+2,y:Math.round((t.y+t.h/2)/n-.5)*n,w:Math.max(0,t.w-4)}}function x(t,e){const n=t=>t.toFixed(2),o=e/2,r=t.filter(t=>t.w>2*o).map(({x:t,y:r,w:a})=>`M${n(t+o)} ${n(r)}H${n(t+a-o)}A${n(o)} ${n(o)} 0 0 1 ${n(t+a-o)} ${n(r+e)}H${n(t+o)}A${n(o)} ${n(o)} 0 0 1 ${n(t+o)} ${n(r)}Z`).join("");return r?`path("${r}")`:"inset(50%)"}function M(c,M={}){const g={current:{...i,...M}},y=c instanceof HTMLElement?[c]:[...c],w=1===y.length,v=w?y[0]:y.length?function(t){let e=t[0].parentElement;for(;e&&!t.every(t=>e.contains(t));)e=e.parentElement;return e??document.body}(y):null,b=t(),k=new Map,$=new Map,E=new Map,C=new Map,S=[],A=t=>void 0!==t.dataset.count?"count":"new"===p(t,g.current.tone)?"new":"status",F=t=>void 0!==t.dataset.live?"false"!==t.dataset.live:g.current.live,z=(t=-1e6)=>{for(const e of y){const n=p(e,g.current.tone),o=k.get(e);o?o.to!==n&&k.set(e,{from:o.to,to:n,at:t}):k.set(e,{from:n,to:n,at:-1e6})}};z();const L=()=>B?.dark()??(!v||a(v))?"dark":"light",j=()=>({mark:"glyph",charset:d[L()],font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:f,cellAspect:1,glyphScale:1,color:"source",saturation:1,shade:0,...g.current.look}),H=()=>{const{cellSize:t=f,cellAspect:e=1}=j(),n=Math.min(2,globalThis.devicePixelRatio||1),o=Math.max(2,Math.round(t*n));return{ch:o/n,cw:Math.max(2,Math.round(o*e))/n}};let T=[0,0];const P=new Map;let B=null,I="";function W(){for(;S.length;)S.pop()();b.restore()}B=v?e({host:v,layer:w?"under":"over",look:j,ink:()=>g.current.ink,kit:g,reducedMotion:()=>g.current.reducedMotion,resolution:(t,e)=>{const{cw:n,ch:o}=H();return[Math.max(2,Math.round(2*t/n)),Math.max(2,Math.round(2*e/o))]},onFail:()=>{B=null,W()},onTheme:()=>B?.field.update({charset:d[L()]}),paint:({pen:t,now:e,still:o,dark:r,box:a,width:i,w:c})=>{const d=g.current,f=r?"dark":"light",p={...l[f],...d.tones?.[f]},M=(t,e)=>((t,e,n=.5)=>{const o=s[t],r=o.findIndex(([,t])=>t===e),a=r>0?o[r-1][0]:0;return a+(Math.min(o[r][0],1)-a)*n})(f,t,e),{cw:w,ch:S}=H(),z=i/c,L=(e,n,o,r)=>{r<=0||(t.fillStyle=function(t,e){const n=Math.max(1,...t),o=t.map(t=>t/n*255),r=(.2126*o[0]+.7152*o[1]+.0722*o[2])/255,a=Math.min(1,e/Math.max(r,.01));return`rgb(${o.map(t=>Math.round(Math.max(0,Math.min(255,t*a)))).join(" ")})`}(o,r),t.fillRect(Math.round((e+.5)*w*z)-1,Math.round((n+.5)*S*z)-1,2,2))};let j=!1;const W=y.map(t=>"count"!==A(t)&&d.indicator?t.querySelector("[data-dot]"):null),q=y.map((t,e)=>{const n=a(t),o=W[e]?a(W[e]):null,[r,i]=P.get(t)??[0,0],l=t=>({...t,x:t.x+T[0]-r,y:t.y+T[1]-i});return{b:l(n),dot:o&&l(o)}}),N=q.find((t,e)=>t.dot&&"status"===A(y[e]))??q.find(t=>t.dot)??q[0];if(N){const t=(t,e)=>{const n=((t-e/2)%e+e)%e;return n>.001?n-e:0},e=[N.dot?t(N.dot.x+N.dot.w/2,w):0,t(N.b.y+N.b.h/2,S)];(Math.abs(e[0]-T[0])>.01||Math.abs(e[1]-T[1])>.01)&&(T=e,B.canvas.style.translate=`${T[0].toFixed(2)}px ${T[1].toFixed(2)}px`)}const R=B.canvas.style,G=(t,e,n)=>Math.max(1,Math.floor((t-e)/n))*n+"px",O=G(v.clientWidth,T[0],w),Q=G(v.clientHeight,T[1],S);R.width===O&&R.height===Q||(R.width=O,R.height=Q,B.field.resize(),j=!0);const Z=q.map((t,e)=>{const n=t=>({...t,x:t.x-T[0],y:t.y-T[1]});return((t,e,n,o,r)=>{const[a,i]=P.get(t)??[0,0],l=(t,e)=>Math.round((t-e/2)/e)*e+e/2-t,s=n?l(n.x+n.w/2,o):0,c=l(e.y+e.h/2,r);return(Math.abs(s-a)>.01||Math.abs(c-i)>.01)&&(P.set(t,[s,c]),b.set(t,"translate",`${s.toFixed(2)}px ${c.toFixed(2)}px`)),{b:{...e,x:e.x+s,y:e.y+c},dot:n&&{...n,x:n.x+s,y:n.y+c}}})(y[e],n(t.b),t.dot&&n(t.dot),w,S)}),D=Z.map(t=>t.b).map(t=>m(t,0,S)),J=x(D,S);return J!==I&&(I=J,B.canvas.style.clipPath=J),y.forEach((t,r)=>{const i=D[r],l=A(t),s=Math.round(i.y/S),c=Math.ceil(i.x/w),d=Math.floor((i.x+i.w)/w)-1;var m,x,g;if(!(d<c))if("status"===l){const a=Z[r].dot;if(!a)return;const i=k.get(t),l=e-i.at,u=o?1:n(l/240);u<1&&(j=!0);const y=(m=p[i.from],x=p[i.to],g=u,m.map((t,e)=>t+(x[e]-t)*g)),v=!o&&F(t),b=Math.floor((a.x+a.w/2)/w),$="light"===f?.55:.7,E="light"===f?.35:.25;let C="neutral"===i.to?M("○"):"amber"===i.to&&F(t)?M("◐"):M("●",$);"red"===i.to&&!o&&l<640?(j=!0,Math.floor(l/160)%2==0&&(C=M("○"))):v&&"amber"===i.to?(j=!0,C=M(h[Math.floor((e+90*r)/130)%4])):v&&(j=!0,C=M("●",$-E*Math.cos((e+500*r)/2200*Math.PI*2))),b>=c&&b<=d&&L(b,s,y,C)}else if("new"===l){const n=Z[r].dot;if(!n)return;const a=(e-($.get(t)??-1e6))/720,i=Math.floor((n.x+n.w/2)/w);a<1&&!o&&(j=!0),i>=c&&i<=d&&L(i,s,p.new,M(a<1&&!o?u[Math.floor(a*u.length)]:"✦"))}else{const r=E.get(t),i=C.get(t)?.digits.children;if(!i)return;if((r?(e-r.at)/600:1)>=1||o){for(const t of i)t.style.opacity="",t.style.translate="";return}j=!0,[...i].forEach((t,o)=>{if(!r.changed[o])return;const i=t,l=a(i),h=(e-r.at-70*o)/460,u=n((h-.72)/.28);if(i.style.opacity=String(u),i.style.translate=`0 ${3*(u-1)}px`,h<=0||h>=.78)return;const f=Math.min(d,Math.max(c,Math.floor((l.x+l.w/2)/w)));L(f,s,p.neutral,M(["·","•","○","●"][Math.floor(9*h)%4]))})}}),j}}):null;const q=t=>[...t].map(t=>Object.assign(document.createElement("span"),{textContent:" "===t?"":t}));if(B){w||(B.canvas.style.zIndex="1");for(const t of y){if("count"===A(t)){const e=(t.textContent??"").trim(),n=[...t.childNodes],r=o(e),a=document.createElement("span");a.setAttribute("aria-hidden","true"),b.set(a,"display","inline-flex"),a.replaceChildren(...q(e)),t.replaceChildren(r,a),C.set(t,{text:e,live:r,digits:a}),S.push(()=>{const o=C.get(t)?.text??e;o===e?t.replaceChildren(...n):t.textContent=o})}else if(g.current.indicator&&!t.querySelector("[data-dot]")){const e=document.createElement("span");e.dataset.dot="",e.setAttribute("aria-hidden","true"),e.setAttribute("style",`display:inline-block;flex:none;width:${f}px;height:${f}px;margin-inline-end:4px;vertical-align:middle`),t.prepend(e),S.push(()=>e.remove())}if(!w)for(const e of[...t.childNodes])if(3===e.nodeType&&e.textContent?.trim()){const t=document.createElement("span");e.parentElement.insertBefore(t,e),t.appendChild(e),S.push(()=>{t.parentElement?.insertBefore(e,t),t.remove()}),N(t)}else e instanceof HTMLElement&&void 0===e.dataset.dot&&N(e)}C.size&&document.fonts?.ready.then(()=>B?.kick()),v.addEventListener("pointermove",O),v.addEventListener("pointerleave",Q)}function N(t){"static"===getComputedStyle(t).position&&b.set(t,"position","relative"),b.set(t,"z-index","2")}function R(t){const e=performance.now();for(const n of t?[t]:y.filter(t=>"new"===A(t)))$.set(n,e);B?.kick()}let G=null;function O(t){const e=t.target,n=y.find(t=>e&&t.contains(e))??null;n!==G&&(G=n,n&&"new"===A(n)&&g.current.sheen&&R(n))}function Q(){G=null}return r(()=>B,g,()=>{z(performance.now()),B?.refresh()},{sheen:R,count:(t,e)=>{const n=e??y.find(t=>"count"===A(t));if(!n)return;const o=String(t),r=C.get(n);if(!r)return void(n.textContent=o);if(o===r.text)return;const a=Math.max(o.length,r.text.length),i=r.text.padStart(a," "),l=o.padStart(a," "),s=B?.still()??!0;r.text=o,r.live.textContent=o,r.digits.replaceChildren(...q(l)),E.set(n,{at:s?-1e6:performance.now(),changed:[...l].map((t,e)=>t!==i[e])}),B?.kick()},refresh:()=>{z(performance.now()),B?.kick()}},()=>{v?.removeEventListener("pointermove",O),v?.removeEventListener("pointerleave",Q),W()})}var g=i;export{g as PILL_DEFAULTS,l as PILL_TONES,x as laneClip,M as pill,m as pillLane,p as pillTone};//# sourceMappingURL=chunk-YDP6566E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{clamp as t,hash as e,mountSurface as r,handle as a,smoothstep as n}from"./chunk-PFQBEWCF.js";var o={colorful:["#22c55e","#06b6d4","#6366f1","#d946ef","#f43f5e","#f59e0b"],mono:["#ffffff"],ocean:["#22d3ee","#3b82f6","#2dd4bf","#818cf8"],sunset:["#f97316","#f43f5e","#ec4899","#fbbf24"]},s={palette:"colorful",mode:"rotate",grain:"dots",speed:1,hover:!0,depth:18},i=["rotate","pulse","progress"],l=t=>{const e=/^#[\da-f]{3}$/i.test(t)?`#${[...t.slice(1)].map(t=>t+t).join("")}`:t;return[1,3,5].map(t=>(parseInt(e.slice(t,t+2),16)||0)/255)},h=(t,e,r)=>t.map((t,a)=>t+(e[a]-t)*r),c=l("#ff4a4a"),u=l("#2fd67b");function p(t){const e=("string"==typeof t?o[t]??o.colorful:t.length?t:o.colorful).map(l),r=new Float32Array(1024);for(let t=0;t<256;t++){const a=t/256*e.length,n=Math.floor(a),o=a-n,s=1===e.length?e[0]:h(e[n%e.length],e[(n+1)%e.length],o*o*(3-2*o)),i=Math.max(...s,.01);r.set([s[0]/i,s[1]/i,s[2]/i,(.2126*s[0]+.7152*s[1]+.0722*s[2])/i],4*t)}return r}var m=(t,e)=>{const r=(-t%1+1)%1,a=1-r;return Math.max(r<e?(1-r/e)**2.2:0,a<.03?(1-a/.03)**2:0)},f=t=>Math.max(m(t,.3),.75*m(t-.5,.22)),M=(t,e)=>t<=e?.42+.4*(t/Math.max(e,.001))**1.6+.38*Math.exp(-(((e-t)/.03)**2)):t-e<.014?1.2*(1-(t-e)/.014)**2:0,d=(e,r)=>t((e-.68*r)/.07);function g(t,r,a,n,o,s,i){const l=Math.ceil(t/a),h=t/2,c=r/2,u=Math.min(h,c),[p,m,f,M]=[0,1,2,3].map(t=>Math.max(0,Math.min(s[t]??s[0]??0,u))),d=new Int32Array(l*Math.ceil(r/n)).fill(-1),g=[],x=[],v=[];for(let t=0;t<d.length;t++){const r=(t%l+.5)*a-h,s=(Math.floor(t/l)+.5)*n-c,u=r<0?s<0?p:M:s<0?m:f,k=Math.abs(r)-h+u,b=Math.abs(s)-c+u,y=-(Math.hypot(Math.max(k,0),Math.max(b,0))+Math.min(Math.max(k,b),0)-u),L=y>0?Math.min(Math.max(0,1-y/Math.max(1,o))**1.7,y/Math.max(.1,i)):0;if(L<.004)continue;d[t]=g.length,g.push(L);const w=Math.atan2(s/Math.max(1,c),r/Math.max(1,h))/(2*Math.PI)+.25,A=w-Math.floor(w);x.push(A),v.push(.78*e(Math.floor(46*A),5)+.22*e(t,9))}const k=Math.max(1,Math.round(t)),b=Math.max(1,Math.round(r)),y=[],L=[];for(let t=0;t<b;t++)for(let e=0;e<k;e++){const r=d[Math.min(l-1,Math.floor((e+.5)/a))+l*Math.floor((t+.5)/n)];r>=0&&(y.push(t*k+e),L.push(r))}return{W:k,H:b,weight:Float32Array.from(g),turn:Float32Array.from(x),crack:Float32Array.from(v),pixel:Int32Array.from(y),owner:Int32Array.from(L)}}function x(o,l={}){const h={current:{...s,...l}};let m="idle",x=0,v=p(h.current.palette),k=!1;const b=()=>"mono"===h.current.palette,y=()=>({..."glyphs"===h.current.grain?{mark:"glyph",charset:" ·.:-+*",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:5,cellAspect:.6,glyphScale:1}:{mark:"dot",cellSize:3.5,cellAspect:1,dotScale:.82},color:b()?"ink":"source",saturation:1.25,shade:.55,contrast:2.4,brightness:.58,...h.current.look}),L=t=>{const e=!t.dark();t.canvas.style.opacity=e?"0.72":"",t.canvas.style.filter=e&&!b()?"brightness(1.45) saturate(.9)":""};let w=null,A=null,F=new Uint8Array(0),I="",E=0,$=null,P=0,R=.62,S=0,W=0,T=0,j=0,z=0,B=0;const H={rotate:0,pulse:0,progress:0};H[h.current.mode]=1;let C=null;C=r({host:o,look:y,ink:t=>h.current.ink??(t?"#b3b1aa":"#8a8882"),kit:h,reducedMotion:()=>h.current.reducedMotion,onTheme:()=>C&&L(C),onFail:()=>{C=null},resolution:(t,e)=>[Math.max(1,Math.round(t)),Math.max(1,Math.round(e))],paint:r=>{const{pen:a,w:s,h:l,now:p,still:b,dark:L}=r,D=h.current,U=getComputedStyle(o),G=Math.min(o.clientWidth||s,o.clientHeight||l),N=Math.max(2,Math.min(D.depth,Math.min(parseFloat(U.paddingTop)||D.depth,parseFloat(U.paddingLeft)||D.depth)-2)),Q=[U.borderTopLeftRadius,U.borderTopRightRadius,U.borderBottomRightRadius,U.borderBottomLeftRadius].map(t=>((t,e)=>t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0)(t??"",G)),q=y(),J="dot"!==q.mark,K=q.cellSize??(J?5:3.5),O=q.cellAspect??(J?.6:1),V=`${s}x${l}:${D.grain}:${N}:${Q.join(",")}:${K}:${O}`;if(V!==I){I=V,C.canvas.style.clipPath=`inset(0 round ${Q.map(t=>`${t}px`).join(" ")})`;const t=Math.min(globalThis.devicePixelRatio||1,q.maxPixelRatio??2),e=Math.max(2,Math.round(K*t)),r=Math.max(2,Math.round(e*O))/t,n=e/t;w=g(s,l,r,n,N,Q,J?Math.min(r,n)/2:(q.dotScale??.82)*r/2),A=a.createImageData(w.W,w.H),F=new Uint8Array(3*w.weight.length)}const X=w,Y=A.data,Z=X.crack,_=(e,r,n,o,s)=>{F.fill(0);for(let a=0;a<X.weight.length;a++){const i=X.turn[a],l=t(X.weight[a]*e(i,a))*(L?1.12:.8);if(l<.03)continue;const h=4*(255&Math.floor(((i-r)%1+1)%1*256));let p=v[h],m=v[h+1],f=v[h+2],M=v[h+3];const d=s&&L?s(i):0;(o>0||n>0||d>0)&&(o>0&&(p+=(u[0]-p)*o,m+=(u[1]-m)*o,f+=(u[2]-f)*o),n>0&&(p+=(c[0]-p)*n,m+=(c[1]-m)*n,f+=(c[2]-f)*n),d>0&&(p+=(1-p)*d,m+=(1-m)*d,f+=(1-f)*d),M=.2126*p+.7152*m+.0722*f);const g=255*Math.min(1,(l+.12)/2.4/Math.max(M,.01));F[3*a]=p*g,F[3*a+1]=m*g,F[3*a+2]=f*g}Y.fill(0);for(let t=0;t<X.pixel.length;t++){const e=4*X.pixel[t],r=3*X.owner[t];Y[e]=F[r],Y[e+1]=F[r+1],Y[e+2]=F[r+2],Y[e+3]=255}a.putImageData(A,0,0)};if(b){const t="progress"===D.mode?t=>"running"===m||"error"===m?M(t,x):.14:t=>("running"===m?.75:.55)*(.7+.3*Math.cos(2*Math.PI*(t-.12)));return"success"===m?_(()=>.62,0,0,.9):"error"===m?_((e,r)=>.5*t(e)*d(Z[r],1),0,.9,0):_(t,0,0,0),!1}const tt=E?Math.min(48,p-E):16;E=p,m!==$&&("running"===m&&"running"!==$&&(z=0),P=p,$=m);let et=p-P;"success"===m&&et>2700&&(m=$="idle",x=0,P=p,et=0);const rt="running"===m,at="error"===m,nt="success"===m,ot=D.hover&&k;for(const t of i)H[t]+=((t===D.mode?1:0)-H[t])*(1-Math.exp(-tt/260));if(at)W=0;else{const t=(rt?1500-500*x:"pulse"===D.mode?9e3:2600)/Math.max(.05,D.speed);W+=(1/t*(ot?1.35:1)-W)*(1-Math.exp(-tt/320)),R+=W*tt,B+=tt,S+=tt/("pulse"===D.mode?14e3:26e3)*(1-H.progress),(rt||nt)&&(z+=((nt?1:x)-z)*(1-Math.exp(-tt/110)))}T+=((ot?1:0)-T)*(1-Math.exp(-tt/220)),j=at?.9*n(0,60,et):j*Math.exp(-tt/180);const st=1+.22*T,it=.32+.68*(.5-.5*Math.cos(2*Math.PI*B/2400)),lt=.05+.1*(.5-.5*Math.cos(2*Math.PI*B/5200)),ht=rt||nt||at,ct=t=>st*(H.rotate*f(t-R)+H.pulse*(rt||at?f(t-R):it*(.78+.22*Math.cos(2*Math.PI*(t-R))))+H.progress*(ht?M(t,z):lt));if(nt){const e=n(0,260,et),r=t((et-240)/620),a=1-n(860,1060,et),o=n(780,1e3,et),s=n(1350,2450,et),i=(L?.86:.55)*e*(1-o)+.62*o*(1-s),l=1-e*(1-n(1900,2700,et)*(1-H.progress)),h=t=>{if(et<240)return 0;const e=r-t;return a*(e>=0?e<.2?(1-e/.2)**2:0:e>-.02?(1+e/.02)**2:0)};return _(t=>Math.max(ct(t)*l,i*(.9+.1*Math.cos(2*Math.PI*(t-.1))),1.3*h(t),H.progress*lt*s),S,0,.9*o*(1-s),e=>t(.8*h(e))),!0}if(at){const t=et<90?1.2:et<170?.1:et<260?1.2:et<340?.1:1,r=n(380,1150,et),a=1-.5*n(700,1500,et),o=Math.floor(et/50);return _((n,s)=>{const i=d(Z[s],r);return i<=0?0:ct(n)*t*i*a*(1-1.4*r*(1-r)*e(s,o))},S,j,0),et<1600||Math.abs(T-(ot?1:0))>.01}return _(ct,S,j,0),!0}});const D=()=>{k||(k=!0,C?.kick())},U=()=>{k=!1,C?.kick()},G=t=>{k=t.target?.matches?.(":focus-visible")??!1,C?.kick()};C&&(L(C),o.addEventListener("pointerenter",D),o.addEventListener("pointermove",D),o.addEventListener("pointerleave",U),o.addEventListener("focusin",G),o.addEventListener("focusout",U));const N=t=>{m=t,C?.kick()};return a(()=>C,h,t=>{v=p(t.palette),C?.refresh(),C&&L(C)},{progress(e){x=t(Number.isFinite(e)?e:0),N("running")},success(){N("success")},error(){N("error")},reset(){x=0,N("idle")}},()=>{o.removeEventListener("pointerenter",D),o.removeEventListener("pointermove",D),o.removeEventListener("pointerleave",U),o.removeEventListener("focusin",G),o.removeEventListener("focusout",U)})}var v=s;export{v as BEAM_DEFAULTS,o as BEAM_PALETTES,x as beam,f as beamArcs,g as beamBand,d as beamCracked,p as beamPalette,M as beamRing};//# sourceMappingURL=chunk-YL2AXWRA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(n){const t=n.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const n=t.length<=4?t.split("").map(n=>parseInt(n+n,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:n[0],g:n[1],b:n[2]}}const r=n.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return r?{r:+r[1],g:+r[2],b:+r[3]}:null}function t(n){return n*n*n*(n*(6*n-15)+10)}function r(n,t,r){return n+(t-n)*r}function o(n,t){let r=127*n+311*t;return r^=r>>13,(r*(r*r*15731+789221)+1376312589&2147483647)/2147483647}function a(n,a){const e=Math.floor(n),i=Math.floor(a),u=a-i,c=t(n-e),s=t(u),f=o(e,i),M=o(e+1,i),h=o(e,i+1),m=o(e+1,i+1);return r(r(f,M,c),r(h,m,c),s)}function e(n,t){return(.5*a(n,t)+.25*a(2.1*n,2.1*t)+.125*a(4.3*n,4.3*t))/.875}var i='"Geist Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace';function u(n){const t=("function"==typeof n.getTransform?n.getTransform().a:1)||1;return n=>Math.round(n*t)/t}var c={r:111,g:109,b:103},s={r:143,g:141,b:134};function f(n,t,r){return Math.min(1,Math.max(0,(n-t)/(r-t)))}function M(n,t=.3,r=.95){return t+(r-t)*Math.min(1,Math.max(0,n))}var h=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function m(n,t,r,o,a=0){const e=(h[(3&o)<<2|3&r]+.5)/16;return Math.min(t-1,Math.max(0,Math.floor(n*(t-1)+e*Math.min(1,Math.max(0,a)))))}export{s as GRAPHITE_DARK,c as GRAPHITE_LIGHT,i as MONO,f as band,m as ditherIndex,e as fbm,o as hash2,n as parseColor,u as pixelSnap,M as toneAlpha,a as vnoise};//# sourceMappingURL=chunk-ZCHGV2CV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{injectStyle as e,imageReady as t,imageFor as n,drawCover as a}from"./chunk-PCGRRX5P.js";import{srOnly as o,mountSurface as r,handle as i,isDark as l,clamp as s}from"./chunk-PFQBEWCF.js";var c={maxBytes:10485760,develop:900};function d(e,t,n=Math.min(2,"number"==typeof devicePixelRatio&&devicePixelRatio>0?devicePixelRatio:1)){const a=Math.max(2,Math.round(6*n)),o=Math.max(2,Math.round(1*a)),r=(e,t)=>{const a=Math.floor(e*n/t);for(let e=a;e>1;e--){const o=e*t/n;if(Math.abs(o-Math.round(o))<.01||e<a-8)return{n:e,css:Math.round(o)}}return{n:1,css:Math.round(t/n)}},i=r(e,o),l=r(t,a);return{cols:i.n,rows:l.n,w:i.css,h:l.css,cw:o/n,ch:a/n}}function p(e,t,n,a){const{cols:o,rows:r}=t,i=e.createImageData(2*o,2*r),l=i.data,{tone:s,glow:c=0,phase:d=0,near:p=null}=a,h=Math.max(1,n/t.cw),u=Math.max(1,n/t.ch),m=o-2,f=r-2,g=Math.max(0,m-1-2*h),x=Math.max(0,f-1-2*u),v=Math.PI/4*(h+u),y=.45*Math.hypot(o,r);for(let e=0;e<r;e++)for(let t=0;t<o;t++){const n=Math.max(1+h-t,0,t-(m-h)),a=Math.max(1+u-e,0,e-(f-u));let r;if(n>0&&a>0){const e=Math.hypot(n/h,a/u);r=Math.hypot(n,a)*(1-1/e)}else r=-Math.min(t-1,m-t,e-1,f-e);let i=0;if(Math.abs(r)<.5){if(i=s,c>0){const o=t>m-h,r=e>f-u,l=t<1+h,p=e<1+u,y=(e,t)=>Math.atan2(e,t)/(Math.PI/2);let M;M=!p||l||o?p&&o?g+v*y(n/h,a/u):!o||p||r?r&&o?g+v+x+v*y(a/u,n/h):r&&!l?g+2*v+x+(m-h-t):r&&l?2*g+2*v+x+v*y(n/h,a/u):l&&!p?2*g+3*v+x+(f-u-e):2*g+3*v+2*x+v*y(a/u,n/h):g+v+(e-(1+u)):t-(1+h);const b=((M-d)%9+9)%9;i=s+c*(.2+.32*Math.max(0,1-Math.abs(b-4.5)/2.2))}}else if(c>0&&r<-.5&&r>-3.5){i=c*(1-(-r-.5)/3)**1.6*(.1+.32*(p?Math.max(0,1-Math.hypot(t-p.x,e-p.y)/y):.4))}const M=Math.round(255*Math.min(1,i));for(let n=0;n<4;n++){const a=4*((2*e+(n>>1))*o*2+2*t+(1&n));l[a]=l[a+1]=l[a+2]=M,l[a+3]=255}}e.putImageData(i,0,0)}function h(h,u={}){const m={current:{...c,...u}};let f="empty",g=null,x="",v="",y="image",M=0,b=0,w=!1,k=0,C=0,E=0,L=0,R=null,S=null,z=null,$=null,P=null;const U=o("",!0),j=["left","top","width","height"],O=()=>{const e=$?.canvas;if(!e||!h.offsetWidth)return null;const t="empty"===f?d(h.offsetWidth,h.offsetHeight):null,n=t?[`${Math.round((h.offsetWidth-t.w)/2)}px`,`${Math.round((h.offsetHeight-t.h)/2)}px`,`${t.w}px`,`${t.h}px`]:["0px","0px","100%","100%"];let a=!1;return j.forEach((t,o)=>{e.style[t]!==n[o]&&(e.style[t]=n[o],a=!0)}),P=t,a?($?.field.resize(),$?.kick(),null):t},B=document.createElement("input"),D=[U,B];let I=null;const W=!h.children.length;$=r({host:h,layer:"under",look:()=>"empty"===f?{mark:"glyph",charset:" .:+*#",font:'"Geist Mono", ui-monospace, monospace',fontWeight:500,cellSize:6,cellAspect:1,glyphScale:.9,...m.current.look}:{blend:"coarse",mark:"glyph",charset:" .:-=+*#%@",font:'"Geist", Arial, sans-serif',fontWeight:500,cellSize:6,cellAspect:.8,glyphScale:.8,background:l(h)?"transparent":"#0b0b0a",color:"source",saturation:1.15,contrast:1.15,levels:"auto",brightness:.08,hover:"trail",trail:{strength:.6,radius:.3},...m.current.look},ink:e=>m.current.ink??`var(--ascii-ink, ${e?"#7a7872":"#76746e"})`,kit:m,reducedMotion:()=>m.current.reducedMotion,resolution:(e,t)=>"empty"===f&&P?[2*P.cols,2*P.rows]:[Math.max(1,Math.round(e)),Math.max(1,Math.round(t))],onFail:()=>{$=null,x&&N(x)},paint:({pen:e,w:t,h:n,now:o,still:r})=>{if("empty"!==f){if(!g)return!1;const i=r?1:s((o-M)/m.current.develop),l=1-(1-i)**2;return a(e,g,0,0,t,n),"developing"===f&&l<1&&function(e,t,n,a,o){const r=Math.max(Math.hypot(a.x,a.y),Math.hypot(t-a.x,a.y),Math.hypot(a.x,n-a.y),Math.hypot(t-a.x,n-a.y)),i=Math.max(24,.22*Math.min(t,n)),l=o*(r+i),s=Math.max(0,l-i),c=e.createRadialGradient(a.x,a.y,s,a.x,a.y,Math.max(s+1,l));c.addColorStop(0,"rgb(0 0 0 / 0)"),c.addColorStop(1,"rgb(0 0 0 / 1)"),e.globalCompositeOperation="source-over",e.fillStyle=c,e.fillRect(0,0,t,n);const d=e.createRadialGradient(a.x,a.y,s,a.x,a.y,Math.max(s+1,l)),p=1-o*o;d.addColorStop(0,"rgb(255 255 255 / 0)"),d.addColorStop(.55,`rgb(255 255 255 / ${.5*p})`),d.addColorStop(1,"rgb(255 255 255 / 0)"),e.globalCompositeOperation="lighter",e.fillStyle=d,e.fillRect(0,0,t,n),e.globalCompositeOperation="source-over"}(e,t,n,z??{x:t/2,y:n/2},l),i>=1&&"developing"===f&&F(),i<1}const i=E?Math.min(64,o-E):16;E=o;const l=w?1:0;C=r?l:C+(l-C)*(1-Math.exp(-i/90)),!r&&C>.004&&(L+=i/1e3*14);const c=Math.max(4,(parseFloat(getComputedStyle(h).borderTopLeftRadius)||16)-6),d=O();if(d){const t=$.canvas.getBoundingClientRect(),n=S&&t.width?{x:(S.x-t.left)/t.width*d.cols,y:(S.y-t.top)/t.height*d.rows}:null;p(e,d,c,{tone:.3,glow:C,phase:L,near:n})}const u=!r&&(w||Math.abs(l-C)>.004);return u||(E=0),u}});const G=e=>{const t=f;f=e,h.dataset.state=e,"empty"===t!=("empty"===e)&&(O(),$?.refresh()),t!==e&&m.current.onState?.(e,"empty"===e?"":y)},F=()=>{G("done"),U.textContent=`${y} ready`,g&&m.current.onImage?.({file:R,src:x,width:g.width,height:g.height})};function N(e){I??(I=Object.assign(document.createElement("img"),{className:"ascii-drop-img",alt:""})),I.src=e,I.parentElement!==h&&(h.prepend(I),D.push(I))}const A=async(e,a=null,o=null)=>{const r=++b;let i;z=o,v&&URL.revokeObjectURL(v),v="string"==typeof e?"":URL.createObjectURL(e),x=v||e,R=a??("undefined"!=typeof File&&e instanceof File?e:null),y=R?.name??("string"==typeof e&&e.split("/").pop()?.split("?")[0]||"image"),U.textContent=`Converting ${y}`;try{i=await t(n(x))}catch{return void(r===b&&(U.textContent=`Could not load ${y}`))}if(r===b){if(g=i,!$)return N(x),G("done"),void F();M=performance.now(),G($.still()?"done":"developing"),$.field.pulse({strength:1}),$.kick(),"done"===f&&F()}},T=(e,t=null)=>{const n=t=>{U.textContent=t,m.current.onError?.(t,e)};return e.type.startsWith("image/")?e.size>m.current.maxBytes?n(`${e.name} is over ${Math.round(m.current.maxBytes/1024/1024)} MB.`):void A(e,e,t):n(`${e.name} isn’t an image.`)},X=()=>{b++,g=null,x="",R=null,v&&URL.revokeObjectURL(v),v="",I?.remove(),G("empty"),U.textContent="",$?.kick()},Y=()=>B.click(),H=e=>new Promise(t=>{const n=$?.field;if(!n||!g||"done"!==f)return void t(null);const a=document.createElement("canvas");a.width=n.canvas.width,a.height=n.canvas.height;const o=a.getContext("2d");o?(o.fillStyle=getComputedStyle(h).backgroundColor||"#000",o.fillRect(0,0,a.width,a.height),n.redraw(),o.drawImage(n.canvas,0,0),a.toBlob(n=>{if(n){const t=document.createElement("a");t.href=URL.createObjectURL(n),t.download=e??m.current.filename??`${y.replace(/\.[^.]+$/,"")}-ascii.png`,t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),1e3)}t(n)},"image/png")):t(null)}),J=()=>{E=0,$?.kick()},Q=e=>{e.preventDefault(),k++,S={x:e.clientX,y:e.clientY},w||(w=!0,h.dataset.over="",J())},q=e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),S={x:e.clientX,y:e.clientY}},K=()=>{k=Math.max(0,k-1),!k&&w&&(w=!1,S=null,delete h.dataset.over,J())},V=e=>{e.preventDefault(),k=0,w=!1,S=null,delete h.dataset.over;const t=h.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top};$?.field.pulse({...n,strength:1});const a=e.dataTransfer?.files?.[0];a?T(a,n):J()},Z=e=>{const t=e.target?.closest?.("[data-dropzone]")?.getAttribute("data-dropzone");"pick"===t?Y():"clear"===t?X():"download"===t&&H()},_=()=>{const e=B.files?.[0];B.value="",e&&T(e)};e("ascii-kit-dropzone",'\n:where(.ascii-drop-empty){position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:100%;min-height:inherit;padding:24px;box-sizing:border-box;text-align:center}\n:where([data-ascii-dropzone]:not([data-state="empty"])) :where(.ascii-drop-empty){display:none}\n:where(.ascii-drop-title){margin:0;font-weight:500}\n:where(.ascii-drop-hint){margin:0;font-size:14px;opacity:.65}\n:where(.ascii-drop-pick){margin-top:8px;height:34px;padding:0 14px;border:0;border-radius:999px;background:currentColor;font:inherit;font-size:14px;cursor:pointer}\n:where(.ascii-drop-pick) > span{color:Canvas}\n:where(.ascii-drop-img){position:absolute;inset:0;width:100%;height:100%;object-fit:cover}\n'),h.dataset.asciiDropzone="",B.type="file",B.accept="image/*",B.tabIndex=-1,B.hidden=!0,B.setAttribute("aria-hidden","true"),W&&D.push(function(){const e=document.createElement("div"),t=document.createElement("p"),n=document.createElement("p"),a=document.createElement("button"),o=document.createElement("span");return e.className="ascii-drop-empty",t.className="ascii-drop-title",t.textContent="Drop an image",n.className="ascii-drop-hint",n.textContent="PNG, JPG or WebP",a.type="button",a.className="ascii-drop-pick",a.dataset.dropzone="pick",o.textContent="Choose file",a.appendChild(o),e.append(t,n,a),e}());for(const e of D)h.appendChild(e);return G("empty"),h.addEventListener("dragenter",Q),h.addEventListener("dragover",q),h.addEventListener("dragleave",K),h.addEventListener("drop",V),h.addEventListener("click",Z),B.addEventListener("change",_),i(()=>$,m,()=>$?.refresh(),{setImage:e=>A(e),clear:X,pick:Y,download:H,get state(){return f}},()=>{b++,v&&URL.revokeObjectURL(v),h.removeEventListener("dragenter",Q),h.removeEventListener("dragover",q),h.removeEventListener("dragleave",K),h.removeEventListener("drop",V),h.removeEventListener("click",Z),B.removeEventListener("change",_),D.forEach(e=>e.remove()),delete h.dataset.asciiDropzone,delete h.dataset.state,delete h.dataset.over})}var u=c;export{u as DROPZONE_DEFAULTS,h as dropzone,p as paintRing,d as ringGrid};//# sourceMappingURL=chunk-ZYYLWSPY.js.map
|