asciify-engine 4.24.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +315 -0
  2. package/README.md +71 -718
  3. package/dist/core.cjs +1 -1
  4. package/dist/core.js +1 -1
  5. package/dist/field.cjs +1 -1
  6. package/dist/field.d.cts +4 -1
  7. package/dist/field.d.ts +4 -1
  8. package/dist/field.js +1 -1
  9. package/dist/hover.cjs +1 -1
  10. package/dist/hover.js +1 -1
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/kit/{chunk-3473NPIN.js → chunk-2D2SG6FW.js} +1 -1
  14. package/dist/kit/chunk-2JQ4MRIP.js +1 -0
  15. package/dist/kit/{chunk-RFLIFKZ4.js → chunk-2KFBIOVS.js} +1 -1
  16. package/dist/kit/{chunk-FR3ZJNOY.js → chunk-2TQW2PIG.js} +1 -1
  17. package/dist/kit/{chunk-C4KZYCPF.js → chunk-3F6FTBMN.js} +1 -1
  18. package/dist/kit/chunk-4SHQA3CO.js +1 -0
  19. package/dist/kit/chunk-4XT5IKM3.js +1 -0
  20. package/dist/kit/{chunk-YBRP6BFW.js → chunk-6L2GAV5C.js} +1 -1
  21. package/dist/kit/{chunk-3A5LID2G.js → chunk-6XNIZ52V.js} +1 -1
  22. package/dist/kit/{chunk-I4QVLLRQ.js → chunk-6YVZZ3DO.js} +1 -1
  23. package/dist/kit/{chunk-FUI5AVIF.js → chunk-A6EDU3UT.js} +1 -1
  24. package/dist/kit/{chunk-J2YZBT3N.js → chunk-A73S2BCE.js} +1 -1
  25. package/dist/kit/{chunk-ENTDGT2V.js → chunk-ANLBW5RI.js} +1 -1
  26. package/dist/kit/{chunk-K563CCOL.js → chunk-B6GZ645M.js} +1 -1
  27. package/dist/kit/{chunk-ZRJVOUWH.js → chunk-BBOSHBZK.js} +1 -1
  28. package/dist/kit/{chunk-5Z2EJAUV.js → chunk-BJRPY7UB.js} +1 -1
  29. package/dist/kit/{chunk-QALCXKU6.js → chunk-CA5J25SV.js} +1 -1
  30. package/dist/kit/{chunk-XANKANGR.js → chunk-CR7QS3B3.js} +1 -1
  31. package/dist/kit/{chunk-ROR6MG3K.js → chunk-D4KCZSIP.js} +1 -1
  32. package/dist/kit/{chunk-YCWMOTYH.js → chunk-EHXSXMBE.js} +1 -1
  33. package/dist/kit/{chunk-TTGMK4EA.js → chunk-EHYFSX5K.js} +1 -1
  34. package/dist/kit/{chunk-PCIAA2LL.js → chunk-EJ3W4FN6.js} +1 -1
  35. package/dist/kit/{chunk-BN7HL52Z.js → chunk-EK4GIXIO.js} +1 -1
  36. package/dist/kit/{chunk-VVW7LZT2.js → chunk-EPVZIGEZ.js} +1 -1
  37. package/dist/kit/chunk-EWPT56TR.js +1 -0
  38. package/dist/kit/{chunk-QRCXXS5Z.js → chunk-FIWIUXNV.js} +1 -1
  39. package/dist/kit/{chunk-5I4IZTL5.js → chunk-G4BQYQJ6.js} +1 -1
  40. package/dist/kit/chunk-GCIZKMJL.js +1 -0
  41. package/dist/kit/{chunk-PFKYKAIP.js → chunk-H4DBJULW.js} +1 -1
  42. package/dist/kit/{chunk-MGVPLQ3Z.js → chunk-HMW5NRUV.js} +1 -1
  43. package/dist/kit/{chunk-IPVN22ZM.js → chunk-IUX46UDR.js} +1 -1
  44. package/dist/kit/{chunk-MQJQIDO5.js → chunk-JAM46FF6.js} +1 -1
  45. package/dist/kit/{chunk-PIU2BMFU.js → chunk-JRSCTMFM.js} +1 -1
  46. package/dist/kit/{chunk-T3GWGPST.js → chunk-KBXVIAWS.js} +1 -1
  47. package/dist/kit/{chunk-7ABNWOW4.js → chunk-KJJJORN6.js} +1 -1
  48. package/dist/kit/chunk-KS3TL3S2.js +1 -0
  49. package/dist/kit/{chunk-BR6ZNJZW.js → chunk-KTYCGGRO.js} +1 -1
  50. package/dist/kit/{chunk-H2UZBVKE.js → chunk-L3P7ZDSK.js} +1 -1
  51. package/dist/kit/{chunk-VC2ZQG63.js → chunk-LUOIH2EM.js} +1 -1
  52. package/dist/kit/{chunk-WJLZM3DR.js → chunk-MIA6TUQC.js} +1 -1
  53. package/dist/kit/{chunk-SARCZMLN.js → chunk-MRDEO5HZ.js} +1 -1
  54. package/dist/kit/{chunk-BQZCLGCY.js → chunk-NPJ77LDC.js} +1 -1
  55. package/dist/kit/{chunk-5QE6UMXN.js → chunk-ODMQERGZ.js} +1 -1
  56. package/dist/kit/{chunk-E3TUOX2A.js → chunk-ONVONNUH.js} +1 -1
  57. package/dist/kit/{chunk-C3C7AYKL.js → chunk-OVCIHOOS.js} +1 -1
  58. package/dist/kit/{chunk-G57QACJG.js → chunk-P6S6HSN3.js} +1 -1
  59. package/dist/kit/{chunk-4OT66HSZ.js → chunk-PCGRRX5P.js} +1 -1
  60. package/dist/kit/{chunk-4ZQFDFEH.js → chunk-PDNKLLBI.js} +1 -1
  61. package/dist/kit/{chunk-IUKSHYED.js → chunk-PFNFW4ZI.js} +1 -1
  62. package/dist/kit/chunk-PFQBEWCF.js +1 -0
  63. package/dist/kit/{chunk-2CF4PX6U.js → chunk-PND73YEV.js} +1 -1
  64. package/dist/kit/{chunk-AIM3J2US.js → chunk-PZAQLUAS.js} +1 -1
  65. package/dist/kit/{chunk-IQTGJRDX.js → chunk-QKZYCROD.js} +1 -1
  66. package/dist/kit/{chunk-W2STAN6V.js → chunk-QTVMD62E.js} +1 -1
  67. package/dist/kit/{chunk-S62H7ZIU.js → chunk-QZHZWO7N.js} +1 -1
  68. package/dist/kit/{chunk-XDKKCIIL.js → chunk-SAQJAH2I.js} +1 -1
  69. package/dist/kit/{chunk-HTUGMGVA.js → chunk-SE6MQQLB.js} +1 -1
  70. package/dist/kit/{chunk-NURPDP3Y.js → chunk-SQGJ263V.js} +1 -1
  71. package/dist/kit/{chunk-XB4DKPGL.js → chunk-SVXRMHUJ.js} +1 -1
  72. package/dist/kit/chunk-UO4U32P7.js +1 -0
  73. package/dist/kit/{chunk-BNVRKD3V.js → chunk-V6GEQ5Y5.js} +1 -1
  74. package/dist/kit/{chunk-KWTF6Q5W.js → chunk-VFV7HZ3G.js} +1 -1
  75. package/dist/kit/{chunk-DZ5XGHTJ.js → chunk-WT3XOWAI.js} +1 -1
  76. package/dist/kit/{chunk-2NVKPXPL.js → chunk-XDNCXCR7.js} +1 -1
  77. package/dist/kit/chunk-XVB3B3FV.js +1 -0
  78. package/dist/kit/{chunk-O7SGY4YJ.js → chunk-XXPDXJMQ.js} +1 -1
  79. package/dist/kit/{chunk-5BEBNKYM.js → chunk-XYLLL2PQ.js} +1 -1
  80. package/dist/kit/{chunk-MIZ2DUHU.js → chunk-YBBYCUFP.js} +1 -1
  81. package/dist/kit/{chunk-DFOWXOZR.js → chunk-YDP6566E.js} +1 -1
  82. package/dist/kit/chunk-YL2AXWRA.js +1 -0
  83. package/dist/kit/{chunk-4QHFEMFS.js → chunk-ZYYLWSPY.js} +1 -1
  84. package/dist/kit.cjs +1 -1
  85. package/dist/kit.d.cts +3 -1
  86. package/dist/kit.d.ts +3 -1
  87. package/dist/kit.js +1 -1
  88. package/package.json +2 -1
  89. package/skills/asciify-engine/SKILL.md +2 -2
  90. package/skills/asciify-engine/references/applying-asciify.md +1 -1
  91. package/skills/asciify-engine/references/kit.md +2 -2
  92. package/skills/asciify-engine/references/performance.md +5 -2
  93. package/dist/kit/chunk-3PCKMO6I.js +0 -1
  94. package/dist/kit/chunk-4HWMQCAM.js +0 -1
  95. package/dist/kit/chunk-73M2OESE.js +0 -1
  96. package/dist/kit/chunk-BTD6EFAW.js +0 -1
  97. package/dist/kit/chunk-OWEZV7TQ.js +0 -1
  98. package/dist/kit/chunk-S7RZP2MT.js +0 -1
  99. package/dist/kit/chunk-SNCXU7KF.js +0 -1
  100. package/dist/kit/chunk-UML6XQAR.js +0 -1
  101. package/dist/kit/chunk-UO7RB7RC.js +0 -1
  102. package/dist/kit/chunk-XM56OTYT.js +0 -1
package/dist/field.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e={none:3,flow:1,orb:2,drift:4,swell:5,caustics:6,contour:7,aurora:8,ripple:9,halo:10,interference:11,mesh:12,cascade:13,constellation:14},t=e=>e?"\nconst float VSCALE=6.;\nvec4 decodeFluid(vec4 t){return vec4((t.xy*2.-1.)*VSCALE,t.z,t.w);}\nvec4 encodeFluid(vec4 v){return vec4(clamp(v.xy/VSCALE*.5+.5,0.,1.),clamp(v.z,0.,1.),1.);}":"\nvec4 decodeFluid(vec4 t){return t;}\nvec4 encodeFluid(vec4 v){return vec4(v.xyz,1.);}",n="#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform vec2 uTexel;\nout vec4 outColor;\nvec2 here(){return gl_FragCoord.xy*uTexel;}\n",r=n+"\nuniform sampler2D uVelocity;\nuniform vec2 uFrom, uTo, uForce;\nuniform float uAspect, uRadius;\nfloat segment(vec2 p,vec2 a,vec2 b){vec2 pa=p-a,ba=b-a;float h=clamp(dot(pa,ba)/max(dot(ba,ba),1e-8),0.,1.);return length(pa-ba*h);}\nvoid main(){\n vec2 uv=here(),scale=vec2(uAspect,1.);\n float d=segment(uv*scale,uFrom*scale,uTo*scale);\n outColor=vec4(texture(uVelocity,uv).xy+uForce*exp(-d*d/(uRadius*uRadius)),0.,1.);\n}",o=n+"\nuniform sampler2D uVelocity;\nvoid main(){\n vec2 uv=here();\n float l=texture(uVelocity,uv-vec2(uTexel.x,0.)).y,r=texture(uVelocity,uv+vec2(uTexel.x,0.)).y;\n float t=texture(uVelocity,uv+vec2(0.,uTexel.y)).x,b=texture(uVelocity,uv-vec2(0.,uTexel.y)).x;\n outColor=vec4(.5*(r-l-t+b),0.,0.,1.);\n}",i=n+"\nuniform sampler2D uVelocity, uCurl;\nuniform float uStrength, uDt;\nvoid main(){\n vec2 uv=here();\n float l=texture(uCurl,uv-vec2(uTexel.x,0.)).x,r=texture(uCurl,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uCurl,uv+vec2(0.,uTexel.y)).x,b=texture(uCurl,uv-vec2(0.,uTexel.y)).x,c=texture(uCurl,uv).x;\n vec2 force=.5*vec2(abs(t)-abs(b),abs(r)-abs(l));\n force=force/(length(force)+1e-4)*uStrength*c;\n force.y=-force.y;\n outColor=vec4(clamp(texture(uVelocity,uv).xy+force*uDt,-1000.,1000.),0.,1.);\n}",a=n+"\nuniform sampler2D uVelocity;\nvoid main(){\n vec2 uv=here(),c=texture(uVelocity,uv).xy;\n float l=texture(uVelocity,uv-vec2(uTexel.x,0.)).x,r=texture(uVelocity,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uVelocity,uv+vec2(0.,uTexel.y)).y,b=texture(uVelocity,uv-vec2(0.,uTexel.y)).y;\n if(uv.x-uTexel.x<0.)l=-c.x;\n if(uv.x+uTexel.x>1.)r=-c.x;\n if(uv.y+uTexel.y>1.)t=-c.y;\n if(uv.y-uTexel.y<0.)b=-c.y;\n outColor=vec4(.5*(r-l+t-b),0.,0.,1.);\n}",l=n+"\nuniform sampler2D uSource;\nuniform float uAmount;\nvoid main(){outColor=vec4(texture(uSource,here()).x*uAmount,0.,0.,1.);}",s=n+"\nuniform sampler2D uPressure, uDivergence;\nvoid main(){\n vec2 uv=here();\n float l=texture(uPressure,uv-vec2(uTexel.x,0.)).x,r=texture(uPressure,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uPressure,uv+vec2(0.,uTexel.y)).x,b=texture(uPressure,uv-vec2(0.,uTexel.y)).x;\n outColor=vec4((l+r+b+t-texture(uDivergence,uv).x)*.25,0.,0.,1.);\n}",u=n+"\nuniform sampler2D uPressure, uVelocity;\nvoid main(){\n vec2 uv=here();\n float l=texture(uPressure,uv-vec2(uTexel.x,0.)).x,r=texture(uPressure,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uPressure,uv+vec2(0.,uTexel.y)).x,b=texture(uPressure,uv-vec2(0.,uTexel.y)).x;\n outColor=vec4(texture(uVelocity,uv).xy-vec2(r-l,t-b),0.,1.);\n}",c=n+"\nuniform sampler2D uVelocity;\nuniform float uDt, uDissipation;\nvoid main(){\n vec2 uv=here();\n vec2 back=uv-uDt*texture(uVelocity,uv).xy*uTexel;\n outColor=vec4(texture(uVelocity,back).xy/(1.+uDissipation*uDt),0.,1.);\n}";var h=class{constructor(e,t){this.previous=null,this.peak=0,this.width=e,this.height=t;const n=e*t;this.pixels=new Uint8Array(4*n),this.signal=new Float32Array(n),this.offsetX=new Float32Array(n),this.offsetY=new Float32Array(n),this.driftX=new Float32Array(n),this.driftY=new Float32Array(n),this.u=new Float32Array(n),this.v=new Float32Array(n),this.ink=new Float32Array(n),this.a=new Float32Array(n),this.b=new Float32Array(n),this.c=new Float32Array(n),this.pressure=new Float32Array(n),this.pressureNext=new Float32Array(n),this.divergence=new Float32Array(n),this.curl=new Float32Array(n)}get active(){return this.peak>2e-4}clear(){for(const e of[this.u,this.v,this.ink,this.a,this.b,this.c,this.pressure,this.pressureNext,this.divergence,this.curl,this.signal,this.pixels,this.offsetX,this.offsetY,this.driftX,this.driftY])e.fill(0);this.previous=null,this.peak=0}leave(){this.previous=null}move(e,t,n,r=performance.now()){if(!Number.isFinite(e+t+n+r))return;e=Math.max(0,Math.min(1,e)),t=Math.max(0,Math.min(1,t)),n=Math.max(.1,Math.min(1,n));const o=this.previous;if(this.previous={x:e,y:t,time:r},!o)return;const i=(e-o.x)*(this.width-1),a=(t-o.y)*(this.height-1),l=Math.hypot(i,a);if(l<.001)return;const s=Math.min(this.width,this.height),u=r>o.time?Math.max(1/240,(r-o.time)/1e3):1/60,c=Math.min(12,l/s/u),h=1-Math.exp(-c/2.2),f=s*(.022+.075*n)*(.65+.95*h),d=Math.min(128,Math.max(1,Math.ceil(l/(.4*f)))),m=l/f*(.32+.22*h)/d,p=i/l,v=a/l,g=-v,x=p,y=l*(2+18*h)/d;for(let n=0;n<d;n++){const r=(n+.5)/d,i=(o.x+(e-o.x)*r)*(this.width-1),a=(o.y+(t-o.y)*r)*(this.height-1),l=Math.max(1,Math.floor(i-3*f)),s=Math.min(this.width-2,Math.ceil(i+3*f)),u=Math.max(1,Math.floor(a-3*f)),c=Math.min(this.height-2,Math.ceil(a+3*f));for(let e=u;e<=c;e++)for(let t=l;t<=s;t++){const n=((t-i)*p+(e-a)*v)/f,r=((t-i)*g+(e-a)*x)/f,o=Math.exp(-n*n*.65-r*r*1.7),l=e*this.width+t;this.ink[l]=1-(1-this.ink[l])*Math.exp(-o*m);const s=1-r*r*.55,u=n*r*.7;this.u[l]=Math.max(-80,Math.min(80,this.u[l]+(p*s+g*u)*o*y)),this.v[l]=Math.max(-80,Math.min(80,this.v[l]+(v*s+x*u)*o*y))}}this.peak=1}read(e,t,n){const r=0|(t=Math.max(.5,Math.min(this.width-1.5,t))),o=0|(n=Math.max(.5,Math.min(this.height-1.5,n))),i=t-r,a=n-o,l=o*this.width+r;return(e[l]*(1-i)+e[l+1]*i)*(1-a)+(e[l+this.width]*(1-i)+e[l+this.width+1]*i)*a}sample(e,t){return this.read(this.signal,e*(this.width-1),t*(this.height-1))}displacement(e,t,n){n[0]=this.read(this.offsetX,e*(this.width-1),t*(this.height-1)),n[1]=this.read(this.offsetY,e*(this.width-1),t*(this.height-1))}step(e){if(!this.active||!Number.isFinite(e))return;let t=Math.max(0,Math.min(.05,e));const n=this.width,r=this.height;for(;t>1e-7;){const e=Math.min(1/60,t);t-=e;const o=Math.exp(-1.9*e),i=Math.exp(-3.2*e);for(let t=1;t<r-1;t++)for(let a=1;a<n-1;a++){const l=t*n+a,s=Math.max(.5,Math.min(n-1.5,a-this.u[l]*e)),u=Math.max(.5,Math.min(r-1.5,t-this.v[l]*e)),c=0|s,h=0|u,f=s-c,d=u-h,m=h*n+c,p=(1-f)*(1-d),v=f*(1-d),g=(1-f)*d,x=f*d;this.a[l]=(this.u[m]*p+this.u[m+1]*v+this.u[m+n]*g+this.u[m+n+1]*x)*o,this.b[l]=(this.v[m]*p+this.v[m+1]*v+this.v[m+n]*g+this.v[m+n+1]*x)*o,this.c[l]=(this.ink[m]*p+this.ink[m+1]*v+this.ink[m+n]*g+this.ink[m+n+1]*x)*i}[this.u,this.a]=[this.a,this.u],[this.v,this.b]=[this.b,this.v],[this.ink,this.c]=[this.c,this.ink];for(let e=1;e<r-1;e++)for(let t=1;t<n-1;t++){const r=e*n+t;this.curl[r]=.5*(this.v[r+1]-this.v[r-1]-this.u[r+n]+this.u[r-n])}for(let t=1;t<r-1;t++)for(let r=1;r<n-1;r++){const o=t*n+r,i=Math.abs(this.curl[o+1])-Math.abs(this.curl[o-1]),a=Math.abs(this.curl[o+n])-Math.abs(this.curl[o-n]),l=Math.hypot(i,a)+1e-4,s=this.curl[o]*e*10,u=Math.hypot(this.u[o],this.v[o]);this.u[o]+=a/l*s,this.v[o]-=i/l*s;const c=Math.min(1,u/(Math.hypot(this.u[o],this.v[o])+1e-6));this.u[o]*=c,this.v[o]*=c,this.divergence[o]=-.5*(this.u[o+1]-this.u[o-1]+this.v[o+n]-this.v[o-n])}this.pressure.fill(0);for(let e=0;e<4;e++){for(let e=1;e<r-1;e++)for(let t=1;t<n-1;t++){const r=e*n+t;this.pressureNext[r]=.25*(this.divergence[r]+this.pressure[r-1]+this.pressure[r+1]+this.pressure[r-n]+this.pressure[r+n])}[this.pressure,this.pressureNext]=[this.pressureNext,this.pressure]}let a=0;for(let t=1;t<r-1;t++)for(let r=1;r<n-1;r++){const o=t*n+r;this.u[o]=Math.max(-80,Math.min(80,this.u[o]-.5*(this.pressure[o+1]-this.pressure[o-1]))),this.v[o]=Math.max(-80,Math.min(80,this.v[o]-.5*(this.pressure[o+n]-this.pressure[o-n]))),this.driftX[o]+=(3.6*this.u[o]-58*this.offsetX[o]-12*this.driftX[o])*e,this.driftY[o]+=(3.6*this.v[o]-58*this.offsetY[o]-12*this.driftY[o])*e,this.offsetX[o]=Math.max(-2,Math.min(2,this.offsetX[o]+this.driftX[o]*e)),this.offsetY[o]=Math.max(-2,Math.min(2,this.offsetY[o]+this.driftY[o]*e)),this.signal[o]=1-Math.exp(.06*-Math.hypot(this.u[o],this.v[o])-.16*this.ink[o]),a=Math.max(a,this.signal[o])}this.peak=a}if(this.active)for(let e=0;e<this.ink.length;e++){const t=Math.round(65535*Math.min(1,this.signal[e]));this.pixels[4*e]=t>>>8,this.pixels[4*e+1]=255&t,this.pixels[4*e+2]=Math.round(128+63.5*this.offsetX[e]),this.pixels[4*e+3]=Math.round(128+63.5*this.offsetY[e])}else this.clear()}};function f(e,t,n,r,o){if(!(o<1))for(let i=0;i<2;i++){for(let i=0;i<r;i++){let r=0;const a=i*n;for(let t=-o;t<=o;t++)r+=e[a+Math.max(0,Math.min(n-1,t))];for(let i=0;i<n;i++)t[a+i]=r/(2*o+1),r+=e[a+Math.min(n-1,i+o+1)]-e[a+Math.max(0,i-o)]}for(let i=0;i<n;i++){let a=0;for(let e=-o;e<=o;e++)a+=t[Math.max(0,Math.min(r-1,e))*n+i];for(let l=0;l<r;l++)e[l*n+i]=a/(2*o+1),a+=t[Math.min(r-1,l+o+1)*n+i]-t[Math.max(0,l-o)*n+i]}}}var d=new Float32Array(0);var m,p=["none","flow","orb","drift","swell","caustics","contour","aurora","ripple","halo","interference","mesh","cascade","constellation"],v=["glyph","dot","pixel","mosaic","lego","voxel","disco","dither","hex","led","cmyk","stipple","engraving","crosshatch","woodblock","risograph","pointillism"],g=[{value:"fluid",label:"Fluid",description:"An ink-in-water wake that bends the image and swirls the characters."},{value:"lantern",label:"Lantern",description:"A soft light follows the pointer and lifts the characters it passes, without distortion."},{value:"trail",label:"Trail",description:"The Asciify Trail: in the wake, sparse characters fill in and dense ones open up, then settle. No distortion."},{value:"loupe",label:"Loupe",description:"A glass loupe glides after the pointer and magnifies the characters it covers."},{value:"reveal",label:"Reveal",description:"Under a soft spotlight the characters take the source image's own colours. Best over a photo or video in one ink."},{value:"none",label:"Off",description:"The field stays still under the pointer."}],x={radius:.13,strength:.5,trail:.45,follow:12},y={strength:.55,radius:.45},b={radius:.075,force:1,dissipation:1.6,refraction:.03,glow:.55,resolution:128,curl:24},E={charset:" .,:-=+*#%@",cellSize:12,cellAspect:1,cellFit:"pixel",font:'ui-monospace, "SF Mono", Menlo, Consolas, monospace',fontWeight:500,glyphScale:.8,mark:"glyph",dotScale:.9,color:"ink",ink:"#f3ba32",highlight:"auto",background:"transparent",brightness:0,contrast:1,gamma:1,invert:!1,levels:"auto",blend:"auto",saturation:1.1,shade:.5,backdrop:0,fit:"cover",focus:{x:.5,y:.5},vignette:0,drift:0,scene:"flow",scale:1,clear:!1,speed:1,hover:"fluid",fluid:b,lantern:x,trail:y,scope:"all",maxPixelRatio:2,respectReducedMotion:!0},w=(e,t,n,r)=>"number"==typeof e&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):r,T=(e,t)=>"string"==typeof e&&/^#([\da-f]{3}|[\da-f]{6})$/i.test(e.trim())?e.trim().toLowerCase():t,M=/^[\u0020-\u007e\u00a0-\u02ff\u0370-\u0482\u048a-\u052f\u2010-\u20cf\u2100-\u2bff]*$/;function R(e){if(!M.test(e)&&void 0===m){const e=Intl.Segmenter;m=e?new e(void 0,{granularity:"grapheme"}):null}return(m&&!M.test(e)?Array.from(m.segment(e),e=>e.segment):Array.from(e)).filter(e=>"\n"!==e&&"\r"!==e&&"\t"!==e).slice(0,256)}function F(e={},t=E){const n="string"==typeof e.charset&&R(e.charset).length>=2?e.charset:t.charset,r=t.fluid||b,o=void 0===e.fluid?t.fluid:e.fluid,i=!1!==o&&(()=>{const e=!0!==o&&o?{...r,...o}:r;return{radius:w(e.radius,.005,.5,b.radius),force:w(e.force,0,8,b.force),dissipation:w(e.dissipation,.05,20,b.dissipation),refraction:w(e.refraction,0,.5,b.refraction),glow:w(e.glow,0,2,b.glow),resolution:Math.round(w(e.resolution,16,512,b.resolution)),curl:w(e.curl,0,80,b.curl)}})(),a=p.includes(e.scene)?e.scene:t.scene,l=!!e.clear&&"object"==typeof e.clear&&("element"in e.clear||"nodeType"in e.clear),s=void 0===e.clear||l?t.clear:e.clear,u=!!s&&{x:w(s.x,-.5,1.5,.25),y:w(s.y,-.5,1.5,.3),width:w(s.width,0,2,.5),height:w(s.height,0,2,.4),feather:w(s.feather,.005,1,.12),shape:"rect"===s.shape?"rect":"ellipse"};return{charset:n,cellSize:w(e.cellSize,3,96,t.cellSize),cellAspect:w(e.cellAspect,.3,2,t.cellAspect),cellFit:"fill"===e.cellFit||"pixel"===e.cellFit?e.cellFit:t.cellFit,font:"string"==typeof e.font&&e.font.trim()?e.font:t.font,fontWeight:Math.round(w(e.fontWeight,100,900,t.fontWeight)),glyphScale:w(e.glyphScale,.3,1.6,t.glyphScale),mark:v.includes(e.mark)?e.mark:t.mark,dotScale:w(e.dotScale,.1,1.4,t.dotScale),color:"source"===e.color||"ink"===e.color?e.color:t.color,ink:T(e.ink,t.ink),highlight:"auto"===e.highlight?"auto":T(e.highlight,t.highlight),background:"transparent"===e.background?"transparent":T(e.background,t.background),brightness:w(e.brightness,-1,1,t.brightness),contrast:w(e.contrast,0,4,t.contrast),gamma:w(e.gamma,.2,5,t.gamma),invert:"boolean"==typeof e.invert?e.invert:t.invert,levels:"none"===e.levels||"auto"===e.levels?e.levels:t.levels,blend:"auto"===e.blend||"coarse"===e.blend||"on"===e.blend||"off"===e.blend?e.blend:t.blend,saturation:w(e.saturation,0,3,t.saturation),shade:w(e.shade,0,1,t.shade),backdrop:w(e.backdrop,0,1,t.backdrop),fit:"contain"===e.fit||"cover"===e.fit?e.fit:t.fit,focus:{x:w(e.focus?.x,0,1,t.focus.x),y:w(e.focus?.y,0,1,t.focus.y)},vignette:w(e.vignette,0,1,t.vignette),drift:w(e.drift,0,2,t.drift),scene:a,scale:w(e.scale,.2,6,t.scale),clear:u,speed:w(e.speed,0,5,t.speed),hover:g.some(t=>t.value===e.hover)?e.hover:t.hover,fluid:i,lantern:{radius:w(e.lantern?.radius,.02,.6,t.lantern.radius),strength:w(e.lantern?.strength,0,1.5,t.lantern.strength),trail:w(e.lantern?.trail,0,3,t.lantern.trail),follow:w(e.lantern?.follow,1,60,t.lantern.follow)},trail:{strength:w(e.trail?.strength,0,1,t.trail.strength),radius:w(e.trail?.radius,.1,1,t.trail.radius)},scope:void 0===e.scope?t.scope:(c=e.scope,"subject"===c||"outside"===c?c:"all"),maxPixelRatio:w(e.maxPixelRatio,.5,4,t.maxPixelRatio),respectReducedMotion:"boolean"==typeof e.respectReducedMotion?e.respectReducedMotion:t.respectReducedMotion};var c}function A(e,t,n,r,o,i={x:.5,y:.5}){if(!(e>0&&t>0&&n>0&&r>0))return{scale:[1,1],offset:[0,0]};const a=e/t,l=n/r,s=l>a,u="cover"===o?s?[a/l,1]:[1,l/a]:s?[1,l/a]:[a/l,1];return{scale:u,offset:"cover"===o?[(1-u[0])*i.x,(1-u[1])*i.y]:[.5*(1-u[0]),.5*(1-u[1])]}}function k(e,t,n,r){const o=Math.max(2,Math.round(e*n)),i=Math.max(2,Math.round(o*t)),a=Math.min(16,Math.max(1,r)),l=Math.ceil(r/a);return{width:i,height:o,columns:a,rows:l,atlasWidth:a*i,atlasHeight:l*o}}function L(e){const t=e.replace("#",""),n=3===t.length?t.split("").map(e=>e+e).join(""):t,r=Number.parseInt(n,16);return Number.isFinite(r)&&6===n.length?[(r>>16&255)/255,(r>>8&255)/255,(255&r)/255]:[0,0,0]}function S(e){const t=new Uint32Array(256);let n=0;for(let r=0;r+3<e.length;r+=4)e[r+3]<8||(t[Math.round(.2126*e[r]+.7152*e[r+1]+.0722*e[r+2])]++,n++);if(!n)return[0,1];const r=e=>{let r=0;for(let o=0;o<256;o++)if(r+=t[o],r>=n*e)return o/255;return 1},o=r(.02),i=r(.98);return i-o<.08?[0,1]:[o,i]}var D=e=>"fluid"!==e.hover||e.fluid?e.hover:"none";function _(e,t,n=24,r=.12,o="ellipse"){return e.width>0&&e.height>0&&{x:(t.left-n-e.left)/e.width,y:(t.top-n-e.top)/e.height,width:(t.width+2*n)/e.width,height:(t.height+2*n)/e.height,feather:r,shape:o}}var C,P=/\.(mp4|webm|mov|m4v|ogv)(\?|#|$)/i,U=/swiftshader|llvmpipe|softpipe|software|basic render/i;function I(){if(C)return C;if("undefined"==typeof document||void 0===globalThis.WebGL2RenderingContext)return C="none";try{const e=document.createElement("canvas").getContext("webgl2");if(!e)return C="none";const t=e.getExtension("WEBGL_debug_renderer_info"),n=String(e.getParameter(t?t.UNMASKED_RENDERER_WEBGL:e.RENDERER)??"");return e.getExtension("WEBGL_lose_context")?.loseContext(),C=U.test(n)?"software":"gpu"}catch{return C="none"}}exports.DEFAULT_FIELD_FLUID=b,exports.DEFAULT_FIELD_LANTERN=x,exports.DEFAULT_FIELD_SETTINGS=E,exports.DEFAULT_FIELD_TRAIL=y,exports.FIELD_HOVERS=g,exports.FIELD_MARKS=v,exports.FIELD_SCENES=p,exports.activeFieldHover=D,exports.fieldCellLayout=k,exports.fieldClearFromRects=_,exports.fieldGlyphs=R,exports.fieldLevels=S,exports.fieldSourceRect=A,exports.glyphFieldTier=I,exports.isGlyphFieldSupported=function(e={}){const t=I();return"gpu"===t||"software"===t&&!!e.allowSoftware},exports.mountGlyphField=function(n,m={}){const p=e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement,g=e=>{const t=e.clear;return p(t)?{element:{element:t},rest:{...e,clear:void 0}}:t&&"object"==typeof t&&p(t.element)?{element:t,rest:{...e,clear:void 0}}:{element:null,rest:e}};let x=g(m).element,y=F(g(m).rest);const b=m.onError,E=n.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,powerPreference:"high-performance"});if(!E)throw new Error("WebGL2 is not available for the glyph field.");const w=E;n.setAttribute("role","img"),n.setAttribute("aria-label",m.label??"ASCII artwork"),n.dataset.renderer="glyph-field";let T=!1;const M=w.getExtension("KHR_parallel_shader_compile");let C,U,I=null,B=null,G=null,N=null,H=[],X=[],q=null,V=!1,z=null,O=null;const j=[];let W=0,Y=0,K=1,$=0,J=k(y.cellSize,y.cellAspect,1,2),Q=2,Z=0,ee=0,te=0,ne=null,re=!1,oe=null,ie=0,ae=0,le=0,se=null,ue=0,ce=!0,he=0,fe=[0,1],de=-1/0,me=-1/0,pe=!1;const ve=(()=>{const e="undefined"==typeof navigator?void 0:navigator;return 1e3/(e&&(e.hardwareConcurrency>0&&e.hardwareConcurrency<=2||e.deviceMemory&&e.deviceMemory<=2||e.connection?.saveData)?30:60)-2})();let ge=0,xe=0,ye=0,be=!0,Ee=!1,we=!1,Te=!1,Me=!1,Re=!0,Fe=null,Ae=null,ke=1/60,Le=0,Se=0,De=[];const _e=new Float32Array(16),Ce=()=>{if(!x)return;const{element:e,padding:t=32,feather:r=.16,shape:o="rect"}=x,i=_(n.getBoundingClientRect(),e.getBoundingClientRect(),t,r,o),a=y.clear;JSON.stringify(a)!==JSON.stringify(i)&&(y={...y,clear:i},be=!0)},Pe=e=>"lantern"===e||"loupe"===e||"reveal"===e,Ue={target:null,at:null,strength:0,trail:[]},Ie=new Float32Array(36);let Be=null,Ge=null,Ne=!1;const He=()=>{if(!W||!Y)return null;const e=W/Y,t=Math.round(e>=1?128:128*e),n=Math.round(e>=1?128/e:128);return Be&&Be.width===t&&Be.height===n||(Be=new h(t,n),Ge||(Ge=Qe(w.LINEAR)),w.bindTexture(w.TEXTURE_2D,Ge),w.texImage2D(w.TEXTURE_2D,0,w.RGBA8,t,n,0,w.RGBA,w.UNSIGNED_BYTE,Be.pixels),Ne=!0),Be};let Xe=0;const qe="function"==typeof matchMedia?matchMedia("(prefers-reduced-motion: reduce)"):null,Ve=()=>y.respectReducedMotion&&!!qe?.matches;let ze;const Oe=new Promise(e=>{ze=e});let je=!0;const We=e=>b?.(e instanceof Error?e:new Error(String(e))),Ye=(e,t)=>{const n=w.createShader(e);return j.push(n),w.shaderSource(n,t),w.compileShader(n),n},Ke=e=>{O??(O=Ye(w.VERTEX_SHADER,"#version 300 es\nvoid main(){vec2 p=vec2((gl_VertexID<<1)&2,gl_VertexID&2);gl_Position=vec4(p*2.-1.,0.,1.);}"));const t=w.createProgram(),n=Ye(w.FRAGMENT_SHADER,e);return w.attachShader(t,O),w.attachShader(t,n),w.linkProgram(t),{program:t,locations:null,fragment:n}},$e=(e,t=!1)=>{if(e.locations)return!0;const{program:n,fragment:r}=e;if(!t&&M&&!w.getProgramParameter(n,M.COMPLETION_STATUS_KHR))return!1;if(!w.getProgramParameter(n,w.LINK_STATUS)){if(w.isContextLost())return!1;throw new Error(w.getShaderInfoLog(r)||w.getProgramInfoLog(n)||"Glyph field program failed to link.")}const o={};for(let e=w.getProgramParameter(n,w.ACTIVE_UNIFORMS)-1;e>=0;e--){const t=w.getActiveUniform(n,e).name.replace(/\[0\]$/,"");o[t]=w.getUniformLocation(n,t)}return e.locations=o,!0},Je=(e=!1)=>!!I&&!!B&&$e(I,e)&&$e(B,e),Qe=e=>{const t=w.createTexture();return w.bindTexture(w.TEXTURE_2D,t),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MIN_FILTER,e),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MAG_FILTER,e===w.LINEAR_MIPMAP_LINEAR?w.LINEAR:e),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_S,w.CLAMP_TO_EDGE),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_T,w.CLAMP_TO_EDGE),t},Ze=()=>{N&&(w.deleteTexture(N.ink),w.deleteTexture(N.under),w.deleteFramebuffer(N.buffer),N=null)},et=()=>function(e,t,n,r,o,i,a){if("fill"!==e||!(o>0&&i>0))return[a.width,a.height];const l=t*r,s=l*n;return[o/Math.max(1,Math.floor(o/s+1e-6)),i/Math.max(1,Math.floor(i/l+1e-6))]}(y.cellFit,y.cellSize,y.cellAspect,K,W,Y,J),tt=()=>!!y.fluid&&"fluid"===D(y),nt=()=>{q?.release(),V=!1,H.forEach(e=>w.deleteTexture(e)),X.forEach(e=>w.deleteFramebuffer(e)),H=[],X=[]};function rt(){G&&w.deleteProgram(G.program),G=Ke((e=>`#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform sampler2D uPrevious;\nuniform vec2 uSize;\nuniform float uAspect, uDt, uDecay, uEnergyDecay, uRadius, uSplat;\nuniform vec2 uFrom, uTo, uForce;\nout vec4 outColor;\n${t(e)}\nfloat segment(vec2 p,vec2 a,vec2 b){vec2 pa=p-a,ba=b-a;float h=clamp(dot(pa,ba)/max(dot(ba,ba),1e-8),0.,1.);return length(pa-ba*h);}\nvoid main(){\n vec2 uv=gl_FragCoord.xy/uSize;\n vec4 here=decodeFluid(texture(uPrevious,uv));\n vec4 state=decodeFluid(texture(uPrevious,uv-uDt*here.xy*vec2(1./uAspect,1.)));\n state.xy*=exp(-uDt*uDecay);\n state.z*=exp(-uDt*uEnergyDecay);\n if(uSplat>.5){\n vec2 scale=vec2(uAspect,1.);\n float d=segment(uv*scale,uFrom*scale,uTo*scale);\n float g=exp(-d*d/(uRadius*uRadius));\n state.xy+=uForce*g;\n state.z=min(1.,state.z+g*min(1.,length(uForce)*.5+.08));\n }\n float speed=length(state.xy);\n if(speed>5.)state.xy*=5./speed;\n outColor=encodeFluid(state);\n}`)(T)),q?.dispose(),q=T?null:function(e,t,n){const h={splat:t(r),curl:t(o),vorticity:t(i),divergence:t(a),fade:t(l),pressure:t(s),gradient:t(u),advect:t(c)},f=Object.values(h);let d=0,m=0,p=[],v=[],g=null,x=null;const y=t=>{const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA16F,d,m,0,e.RGBA,e.HALF_FLOAT,null);const r=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE?(e.deleteFramebuffer(r),e.deleteTexture(n),null):(e.viewport(0,0,d,m),e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),{texture:n,buffer:r})},b=t=>{t&&(e.deleteTexture(t.texture),e.deleteFramebuffer(t.buffer))},E=()=>{[...p,...v,g,x].forEach(b),p=[],v=[],g=x=null},w=(t,n)=>{const r=t.locations;return e.useProgram(t.program),e.bindFramebuffer(e.FRAMEBUFFER,n.buffer),e.uniform2f(r.uTexel,1/d,1/m),r},T=(t,n,r,o)=>{e.activeTexture(e.TEXTURE0+r),e.bindTexture(e.TEXTURE_2D,o),e.uniform1i(t[n],r)},M=()=>e.drawArrays(e.TRIANGLES,0,3),R=e=>{const t=e[0];e[0]=e[1],e[1]=t};return{resize(t,n){E(),d=t,m=n;const r=[y(e.LINEAR),y(e.LINEAR),y(e.NEAREST),y(e.NEAREST),y(e.NEAREST),y(e.NEAREST)];return e.bindFramebuffer(e.FRAMEBUFFER,null),r.some(e=>!e)?(r.forEach(b),!1):(p=[r[0],r[1]],v=[r[2],r[3]],g=r[4],x=r[5],!0)},ready:()=>f.every(n),step(t,n){if(!p.length||!g||!x)return;let r;e.viewport(0,0,d,m),t&&(r=w(h.splat,p[1]),T(r,"uVelocity",0,p[0].texture),e.uniform2f(r.uFrom,t.from[0],t.from[1]),e.uniform2f(r.uTo,t.to[0],t.to[1]),e.uniform2f(r.uForce,t.force[0],t.force[1]),e.uniform1f(r.uAspect,n.aspect),e.uniform1f(r.uRadius,n.radius),M(),R(p)),n.curl>0&&(r=w(h.curl,x),T(r,"uVelocity",0,p[0].texture),M(),r=w(h.vorticity,p[1]),T(r,"uVelocity",0,p[0].texture),T(r,"uCurl",1,x.texture),e.uniform1f(r.uStrength,n.curl),e.uniform1f(r.uDt,n.dt),M(),R(p)),r=w(h.divergence,g),T(r,"uVelocity",0,p[0].texture),M(),r=w(h.fade,v[1]),T(r,"uSource",0,v[0].texture),e.uniform1f(r.uAmount,.8),M(),R(v);for(let e=0;e<20;e++)r=w(h.pressure,v[1]),T(r,"uPressure",0,v[0].texture),T(r,"uDivergence",1,g.texture),M(),R(v);r=w(h.gradient,p[1]),T(r,"uPressure",0,v[0].texture),T(r,"uVelocity",1,p[0].texture),M(),R(p),r=w(h.advect,p[1]),T(r,"uVelocity",0,p[0].texture),e.uniform1f(r.uDt,n.dt),e.uniform1f(r.uDissipation,n.dissipation),M(),R(p),e.bindFramebuffer(e.FRAMEBUFFER,null)},get velocity(){return p[0]?.texture??null},get size(){return[d,m]},release:E,dispose(){E(),f.forEach(({program:t})=>e.deleteProgram(t))}}}(w,Ke,e=>$e(e))}const ot=()=>{nt();const e=y.fluid;if(!(e&&tt()&&W&&Y))return;G||rt();const t=e.resolution,n=W/Y;if(Z=n>=1?t:Math.max(8,Math.round(t*n)),ee=n>=1?Math.max(8,Math.round(t/n)):t,V=!!q&&q.resize(Z,ee),V)return void(te=0);const r=()=>{nt();for(let e=0;e<2;e++){const e=Qe(w.LINEAR);w.texImage2D(w.TEXTURE_2D,0,T?w.RGBA8:w.RGBA16F,Z,ee,0,w.RGBA,T?w.UNSIGNED_BYTE:w.HALF_FLOAT,null);const t=w.createFramebuffer();w.bindFramebuffer(w.FRAMEBUFFER,t),w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_2D,e,0),H.push(e),X.push(t)}return w.checkFramebufferStatus(w.FRAMEBUFFER)===w.FRAMEBUFFER_COMPLETE};if(!r()){if(T)throw new Error("The glyph field could not allocate its fluid buffers.");T=!0,it(),rt(),r()}for(const e of X)w.bindFramebuffer(w.FRAMEBUFFER,e),w.viewport(0,0,Z,ee),w.clearColor(T?.5:0,T?.5:0,0,1),w.clear(w.COLOR_BUFFER_BIT);w.bindFramebuffer(w.FRAMEBUFFER,null),te=0};function it(){I&&w.deleteProgram(I.program),B&&w.deleteProgram(B.program),Ze(),I=Ke((e=>`#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform sampler2D uSource, uFluid;\nuniform vec2 uResolution, uCell;\nuniform float uCount, uBlend;\nconst float BAYER[16]=float[16](0.,8.,2.,10.,12.,4.,14.,6.,3.,11.,1.,9.,15.,7.,13.,5.);\nuniform vec4 uSourceMap;\nuniform int uScene;\nuniform vec3 uInk, uHighlight;\nuniform vec4 uBackground;\nuniform float uBrightness, uContrast, uGamma, uInvert, uVignette, uSourceColor;\nuniform float uRefraction, uGlow, uTime, uDrift, uFluidOn, uLod, uSaturation, uBackdrop, uShade, uHighlightAuto, uFluidMode;\nuniform vec2 uFluidTexel;\nuniform int uHoverMode;\nuniform vec3 uLight;\nuniform vec3 uTrail[12];\nuniform float uLightRadius, uLightGain, uClock, uFlicker, uTrailAmount;\nuniform sampler2D uTrailMap, uScope;\nuniform float uScopeMode;\nuniform vec2 uLevels;\nuniform int uMark;\nuniform float uScale, uClearFeather, uClearShape;\nuniform vec4 uClear;\nuniform vec4 uPulse[4];\nlayout(location=0) out vec4 outInk;\nlayout(location=1) out vec4 outUnder;\n${t(e)}\nfloat hash(vec2 p){p=fract(p*vec2(123.34,456.21));p+=dot(p,p+45.32);return fract(p.x*p.y);}\nfloat noise(vec2 p){vec2 i=floor(p),f=fract(p),u=f*f*(3.-2.*f);\n return mix(mix(hash(i),hash(i+vec2(1,0)),u.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),u.x),u.y);}\nfloat fbm(vec2 p){float v=0.,a=.5;for(int i=0;i<5;i++){v+=a*noise(p);p=p*2.03+vec2(1.7,9.2);a*=.5;}return v;}\nvec3 generated(vec2 uv,float aspect){\n vec2 p=(uv-.5)*vec2(aspect,1.)*uScale;\n if(uScene==1){\n float t=uTime*.08;\n vec2 q=vec2(fbm(p*1.6+t),fbm(p*1.6-t+3.1));\n return vec3(smoothstep(.28,.86,fbm(p*1.8+q*1.6+vec2(t*.6,-t*.4))));\n }\n if(uScene==2){\n float r=.36,d=length(p),a=uTime*.25;\n vec3 l=normalize(vec3(cos(a)*.8,.55,sin(a)*.6+.6));\n if(d<r){\n vec3 n=normalize(vec3(p.x,-p.y,sqrt(r*r-d*d)));\n float diffuse=max(dot(n,l),0.),rim=pow(1.-n.z,2.5);\n float lon=atan(n.x,n.z)+uTime*.35,lat=asin(clamp(n.y,-1.,1.));\n float bands=.5+.25*sin(lat*14.)+.25*sin(lon*6.);\n return vec3(clamp(diffuse*.85+rim*.5+bands*.12,0.,1.));\n }\n return vec3(exp(-pow((d-r)*9.,2.))*.35);\n }\n if(uScene==4){\n // Drift: a few broad lobes that wander slowly. Built for halftone, where large soft shapes read best.\n float t=uTime*.045;\n vec2 q=p*1.15;\n vec2 w=vec2(fbm(q*.7+vec2(t,-t*.7)),fbm(q*.7+vec2(4.3-t*.8,t+1.7)));\n float n=fbm(q+w*1.3+vec2(t*.4,t*.25));\n return vec3(smoothstep(.36,.74,n));\n }\n if(uScene==5){\n // Swell: three crossing swells, the second bent by the first, so crests roll diagonally instead of pooling.\n float t=uTime;\n float s=sin((dot(p,vec2(.94,.33))/.95-t/9.)*6.2831853);\n float c=sin((dot(p,vec2(.6,-.8))/.58-t/13.)*6.2831853+s*.9);\n float k=sin((dot(p,vec2(-.29,.96))/.36+t/17.)*6.2831853);\n return vec3(smoothstep(.3,.9,.5+.5*(s*.5+c*.35+k*.15)));\n }\n // The kit's background scenes. Each starts a little way in, so a reduced-motion still is already composed.\n float t=uTime+40.,px=uCell.y/uResolution.y*uScale;\n if(uScene==6){\n // Caustics: light focused by a moving water surface. Two layers of warped sine waves drift against each other; each draws\n // smooth filaments along its zero line, about a character wide. Where they cross the light lifts a little, never to a blot.\n float tt=t*.12,a=0.,b=0.;\n for(int l=0;l<2;l++){\n float f=float(l),sc=5.4+f*2.4;\n vec2 q=(l==0?p:mat2(.8,-.6,.6,.8)*p)*sc;\n q+=vec2(sin(q.y*.45+tt*(1.+f*.3)),cos(q.x*.4-tt*(.8+f*.4)))*1.3;\n float v=sin(q.x+1.4*sin(q.y*.7+tt))+sin(q.y*1.1+1.2*sin(q.x*.8-tt*1.3))*.9;\n float wv=max(fwidth(v),1e-4);\n float line=(1.-smoothstep(.2,1.5,abs(v)/wv))*(l==0?.78:.62)+exp(-abs(v)/(wv*5.))*.16;\n if(l==0)a=line;else b=line;\n }\n float pulse=.85+.15*sin(tt*3.+p.x*1.7-p.y*1.1);\n float light=max(a,b)+.3*min(a,b);\n return vec3(clamp(light*light*pulse,0.,.78));\n }\n if(uScene==7){\n // Contour: a slow terrain read as survey lines about a character wide at any size; every fifth is an index line.\n float tt=t*.02;\n vec2 q=p*1.15+vec2(tt,-tt*.6);\n float h=noise(q)*.62+noise(q*2.07+3.1)*.27+noise(q*4.3-tt+7.)*.11;\n h+=.08*sin(tt*2.+p.x*.8);\n float k=h*13.,w=max(fwidth(k),1e-4),d=abs(fract(k+.5)-.5)/w;\n float major=mod(floor(k+.5),5.)<.5?1.:0.;\n return vec3((1.-smoothstep(.35,1.25-major*.25,d))*mix(.55,1.,major));\n }\n if(uScene==8){\n // Aurora: three curtains at different distances hang from the top. Far ones sit higher and dimmer; the nearest is tallest\n // and brightest. Each folds slowly and is brightest along its lower hem, fading upward. The rays are set per character\n // column, so the curtains read as vertical strokes at any stage size, from a small card to a phone.\n float tt=t*.05,a=0.,cw=uCell.x/uResolution.x;\n float col=floor(uv.x/cw+.5);\n for(int n=0;n<3;n++){\n float f=float(n),near=f/2.;\n float x=p.x*(1.3-near*.4)+f*3.7;\n float hem=-.28+near*.3+.16*sin(x*1.3+tt*(.9+f*.25)+f*2.)+.045*sin(x*3.4-tt*1.5+f);\n float d=hem-p.y;\n float body=d>0.?exp(-d/(.14+near*.26))*(.45+.55*exp(-d/.03)):exp(-d*d/.0002);\n float fold=.5+.5*sin(x*2.1+tt*.9+f*1.7+.7*sin(x*.8-tt*.6));\n float ray=mix(hash(vec2(col,f*7.1)),noise(vec2(col*.18+f*9.,tt*.7+f)),.55);\n float layer=clamp(body*(.1+.9*fold*fold)*(.2+.8*ray)*(.4+near*.6)*4.2,0.,1.);\n a=1.-(1.-a)*(1.-layer);\n }\n return vec3(smoothstep(.12,.9,a));\n }\n if(uScene==9){\n // Ripple: still water. Drops land here and there, each a few rings that widen and fade; the pointer drops its own.\n float tone=0.,g=.72;\n vec2 q=p/g,id=floor(q);\n for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){\n vec2 c=id+vec2(i,j),h=vec2(hash(c),hash(c+7.3));\n float period=5.+h.x*5.,age=fract(t*.3/period*4.+h.y);\n vec2 at=(c+.2+.6*h)*g;\n float d=length(p-at),r=age*.62;\n float rings=max(0.,cos((d-r)*34.))*exp(-pow((d-r)/.11,2.));\n tone+=rings*pow(1.-age,1.8)*smoothstep(0.,.06,age)*(.7+.3*h.x);\n }\n return vec3(clamp(tone*1.25,0.,1.));\n }\n if(uScene==10){\n // Halo: a slow breathing corona that frames the content, its rays turning. The ring fits the stage: wide on a desktop\n // hero, tall on a phone, so the whole halo stays on screen; the middle stays empty for a headline.\n vec2 r=vec2(min(.46,aspect*.4),min(.34,.36/max(aspect,.01)*.5+.2));\n vec2 e=p/r;\n float d=length(e),a=atan(e.y,e.x),tt=t*.07,k=min(r.x,r.y);\n float breathe=1.+.04*sin(tt*3.1);\n float rays=.5+.5*noise(vec2(a*3.2+tt,tt*.5))*(.6+.4*noise(vec2(a*7.-tt*1.2,3.+tt*.4)));\n float s=(d-breathe)*k;\n float rim=exp(-pow(s/.03,2.));\n float corona=exp(-max(0.,s)/(.1+.08*rays))*smoothstep(-.04,.015,s)*rays*smoothstep(.36,.12,s);\n return vec3(clamp(rim*(.55+.45*rays)+corona*.85,0.,1.));\n }\n if(uScene==11){\n // Interference: two ring grids from slowly orbiting centres. Where they cross, broad moire bands open and close.\n float tt=t*.05;\n vec2 a=vec2(-.3+.12*sin(tt),.07*cos(tt*1.3)),b=vec2(.3+.1*cos(tt*.8),-.06*sin(tt*1.1));\n float f=6.2831853/max(px*4.6,.004);\n float m=cos(length(p-a)*f)+cos(length(p-b)*f);\n return vec3(smoothstep(.7,2.,m));\n }\n if(uScene==12){\n // Mesh: four soft lights on slow Lissajous paths, a gradient mesh written in characters.\n float tt=t*.07,m=0.;\n for(int n=0;n<4;n++){\n float f=float(n)*1.7;\n vec2 c=vec2(.66*sin(tt*(.7+f*.13)+f),.34*cos(tt*(.9-f*.07)+f*1.3));\n float s=.3+.07*sin(tt+f);\n m+=exp(-dot(p-c,p-c)/(s*s))*(.8-float(n)*.1);\n }\n return vec3(smoothstep(.06,1.1,m));\n }\n if(uScene==13){\n // Cascade: streaks fall in three depths. Far ones are frequent, faint, short and slow; near ones rare, long, bright and\n // quick. Each has a bright head and a tail that fades behind it, and a column can carry two streaks at once.\n float tone=0.,cw=uCell.x/uResolution.x,ch=uCell.y/uResolution.y;\n float col=floor(uv.x/cw+.5);\n for(int n=0;n<3;n++){\n float f=float(n);\n for(int k=0;k<2;k++){\n float seed=f*13.1+float(k)*41.7,h=hash(vec2(col,seed));\n if(h<1.-(.5-f*.15))continue;\n float speed=(.045+f*.07)*(.75+.5*hash(vec2(col,seed+2.)));\n float tail=.12+f*.16,y=fract(t*speed+hash(vec2(col,seed+5.)))*(1.+tail*2.)-tail;\n float d=y-uv.y;\n if(d<0.||d>tail)continue;\n float head=d<ch*1.2?1.:0.;\n tone=max(tone,max(head*(.55+f*.22),pow(1.-d/tail,1.7)*(.28+f*.3)));\n }\n }\n return vec3(clamp(tone,0.,1.));\n }\n if(uScene==14){\n // Constellation: points wander in their own cells; neighbours close enough are linked by fine lines. Each point is a\n // bright core in a soft halo, so it reads at card size as well as full width.\n float g=.23,tt=t*.18;\n vec2 q=p/g,id=floor(q);\n vec2 pts[9];\n for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){\n vec2 c=id+vec2(i,j);\n float h=hash(c),k=hash(c+3.7);\n pts[(j+1)*3+i+1]=c+.5+.36*vec2(sin(tt*(.6+h)+h*6.28),cos(tt*(.5+k)+k*6.28));\n }\n float line=0.,star=0.,lw=max(px/g,.02);\n for(int n=0;n<9;n++){\n vec2 e=q-pts[n];\n float d2=dot(e,e),tw=.8+.2*sin(tt*3.+float(n)*1.7);\n star=max(star,max(exp(-d2/(lw*lw*1.6)),.38*exp(-d2/(lw*lw*7.)))*tw);\n for(int m=n+1;m<9;m++){\n vec2 a=pts[n],ba=pts[m]-a;\n float len=length(ba);\n if(len>1.35)continue;\n float hh=clamp(dot(q-a,ba)/dot(ba,ba),0.,1.);\n float d=length(q-a-ba*hh);\n line=max(line,(1.-smoothstep(lw*.3,lw*.75,d))*smoothstep(1.35,.6,len)*.72);\n }\n }\n return vec3(clamp(max(line,star),0.,1.));\n }\n return vec3(0.);\n}\n// Hover scope: 1 where the pointer response may act. The map holds the source's soft subject coverage in alpha.\nfloat hoverScope(vec2 uv){\n if(uScopeMode<.5||uScene!=0)return 1.;\n vec2 s=uv*uSourceMap.xy+uSourceMap.zw;\n float c=(s.x<0.||s.y<0.||s.x>1.||s.y>1.)?0.:texture(uScope,s).a;\n return uScopeMode<1.5?c:1.-c;\n}\nvoid main(){\n vec2 cell=floor(gl_FragCoord.xy);\n vec2 uv=(cell+.5)*uCell/uResolution;\n float aspect=uResolution.x/uResolution.y;\n float hs=hoverScope(uv);\n vec4 fluid=vec4(0.);\n // lift: signed tone change. The solver's flow brightens one side of each eddy and opens the other into gaps.\n float lift=0.,wake=0.,bend=1.,swirl=0.,speed=0.;\n if(uFluidOn>.5){\n vec4 raw=texture(uFluid,vec2(uv.x,1.-uv.y));\n if(uFluidMode>.5){\n vec2 v=raw.xy*uFluidTexel*vec2(aspect,1.)*hs;\n fluid=vec4(v,0.,1.);\n swirl=clamp(dot(v,vec2(.4,.65))*uGlow*.32,-.65,.65);\n speed=clamp(length(v)*uGlow*.055,0.,.38);\n bend=.4;\n } else {\n fluid=decodeFluid(raw);\n fluid.xyz*=hs;\n wake=clamp(fluid.z*uGlow,0.,1.);\n lift=wake*.55;\n }\n }\n vec2 drift=uDrift*.006*vec2(sin(uv.y*5.3+uTime*.6),cos(uv.x*4.1-uTime*.5));\n vec2 sampleAt=uv-vec2(fluid.x/aspect,-fluid.y)*uRefraction*bend+drift;\n float spot=0.;\n if(uHoverMode==4||uHoverMode==5){\n vec2 d=(uv-uLight.xy)*vec2(aspect,1.);\n float q2=dot(d,d)/(uLightRadius*uLightRadius*2.2);\n // Loupe: flat-topped zoom with a soft rim. Reveal: a soft spot in the source's colours.\n if(uHoverMode==4) sampleAt-=(uv-uLight.xy)*exp(-q2*q2)*.45*uLight.z*min(1.,uLightGain*1.6)*hs;\n else spot=exp(-q2*1.6)*uLight.z*min(1.,uLightGain*1.6)*hs;\n }\n vec3 rgb,glow=vec3(0.);\n if(uScene==0){\n vec2 s=sampleAt*uSourceMap.xy+uSourceMap.zw;\n bool inside=!(s.x<0.||s.y<0.||s.x>1.||s.y>1.);\n rgb=inside?textureLod(uSource,s,uLod).rgb:vec3(0.);\n if(uBackdrop>0.){\n vec2 b=(uv-vec2(fluid.x/aspect,-fluid.y)*uRefraction*bend*.5)*uSourceMap.xy+uSourceMap.zw;\n glow=(b.x<0.||b.y<0.||b.x>1.||b.y>1.)?vec3(0.):textureLod(uSource,b,uLod+3.).rgb*uBackdrop;\n }\n } else rgb=generated(sampleAt,aspect);\n float tone=dot(rgb,vec3(.2126,.7152,.0722));\n tone=clamp((tone-uLevels.x)/max(uLevels.y-uLevels.x,.01),0.,1.);\n tone=clamp((tone-.5)*uContrast+.5+uBrightness,0.,1.);\n tone=pow(tone,1./uGamma);\n if(uInvert>.5)tone=1.-tone;\n float flick=0.,trailFold=0.;\n // Reveal: under the spot the characters take the source's own colour and a little more ink.\n if(spot>0.)lift=spot*.22;\n if(uHoverMode==2){\n // Lantern: a soft light and its fading tail lift the characters they pass. Nothing moves the image.\n vec2 ap=vec2(aspect,1.),d=(uv-uLight.xy)*ap;\n float r2=uLightRadius*uLightRadius,glowL=uLight.z*exp(-dot(d,d)/r2);\n for(int i=0;i<12;i++){vec2 e=(uv-uTrail[i].xy)*ap;glowL+=uTrail[i].z*exp(-dot(e,e)/(r2*.55));}\n glowL=min(glowL,1.)*hs;\n float grain=fract(sin(dot(cell,vec2(12.9898,78.233)))*43758.5453);\n lift=glowL*uLightGain*(.7+.6*grain);\n wake=glowL*.4;\n // A few letters at the light's rim step up the ramp and back, as if being retyped.\n flick=uFlicker*step(.9,fract(grain*13.7+floor(uClock*7.+grain*5.)*.37))*glowL*(1.-glowL)*4.;\n }\n if(uHoverMode==3){\n // Trail: the studio's ink field, as a 16-bit density. Sparse marks fill in, dense marks open up.\n vec4 ink=texture(uTrailMap,uv);\n float density=(ink.r*65280.+ink.g*255.)/65535.*uTrailAmount;\n float t=clamp(density/.38,0.,1.);\n trailFold=t*t*(3.-2.*t)*hs;\n }\n if(uFluidMode>.5&&uHoverMode==1){\n // Dark ground: any motion lights the characters. Lit ground: the flow lights one side of each eddy and opens the other.\n // A little cell-to-cell grain keeps the lit area a shimmer of letters rather than a solid block.\n float grain=fract(sin(dot(cell,vec2(12.9898,78.233)))*43758.5453);\n lift=mix(abs(swirl)*.5+speed,swirl+speed*.35,smoothstep(.12,.55,tone))*(.65+.7*grain);\n wake=clamp(lift*1.6,0.,1.);\n }\n tone=clamp(tone+lift,0.,1.);\n tone+=(1.-2.*tone)*trailFold;\n // Pulses: rings sent by the interface (field.pulse()), e.g. on a save or a notification.\n for(int i=0;i<4;i++){\n if(uPulse[i].w<=0.)continue;\n float dist=length((uv-uPulse[i].xy)*vec2(aspect,1.)),front=uPulse[i].z*.95;\n float ring=exp(-pow((dist-front)/.1,2.))*uPulse[i].w*exp(-uPulse[i].z*.85);\n tone=clamp(tone+ring*.85,0.,1.);\n }\n tone*=1.-uVignette*smoothstep(.35,1.05,length((uv-.5)*vec2(min(aspect,1.8),1.)*2.));\n if(uClear.z>0.){\n // Clear zone: the field fades out around content so text above it stays readable.\n vec2 half_=uClear.zw*.5*vec2(aspect,1.),q=(uv-uClear.xy-uClear.zw*.5)*vec2(aspect,1.);\n float dz;\n if(uClearShape>.5){vec2 e=abs(q)-half_;dz=length(max(e,0.))+min(max(e.x,e.y),0.);}\n else dz=(length(q/max(half_,vec2(1e-4)))-1.)*min(half_.x,half_.y);\n tone*=smoothstep(0.,uClearFeather,dz);\n }\n // Blend: a shade between two characters takes the upper one in the share of cells a 4x4 Bayer pattern gives it.\n float level=tone*(uCount-1.),upper=fract(level)>=.5?1.:0.;\n if(uBlend>.5&&tone>.02&&tone<.98){\n ivec2 q=ivec2(mod(gl_FragCoord.xy,4.));\n upper=fract(level)>(BAYER[q.y*4+q.x]+.5)/16.?1.:0.;\n }\n float index=min(uCount-1.,floor(level)+upper+(flick>.5&&tone>.02?1.:0.));\n vec3 hue=rgb/max(max(rgb.r,rgb.g),max(rgb.b,.03));\n hue=mix(vec3(dot(hue,vec3(.2126,.7152,.0722))),hue,uSaturation);\n vec3 ink=mix(uInk*mix(1.,.3+.7*tone,uShade),clamp(hue*(.38+.62*tone),0.,1.),uSourceColor);\n vec3 lifted=uHighlightAuto>.5?ink/max(max(ink.r,ink.g),max(ink.b,.06)):uHighlight;\n ink=mix(ink,lifted,wake*.7);\n if(spot>0.)ink=mix(ink,clamp(rgb/max(max(rgb.r,rgb.g),max(rgb.b,.08))*(.45+.55*tone),0.,1.),spot);\n float underAlpha=max(uBackground.a,min(1.,max(glow.r,max(glow.g,glow.b))));\n vec3 under=min(uBackground.rgb*uBackground.a+glow,vec3(underAlpha));\n // Glyphs keep their atlas index, exact in 8 bits; the other marks keep the tone, and empty where the charset is blank.\n outInk=vec4(ink,uMark==0?index/255.:uMark==1?(tone>.003?tone:0.):index>0.?max(tone,1./255.):0.);\n outUnder=vec4(under,underAlpha);\n}`)(T)),B=Ke("#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform sampler2D uAtlas, uCells, uUnder;\nuniform vec2 uResolution, uCell, uPitch;\nuniform float uColumns, uDotScale, uSourceColor;\nuniform int uMark;\nout vec4 outColor;\nconst float BAYER[16]=float[16](0.,8.,2.,10.,12.,4.,14.,6.,3.,11.,1.,9.,15.,7.,13.,5.);\n// The Studio's print defaults: screen angle -35deg, roughness .35, seed 7, registration .2 and its coral second ink.\nconst vec2 DIR=vec2(.81915,-.57358);\nconst float ROUGH=.35,SEED=7.;\nconst vec3 SECOND=vec3(.925,.404,.322);\nfloat hash(vec2 p){p=fract(p*vec2(123.34,456.21));p+=dot(p,p+45.32);return fract(p.x*p.y);}\n// Coverage of a signed distance given in device pixels.\nfloat cover(float d){return clamp(.5-d,0.,1.);}\nfloat box(vec2 p,vec2 lo,vec2 hi){vec2 a=clamp(p-lo,0.,1.)*clamp(hi-p,0.,1.);return a.x*a.y;}\nfloat disc(vec2 p,vec2 c,float r){return r>.05?cover(length(p-c)-r):0.;}\nfloat ellipse(vec2 p,vec2 c,vec2 r,float a){vec2 d=p-c;d=vec2(cos(a)*d.x+sin(a)*d.y,-sin(a)*d.x+cos(a)*d.y);float k=length(d/r);return cover((k-1.)*min(r.x,r.y));}\n// World-anchored parallel cuts across direction d: period and width in cell heights, so lines run on from cell to cell.\nfloat cuts(vec2 w,vec2 d,float period,float width,float px){\n if(width<=0.)return 0.;\n float proj=dot(vec2(-d.y,d.x),w);\n return cover((abs(fract(proj/period+.5)-.5)*period-width*.5)*px);\n}\n// Lays an ink over what is already down, multiplying where they overlap, as transparent inks do on paper.\nvoid lay(inout vec3 rgb,inout float a,vec3 c,float k){\n float next=a+k*(1.-a);\n rgb=next>0.?(rgb*a*(1.-k)+mix(c,rgb*c,a)*k)/next:c;\n a=next;\n}\nvoid main(){\n vec2 frag=vec2(gl_FragCoord.x,uResolution.y-gl_FragCoord.y);\n // The pitch is the atlas cell, or a fractional one under cellFit 'fill', where each glyph sits centred in its stretched cell.\n vec2 cell=floor(frag/uPitch);\n vec4 ink=texelFetch(uCells,ivec2(cell),0),under=texelFetch(uUnder,ivec2(cell),0);\n vec2 local=frag-cell*uPitch;\n float coverage;\n vec3 rgb=ink.rgb;\n if(uMark==0){\n float index=floor(ink.a*255.+.5);\n ivec2 tile=ivec2(int(mod(index,uColumns)),int(floor(index/uColumns)));\n vec2 texel=floor(local-floor((uPitch-uCell)*.5));\n coverage=all(greaterThanEqual(texel,vec2(0.)))&&all(lessThan(texel,uCell))?texelFetch(uAtlas,tile*ivec2(uCell)+ivec2(texel),0).a:0.;\n } else if(uMark==1){\n // Halftone: dot area follows tone, so midtones read true; edges are antialiased to one device pixel.\n float r=sqrt(ink.a)*min(uPitch.x,uPitch.y)*.5*uDotScale;\n coverage=ink.a>.003?clamp(r-length(local-uPitch*.5)+.5,0.,1.):0.;\n } else if(ink.a<=0.){\n coverage=0.;\n } else {\n float tone=ink.a,side=min(uPitch.x,uPitch.y);\n vec2 q=local/uPitch,c=uPitch*.5,p=local+.5;\n // Tiles fade with the tone in one ink, as the Studio's do; in source colour the colour already carries it.\n float fade=uSourceColor>.5?1.:tone,gap=max(.5,uPitch.x*.06),grain=hash(cell+SEED);\n vec2 w=(cell+q)*uPitch/uPitch.y;\n if(uMark==2)coverage=fade;\n else if(uMark==3)coverage=box(p,vec2(0.),uPitch-gap)*fade;\n else if(uMark==4){\n // Lego: a gapped brick, lit from above, with a raised stud ringed by its shadow.\n coverage=box(p,vec2(0.),uPitch-gap)*fade;\n rgb*=1.06-.14*q.y;\n float r=side*.28,d=length(local-c)-r,lit=clamp(dot(c-local,vec2(.6,.8))/r,-1.,1.);\n rgb=mix(rgb,mix(rgb,vec3(1.),.2+.12*lit),cover(d));\n rgb=mix(rgb,rgb*.72,cover(abs(d)-max(.5,side*.04)));\n } else if(uMark==5){\n // Voxel: an isometric cube; top, left and right faces at full, .72 and .42 strength.\n float h=.5*abs(q.x-.5);\n coverage=cover(-min(q.y-h,1.-h-q.y)*uPitch.y)*cover(-min(q.x,1.-q.x)*uPitch.x);\n coverage*=mix(q.x<.5?.72:.42,1.,cover((q.y-(.5-h))*uPitch.y))*fade;\n } else if(uMark==6){\n // Disco: a gapped mirror tile, its upper facet catching light and its lower in shade.\n coverage=box(p,vec2(0.),uPitch-gap)*fade;\n rgb=q.y<.35?mix(rgb,vec3(1.),.1+grain*.25):q.y>.65?rgb*.75:rgb;\n } else if(uMark==7){\n // Dither: an ordered 4x4 Bayer screen at about five dots a cell, lit where the cell's tone passes the threshold.\n ivec2 b=ivec2(mod(floor(frag/max(1.,floor(side/5.))),4.));\n coverage=tone>(BAYER[b.y*4+b.x]+.5)/16.?1.:0.;\n } else if(uMark==8){\n // Hex: a flat-topped hexagon filling the cell.\n vec2 h=abs((local-c)/(uPitch*.49));\n coverage=cover(max(h.y-.866,h.x*.866+h.y*.5-.866)*side*.49)*fade;\n } else if(uMark==9){\n // LED: a round lamp with a soft halo and a specular glint, separated by an unlit matrix.\n float r=side*.39,d=length(local-c);\n coverage=max(cover(d-r),.3*exp(-pow(max(0.,d-r)/(side*.12),2.)))*fade;\n rgb=mix(rgb,vec3(1.),.35*disc(local,uPitch*vec2(.43,.4),side*.11));\n } else if(uMark==10){\n // CMYK: the cell's hue separated into offset cyan, magenta and yellow dots, each sized by its share of the tone. The\n // key screen carries the neutral share in the ink's own lightness, since a light ink on a dark page has no black.\n float top=max(rgb.r,max(rgb.g,rgb.b)),low=min(rgb.r,min(rgb.g,rgb.b));\n vec3 cmy=(top-rgb)/max(top,.001);\n float a=0.;vec3 col=vec3(1.);\n lay(col,a,vec3(top),disc(local,c,side*.48*sqrt(tone*low/max(top,.001))));\n lay(col,a,vec3(0.,1.,1.),disc(local,uPitch*vec2(.36,.36),side*.48*sqrt(tone*cmy.x)));\n lay(col,a,vec3(1.,0.,1.),disc(local,uPitch*vec2(.64,.36),side*.48*sqrt(tone*cmy.y)));\n lay(col,a,vec3(1.,1.,0.),disc(local,uPitch*vec2(.5,.66),side*.48*sqrt(tone*cmy.z)));\n rgb=col;coverage=a;\n } else if(uMark==11||uMark==16){\n // Stipple and pointillism: four jittered marks a cell, their size following the tone.\n coverage=0.;vec3 col=rgb;\n for(int m=0;m<4;m++){\n vec2 o=vec2(float(m%2),float(m/2));\n float j=hash(cell*2.+o+SEED),jy=hash(cell+o*11.+SEED+1.);\n vec2 at=((o+.5)/2.+(vec2(j,jy)-.5)*ROUGH*.28)*uPitch;\n float r=min(min(min(at.x,uPitch.x-at.x),min(at.y,uPitch.y-at.y)),side*min(.245,.21*sqrt(tone)*(1.-ROUGH*j*.35)));\n float k=uMark==11?disc(local,at,r):ellipse(local,at,vec2(r,r*.64),j*3.14159);\n if(uMark==16&&k>coverage)col=uSourceColor>.5?clamp(rgb+(j-.5)*ROUGH*.25*vec3(1.,-.4,-1.),0.,1.):rgb*(1.+(j-.5)*ROUGH*.5);\n coverage=max(coverage,k);\n }\n rgb=col;\n } else if(uMark==12||uMark==13){\n // Engraving and crosshatch: parallel cuts whose weight follows the tone; crossings join only in the darker tones.\n float cv=tone*(1.-ROUGH*grain*.3),px=uPitch.y;\n coverage=cuts(w,DIR,.5,min(.47,.36*cv),px);\n if(uMark==13){\n coverage=max(coverage,cuts(w,vec2(-DIR.y,DIR.x),.5,min(.47,.36*max(0.,cv*1.5-.3)),px)*step(.2,cv));\n coverage=max(coverage,cuts(w,normalize(DIR+vec2(-DIR.y,DIR.x)),.5,min(.47,.36*max(0.,cv*2.-1.2)),px)*step(.6,cv));\n }\n } else if(uMark==14){\n // Woodblock: broad carved bands in five stepped weights, their edges wavering along the grain.\n float cv=ceil(tone*(1.-ROUGH*grain*.3)*5.)/5.,width=min(.94,.72*cv);\n float proj=dot(vec2(-DIR.y,DIR.x),w),line=floor(proj+.5),along=dot(DIR,w);\n float cut=sin(along*5.3+line*1.9+SEED)*.5+sin(along*13.1+line)*.25;\n coverage=cover((abs(proj-line)-width*.5*(1.+ROUGH*cut*.5))*uPitch.y);\n } else if(uMark==15){\n // Risograph: two offset screens, the main ink and the coral second ink, misregistered along the screen angle.\n float split=uSourceColor>.5?clamp(.5+(rgb.r-rgb.b)*.5,0.,1.):.5,r=side*min(.48,.44*sqrt(tone));\n float a=0.;vec3 col=rgb;\n lay(col,a,rgb,disc(local,c,r*sqrt(.35+(1.-split)*.65)));\n lay(col,a,SECOND,disc(local,c+DIR*.2*.38*side,r*sqrt(.3+split*.7)*(1.-ROUGH*hash(cell+SEED+13.)*.3)));\n rgb=col;coverage=a;\n } else coverage=0.;\n }\n outColor=vec4(rgb*coverage+under.rgb*(1.-coverage),coverage+under.a*(1.-coverage));\n}"),M||Je(!0)}const at=()=>`${y.fontWeight} ${Math.max(1,J.height*y.glyphScale)}px ${y.font}`,lt=()=>{const e=R(y.charset);Q=e.length,J=k(y.cellSize,y.cellAspect,K,Q),$=K;const t=document.createElement("canvas");t.width=J.atlasWidth,t.height=J.atlasHeight;const n=t.getContext("2d");n.fillStyle="#fff",n.textAlign="center",n.textBaseline="alphabetic",n.font=at();const r=n.measureText("M"),o=r.actualBoundingBoxAscent||J.height*y.glyphScale*.7,i=r.actualBoundingBoxDescent||0,a=(J.height+o-i)/2;e.forEach((e,t)=>{const r=t%J.columns*J.width+J.width/2,o=Math.floor(t/J.columns)*J.height+a,i=n.measureText(e).width;n.save(),n.beginPath(),n.rect(r-J.width/2,o-a,J.width,J.height),n.clip(),n.translate(r,o),i>.96*J.width&&n.scale(.96*J.width/i,1),n.fillText(e,0,0),n.restore()}),w.bindTexture(w.TEXTURE_2D,C),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),w.texImage2D(w.TEXTURE_2D,0,w.RGBA8,w.RGBA,w.UNSIGNED_BYTE,t),t.width=t.height=1,be=!0},st="undefined"==typeof document?void 0:document.fonts,ut=()=>{if(!st?.load)return;const e=at();st.load(e,R(y.charset).join("")).then(()=>{Ee||we||at()!==e||(lt(),It())},()=>{})},ct=e=>e.trim().replace(/^["']|["']$/g,"").toLowerCase(),ht=e=>{const t=e.fontfaces??[],n=y.font.split(",").map(ct);t.some(e=>n.includes(ct(e.family)))&&ut()},ft=()=>{if(fe=[0,1],ne&&"none"!==y.levels)try{const e=document.createElement("canvas");e.width=e.height=64;const t=e.getContext("2d",{willReadFrequently:!0});ne===se&&(t.imageSmoothingQuality="medium"),t.drawImage(ne,0,0,64,64),fe=S(t.getImageData(0,0,64,64).data)}catch{fe=[0,1]}};let dt=null,mt=null,pt=!1,vt=-1/0,gt=new Uint8Array(0),xt=null;const yt=()=>{if(pt=!1,!ne||"all"===y.scope)return;const e=ie||1,t=ae||1,n=Math.max(8,Math.round(e>=t?96:96*e/t)),r=Math.max(8,Math.round(t>=e?96:96*t/e));try{if(xt??(xt=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),!xt)return;const e=xt.canvas;e.width!==n||e.height!==r?(e.width=n,e.height=r):xt.clearRect(0,0,n,r),xt.drawImage(ne,0,0,n,r),mt=function(e,t,n,r,o){const i=t*n,a=o&&o.width===t&&o.height===n?o:{width:t,height:n,subject:new Float32Array(i),depth:new Float32Array(i),key:"none"},{subject:l,depth:s}=a;let u=0;for(let t=0;t<i;t++)e[4*t+3]<250&&u++;const c=t=>(.2126*e[4*t]+.7152*e[4*t+1]+.0722*e[4*t+2])/255;let h="none",m=0;if(u>.01*i)h="alpha";else{let e=0,r=0,o=0;const i=Math.max(1,Math.round(.03*Math.min(t,n)));for(let a=0;a<n;a++)for(let l=0;l<t;l++){if(l>=i&&a>=i&&l<t-i&&a<n-i)continue;const s=c(a*t+l);e+=s,r+=s*s,o++}m=e/Math.max(1,o),Math.sqrt(Math.max(0,r/Math.max(1,o)-m*m))<.07&&(h="ground")}for(let t=0;t<i;t++){const n=e[4*t+3]/255,r=c(t);let o=1;if("alpha"===h)o=n;else if("ground"===h){const e=Math.max(0,Math.min(1,(Math.abs(r-m)-.035)/.12));o=e*e*(3-2*e)}l[t]=1*o,s[t]=r*n}a.key=h,d.length<i&&(d=new Float32Array(i));const p=d;return f(l,p,t,n,Math.max(1,Math.round(.02*Math.min(t,n)))),f(s,p,t,n,Math.max(1,Math.round(.035*Math.min(t,n)))),a}(xt.getImageData(0,0,n,r).data,n,r,0,mt)}catch{return}if("none"!==mt.key){gt.length!==n*r*4&&(gt=new Uint8Array(n*r*4));for(let e=0;e<n*r;e++)gt[4*e+3]=Math.round(255*mt.subject[e]);dt??(dt=Qe(w.LINEAR)),w.bindTexture(w.TEXTURE_2D,dt),w.pixelStorei(w.UNPACK_FLIP_Y_WEBGL,!1),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),w.texImage2D(w.TEXTURE_2D,0,w.RGBA8,n,r,0,w.RGBA,w.UNSIGNED_BYTE,gt),pt=!0}},bt=()=>{if(!ne)return;const e=performance.now();ne instanceof HTMLVideoElement&&!(e-de>1500)||(ft(),de=e),ne instanceof HTMLVideoElement&&!(e-vt>160)||(yt(),vt=e),w.bindTexture(w.TEXTURE_2D,U),w.pixelStorei(w.UNPACK_FLIP_Y_WEBGL,!1),w.pixelStorei(w.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);try{w.texImage2D(w.TEXTURE_2D,0,w.RGBA8,w.RGBA,w.UNSIGNED_BYTE,ne),w.generateMipmap(w.TEXTURE_2D)}catch(e){We(e)}},Et=()=>{T=!w.getExtension("EXT_color_buffer_float")&&!w.getExtension("EXT_color_buffer_half_float"),it(),z=w.createVertexArray(),C=Qe(w.NEAREST),U=Qe(w.LINEAR_MIPMAP_LINEAR),w.bindTexture(w.TEXTURE_2D,U),w.texImage2D(w.TEXTURE_2D,0,w.RGBA8,1,1,0,w.RGBA,w.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),w.generateMipmap(w.TEXTURE_2D),W=Y=0,$=0,wt(),ut(),ne&&bt()};function wt(){const e=n.clientWidth||n.clientHeight?{width:n.clientWidth,height:n.clientHeight}:n.getBoundingClientRect();pe=!e.width||!e.height;const t=Math.min(globalThis.devicePixelRatio||1,y.maxPixelRatio,Math.sqrt(8294400/Math.max(1,e.width*e.height))),r=Math.max(1,Math.round(e.width*t)),o=Math.max(1,Math.round(e.height*t));if(r===W&&o===Y&&t===K)return!1;const i=!W||Math.abs(r/o-W/Y)>.01;return K=t,W=r,Y=o,n.width=W,n.height=Y,$!==K&&lt(),(i||tt()&&!H.length&&!V)&&ot(),be=!0,!0}let Tt=null,Mt=[0,0,0],Rt=[1,1,1],Ft=[0,0,0,0],At=A(1,1,1,1,"cover"),kt=null,Lt=0,St=0,Dt=0,_t=0;const Ct=()=>{Tt!==y&&(Tt=y,Mt=L(y.ink),Rt=L("auto"===y.highlight?"#ffffff":y.highlight),Ft="transparent"===y.background?[0,0,0,0]:[...L(y.background),1]),kt===y&&Lt===W&&St===Y&&Dt===ie&&_t===ae||(kt=y,Lt=W,St=Y,Dt=ie,_t=ae,At=A(W,Y,ie||1,ae||1,y.fit,y.focus));const t=y.fluid,n=ne&&ue?J.height/Y*ue*At.scale[1]:1,r=(()=>{const[e,t]=et(),n=Math.ceil(W/e-1e-4),r=Math.ceil(Y/t-1e-4);if(N&&N.columns===n&&N.rows===r)return N;Ze();const o=()=>{const e=Qe(w.NEAREST);return w.texStorage2D(w.TEXTURE_2D,1,T?w.RGBA8:w.RGBA16F,n,r),e},i=o(),a=o(),l=w.createFramebuffer();return w.bindFramebuffer(w.FRAMEBUFFER,l),w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT0,w.TEXTURE_2D,i,0),w.framebufferTexture2D(w.FRAMEBUFFER,w.COLOR_ATTACHMENT1,w.TEXTURE_2D,a,0),w.drawBuffers([w.COLOR_ATTACHMENT0,w.COLOR_ATTACHMENT1]),N={ink:i,under:a,buffer:l,columns:n,rows:r}})(),o=I.locations,i=B.locations,a=D(y),l=!Ve();w.bindFramebuffer(w.FRAMEBUFFER,r.buffer),w.viewport(0,0,r.columns,r.rows),w.useProgram(I.program),w.activeTexture(w.TEXTURE0),w.bindTexture(w.TEXTURE_2D,U),w.uniform1i(o.uSource,0),w.activeTexture(w.TEXTURE2),w.bindTexture(w.TEXTURE_2D,(V?q?.velocity:H[te])??U),w.uniform1i(o.uFluid,2),w.activeTexture(w.TEXTURE3),w.bindTexture(w.TEXTURE_2D,Ge??U),w.uniform1i(o.uTrailMap,3),w.activeTexture(w.TEXTURE6),w.bindTexture(w.TEXTURE_2D,dt??U),w.uniform1i(o.uScope,6),w.uniform1f(o.uScopeMode,pt&&"all"!==y.scope?"subject"===y.scope?1:2:0),w.uniform1f(o.uFluidMode,V?1:0),w.uniform1i(o.uHoverMode,"fluid"===a?1:"lantern"===a?2:"trail"===a&&Ne?3:"loupe"===a?4:"reveal"===a?5:0),w.uniform1f(o.uTrailAmount,y.trail.strength),w.uniform3f(o.uLight,Ue.at?.[0]??-1,Ue.at?.[1]??-1,Pe(a)?Ue.strength:0),w.uniform3fv(o.uTrail,Ie),w.uniform1f(o.uLightRadius,y.lantern.radius),w.uniform1f(o.uLightGain,y.lantern.strength),w.uniform1f(o.uClock,performance.now()/1e3),w.uniform1f(o.uFlicker,l?1:0),w.uniform2f(o.uFluidTexel,1/Math.max(1,Z),1/Math.max(1,ee)),w.uniform2f(o.uResolution,W,Y);const[s,u]=et();var c;w.uniform2f(o.uCell,s,u),w.uniform1f(o.uCount,Q),w.uniform1f(o.uBlend,"on"===y.blend||Q<=9&&("coarse"===y.blend||"auto"===y.blend&&re)?1:0),w.uniform4f(o.uSourceMap,At.scale[0],At.scale[1],At.offset[0],At.offset[1]),w.uniform1i(o.uScene,ne?0:(c=y.scene,e[c]??3)),w.uniform1i(o.uMark,v.indexOf(y.mark)),w.uniform1f(o.uScale,y.scale);const h=y.clear;w.uniform4f(o.uClear,h?h.x:0,h?h.y:0,h?h.width:0,h?h.height:0),w.uniform1f(o.uClearFeather,h?h.feather:.1),w.uniform1f(o.uClearShape,h&&"rect"===h.shape?1:0);const f=performance.now();_e.fill(0);for(let e=0;e<De.length;e++){const t=De[e],n=4*e;_e[n]=t.x,_e[n+1]=t.y,_e[n+2]=(f-t.born)/1e3,_e[n+3]=t.strength}w.uniform4fv(o.uPulse,_e),w.uniform3fv(o.uInk,Mt),w.uniform3fv(o.uHighlight,Rt),w.uniform1f(o.uHighlightAuto,"auto"===y.highlight?1:0),w.uniform4fv(o.uBackground,Ft),w.uniform1f(o.uBrightness,y.brightness),w.uniform1f(o.uContrast,y.contrast),w.uniform1f(o.uGamma,y.gamma),w.uniform1f(o.uInvert,y.invert?1:0),w.uniform1f(o.uVignette,y.vignette),w.uniform1f(o.uSourceColor,"source"===y.color?1:0),w.uniform1f(o.uRefraction,t?t.refraction*(l?1:.25):0),w.uniform1f(o.uGlow,t?t.glow:0),w.uniform1f(o.uTime,ye),w.uniform1f(o.uDrift,l?y.drift:0),w.uniform1f(o.uFluidOn,t&&"fluid"===a&&(H.length||V)?1:0),w.uniform1f(o.uLod,Math.max(0,Math.log2(Math.max(1,n))-.5)),w.uniform1f(o.uSaturation,y.saturation),w.uniform1f(o.uShade,y.shade),w.uniform1f(o.uBackdrop,ne?y.backdrop:0),w.uniform2f(o.uLevels,ne&&"auto"===y.levels?fe[0]:0,ne&&"auto"===y.levels?fe[1]:1),w.bindVertexArray(z),w.drawArrays(w.TRIANGLES,0,3),w.bindFramebuffer(w.FRAMEBUFFER,null),w.viewport(0,0,W,Y),w.useProgram(B.program),w.activeTexture(w.TEXTURE1),w.bindTexture(w.TEXTURE_2D,C),w.uniform1i(i.uAtlas,1),w.activeTexture(w.TEXTURE4),w.bindTexture(w.TEXTURE_2D,r.ink),w.uniform1i(i.uCells,4),w.activeTexture(w.TEXTURE5),w.bindTexture(w.TEXTURE_2D,r.under),w.uniform1i(i.uUnder,5),w.uniform2f(i.uResolution,W,Y),w.uniform2f(i.uCell,J.width,J.height),w.uniform2f(i.uPitch,s,u),w.uniform1f(i.uColumns,J.columns),w.uniform1f(i.uDotScale,y.dotScale),w.uniform1i(i.uMark,v.indexOf(y.mark)),w.uniform1f(i.uSourceColor,"source"===y.color?1:0),w.drawArrays(w.TRIANGLES,0,3)},Pt=()=>!Ee&&!we&&!Te&&!pe&&(Re||je)&&!("undefined"!=typeof document&&document.hidden),Ut=e=>{if(ge=0,!Pt())return;const t=(e-xe)/1e3,n=Math.min(1/30,Math.max(1/480,t));xe=e,ke=.9*ke+.1*Math.min(t,.25),Le=ke>1/24?Le+1:0;try{Le>45&&Se<2&&(Le=0,Se++,1===Se&&K>1?(y={...y,maxPixelRatio:1},wt()):Se=2);const t=Je(),r=!(Me||Se>=2&&!(ne instanceof HTMLVideoElement)||(!(ne instanceof HTMLVideoElement)||ne.paused||ne.ended)&&(Ve()||!(!ne&&"none"!==y.scene||y.drift>0)));r&&(ye+=n*y.speed),ne instanceof HTMLVideoElement&&ne.readyState>=2&&ce&&(ce=!("requestVideoFrameCallback"in ne),bt(),be=!0);const o=D(y);let i="fluid"===o&&(null!==Ae||e<Xe);if(i?((e,t)=>{const n=y.fluid;if(!n||!X.length&&!V)return;if(V?!q?.ready():!G||!$e(G))return;const r=W/Y,o=Ae;if(Ae=null,V&&q){const i=5200*n.force*(Ve()?.35:1);return o&&(Xe=t+1e3*Math.min(9,6/Math.max(.3,n.dissipation))),void q.step(o?{from:o.from,to:o.to,force:[(o.to[0]-o.from[0])*i,(o.to[1]-o.from[1])*i]}:null,{dt:Math.min(e,1/60),radius:1.1*n.radius,curl:n.curl,dissipation:n.dissipation,aspect:r})}let i=0,a=0;if(o){const e=(Ve()?1:3)*n.force;i=(o.to[0]-o.from[0])*r*e*4,a=(o.to[1]-o.from[1])*e*4,Xe=t+7/Math.min(n.dissipation,1.1*n.dissipation)*1e3}const l=G.locations;w.bindFramebuffer(w.FRAMEBUFFER,X[1-te]),w.viewport(0,0,Z,ee),w.useProgram(G.program),w.activeTexture(w.TEXTURE0),w.bindTexture(w.TEXTURE_2D,H[te]),w.uniform1i(l.uPrevious,0),w.uniform2f(l.uSize,Z,ee),w.uniform1f(l.uAspect,r),w.uniform1f(l.uDt,e),w.uniform1f(l.uDecay,n.dissipation),w.uniform1f(l.uEnergyDecay,1.1*n.dissipation),w.uniform1f(l.uRadius,n.radius),w.uniform1f(l.uSplat,o?1:0),w.uniform2f(l.uFrom,o?.from[0]??0,o?.from[1]??0),w.uniform2f(l.uTo,o?.to[0]??0,o?.to[1]??0),w.uniform2f(l.uForce,i,a),w.drawArrays(w.TRIANGLES,0,3),te=1-te})(n,e):Ae=null,Pe(o)&&(i=((e,t)=>{const n=y.lantern,r=Ue.target;if(r){const o=Ue.at;if(o)if(Ve())o[0]=r[0],o[1]=r[1];else{const t=1-Math.exp(-n.follow*e);o[0]+=(r[0]-o[0])*t,o[1]+=(r[1]-o[1])*t}else Ue.at=[r[0],r[1]];const i=Ue.at,a=Ue.trail[Ue.trail.length-1];n.trail>0&&(!a||t-a.born>28&&Math.hypot(i[0]-a.x,i[1]-a.y)>.004)&&(Ue.trail.push({x:i[0],y:i[1],born:t}),Ue.trail.length>12&&Ue.trail.shift())}Ue.strength+=((r?1:0)-Ue.strength)*(1-Math.exp(-e*(r?9:5)));const o=Ue.trail;for(let e=o.length-1;e>=0;e--)n.trail>0&&t-o[e].born<4e3*n.trail||o.splice(e,1);Ie.fill(0);for(let e=0;e<o.length;e++){const r=o[e];Ie[3*e]=r.x,Ie[3*e+1]=r.y,Ie[3*e+2]=.55*Math.exp(-(t-r.born)/1e3/Math.max(.01,n.trail))}return Ue.strength>.003||o.length>0})(n,e)||i),"trail"===o){const e=!!Be?.active;i=(e=>{const t=He();return!(!t||!t.active||(t.step(e),w.bindTexture(w.TEXTURE_2D,Ge),w.texSubImage2D(w.TEXTURE_2D,0,0,0,t.width,t.height,w.RGBA,w.UNSIGNED_BYTE,t.pixels),Ne=!0,0))})(n)||i,e&&!Be?.active&&(be=!0)}if(De.length){for(let t=De.length-1;t>=0;t--)e-De[t].born>=2400&&De.splice(t,1);i=!0,De.length||(be=!0)}t&&(i||be||r&&e-me>=ve)&&(Ct(),me=e,be=!1,!je||le&&!ne||(je=!1,ze())),(r||i||Ae||!t)&&(ge=requestAnimationFrame(Ut))}catch(e){Te=!0,We(e)}};function It(){!ge&&Pt()&&(xe=performance.now(),ge=requestAnimationFrame(Ut))}const Bt=(e,t)=>{const r=n.getBoundingClientRect();if(!r.width||!r.height)return null;const o=(e-r.left)/r.width,i=(t-r.top)/r.height;return o<-.05||o>1.05||i<-.05||i>1.05?null:[o,1-i]},Gt=e=>{const t=D(y);if("none"===t||Me)return Fe=null,void(Ue.target=null);if(Pe(t))return Ue.target=e?[e[0],1-e[1]]:null,Fe=null,void It();if("trail"===t){const t=He();if(!t)return;return e?t.move(e[0],1-e[1],y.trail.radius,performance.now()):t.leave(),Fe=null,void It()}e?(Fe&&(Ae=Ae?{from:Ae.from,to:e}:{from:Fe,to:e}),Fe=e,It()):Fe=null},Nt=e=>Gt(Bt(e.clientX,e.clientY)),Ht=()=>{Fe=null,Be?.leave(),Ue.target&&(Ue.target=null,It())},Xt=m.interactionTarget??window;Xt.addEventListener("pointermove",Nt,{passive:!0}),Xt.addEventListener("pointerdown",Nt,{passive:!0}),document.addEventListener("pointerleave",Ht),Xt!==window&&Xt.addEventListener("pointerleave",Ht);const qt="function"==typeof ResizeObserver?new ResizeObserver(()=>{const e=wt();Ce(),(e||be)&&It()}):null;qt?.observe(n),x&&qt?.observe(x.element);const Vt="function"==typeof IntersectionObserver?new IntersectionObserver(([e])=>{Re=e.isIntersecting,Re&&(be=!0,It())},{rootMargin:"120px"}):null;Vt?.observe(n);const zt=()=>{document.hidden||(be=!0,It())};document.addEventListener("visibilitychange",zt);const Ot=()=>{be=!0,It()};qe?.addEventListener?.("change",Ot),st?.addEventListener?.("loadingdone",ht);const jt=e=>{e.preventDefault(),we=!0,ge&&cancelAnimationFrame(ge),ge=0},Wt=()=>{we=!1,j.length=0,O=null,I=B=G=null,N=null,H=[],X=[],q=null,V=!1,Ge=null,Be=null,Ne=!1,dt=null,pt=!1;try{Et(),be=!0,It()}catch(e){We(e)}};n.addEventListener("webglcontextlost",jt),n.addEventListener("webglcontextrestored",Wt);const Yt=()=>{oe&&(oe.pause(),oe.removeAttribute("src"),oe.load(),oe=null),he&&ne instanceof HTMLVideoElement&&"cancelVideoFrameCallback"in ne&&ne.cancelVideoFrameCallback(he),he=0},Kt=()=>{se?.close(),se=null},$t=async e=>{const t=await createImageBitmap(e,{premultiplyAlpha:"none"}),n=[t.width,t.height],r=function(e,t,n,r,o,i,a=8){if(!(n>=16&&r>=16&&e>0&&t>0&&o>0))return 1;const l=a/o/("cover"===i?Math.min(e/n,t/r):Math.max(e/n,t/r));return l>.5?1:2**-Math.floor(Math.log2(1/l))}(t.width,t.height,W,Y,J.height,y.fit);if(1===r)return{element:t,owned:!0,natural:n};try{return{element:await createImageBitmap(t,{resizeWidth:Math.max(1,Math.round(t.width*r)),resizeHeight:Math.max(1,Math.round(t.height*r)),resizeQuality:"medium",premultiplyAlpha:"none"}),owned:!0,natural:n}}finally{t.close()}},Jt=e=>new Promise((t,n)=>{const r=new Image;r.crossOrigin="anonymous",r.decoding="async",r.onload=()=>t({element:r,owned:!1}),r.onerror=()=>n(new Error("The glyph field could not load this image.")),r.src=e}),Qt=async e=>{const t=++le;if(!e)return Yt(),Kt(),ne=null,ie=ae=ue=0,re=!1,be=!0,void It();try{const n=await(async e=>{if("string"!=typeof e)return e instanceof HTMLImageElement&&!e.complete?e.decode().then(()=>({element:e,owned:!1})):e instanceof HTMLVideoElement&&e.readyState<2?new Promise((t,n)=>{e.addEventListener("loadeddata",()=>t({element:e,owned:!1}),{once:!0}),e.addEventListener("error",()=>n(new Error("The glyph field could not load this video.")),{once:!0})}):{element:e,owned:!1};if(P.test(e))return new Promise((t,n)=>{const r=document.createElement("video");r.crossOrigin="anonymous",r.muted=!0,r.loop=!0,r.playsInline=!0,r.preload="auto",r.addEventListener("loadeddata",()=>{r.play().catch(()=>{}),t({element:r,owned:!0})},{once:!0}),r.addEventListener("error",()=>n(new Error("The glyph field could not load this video.")),{once:!0}),r.src=e});if("function"!=typeof createImageBitmap||"function"!=typeof fetch)return Jt(e);let t;try{t=await(await fetch(e).then(e=>{if(!e.ok)throw new Error("The glyph field could not load this image.");return e})).blob()}catch(t){if(t instanceof Error&&t.message.startsWith("The glyph field"))throw t;return Jt(e)}if(!/svg/i.test(t.type))try{return await $t(t)}catch{}const n=URL.createObjectURL(t);try{return await Jt(n)}finally{URL.revokeObjectURL(n)}})(e),{element:r,owned:o}=n;if(Ee||t!==le)return void(o&&r instanceof HTMLVideoElement?(r.pause(),r.removeAttribute("src"),r.load()):o&&r.close());Yt(),Kt(),oe=o&&r instanceof HTMLVideoElement?r:null,!o||r instanceof HTMLVideoElement||(se=r),ne=r,re="string"==typeof e||e instanceof HTMLImageElement||e instanceof HTMLVideoElement,ue=r instanceof HTMLVideoElement?r.videoHeight:r instanceof HTMLImageElement?r.naturalHeight:r.height,ie=n.natural?.[0]??(r instanceof HTMLVideoElement?r.videoWidth:r instanceof HTMLImageElement?r.naturalWidth:r.width),ae=n.natural?.[1]??ue,ce=!0,r instanceof HTMLVideoElement&&(e=>{const t=e;if(!t.requestVideoFrameCallback)return;const n=()=>{Ee||ne!==e||(ce=!0,It(),he=t.requestVideoFrameCallback(n))};he=t.requestVideoFrameCallback(n)})(r),we||bt(),be=!0,It()}catch(e){je&&t===le&&(je=!1,ze()),We(e)}};Et(),Ce();const Zt=m.source??null;return Zt?(le=1,Qt(Zt)):It(),{canvas:n,ready:Oe,get settings(){return y},update(e){const t=y,{element:r,rest:o}=g(e);"clear"in e&&(x&&x.element!==r?.element&&qt?.unobserve(x.element),x=r,r&&qt?.observe(r.element)),y=F(r?{...o,clear:y.clear}:o,y),Ce(),e.label&&n.setAttribute("aria-label",e.label),y.maxPixelRatio!==t.maxPixelRatio&&wt(),y.charset===t.charset&&y.cellSize===t.cellSize&&y.cellAspect===t.cellAspect&&y.font===t.font&&y.fontWeight===t.fontWeight&&y.glyphScale===t.glyphScale||(lt(),ut()),y.levels!==t.levels&&ft(),y.scope===t.scope||we||(yt(),vt=performance.now());((!!t.fluid&&"fluid"===D(t))!==tt()||y.fluid&&t.fluid&&y.fluid.resolution!==t.fluid.resolution)&&ot(),"source"in e&&Qt(e.source??null),be=!0,It()},setSource:Qt,pointer(e,t=0){if(null===e)return void Gt(null);const r=n.getBoundingClientRect();Gt(Bt(r.left+e,r.top+t))},redraw(){if(!(Ee||we||Te)&&W)try{Je(!0)&&(Ct(),je||(be=!1))}catch(e){Te=!0,We(e)}},pulse(e={}){if(Ee||Ve())return;const t=n.getBoundingClientRect();if(!t.width||!t.height)return;let r=e.x??t.width/2,o=e.y??t.height/2;if(e.element){const n=e.element.getBoundingClientRect();r=n.left+n.width/2-t.left,o=n.top+n.height/2-t.top}const i=Math.max(0,Math.min(2,e.strength??1));De=[...De,{x:r/t.width,y:o/t.height,born:performance.now(),strength:i}].slice(-4),It()},play(){Me=!1,ne instanceof HTMLVideoElement&&ne.play().catch(()=>{}),be=!0,It()},pause(){Me=!0,ne instanceof HTMLVideoElement&&ne.pause()},resize(){wt()&&It()},destroy(){if(!Ee&&(Ee=!0,ge&&cancelAnimationFrame(ge),Xt.removeEventListener("pointermove",Nt),Xt.removeEventListener("pointerdown",Nt),document.removeEventListener("pointerleave",Ht),Xt.removeEventListener("pointerleave",Ht),document.removeEventListener("visibilitychange",zt),qe?.removeEventListener?.("change",Ot),st?.removeEventListener?.("loadingdone",ht),n.removeEventListener("webglcontextlost",jt),n.removeEventListener("webglcontextrestored",Wt),qt?.disconnect(),Vt?.disconnect(),Yt(),Kt(),ne=null,!we)){nt(),Ze(),w.deleteTexture(C),w.deleteTexture(U);for(const e of[I,B,G])e&&w.deleteProgram(e.program);q?.dispose(),Ge&&w.deleteTexture(Ge),dt&&w.deleteTexture(dt),j.forEach(e=>w.deleteShader(e)),z&&w.deleteVertexArray(z)}}}},exports.normalizeFieldSettings=F;//# sourceMappingURL=field.cjs.map
1
+ "use strict";var e={none:3,flow:1,orb:2,drift:4,swell:5,caustics:6,contour:7,aurora:8,ripple:9,halo:10,interference:11,mesh:12,cascade:13,constellation:14},t=e=>e?"\nconst float VSCALE=6.;\nvec4 decodeFluid(vec4 t){return vec4((t.xy*2.-1.)*VSCALE,t.z,t.w);}\nvec4 encodeFluid(vec4 v){return vec4(clamp(v.xy/VSCALE*.5+.5,0.,1.),clamp(v.z,0.,1.),1.);}":"\nvec4 decodeFluid(vec4 t){return t;}\nvec4 encodeFluid(vec4 v){return vec4(v.xyz,1.);}",n=e=>`#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform sampler2D uSource, uFluid;\nuniform vec2 uResolution, uCell;\nuniform float uCount, uBlend;\nconst float BAYER[16]=float[16](0.,8.,2.,10.,12.,4.,14.,6.,3.,11.,1.,9.,15.,7.,13.,5.);\nuniform vec4 uSourceMap;\nuniform int uScene;\nuniform vec3 uInk, uHighlight;\nuniform vec4 uBackground;\nuniform float uBrightness, uContrast, uGamma, uInvert, uVignette, uSourceColor;\nuniform float uRefraction, uGlow, uTime, uDrift, uFluidOn, uLod, uSaturation, uBackdrop, uShade, uHighlightAuto, uFluidMode;\nuniform vec2 uFluidTexel;\nuniform int uHoverMode;\nuniform vec3 uLight;\nuniform vec3 uTrail[12];\nuniform float uLightRadius, uLightGain, uClock, uFlicker, uTrailAmount;\nuniform sampler2D uTrailMap, uScope;\nuniform float uScopeMode;\nuniform vec2 uLevels;\nuniform int uMark;\nuniform float uScale, uClearFeather, uClearShape;\nuniform vec4 uClear;\nuniform vec4 uPulse[4];\nlayout(location=0) out vec4 outInk;\nlayout(location=1) out vec4 outUnder;\n${t(e)}\nfloat hash(vec2 p){p=fract(p*vec2(123.34,456.21));p+=dot(p,p+45.32);return fract(p.x*p.y);}\nfloat noise(vec2 p){vec2 i=floor(p),f=fract(p),u=f*f*(3.-2.*f);\n return mix(mix(hash(i),hash(i+vec2(1,0)),u.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),u.x),u.y);}\nfloat fbm(vec2 p){float v=0.,a=.5;for(int i=0;i<5;i++){v+=a*noise(p);p=p*2.03+vec2(1.7,9.2);a*=.5;}return v;}\nvec3 generated(vec2 uv,float aspect){\n vec2 p=(uv-.5)*vec2(aspect,1.)*uScale;\n if(uScene==1){\n float t=uTime*.08;\n vec2 q=vec2(fbm(p*1.6+t),fbm(p*1.6-t+3.1));\n return vec3(smoothstep(.28,.86,fbm(p*1.8+q*1.6+vec2(t*.6,-t*.4))));\n }\n if(uScene==2){\n float r=.36,d=length(p),a=uTime*.25;\n vec3 l=normalize(vec3(cos(a)*.8,.55,sin(a)*.6+.6));\n if(d<r){\n vec3 n=normalize(vec3(p.x,-p.y,sqrt(r*r-d*d)));\n float diffuse=max(dot(n,l),0.),rim=pow(1.-n.z,2.5);\n float lon=atan(n.x,n.z)+uTime*.35,lat=asin(clamp(n.y,-1.,1.));\n float bands=.5+.25*sin(lat*14.)+.25*sin(lon*6.);\n return vec3(clamp(diffuse*.85+rim*.5+bands*.12,0.,1.));\n }\n return vec3(exp(-pow((d-r)*9.,2.))*.35);\n }\n if(uScene==4){\n // Drift: a few broad lobes that wander slowly. Built for halftone, where large soft shapes read best.\n float t=uTime*.045;\n vec2 q=p*1.15;\n vec2 w=vec2(fbm(q*.7+vec2(t,-t*.7)),fbm(q*.7+vec2(4.3-t*.8,t+1.7)));\n float n=fbm(q+w*1.3+vec2(t*.4,t*.25));\n return vec3(smoothstep(.36,.74,n));\n }\n if(uScene==5){\n // Swell: three crossing swells, the second bent by the first, so crests roll diagonally instead of pooling.\n float t=uTime;\n float s=sin((dot(p,vec2(.94,.33))/.95-t/9.)*6.2831853);\n float c=sin((dot(p,vec2(.6,-.8))/.58-t/13.)*6.2831853+s*.9);\n float k=sin((dot(p,vec2(-.29,.96))/.36+t/17.)*6.2831853);\n return vec3(smoothstep(.3,.9,.5+.5*(s*.5+c*.35+k*.15)));\n }\n // The kit's background scenes. Each starts a little way in, so a reduced-motion still is already composed.\n float t=uTime+40.,px=uCell.y/uResolution.y*uScale;\n if(uScene==6){\n // Caustics: light focused by a moving water surface. Two layers of warped sine waves drift against each other; each draws\n // smooth filaments along its zero line, about a character wide. Where they cross the light lifts a little, never to a blot.\n float tt=t*.12,a=0.,b=0.;\n for(int l=0;l<2;l++){\n float f=float(l),sc=5.4+f*2.4;\n vec2 q=(l==0?p:mat2(.8,-.6,.6,.8)*p)*sc;\n q+=vec2(sin(q.y*.45+tt*(1.+f*.3)),cos(q.x*.4-tt*(.8+f*.4)))*1.3;\n float v=sin(q.x+1.4*sin(q.y*.7+tt))+sin(q.y*1.1+1.2*sin(q.x*.8-tt*1.3))*.9;\n float wv=max(fwidth(v),1e-4);\n float line=(1.-smoothstep(.2,1.5,abs(v)/wv))*(l==0?.78:.62)+exp(-abs(v)/(wv*5.))*.16;\n if(l==0)a=line;else b=line;\n }\n float pulse=.85+.15*sin(tt*3.+p.x*1.7-p.y*1.1);\n float light=max(a,b)+.3*min(a,b);\n return vec3(clamp(light*light*pulse,0.,.78));\n }\n if(uScene==7){\n // Contour: a slow terrain read as survey lines about a character wide at any size; every fifth is an index line.\n float tt=t*.02;\n vec2 q=p*1.15+vec2(tt,-tt*.6);\n float h=noise(q)*.62+noise(q*2.07+3.1)*.27+noise(q*4.3-tt+7.)*.11;\n h+=.08*sin(tt*2.+p.x*.8);\n float k=h*13.,w=max(fwidth(k),1e-4),d=abs(fract(k+.5)-.5)/w;\n float major=mod(floor(k+.5),5.)<.5?1.:0.;\n return vec3((1.-smoothstep(.35,1.25-major*.25,d))*mix(.55,1.,major));\n }\n if(uScene==8){\n // Aurora: three curtains at different distances hang from the top. Far ones sit higher and dimmer; the nearest is tallest\n // and brightest. Each folds slowly and is brightest along its lower hem, fading upward. The rays are set per character\n // column, so the curtains read as vertical strokes at any stage size, from a small card to a phone.\n float tt=t*.05,a=0.,cw=uCell.x/uResolution.x;\n float col=floor(uv.x/cw+.5);\n for(int n=0;n<3;n++){\n float f=float(n),near=f/2.;\n float x=p.x*(1.3-near*.4)+f*3.7;\n float hem=-.28+near*.3+.16*sin(x*1.3+tt*(.9+f*.25)+f*2.)+.045*sin(x*3.4-tt*1.5+f);\n float d=hem-p.y;\n float body=d>0.?exp(-d/(.14+near*.26))*(.45+.55*exp(-d/.03)):exp(-d*d/.0002);\n float fold=.5+.5*sin(x*2.1+tt*.9+f*1.7+.7*sin(x*.8-tt*.6));\n float ray=mix(hash(vec2(col,f*7.1)),noise(vec2(col*.18+f*9.,tt*.7+f)),.55);\n float layer=clamp(body*(.1+.9*fold*fold)*(.2+.8*ray)*(.4+near*.6)*4.2,0.,1.);\n a=1.-(1.-a)*(1.-layer);\n }\n return vec3(smoothstep(.12,.9,a));\n }\n if(uScene==9){\n // Ripple: still water. Drops land here and there, each a few rings that widen and fade; the pointer drops its own.\n float tone=0.,g=.72;\n vec2 q=p/g,id=floor(q);\n for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){\n vec2 c=id+vec2(i,j),h=vec2(hash(c),hash(c+7.3));\n float period=5.+h.x*5.,age=fract(t*.3/period*4.+h.y);\n vec2 at=(c+.2+.6*h)*g;\n float d=length(p-at),r=age*.62;\n float rings=max(0.,cos((d-r)*34.))*exp(-pow((d-r)/.11,2.));\n tone+=rings*pow(1.-age,1.8)*smoothstep(0.,.06,age)*(.7+.3*h.x);\n }\n return vec3(clamp(tone*1.25,0.,1.));\n }\n if(uScene==10){\n // Halo: a slow breathing corona that frames the content, its rays turning. The ring fits the stage: wide on a desktop\n // hero, tall on a phone, so the whole halo stays on screen; the middle stays empty for a headline.\n vec2 r=vec2(min(.46,aspect*.4),min(.34,.36/max(aspect,.01)*.5+.2));\n vec2 e=p/r;\n float d=length(e),a=atan(e.y,e.x),tt=t*.07,k=min(r.x,r.y);\n float breathe=1.+.04*sin(tt*3.1);\n float rays=.5+.5*noise(vec2(a*3.2+tt,tt*.5))*(.6+.4*noise(vec2(a*7.-tt*1.2,3.+tt*.4)));\n float s=(d-breathe)*k;\n float rim=exp(-pow(s/.03,2.));\n float corona=exp(-max(0.,s)/(.1+.08*rays))*smoothstep(-.04,.015,s)*rays*smoothstep(.36,.12,s);\n return vec3(clamp(rim*(.55+.45*rays)+corona*.85,0.,1.));\n }\n if(uScene==11){\n // Interference: two ring grids from slowly orbiting centres. Where they cross, broad moire bands open and close.\n float tt=t*.05;\n vec2 a=vec2(-.3+.12*sin(tt),.07*cos(tt*1.3)),b=vec2(.3+.1*cos(tt*.8),-.06*sin(tt*1.1));\n float f=6.2831853/max(px*4.6,.004);\n float m=cos(length(p-a)*f)+cos(length(p-b)*f);\n return vec3(smoothstep(.7,2.,m));\n }\n if(uScene==12){\n // Mesh: four soft lights on slow Lissajous paths, a gradient mesh written in characters.\n float tt=t*.07,m=0.;\n for(int n=0;n<4;n++){\n float f=float(n)*1.7;\n vec2 c=vec2(.66*sin(tt*(.7+f*.13)+f),.34*cos(tt*(.9-f*.07)+f*1.3));\n float s=.3+.07*sin(tt+f);\n m+=exp(-dot(p-c,p-c)/(s*s))*(.8-float(n)*.1);\n }\n return vec3(smoothstep(.06,1.1,m));\n }\n if(uScene==13){\n // Cascade: streaks fall in three depths. Far ones are frequent, faint, short and slow; near ones rare, long, bright and\n // quick. Each has a bright head and a tail that fades behind it, and a column can carry two streaks at once.\n float tone=0.,cw=uCell.x/uResolution.x,ch=uCell.y/uResolution.y;\n float col=floor(uv.x/cw+.5);\n for(int n=0;n<3;n++){\n float f=float(n);\n for(int k=0;k<2;k++){\n float seed=f*13.1+float(k)*41.7,h=hash(vec2(col,seed));\n if(h<1.-(.5-f*.15))continue;\n float speed=(.045+f*.07)*(.75+.5*hash(vec2(col,seed+2.)));\n float tail=.12+f*.16,y=fract(t*speed+hash(vec2(col,seed+5.)))*(1.+tail*2.)-tail;\n float d=y-uv.y;\n if(d<0.||d>tail)continue;\n float head=d<ch*1.2?1.:0.;\n tone=max(tone,max(head*(.55+f*.22),pow(1.-d/tail,1.7)*(.28+f*.3)));\n }\n }\n return vec3(clamp(tone,0.,1.));\n }\n if(uScene==14){\n // Constellation: points wander in their own cells; neighbours close enough are linked by fine lines. Each point is a\n // bright core in a soft halo, so it reads at card size as well as full width.\n float g=.23,tt=t*.18;\n vec2 q=p/g,id=floor(q);\n vec2 pts[9];\n for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){\n vec2 c=id+vec2(i,j);\n float h=hash(c),k=hash(c+3.7);\n pts[(j+1)*3+i+1]=c+.5+.36*vec2(sin(tt*(.6+h)+h*6.28),cos(tt*(.5+k)+k*6.28));\n }\n float line=0.,star=0.,lw=max(px/g,.02);\n for(int n=0;n<9;n++){\n vec2 e=q-pts[n];\n float d2=dot(e,e),tw=.8+.2*sin(tt*3.+float(n)*1.7);\n star=max(star,max(exp(-d2/(lw*lw*1.6)),.38*exp(-d2/(lw*lw*7.)))*tw);\n for(int m=n+1;m<9;m++){\n vec2 a=pts[n],ba=pts[m]-a;\n float len=length(ba);\n if(len>1.35)continue;\n float hh=clamp(dot(q-a,ba)/dot(ba,ba),0.,1.);\n float d=length(q-a-ba*hh);\n line=max(line,(1.-smoothstep(lw*.3,lw*.75,d))*smoothstep(1.35,.6,len)*.72);\n }\n }\n return vec3(clamp(max(line,star),0.,1.));\n }\n return vec3(0.);\n}\n// Hover scope: 1 where the pointer response may act. The map holds the source's soft subject coverage in alpha.\nfloat hoverScope(vec2 uv){\n if(uScopeMode<.5||uScene!=0)return 1.;\n vec2 s=uv*uSourceMap.xy+uSourceMap.zw;\n float c=(s.x<0.||s.y<0.||s.x>1.||s.y>1.)?0.:texture(uScope,s).a;\n return uScopeMode<1.5?c:1.-c;\n}\nvoid main(){\n vec2 cell=floor(gl_FragCoord.xy);\n vec2 uv=(cell+.5)*uCell/uResolution;\n float aspect=uResolution.x/uResolution.y;\n float hs=hoverScope(uv);\n vec4 fluid=vec4(0.);\n // lift: signed tone change. The solver's flow brightens one side of each eddy and opens the other into gaps.\n float lift=0.,wake=0.,bend=1.,swirl=0.,speed=0.;\n if(uFluidOn>.5){\n vec4 raw=texture(uFluid,vec2(uv.x,1.-uv.y));\n if(uFluidMode>.5){\n vec2 v=raw.xy*uFluidTexel*vec2(aspect,1.)*hs;\n fluid=vec4(v,0.,1.);\n swirl=clamp(dot(v,vec2(.4,.65))*uGlow*.32,-.65,.65);\n speed=clamp(length(v)*uGlow*.055,0.,.38);\n bend=.4;\n } else {\n fluid=decodeFluid(raw);\n fluid.xyz*=hs;\n wake=clamp(fluid.z*uGlow,0.,1.);\n lift=wake*.55;\n }\n }\n vec2 drift=uDrift*.006*vec2(sin(uv.y*5.3+uTime*.6),cos(uv.x*4.1-uTime*.5));\n vec2 sampleAt=uv-vec2(fluid.x/aspect,-fluid.y)*uRefraction*bend+drift;\n float spot=0.;\n if(uHoverMode==4||uHoverMode==5){\n vec2 d=(uv-uLight.xy)*vec2(aspect,1.);\n float q2=dot(d,d)/(uLightRadius*uLightRadius*2.2);\n // Loupe: flat-topped zoom with a soft rim. Reveal: a soft spot in the source's colours.\n if(uHoverMode==4) sampleAt-=(uv-uLight.xy)*exp(-q2*q2)*.45*uLight.z*min(1.,uLightGain*1.6)*hs;\n else spot=exp(-q2*1.6)*uLight.z*min(1.,uLightGain*1.6)*hs;\n }\n vec3 rgb,glow=vec3(0.);\n if(uScene==0){\n vec2 s=sampleAt*uSourceMap.xy+uSourceMap.zw;\n bool inside=!(s.x<0.||s.y<0.||s.x>1.||s.y>1.);\n rgb=inside?textureLod(uSource,s,uLod).rgb:vec3(0.);\n if(uBackdrop>0.){\n vec2 b=(uv-vec2(fluid.x/aspect,-fluid.y)*uRefraction*bend*.5)*uSourceMap.xy+uSourceMap.zw;\n glow=(b.x<0.||b.y<0.||b.x>1.||b.y>1.)?vec3(0.):textureLod(uSource,b,uLod+3.).rgb*uBackdrop;\n }\n } else rgb=generated(sampleAt,aspect);\n float tone=dot(rgb,vec3(.2126,.7152,.0722));\n tone=clamp((tone-uLevels.x)/max(uLevels.y-uLevels.x,.01),0.,1.);\n tone=clamp((tone-.5)*uContrast+.5+uBrightness,0.,1.);\n tone=pow(tone,1./uGamma);\n if(uInvert>.5)tone=1.-tone;\n float flick=0.,trailFold=0.;\n // Reveal: under the spot the characters take the source's own colour and a little more ink.\n if(spot>0.)lift=spot*.22;\n if(uHoverMode==2){\n // Lantern: a soft light and its fading tail lift the characters they pass. Nothing moves the image.\n vec2 ap=vec2(aspect,1.),d=(uv-uLight.xy)*ap;\n float r2=uLightRadius*uLightRadius,glowL=uLight.z*exp(-dot(d,d)/r2);\n for(int i=0;i<12;i++){vec2 e=(uv-uTrail[i].xy)*ap;glowL+=uTrail[i].z*exp(-dot(e,e)/(r2*.55));}\n glowL=min(glowL,1.)*hs;\n float grain=fract(sin(dot(cell,vec2(12.9898,78.233)))*43758.5453);\n lift=glowL*uLightGain*(.7+.6*grain);\n wake=glowL*.4;\n // A few letters at the light's rim step up the ramp and back, as if being retyped.\n flick=uFlicker*step(.9,fract(grain*13.7+floor(uClock*7.+grain*5.)*.37))*glowL*(1.-glowL)*4.;\n }\n if(uHoverMode==3){\n // Trail: the studio's ink field, as a 16-bit density. Sparse marks fill in, dense marks open up.\n vec4 ink=texture(uTrailMap,uv);\n float density=(ink.r*65280.+ink.g*255.)/65535.*uTrailAmount;\n float t=clamp(density/.38,0.,1.);\n trailFold=t*t*(3.-2.*t)*hs;\n }\n if(uFluidMode>.5&&uHoverMode==1){\n // Dark ground: any motion lights the characters. Lit ground: the flow lights one side of each eddy and opens the other.\n // A little cell-to-cell grain keeps the lit area a shimmer of letters rather than a solid block.\n float grain=fract(sin(dot(cell,vec2(12.9898,78.233)))*43758.5453);\n lift=mix(abs(swirl)*.5+speed,swirl+speed*.35,smoothstep(.12,.55,tone))*(.65+.7*grain);\n wake=clamp(lift*1.6,0.,1.);\n }\n tone=clamp(tone+lift,0.,1.);\n tone+=(1.-2.*tone)*trailFold;\n // Pulses: rings sent by the interface (field.pulse()), e.g. on a save or a notification.\n for(int i=0;i<4;i++){\n if(uPulse[i].w<=0.)continue;\n float dist=length((uv-uPulse[i].xy)*vec2(aspect,1.)),front=uPulse[i].z*.95;\n float ring=exp(-pow((dist-front)/.1,2.))*uPulse[i].w*exp(-uPulse[i].z*.85);\n tone=clamp(tone+ring*.85,0.,1.);\n }\n tone*=1.-uVignette*smoothstep(.35,1.05,length((uv-.5)*vec2(min(aspect,1.8),1.)*2.));\n if(uClear.z>0.){\n // Clear zone: the field fades out around content so text above it stays readable.\n vec2 half_=uClear.zw*.5*vec2(aspect,1.),q=(uv-uClear.xy-uClear.zw*.5)*vec2(aspect,1.);\n float dz;\n if(uClearShape>.5){vec2 e=abs(q)-half_;dz=length(max(e,0.))+min(max(e.x,e.y),0.);}\n else dz=(length(q/max(half_,vec2(1e-4)))-1.)*min(half_.x,half_.y);\n tone*=smoothstep(0.,uClearFeather,dz);\n }\n // Blend: a shade between two characters takes the upper one in the share of cells a 4x4 Bayer pattern gives it.\n float level=tone*(uCount-1.),upper=fract(level)>=.5?1.:0.;\n if(uBlend>.5&&tone>.02&&tone<.98){\n ivec2 q=ivec2(mod(gl_FragCoord.xy,4.));\n upper=fract(level)>(BAYER[q.y*4+q.x]+.5)/16.?1.:0.;\n }\n float index=min(uCount-1.,floor(level)+upper+(flick>.5&&tone>.02?1.:0.));\n vec3 hue=rgb/max(max(rgb.r,rgb.g),max(rgb.b,.03));\n hue=mix(vec3(dot(hue,vec3(.2126,.7152,.0722))),hue,uSaturation);\n vec3 ink=mix(uInk*mix(1.,.3+.7*tone,uShade),clamp(hue*(.38+.62*tone),0.,1.),uSourceColor);\n vec3 lifted=uHighlightAuto>.5?ink/max(max(ink.r,ink.g),max(ink.b,.06)):uHighlight;\n ink=mix(ink,lifted,wake*.7);\n if(spot>0.)ink=mix(ink,clamp(rgb/max(max(rgb.r,rgb.g),max(rgb.b,.08))*(.45+.55*tone),0.,1.),spot);\n float underAlpha=max(uBackground.a,min(1.,max(glow.r,max(glow.g,glow.b))));\n vec3 under=min(uBackground.rgb*uBackground.a+glow,vec3(underAlpha));\n // Glyphs keep their atlas index, exact in 8 bits; the other marks keep the tone, and empty where the charset is blank.\n outInk=vec4(ink,uMark==0?index/255.:uMark==1?(tone>.003?tone:0.):index>0.?max(tone,1./255.):0.);\n outUnder=vec4(under,underAlpha);\n}`,r="#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform sampler2D uAtlas, uCells, uUnder;\nuniform vec2 uResolution, uCell, uPitch;\nuniform float uColumns, uDotScale, uSourceColor;\nuniform int uMark;\nout vec4 outColor;\nconst float BAYER[16]=float[16](0.,8.,2.,10.,12.,4.,14.,6.,3.,11.,1.,9.,15.,7.,13.,5.);\n// The Studio's print defaults: screen angle -35deg, roughness .35, seed 7, registration .2 and its coral second ink.\nconst vec2 DIR=vec2(.81915,-.57358);\nconst float ROUGH=.35,SEED=7.;\nconst vec3 SECOND=vec3(.925,.404,.322);\nfloat hash(vec2 p){p=fract(p*vec2(123.34,456.21));p+=dot(p,p+45.32);return fract(p.x*p.y);}\n// Coverage of a signed distance given in device pixels.\nfloat cover(float d){return clamp(.5-d,0.,1.);}\nfloat box(vec2 p,vec2 lo,vec2 hi){vec2 a=clamp(p-lo,0.,1.)*clamp(hi-p,0.,1.);return a.x*a.y;}\nfloat disc(vec2 p,vec2 c,float r){return r>.05?cover(length(p-c)-r):0.;}\nfloat ellipse(vec2 p,vec2 c,vec2 r,float a){vec2 d=p-c;d=vec2(cos(a)*d.x+sin(a)*d.y,-sin(a)*d.x+cos(a)*d.y);float k=length(d/r);return cover((k-1.)*min(r.x,r.y));}\n// World-anchored parallel cuts across direction d: period and width in cell heights, so lines run on from cell to cell.\nfloat cuts(vec2 w,vec2 d,float period,float width,float px){\n if(width<=0.)return 0.;\n float proj=dot(vec2(-d.y,d.x),w);\n return cover((abs(fract(proj/period+.5)-.5)*period-width*.5)*px);\n}\n// Lays an ink over what is already down, multiplying where they overlap, as transparent inks do on paper.\nvoid lay(inout vec3 rgb,inout float a,vec3 c,float k){\n float next=a+k*(1.-a);\n rgb=next>0.?(rgb*a*(1.-k)+mix(c,rgb*c,a)*k)/next:c;\n a=next;\n}\nvoid main(){\n vec2 frag=vec2(gl_FragCoord.x,uResolution.y-gl_FragCoord.y);\n // The pitch is the atlas cell, or a fractional one under cellFit 'fill', where each glyph sits centred in its stretched cell.\n vec2 cell=floor(frag/uPitch);\n vec4 ink=texelFetch(uCells,ivec2(cell),0),under=texelFetch(uUnder,ivec2(cell),0);\n vec2 local=frag-cell*uPitch;\n float coverage;\n vec3 rgb=ink.rgb;\n if(uMark==0){\n float index=floor(ink.a*255.+.5);\n ivec2 tile=ivec2(int(mod(index,uColumns)),int(floor(index/uColumns)));\n vec2 texel=floor(local-floor((uPitch-uCell)*.5));\n coverage=all(greaterThanEqual(texel,vec2(0.)))&&all(lessThan(texel,uCell))?texelFetch(uAtlas,tile*ivec2(uCell)+ivec2(texel),0).a:0.;\n } else if(uMark==1){\n // Halftone: dot area follows tone, so midtones read true; edges are antialiased to one device pixel.\n float r=sqrt(ink.a)*min(uPitch.x,uPitch.y)*.5*uDotScale;\n coverage=ink.a>.003?clamp(r-length(local-uPitch*.5)+.5,0.,1.):0.;\n } else if(ink.a<=0.){\n coverage=0.;\n } else {\n float tone=ink.a,side=min(uPitch.x,uPitch.y);\n vec2 q=local/uPitch,c=uPitch*.5,p=local+.5;\n // Tiles fade with the tone in one ink, as the Studio's do; in source colour the colour already carries it.\n float fade=uSourceColor>.5?1.:tone,gap=max(.5,uPitch.x*.06),grain=hash(cell+SEED);\n vec2 w=(cell+q)*uPitch/uPitch.y;\n if(uMark==2)coverage=fade;\n else if(uMark==3)coverage=box(p,vec2(0.),uPitch-gap)*fade;\n else if(uMark==4){\n // Lego: a gapped brick, lit from above, with a raised stud ringed by its shadow.\n coverage=box(p,vec2(0.),uPitch-gap)*fade;\n rgb*=1.06-.14*q.y;\n float r=side*.28,d=length(local-c)-r,lit=clamp(dot(c-local,vec2(.6,.8))/r,-1.,1.);\n rgb=mix(rgb,mix(rgb,vec3(1.),.2+.12*lit),cover(d));\n rgb=mix(rgb,rgb*.72,cover(abs(d)-max(.5,side*.04)));\n } else if(uMark==5){\n // Voxel: an isometric cube; top, left and right faces at full, .72 and .42 strength.\n float h=.5*abs(q.x-.5);\n coverage=cover(-min(q.y-h,1.-h-q.y)*uPitch.y)*cover(-min(q.x,1.-q.x)*uPitch.x);\n coverage*=mix(q.x<.5?.72:.42,1.,cover((q.y-(.5-h))*uPitch.y))*fade;\n } else if(uMark==6){\n // Disco: a gapped mirror tile, its upper facet catching light and its lower in shade.\n coverage=box(p,vec2(0.),uPitch-gap)*fade;\n rgb=q.y<.35?mix(rgb,vec3(1.),.1+grain*.25):q.y>.65?rgb*.75:rgb;\n } else if(uMark==7){\n // Dither: an ordered 4x4 Bayer screen at about five dots a cell, lit where the cell's tone passes the threshold.\n ivec2 b=ivec2(mod(floor(frag/max(1.,floor(side/5.))),4.));\n coverage=tone>(BAYER[b.y*4+b.x]+.5)/16.?1.:0.;\n } else if(uMark==8){\n // Hex: a flat-topped hexagon filling the cell.\n vec2 h=abs((local-c)/(uPitch*.49));\n coverage=cover(max(h.y-.866,h.x*.866+h.y*.5-.866)*side*.49)*fade;\n } else if(uMark==9){\n // LED: a round lamp with a soft halo and a specular glint, separated by an unlit matrix.\n float r=side*.39,d=length(local-c);\n coverage=max(cover(d-r),.3*exp(-pow(max(0.,d-r)/(side*.12),2.)))*fade;\n rgb=mix(rgb,vec3(1.),.35*disc(local,uPitch*vec2(.43,.4),side*.11));\n } else if(uMark==10){\n // CMYK: the cell's hue separated into offset cyan, magenta and yellow dots, each sized by its share of the tone. The\n // key screen carries the neutral share in the ink's own lightness, since a light ink on a dark page has no black.\n float top=max(rgb.r,max(rgb.g,rgb.b)),low=min(rgb.r,min(rgb.g,rgb.b));\n vec3 cmy=(top-rgb)/max(top,.001);\n float a=0.;vec3 col=vec3(1.);\n lay(col,a,vec3(top),disc(local,c,side*.48*sqrt(tone*low/max(top,.001))));\n lay(col,a,vec3(0.,1.,1.),disc(local,uPitch*vec2(.36,.36),side*.48*sqrt(tone*cmy.x)));\n lay(col,a,vec3(1.,0.,1.),disc(local,uPitch*vec2(.64,.36),side*.48*sqrt(tone*cmy.y)));\n lay(col,a,vec3(1.,1.,0.),disc(local,uPitch*vec2(.5,.66),side*.48*sqrt(tone*cmy.z)));\n rgb=col;coverage=a;\n } else if(uMark==11||uMark==16){\n // Stipple and pointillism: four jittered marks a cell, their size following the tone.\n coverage=0.;vec3 col=rgb;\n for(int m=0;m<4;m++){\n vec2 o=vec2(float(m%2),float(m/2));\n float j=hash(cell*2.+o+SEED),jy=hash(cell+o*11.+SEED+1.);\n vec2 at=((o+.5)/2.+(vec2(j,jy)-.5)*ROUGH*.28)*uPitch;\n float r=min(min(min(at.x,uPitch.x-at.x),min(at.y,uPitch.y-at.y)),side*min(.245,.21*sqrt(tone)*(1.-ROUGH*j*.35)));\n float k=uMark==11?disc(local,at,r):ellipse(local,at,vec2(r,r*.64),j*3.14159);\n if(uMark==16&&k>coverage)col=uSourceColor>.5?clamp(rgb+(j-.5)*ROUGH*.25*vec3(1.,-.4,-1.),0.,1.):rgb*(1.+(j-.5)*ROUGH*.5);\n coverage=max(coverage,k);\n }\n rgb=col;\n } else if(uMark==12||uMark==13){\n // Engraving and crosshatch: parallel cuts whose weight follows the tone; crossings join only in the darker tones.\n float cv=tone*(1.-ROUGH*grain*.3),px=uPitch.y;\n coverage=cuts(w,DIR,.5,min(.47,.36*cv),px);\n if(uMark==13){\n coverage=max(coverage,cuts(w,vec2(-DIR.y,DIR.x),.5,min(.47,.36*max(0.,cv*1.5-.3)),px)*step(.2,cv));\n coverage=max(coverage,cuts(w,normalize(DIR+vec2(-DIR.y,DIR.x)),.5,min(.47,.36*max(0.,cv*2.-1.2)),px)*step(.6,cv));\n }\n } else if(uMark==14){\n // Woodblock: broad carved bands in five stepped weights, their edges wavering along the grain.\n float cv=ceil(tone*(1.-ROUGH*grain*.3)*5.)/5.,width=min(.94,.72*cv);\n float proj=dot(vec2(-DIR.y,DIR.x),w),line=floor(proj+.5),along=dot(DIR,w);\n float cut=sin(along*5.3+line*1.9+SEED)*.5+sin(along*13.1+line)*.25;\n coverage=cover((abs(proj-line)-width*.5*(1.+ROUGH*cut*.5))*uPitch.y);\n } else if(uMark==15){\n // Risograph: two offset screens, the main ink and the coral second ink, misregistered along the screen angle.\n float split=uSourceColor>.5?clamp(.5+(rgb.r-rgb.b)*.5,0.,1.):.5,r=side*min(.48,.44*sqrt(tone));\n float a=0.;vec3 col=rgb;\n lay(col,a,rgb,disc(local,c,r*sqrt(.35+(1.-split)*.65)));\n lay(col,a,SECOND,disc(local,c+DIR*.2*.38*side,r*sqrt(.3+split*.7)*(1.-ROUGH*hash(cell+SEED+13.)*.3)));\n rgb=col;coverage=a;\n } else coverage=0.;\n }\n outColor=vec4(rgb*coverage+under.rgb*(1.-coverage),coverage+under.a*(1.-coverage));\n}",i="#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform vec2 uTexel;\nout vec4 outColor;\nvec2 here(){return gl_FragCoord.xy*uTexel;}\n",o=i+"\nuniform sampler2D uVelocity;\nuniform vec2 uFrom, uTo, uForce;\nuniform float uAspect, uRadius;\nfloat segment(vec2 p,vec2 a,vec2 b){vec2 pa=p-a,ba=b-a;float h=clamp(dot(pa,ba)/max(dot(ba,ba),1e-8),0.,1.);return length(pa-ba*h);}\nvoid main(){\n vec2 uv=here(),scale=vec2(uAspect,1.);\n float d=segment(uv*scale,uFrom*scale,uTo*scale);\n outColor=vec4(texture(uVelocity,uv).xy+uForce*exp(-d*d/(uRadius*uRadius)),0.,1.);\n}",a=i+"\nuniform sampler2D uVelocity;\nvoid main(){\n vec2 uv=here();\n float l=texture(uVelocity,uv-vec2(uTexel.x,0.)).y,r=texture(uVelocity,uv+vec2(uTexel.x,0.)).y;\n float t=texture(uVelocity,uv+vec2(0.,uTexel.y)).x,b=texture(uVelocity,uv-vec2(0.,uTexel.y)).x;\n outColor=vec4(.5*(r-l-t+b),0.,0.,1.);\n}",l=i+"\nuniform sampler2D uVelocity, uCurl;\nuniform float uStrength, uDt;\nvoid main(){\n vec2 uv=here();\n float l=texture(uCurl,uv-vec2(uTexel.x,0.)).x,r=texture(uCurl,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uCurl,uv+vec2(0.,uTexel.y)).x,b=texture(uCurl,uv-vec2(0.,uTexel.y)).x,c=texture(uCurl,uv).x;\n vec2 force=.5*vec2(abs(t)-abs(b),abs(r)-abs(l));\n force=force/(length(force)+1e-4)*uStrength*c;\n force.y=-force.y;\n outColor=vec4(clamp(texture(uVelocity,uv).xy+force*uDt,-1000.,1000.),0.,1.);\n}",s=i+"\nuniform sampler2D uVelocity;\nvoid main(){\n vec2 uv=here(),c=texture(uVelocity,uv).xy;\n float l=texture(uVelocity,uv-vec2(uTexel.x,0.)).x,r=texture(uVelocity,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uVelocity,uv+vec2(0.,uTexel.y)).y,b=texture(uVelocity,uv-vec2(0.,uTexel.y)).y;\n if(uv.x-uTexel.x<0.)l=-c.x;\n if(uv.x+uTexel.x>1.)r=-c.x;\n if(uv.y+uTexel.y>1.)t=-c.y;\n if(uv.y-uTexel.y<0.)b=-c.y;\n outColor=vec4(.5*(r-l+t-b),0.,0.,1.);\n}",c=i+"\nuniform sampler2D uSource;\nuniform float uAmount;\nvoid main(){outColor=vec4(texture(uSource,here()).x*uAmount,0.,0.,1.);}",u=i+"\nuniform sampler2D uPressure, uDivergence;\nvoid main(){\n vec2 uv=here();\n float l=texture(uPressure,uv-vec2(uTexel.x,0.)).x,r=texture(uPressure,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uPressure,uv+vec2(0.,uTexel.y)).x,b=texture(uPressure,uv-vec2(0.,uTexel.y)).x;\n outColor=vec4((l+r+b+t-texture(uDivergence,uv).x)*.25,0.,0.,1.);\n}",h=i+"\nuniform sampler2D uPressure, uVelocity;\nvoid main(){\n vec2 uv=here();\n float l=texture(uPressure,uv-vec2(uTexel.x,0.)).x,r=texture(uPressure,uv+vec2(uTexel.x,0.)).x;\n float t=texture(uPressure,uv+vec2(0.,uTexel.y)).x,b=texture(uPressure,uv-vec2(0.,uTexel.y)).x;\n outColor=vec4(texture(uVelocity,uv).xy-vec2(r-l,t-b),0.,1.);\n}",f=i+"\nuniform sampler2D uVelocity;\nuniform float uDt, uDissipation;\nvoid main(){\n vec2 uv=here();\n vec2 back=uv-uDt*texture(uVelocity,uv).xy*uTexel;\n outColor=vec4(texture(uVelocity,back).xy/(1.+uDissipation*uDt),0.,1.);\n}";var d=new Set,m=0,p=0,g=null,v=[],x=0,E=1,y=0,w=0;function b(e){m=0,x&&e>x&&(v.push(e-x),v.length>120&&v.shift()),x=e,p=performance.now();const t=[...d];d.clear();for(const n of t)try{n(e)}catch(e){"undefined"!=typeof console&&console.error(e)}te?.endFrame(e);const n=performance.now()-p;if(y=.9*y+.1*n,e-w>500){w=e;const t=R(),n=!!te?.overloaded;(y>.5*t||n)&&E<3?E++:y<.2*t&&!n&&E>1&&E--}d.size||(x=0)}function T(e){d.add(e),m&&g!==requestAnimationFrame&&(m=0),m||(g=requestAnimationFrame,m=requestAnimationFrame(b))}function M(e){d.delete(e),!d.size&&m&&(cancelAnimationFrame(m),m=0,x=0)}function R(){if(v.length<20)return 1e3/60;const e=[...v].sort((e,t)=>e-t);return Math.min(1e3/60,Math.max(1e3/360,e[Math.floor(.2*e.length)]))}var A=new Set,F=new Set,k=new Set,S=new Set,_=new Set,L=!1,D=null,P=null,C=null,U=null,I=e=>{let t=null;for(const n of A){if(n.target===window){(!n.near||n.near()||n.inside)&&n.move(e);continue}t??(t=e.composedPath());t.includes(n.target)?(n.inside=!0,n.move(e)):n.inside&&(n.inside=!1,n.leave())}},B=()=>{for(const e of A)e.inside=!1,e.leave()},N=()=>{for(const e of[...F])e()},G=()=>{for(const e of[...k])e()},X=()=>{for(const e of[...S])e()},q=e=>{for(const t of[..._])t(e)};function H(){const e=A.size+F.size+k.size+S.size+_.size>0;if("undefined"==typeof document)return;if(D!==document&&(L=!1,D=document,P=C=null,U=null),e===L)return;L=e;const t=e?"addEventListener":"removeEventListener";if("undefined"!=typeof window&&(window[t]?.("pointermove",I,{capture:!0,passive:!0}),window[t]?.("pointerdown",I,{capture:!0,passive:!0})),document[t]?.("pointerleave",B),document[t]?.("visibilitychange",N),("undefined"==typeof document?void 0:document.fonts)?.[t]?.("loadingdone",q),P??(P="function"==typeof matchMedia?matchMedia("(prefers-reduced-motion: reduce)"):null),C??(C="function"==typeof matchMedia?matchMedia("(prefers-color-scheme: dark)"):null),P?.[t]?.("change",G),C?.[t]?.("change",X),e){U??(U="function"==typeof MutationObserver?new MutationObserver(X):null);for(const e of[document.documentElement,document.body])e&&U?.observe(e,{attributes:!0,attributeFilter:["class","data-theme","data-mode","style"]})}else U?.disconnect()}var z=(e,t)=>(e.add(t),H(),()=>{e.delete(t)&&H()});function V(e){const t=e.target;if("undefined"==typeof window||t===window||"undefined"==typeof document)return z(A,e);const n=t,r=n.getRootNode?.();if(n.ownerDocument===document&&(!r||r===document))return z(A,e);const i=e.move,o=()=>e.leave();return n.addEventListener("pointermove",i,{passive:!0}),n.addEventListener("pointerdown",i,{passive:!0}),n.addEventListener("pointerleave",o),()=>{n.removeEventListener("pointermove",i),n.removeEventListener("pointerdown",i),n.removeEventListener("pointerleave",o)}}var O=new Map,j=null,W=new Map,Y=e=>t=>{for(const n of t)for(const t of[...e.get(n.target)??[]])t(n)},K=(e,t,n)=>{const r=e.get(t);return r?(r.add(n),!1):(e.set(t,new Set([n])),!0)},$=(e,t,n)=>{const r=e.get(t);return!(!r?.delete(n)||r.size)&&(e.delete(t),!0)};function Q(e,t){return"function"!=typeof ResizeObserver?()=>{}:(j??(j=new ResizeObserver(Y(O))),K(O,e,t)?j.observe(e):queueMicrotask(()=>{O.get(e)?.has(t)&&t({target:e})}),()=>{$(O,e,t)&&j?.unobserve(e),O.size||(j?.disconnect(),j=null)})}var J=268435456,Z=[1,.85,.7,.58,.5],ee=class{constructor(){this.lost=!1,this.level=0,this.programs=new Map,this.atlases=new Map,this.vertex=null,this.vao=null,this.clients=new Set,this.parallel=null,this.timer=null,this.queries=[],this.open=null,this.drew=!1,this.gpuMs=[],this.cpuMs=[],this.changedAt=0,this.lostTimer=0,this.renderer="",this.overloaded=!1,this.onLost=e=>{e.preventDefault(),this.lost=!0,this.reset();for(const e of[...this.clients])e.lost();clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{if(this.lost){this.canvas.removeEventListener?.("webglcontextlost",this.onLost),this.canvas.removeEventListener?.("webglcontextrestored",this.onRestored);try{this.create()}catch{return}this.restored()}},1e3)},this.onRestored=()=>{clearTimeout(this.lostTimer),this.lost=!1,this.restored()},this.idleTimer=0,this.create()}create(){let e=null,t=null;const i={alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!0,powerPreference:"high-performance"};if("undefined"!=typeof document&&(e=document.createElement("canvas"),t=e.getContext("webgl2",i)),!t&&"function"==typeof OffscreenCanvas)try{e=new OffscreenCanvas(1,1),t=e.getContext("webgl2",i)}catch{t=null}if(!t||!e)throw new Error("WebGL2 is not available for the glyph field.");this.canvas=e,this.gl=t,this.lost=!1,e.width=e.height=1,this.parallel=t.getExtension("KHR_parallel_shader_compile"),this.timer=t.getExtension("EXT_disjoint_timer_query_webgl2");const o=t.getExtension("WEBGL_debug_renderer_info");this.renderer=String(t.getParameter(o?o.UNMASKED_RENDERER_WEBGL:t.RENDERER)??""),e.addEventListener?.("webglcontextlost",this.onLost),e.addEventListener?.("webglcontextrestored",this.onRestored);const a=!t.getExtension("EXT_color_buffer_float")&&!t.getExtension("EXT_color_buffer_half_float");this.program(n(a)),this.program(r)}restored(){for(const e of[...this.clients])e.restored()}reset(){this.programs.clear(),this.atlases.clear(),this.vertex=null,this.vao=null,this.queries=[],this.open=null,this.gpuMs=[],this.cpuMs=[]}join(e){this.clients.add(e),clearTimeout(this.idleTimer)}leave(e){this.clients.delete(e),this.clients.size?this.fit():(this.lost||(this.canvas.width=this.canvas.height=1,this.level=0),clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.clients.size||this.dispose()},3e3))}dispose(){if(clearTimeout(this.lostTimer),this.canvas.removeEventListener?.("webglcontextlost",this.onLost),this.canvas.removeEventListener?.("webglcontextrestored",this.onRestored),!this.lost)try{this.gl.getExtension("WEBGL_lose_context")?.loseContext()}catch{}this.reset(),te===this&&(te=null)}program(e){const t=this.programs.get(e);if(t)return t;const n=this.gl,r=(e,t)=>{const r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r};this.vertex??(this.vertex=r(n.VERTEX_SHADER,"#version 300 es\nvoid main(){vec2 p=vec2((gl_VertexID<<1)&2,gl_VertexID&2);gl_Position=vec4(p*2.-1.,0.,1.);}"));const i=n.createProgram(),o=r(n.FRAGMENT_SHADER,e);n.attachShader(i,this.vertex),n.attachShader(i,o),n.linkProgram(i);const a={program:i,locations:null,fragment:o};return this.programs.set(e,a),a}linked(e,t=!1){if(e.locations)return!0;const n=this.gl;if(!t&&this.parallel&&!n.getProgramParameter(e.program,this.parallel.COMPLETION_STATUS_KHR))return!1;if(!n.getProgramParameter(e.program,n.LINK_STATUS)){if(n.isContextLost())return!1;throw new Error(e.fragment&&n.getShaderInfoLog(e.fragment)||n.getProgramInfoLog(e.program)||"Glyph field program failed to link.")}const r={};for(let t=n.getProgramParameter(e.program,n.ACTIVE_UNIFORMS)-1;t>=0;t--){const i=n.getActiveUniform(e.program,t).name.replace(/\[0\]$/,"");r[i]=n.getUniformLocation(e.program,i)}return e.locations=r,!0}get canCompileInParallel(){return!!this.parallel}vertexArray(){return this.vao??(this.vao=this.gl.createVertexArray())}atlas(e,t,n){let r=this.atlases.get(e);if(r)r.refs||(this.atlases.delete(e),this.atlases.set(e,r));else{const n=this.gl,i=n.createTexture();n.bindTexture(n.TEXTURE_2D,i);for(const[e,t]of[[n.TEXTURE_MIN_FILTER,n.NEAREST],[n.TEXTURE_MAG_FILTER,n.NEAREST],[n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE],[n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE]])n.texParameteri(n.TEXTURE_2D,e,t);r={key:e,texture:i,refs:0,final:!1,users:new Set,bytes:0},this.atlases.set(e,r),this.paintAtlas(r,t)}return r.refs++,r.users.add(n),r}paintAtlas(e,t){const n=this.gl,{image:r,final:i}=t();n.bindTexture(n.TEXTURE_2D,e.texture),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.texImage2D(n.TEXTURE_2D,0,n.RGBA8,n.RGBA,n.UNSIGNED_BYTE,r),e.bytes=r.width*r.height*4,e.final=i;for(const t of[...e.users])t()}releaseAtlas(e,t){e&&e.users.delete(t)&&(--e.refs>0||this.evictAtlases())}evictAtlases(){const e=[...this.atlases.values()].filter(e=>!e.refs);let t=e.length-8;for(const n of e){if(t<=0&&!this.overBudget)break;t--,this.atlases.delete(n.key),this.lost||this.gl.deleteTexture(n.texture)}}fit(){if(this.lost)return;let e=1,t=1;for(const n of this.clients){const[r,i]=n.size();e=Math.max(e,r),t=Math.max(t,i)}const n=this.canvas,r=e=>256*Math.ceil(e/256);n.width*n.height>r(e)*r(t)*2&&(n.width=r(e),n.height=r(t))}get bytes(){let e=this.canvas.width*this.canvas.height*4*2;for(const t of this.clients)e+=t.bytes();for(const t of this.atlases.values())e+=t.bytes;return e}get overBudget(){return this.bytes>J}get roomy(){return this.bytes<228170137.6}begin(e,t){const n=this.canvas;if(n.width<e||n.height<t){const r=e=>256*Math.ceil(e/256);n.width=Math.max(n.width,r(e)),n.height=Math.max(n.height,r(t))}if(!this.drew&&(this.drew=!0,this.timer&&!this.open&&this.queries.length<4)){const e=this.gl.createQuery();e&&(this.gl.beginQuery(this.timer.TIME_ELAPSED_EXT,e),this.open=e)}}present(e,t,n){e.globalCompositeOperation="copy",e.imageSmoothingEnabled=!1,e.drawImage(this.canvas,0,this.canvas.height-n,t,n,0,0,t,n)}endFrame(e){if(this.lost)return void(this.drew=!1);const t=this.gl,n=this.timer;if(this.drew&&(this.cpuMs.push(performance.now()-p),this.cpuMs.length>60&&this.cpuMs.shift(),n&&this.open&&(t.endQuery(n.TIME_ELAPSED_EXT),this.queries.push({query:this.open,frame:e}),this.open=null)),this.drew=!1,n){const e=t.getParameter(n.GPU_DISJOINT_EXT);for(;this.queries.length&&t.getQueryParameter(this.queries[0].query,t.QUERY_RESULT_AVAILABLE);){const{query:n}=this.queries.shift();e||(this.gpuMs.push(t.getQueryParameter(n,t.QUERY_RESULT)/1e6),this.gpuMs.length>60&&this.gpuMs.shift()),t.deleteQuery(n)}}this.adapt(e)}adapt(e){const t=R(),n=this.gpuMs.length>=5&&Math.min(...this.gpuMs.slice(-5))>1.5*t,r=this.gpuMs.length>=10||n?this.gpuMs:null;let i;if(r)i=[...r].sort((e,t)=>e-t)[Math.floor(.75*r.length)]/t;else{if(v.length<30||this.cpuMs.length<10)return;const e=v.slice(-30).sort((e,t)=>e-t),n=[...this.cpuMs].sort((e,t)=>e-t)[this.cpuMs.length>>1];i=e[Math.floor(.75*e.length)]/t>1.6&&n<.5*t?1:.5}if(this.overloaded=i>.8&&this.atMinimum,e-this.changedAt<(i>.8?800:4e3))return;let o=this.level;if(i>2?o=Z.length-1:i>.8&&o<Z.length-1?o++:i<.3&&o>0&&o--,o!==this.level){this.level=o,this.changedAt=e,this.gpuMs=[],this.cpuMs=[];for(const e of[...this.clients])e.rescale()}}get scale(){return Z[this.level]}get atMinimum(){return this.level===Z.length-1}},te=null,ne=!1;function re(){if(te||ne)return te;try{te=new ee}catch{ne=!0}return te}var ie=new WeakSet,oe=class{constructor(e,t){this.previous=null,this.peak=0,this.width=e,this.height=t;const n=e*t;this.pixels=new Uint8Array(4*n),this.signal=new Float32Array(n),this.offsetX=new Float32Array(n),this.offsetY=new Float32Array(n),this.driftX=new Float32Array(n),this.driftY=new Float32Array(n),this.u=new Float32Array(n),this.v=new Float32Array(n),this.ink=new Float32Array(n),this.a=new Float32Array(n),this.b=new Float32Array(n),this.c=new Float32Array(n),this.pressure=new Float32Array(n),this.pressureNext=new Float32Array(n),this.divergence=new Float32Array(n),this.curl=new Float32Array(n)}get active(){return this.peak>2e-4}clear(){for(const e of[this.u,this.v,this.ink,this.a,this.b,this.c,this.pressure,this.pressureNext,this.divergence,this.curl,this.signal,this.pixels,this.offsetX,this.offsetY,this.driftX,this.driftY])e.fill(0);this.previous=null,this.peak=0}leave(){this.previous=null}move(e,t,n,r=performance.now()){if(!Number.isFinite(e+t+n+r))return;e=Math.max(0,Math.min(1,e)),t=Math.max(0,Math.min(1,t)),n=Math.max(.1,Math.min(1,n));const i=this.previous;if(this.previous={x:e,y:t,time:r},!i)return;const o=(e-i.x)*(this.width-1),a=(t-i.y)*(this.height-1),l=Math.hypot(o,a);if(l<.001)return;const s=Math.min(this.width,this.height),c=r>i.time?Math.max(1/240,(r-i.time)/1e3):1/60,u=Math.min(12,l/s/c),h=1-Math.exp(-u/2.2),f=s*(.022+.075*n)*(.65+.95*h),d=Math.min(128,Math.max(1,Math.ceil(l/(.4*f)))),m=l/f*(.32+.22*h)/d,p=o/l,g=a/l,v=-g,x=p,E=l*(2+18*h)/d;for(let n=0;n<d;n++){const r=(n+.5)/d,o=(i.x+(e-i.x)*r)*(this.width-1),a=(i.y+(t-i.y)*r)*(this.height-1),l=Math.max(1,Math.floor(o-3*f)),s=Math.min(this.width-2,Math.ceil(o+3*f)),c=Math.max(1,Math.floor(a-3*f)),u=Math.min(this.height-2,Math.ceil(a+3*f));for(let e=c;e<=u;e++)for(let t=l;t<=s;t++){const n=((t-o)*p+(e-a)*g)/f,r=((t-o)*v+(e-a)*x)/f,i=Math.exp(-n*n*.65-r*r*1.7),l=e*this.width+t;this.ink[l]=1-(1-this.ink[l])*Math.exp(-i*m);const s=1-r*r*.55,c=n*r*.7;this.u[l]=Math.max(-80,Math.min(80,this.u[l]+(p*s+v*c)*i*E)),this.v[l]=Math.max(-80,Math.min(80,this.v[l]+(g*s+x*c)*i*E))}}this.peak=1}read(e,t,n){const r=0|(t=Math.max(.5,Math.min(this.width-1.5,t))),i=0|(n=Math.max(.5,Math.min(this.height-1.5,n))),o=t-r,a=n-i,l=i*this.width+r;return(e[l]*(1-o)+e[l+1]*o)*(1-a)+(e[l+this.width]*(1-o)+e[l+this.width+1]*o)*a}sample(e,t){return this.read(this.signal,e*(this.width-1),t*(this.height-1))}displacement(e,t,n){n[0]=this.read(this.offsetX,e*(this.width-1),t*(this.height-1)),n[1]=this.read(this.offsetY,e*(this.width-1),t*(this.height-1))}step(e){if(!this.active||!Number.isFinite(e))return;let t=Math.max(0,Math.min(.05,e));const n=this.width,r=this.height;for(;t>1e-7;){const e=Math.min(1/60,t);t-=e;const i=Math.exp(-1.9*e),o=Math.exp(-3.2*e);for(let t=1;t<r-1;t++)for(let a=1;a<n-1;a++){const l=t*n+a,s=Math.max(.5,Math.min(n-1.5,a-this.u[l]*e)),c=Math.max(.5,Math.min(r-1.5,t-this.v[l]*e)),u=0|s,h=0|c,f=s-u,d=c-h,m=h*n+u,p=(1-f)*(1-d),g=f*(1-d),v=(1-f)*d,x=f*d;this.a[l]=(this.u[m]*p+this.u[m+1]*g+this.u[m+n]*v+this.u[m+n+1]*x)*i,this.b[l]=(this.v[m]*p+this.v[m+1]*g+this.v[m+n]*v+this.v[m+n+1]*x)*i,this.c[l]=(this.ink[m]*p+this.ink[m+1]*g+this.ink[m+n]*v+this.ink[m+n+1]*x)*o}[this.u,this.a]=[this.a,this.u],[this.v,this.b]=[this.b,this.v],[this.ink,this.c]=[this.c,this.ink];for(let e=1;e<r-1;e++)for(let t=1;t<n-1;t++){const r=e*n+t;this.curl[r]=.5*(this.v[r+1]-this.v[r-1]-this.u[r+n]+this.u[r-n])}for(let t=1;t<r-1;t++)for(let r=1;r<n-1;r++){const i=t*n+r,o=Math.abs(this.curl[i+1])-Math.abs(this.curl[i-1]),a=Math.abs(this.curl[i+n])-Math.abs(this.curl[i-n]),l=Math.hypot(o,a)+1e-4,s=this.curl[i]*e*10,c=Math.hypot(this.u[i],this.v[i]);this.u[i]+=a/l*s,this.v[i]-=o/l*s;const u=Math.min(1,c/(Math.hypot(this.u[i],this.v[i])+1e-6));this.u[i]*=u,this.v[i]*=u,this.divergence[i]=-.5*(this.u[i+1]-this.u[i-1]+this.v[i+n]-this.v[i-n])}this.pressure.fill(0);for(let e=0;e<4;e++){for(let e=1;e<r-1;e++)for(let t=1;t<n-1;t++){const r=e*n+t;this.pressureNext[r]=.25*(this.divergence[r]+this.pressure[r-1]+this.pressure[r+1]+this.pressure[r-n]+this.pressure[r+n])}[this.pressure,this.pressureNext]=[this.pressureNext,this.pressure]}let a=0;for(let t=1;t<r-1;t++)for(let r=1;r<n-1;r++){const i=t*n+r;this.u[i]=Math.max(-80,Math.min(80,this.u[i]-.5*(this.pressure[i+1]-this.pressure[i-1]))),this.v[i]=Math.max(-80,Math.min(80,this.v[i]-.5*(this.pressure[i+n]-this.pressure[i-n]))),this.driftX[i]+=(3.6*this.u[i]-58*this.offsetX[i]-12*this.driftX[i])*e,this.driftY[i]+=(3.6*this.v[i]-58*this.offsetY[i]-12*this.driftY[i])*e,this.offsetX[i]=Math.max(-2,Math.min(2,this.offsetX[i]+this.driftX[i]*e)),this.offsetY[i]=Math.max(-2,Math.min(2,this.offsetY[i]+this.driftY[i]*e)),this.signal[i]=1-Math.exp(.06*-Math.hypot(this.u[i],this.v[i])-.16*this.ink[i]),a=Math.max(a,this.signal[i])}this.peak=a}if(this.active)for(let e=0;e<this.ink.length;e++){const t=Math.round(65535*Math.min(1,this.signal[e]));this.pixels[4*e]=t>>>8,this.pixels[4*e+1]=255&t,this.pixels[4*e+2]=Math.round(128+63.5*this.offsetX[e]),this.pixels[4*e+3]=Math.round(128+63.5*this.offsetY[e])}else this.clear()}};function ae(e,t,n,r,i){if(!(i<1))for(let o=0;o<2;o++){for(let o=0;o<r;o++){let r=0;const a=o*n;for(let t=-i;t<=i;t++)r+=e[a+Math.max(0,Math.min(n-1,t))];for(let o=0;o<n;o++)t[a+o]=r/(2*i+1),r+=e[a+Math.min(n-1,o+i+1)]-e[a+Math.max(0,o-i)]}for(let o=0;o<n;o++){let a=0;for(let e=-i;e<=i;e++)a+=t[Math.max(0,Math.min(r-1,e))*n+o];for(let l=0;l<r;l++)e[l*n+o]=a/(2*i+1),a+=t[Math.min(r-1,l+i+1)*n+o]-t[Math.max(0,l-i)*n+o]}}}var le=new Float32Array(0);var se,ce=["none","flow","orb","drift","swell","caustics","contour","aurora","ripple","halo","interference","mesh","cascade","constellation"],ue=["glyph","dot","pixel","mosaic","lego","voxel","disco","dither","hex","led","cmyk","stipple","engraving","crosshatch","woodblock","risograph","pointillism"],he=[{value:"fluid",label:"Fluid",description:"An ink-in-water wake that bends the image and swirls the characters."},{value:"lantern",label:"Lantern",description:"A soft light follows the pointer and lifts the characters it passes, without distortion."},{value:"trail",label:"Trail",description:"The Asciify Trail: in the wake, sparse characters fill in and dense ones open up, then settle. No distortion."},{value:"loupe",label:"Loupe",description:"A glass loupe glides after the pointer and magnifies the characters it covers."},{value:"reveal",label:"Reveal",description:"Under a soft spotlight the characters take the source image's own colours. Best over a photo or video in one ink."},{value:"none",label:"Off",description:"The field stays still under the pointer."}],fe={radius:.13,strength:.5,trail:.45,follow:12},de={strength:.55,radius:.45},me={radius:.075,force:1,dissipation:1.6,refraction:.03,glow:.55,resolution:128,curl:24},pe={charset:" .,:-=+*#%@",cellSize:12,cellAspect:1,cellFit:"pixel",font:'ui-monospace, "SF Mono", Menlo, Consolas, monospace',fontWeight:500,glyphScale:.8,mark:"glyph",dotScale:.9,color:"ink",ink:"#f3ba32",highlight:"auto",background:"transparent",brightness:0,contrast:1,gamma:1,invert:!1,levels:"auto",blend:"auto",saturation:1.1,shade:.5,backdrop:0,fit:"cover",focus:{x:.5,y:.5},vignette:0,drift:0,scene:"flow",scale:1,clear:!1,speed:1,hover:"fluid",fluid:me,lantern:fe,trail:de,scope:"all",maxPixelRatio:2,respectReducedMotion:!0},ge=(e,t,n,r)=>"number"==typeof e&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):r,ve=(e,t)=>"string"==typeof e&&/^#([\da-f]{3}|[\da-f]{6})$/i.test(e.trim())?e.trim().toLowerCase():t,xe=/^[\u0020-\u007e\u00a0-\u02ff\u0370-\u0482\u048a-\u052f\u2010-\u20cf\u2100-\u2bff]*$/;function Ee(e){if(!xe.test(e)&&void 0===se){const e=Intl.Segmenter;se=e?new e(void 0,{granularity:"grapheme"}):null}return(se&&!xe.test(e)?Array.from(se.segment(e),e=>e.segment):Array.from(e)).filter(e=>"\n"!==e&&"\r"!==e&&"\t"!==e).slice(0,256)}function ye(e={},t=pe){const n="string"==typeof e.charset&&Ee(e.charset).length>=2?e.charset:t.charset,r=t.fluid||me,i=void 0===e.fluid?t.fluid:e.fluid,o=!1!==i&&(()=>{const e=!0!==i&&i?{...r,...i}:r;return{radius:ge(e.radius,.005,.5,me.radius),force:ge(e.force,0,8,me.force),dissipation:ge(e.dissipation,.05,20,me.dissipation),refraction:ge(e.refraction,0,.5,me.refraction),glow:ge(e.glow,0,2,me.glow),resolution:Math.round(ge(e.resolution,16,512,me.resolution)),curl:ge(e.curl,0,80,me.curl)}})(),a=ce.includes(e.scene)?e.scene:t.scene,l=!!e.clear&&"object"==typeof e.clear&&("element"in e.clear||"nodeType"in e.clear),s=void 0===e.clear||l?t.clear:e.clear,c=!!s&&{x:ge(s.x,-.5,1.5,.25),y:ge(s.y,-.5,1.5,.3),width:ge(s.width,0,2,.5),height:ge(s.height,0,2,.4),feather:ge(s.feather,.005,1,.12),shape:"rect"===s.shape?"rect":"ellipse"};return{charset:n,cellSize:ge(e.cellSize,3,96,t.cellSize),cellAspect:ge(e.cellAspect,.3,2,t.cellAspect),cellFit:"fill"===e.cellFit||"pixel"===e.cellFit?e.cellFit:t.cellFit,font:"string"==typeof e.font&&e.font.trim()?e.font:t.font,fontWeight:Math.round(ge(e.fontWeight,100,900,t.fontWeight)),glyphScale:ge(e.glyphScale,.3,1.6,t.glyphScale),mark:ue.includes(e.mark)?e.mark:t.mark,dotScale:ge(e.dotScale,.1,1.4,t.dotScale),color:"source"===e.color||"ink"===e.color?e.color:t.color,ink:ve(e.ink,t.ink),highlight:"auto"===e.highlight?"auto":ve(e.highlight,t.highlight),background:"transparent"===e.background?"transparent":ve(e.background,t.background),brightness:ge(e.brightness,-1,1,t.brightness),contrast:ge(e.contrast,0,4,t.contrast),gamma:ge(e.gamma,.2,5,t.gamma),invert:"boolean"==typeof e.invert?e.invert:t.invert,levels:"none"===e.levels||"auto"===e.levels?e.levels:t.levels,blend:"auto"===e.blend||"coarse"===e.blend||"on"===e.blend||"off"===e.blend?e.blend:t.blend,saturation:ge(e.saturation,0,3,t.saturation),shade:ge(e.shade,0,1,t.shade),backdrop:ge(e.backdrop,0,1,t.backdrop),fit:"contain"===e.fit||"cover"===e.fit?e.fit:t.fit,focus:{x:ge(e.focus?.x,0,1,t.focus.x),y:ge(e.focus?.y,0,1,t.focus.y)},vignette:ge(e.vignette,0,1,t.vignette),drift:ge(e.drift,0,2,t.drift),scene:a,scale:ge(e.scale,.2,6,t.scale),clear:c,speed:ge(e.speed,0,5,t.speed),hover:he.some(t=>t.value===e.hover)?e.hover:t.hover,fluid:o,lantern:{radius:ge(e.lantern?.radius,.02,.6,t.lantern.radius),strength:ge(e.lantern?.strength,0,1.5,t.lantern.strength),trail:ge(e.lantern?.trail,0,3,t.lantern.trail),follow:ge(e.lantern?.follow,1,60,t.lantern.follow)},trail:{strength:ge(e.trail?.strength,0,1,t.trail.strength),radius:ge(e.trail?.radius,.1,1,t.trail.radius)},scope:void 0===e.scope?t.scope:(u=e.scope,"subject"===u||"outside"===u?u:"all"),maxPixelRatio:ge(e.maxPixelRatio,.5,4,t.maxPixelRatio),respectReducedMotion:"boolean"==typeof e.respectReducedMotion?e.respectReducedMotion:t.respectReducedMotion};var u}function we(e,t,n,r,i,o={x:.5,y:.5}){if(!(e>0&&t>0&&n>0&&r>0))return{scale:[1,1],offset:[0,0]};const a=e/t,l=n/r,s=l>a,c="cover"===i?s?[a/l,1]:[1,l/a]:s?[1,l/a]:[a/l,1];return{scale:c,offset:"cover"===i?[(1-c[0])*o.x,(1-c[1])*o.y]:[.5*(1-c[0]),.5*(1-c[1])]}}function be(e,t,n,r){const i=Math.max(2,Math.round(e*n)),o=Math.max(2,Math.round(i*t)),a=Math.min(16,Math.max(1,r)),l=Math.ceil(r/a);return{width:o,height:i,columns:a,rows:l,atlasWidth:a*o,atlasHeight:l*i}}function Te(e){const t=e.replace("#",""),n=3===t.length?t.split("").map(e=>e+e).join(""):t,r=Number.parseInt(n,16);return Number.isFinite(r)&&6===n.length?[(r>>16&255)/255,(r>>8&255)/255,(255&r)/255]:[0,0,0]}function Me(e){const t=new Uint32Array(256);let n=0;for(let r=0;r+3<e.length;r+=4)e[r+3]<8||(t[Math.round(.2126*e[r]+.7152*e[r+1]+.0722*e[r+2])]++,n++);if(!n)return[0,1];const r=e=>{let r=0;for(let i=0;i<256;i++)if(r+=t[i],r>=n*e)return i/255;return 1},i=r(.02),o=r(.98);return o-i<.08?[0,1]:[i,o]}var Re=e=>"fluid"!==e.hover||e.fluid?e.hover:"none";function Ae(e,t,n=24,r=.12,i="ellipse"){return e.width>0&&e.height>0&&{x:(t.left-n-e.left)/e.width,y:(t.top-n-e.top)/e.height,width:(t.width+2*n)/e.width,height:(t.height+2*n)/e.height,feather:r,shape:i}}var Fe,ke=/\.(mp4|webm|mov|m4v|ogv)(\?|#|$)/i,Se=/swiftshader|llvmpipe|softpipe|software|basic render/i;function _e(){if(Fe)return Fe;if("undefined"==typeof document||void 0===globalThis.WebGL2RenderingContext)return Fe="none";try{const e=re();if(e)return Fe=Se.test(e.renderer)?"software":"gpu";const t=document.createElement("canvas").getContext("webgl2");if(!t)return Fe="none";const n=t.getExtension("WEBGL_debug_renderer_info"),r=String(t.getParameter(n?n.UNMASKED_RENDERER_WEBGL:t.RENDERER)??"");return t.getExtension("WEBGL_lose_context")?.loseContext(),Fe=Se.test(r)?"software":"gpu"}catch{return Fe="none"}}exports.DEFAULT_FIELD_FLUID=me,exports.DEFAULT_FIELD_LANTERN=fe,exports.DEFAULT_FIELD_SETTINGS=pe,exports.DEFAULT_FIELD_TRAIL=de,exports.FIELD_HOVERS=he,exports.FIELD_MARKS=ue,exports.FIELD_SCENES=ce,exports.activeFieldHover=Re,exports.fieldCellLayout=be,exports.fieldClearFromRects=Ae,exports.fieldGlyphs=Ee,exports.fieldLevels=Me,exports.fieldSourceRect=we,exports.glyphFieldTier=_e,exports.isGlyphFieldSupported=function(e={}){const t=_e();return"gpu"===t||"software"===t&&!!e.allowSoftware},exports.mountGlyphField=function(i,d={}){const m=e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement,p=e=>{const t=e.clear;return m(t)?{element:{element:t},rest:{...e,clear:void 0}}:t&&"object"==typeof t&&m(t.element)?{element:t,rest:{...e,clear:void 0}}:{element:null,rest:e}};let g=p(d).element,v=ye(p(d).rest);const x=d.onError,y=i.ownerDocument,w=y&&"undefined"!=typeof document&&y!==document?null:re(),b=w?i.getContext("2d",{alpha:!0}):null,R=!(!w||!b),A=R?w.gl:i.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,powerPreference:"high-performance"});if(!A)throw new Error("WebGL2 is not available for the glyph field.");let S=A;R&&(e=>{ie.add(e)})(i),i.setAttribute("role","img"),i.setAttribute("aria-label",d.label??"ASCII artwork"),i.dataset.renderer="glyph-field";let L=!1;const D=R?null:S.getExtension("KHR_parallel_shader_compile");let P,C,U=null,I=null,B=null,N=null,G=null,X=[],q=[],H=null,O=!1,j=null,J=null;const Z=[];let ee=0,te=0,ne=1,se=0,ce=be(v.cellSize,v.cellAspect,1,2),he=2,fe=0,de=0,me=0,pe=null,ge=!1,ve=null,xe=0,Fe=0,Se=0,_e=null,Le=0,De=0,Pe=!0,Ce=0,Ue=[0,1],Ie=-1/0,Be=-1/0,Ne=!1;const Ge=(()=>{const e="undefined"==typeof navigator?void 0:navigator;return 1e3/(e&&(e.hardwareConcurrency>0&&e.hardwareConcurrency<=2||e.deviceMemory&&e.deviceMemory<=2||e.connection?.saveData)?30:60)-2})();let Xe=!1,qe=0,He=0,ze=!0,Ve=!1,Oe=!1,je=!1,We=!1,Ye=!0,Ke=null,$e=null,Qe=1/60,Je=0,Ze=0,et=[];const tt=new Float32Array(16),nt=()=>{if(!g)return;const{element:e,padding:t=32,feather:n=.16,shape:r="rect"}=g,o=Ae(i.getBoundingClientRect(),e.getBoundingClientRect(),t,n,r),a=v.clear;JSON.stringify(a)!==JSON.stringify(o)&&(v={...v,clear:o},ze=!0)},rt=e=>"lantern"===e||"loupe"===e||"reveal"===e,it={target:null,at:null,strength:0,trail:[]},ot=new Float32Array(36);let at=null,lt=null,st=!1;const ct=()=>{if(!ee||!te)return null;const e=ee/te,t=Math.round(e>=1?128:128*e),n=Math.round(e>=1?128/e:128);return at&&at.width===t&&at.height===n||(at=new oe(t,n),lt||(lt=wt(S.LINEAR)),S.bindTexture(S.TEXTURE_2D,lt),S.texImage2D(S.TEXTURE_2D,0,S.RGBA8,t,n,0,S.RGBA,S.UNSIGNED_BYTE,at.pixels),st=!0),at};let ut=0;const ht="function"==typeof matchMedia?matchMedia("(prefers-reduced-motion: reduce)"):null,ft=()=>v.respectReducedMotion&&!!ht?.matches;let dt;const mt=new Promise(e=>{dt=e});let pt=!0;const gt=e=>x?.(e instanceof Error?e:new Error(String(e))),vt=(e,t)=>{const n=S.createShader(e);return Z.push(n),S.shaderSource(n,t),S.compileShader(n),n},xt=e=>{if(R)return w.program(e);J??(J=vt(S.VERTEX_SHADER,"#version 300 es\nvoid main(){vec2 p=vec2((gl_VertexID<<1)&2,gl_VertexID&2);gl_Position=vec4(p*2.-1.,0.,1.);}"));const t=S.createProgram(),n=vt(S.FRAGMENT_SHADER,e);return S.attachShader(t,J),S.attachShader(t,n),S.linkProgram(t),{program:t,locations:null,fragment:n}},Et=(e,t=!1)=>{if(e.locations)return!0;if(R)return w.linked(e,t);const{program:n,fragment:r}=e;if(!t&&D&&!S.getProgramParameter(n,D.COMPLETION_STATUS_KHR))return!1;if(!S.getProgramParameter(n,S.LINK_STATUS)){if(S.isContextLost())return!1;throw new Error(S.getShaderInfoLog(r)||S.getProgramInfoLog(n)||"Glyph field program failed to link.")}const i={};for(let e=S.getProgramParameter(n,S.ACTIVE_UNIFORMS)-1;e>=0;e--){const t=S.getActiveUniform(n,e).name.replace(/\[0\]$/,"");i[t]=S.getUniformLocation(n,t)}return e.locations=i,!0},yt=(e=!1)=>!!U&&!!I&&Et(U,e)&&Et(I,e),wt=e=>{const t=S.createTexture();return S.bindTexture(S.TEXTURE_2D,t),S.texParameteri(S.TEXTURE_2D,S.TEXTURE_MIN_FILTER,e),S.texParameteri(S.TEXTURE_2D,S.TEXTURE_MAG_FILTER,e===S.LINEAR_MIPMAP_LINEAR?S.LINEAR:e),S.texParameteri(S.TEXTURE_2D,S.TEXTURE_WRAP_S,S.CLAMP_TO_EDGE),S.texParameteri(S.TEXTURE_2D,S.TEXTURE_WRAP_T,S.CLAMP_TO_EDGE),t},bt=()=>{G&&(S.deleteTexture(G.ink),S.deleteTexture(G.under),S.deleteFramebuffer(G.buffer),G=null)},Tt=()=>function(e,t,n,r,i,o,a){if("fill"!==e||!(i>0&&o>0))return[a.width,a.height];const l=t*r,s=l*n;return[i/Math.max(1,Math.floor(i/s+1e-6)),o/Math.max(1,Math.floor(o/l+1e-6))]}(v.cellFit,v.cellSize,v.cellAspect,ne,ee,te,ce),Mt=()=>!!v.fluid&&"fluid"===Re(v),Rt=()=>{H?.release(),O=!1,X.forEach(e=>S.deleteTexture(e)),q.forEach(e=>S.deleteFramebuffer(e)),X=[],q=[]};function At(){B&&!R&&S.deleteProgram(B.program),B=xt((e=>`#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nuniform sampler2D uPrevious;\nuniform vec2 uSize;\nuniform float uAspect, uDt, uDecay, uEnergyDecay, uRadius, uSplat;\nuniform vec2 uFrom, uTo, uForce;\nout vec4 outColor;\n${t(e)}\nfloat segment(vec2 p,vec2 a,vec2 b){vec2 pa=p-a,ba=b-a;float h=clamp(dot(pa,ba)/max(dot(ba,ba),1e-8),0.,1.);return length(pa-ba*h);}\nvoid main(){\n vec2 uv=gl_FragCoord.xy/uSize;\n vec4 here=decodeFluid(texture(uPrevious,uv));\n vec4 state=decodeFluid(texture(uPrevious,uv-uDt*here.xy*vec2(1./uAspect,1.)));\n state.xy*=exp(-uDt*uDecay);\n state.z*=exp(-uDt*uEnergyDecay);\n if(uSplat>.5){\n vec2 scale=vec2(uAspect,1.);\n float d=segment(uv*scale,uFrom*scale,uTo*scale);\n float g=exp(-d*d/(uRadius*uRadius));\n state.xy+=uForce*g;\n state.z=min(1.,state.z+g*min(1.,length(uForce)*.5+.08));\n }\n float speed=length(state.xy);\n if(speed>5.)state.xy*=5./speed;\n outColor=encodeFluid(state);\n}`)(L)),R?H?.release():H?.dispose(),H=L?null:function(e,t,n){const r={splat:t(o),curl:t(a),vorticity:t(l),divergence:t(s),fade:t(c),pressure:t(u),gradient:t(h),advect:t(f)},i=Object.values(r);let d=0,m=0,p=[],g=[],v=null,x=null;const E=t=>{const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA16F,d,m,0,e.RGBA,e.HALF_FLOAT,null);const r=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE?(e.deleteFramebuffer(r),e.deleteTexture(n),null):(e.viewport(0,0,d,m),e.clearColor(0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),{texture:n,buffer:r})},y=t=>{t&&(e.deleteTexture(t.texture),e.deleteFramebuffer(t.buffer))},w=()=>{[...p,...g,v,x].forEach(y),p=[],g=[],v=x=null},b=(t,n)=>{const r=t.locations;return e.useProgram(t.program),e.bindFramebuffer(e.FRAMEBUFFER,n.buffer),e.uniform2f(r.uTexel,1/d,1/m),r},T=(t,n,r,i)=>{e.activeTexture(e.TEXTURE0+r),e.bindTexture(e.TEXTURE_2D,i),e.uniform1i(t[n],r)},M=()=>e.drawArrays(e.TRIANGLES,0,3),R=e=>{const t=e[0];e[0]=e[1],e[1]=t};return{resize(t,n){w(),d=t,m=n;const r=[E(e.LINEAR),E(e.LINEAR),E(e.NEAREST),E(e.NEAREST),E(e.NEAREST),E(e.NEAREST)];return e.bindFramebuffer(e.FRAMEBUFFER,null),r.some(e=>!e)?(r.forEach(y),!1):(p=[r[0],r[1]],g=[r[2],r[3]],v=r[4],x=r[5],!0)},ready:()=>i.every(n),step(t,n){if(!p.length||!v||!x)return;let i;e.viewport(0,0,d,m),t&&(i=b(r.splat,p[1]),T(i,"uVelocity",0,p[0].texture),e.uniform2f(i.uFrom,t.from[0],t.from[1]),e.uniform2f(i.uTo,t.to[0],t.to[1]),e.uniform2f(i.uForce,t.force[0],t.force[1]),e.uniform1f(i.uAspect,n.aspect),e.uniform1f(i.uRadius,n.radius),M(),R(p)),n.curl>0&&(i=b(r.curl,x),T(i,"uVelocity",0,p[0].texture),M(),i=b(r.vorticity,p[1]),T(i,"uVelocity",0,p[0].texture),T(i,"uCurl",1,x.texture),e.uniform1f(i.uStrength,n.curl),e.uniform1f(i.uDt,n.dt),M(),R(p)),i=b(r.divergence,v),T(i,"uVelocity",0,p[0].texture),M(),i=b(r.fade,g[1]),T(i,"uSource",0,g[0].texture),e.uniform1f(i.uAmount,.8),M(),R(g);for(let e=0;e<20;e++)i=b(r.pressure,g[1]),T(i,"uPressure",0,g[0].texture),T(i,"uDivergence",1,v.texture),M(),R(g);i=b(r.gradient,p[1]),T(i,"uPressure",0,g[0].texture),T(i,"uVelocity",1,p[0].texture),M(),R(p),i=b(r.advect,p[1]),T(i,"uVelocity",0,p[0].texture),e.uniform1f(i.uDt,n.dt),e.uniform1f(i.uDissipation,n.dissipation),M(),R(p),e.bindFramebuffer(e.FRAMEBUFFER,null)},get velocity(){return p[0]?.texture??null},get size(){return[d,m]},release:w,dispose(){w(),i.forEach(({program:t})=>e.deleteProgram(t))}}}(S,xt,e=>Et(e))}const Ft=()=>{Rt();const e=v.fluid;if(!(e&&Mt()&&ee&&te))return;B||At();const t=e.resolution,n=ee/te;if(fe=n>=1?t:Math.max(8,Math.round(t*n)),de=n>=1?Math.max(8,Math.round(t/n)):t,O=!!H&&H.resize(fe,de),O)return void(me=0);const r=()=>{Rt();for(let e=0;e<2;e++){const e=wt(S.LINEAR);S.texImage2D(S.TEXTURE_2D,0,L?S.RGBA8:S.RGBA16F,fe,de,0,S.RGBA,L?S.UNSIGNED_BYTE:S.HALF_FLOAT,null);const t=S.createFramebuffer();S.bindFramebuffer(S.FRAMEBUFFER,t),S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT0,S.TEXTURE_2D,e,0),X.push(e),q.push(t)}return S.checkFramebufferStatus(S.FRAMEBUFFER)===S.FRAMEBUFFER_COMPLETE};if(!r()){if(L)throw new Error("The glyph field could not allocate its fluid buffers.");L=!0,kt(),At(),r()}for(const e of q)S.bindFramebuffer(S.FRAMEBUFFER,e),S.viewport(0,0,fe,de),S.clearColor(L?.5:0,L?.5:0,0,1),S.clear(S.COLOR_BUFFER_BIT);S.bindFramebuffer(S.FRAMEBUFFER,null),me=0};function kt(){U&&!R&&S.deleteProgram(U.program),I&&!R&&S.deleteProgram(I.program),bt(),U=xt(n(L)),I=xt(r),(R?w.canCompileInParallel:D)||yt(!0)}const St=()=>`${v.fontWeight} ${Math.max(1,ce.height*v.glyphScale)}px ${v.font}`,_t=()=>{ze=!0,sn()},Lt=()=>`${Ee(v.charset).join("")}\0${St()}\0${ce.width}x${ce.height}x${ce.columns}`,Dt=()=>{const e=Ee(v.charset);if(he=e.length,ce=be(v.cellSize,v.cellAspect,ne,he),se=ne,R){const e=Lt();if(N?.key!==e){const t=N;N=w.atlas(e,Pt,_t),w.releaseAtlas(t,_t),P=N.texture}return void(ze=!0)}const{image:t}=Pt();S.bindTexture(S.TEXTURE_2D,P),S.pixelStorei(S.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),S.texImage2D(S.TEXTURE_2D,0,S.RGBA8,S.RGBA,S.UNSIGNED_BYTE,t),t.width=t.height=1,ze=!0};function Pt(){const e=Ee(v.charset),t=document.createElement("canvas");t.width=ce.atlasWidth,t.height=ce.atlasHeight;const n=t.getContext("2d");n.fillStyle="#fff",n.textAlign="center",n.textBaseline="alphabetic",n.font=St();const r=n.measureText("M"),i=r.actualBoundingBoxAscent||ce.height*v.glyphScale*.7,o=r.actualBoundingBoxDescent||0,a=(ce.height+i-o)/2;e.forEach((e,t)=>{const r=t%ce.columns*ce.width+ce.width/2,i=Math.floor(t/ce.columns)*ce.height+a,o=n.measureText(e).width;n.save(),n.beginPath(),n.rect(r-ce.width/2,i-a,ce.width,ce.height),n.clip(),n.translate(r,i),o>.96*ce.width&&n.scale(.96*ce.width/o,1),n.fillText(e,0,0),n.restore()});let l=!0;try{l=!Ct?.check||Ct.check(n.font,e.join(""))}catch{}return R&&queueMicrotask(()=>{t.width=t.height=1}),{image:t,final:l}}const Ct="undefined"==typeof document?void 0:document.fonts,Ut=()=>{if(!Ct?.load)return;const e=St();Ct.load(e,Ee(v.charset).join("")).then(()=>{if(!Ve&&!Oe&&St()===e)return R?void(N&&!N.final&&N.key===Lt()&&w.paintAtlas(N,Pt)):(Dt(),void sn())},()=>{})},It=e=>e.trim().replace(/^["']|["']$/g,"").toLowerCase(),Bt=()=>{if(Ue=[0,1],pe&&"none"!==v.levels)try{const e=document.createElement("canvas");e.width=e.height=64;const t=e.getContext("2d",{willReadFrequently:!0});pe===_e&&(t.imageSmoothingQuality="medium"),t.drawImage(pe,0,0,64,64),Ue=Me(t.getImageData(0,0,64,64).data)}catch{Ue=[0,1]}};let Nt=null,Gt=null,Xt=!1,qt=-1/0,Ht=new Uint8Array(0),zt=null;const Vt=()=>{if(Xt=!1,!pe||"all"===v.scope)return;const e=xe||1,t=Fe||1,n=Math.max(8,Math.round(e>=t?96:96*e/t)),r=Math.max(8,Math.round(t>=e?96:96*t/e));try{if(zt??(zt=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})),!zt)return;const e=zt.canvas;e.width!==n||e.height!==r?(e.width=n,e.height=r):zt.clearRect(0,0,n,r),zt.drawImage(pe,0,0,n,r),Gt=function(e,t,n,r,i){const o=t*n,a=i&&i.width===t&&i.height===n?i:{width:t,height:n,subject:new Float32Array(o),depth:new Float32Array(o),key:"none"},{subject:l,depth:s}=a;let c=0;for(let t=0;t<o;t++)e[4*t+3]<250&&c++;const u=t=>(.2126*e[4*t]+.7152*e[4*t+1]+.0722*e[4*t+2])/255;let h="none",f=0;if(c>.01*o)h="alpha";else{let e=0,r=0,i=0;const o=Math.max(1,Math.round(.03*Math.min(t,n)));for(let a=0;a<n;a++)for(let l=0;l<t;l++){if(l>=o&&a>=o&&l<t-o&&a<n-o)continue;const s=u(a*t+l);e+=s,r+=s*s,i++}f=e/Math.max(1,i),Math.sqrt(Math.max(0,r/Math.max(1,i)-f*f))<.07&&(h="ground")}for(let t=0;t<o;t++){const n=e[4*t+3]/255,r=u(t);let i=1;if("alpha"===h)i=n;else if("ground"===h){const e=Math.max(0,Math.min(1,(Math.abs(r-f)-.035)/.12));i=e*e*(3-2*e)}l[t]=1*i,s[t]=r*n}a.key=h,le.length<o&&(le=new Float32Array(o));const d=le;return ae(l,d,t,n,Math.max(1,Math.round(.02*Math.min(t,n)))),ae(s,d,t,n,Math.max(1,Math.round(.035*Math.min(t,n)))),a}(zt.getImageData(0,0,n,r).data,n,r,0,Gt)}catch{return}if("none"!==Gt.key){Ht.length!==n*r*4&&(Ht=new Uint8Array(n*r*4));for(let e=0;e<n*r;e++)Ht[4*e+3]=Math.round(255*Gt.subject[e]);Nt??(Nt=wt(S.LINEAR)),S.bindTexture(S.TEXTURE_2D,Nt),S.pixelStorei(S.UNPACK_FLIP_Y_WEBGL,!1),S.pixelStorei(S.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),S.texImage2D(S.TEXTURE_2D,0,S.RGBA8,n,r,0,S.RGBA,S.UNSIGNED_BYTE,Ht),Xt=!0}},Ot=()=>{if(!pe)return;const e=performance.now();pe instanceof HTMLVideoElement&&!(e-Ie>1500)||(Bt(),Ie=e),pe instanceof HTMLVideoElement&&!(e-qt>160)||(Vt(),qt=e),S.bindTexture(S.TEXTURE_2D,C),S.pixelStorei(S.UNPACK_FLIP_Y_WEBGL,!1),S.pixelStorei(S.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);try{S.texImage2D(S.TEXTURE_2D,0,S.RGBA8,S.RGBA,S.UNSIGNED_BYTE,pe),S.generateMipmap(S.TEXTURE_2D);const e=pe;De=(e.videoWidth||e.naturalWidth||e.width)*(e.videoHeight||e.naturalHeight||e.height)*4*4/3}catch(e){gt(e)}},jt=()=>{L=!S.getExtension("EXT_color_buffer_float")&&!S.getExtension("EXT_color_buffer_half_float"),kt(),j=R?w.vertexArray():S.createVertexArray(),R||(P=wt(S.NEAREST)),C=wt(S.LINEAR_MIPMAP_LINEAR),S.bindTexture(S.TEXTURE_2D,C),S.texImage2D(S.TEXTURE_2D,0,S.RGBA8,1,1,0,S.RGBA,S.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),S.generateMipmap(S.TEXTURE_2D),ee=te=0,se=0,Wt(),Ut(),pe&&Ot()};function Wt(){const e=i.clientWidth||i.clientHeight?{width:i.clientWidth,height:i.clientHeight}:i.getBoundingClientRect();Ne=!e.width||!e.height;const t=Math.min(globalThis.devicePixelRatio||1,v.maxPixelRatio,Math.sqrt(8294400/Math.max(1,e.width*e.height))),n=R&&w.scale<1&&t>1?Math.max(1,t*w.scale):t,r=Math.max(1,Math.round(e.width*n)),o=Math.max(1,Math.round(e.height*n));if(r===ee&&o===te&&n===ne)return!1;const a=!ee||Math.abs(r/o-ee/te)>.01;return ne=n,ee=r,te=o,i.width=ee,i.height=te,se!==ne&&Dt(),(a||Mt()&&!X.length&&!O)&&Ft(),ze=!0,!0}let Yt=null,Kt=[0,0,0],$t=[1,1,1],Qt=[0,0,0,0],Jt=we(1,1,1,1,"cover"),Zt=null,en=0,tn=0,nn=0,rn=0;const on=()=>{Yt!==v&&(Yt=v,Kt=Te(v.ink),$t=Te("auto"===v.highlight?"#ffffff":v.highlight),Qt="transparent"===v.background?[0,0,0,0]:[...Te(v.background),1]),Zt===v&&en===ee&&tn===te&&nn===xe&&rn===Fe||(Zt=v,en=ee,tn=te,nn=xe,rn=Fe,Jt=we(ee,te,xe||1,Fe||1,v.fit,v.focus)),R&&w.begin(ee,te);const t=v.fluid,n=pe&&Le?ce.height/te*Le*Jt.scale[1]:1,r=(()=>{const[e,t]=Tt(),n=Math.ceil(ee/e-1e-4),r=Math.ceil(te/t-1e-4);if(G&&G.columns===n&&G.rows===r)return G;bt();const i=()=>{const e=wt(S.NEAREST);return S.texStorage2D(S.TEXTURE_2D,1,L?S.RGBA8:S.RGBA16F,n,r),e},o=i(),a=i(),l=S.createFramebuffer();return S.bindFramebuffer(S.FRAMEBUFFER,l),S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT0,S.TEXTURE_2D,o,0),S.framebufferTexture2D(S.FRAMEBUFFER,S.COLOR_ATTACHMENT1,S.TEXTURE_2D,a,0),S.drawBuffers([S.COLOR_ATTACHMENT0,S.COLOR_ATTACHMENT1]),G={ink:o,under:a,buffer:l,columns:n,rows:r}})(),i=U.locations,o=I.locations,a=Re(v),l=!ft();S.bindFramebuffer(S.FRAMEBUFFER,r.buffer),S.viewport(0,0,r.columns,r.rows),S.useProgram(U.program),S.activeTexture(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,C),S.uniform1i(i.uSource,0),S.activeTexture(S.TEXTURE2),S.bindTexture(S.TEXTURE_2D,(O?H?.velocity:X[me])??C),S.uniform1i(i.uFluid,2),S.activeTexture(S.TEXTURE3),S.bindTexture(S.TEXTURE_2D,lt??C),S.uniform1i(i.uTrailMap,3),S.activeTexture(S.TEXTURE6),S.bindTexture(S.TEXTURE_2D,Nt??C),S.uniform1i(i.uScope,6),S.uniform1f(i.uScopeMode,Xt&&"all"!==v.scope?"subject"===v.scope?1:2:0),S.uniform1f(i.uFluidMode,O?1:0),S.uniform1i(i.uHoverMode,"fluid"===a?1:"lantern"===a?2:"trail"===a&&st?3:"loupe"===a?4:"reveal"===a?5:0),S.uniform1f(i.uTrailAmount,v.trail.strength),S.uniform3f(i.uLight,it.at?.[0]??-1,it.at?.[1]??-1,rt(a)?it.strength:0),S.uniform3fv(i.uTrail,ot),S.uniform1f(i.uLightRadius,v.lantern.radius),S.uniform1f(i.uLightGain,v.lantern.strength),S.uniform1f(i.uClock,performance.now()/1e3),S.uniform1f(i.uFlicker,l?1:0),S.uniform2f(i.uFluidTexel,1/Math.max(1,fe),1/Math.max(1,de)),S.uniform2f(i.uResolution,ee,te);const[s,c]=Tt();var u;S.uniform2f(i.uCell,s,c),S.uniform1f(i.uCount,he),S.uniform1f(i.uBlend,"on"===v.blend||he<=9&&("coarse"===v.blend||"auto"===v.blend&&ge)?1:0),S.uniform4f(i.uSourceMap,Jt.scale[0],Jt.scale[1],Jt.offset[0],Jt.offset[1]),S.uniform1i(i.uScene,pe?0:(u=v.scene,e[u]??3)),S.uniform1i(i.uMark,ue.indexOf(v.mark)),S.uniform1f(i.uScale,v.scale);const h=v.clear;S.uniform4f(i.uClear,h?h.x:0,h?h.y:0,h?h.width:0,h?h.height:0),S.uniform1f(i.uClearFeather,h?h.feather:.1),S.uniform1f(i.uClearShape,h&&"rect"===h.shape?1:0);const f=performance.now();tt.fill(0);for(let e=0;e<et.length;e++){const t=et[e],n=4*e;tt[n]=t.x,tt[n+1]=t.y,tt[n+2]=(f-t.born)/1e3,tt[n+3]=t.strength}S.uniform4fv(i.uPulse,tt),S.uniform3fv(i.uInk,Kt),S.uniform3fv(i.uHighlight,$t),S.uniform1f(i.uHighlightAuto,"auto"===v.highlight?1:0),S.uniform4fv(i.uBackground,Qt),S.uniform1f(i.uBrightness,v.brightness),S.uniform1f(i.uContrast,v.contrast),S.uniform1f(i.uGamma,v.gamma),S.uniform1f(i.uInvert,v.invert?1:0),S.uniform1f(i.uVignette,v.vignette),S.uniform1f(i.uSourceColor,"source"===v.color?1:0),S.uniform1f(i.uRefraction,t?t.refraction*(l?1:.25):0),S.uniform1f(i.uGlow,t?t.glow:0),S.uniform1f(i.uTime,He),S.uniform1f(i.uDrift,l?v.drift:0),S.uniform1f(i.uFluidOn,t&&"fluid"===a&&(X.length||O)?1:0),S.uniform1f(i.uLod,Math.max(0,Math.log2(Math.max(1,n))-.5)),S.uniform1f(i.uSaturation,v.saturation),S.uniform1f(i.uShade,v.shade),S.uniform1f(i.uBackdrop,pe?v.backdrop:0),S.uniform2f(i.uLevels,pe&&"auto"===v.levels?Ue[0]:0,pe&&"auto"===v.levels?Ue[1]:1),S.bindVertexArray(j),S.drawArrays(S.TRIANGLES,0,3),S.bindFramebuffer(S.FRAMEBUFFER,null),S.viewport(0,0,ee,te),S.useProgram(I.program),S.activeTexture(S.TEXTURE1),S.bindTexture(S.TEXTURE_2D,P),S.uniform1i(o.uAtlas,1),S.activeTexture(S.TEXTURE4),S.bindTexture(S.TEXTURE_2D,r.ink),S.uniform1i(o.uCells,4),S.activeTexture(S.TEXTURE5),S.bindTexture(S.TEXTURE_2D,r.under),S.uniform1i(o.uUnder,5),S.uniform2f(o.uResolution,ee,te),S.uniform2f(o.uCell,ce.width,ce.height),S.uniform2f(o.uPitch,s,c),S.uniform1f(o.uColumns,ce.columns),S.uniform1f(o.uDotScale,v.dotScale),S.uniform1i(o.uMark,ue.indexOf(v.mark)),S.uniform1f(o.uSourceColor,"source"===v.color?1:0),S.drawArrays(S.TRIANGLES,0,3),R&&w.present(b,ee,te)},an=()=>!Ve&&!Oe&&!je&&!Ne&&(Ye||pt)&&!("undefined"!=typeof document&&document.hidden),ln=e=>{if(Xe=!1,!an())return;const t=(e-qe)/1e3,n=Math.min(1/30,Math.max(1/480,t));qe=e,Qe=.9*Qe+.1*Math.min(t,.25),Je=Qe>1/24?Je+1:0;try{R&&w.overloaded&&Ze<2&&Je>10&&(Ze=2),Je>45&&Ze<2&&(!R||w.atMinimum)&&(Je=0,Ze++,1===Ze&&ne>1?(v={...v,maxPixelRatio:1},Wt()):Ze=2);const t=yt(),r=!(We||Ze>=2&&!(pe instanceof HTMLVideoElement)||(!(pe instanceof HTMLVideoElement)||pe.paused||pe.ended)&&(ft()||!(!pe&&"none"!==v.scene||v.drift>0)));r&&(He+=n*v.speed),pe instanceof HTMLVideoElement&&pe.readyState>=2&&Pe&&(Pe=!("requestVideoFrameCallback"in pe),Ot(),ze=!0);const i=Re(v);let o="fluid"===i&&(null!==$e||e<ut);if(o?((e,t)=>{const n=v.fluid;if(!n||!q.length&&!O)return;if(O?!H?.ready():!B||!Et(B))return;const r=ee/te,i=$e;if($e=null,O&&H){const o=5200*n.force*(ft()?.35:1);return i&&(ut=t+1e3*Math.min(9,6/Math.max(.3,n.dissipation))),void H.step(i?{from:i.from,to:i.to,force:[(i.to[0]-i.from[0])*o,(i.to[1]-i.from[1])*o]}:null,{dt:Math.min(e,1/60),radius:1.1*n.radius,curl:n.curl,dissipation:n.dissipation,aspect:r})}let o=0,a=0;if(i){const e=(ft()?1:3)*n.force;o=(i.to[0]-i.from[0])*r*e*4,a=(i.to[1]-i.from[1])*e*4,ut=t+7/Math.min(n.dissipation,1.1*n.dissipation)*1e3}const l=B.locations;S.bindFramebuffer(S.FRAMEBUFFER,q[1-me]),S.viewport(0,0,fe,de),S.useProgram(B.program),S.activeTexture(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,X[me]),S.uniform1i(l.uPrevious,0),S.uniform2f(l.uSize,fe,de),S.uniform1f(l.uAspect,r),S.uniform1f(l.uDt,e),S.uniform1f(l.uDecay,n.dissipation),S.uniform1f(l.uEnergyDecay,1.1*n.dissipation),S.uniform1f(l.uRadius,n.radius),S.uniform1f(l.uSplat,i?1:0),S.uniform2f(l.uFrom,i?.from[0]??0,i?.from[1]??0),S.uniform2f(l.uTo,i?.to[0]??0,i?.to[1]??0),S.uniform2f(l.uForce,o,a),S.drawArrays(S.TRIANGLES,0,3),me=1-me})(n,e):$e=null,rt(i)&&(o=((e,t)=>{const n=v.lantern,r=it.target;if(r){const i=it.at;if(i)if(ft())i[0]=r[0],i[1]=r[1];else{const t=1-Math.exp(-n.follow*e);i[0]+=(r[0]-i[0])*t,i[1]+=(r[1]-i[1])*t}else it.at=[r[0],r[1]];const o=it.at,a=it.trail[it.trail.length-1];n.trail>0&&(!a||t-a.born>28&&Math.hypot(o[0]-a.x,o[1]-a.y)>.004)&&(it.trail.push({x:o[0],y:o[1],born:t}),it.trail.length>12&&it.trail.shift())}it.strength+=((r?1:0)-it.strength)*(1-Math.exp(-e*(r?9:5)));const i=it.trail;for(let e=i.length-1;e>=0;e--)n.trail>0&&t-i[e].born<4e3*n.trail||i.splice(e,1);ot.fill(0);for(let e=0;e<i.length;e++){const r=i[e];ot[3*e]=r.x,ot[3*e+1]=r.y,ot[3*e+2]=.55*Math.exp(-(t-r.born)/1e3/Math.max(.01,n.trail))}return it.strength>.003||i.length>0})(n,e)||o),"trail"===i){const e=!!at?.active;o=(e=>{const t=ct();return!(!t||!t.active||(t.step(e),S.bindTexture(S.TEXTURE_2D,lt),S.texSubImage2D(S.TEXTURE_2D,0,0,0,t.width,t.height,S.RGBA,S.UNSIGNED_BYTE,t.pixels),st=!0,0))})(n)||o,e&&!at?.active&&(ze=!0)}if(et.length){for(let t=et.length-1;t>=0;t--)e-et[t].born>=2400&&et.splice(t,1);o=!0,et.length||(ze=!0)}t&&(o||ze||r&&e-Be>=Ge*E)&&(on(),Be=e,ze=!1,!pt||Se&&!pe||(pt=!1,dt())),(r||o||$e||!t)&&(Xe=!0,T(ln))}catch(e){je=!0,gt(e)}};function sn(){!Xe&&an()&&(qe=performance.now(),Xe=!0,T(ln))}const cn=(e,t)=>{const n=i.getBoundingClientRect();if(!n.width||!n.height)return null;const r=(e-n.left)/n.width,o=(t-n.top)/n.height;return r<-.05||r>1.05||o<-.05||o>1.05?null:[r,1-o]},un=e=>{const t=Re(v);if("none"===t||We)return Ke=null,void(it.target=null);if(rt(t))return it.target=e?[e[0],1-e[1]]:null,Ke=null,void sn();if("trail"===t){const t=ct();if(!t)return;return e?t.move(e[0],1-e[1],v.trail.radius,performance.now()):t.leave(),Ke=null,void sn()}e?(Ke&&($e=$e?{from:$e.from,to:e}:{from:Ke,to:e}),Ke=e,sn()):Ke=null},hn=d.interactionTarget??window,fn={target:hn,move:e=>{const t=cn(e.clientX,e.clientY);hn===window&&(fn.inside=!!t),un(t)},leave:()=>{Ke=null,at?.leave(),it.target&&(it.target=null,sn())},near:()=>Ye},dn=[V(fn)],mn=()=>{const e=Wt();nt(),(e||ze)&&sn()};let pn=g?Q(g.element,mn):()=>{};dn.push(Q(i,mn),()=>pn()),dn.push(function(e,t,n){if("function"!=typeof IntersectionObserver)return()=>{};let r=W.get(t);if(!r){const e=new Map;r={observer:new IntersectionObserver(Y(e),{rootMargin:t}),watch:e},W.set(t,r)}const{observer:i,watch:o}=r;return K(o,e,n)||i.unobserve(e),i.observe(e),()=>{$(o,e,n)&&i.unobserve(e),o.size||(i.disconnect(),W.delete(t))}}(i,"120px",e=>{Ye=e.isIntersecting,Ye&&(ze=!0,sn())})),dn.push(z(F,()=>{document.hidden||(ze=!0,sn())})),dn.push((e=>z(k,e))(()=>{ze=!0,sn()})),dn.push((e=>z(_,e))(e=>{const t=e.fontfaces??[],n=v.font.split(",").map(It);t.some(e=>n.includes(It(e.family)))&&Ut()}));const gn=e=>{e?.preventDefault(),Oe=!0,Xe&&M(ln),Xe=!1},vn=()=>{Oe=!1,R&&(S=w.gl),Z.length=0,J=null,N=null,U=I=B=null,G=null,X=[],q=[],H=null,O=!1,lt=null,at=null,st=!1,Nt=null,Xt=!1;try{jt(),ze=!0,sn()}catch(e){gt(e)}},xn={lost:()=>gn(),restored:vn,rescale:()=>{Wt()&&sn()},size:()=>[ee,te],bytes:()=>{const e=L?4:8;return ee*te*4+De+(G?G.columns*G.rows*e*2:0)+fe*de*e*(O?6:X.length)+(at?at.width*at.height*4:0)}};R?w.join(xn):(i.addEventListener("webglcontextlost",gn),i.addEventListener("webglcontextrestored",vn));const En=()=>{ve&&(ve.pause(),ve.removeAttribute("src"),ve.load(),ve=null),Ce&&pe instanceof HTMLVideoElement&&"cancelVideoFrameCallback"in pe&&pe.cancelVideoFrameCallback(Ce),Ce=0},yn=()=>{_e?.close(),_e=null},wn=async e=>{const t=await createImageBitmap(e,{premultiplyAlpha:"none"}),n=[t.width,t.height],r=function(e,t,n,r,i,o,a=8){if(!(n>=16&&r>=16&&e>0&&t>0&&i>0))return 1;const l=a/i/("cover"===o?Math.min(e/n,t/r):Math.max(e/n,t/r));return l>.5?1:2**-Math.floor(Math.log2(1/l))}(t.width,t.height,ee,te,ce.height,v.fit);if(1===r)return{element:t,owned:!0,natural:n};try{return{element:await createImageBitmap(t,{resizeWidth:Math.max(1,Math.round(t.width*r)),resizeHeight:Math.max(1,Math.round(t.height*r)),resizeQuality:"medium",premultiplyAlpha:"none"}),owned:!0,natural:n}}finally{t.close()}},bn=e=>new Promise((t,n)=>{const r=new Image;r.crossOrigin="anonymous",r.decoding="async",r.onload=()=>t({element:r,owned:!1}),r.onerror=()=>n(new Error("The glyph field could not load this image.")),r.src=e}),Tn=(e,t,n)=>{const{element:r,owned:i}=e;if(Ve||n!==Se)return void(i&&r instanceof HTMLVideoElement?(r.pause(),r.removeAttribute("src"),r.load()):i&&r.close());r!==pe&&(En(),yn()),ve=i&&r instanceof HTMLVideoElement?r:null,!i||r instanceof HTMLVideoElement||(_e=r);const o=r!==pe;pe=r,ge="string"==typeof t||t instanceof HTMLImageElement||t instanceof HTMLVideoElement,Le=r instanceof HTMLVideoElement?r.videoHeight:r instanceof HTMLImageElement?r.naturalHeight:r.height,xe=e.natural?.[0]??(r instanceof HTMLVideoElement?r.videoWidth:r instanceof HTMLImageElement?r.naturalWidth:r.width),Fe=e.natural?.[1]??Le,Pe=!0,r instanceof HTMLVideoElement&&o&&(e=>{const t=e;if(!t.requestVideoFrameCallback)return;const n=()=>{Ve||pe!==e||(Pe=!0,sn(),Ce=t.requestVideoFrameCallback(n))};Ce=t.requestVideoFrameCallback(n)})(r),Oe||Ot(),ze=!0,sn()},Mn=(e,t)=>{pt&&e===Se&&(pt=!1,dt()),gt(t)},Rn=e=>{const t=++Se;if(!e)return En(),yn(),pe=null,xe=Fe=Le=De=0,ge=!1,ze=!0,sn(),Promise.resolve();if((e=>!("string"==typeof e||e instanceof HTMLImageElement&&!e.complete||e instanceof HTMLVideoElement&&e.readyState<2))(e)){try{Tn({element:e,owned:!1},e,t)}catch(e){Mn(t,e)}return Promise.resolve()}return(async e=>{if("string"!=typeof e)return e instanceof HTMLImageElement&&!e.complete?e.decode().then(()=>({element:e,owned:!1})):e instanceof HTMLVideoElement&&e.readyState<2?new Promise((t,n)=>{e.addEventListener("loadeddata",()=>t({element:e,owned:!1}),{once:!0}),e.addEventListener("error",()=>n(new Error("The glyph field could not load this video.")),{once:!0})}):{element:e,owned:!1};if(ke.test(e))return new Promise((t,n)=>{const r=document.createElement("video");r.crossOrigin="anonymous",r.muted=!0,r.loop=!0,r.playsInline=!0,r.preload="auto",r.addEventListener("loadeddata",()=>{r.play().catch(()=>{}),t({element:r,owned:!0})},{once:!0}),r.addEventListener("error",()=>n(new Error("The glyph field could not load this video.")),{once:!0}),r.src=e});if("function"!=typeof createImageBitmap||"function"!=typeof fetch)return bn(e);let t;try{t=await(await fetch(e).then(e=>{if(!e.ok)throw new Error("The glyph field could not load this image.");return e})).blob()}catch(t){if(t instanceof Error&&t.message.startsWith("The glyph field"))throw t;return bn(e)}if(!/svg/i.test(t.type))try{return await wn(t)}catch{}const n=URL.createObjectURL(t);try{return await bn(n)}finally{URL.revokeObjectURL(n)}})(e).then(n=>Tn(n,e,t),e=>Mn(t,e))};jt(),nt();const An=d.source??null;return An?(Se=1,Rn(An)):sn(),{canvas:i,ready:mt,get settings(){return v},update(e){const t=v,{element:n,rest:r}=p(e);"clear"in e&&g?.element!==n?.element?(pn(),g=n,pn=n?Q(n.element,mn):()=>{}):"clear"in e&&(g=n),v=ye(n?{...r,clear:v.clear}:r,v),nt(),e.label&&i.setAttribute("aria-label",e.label),v.maxPixelRatio!==t.maxPixelRatio&&Wt(),v.charset===t.charset&&v.cellSize===t.cellSize&&v.cellAspect===t.cellAspect&&v.font===t.font&&v.fontWeight===t.fontWeight&&v.glyphScale===t.glyphScale||(Dt(),Ut()),v.levels!==t.levels&&Bt(),v.scope===t.scope||Oe||(Vt(),qt=performance.now());((!!t.fluid&&"fluid"===Re(t))!==Mt()||v.fluid&&t.fluid&&v.fluid.resolution!==t.fluid.resolution)&&Ft(),"source"in e&&Rn(e.source??null),ze=!0,sn()},setSource:Rn,pointer(e,t=0){if(null===e)return void un(null);const n=i.getBoundingClientRect();un(cn(n.left+e,n.top+t))},redraw(){if(!(Ve||Oe||je)&&ee)try{yt(!(pt&&(R?w.canCompileInParallel:D)))&&(on(),pt||(ze=!1))}catch(e){je=!0,gt(e)}},pulse(e={}){if(Ve||ft())return;const t=i.getBoundingClientRect();if(!t.width||!t.height)return;let n=e.x??t.width/2,r=e.y??t.height/2;if(e.element){const i=e.element.getBoundingClientRect();n=i.left+i.width/2-t.left,r=i.top+i.height/2-t.top}const o=Math.max(0,Math.min(2,e.strength??1));et=[...et,{x:n/t.width,y:r/t.height,born:performance.now(),strength:o}].slice(-4),sn()},play(){We=!1,pe instanceof HTMLVideoElement&&pe.play().catch(()=>{}),ze=!0,sn()},pause(){We=!0,pe instanceof HTMLVideoElement&&pe.pause()},resize(){Wt()&&sn()},destroy(){if(!Ve){if(Ve=!0,Xe&&M(ln),Xe=!1,dn.forEach(e=>e()),R?w.leave(xn):(i.removeEventListener("webglcontextlost",gn),i.removeEventListener("webglcontextrestored",vn)),En(),yn(),pe=null,!Oe)if(Rt(),bt(),S.deleteTexture(C),lt&&S.deleteTexture(lt),Nt&&S.deleteTexture(Nt),R)w.releaseAtlas(N,_t),H?.release();else{S.deleteTexture(P);for(const e of[U,I,B])e&&S.deleteProgram(e.program);H?.dispose(),Z.forEach(e=>S.deleteShader(e)),j&&S.deleteVertexArray(j)}N=null}}}},exports.normalizeFieldSettings=ye;//# sourceMappingURL=field.cjs.map
package/dist/field.d.cts CHANGED
@@ -245,7 +245,10 @@ interface GlyphField {
245
245
  setSource(source: FieldSource | null): Promise<void>;
246
246
  /** Moves the wake programmatically, in CSS pixels relative to the canvas. `null` lifts the pointer. */
247
247
  pointer(x: number | null, y?: number): void;
248
- /** Draws the current frame now, so the canvas can be read with drawImage in the same task. */
248
+ /**
249
+ * Draws the current frame now, so the canvas can be read with drawImage in the same task. Before `ready`, while the shaders
250
+ * are still compiling in parallel, it leaves the first frame to the field's own loop rather than block on the compiler.
251
+ */
249
252
  redraw(): void;
250
253
  /**
251
254
  * Sends a ring through the field, for interface events such as a save or a message.
package/dist/field.d.ts CHANGED
@@ -245,7 +245,10 @@ interface GlyphField {
245
245
  setSource(source: FieldSource | null): Promise<void>;
246
246
  /** Moves the wake programmatically, in CSS pixels relative to the canvas. `null` lifts the pointer. */
247
247
  pointer(x: number | null, y?: number): void;
248
- /** Draws the current frame now, so the canvas can be read with drawImage in the same task. */
248
+ /**
249
+ * Draws the current frame now, so the canvas can be read with drawImage in the same task. Before `ready`, while the shaders
250
+ * are still compiling in parallel, it leaves the first frame to the field's own loop rather than block on the compiler.
251
+ */
249
252
  redraw(): void;
250
253
  /**
251
254
  * Sends a ring through the field, for interface events such as a save or a message.