@occluze/umber 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -47
- package/THIRD-PARTY-NOTICES.md +33 -0
- package/dist/chunks/badge.js +2 -2
- package/dist/chunks/basis.js +2 -2
- package/dist/chunks/batches.js +2 -0
- package/dist/chunks/capture.js +2 -2
- package/dist/chunks/covers.js +2 -2
- package/dist/chunks/curves.js +2 -2
- package/dist/chunks/flip.js +2 -2
- package/dist/chunks/fx.js +2 -2
- package/dist/chunks/gl.js +2 -2
- package/dist/chunks/glsl.js +2 -2
- package/dist/chunks/glyphs.js +2 -0
- package/dist/chunks/inspect.js +2 -2
- package/dist/chunks/instances.js +2 -2
- package/dist/chunks/layers.js +2 -2
- package/dist/chunks/licence.js +2 -2
- package/dist/chunks/morph.js +2 -2
- package/dist/chunks/pace.js +2 -0
- package/dist/chunks/patch.js +2 -2
- package/dist/chunks/prepared.js +2 -2
- package/dist/chunks/profiler.js +2 -2
- package/dist/chunks/recheck.js +2 -0
- package/dist/chunks/resize.js +2 -0
- package/dist/chunks/restore.js +2 -2
- package/dist/chunks/shapes.js +2 -2
- package/dist/chunks/sim.js +2 -2
- package/dist/chunks/text.js +2 -2
- package/dist/chunks/video.js +2 -2
- package/dist/chunks/vocabulary.js +2 -2
- package/dist/chunks/warm.js +2 -2
- package/dist/modules/debug.js +2 -2
- package/dist/modules/debug.mjs +2 -2
- package/dist/modules/handoff.js +2 -2
- package/dist/modules/handoff.mjs +2 -2
- package/dist/modules/input.js +2 -2
- package/dist/modules/input.mjs +2 -2
- package/dist/modules/scrollfx.js +2 -2
- package/dist/modules/scrollfx.mjs +2 -2
- package/dist/modules/scrub.js +2 -2
- package/dist/modules/scrub.mjs +2 -2
- package/dist/modules/three.js +2 -2
- package/dist/modules/three.mjs +2 -2
- package/dist/node/assets.mjs +4 -2
- package/dist/node/astro.mjs +26 -18
- package/dist/node/cli.mjs +63 -10
- package/dist/node/shared-P6KINBNR.mjs +2113 -0
- package/dist/node/{shared-4FIU6DYP.mjs → shared-VQKZUUXF.mjs} +106 -17
- package/dist/node/vite.mjs +7 -3
- package/dist/prepared.mjs +2 -0
- package/dist/umber.css +1 -1
- package/dist/umber.js +2 -2
- package/dist/umber.mjs +2 -2
- package/docs/AI-quick.md +43 -87
- package/docs/AI.md +1965 -1828
- package/docs/npm.md +13 -16
- package/package.json +31 -48
- package/types/assets.d.ts +109 -4
- package/types/astro.d.ts +20 -23
- package/types/debug.d.ts +1 -1
- package/types/esm.d.ts +2 -6
- package/types/input.d.ts +3 -3
- package/types/loop.d.ts +21 -9
- package/types/module.d.ts +0 -2
- package/types/scrollfx.d.ts +5 -41
- package/types/scrub.d.ts +2 -2
- package/types/three.d.ts +26 -1
- package/types/umber.d.ts +152 -155
- package/types/vite.d.ts +3 -3
- package/dist/chunks/views.js +0 -2
- package/dist/frameworks/astro.mjs +0 -2
- package/dist/frameworks/react.mjs +0 -2
- package/dist/frameworks/svelte.mjs +0 -2
- package/dist/frameworks/vue.mjs +0 -2
- package/dist/modules/router-swap.js +0 -2
- package/dist/modules/router.js +0 -2
- package/dist/modules/router.mjs +0 -2
- package/dist/modules/scroll-more.js +0 -2
- package/dist/modules/scroll-touch.js +0 -2
- package/dist/modules/scroll.js +0 -2
- package/dist/modules/scroll.mjs +0 -2
- package/dist/node/shared-3Q24RNIF.mjs +0 -602
- package/types/react.d.ts +0 -15
- package/types/router.d.ts +0 -223
- package/types/scroll.d.ts +0 -190
- package/types/svelte.d.ts +0 -16
- package/types/vue.d.ts +0 -14
package/dist/chunks/gl.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Umber v0.
|
|
2
|
-
var e=()=>{};var t=()=>Promise.reject(new Error("no words"));var s={configure:e,debug:!1,warnings:!1,info:e,warn:e,error:e,report:e,words:t},i=s;function r(e){i=e}var n=()=>{let e=typeof window<"u"?window.occluzeCapture:void 0;return e?.version===1?e:null},a=()=>new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(0)});var l=/(swiftshader|llvmpipe|software|basic render)|mali-4|mali-t|adreno \(tm\) [2-5]|powervr|intel\(r\) hd graphics [2-5]/i,o=[1400,1600];function h(e){return e<2?"low":e<4?"mid":"high"}var u=e=>typeof e=="string"?e:"";function d(e){let t=/^(m?)([0-5])$|^(low|mid|high)$/.exec(e.trim().toLowerCase());if(!t)return null;let[,s,i="",r]=t;return r?{level:"lmh".indexOf(r.charAt(0))*2+1,mobile:!1}:{level:+i,mobile:!!s}}function c(e){let t=u(e.getParameter(e.RENDERER));if(!t||/^(webkit webgl|mozilla|webgl)$/i.test(t.trim())){let s=e.getExtension("WEBGL_debug_renderer_info");s&&(t=u(e.getParameter(s.UNMASKED_RENDERER_WEBGL))||t)}return t}function f(e){let t=l.exec(e);return t?[t[1]?0:1,`rule: ${t[0]}`]:[2,"default"]}function m(e,t){let s=c(t),i=e.env.isTouch&&Math.min(screen.width,screen.height)<820,r,n="url",a=e.gpu?d(e.gpu):null;if(e.gpu&&!a&&e.lib.say("gpu",[e.gpu]),a)({level:r,mobile:i}=a);else{let[e,t]=f(s);r=e<2?e:e+(i?0:2),n=t}let l=r>3;return{level:r,tier:h(r),mobile:i,renderer:s,reason:n,maxTexture:Math.min(t.getParameter(t.MAX_TEXTURE_SIZE),l?4096:2048),textureBudget:(l?192:96)*2**20,wide:(i?void 0:o[r])??1/0}}function p(e){if(!(!e||typeof navigator<"u"&&/apple/i.test(navigator.vendor||"")))try{e.isContextLost()||e.getExtension("WEBGL_lose_context")?.loseContext()}catch{}}var g=class{constructor(e,t){this.stage=e;this.own=t;this.dirty=!0;this.tweening=!1;this.pb="dormant";this.changing=0;this.onRequest=new Set;this.Za=2;this.Oa=0;this.pc=!1;this.xb=0;this.holds=new Set}markDirty(){this.dirty=!0,this.xb=0,this.request()}request(){!this.inactive&&!document.hidden&&this.stage.env.host.ticker.wake(1);for(let e of this.onRequest)e()}wake(e=1){this.oa(e),this.markDirty()}get forced(){return this.Za}oa(e){this.Za=Math.max(this.Za,e)}Lh(){this.Za>0&&this.Za--}live(e){typeof e=="number"?(this.pc=!1,this.Oa=Math.max(this.Oa,performance.now()+e*1e3)):(this.pc=e,e||(this.Oa=0)),this.markDirty()}Xb(e){this.Oa=Math.max(this.Oa,performance.now()+e*1e3),this.markDirty()}Na(e){return this.pc||this.changing>0||e<this.Oa}hold(e){this.holds.has(e)||(this.holds.add(e),!(this.holds.size>1)&&(this.stage.chunks.morph?.cancel(),this.own.showDom()))}release(e){if(!(!this.holds.delete(e)||this.holds.size)){for(let e of this.stage.planes.all)e.status!=="error"&&e.setStatus("loading"),e._G();this.own.invalidate(),this.wake(2)}}get paused(){return this.holds.size>0}get pauses(){return this.holds}get inactive(){return this.paused||this.stage.gpu.context.state!=="live"||this.stage.env.destroyed}mc(e){let t=performance.now(),s=this.stage.planes.all;e?this.xb=0:this.xb++;let i=()=>s.some(e=>e.zone.screen);e||this.forced>0||this.stage.gpu.media.uploads.length>0||this.tweening||this.stage.chunks.morph?.busy===!0||this.Na(t)||s.some(e=>e.visible&&e.status==="loading"&&(e.zone.near||e.zone.soon)&&!e.raster?.empty)||s.some(e=>t<e.animUntil&&(e.animUntil===1/0?e.zone.screen:e.zone.soon))||this.stage.chunks.Ga||this.stage.env.frame.scrolled&&s.some(e=>e.live&&(e.zone.soon||e.visible))||this.xb<60&&i()?this.request():(this.pb=i()?"asleep":"dormant",this.stage.env.stats.busy=[])}};var v=8,b=6e4,y=2,w=2e3,x=6e4,k=class{constructor(){this.state="live";this.losses=0;this.recent=[]}lose(e=performance.now()){this.losses++,this.recent=this.recent.filter(t=>e-t<b),this.recent.push(e)}lf(){let e=this.recent.length-y;return e>0?Math.min(x,w*2**(e-1)):0}get gone(){return this.state==="lost"||this.state==="failed-lost"||this.state==="given-up"}get off(){return this.state==="failed"||this.state==="failed-lost"||this.state==="given-up"}};function _(e,t){let s=e.gpu.context;s.lose(),s.losses<=v?(t.preventDefault(),s.state=s.off?"failed-lost":"lost"):(e.env.lib.say("losses",[s.losses]),s.state="given-up",document.documentElement.classList.remove("has-umber")),E(e),s.off&&e.env.host.off("context-lost")}function E(e){e.chunks.morph?.cancel();for(let t of e.planes.all){t.setStatus(null),t.status==="loading"&&t.wait(),t.el.removeAttribute("data-umber-morphing"),t.textureState!=="error"&&(t._l?.(),t._l=null,t.textureState="none"),t.texture=null,t.prev=null,t.program=null,t.grid=null;for(let e of t.parts())e?.lost?.()}for(let t of e.gpu.subsystems)t.lost?.();e.chunks.layers?.fade.forget(),e.gpu.media.vc(),e.chunks.views?.lost(),e.env.host.emit("lost"),e.gpu.context.state==="lost"&&e.env.lib.say("lost",[])}function M(e,t,s){if(!e.gpu.context.off){i.error(`GL ${t} failed; the plain DOM shows for the rest of this visit.`),e.gpu.context.state=e.gpu.context.gone?"failed-lost":"failed";try{e.chunks.morph?.cancel()}catch{}S(e),document.documentElement.classList.remove("has-umber"),e.env.host.off("error",s)}}function S(e){for(let t of e.planes.all)t.status!=="error"&&(t.setStatus(null),t.wait()),t.el.removeAttribute("data-umber-morphing");if(!e.gpu.context.gone)try{e.gpu.gl.clearColor(0,0,0,0),e.gpu.gl.clear(e.gpu.gl.COLOR_BUFFER_BIT)}catch{}}var A=`#version 300 es\nprecision highp float;\nlayout(location=0)in vec2 aPosition;\nuniform vec2 uViewport;\nuniform vec4 uSurface;\nuniform vec4 uRect;\nuniform vec2 uSize;\nuniform mat3 uPlaneMatrix;\nuniform float uTime;\nuniform float uScrollVelocity;\nuniform vec2 uMouse;\nuniform float uProgress;\nuniform float uBleed;\nout vec2 vUv;\n#define PI 3.141592653589793\n/*__VERTEX_HEAD__*/\nvoid main(){\nvec2 uv=(aPosition*(uSize+2.0*uBleed)-uBleed)/uSize;\nvUv=uv;\nvec3 pos=vec3(0.0);\n/*__VERTEX_MAIN__*/\nvec3 h=uPlaneMatrix*vec3(uv*uSize+pos.xy,1.0);\nh.xy-=uSurface.xy*h.z;\ngl_Position=vec4(h.x/uSurface.z*2.0-h.z,h.z-h.y/uSurface.w*2.0,pos.z*0.0001*h.z,h.z);\n}\n`,R=`#version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n#define UMBER_FRAGMENT\nin vec2 vUv;\nout vec4 outColor;\nuniform vec2 uViewport;\nuniform vec4 uSurface;\nuniform vec4 uRect;\nuniform vec2 uSize;\nuniform float uTime;\nuniform float uScrollVelocity;\nuniform vec2 uMouse;\nuniform float uProgress;\nuniform float uAlpha;\nuniform vec4 uRadius;\nuniform float uRadiusKy;\nuniform float uDpr;\nuniform vec2 uCanvas;\nuniform float uUmberHdr;\nuniform int uUmberClips;\nuniform mat3 uUmberClipXf[2];\nuniform vec4 uUmberClipBox[2];\nuniform vec4 uUmberClipRadius[2];\nuniform vec4 uUmberClipPoly[4];\nuniform vec2 uUmberClipPolyInfo;\nuniform sampler2D uImage;\nuniform vec2 uImageSize;\nuniform float uFit;\nuniform vec2 uFitPosition;\n#define PI 3.141592653589793\nvec2 fitUv(vec2 uv){\nif(uFit>2.5)return(uv*uSize-uFitPosition)/uImageSize;\nif(uFit>1.5)return uv;\nvec2 ratio=uSize/max(uImageSize,vec2(1.0));\nfloat s=uFit<0.5?max(ratio.x,ratio.y):min(ratio.x,ratio.y);\nvec2 scaled=uImageSize*s;\nvec2 offset=(uSize-scaled)*uFitPosition;\nreturn(uv*uSize-offset)/scaled;\n}\nvec4 sampleImage(vec2 uv){\nvec2 f=fitUv(uv);\nvec4 c=texture(uImage,f);\nif(uFit>0.5&&uFit<1.5&&(f.x<0.0||f.y<0.0||f.x>1.0||f.y>1.0))c=vec4(0.0);\nc.rgb/=max(c.a,1e-5);\nreturn c;\n}\nfloat roundedBox(vec2 p,vec2 size,vec4 r){\nvec4 s=max(r+r.yzwx,1e-5);\nr*=min(1.0,min(min(size.x/s.x,size.y/s.y),min(size.x/s.z,size.y/s.w)));\nvec2 h=size*0.5;\nvec2 d=abs(p-h)-h;\nfloat o=length(max(d,0.0))+min(max(d.x,d.y),0.0);\nvec2 q=p;\nif(max(q.x,q.y)<r.x)o=max(o,length(q-r.x)-r.x);\nq=vec2(size.x-p.x,p.y);\nif(max(q.x,q.y)<r.y)o=max(o,length(q-r.y)-r.y);\nq=size-p;\nif(max(q.x,q.y)<r.z)o=max(o,length(q-r.z)-r.z);\nq=vec2(p.x,size.y-p.y);\nif(max(q.x,q.y)<r.w)o=max(o,length(q-r.w)-r.w);\nreturn o;\n}\nvec2 umberClipPoint(int i){\nvec4 v=uUmberClipPoly[i/2];\nreturn(i-(i/2)*2)==0?v.xy:v.zw;\n}\nfloat umberPolygon(vec2 p){\nint n=int(uUmberClipPolyInfo.y+0.5);\nfloat d=1e20;\nfloat s=1.0;\nfor(int i=0;i<8;i++){\nif(i>=n)break;\nvec2 a=umberClipPoint(i);\nvec2 b=umberClipPoint(i==0?n-1:i-1);\nvec2 e=b-a;\nvec2 w=p-a;\nvec2 q=w-e*clamp(dot(w,e)/max(dot(e,e),1e-8),0.0,1.0);\nd=min(d,dot(q,q));\nbvec3 c=bvec3(p.y>=a.y,p.y<b.y,e.x*w.y>e.y*w.x);\nif(all(c)||all(not(c)))s= -s;\n}\nreturn s*sqrt(d);\n}\nfloat umberClip(){\nfloat cover=1.0;\nfor(int i=0;i<2;i++){\nif(i>=uUmberClips)break;\nvec3 q=uUmberClipXf[i]*vec3(gl_FragCoord.xy,1.0);\nvec2 p=q.xy/q.z;\nfloat d=float(i)==uUmberClipPolyInfo.x\n?umberPolygon(p)\n:roundedBox(p-uUmberClipBox[i].xy,uUmberClipBox[i].zw,uUmberClipRadius[i]);\nfloat k=clamp(0.5-d/max(length(vec2(dFdx(d),dFdy(d))),1e-4),0.0,1.0);\ncover*=q.z<0.0?1.0-k:k;\n}\nreturn cover;\n}\n/*__FRAGMENT_HEAD__*/\nvoid main(){\nvec2 uv=vUv;\n/*__FRAGMENT_UV__*/\nvec4 color= /*__FRAGMENT_SOURCE__*/;\n/*__FRAGMENT_COLOR__*/\nfloat alpha=uAlpha;\nvec2 umberK=vec2(1.0,uRadiusKy>0.0?uRadiusKy:1.0);\nfloat umberD=roundedBox(vUv*uSize*umberK,uSize*umberK,uRadius);\nfloat umberW=max(length(vec2(dFdx(umberD),dFdy(umberD))),1e-4);\nif(uRadius.x+uRadius.y+uRadius.z+uRadius.w>0.0)alpha*=clamp(0.5-umberD/umberW,0.0,1.0);\n/*__FRAGMENT_ALPHA__*/\nif(uUmberClips>0)alpha*=umberClip();\nfloat a=clamp(color.a*alpha,0.0,1.0);\noutColor=vec4((uUmberHdr>0.5?max(color.rgb,0.0):clamp(color.rgb,0.0,1.0))*a,a);\n}\n`,T={},z=/\b(umberHash|noise|fbm|rotate2d|screenUv|screenPx|samplePrev)\s*\(|\buScreen\b/;function U(e,t=T){let s=new Map,i=r=>{let n=t[r];if(!(!n||s.has(r)||n.defined.test(e))){for(let e of n.needs??[])i(e);s.set(r,n)}};for(let[s,r]of Object.entries(t))r.used.test(e)&&i(s);return[...s.values()].map(e=>e.code).join(`\n\n`)}var P="#define PI 3.141592653589793";function C(e,t,s){return e.map(({name:e,def:i})=>{let r=t(i);return r?`// ${s}: ${e}\n {\n${B(r)}\n }`:""}).filter(Boolean).join(`\n\n `)}function F(e,t){return e.map(({name:e,def:s})=>{let i=t(s);return i?`// ${e}\n${i}`:""}).filter(Boolean).join(`\n\n`)}function L(e){let{effects:t,shader:s,uniforms:i,chunks:r={vertex:"",fragment:""}}=e,n=[...t.map(({def:e})=>`${e.vertex?.head??""}\n${e.fragment?.head??""}`),s?.def.head??"",r.vertex+r.fragment].join(`\n`),a=j(i,n),l=$(e,r).replace(P,`${P}\n\n${a}`);return{vertex:I(t,r).replace(P,`${P}\n\n${a.split(`\n`).filter(e=>!e.includes("sampler2D")).join(`\n`)}`),fragment:l}}function I(e,t){let s=e.map(({def:e})=>`${e.vertex?.head??""}\n${e.vertex?.main??""}`).join(`\n`)+t.vertex,i=U(s);return A.replace("/*__VERTEX_HEAD__*/",[i?`// helpers\n${i}`:"",t.vertex,F(e,e=>e.vertex?.head)].filter(Boolean).join(`\n\n`)).replace("/*__VERTEX_MAIN__*/",C(e,e=>e.vertex?.main,"vertex"))}function N(e){return`// shader: ${e.name}\n${e.def.head??""}\nvec4 umberSurface(vec2 uv) {\n vec4 color = vec4(0.0);\n {\n${B(e.def.fragment)}\n }\n return color;\n}`}function D(e,t){return e!=="text"?R:R.replace(/vec4 sampleImage\(vec2 uv\) ?\{/,e=>`${H.test(t)?`#define UMBER_TEXT_FLAT\n`:""}vec4 umberText(vec2 f);\n${e}`).replace(/texture\(uImage, ?f\)/,"umberText(f)")}function $({kind:e,effects:t,shader:s},i){let r=e==="shader"&&s?s:null,n=[...t.map(({def:e})=>Object.values(e.fragment??{}).join(`\n`)),s?`${s.def.head??""}\n${s.def.fragment}`:"",i.fragment,e==="text"?"umberText()":""].join(`\n`),a=U(n),l=/\bsampleRaw\s*\(/.test(n)&&!/vec4\s+sampleRaw\s*\(/.test(n)?"vec4 sampleRaw(vec2 uv) { vec4 c = sampleImage(uv); return vec4(c.rgb * c.a, c.a); }":"";return D(e,n).replace("/*__FRAGMENT_HEAD__*/",[a?`// helpers\n${a}`:"",l,i.fragment,r?N(r):"",F(t,e=>e.fragment?.head)].filter(Boolean).join(`\n\n`)).replace("/*__FRAGMENT_UV__*/",C(t,e=>e.fragment?.uv,"uv")).replace("/*__FRAGMENT_SOURCE__*/",r?"umberSurface(uv)":"sampleImage(uv)").replace("/*__FRAGMENT_COLOR__*/",C(t,e=>e.fragment?.color,"color")).replace("/*__FRAGMENT_ALPHA__*/",C(t,e=>e.fragment?.alpha,"alpha"))}function B(e){return e.trim().split(`\n`).map(e=>` ${e}`).join(`\n`)}var O=new Set(["uViewport","uSurface","uRect","uSize","uTime","uScrollVelocity","uMouse","uProgress","uAlpha","uRadius","uRadiusKy","uDpr","uImage","uImageSize","uFit","uFitPosition","uGlyphIndex","uGlyphData","uUmberTextLayout","uUmberTextColor","uUmberCurves","uUmberBands","uUmberGlyphs","uPlaneMatrix","uCanvas","uBleed","uUmberClips","uUmberClipXf","uUmberClipBox","uUmberClipRadius","uUmberClipPoly","uUmberClipPolyInfo","uUmberHdr"]),H=/\bglyph\s*\(/;function q(e){if(typeof e=="number"||typeof e=="boolean")return"float";if(Array.isArray(e)||ArrayBuffer.isView(e)){let t=e.length;return t===2?"vec2":t===3?"vec3":t===4?"vec4":t===9?"mat3":t===16?"mat4":null}return typeof e=="string"?"sampler2D":e&&typeof e=="object"?"highp sampler2D":null}function G(e,t){let s=e=>e.charAt(0).toUpperCase()+e.slice(1),i=e=>e.split(/[-_\s]+/).map(s).join("");return`u${i(e)}${i(t)}`}var V=/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g;function W(e){let t=e.replace(/\\n/g,`\n`).replace(V," ");return e=>new RegExp(`\\buniform\\b[^;]*\\b${e}\\b`).test(t)}function j(e,t){let s=[],i=W(t);for(let t in e){if(O.has(t)||i(t))continue;let r=q(e[t]);r&&s.push(`uniform ${r} ${t};`)}return s.join(`\n`)}var X=5e3,Y=class{constructor(e){this.start=e;this.pending=null}get(){return this.pending??=this.start()}get asked(){return this.pending}forget(){this.pending=null}},K=class{constructor(e){this.stage=e;this.text=null;this.mb=new Set;this.La=new Set;this.shapes=null;this.shapesError=null;this.Ga=!1;this.layers=null;this.views=null;this.video=null;this.ob=new Set;this.morph=null;this.fx=null;this.flow=null;this.warm=null;this.instances=null;this.za=null;this.flip=null;this.gone=new Map;this.lc=new Set;this.Gc=new Y(()=>this.load({load:this.stage.env.host.loadText,file:"text",dom:'data-umber="text" stays normal DOM text.',made:(e,t)=>(T.glyph=e.GLYPH_HELPER,T.umberText=e.TEXT_HELPER,e.textPlanes(this.stage,t),!0),failed:()=>{this.Rh()}}).then(e=>{e||(this.gone.delete("text"),this.Gc.forget())}));this.wg=new Y(()=>this.load({load:this.stage.env.host.loadLayers,file:"layers",dom:'three.js layers (data-umber="layer", umber.view()) stay off and keep their DOM content.',made:e=>e.layers(this.stage),failed:()=>{for(let e of this.stage.planes.all)e.kind==="layer"&&!e.layer&&e.setStatus("error")}}));this.ii=new Y(()=>this.load({load:this.stage.env.host.loadVideo,file:"video",dom:"GL videos and module elements show their DOM.",made:e=>{e.video(this.stage)},failed:()=>{this.pa(this.ob,{failed:!0})}}));this.mg=new Y(()=>this.load({load:this.stage.env.host.loadGlsl,file:"glsl",dom:"planes whose effects #include a chunk or share a helper name show their DOM.",made:e=>{this.stage.gpu.programs.glsl=e.glsl(this.stage),Object.assign(T,e.GLSL_HELPERS),this.stage.planes.defined("chunk","")},failed:()=>{for(let e of this.stage.planes.all)e.missing.includes("chunk:")&&e.setStatus("error")}}));this.rg=new Y(()=>this.load({load:this.stage.env.host.loadInstances,file:"instances",dom:"planes with instances show their DOM.",made:e=>{this.instances=e.instances(this.stage),this.pa(this.lc)},failed:()=>{this.pa(this.lc,{failed:!0})}}));this.bg=new Y(()=>this.load({load:this.stage.env.host.loadFlip,file:"flip",dom:"elements jump to their new place and pictures change at once.",made:e=>this.flip=e.flip(this.stage)}));this.kg=new Y(()=>this.load({load:this.stage.env.host.loadFx,file:"fx",dom:"render targets stay off and backdrop planes show their DOM.",made:(e,t)=>e.fx(this.stage,T,t),failed:()=>{for(let e of this.stage.planes.all)e.backdrop&&e.setStatus("error")}}));this.ni=new Y(()=>this.load({load:this.stage.env.host.loadWarm,file:"warm",dom:"nothing is loaded ahead and placeholders stay off.",made:e=>this.warm=e.warm(this.stage)}));this.vd=new Y(()=>this.load({load:this.stage.env.host.loadMorph,file:"morph",dom:"data-umber-id images reveal on their own page instead of flying.",made:e=>e.morph(this.stage)}));this.Gh=new Y(()=>this.load({load:this.stage.env.host.loadShapes,file:"shapes",dom:"GL elements cut, turned or tilted by CSS show their DOM.",made:e=>{this.Ga=!1,e.shapes(this.stage)},failed:e=>{this.Sd(e??"")}}))}load({load:e,file:t,dom:s,made:r,failed:n,wait:a=(n?X:0)}){let l=!1,o=(e,r)=>(this.stage.env.destroyed||l||(l=!0,r===void 0?i.error(`${e}; ${s}`):i.error(`${e}; ${s}`,r),this.gone.set(t,n),n?.(e)),null),h=()=>o(`chunks/${t}.js took more than ${a/1e3} s to load`),u=e=>o(`chunks/${t}.js failed to load`,e);return a&&setTimeout(h,a),e?e().then(e=>(l=!0,this.stage.env.destroyed?null:r(e,this.gone.delete(t))),u):Promise.resolve().then(()=>o(`this build has no chunks/${t}.js`))}Ma(e){this.gone.get(e)?.()}pa(e,{failed:t=!1}={}){for(let s of e)s.destroyed?e.delete(s):t?s.setStatus("error"):s.el.isConnected&&this.stage.planes.ca(s);t||e.clear()}loadText(){if(!this.text){if(this.Gc.asked){this.Ma("text");return}this.Gc.get()}}loadLayers(){return this.wg.get()}loadVideo(){this.ii.get(),this.Ma("video")}loadGlsl(){this.mg.get()}loadInstances(e){this.lc.add(e),this.rg.get(),this.Ma("instances")}loadFlip(){return this.bg.get()}loadFx(){return this.kg.get()}loadWarm(){return this.ni.get()}loadMorph(){return this.vd.get()}get Mg(){return this.vd.asked}loadShapes(){this.Gh.get()}Rh(){this.mb.clear(),this.pa(this.La,{failed:!0});for(let e of this.stage.planes.all)e.kind==="text"&&(this.La.delete(e),e.textureState="error",e.status!=="error"&&e.setStatus("error"))}Sd(e){this.shapesError=e,this.Ga=!1;for(let e of this.stage.planes.all)e.shapeWait&&(e.stale=!0);this.stage.scheduler.markDirty()}};function J(e){return typeof e=="number"?new Float64Array(e):new Float64Array(e)}function Z(e){return typeof e=="number"?new Float32Array(e):new Float32Array(e)}function Q(e){return new Int32Array(e)}var ee=(e,t)=>e[t]??NaN;var te=e=>parseFloat(e??"0")||0,se=(e,t)=>e===void 0||e===""?t:e,ie=e=>!!e&&e!=="none";function re(e){try{return e.matches(":modal")||e.matches(":popover-open")}catch{return!1}}function ne(e,t){let s=t.get(e);if(s)return s;let i=getComputedStyle(e),r=[i.maskImage,i.getPropertyValue("-webkit-mask-image"),i.maskBorderSource,i.getPropertyValue("-webkit-mask-box-image-source")].some(ie),n={el:e,tag:e.localName||e.tagName.toLowerCase(),display:i.display,position:se(i.position,"static"),overflowX:se(i.overflowX,"visible"),overflowY:se(i.overflowY,"visible"),contain:se(i.contain,"none"),contentVisibility:se(i.contentVisibility,"visible"),willChange:se(i.willChange,"auto"),filter:se(i.filter,"none"),backdropFilter:se(i.backdropFilter||i.webkitBackdropFilter,"none"),clipPath:se(i.clipPath,"none"),clip:se(i.getPropertyValue("clip"),"auto"),mask:r,transform:se(i.transform,"none"),translate:se(i.translate,"none"),rotate:se(i.rotate,"none"),scale:se(i.scale,"none"),perspective:se(i.perspective,"none"),transformOrigin:se(i.transformOrigin,""),perspectiveOrigin:se(i.perspectiveOrigin,""),transformStyle:se(i.transformStyle,"flat"),backfaceVisibility:se(i.backfaceVisibility||i.getPropertyValue("-webkit-backface-visibility"),"visible"),offsetPath:se(i.offsetPath,"none"),opacity:se(i.opacity,"1"),isolation:se(i.isolation,"auto"),mixBlendMode:se(i.mixBlendMode,"normal"),zoom:se(i.zoom,"1"),topLayer:re(e)};return t.set(e,n),n}var ae=new Float64Array(64);var le=e=>(e.overflowY==="auto"||e.overflowY==="scroll")&&e.el.scrollHeight>e.el.clientHeight;function oe(e){let t=e.width.endsWith("px")?te(e.width):NaN,s=e.height.endsWith("px")?te(e.height):NaN;return e.boxSizing!=="border-box"&&(t+=te(e.paddingLeft)+te(e.paddingRight)+te(e.borderLeftWidth)+te(e.borderRightWidth),s+=te(e.paddingTop)+te(e.paddingBottom)+te(e.borderTopWidth)+te(e.borderBottomWidth)),[t,s]}function he(e){return e.assignedSlot??e.parentElement??e.parentNode?.host??null}function ue(e,t){let s=[],i=e;for(;i;){let e=ne(i,t);if(s.push(e),e.tag==="html"||e.topLayer)break;i=he(i)}return s}var de=(e,...t)=>t.some(t=>new RegExp(`\\b${t}\\b`).test(e)),ce=e=>e.tag==="html",fe=e=>{let t=ce(e)?e.willChange.replace(/(^|,)\s*(backdrop-)?filter\s*(?=,|$)/g,"$1"):e.willChange;return de(t,"transform","perspective","filter","translate","rotate","scale")},me=["transform","translate","rotate","scale","perspective","filter","backdropFilter"];function pe(e,{countZoom:t=!0}={}){for(let t of me)if(e[t]!=="none"&&!(ce(e)&&t.endsWith("ilter")))return`${t==="backdropFilter"?"backdrop-filter":t}: ${e[t]}`;if(de(e.contain,"layout","paint","strict","content"))return`contain: ${e.contain}`;if(e.contentVisibility==="auto"||e.contentVisibility==="hidden")return`content-visibility: ${e.contentVisibility}`;if(fe(e))return`will-change: ${e.willChange}`;let s=parseFloat(e.zoom??"1");return t&&Number.isFinite(s)&&Math.abs(s-1)>1e-6?`zoom: ${e.zoom}`:null}var ge=e=>pe(e,{countZoom:!1})!==null;function ve(e,t=null){for(let[s,i]of e.entries()){if(i.tag==="html")break;if(i.tag!=="body"&&i.el.classList.contains("pin-spacer")||i.position==="fixed"&&!be(e,s)||i.position==="sticky"&&ye(e,s,t))return!0}return!1}function be(e,t){return e.some((e,s)=>s>t&&ge(e))}function ye(e,t,s){for(let i=t+1;i<e.length;i++){let t=e[i];if(!t)break;if(t.el===s||t.tag==="html"||t.tag==="body")return!0;if(Me(t))return!1}return!0}function we(e){if(e==="none"||e==="")return!0;let t=/^matrix\((.*)\)$/.exec(e);if(!t)return!1;let[,s=""]=t,[i,r,n,a]=s.split(",").map(Number);return i===void 0||r===void 0||n===void 0||a===void 0?!1:Math.abs(r)<=1e-9&&Math.abs(n)<=1e-9&&i>1e-9&&a>1e-9}function xe(e,t=()=>!1){let s=ke(e);for(let[i,r]of e.entries())if(!Ee(r)||i>0&&Se(r)&&!(_e(r,s)||r.tag==="body"&&r.zoom==="1"&&t(r)))return!1;return!0}function ke(e){let t=e.at(-1);return t?.tag!=="html"||t.overflowX==="visible"&&t.overflowY==="visible"}function _e(e,t){return e.tag==="html"||e.tag==="body"&&(t||le(e))}function Ee(e){if(e.mask||e.clipPath!=="none"||e.clip!=="auto"&&e.clip!==""||e.topLayer||e.rotate!=="none"||e.perspective!=="none"||e.offsetPath!=="none"&&e.offsetPath!==""||e.el.namespaceURI==="http://www.w3.org/2000/svg")return!1;let t=e.scale.split(" ");return!we(e.transform)||e.translate.split(" ").length>2?!1:e.scale==="none"||t.length<=2&&t.every(e=>parseFloat(e)>1e-9)}function Me(e){let t=e=>e==="hidden"||e==="auto"||e==="scroll"||e==="overlay";return e.display!=="inline"&&e.display!=="contents"&&(t(e.overflowX)||t(e.overflowY))}function Se(e){return e.display==="inline"?!1:e.overflowX!=="visible"||e.overflowY!=="visible"||de(e.contain,"paint","strict","content")||e.contentVisibility==="auto"||e.contentVisibility==="hidden"}var Ae=3e3;function Re(e,t){e.setStatus(t?"loading":null),e.wait()}function Te(e,t){return{el:e.el,reason:t==="oval"?"its rounded corners have different shapes, so its DOM shows":t}}var ze=e=>e.xfReason??e._F??e._I??e._x??e._j,Ue=class{constructor(e){this.stage=e}Fa(e,t){e.warned.has(t)||(e.warned.add(t),i.warn(t,e.el))}decide(e){if(e.kind==="layer"){e.level&&this.stage.chunks.layers?.upright(e);return}this.ub(e,ze(e))}report(e,t=e.domReason){this.stage.env.host.emit("fallback",Te(e,t))}ub(e,t){if(t===e.domReason)return;let s=e.domReason;e.domReason=t,t?(this.Fa(e,t),e.setStatus("error"),s&&s===e._j&&(e.emit("error"),this.report(e)),this.stage.env.lib.unmarkMedia(e.el)):s&&e.textureState!=="error"&&(e.media&&this.stage.env.lib.markMedia(e.el,e.media),Re(e),e.zone.near&&e.textureState==="none"&&this.stage.factory.load(e)),(!t||!s)&&this.stage.scheduler.markDirty()}};function Pe(e,t,s){let i=t.state;if(i.status==="loading"){if(!Fe(t)){i.waitingSince=null;return}i.waitingSince===null&&(i.waitingSince=s,t.emit("wait")),!(s-i.waitingSince<Ae)&&(e.say("slow",[Ae/1e3],t.el),t.slow=!0,t.setStatus("error"),e.unmarkMedia(t.el))}}function Ce(e,t){t.slow&&(t.slow=!1,!t.domReason&&(t.media&&e.markMedia(t.el,t.media),Re(t)))}function Fe(e){let t=(e.textureState==="none"||e.textureState==="loading"||e.textureState==="queued")&&!e.raster?.empty,s=!e.modules.feed||e.plays.la.size>0;return e.kind!=="layer"&&e.visible&&!!e.opacity&&t&&s&&e.el.getAttribute("data-umber-status")==="loading"}function Le(e,t,s){let i=/^(static|relative)$/.test(getComputedStyle(e).position),r=document.documentElement,n=s.bodyOrNull(),a=new Map,l=e=>pe(ne(e,a));if(t==="created"&&n&&e.parentElement===n&&l(n)?.startsWith("zoom:")&&r.insertBefore(e,n),i)return"umber.css";for(let t=e.parentElement;t;t=t.parentElement){let e=l(t);if(e)return`${t===r||t===n?`<${t.localName}>`:s.describe(t)} has ${e}`}return null}function Ie(e,t,s,i){if(!e||e===document.documentElement||s&&e.contains(s))return 1;let r=getComputedStyle(e);if(!i&&r.visibility==="hidden")return 0;let n=t.get(e);if(n!==void 0)return n;let a=r.display==="none"?0:parseFloat(r.opacity);Number.isFinite(a)||(a=1);let l=a===0?0:a*Ie(e.parentElement,t,s,1);return t.set(e,l),l}function Ne(e,t){if(e._x=null,e.kind==="text"||e.kind==="layer"){e.fit=2,e.radius.fill(0);return}let s=e.el,i=e.media,r=getComputedStyle(s),n=i&&i!==s?getComputedStyle(i):r,a=e._f,l=e._d,o=De(e,a,l),h=a>0?a:e.doc.w,u=l>0?l:e.doc.h,d=(e=>e===s?r:e===i?n:getComputedStyle(e))(e.geomEl),c=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"],f=(e,t)=>e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0,m=[0,0,0,0],p=[0,0,0,0],g=0,v=!1;for(let[e,t]of c.entries()){let[s="",i=s]=(d[t]||"0px").trim().split(/\s+/),r=f(s,h),n=f(i,u);r>0&&n>0?g?v||=Math.abs(r-n*g)>1:g=r/n:(r=0,n=0),m[e]=r,p[e]=n}e._b=g||1;let b=(e,t)=>t>0?e/t:1,y=Math.min(1,b(h,m[0]+m[1]),b(u,p[1]+p[2]),b(h,m[2]+m[3]),b(u,p[3]+p[0]));m.forEach((t,s)=>{e.radius[s]=t*y*o}),v&&(e._x="oval",e.warned.add(e._x),t("oval",[e.geomEl],e.el));let w=s.getAttribute("data-umber-fit"),x=(w??"")||n.objectFit;e.fit=$e(x,!!w),e.objectPosition=(n.objectPosition||"50% 50%").split(/\s+/),Oe(e)}function De(e,t,s){return e.level?e.edge[0]:t>0&&s>0&&Math.abs(e.doc.w-t)>.01?Math.min(e.doc.w/t,e.doc.h/s):1}function $e(e,t){return e==="contain"?1:e==="fill"&&t?2:0}function Be(e,t){let s=parseFloat(e);return e.endsWith("%")?s/100:e.endsWith("px")?t*t>.25?s/t:0:.5}function Oe(e){let t=e.objectPosition;if(!t)return;let s=e._f>0?e._f:e.doc.w,i=e._d>0?e._d:e.doc.h,r=e.texture?.ready?e.texture:null,n=e.media,a=NaN,l=NaN;r?(a=(r.box?.[2]??0)||r.width,l=(r.box?.[3]??0)||r.height):n&&(a=n.naturalWidth||n.videoWidth,l=n.naturalHeight||n.videoHeight);let o=(e.fit?Math.min:Math.max)(s/a,i/l);t.forEach((t,r)=>{e._g[r]=Be(t,r?i-l*o:s-a*o)})}function He(e){let t=e.media;return(e.kind==="image"||e.kind==="video")&&t&&t!==e.el&&e.el.contains(t)&&t.getClientRects().length>0?t:e.el}function qe(e,t,s,i=e.rect){let r=e.offset;if(i[0]=e.doc.x-t+(r?r[0]:0),i[1]=e.doc.y-s+(r?r[1]:0),i[2]=e.doc.w,i[3]=e.doc.h,e.pad){let t=e.pad*(e.layoutW?e.doc.w/e.layoutW:1),s=e.pad*(e.layoutH?e.doc.h/e.layoutH:1);i[0]-=t,i[1]-=s,i[2]+=t*2,i[3]+=s*2}return i}var Ge=/^(transform|translate|rotate|scale|perspective|offset[A-Z]|left|top|right|bottom|inset|width|height|min[WH]|max[WH]|margin|padding|flex|grid|clipPath|clip$|opacity|visibility|display|fontSize|letterSpacing|lineHeight|border\w*(Width|Radius)|all$|zoom)/,Ve=/^(rotate|perspective|offset|clip|display|border\w*Radius|all$|zoom)/,We={transform:/^(none|((translate[XY]?\([^()]*\)|scale[XY]?\([^()-]*\)) ?)+)$/,translate:/^\S+( \S+)?$/,scale:/^[^-\s]+( [^-\s]+)?$/},je=new WeakMap;function Xe(e){let t=je.get(e);if(t!==void 0)return t;try{let s=e.effect.getKeyframes();t=0;for(let e of new Set(s.flatMap(e=>Object.keys(e)))){if(!Ge.test(e))continue;let i=s.map(t=>t[e]).filter(e=>e!=null),r=We[e];t=Math.max(t,Ve.test(e)||r&&!(i.length&&i.every(e=>r.test(String(e).trim())))?2:1)}}catch{t=2}return je.set(e,t),t}function Ye(e,t){let s=(t-e[1])/Math.max(t+e[3],1);return Math.min(1,Math.max(0,s))}var Ke="model",Je=e=>e===Ke?"layer":e,Ze=e=>e.matches("[data-umber~=model]"),Qe=e=>Ze(e)?Ke:e.getAttribute("data-umber-layer")??"";function et(e,t){let s=e.raster,i=e.zone.soon||e.visible||t.jump||!!e.wrap,r=e.animUntil,n=!!r,a=n&&t.now<r;return{near:i,settling:e.zone.screen&&e.status==="loading"&&!e.backHidden,textWatch:e.zone.soon&&!!s?.Ca,colorWatch:tt(e,t),innerScrolled:i&&!!t.inside?.(e.geomEl),animating:e.heldMoved||a&&st(e,t,i),animationEnded:n&&!a,scrollDriven:e.scrollLinked&&i&&(t.scrolled||t.Jb),rewalk:t.Ga&&i}}var tt=(e,t)=>e.kind==="text"&&e.zone.soon&&!!e.raster&&t.now<e.raster.xa;function st(e,t,s){return e.animUntil!==1/0?s:e.zone.screen||t.scrolled&&s||e.visible}function it(e,t,s){let i=nt(e,s),r=i||e.morphHidden||s.animating||s.scrollDriven;if(e.status==="error"&&!r&&!s.innerScrolled)return null;let n=r||s.settling||s.textWatch,a=n||rt(e,t,s),l=a&&(n||t.live),o=t.jb&&e.zone.soon&&!e.opacitySettled,h=l||s.colorWatch||o;return!a&&!h?null:{rect:a,style:l,opacity:h,swept:o,full:a&&at(e,t,s,i)}}var rt=(e,t,s)=>t.live&&e.zone.soon||e.live&&s.near||s.innerScrolled,nt=(e,t)=>e.stale||t.rewalk||t.animationEnded,at=(e,t,s,i)=>i||!e.chained||s.animating&&t.Sd;var lt=new Set,ot=null;function ht(e){for(let t of lt)try{e(t)}catch{}}var ut=["play","pause","finish","reverse","cancel","updatePlaybackRate"],dt=["currentTime","startTime","playbackRate"];function ct(e){if(typeof Element>"u")return;let t=Element.prototype,s=t.animate;if(typeof s!="function")return;let i=function(...t){let i=s.apply(this,t);return e.live&&ht(e=>{e.animate(this)}),i};t.animate=i,e.undo.push(()=>{t.animate===i&&(t.animate=s)})}function ft(e){if(typeof Animation>"u")return;let t=Animation.prototype,s=t=>{e.live&&ht(e=>{e.animation(t)})};for(let i of ut){let r=Reflect.get(t,i);if(typeof r!="function")continue;let n=function(...e){let t=r.apply(this,e);return s(this),t};Reflect.set(t,i,n),e.undo.push(()=>{Reflect.get(t,i)===n&&Reflect.set(t,i,r)})}for(let i of dt){let r=Object.getOwnPropertyDescriptor(t,i),n=r?.set;if(!r?.configurable||!n)continue;let a={...r,set(e){n.call(this,e),s(this)}};Object.defineProperty(t,i,a),e.undo.push(()=>{Object.getOwnPropertyDescriptor(t,i)?.set===a.set&&Object.defineProperty(t,i,r)})}}function mt(e){if(lt.add(e),!ot){let e={live:!0,undo:[]};ct(e),ft(e),ot=e}return()=>{if(!(!lt.delete(e)||lt.size||!ot)){ot.live=!1;for(let e of ot.undo)e();ot=null}}}var pt=6,gt=12,vt=100,bt=50,yt=class{constructor(e,t,s){this.stage=e;this.observers=t;this.own=s;this.Pb=!1;this.at={full:!1,restyle:!1,r:new DOMRect,sx:0,sy:0,now:0};this.$d=!1;this.Bd=new Map;this.hb=new Set;this.ec=0;this.wb=null;this.vb=null;this.Jb=!1;this.sd=NaN;this.oc=NaN;this.kd=!1;this.Wc=null}da(){this.Pb=!0}get df(){return this.Pb}Oc(){this.Pb=!1}og(){let e=this.stage;for(let t of["pointerover","pointerout","pointerdown","focusin","focusout","keydown","input"])e.env.listen(document,t,e=>{this.hook(e)});e.env.cleanups.push(mt({animate:e=>{this.tc(e)},animation:e=>{this.uc(e)}}));let t=e=>{this.nd(e)};document.addEventListener("scroll",t,{capture:!0,passive:!0}),e.env.cleanups.push(()=>{document.removeEventListener("scroll",t,{capture:!0})}),e.env.cleanups.push(e.env.host.env.onForcedColorsChange(t=>{t?e.scheduler.hold("forced"):e.scheduler.release("forced")}))}run(e){let t=this.stage,s=performance.now(),i=t.scheduler.Na(s);if(this.$d&&!i)for(let e of t.planes.all)e.stale=!0;this.$d=i,this.own.resize();let r=this.mh(e);this.Bd.clear(),t.env.frame.Va.clear(),this.Wc=null,!t.env.frame.scrolled&&(this.vb??this.wb)&&this.hovered(s),this.Ah(e,s);let n={now:s,live:i,jump:r,jb:e.frame%gt===0,scrolled:t.env.frame.scrolled,Jb:this.Jb,Ga:t.chunks.Ga,Sd:t.chunks.shapesError!==null,inside:this.hb.size>0?e=>this.qg(e):null},a=!1;for(let e of t.planes.all)this.Kg(e,n)&&(a=!0);(a||this.kd)&&t.chunks.shapes?.Df(),this.kd=a,this.hb.clear()}Ah(e,t){e.woke&&this.da();let s=this.df||e.frame%pt===0&&this.stage.planes.all.some(e=>e.zone.soon);this.stage.chunks.shapes?this.stage.chunks.shapes.start(t,s):s&&this.Ag(t)}mh(e){let t=this.stage;t.env.frame.screen.width=window.innerWidth||t.canvasHost.viewport.width,t.env.frame.screen.height=window.innerHeight||t.canvasHost.viewport.height,t.env.frame.scrollX=e.scroll.x,t.env.frame.scrollY=e.scroll.y,t.env.host.scroll.root?(t.env.frame.pageX=window.scrollX||0,t.env.frame.pageY=window.scrollY||0):(t.env.frame.pageX=t.env.frame.scrollX,t.env.frame.pageY=t.env.frame.scrollY),this.Jb=t.env.frame.scrolled,t.env.frame.scrolled=t.env.frame.scrollX!==this.sd||t.env.frame.scrollY!==this.oc;let s=Math.abs(t.env.frame.scrollY-this.oc)>t.env.frame.screen.height/4;return this.sd=t.env.frame.scrollX,this.oc=t.env.frame.scrollY,s}Kg(e,t){let s=this.stage;if(e.destroyed||!e.el.isConnected||!e.program&&e.kind!=="layer")return!1;let i=et(e,t);i.settling&&Pe(s.env.lib,e,t.now),e.heldMoved=!1,i.animationEnded&&(e.animUntil=0),nt(e,i)&&(e.stale=!0);let r=it(e,t,i);if(!r)return!1;let n=r.rect&&this.Lg(e,r.full,r.style,t.now);return r.opacity&&this.Jg(e,r.style),e.stale&&Ne(e,s.env.lib.say),r.rect&&(e._I=s.chunks.shapes?s.chunks.shapes.Gg(e,r.full,r.style):null,s.fallbacks.decide(e)),e.kind==="text"&&s.chunks.text&&e.zone.near&&e.textureState!=="loading"&&e.textureState!=="error"&&s.chunks.text.check(e,t.now,r.swept),e.stale=!1,n}Lg(e,t,s,i){let r=this.stage;t&&(this.observers.Eh(e,He(e)),e.gen=r.batches.bd);let n=e.geomEl.getBoundingClientRect(),a=e.offset;a&&(n=new DOMRect(n.x-a[0],n.y-a[1],n.width,n.height));let l=e.scrolls?r.env.frame.scrollX:r.env.frame.pageX,o=e.scrolls?r.env.frame.scrollY:r.env.frame.pageY,h=e.doc.w!==n.width||e.doc.h!==n.height;if(e.doc.x=n.left+l,e.doc.y=n.top+o,e.doc.w=n.width,e.doc.h=n.height,e.measured=!0,h&&(e._y!==-1&&e.emit("resize"),r.gpu.media.sharpen(e)),r.chunks.shapes){let a=this.at;a.full=t,a.restyle=s,a.r=n,a.sx=l,a.sy=o,a.now=i,r.chunks.shapes.ud(e,a)}else this.Ig(e,t,n);return t&&(e.live=(e.pinned=ve(e.nodes,r.env.host.scroll.root))||r.env.lib.attr.bool(e.el,"data-umber-live"),wt(e,l,o)),!!e.scene}Jg(e,t){let s=e.media===e.el,i=Ie(s?e.el.parentElement:e.el,this.Bd,this.stage.canvasHost.el);if(s){let t=parseFloat(e.el.style.opacity);t>=0?i*=Math.min(t,1):e.status!=="ready"&&!e.el.hasAttribute("data-umber-play")&&+(getComputedStyle(e.el).opacity||1)<1&&this.stage.env.lib.say("fade",[],e.el)}e.opacitySettled=!t&&i===e.opacity,e.opacity=i}Ig(e,t,s){let i=this.stage;if(!t&&!e._r)return;let r=t?!this.mi(e,s):!this._r(document.body,s);r&&i.chunks.loadShapes(),e.xfReason=e._w=r&&i.chunks.shapesError?`${i.env.lib.describe(e.el)}: it is cut, turned or tilted by CSS, and ${i.chunks.shapesError}, so its DOM shows. Serve chunks/shapes.js next to chunks/gl.js.`:null;let n=r&&!i.chunks.shapesError;n!==e.shapeWait&&(e.shapeWait=n,n&&e.status==="ready"&&Re(e),i.scheduler.markDirty())}mi(e,t){let s=e.nodes=ue(e.geomEl,this.stage.env.frame.Va);e.chained=!0;let[i,r]=oe(getComputedStyle(e.geomEl));return e._f=Number.isFinite(i)&&i>0?i:t.width,e._d=Number.isFinite(r)&&r>0?r:t.height,e._r=!1,xe(s,s=>e._r=this._r(s.el,t))}_r(e,t){let s=this.Wc??=e.getBoundingClientRect(),{clientLeft:i,clientTop:r,clientWidth:n,clientHeight:a}=e;return!/[1-9]/.test(getComputedStyle(e).borderRadius)&&t.left>=s.left+i-.5&&t.top>=s.top+r-.5&&t.right<=s.left+i+n+.5&&t.bottom<=s.top+r+a+.5}hook(e){let t=this.stage;if(!t.planes.all.some(e=>e.zone.screen))return;let s=e.target;if((e.type==="pointerover"||e.type==="pointerout")&&(t.env.frame.scrolled||this.Jb)&&s instanceof Element){e.type==="pointerout"?this.wb??=s:this.vb=s;return}let i=!1;s instanceof Element&&e.type!=="keydown"&&e.type!=="pointerdown"&&e.type!=="input"&&(i=this.fc(s));let r=performance.now();(i||r-this.ec>=vt)&&(this.ec=r,this.da(),t.scheduler.request())}nd(e){let t=this.stage,s=e.target;!(s instanceof Element)||s===t.env.host.scroll.root||s===document.documentElement||s===document.body||(t.batches.nd(),t.planes.all.some(e=>e.zone.soon&&s.contains(e.el))&&(this.hb.add(s),t.scheduler.markDirty()))}Kh(e){this.hb.add(e)}fc(e){let t=this.stage;if(e===document.documentElement||e===document.body||e===t.env.host.scroll.root)return!1;let s=!1;for(let i of t.planes.all)i.zone.screen&&(i.el.contains(e)||e.contains(i.el))&&(i.stale=!0,s=!0);return s}hovered(e){let t=this.wb,s=this.vb;this.wb=null,this.vb=null;let i=!1;t?.isConnected&&(i=this.fc(t)),s?.isConnected&&this.fc(s)&&(i=!0),i&&this.da(),this.ec=e}qg(e){for(let t of this.hb)if(t.contains(e))return!0;return!1}Ag(e){let t=this.stage;if(this.Oc(),typeof document.getAnimations=="function"){for(let e of t.planes.all)(e._m=e.animUntil===1/0)&&(e.animUntil=0);for(let t of document.getAnimations())if(!this.cg(t,e))return;for(let e of t.planes.all)e._m&&(e._m=!1,e.animUntil!==1/0&&(e.stale=!0))}}cg(e,t){let s=this.stage,i=e.effect,r=i?.target;if(!i||!r||i.pseudoElement||e.playState==="idle")return!0;let n=Xe(e);if(!n)return!0;let a=e.playState==="running"&&!!e.playbackRate,l=xt(e);for(let o of s.planes.all){if(!o.zone.soon||!(r===o.el||r.contains(o.geomEl)))continue;if(!s.chunks.shapesError&&(l||!a||o.shapeWait||n>1))return s.chunks.Ga=!0,s.chunks.loadShapes(),!1;if(!a)continue;let h=l?1/0:kt(e,i,t);h>o.animUntil&&(o.animUntil=h,o.animLabel=`animation on ${s.env.lib.describe(r)}`)}return!0}uc(e){let t=this.stage;if(t.scheduler.inactive)return;if(t.chunks.shapes){t.chunks.shapes.uc(e);return}let s=e.effect?.target;s&&Xe(e)&&this.tc(s)}tc(e){let t=this.stage;if(!(t.scheduler.inactive||!(e instanceof Element))){for(let s of t.planes.all)if(s.zone.soon&&(e===s.el||e.contains(s.geomEl))){this.da(),t.scheduler.request();return}}}};function wt(e,t,s){let i=e.wrap;if(!i)return;let r=e.el.closest("[data-umber-wrap]");if(!r)throw new Error("the data-umber-wrap track of a wrapped plane is gone");let n=r.getBoundingClientRect(),a=new DOMMatrixReadOnly(getComputedStyle(r).transform);i.period=i.axis?r.offsetHeight:r.offsetWidth,i.start=i.axis?n.top-a.m42+s:n.left-a.m41+t}function xt(e){let t=typeof DocumentTimeline<"u"?DocumentTimeline:null;return!!(e.timeline&&t&&!(e.timeline instanceof t))}function kt(e,t,s){let i=t.getComputedTiming(),r=Number(i.endTime);if(r===1/0)return 1/0;let n=Number(i.localTime)||0;return s+Math.max(0,e.playbackRate<0?n:r-n)/Math.abs(e.playbackRate)+bt}var _t=class{constructor(e,t){this.stage=e;this.rb=new WeakMap;this.io=new IntersectionObserver(e=>{this.zf(e)},{rootMargin:"25% 0px 25% 0px"}),this.Ab=new IntersectionObserver(t=>{for(let s of t){let t=e.planes.of(s.target);!t||t.zone.screen===s.isIntersecting||t.wrap?.period||(t.zone.screen=s.isIntersecting,t.zone.screen&&e.gpu.programs.want(t,!0),t.modules.tell(e=>e.visible?.(t.zone.screen)),t.emit(t.zone.screen?"enter":"leave"))}e.scheduler.markDirty()}),this.zb=new IntersectionObserver(t=>{for(let s of t){let t=e.planes.of(s.target);if(t){if(!s.isIntersecting&&!t.wrap){t.zone.near&&t.modules.tell(e=>e.near?.(!1)),t.zone.near=!1,t._P=performance.now();continue}t.zone.near||t.modules.tell(e=>e.near?.(!0)),t.zone.near=!0,e.factory.load(t)}}},{rootMargin:"150%"}),this.ro=new ResizeObserver(s=>{for(let i of s){if(i.target===e.canvasHost.el){t(),e.factory.invalidate();continue}if(i.target===document.documentElement){e.factory.invalidate();continue}let s=e.planes.of(i.target)??this.rb.get(i.target);s&&(s.stale=!0)}e.scheduler.markDirty()}),this.ro.observe(e.canvasHost.el),this.ro.observe(document.documentElement)}zf(e){let t=!1,s=!1;for(let i of e){let e=this.stage.planes.of(i.target);if(!e)continue;let r=this.soon(e,i.isIntersecting);r!=="quiet"&&(t=!0),r==="shows"&&(s=!0)}s?this.stage.scheduler.markDirty():t&&this.stage.scheduler.request()}soon(e,t){let s=this.stage,i=e.animUntil===1/0&&!e.zone.screen;return t&&!e.zone.soon&&!i&&s.measurePhase.da(),e.zone.soon=t,t&&(s.gpu.programs.want(e,!0),e.zone.near&&s.factory.load(e)),(t&&e.gen!==s.batches.bd||s.transitions.ongoing)&&(e.stale=!0),this.hi(e,t),i?"quiet":e.zone.screen||e.visible?"shows":"news"}hi(e,t){e.modules.feed||e.kind!=="video"||(t&&(e.videoFrame=!0),e.media&&this.stage.chunks.video?.kf(e,t))}observe(e){this.io.observe(e.el),this.Ab.observe(e.el),this.zb.observe(e.el),this.ro.observe(e.el)}forget(e){this.io.unobserve(e.el),this.Ab.unobserve(e.el),this.zb.unobserve(e.el),this.ro.unobserve(e.el),e.geomEl!==e.el&&(this.ro.unobserve(e.geomEl),this.rb.delete(e.geomEl))}Eh(e,t){t!==e.geomEl&&(e.geomEl!==e.el&&(this.ro.unobserve(e.geomEl),this.rb.delete(e.geomEl)),e.geomEl=t,t!==e.el&&(this.rb.set(t,e),this.ro.observe(t)))}wd(e,t){this.ro.unobserve(e),this.ro.observe(t)}disconnect(){this.io.disconnect(),this.Ab.disconnect(),this.zb.disconnect(),this.ro.disconnect()}};function Et(e,t){Mt(e,t),e.env.listen(window,"resize",()=>{t.resized(),(!e.env.host.env.isTouch||innerWidth!==e.env.frame.screen.width)&&e.factory.invalidate()}),e.env.listen(window,"pointermove",s=>{let i=s;e.env.frame.pointer.x=i.clientX,e.env.frame.pointer.y=i.clientY,t.following()&&e.scheduler.request()}),e.env.listen(document,"visibilitychange",()=>{if(!document.hidden){for(let t of e.planes.all)t._G();e.gpu.renderer.adaptive.rest(30),e.factory.invalidate(),e.scheduler.wake(2)}}),e.env.listen(e.gpu.canvas,"webglcontextlost",t=>{_(e,t)},!1),e.env.listen(e.gpu.canvas,"webglcontextrestored",()=>{let t=()=>{e.env.destroyed||e.chunks.load({load:e.env.host.loadRestore,file:"restore",dom:"the DOM shows for the rest of this visit.",made:t=>{t.restored(e)}})},s=e.gpu.context.lf();s?setTimeout(t,s):t()});let s=document.fonts;typeof s?.addEventListener=="function"&&e.env.listen(s,"loadingdone",()=>{for(let t of e.planes.all)t.raster&&(t.raster.ja=!0);e.factory.invalidate()}),St(e)}function Mt(e,t){let s=null,i=()=>{let r=matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),n=()=>{t.resized(),e.scheduler.markDirty(),i()};typeof r.addEventListener=="function"&&(r.addEventListener("change",n,{once:!0}),s=()=>{r.removeEventListener("change",n)})};i(),e.env.cleanups.push(()=>s?.())}function St(e){let t=t=>t instanceof Element&&e.planes.all.some(e=>t===e.el||t.contains(e.geomEl)),s=s=>{t(s.target)&&(e.measurePhase.da(),e.scheduler.markDirty())},i=t=>{let s=t.target;if(!(s instanceof Element))return;let i=!1;for(let t of e.planes.all)(s===t.el||s.contains(t.geomEl))&&(t.stale=!0,i=!0);i&&(e.measurePhase.da(),e.scheduler.markDirty())};for(let t of["transitionrun","animationstart"])e.env.listen(document,t,s);for(let t of["transitionend","animationend","transitioncancel","animationcancel"])e.env.listen(document,t,i)}var At={scrub:"modules/scrub.js"};var Rt=null,Tt=(e,t)=>e.replace(/var\(\s*(--[\w-]+)\s*(?:,((?:[^()]|\([^()]*\))*))?\)/g,(e,s,i)=>getComputedStyle(t).getPropertyValue(s).trim()||Tt(i??"",t));function zt(e,t,s){let i=Tt(e,t).trim().replace(/currentcolor/gi,getComputedStyle(t).color);return typeof CSS>"u"||i.includes("var(")||!CSS.supports("color",i)?e.includes("var(")?(s("var",[e],t),new Float32Array(4)):null:(Rt??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),Rt?(Rt.clearRect(0,0,1,1),Rt.fillStyle=i,Rt.fillRect(0,0,1,1),Float32Array.from(Rt.getImageData(0,0,1,1).data,e=>e/255)):null)}var Ut=e=>e,Pt=["uniformMatrix2fv","uniformMatrix3fv","uniformMatrix4fv",void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,"uniformMatrix2x3fv","uniformMatrix2x4fv","uniformMatrix3x2fv","uniformMatrix3x4fv","uniformMatrix4x2fv","uniformMatrix4x3fv"],Ct=["uniform1iv","uniform2iv","uniform3iv","uniform4iv"],Ft=["uniform1uiv","uniform2uiv","uniform3uiv","uniform4uiv"];function Lt(e,t,s){return(t===e.UNSIGNED_INT||t>=e.UNSIGNED_INT_VEC2&&t<=e.UNSIGNED_INT_VEC4?Ft:Ct)[s-1]}var It=(...e)=>e.find(e=>!!e)??0,Nt=class{constructor(e,t,s,i="program"){this.gl=e;this.vertex=t;this.fragment=s;this.uniforms=new Map;this.state="pending";this.started=!1;this.error=null;this.shaders=[];this.options=typeof i=="string"?{label:i}:i;let r=globalThis.occluzeCapture;this.Eb=r?.version===1?null:e.getExtension("KHR_parallel_shader_compile");let n=Ut(e.createProgram());if(!n)throw new Error("the WebGL context is lost");this.program=n,this.options.lazy||this.start()}start(){if(this.started)return;this.started=!0;let e=this.gl,t=this.program,s,i;try{s=Ot(e,e.VERTEX_SHADER,this.vertex),i=Ot(e,e.FRAGMENT_SHADER,this.fragment)}catch{this.state="failed";return}e.attachShader(t,s),e.attachShader(t,i),e.bindAttribLocation(t,0,"aPosition");for(let[s,i]of this.options.attributes??[])e.bindAttribLocation(t,i,s);e.linkProgram(t),this.shaders=[s,i],this.Eb||this.Yb()}ready(){return this.state!=="pending"?this.state==="ok":this.compiled()?(this.Yb(),this.state==="ok"):!1}compiled(){return this.start(),this.state!=="pending"?!0:!this.Eb||!!this.gl.getProgramParameter(this.program,this.Eb.COMPLETION_STATUS_KHR)}get failed(){return this.state==="failed"}Yb(){if(this.start(),this.state!=="pending")return;let e=this.gl,t=this.program;if(!e.getProgramParameter(t,e.LINK_STATUS)){this.error=this.yg(),this.Vb(),e.deleteProgram(t),this.state="failed";return}this.Vb();let s=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<s;i++){let s=e.getActiveUniform(t,i);if(!s)continue;let r=s.name.replace(/\[0\]$/,""),n=e.getUniformLocation(t,s.name);n&&this.uniforms.set(r,{location:n,type:s.type,size:s.size})}this.state="ok"}yg(){let e=this.gl,[t,s]=this.shaders,i=Ht(e,t);if(i!==null)return["vertex",this.options.label,i,this.vertex];let r=Ht(e,s);return r!==null?["fragment",this.options.label,r,this.fragment]:["link",this.options.label,e.getProgramInfoLog(this.program)??"",""]}Vb(){for(let e of this.shaders)this.gl.deleteShader(e);this.shaders=[]}set(e,t){let s=this.state==="ok"?this.uniforms.get(e):void 0;!s||t==null||(typeof t=="number"?Dt(this.gl,s,t):Bt(this.gl,s,t))}dispose(){this.Vb(),this.state!=="failed"&&this.gl.deleteProgram(this.program)}};function Dt(e,t,s){if(t.last===s)return;t.last=s;let{type:i,location:r}=t;i===e.FLOAT?e.uniform1f(r,s):i===e.UNSIGNED_INT?e.uniform1ui(r,s):e.uniform1i(r,s)}function $t(e,t){let s=e.last;if(s?.length===t.length){let e=t.length;for(;e--&&s[e]===t[e];);if(e<0)return!1}else s=[],e.last=s;for(let e=0;e<t.length;e++)s[e]=ee(t,e);return!0}function Bt(e,t,s){if(!$t(t,s))return;let{type:i,location:r}=t,n=Pt[i-e.FLOAT_MAT2];if(i===e.FLOAT_VEC2)e.uniform2fv(r,s);else if(i===e.FLOAT_VEC3)e.uniform3fv(r,s,0,Math.min(s.length,t.size*3));else if(i===e.FLOAT_VEC4)e.uniform4fv(r,s);else if(n)e[n](r,!1,s);else if(i===e.FLOAT)e.uniform1fv(r,s);else{let n=Lt(e,i,s.length/t.size);n&&e[n](r,s)}}function Ot(e,t,s){let i=Ut(e.createShader(t));if(!i)throw new Error("the WebGL context is lost");return e.shaderSource(i,s),e.compileShader(i),i}function Ht(e,t){return t&&!e.getShaderParameter(t,e.COMPILE_STATUS)?e.getShaderInfoLog(t)??"":null}var qt=255,Gt=e=>Math.min(qt,Math.max(1,Math.round(e)||1)),Vt=class{constructor(e,t){this.gl=e;this.segments=t;this.buffers=[];let s=Gt(t),i=new Float32Array((s+1)*(s+1)*2),r=0;for(let e=0;e<=s;e++)for(let t=0;t<=s;t++)i[r++]=t/s,i[r++]=e/s;let n=new Uint16Array(s*s*6);r=0;for(let e=0;e<s;e++)for(let t=0;t<s;t++){let i=e*(s+1)+t,a=i+1,l=i+(s+1),o=l+1;n[r++]=i,n[r++]=l,n[r++]=a,n[r++]=a,n[r++]=l,n[r++]=o}this.vao=Ut(e.createVertexArray()),e.bindVertexArray(this.vao);let a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,i,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);let l=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW),e.bindVertexArray(null),this.buffers.push(a,l),this.count=n.length}draw(){let e=this.gl;e.bindVertexArray(this.vao),e.drawElements(e.TRIANGLES,this.count,e.UNSIGNED_SHORT,0)}dispose(){this.gl.deleteVertexArray(this.vao),this.buffers.forEach(e=>{this.gl.deleteBuffer(e)})}},Wt=class{constructor(e){this.gl=e;this.ms=-1;this.pending=[];this.active=null;this.ra=e.getExtension("EXT_disjoint_timer_query_webgl2")}get supported(){return!!this.ra}begin(){if(!this.ra||this.active||this.pending.length>3)return;let e=Ut(this.gl.createQuery());e&&(this.gl.beginQuery(this.ra.TIME_ELAPSED_EXT,e),this.active=e)}end(){!this.ra||!this.active||(this.gl.endQuery(this.ra.TIME_ELAPSED_EXT),this.pending.push(this.active),this.active=null)}poll(){let e=this.gl;if(!this.ra)return;let t=e.getParameter(this.ra.GPU_DISJOINT_EXT),s=this.pending[0];for(;s!==void 0&&e.getQueryParameter(s,e.QUERY_RESULT_AVAILABLE);){let i=e.getQueryParameter(s,e.QUERY_RESULT);t||(this.ms=i/1e6),e.deleteQuery(s),this.pending.shift(),s=this.pending[0]}}dispose(){this.active&&this.end(),this.pending.forEach(e=>{this.gl.deleteQuery(e)}),this.pending=[]}};function jt(e){let t=e;return[It(t.displayWidth,t.videoWidth,t.naturalWidth,t.width),It(t.displayHeight,t.videoHeight,t.naturalHeight,t.height)]}var Xt=e=>e instanceof HTMLVideoElement||"displayWidth"in e,Yt=class{constructor(e){this.gl=e;this.width=1;this.height=1;this.ready=!1;this.packed=0;this.ua=1;this.refs=0;this.box=[];this.mipmaps=!1;this.texture=Ut(e.createTexture()),e.bindTexture(e.TEXTURE_2D,this.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),this.params(!1)}params(e){let t=this.gl;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR)}get bytes(){return this.ready?this.packed||this.width*this.height*4*(this.mipmaps?4/3:1):0}adopt(e,t){this.texture!==e&&this.gl.deleteTexture(this.texture),this.texture=e,this.width=t.width,this.height=t.height,this.packed=t.bytes,this.mipmaps=t.mipmaps,this.ua=1,this.ready=!0}upload(e,t={}){let s=this.gl,i=t.mipmaps??!Xt(e),[r,n]=jt(e);return!r||!n||!this.texture||this.packed&&(s.deleteTexture(this.texture),this.texture=Ut(s.createTexture()),this.packed=0,this.ua=1,this.ready=!1,!this.texture)?!1:(s.bindTexture(s.TEXTURE_2D,this.texture),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!t.straight),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),this.ready&&r===this.width&&n===this.height&&(!i||this.mipmaps)?s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e):s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i&&s.generateMipmap(s.TEXTURE_2D),(i!==this.mipmaps||!this.ready)&&this.params(i),this.mipmaps=i,this.width=r,this.height=n,this.ready=!0,!0)}angle(e){e===this.ua||!this.mipmaps||!this.ready||(this.ua=e,this.gl.texParameterf(this.gl.TEXTURE_2D,Kt,e))}dispose(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.ready=!1}},Kt=34046,Jt=34047,Zt=8;function Qt(e){if(!e.getExtension("EXT_texture_filter_anisotropic"))return 1;let t=e.getParameter(Jt);return Math.max(1,Math.min(Zt,t??1))}async function es(e,t,s,r=!1){let n=[],a,l="",o=(e,s,i)=>{n[2]=e,n[3]=s;let[r=0]=n,a=r?Math.max(r/e,ee(n,1)/s):1,l=2**Math.floor(Math.log2(a));return a<l*1.1&&(a=l,a<=.8&&n[0]&&(n[0]=e*a,n[1]=s*a)),a>.8&&!i?(a=1,n[0]=0):n[1]||=ee(n,0)*s/e,Math.min(a,t/Math.max(e,s))};try{let t=await fetch(e,{mode:"cors",credentials:"omit"});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.blob();l=i.type,s&&(n=s()),a=await createImageBitmap(i,{premultiplyAlpha:r?"none":"premultiply",colorSpaceConversion:"default"});let h=a.width,u=a.height,d=o(h,u);if(d>=1)return a;let c=await createImageBitmap(a,{resizeWidth:Math.max(1,Math.round(h*d)),resizeHeight:Math.max(1,Math.round(u*d)),resizeQuality:"high"});return a.close(),c}catch(t){a?.close(),i.info("fetch decode failed, trying <img>",e,t);let r=await new Promise((t,s)=>{let i=new Image;i.crossOrigin="anonymous",i.decoding="async",i.onload=()=>{t(i)},i.onerror=()=>{s(new Error(`could not load ${e}`))},i.src=e});s&&!n[2]&&(n=s());let h=r.width,u=r.height,d=o(h,u,l.includes("svg"));if(d===1||!h)return r;let c=document.createElement("canvas");c.width=Math.round(h*d)||1,c.height=Math.round(u*d)||1;let f=c.getContext("2d");return f?(f.drawImage(r,0,0,c.width,c.height),c):r}}var ts=e=>e,ss=(e,t)=>{let s=3*e,i=3*(t-e)-s,r=1-s-i;return e=>((r*e+i)*e+s)*e};function is(e,t,s,i){let r=ss(e,s),n=ss(t,i);return e=>{if(e<=0||e>=1)return e;let t=0,s=1;for(let i=0;i<24;i++){let i=(t+s)/2;r(i)<e?t=i:s=i}return n((t+s)/2)}}function rs(e){let t=[],s=[];for(let i of e.split(",")){let[e="",...r]=i.trim().split(/\s+/);if(r.length>2||!(parseFloat(e)>=-1/0)||r.some(e=>!e.endsWith("%")))return null;for(let i of r.length?r:[""])t.push(i?parseFloat(i)/100:NaN),s.push(+e)}let i=t.length;return i<2?null:(ns(t),e=>{let r=0;for(let s=0;s<i;s++)ee(t,s)<=e&&(r=s);r===i-1&&r--;let n=ee(t,r),a=ee(t,r+1),l=ee(s,r),o=ee(s,r+1);return n===a?o:l+(e-n)/(a-n)*(o-l)})}function ns(e){let t=e.length;ee(e,0)>=-1/0||(e[0]=0),ee(e,t-1)>=-1/0||(e[t-1]=Math.max(1,...e.filter(e=>e>=-1/0)));for(let s=1;s<t;s++){let t=s;for(;!(ee(e,t)>=-1/0);)t++;let i=ee(e,s-1);e[s]=i+Math.max(0,ee(e,t)-i)/(t-s+1)}}function as([e,t],s,i,r){let n=t*Math.sqrt(Math.max(1-e*e,1e-8)),a=Math.exp(-e*t*r),l=(i+e*t*s)/n,o=Math.cos(n*r),h=Math.sin(n*r),u=a*(s*o+l*h);return[u,-e*t*u+a*n*(l*o-s*h)]}function ls(e){let t=1-Math.min(.95,Math.max(0,e||0)),s=[t,1],i=0;for(let e=0;e<12/t;e+=.01)Math.abs(as(s,1,0,e)[0])>.001&&(i=e);let r=[t,i],n=e=>e>=1?1:1-as(r,1,0,e)[0];return n.spring=r,n}var os=e=>t=>Math.pow(t,e),hs={quad:os(2),cubic:os(3),quart:os(4),quint:os(5),sine:e=>1-Math.cos(e*Math.PI/2),expo:e=>e===0?0:Math.pow(2,10*e-10),circ:e=>1-Math.sqrt(1-e*e)},us={power1:"quad",power2:"cubic",power3:"quart",power4:"quint"},ds=e=>t=>1-e(1-t),cs=e=>t=>t<.5?e(t*2)/2:1-e((1-t)*2)/2,fs="umber",ms=[.625,.05,0,1],ps={umber:ms,ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]},gs=new Map;function vs(e){if(e==="linear"||e==="none")return ts;let t=ps[e];if(t)return is(...t);let s=/^linear\((.*)\)$/.exec(e)?.[1];if(s!==void 0)return rs(s);let i=/^spring(?:\(([^)]*)\))?$/.exec(e);if(i)return ls(i[1]?parseFloat(i[1]):.2);let r=(/^cubic-bezier\(([^)]*)\)$/.exec(e)??/^([-\d.\s]+,[-\d.\s]+,[-\d.\s]+,[-\d.\s]+)$/.exec(e))?.[1];return r!==void 0?bs(r):ys(e)}function bs(e){let t=e.split(",").map(e=>parseFloat(e)),[s=NaN,i=NaN,r=NaN,n=NaN]=t;return t.length===4&&t.every(Number.isFinite)&&s>=0&&s<=1&&r>=0&&r<=1?is(s,i,r,n):null}function ys(e){let t=/^([a-z]+\d?)(?:\.(in|out|inout))?$/.exec(e);if(!t)return null;let[,s="",i="out"]=t,r=hs[us[s]??s];return r?i==="in"?r:i==="out"?ds(r):cs(r):null}function ws(e,t){if(typeof e=="function")return e;let s=(e??fs).trim().toLowerCase(),i=gs.get(s);if(i)return i;let r=vs(s||fs);return r||(t("ease",[e]),r=is(...ms)),gs.set(s,r),r}var xs=/\b(?:(?:quad|cubic|quart|quint|sine|expo|circ)(?:In|Out|B)|stagger|[sp]noise|cellular|sd[A-Z]|op[A-Z]|aa|blend[A-Z]|bayer|blueNoise|dither|srgbTo|linearTo|oklabTo|mixOklab|umber[A-Z])\w*\s*\(/;var ks=class{constructor(e,t){this.Pa=t;this.v=e}get value(){return this.v}set value(e){e!==this.v&&(this.v=e,this.Pa())}},_s=class extends ks{constructor(e,t){super(e.value,t);this.source=e;this.last=[];this.changed()}get value(){return this.source.value}set value(e){this.source.value=e,this.Pa()}changed(){let e=this.source.value,t=this.last;if(typeof e=="number"||typeof e=="boolean"){let s=Number(e);return t.length===1&&t[0]===s?!1:(t.length=1,t[0]=s,!0)}if(Array.isArray(e)||ArrayBuffer.isView(e)){let s=e,i=t.length===s.length;for(let e=0;e<s.length;e++)t[e]!==s[e]&&(i=!1),t[e]=s[e];return t.length=s.length,!i}return!1}};function Es(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&!ArrayBuffer.isView(e)&&"value"in e&&typeof e.value!="string"}var Ms=new Set,Ss=()=>({status:"loading",drawnFrame:null,waitingSince:null}),As=0,Rs=class{constructor(e,t,s,i){this.id=++As;this.order=0;this.effects=[];this.shader=null;this.uniforms={};this.missing=[];this.backdrop=null;this.doc={x:0,y:0,w:0,h:0};this.rect=Z(4);this.size=Z(2);this.level=0;this.nodes=[];this.dynamic=[];this._f=0;this._d=0;this._q=J(9);this.edge=J([1,1]);this._K=J(9);this._O=J(9);this._c=Z([1,0,0,0,1,0,0,0,1]);this._D=Z(9);this._v=Z(4);this.backHidden=!1;this.scene=null;this._w=null;this.xfReason=null;this._I=null;this._F=null;this._x=null;this._b=1;this.warned=new Set;this.animUntil=0;this._m=!1;this.scrollLinked=!1;this._p=[];this.animLabel="";this.heldMoved=!1;this._N=0;this._z=Z([NaN,NaN,NaN,NaN]);this.progress=0;this.scrolls=!0;this.clips=null;this.chained=!1;this.domReason=null;this._j=null;this.slow=!1;this.bends=!1;this.shapeWait=!1;this._r=!1;this.stale=!0;this.gen=-1;this.measured=!1;this.live=!1;this.offset=null;this.pinned=!1;this.zone={near:!1,soon:!1,screen:!1};this._P=0;this._B=!1;this.visible=!1;this.listed=-1;this.drawn=!1;this.opacity=1;this.opacitySettled=!1;this._y=-1;this.radius=Z(4);this.fit=0;this._g=Z([.5,.5]);this.media=null;this.layer=null;this.pad=0;this.bleed=0;this.zoom=1;this.wrap=null;this.layoutW=0;this.layoutH=0;this.raster=null;this.texture=null;this.prev=null;this.fly=null;this.textureState="none";this.loads=0;this.videoFrame=!1;this._l=null;this.modules=new Us;this.state=Ss();this._J=!1;this.destroyed=!1;this.plays=new zs;this._E=!1;this.morphHidden=!1;this.viewTransition=!1;this.listeners=[];this._a=new Set;this._u=!1;this.mouse=Z([.5,.5]);this._h=Z([.5,.5]);this.reads=Ms;this._C=!1;this.programKey="";this.program=null;this.grid=null;this.glsl=!1;this.segments=1;this.el=e,this.kind=t,this.index=s,this.host=i,this.handlers=i.env.lib.createEmitter(!1,"plane "),this.geomEl=e,this.loaded=new Promise(e=>{this._i=()=>{this._J=!0,e()}})}get inView(){return this.zone.screen}drawable(){return this.status==="error"||this.textureState==="error"?!1:this.kind==="layer"?!!this.layer?.ready:(this.kind==="shader"||!!this.texture?.ready)&&!!this.grid&&!!this.program?.ready()}get _k(){return this.reads.has("glyph")}_L(e){let t=this.shader?.def.head?1:0;for(let{def:e}of this.effects)(e.vertex?.head||e.fragment?.head)&&t++;this.glsl=t>1||e.includes("#include")||z.test(e)||xs.test(e);let s=new Set;e.includes("uScrollVelocity")&&s.add("velocity"),e.includes("uTime")&&s.add("time"),e.includes("uProgress")&&s.add("progress"),H.test(e)&&s.add("glyph"),this.reads=s.size?s:Ms}set(e,t){typeof t=="string"&&(t=zt(t,this.el,this.host.env.lib.say)??t);let s=this._o(e);return Es(t)&&!(s instanceof _s&&s.source===t)?(!s&&!O.has(e)&&this._M(e),this.uniforms[e]=new _s(t,()=>{this.host.scheduler.markDirty()}),this._C=!0):s?s.value=t:this._H(e,t),this.host.scheduler.markDirty(),this}_H(e,t){O.has(e)||this._M(e);let s=new ks(t,()=>{this.host.scheduler.markDirty()});return this.uniforms[e]=s,s}_M(e){this.host.env.lib.say("set",[this.el,e,Object.keys(this.uniforms),this.effects.map(e=>e.name).join(", ")||"none"],this.el)}_o(e){return this.uniforms[e]}get(e){return this._o(e)?.value}tween(e,t){let s=this._o(e);return s||(s=this._H(e,0),this.host.scheduler.markDirty()),this.host.env.tweens.to(s,t)}play(e={}){let{uniform:t,...s}=e,i=t?[t]:[...this.plays.la.keys()];if(!i.length)return this.host.env.lib.say("play",[],this.el),null;let r=null;for(let e of i){let t=this.plays.la.get(e)??{},i=this.host.env.reducedMotion?this.tween(e,{value:1,...s,duration:0,delay:0}):this.tween(e,{value:1,duration:typeof t.duration=="number"?t.duration:1.4,delay:typeof t.delay=="number"?t.delay:void 0,ease:t.ease??fs,...s});!i.done&&!this._J&&(i.pause(),this.loaded.then(()=>{i.play(),this.host.scheduler.wake()})),r??=i}return r}lift(){return this.host.chunks.loadFlip().then(e=>e&&!this.destroyed?e.lift(this):null)}land(e){return this.host.chunks.loadFlip().then(t=>t?.land(this,e))}on(e,t){return this.handlers.on(e,t)}off(e,t){this.handlers.off(e,t)}emit(e){this.handlers.emit(e,this)}destroy(){this.destroyed||this.host.planes.remove(this)}revert(){this.destroy()}wake(e=1){this.host.scheduler.wake(e)}parts(){return[this.plays,this.layer,this.modules,this.raster]}get status(){return this.state.status}wait(){this.state=Ss()}_G(){this.state.status==="loading"&&(this.state.waitingSince=null)}drawnIn(e){this.state.status==="loading"&&this.state.drawnFrame===null&&(this.state.drawnFrame=e)}setStatus(e,t){let s=this.status;e&&e!==s&&(this.state=e==="loading"?Ss():{status:e}),e===null?this.el.removeAttribute("data-umber-status"):this.el.setAttribute("data-umber-status",e),e&&e!==s&&(e==="ready"||e==="error"&&!this._j)&&(this.emit(e),e==="error"&&this.host.fallbacks.report(this,t))}};function Ts(e){for(let t of e)try{t()}catch(e){i.error("plane cleanup failed",e)}}var zs=class{constructor(){this.la=new Map;this.cleanups=[]}dispose(){Ts(this.cleanups),this.cleanups=[]}},Us=class{constructor(){this.list=[];this.feed=null;this.frames=null}tell(e){for(let t of this.list)try{e(t.binding)}catch(e){i.error(`module "${t.name}" failed`,e)}}lost(){this.frames?.forget(),this.tell(e=>e.lost?.())}dispose(e){this.tell(e=>e.destroy?.()),this.list=[],this.feed=null,this.frames&&(this.frames.dispose(),this.frames=null,e.texture=null)}};var Ps={duration:1.4,delay:0,ease:fs,start:"top 90%",trigger:"auto",repeat:""};function Cs(e,t){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):t}function Fs(e,t){let s=Cs(e,"").trim().toLowerCase();return s==="scroll"||s==="load"||s==="manual"||s==="hover"?s:(s===""||s==="auto"||t("trigger",[e]),"auto")}function Ls(e){let t=e.getBoundingClientRect();return(t.width>0||t.height>0)&&t.top<window.innerHeight&&t.bottom>0}function Is(e,t){let s=Cs(e,Ps.start).trim().toLowerCase().split(/\s+/),[i="",r="bottom"]=s,n=i||"top",a=Ns(n);n!=="top"&&n!=="center"&&n!=="bottom"&&t("edge",[e]);let l="0px";return r==="top"?l="-100%":r==="center"?l="-50%":r==="bottom"?l="0px":/^-?[\d.]+%$/.test(r)?l=`-${Math.max(0,100-parseFloat(r))}%`:/^-?[\d.]+(px)?$/.test(r)?l=`${-Math.max(0,(window.innerHeight||800)-parseFloat(r))}px`:t("line",[e]),{rootMargin:`${a?1e3:0}% 0px ${l} 0px`,threshold:a}}function Ns(e){return e==="center"?.5:e==="bottom"?1:0}var Ds=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t;function $s(e){let t=Cs(e,"").trim().toLowerCase();return t==="reverse"?"reverse":t===""||t==="false"||t==="none"||t==="0"?"":"replay"}function Bs(){}function Os(e,t,s){let i=e.closest("a, button")??e,r=()=>{s(1,t)},n=()=>{s(0,0)};return i.addEventListener("pointerenter",r),i.addEventListener("pointerleave",n),()=>{i.removeEventListener("pointerenter",r),i.removeEventListener("pointerleave",n)}}function Hs(e,t,s,i){let r=!0,n=new IntersectionObserver(e=>{let t=e[e.length-1];t&&s(t,r),r=!1},i);return n.observe(e),t.push(n),n}function qs(e,t,s,i){let r=e.uniforms[t];if(!r)return Bs;let n=Fs(s.trigger,i.lib.say),a=Ds(s.delay,0),l=(e,t)=>i.tweens.to(r,{value:e,duration:i.reducedMotion?0:Ds(s.duration,Ps.duration),delay:t,ease:s.ease});if(n==="hover")return Os(e.el,a,l);if(e._E||i.reducedMotion)return r.value=1,Bs;if(n==="manual")return Bs;let o=!0,h=$s(s.repeat),u=!1,d=[],c=t=>(u=!0,e.loaded.then(()=>{o&&u&&l(1,Math.max(0,a-(performance.now()-t)/1e3))})),f=(t,s)=>Hs(e.el,d,t,s),m=()=>{if(!o||((n==="load"||n==="auto"&&Ls(e.el))&&c(performance.now()),u&&!h))return;let{rootMargin:t,threshold:a}=Is(s.start,i.lib.say),d=f((e,t)=>{if(e.isIntersecting&&e.intersectionRatio>=a){if(u)return;h||d.disconnect(),c(performance.now());return}h!=="reverse"||!u||t||e.boundingClientRect.top>=(e.rootBounds?.bottom??innerHeight)&&(u=!1,l(0,0))},{rootMargin:t,threshold:a});h==="replay"&&f((e,t)=>{e.isIntersecting||!u||t||(u=!1,i.tweens.to(r,{value:0,duration:0}))},{threshold:0})},p=i.clock.whenOpen(m);return()=>{o=!1,p();for(let e of d)e.disconnect()}}var Gs={texture:null},Vs=4e3,Ws=class{constructor(e){this.stage=e;this.settles=0;this.landing=[]}get ongoing(){return this.stage.env.host.clock.held||this.stage.scheduler.Na(performance.now())}pi(e){let t=null,s=document.documentElement,i=()=>{let i=!1;try{i=s.matches(e)}catch{this.stage.env.lib.say("busy",[e]),r.disconnect()}i&&!t?t=this.stage.env.host.engine.transition():!i&&t&&(t(),t=null)},r=new MutationObserver(i);r.observe(s,{attributes:!0}),this.stage.env.cleanups.push(()=>{r.disconnect()}),i()}begin(){let e=this.stage;e.scheduler.changing++,e.scheduler.markDirty(),e.chunks.fx?.leave?.Qb();for(let t of e.planes.all)this.named(t)}end(){let e=this.stage;if(--e.scheduler.changing<1){e.scheduler.changing=0,this.stage.scheduler.Xb(1),this.retry(),this.settle(),e.chunks.fx?.leave?.play();for(let t of e.planes.all)this.named(t)}return new Promise(t=>{this.landing.push(t),setTimeout(t,Vs),e.scheduler.markDirty()})}land(e,t){if(!(!this.landing.length||e||t.some(e=>e.status==="loading"&&!e.viewTransition))){for(let e of this.landing)e();this.landing.length=0}}named(e){let t=this.stage.scheduler.changing>0&&e.kind!=="layer"&&!/^(none)?$/.test(getComputedStyle(e.el).getPropertyValue("view-transition-name"));t!==e.viewTransition&&(e.viewTransition=t,e.status!=="error"&&(Re(e,!t),this.stage.scheduler.markDirty()))}capture(e,t=!1){let s=s=>t?s?.known(e):s?.capture(e),i=this.settles;this.stage.chunks.morph?s(this.stage.chunks.morph):this.stage.chunks.Mg?.then(e=>{i===this.settles&&s(e)})}settle(){this.settles++,this.stage.chunks.morph?.settle()}retry(){for(let e of this.stage.chunks.morph?.retry()??[])e.zone.near=!0,this.stage.factory.load(e)}flip(e,t,s){let r=js(e),n=this.stage.planes.all.filter(e=>e.measured&&r.some(t=>t.contains(e.el))),a=n.map(e=>{let t=this.where(e);return e.fly=(e,s,i)=>{e[0]=t[0]-s,e[1]=t[1]-i,e[2]=t[2],e[3]=t[3]},e.stale=!0,t});try{t?.()}catch(e){i.error("umber.flip(): change() threw",e)}return this.stage.scheduler.markDirty(),this.stage.chunks.loadFlip().then(e=>{if(e)return e.fly(n,a,s);for(let e of n)e.fly=null})}where(e){let t=Z(9);return t.set(e.rect),t[0]+=e.scrolls?this.stage.env.frame.scrollX:this.stage.env.frame.pageX,t[1]+=e.scrolls?this.stage.env.frame.scrollY:this.stage.env.frame.pageY,t.set(e.radius,4),t[8]=e._b,t}swap(e){let t=e.prev,s=this.stage.chunks.flip;if(!t)return;let i=e.uniforms,r=()=>{e.prev!==t||!e.texture?.ready||(this.stage.gpu.media.free(t),e.prev=null,i.uPrev&&(i.uPrev.value=Gs),this.stage.scheduler.markDirty())};if(!i.uSwap||this.stage.env.reducedMotion||!s){r();return}s.swap(e,t,r)}};function js(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:Array.from(e??[])}var Xs=3e3,Ys=896,Ks=class{constructor(e,t,s,i){this.stage=e;this.chunks=t;this.transitions=s;this.observers=i;this.Ic=0}load(e){let t=this.stage;if(t.gpu.programs.want(e,!1),!(e.textureState!=="none"||t.gpu.context.gone)){if(e.modules.feed){e.textureState="loading";return}switch(e.kind){case"video":t.chunks.video?.load(e);return;case"layer":e.layer&&t.chunks.layers?.setup(e);return;case"text":if(t.chunks.text){t.chunks.text.load(e);return}e.textureState="loading",t.chunks.mb.add(e),t.chunks.loadText();return;case"image":case"shader":case"group":t.gpu.media.loadImage(e)}}}invalidate(e){let t=this.stage;for(let s of t.env.onInvalidate)s(e);for(let s of e?[t.planes.of(e)]:t.planes.all)s&&(s.stale=!0,this.rh(s));t.scheduler.markDirty()}get following(){return this.Ic>0}create(e){try{this.build(e)}catch(t){i.error("could not create a GL plane",e,t),e.setAttribute("data-umber-status","error")}}build(e){let t=this.stage,s=this.Pg(e),i=s.kind;if(i==="layer"){this.wf(s);return}if(!t.chunks.video&&(i==="video"||this.qc(e).length)){t.chunks.ob.add(s),this.chunks.loadVideo(),this.track(s,!1);return}let r={glsl:"",segments:1};this.qf(s,r),this.nf(s,r),this.Eg(s)&&(i==="shader"&&!this.sf(s,r)||(this.jh(s,r.glsl),s.segments=r.segments,this.Hd(s)&&(this.track(s),this.arrived(s),this.setUp(s))))}Pg(e){let t=this.stage,s=Je(this.stage.env.lib.kindOf(e)||"image"),i=this.stage.env.lib.findMedia(e),r=new Rs(e,s,t.planes.all.length,t),n=s==="group";r.media=s==="shader"||s==="text"||n?null:i,n||this.stage.env.lib.unmarkMedia(e),r.media&&this.stage.env.lib.markMedia(e,r.media),e.hasAttribute("data-umber-placeholder")&&t.chunks.loadWarm().then(t=>t?.paint(e)),r.order=this.stage.env.lib.attr.num(e,"data-umber-order",0);let a=e.closest("[data-umber-wrap]");return a&&(r.wrap={axis:a.getAttribute("data-umber-wrap")==="y"?1:0,period:0,start:0}),r.live=this.stage.env.lib.attr.bool(e,"data-umber-live")||this.stage.env.lib.needsLive(e),r.scrolls=t.env.host.scroll.contains(e),r.setStatus(t.scheduler.inactive?null:"loading"),s==="text"&&(t.chunks.text?t.chunks.text.units(r):this.chunks.loadText()),r}wf(e){let t=this.stage.chunks.layers;t?this.track(e,t.create(e)):(this.stage.chunks.loadLayers(),this.track(e,!1),this.chunks.Ma("layers"))}qf(e,t){for(let{name:s,binding:i}of this.rf(e)){let r=i.effect;r&&(this.ba(e,r.uniforms??{}),t.segments=Math.max(t.segments,this.Od(s,r)),t.glsl+=JSON.stringify([r.vertex,r.fragment]),e.effects.push({name:s,def:r,options:{},ctx:null}))}}nf(e,t){let s=e.el,i=this.stage.env.registry;for(let r of this.stage.env.lib.attr.list(s,"data-umber-effect")){let n=i.effects.get(r);if(!n){e.missing.push(r),this.stage.env.lib.say("effect",[s,r,[...i.effects.keys()]],s);continue}let a=n.play??"",l=this.cd(s,r,n);this.ba(e,n.uniforms??{}),a&&!(a in e.uniforms)&&this.ba(e,{[a]:0}),this.db(e,r,l),n.reduced&&this.stage.env.reducedMotion&&this.ba(e,n.reduced),t.segments=Math.max(t.segments,this.Od(r,n)),t.glsl+=JSON.stringify([n.vertex,n.fragment]),e.effects.push({name:r,def:n,options:l,ctx:null}),a&&!e.plays.la.has(a)&&e.plays.la.set(a,l)}}Eg(e){let t=e.el;if(e.plays.la.size)t.setAttribute("data-umber-play","");else{if(e.missing.length&&t.hasAttribute("data-umber-play"))return e._A=setTimeout(()=>{e.setStatus(null)},Ae),this.track(e,!1),!1;t.removeAttribute("data-umber-play")}return!0}sf(e,t){let s=e.el,i=this.stage.env.registry.shaders,r=s.getAttribute("data-umber-shader")??"",n=i.get(r);if(!n)return e.missing.push(`shader:${r}`),this.stage.env.lib.say("shader",[s,r,[...i.keys()]],s),e.setStatus("error"),this.track(e,!1),!1;let a=this.Rd(s,n);return this.ba(e,n.uniforms??{}),this.db(e,"",a),t.glsl+=n.fragment+(n.head??""),e.shader={name:r,def:n,options:a,ctx:null},!0}jh(e,t){let s=this.stage;e._L(t),this.Cf(e,t),t.includes("uBackdrop")&&(this.ba(e,{uBackdrop:e.backdrop={texture:null}}),s.chunks.loadFx()),t.includes("uFlow")&&(this.ba(e,{uFlow:s.chunks.flow??={texture:s.gpu.renderer.blank.texture}}),s.chunks.loadFx().then(e=>e?.flow())),/\b(uPrev|uSwap|samplePrev)\b/.test(t)&&(this.ba(e,{uPrev:Gs,uPrevSize:[1,1],uSwap:1}),s.chunks.loadFlip()),e._k&&e.kind!=="text"&&this.stage.env.lib.say("glyph",[],e.el)}Cf(e,t){let s=W(t);for(let[i,r]of Object.entries(e.uniforms)){let e=r.value;ArrayBuffer.isView(e)&&!q(e)&&t.includes(i)&&!s(i)&&this.stage.env.lib.say("texture",[i])}}Hd(e){let t=this.stage;if((e._k||e.kind==="text")&&!t.chunks.text)return t.chunks.La.add(e),this.chunks.loadText(),this.track(e,!1),!1;if(e.glsl&&!t.gpu.programs.glsl)return e.missing.push("chunk:"),this.chunks.loadGlsl(),this.track(e,!1),this.chunks.Ma("glsl"),!1;let s=e.el.getAttribute("data-umber-instances")??e.effects.find(e=>e.def.instances!=null)?.def.instances;if(s!=null){if(!t.chunks.instances)return this.chunks.loadInstances(e),this.track(e,!1),!1;t.chunks.instances.part(e,s)}return t.gpu.programs.prepare(e)?!0:(this.track(e,!1),!1)}arrived(e){let t=this.stage;e.backdrop&&this.chunks.Ma("fx"),e.kind==="group"&&(e.textureState="ready",e._i(),t.chunks.loadFx()),e.el.hasAttribute("data-umber-id")&&t.chunks.loadMorph(),t.scheduler.changing&&this.transitions.named(e),(!e.viewTransition&&t.chunks.morph?.claim(e)||e.wrap)&&(e.zone.near=!0,e.kind!=="shader"&&this.load(e))}setUp(e){let t=this.stage;for(let t of e.effects){let s=this.context(e,t.name,t.options);t.ctx=s;try{t.cleanup=t.def.setup?.(s)}catch(e){i.error(`effect "${t.name}" setup failed`,e)}}for(let[s,i]of e.plays.la)e.plays.cleanups.push(qs(e,s,i,{lib:t.env.lib,clock:t.env.host.clock,reducedMotion:t.env.reducedMotion,tweens:t.env.tweens}));let s=e.shader;if(!s)return;let r=this.context(e,s.name,s.options);s.ctx=r;try{s.cleanup=s.def.setup?.(r)}catch(e){i.error(`shader "${s.name}" setup failed`,e)}e.textureState="ready",e._i()}track(e,t=!0){this.stage.planes.add(e),t&&(e._A=setTimeout(()=>{this.Ef(e)},Xs),this.observers.observe(e))}Ef(e){e._A=void 0,!(e.destroyed||!e.measured||!e.el.isConnected||e.status==="error")&&(e.doc.w>0&&e.doc.h>0||this.stage.env.host.loadInspect?.().then(t=>{i.warn(t.zero(e,Xs),e.el)},()=>{}))}cf(e,t){let s=this.stage,i=new Rs(e,"layer",s.planes.all.length,s);if(i.live=this.stage.env.lib.needsLive(e),i.scrolls=s.env.host.scroll.contains(e),i.setStatus("loading"),!s.chunks.layers)throw new Error("umber.view(): chunks/layers.js is not here");return s.chunks.layers.build(i,"view",t,{}),this.track(i),s.scheduler.markDirty(),i}cd(e,t,s){return this.stage.env.lib.config(e,`data-umber-${t}`,s.play?{...Ps,...s.options}:s.options??{})}Rd(e,t){return this.stage.env.lib.config(e,"data-umber-shader",t.options??{})}rh(e){let t=(t,s,i)=>{let r={};for(let e in t.options)JSON.stringify(s[e])!==JSON.stringify(t.options[e])&&(t.options[e]=s[e],r[e]=s[e]);this.db(e,i,r)};for(let s of e.effects)t(s,this.cd(e.el,s.name,s.def),s.name);e.shader&&t(e.shader,this.Rd(e.el,e.shader.def),"")}db(e,t,s){for(let i in s){let r=s[i],n=typeof r=="string"?zt(r,e.el,this.stage.env.lib.say)??(r.includes("/")?r:null):r;i==="bleed"&&(e.bleed=Math.max(e.bleed,Number(n)||0)),i==="zoom"&&(e.zoom=Math.max(e.zoom,Number(n)||1)),(typeof n=="number"||typeof n=="boolean"||typeof n=="string"||Array.isArray(n)||n instanceof Float32Array)&&this.ba(e,{[G(t,i)]:typeof n=="boolean"?Number(n):n})}}ba(e,t){let s=()=>{this.stage.scheduler.markDirty()};for(let i in t){let r=t[i];if(Es(r)){e.uniforms[i]=new _s(r,s),e._C=!0;continue}Array.isArray(r)&&(r=new Float32Array(r)),typeof r=="string"?r=zt(r,e.el,this.stage.env.lib.say)??this.stage.gpu.media.Wd(r):r instanceof Object&&!("texture"in r)&&!(r instanceof Float32Array&&r.length<=Ys)&&this.stage.env.lib.say("texture",[i]),e.uniforms[i]=new ks(r,s)}}context(e,t,s){let i=this.stage,r=e=>{this.Ic+=e?1:-1};return{name:t,el:e.el,plane:e,engine:i.env.host.engine,options:s,uniforms:e.uniforms,get reducedMotion(){return i.env.reducedMotion},viewport:i.canvasHost.viewport,frame:null,trackMouse(t){if(t!==e._u){if(e._u=t,r(t),t){let t=e.rect;e._h[0]=(i.env.frame.pointer.x-t[0])/Math.max(t[2],1),e.mouse[0]=e._h[0],e._h[1]=(i.env.frame.pointer.y-t[1])/Math.max(t[3],1),e.mouse[1]=e._h[1]}i.scheduler.markDirty()}},busy(s){s?e._a.add(t):e._a.delete(t),i.scheduler.markDirty()},wake(e){i.scheduler.wake(e)},listen(t,s){for(let[e,i]of Object.entries(s))t.addEventListener(e,i);let i=!1,r=()=>{if(!i){i=!0;for(let[e,i]of Object.entries(s))t.removeEventListener(e,i)}};return e.listeners.push(r),r}}}qc(e){return[...this.stage.env.registry.modules].filter(([t,s])=>s.module.plane&&(s.module.attributes?.length?s.module.attributes:[t]).some(t=>e.hasAttribute(`data-umber-${t}`)))}rf(e){let t=e.el,s=this.stage.env.registry.modules;this.stage.chunks.video?.bind(e);for(let i in At)s.has(i)||!t.hasAttribute(`data-umber-${i}`)||(e.missing.push(`module:${i}`),this.stage.env.lib.say("module",[t,i],t));return e.modules.list}Od(e,t){let s=Number(t.segments)||1;return s<=qt?s:(this.stage.env.lib.say("segments",[e,s,qt]),qt)}Pf(e){if(e.destroyed)return;let t=this.stage;e.destroyed=!0,clearTimeout(e._A);for(let t of e.effects)try{typeof t.cleanup=="function"&&t.cleanup()}catch(e){i.error(`effect "${t.name}" cleanup failed`,e)}Ts(e.listeners),e.listeners=[];try{typeof e.shader?.cleanup=="function"&&e.shader.cleanup()}catch(t){i.error(`shader "${e.shader?.name}" cleanup failed`,t)}for(let t of e.parts())t?.dispose(e);e._u&&this.Ic--,e._u=!1,e._l?.(),e._l=null,t.gpu.media.forget(e),t.gpu.media.release(e),t.gpu.media.free(e.prev),e.prev=null,this.observers.forget(e),t.planes.forget(e),t.env.tweens.qd(Object.values(e.uniforms)),e.status!=="error"&&e.setStatus(null),e.el.removeAttribute("data-umber-morphing"),e.el.removeAttribute("data-umber-play"),this.stage.env.lib.unmarkMedia(e.el),e.emit("destroy")}};var Js=class{constructor(e,t){this.stage=e;this.own=t;this.Ld=[];this.nc=0}run(e,t){let s=this.stage,i=performance.now(),r=s.env.stats;if(r.planes=s.planes.all.length,r.visible=s.planes.visible.length,r.programs=s.gpu.programs.size,this.upload()&&(t=!0),!t){this.nc=0,r.skipped++,s.scheduler.pb="idle",this.own.mc(!1);return}let n=s.gpu.renderer.draw(e);for(let e of s.planes.all)e.visible||(e._z[0]=NaN);this.own.drawn(),s.scheduler.Lh(),s.gpu.renderer.list.some(Zs)&&s.scheduler.oa(1);let a=performance.now();this.nc=a-i,r.renders++,r.draws=n,s.scheduler.pb="active",r.frameMs=Math.round(e.dt*1e4)/10,r.fps=Math.round(1/e.dt),this.Ld.push(a),r.rendersPerSec=this.Dd(a),s.gpu.renderer.je(e)&&this.own.resize(),this.own.mc(!0)}upload(){let e=this.stage,t=!1;do{e.gpu.media.di(e.chunks.za?0:this.nc)&&(t=!0)}while(e.chunks.za&&e.gpu.media.uploads.length);let s=e.chunks.video;if(s)for(let i of e.planes.all)i.modules.frames?.pending&&s.feed(i)&&(t=!0);return t}Dd(e){let t=this.Ld;for(let s=t[0];s!==void 0&&e-s>1e3;s=t[0])t.shift();return t.length}},Zs=e=>e.state.status==="loading"&&e.state.drawnFrame!==null;function Qs(e,t,s,i){let r=1-Math.min(1,Math.max(0,s));return e+(t-e)*(1-Math.pow(r,Math.max(0,i)*60))}var ei=3600,ti=2,si=.12,ii=5e-4,ri=.15,ni=5e-4,ai=e=>{let t=e.uniforms;for(let[s,i]of e.plays.la)if(i.trigger==="hover"&&t[s]?.value>0)return!0;return!1},li=class{constructor(e,t,s){this.stage=e;this.transitions=t;this.own=s;this.gh={changed:!1,busy:!1}}result(e,t){let s=this.gh;return s.changed=e,s.busy=t,s}run(e){let t=this.stage,s=t.env.reducedMotion;s||(t.env.frame.time=e.time);let i=t.canvasHost.viewport.width,r=t.canvasHost.viewport.height,n=this.own.stepTweens(e.time),a=this.fg(e,s),l=this.own.dirty()||t.scheduler.forced>0||n,o=!1;t.chunks.shapes?.frame(i,r);let h=t.planes.visible,u=h.length;h.length=0;let d=t.env.frame.velocity!==0||a!==0,c={frame:e,vw:i,vh:r,still:s,scrolling:d,sx:0,sy:0};for(let e of t.planes.all){if(e.destroyed)continue;let t=this.ai(e,c,l);t.changed&&(l=!0),t.busy&&(o=!0)}!o&&t.gpu.media.uploads.some(ci)&&(o=!0),h.length!==u&&(l=!0);let f=!!t.chunks.morph?.update(t.env.now);f&&(l=!0),this.transitions.land(f,h),bi(h,e);let m=t.scheduler.Na(performance.now()),p=l||o||m||this.own.dirty();return t.env.stats.busy=this._a(h,m,f,n),p}fg(e,t){let s=this.stage,i=t?0:Math.max(-1,Math.min(1,(e.scroll.velocity||0)/ei)),r=s.env.frame.velocity;return s.env.frame.velocity=Qs(s.env.frame.velocity,i,si,e.dt),Math.abs(s.env.frame.velocity)<ii&&i===0&&(s.env.frame.velocity=0),s.env.host.velocity.value=s.env.frame.velocity,r}ai(e,t,s){let i=this.stage,r=t.sx=e.scrolls?i.env.frame.scrollX:i.env.frame.pageX,n=t.sy=e.scrolls?i.env.frame.scrollY:i.env.frame.pageY,a=qe(e,r,n);oi(e,a,t),e.fly?.(a,r,n),this.Fd(e,a,r,n);let l=this.Zh(e,t.frame,a);e.visible=ui(e,a,t),this.clip(e,a)&&(l=!0);let o=e.visible?i.planes.visible.push(e)-1:-1;return o!==e.listed&&(e.listed=o,l=!0),o<0?this.result(l,!1):(this.Yh(e,a,t,s||l)&&(l=!0),this.result(l,gi(e,t.still)))}clip(e,t){let s=this.stage.chunks.shapes;if(!e.clips||!s||(e.clips.ka=null,!e.visible))return!1;let i=s.clip(e.clips,t,e.bends);return i.visible||(e.visible=!1),i.moved}Yh(e,t,s,i){let r=!i&&di(e,t),n=Ye(t,this.stage.env.frame.screen.height);return n!==e.progress&&(e.progress=n,e.reads.has("progress")&&(r=!0)),mi(e)&&(r=!0),e.kind==="video"&&e._a.has("video")&&(e.videoFrame=!0),e._u&&this.eg(e,t,s)&&(r=!0),pi(e,s.frame),e.kind==="video"&&e.videoFrame&&vi(e)&&(r=!0),s.scrolling&&(e.reads.has("velocity")||e.layer)&&(r=!0),r}Fd(e,t,s,i){let r=this.stage.chunks.shapes;if(e.level&&!e.xfReason&&r){r.Fd(e,s,i);return}let n=e._c;n[0]=1,n[4]=1,n[8]=1,n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=t[0],n[7]=t[1],e.size[0]=t[2],e.size[1]=t[3]}Zh(e,t,s){let r=!1;if(!e.modules.list.length||!(e.zone.near||e.zone.soon)||e.status==="error")return r;for(let n of e.modules.list)if(n.binding.update)try{n.binding.update(t,s,this.stage.env.frame.screen)&&(r=!0)}catch(e){i.error(`module "${n.name}" update failed`,e),n.binding.update=void 0}return r}eg(e,t,{sx:s,sy:i,frame:r}){let n=r.dt,a=this.stage,l=a.env.frame.pointer;e.level&&!e.xfReason&&a.chunks.shapes?a.chunks.shapes.pointer(e,l.x+s,l.y+i):(e._h[0]=(l.x-t[0])/Math.max(t[2],1),e._h[1]=(l.y-t[1])/Math.max(t[3],1));let o=e._h[0],h=e._h[1],u=Math.abs(o-e.mouse[0])+Math.abs(h-e.mouse[1])<ni,d=u?o:Qs(e.mouse[0],o,ri,n),c=u?h:Qs(e.mouse[1],h,ri,n);return Math.fround(d)===e.mouse[0]&&Math.fround(c)===e.mouse[1]?!1:(e.mouse[0]=d,e.mouse[1]=c,!0)}_a(e,t,s,i){let r=this.stage,n=[];t&&n.push("live"),r.gpu.media.uploads.length&&n.push("upload"),r.env.frame.velocity!==0&&n.push("scroll"),s&&n.push("morph"),i&&n.push("tween");let a=this.own.Vd();a&&n.push(`dom-watch:${this.stage.env.lib.describe(a)}`);for(let t of e)t._a.forEach(e=>n.push(e)),t.reads.has("time")&&ai(t)&&n.push("hover"),t.shader&&t.shader.def.animate!==!1&&n.push(`shader:${t.shader.name}`);return n}};function oi(e,t,s){let i=e.wrap;if(!i?.period)return;let r=i.axis,n=r?t[3]:t[2],a=i.start-(r?s.sy:s.sx);t[r]=a+((t[r]-a+n)%i.period+i.period)%i.period-n;let l=hi(t,s);l!==e.zone.screen&&(e.zone.screen=l,e.modules.tell(e=>e.visible?.(l)),e.emit(l?"enter":"leave")),!l&&e.status==="loading"&&e.texture?.ready&&e.program?.ready()&&e.setStatus("ready")}var hi=(e,t)=>e[0]<t.vw&&e[0]+e[2]>0&&e[1]<t.vh&&e[1]+e[3]>0;function ui(e,t,s){return e.el.isConnected&&e.status!=="error"&&e.textureState!=="error"&&(!!e.program||!!e.layer)&&t[2]>0&&t[3]>0&&(e.opacity>.001||e.layer?.def.followOpacity===!1)&&!e.backHidden&&!e.shapeWait&&hi(t,s)}function di(e,t){if(fi(e))return!1;let s=e._z;if(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])return!0;if(e.level){let t=e._c,s=e._D;for(let e=0;e<9;e++)if(t[e]!==s[e])return!0}return e.opacity!==e._y}var ci=e=>e.plane.visible||e.plane.zone.screen;function fi(e){if(e.modules.feed||e.kind==="shader"||e.kind==="layer"||e.texture?.ready||e.prev?.ready)return!1;let t=e.kind==="video"?e.media:null;return!(t&&e.videoFrame&&(t.readyState||0)>=ti)}function mi(e){if(!e._C)return!1;let t=!1;for(let s in e.uniforms){let i=e.uniforms[s];i instanceof _s&&i.changed()&&(t=!0)}return t}function pi(e,t){for(let s of e.effects){let e=s.ctx;if(!(!s.def.update||!e)){e.frame=t;try{s.def.update(e)}catch(e){i.error(`effect "${s.name}" update failed`,e),s.def={...s.def,update:void 0}}}}let s=e.shader,r=s?.ctx;if(!(!s?.def.update||!r)){r.frame=t;try{s.def.update(r)}catch(e){i.error(`shader "${s.name}" update failed`,e),s.def={...s.def,update:void 0}}}}function gi(e,t){return e._a.size?!0:t?!1:e.reads.has("time")&&ai(e)?!0:!!e.shader&&e.shader.def.animate!==!1||!!e.layer?.ready&&e.layer.def.animate!==!1}var vi=e=>(e.media?.readyState??0)>=ti;function bi(e,t){for(let s of e){let e=s.state;e.status==="loading"&&e.drawnFrame!==null&&e.drawnFrame<t.frame&&s.setStatus("ready"),s._E&&s.status==="ready"&&!s.morphHidden&&s.el.removeAttribute("data-umber-morphing")}}var yi=class{constructor(e,t){this.stage=e;this.own=t;this.watched=null;this.slides=new ki;this.batches=0}get Tc(){return this.batches}get bd(){return this.batches+(this.stage.env.host.changes?.()??0)}nd(){this.batches++}scan(e){this.Ad();for(let t of this.stage.env.lib.findGL(e))this.stage.planes.of(t)||this.stage.factory.create(t);this.stage.scheduler.markDirty()}Vd(){let e=this.watched;return this.watched=null,e}apply(e){e.still||this.batches++,(e.styles||e.added.length)&&this.Ad();for(let t of e.ca){let e=this.stage.planes.of(t);e&&this.stage.planes.remove(e)}this.hf(e);let t=this.ef(e),s=this.ff(e)||t;s&&(this.own.Xb(1.5),this.stage.chunks.fx?.leave?.swap()),e.touched.length&&this.jf(e.touched),this.gf(e),s&&this.stage.measurePhase.da()}gf(e){if(e.look)for(let e of this.stage.planes.all)e.status==="error"&&(e.stale=!0);if(e.styles){for(let e of this.stage.planes.all)e.stale=!0;this.stage.measurePhase.da(),this.stage.scheduler.markDirty()}(e.styles||e.touched.some(e=>e===document.documentElement||e===document.body))&&this.stage.canvasHost.check()}hf(e){for(let t of e.sources){let s=this.stage.planes.of(t);s?.kind==="image"&&s.textureState!=="none"?this.stage.gpu.media.loadImage(s,!0):s?.kind==="video"&&this.stage.chunks.video?.Md(s,e.ca)}}ff(e){if(!e.removed&&!(e.detached&&this.stage.planes.all.some(e=>!e.el.isConnected)))return!1;let t=this.stage.planes.all.length;return this.stage.planes.prune(),this.stage.planes.all.length>=t?!1:(this.stage.transitions.retry(),!0)}ef(e){let t=[...e.added,...e.ca];if(!t.length)return!1;for(let t of e.added)this.stage.chunks.video?.wh(t);let s=[...new Set(t.flatMap(e=>this.stage.env.lib.findGL(e)))];this.stage.chunks.fx?.groups.moved();for(let e of s){let t=this.stage.planes.of(e);t&&(t.stale=!0),t&&this.stage.chunks.morph?.forget(t)&&this.stage.planes.attach(t)}let i=s.filter(e=>!this.stage.planes.of(e));if(!i.length)return!1;i.some(e=>e.hasAttribute("data-umber-id"))&&this.stage.chunks.morph?.capture(null,!0);for(let e of i)this.stage.factory.create(e);return this.stage.chunks.morph?.settle(!1),e.added.some(e=>e!==document.documentElement)}jf(e){let t=!1,s=new Map,i=e=>(s.has(e)||s.set(e,this.slides.slid(e)),s.get(e)??null);for(let s of this.stage.planes.all){let r=e.find(e=>wi(e,s));if(!r)continue;if(s.status==="error"){this.dd??=setTimeout(()=>{this.dd=void 0;for(let e of this.stage.planes.all)e.status==="error"&&(e.stale=!0);this.stage.scheduler.request()},250);continue}let n=r===s.el||s.level?null:i(r);n?(s.doc.x+=n[0],s.doc.y+=n[1],this.stage.measurePhase.Kh(r)):s.stale=!0,t=!0,this.watched=r}t&&(this.stage.measurePhase.da(),this.stage.scheduler.markDirty())}Ad(){!this.stage.chunks.shapes&&document.querySelector("[data-umber-occlude]")&&this.stage.chunks.loadShapes(),document.querySelector("[data-umber-pass]")&&this.stage.chunks.loadFx()}};function wi(e,t){return e===t.el?!0:e.contains(t.geomEl)?t.zone.soon||t.visible||e!==document.documentElement&&e!==document.body:!1}var xi=e=>!!e&&e!=="none",ki=class{constructor(){this.seen=new WeakMap}slid(e){let{transform:t,translate:s,rotate:i,scale:r}=getComputedStyle(e),n=t.split(","),[a,l]=n.splice(n.length>6?12:4,2).map(parseFloat),[o=0,h=0]=xi(s)?s.split(" ").map(parseFloat):[],u=!xi(i)&&!xi(r)&&!/[%(]/.test(s)&&(a!==void 0||xi(s))?[(a??0)+o,(l??0)+h]:null,d=String(e.getAttribute("class"))+(e.getAttribute("style")??"").replace(/(^|;)\s*(transform|translate)\s*:[^;]*/g,"")+String(n),c=this.seen.get(e);return this.seen.set(e,{key:d,move:u}),c?.key===d&&u&&c.move?[u[0]-c.move[0],u[1]-c.move[1]]:null}};var _i=[1,.85,.7,.55],Ei={high:2,mid:1.5,low:1},Mi=.8;function Si({option:e,tier:t,width:s,height:i,budget:r=12e6,wide:n=1/0}){let a=0,l;typeof e=="number"&&e>0?l=e:Array.isArray(e)?(a=Math.max(0,e[0]||0),l=e[1]||Ei[t]):l=(e&&typeof e=="object"?e[t]:void 0)??Ei[t],s>n&&(l=Math.min(l,Mi));let o=Math.max(a,Math.min(typeof devicePixelRatio=="number"&&devicePixelRatio||1,l)),h=s*i;return h*o*o>r&&(o=Math.sqrt(r/Math.max(h,1))),o}function Ai(e,t,s){return e<0?s?45/150:1:e>t*.6?1:0}var Ri=class{constructor(){this.scale=1;this.index=0;this.settle=30;this.Sa=0;this.Ya=0;this.hd=[];this.Cc=150;this.rd=-1}frame(e,t,s,i){let r=e.frame-this.rd===1;this.rd=e.frame;let n=this.hd;n.push(e.dt),n.length>120&&n.shift();let a=e.dt*60;if(this.settle>0||t)return this.settle=Math.max(0,this.settle-a),!1;if(!r||n.length<30)return!1;let l=1/0;for(let e of n)e<l&&(l=e);e.dt>Math.max(l*1.5,1/40)?(this.Sa+=Ai(s,l*1e3,i),this.Ya=0):e.dt<l*1.2&&(this.Ya+=a,this.Sa=Math.max(0,this.Sa-a));let o=i?45:150;return this.Sa>o&&this.index<_i.length-1?(this.Cc=Math.min(this.Cc*2,2400),this.Pd(this.index+1),!0):this.Ya>this.Cc&&this.index>0?(this.Pd(this.index-1),!0):!1}onResize(){this.settle=30,this.Sa=0,this.Ya=0}rest(e){this.settle=Math.max(this.settle,e)}reset(){this.hd.length=0,this.settle=30}Pd(e){let t=_i[e];t!==void 0&&(this.index=e,this.scale=t,this.Sa=0,this.Ya=0,this.settle=30)}};var Ti=12e6,zi=class{constructor(e,t,s,i){this.stage=e;this.ownership=s;this.own=i;this.reason=null;this.viewport={width:1,height:1};this.dpr=1;this.Bb=!0;this.ratio=1;this.el=t}Ib(){this.Bb=!0}uh(){this.Bb&&this.resize()}check(){if(this.stage.env.destroyed)return;let e=Le(this.el,this.ownership,this.stage.env.lib);e!==this.reason&&(this.reason=e,this.stage.gpu.canvas.style.display=e?"none":"",e&&this.stage.env.lib.say("host",[e,this.ownership==="created"]),e?this.stage.scheduler.hold("host"):this.stage.scheduler.release("host"))}keep(){if(this.stage.gpu.context.off||this.stage.env.destroyed)return!1;let e=document.documentElement;e.classList.contains("has-umber")||e.classList.add("has-umber");let t=this.stage.gpu.canvas;if(t.isConnected)return!1;document.querySelectorAll("[data-umber-canvas]").forEach(e=>{(this.ownership==="created"&&e.parentElement?.hasAttribute("data-umber-host")?e.parentElement:e).remove()});let s=this.el,r=this.ownership==="created"?null:this.Jh(),n=r?.isConnected?r:s;return n.isConnected||(document.body.prepend(n),this.ownership==="site"&&this.stage.env.host.loadInspect?.().then(e=>{i.warn(e.hostLeft)},()=>{})),n!==s&&(this.own.wd(s,n),this.el=n),t.parentElement!==n&&n.appendChild(t),this.Bb=!0,this.check(),this.stage.factory.invalidate(),!0}Jh(){let e=this.stage.env.options.host;return e instanceof HTMLElement?e:document.querySelector(typeof e=="string"?e:"[data-umber-host]")}resize(){this.Bb=!1,this.stage.gpu.renderer.adaptive.onResize();let e=this.el.clientWidth||window.innerWidth,t=this.el.clientHeight||window.innerHeight;this.viewport.width=e,this.viewport.height=t;let s=this.stage.chunks.za?this.stage.chunks.za.dpr(e,t):Si({option:this.stage.env.options.dpr,tier:this.stage.gpu.tier.tier,width:e,height:t,budget:Number(this.stage.env.options.pixelBudget)||Ti,wide:this.stage.gpu.tier.wide});this.dpr=s,devicePixelRatio!==this.ratio&&(this.ratio=devicePixelRatio,this.stage.planes.all.forEach(e=>{this.stage.gpu.media.sharpen(e)}));let i=s*this.stage.gpu.renderer.adaptive.scale,r=Math.max(1,Math.round(e*i)),n=Math.max(1,Math.round(t*i));(this.stage.gpu.canvas.width!==r||this.stage.gpu.canvas.height!==n)&&(this.stage.gpu.canvas.width=r,this.stage.gpu.canvas.height=n,this.stage.chunks.views?.resized(r,n)),this.stage.env.stats.dpr=Math.round(s*100)/100,this.stage.env.stats.width=r,this.stage.env.stats.height=n,this.stage.scheduler.oa(1)}};function Ui(e){return{onScreen:Ls,ease:t=>ws(t,e),Texture:Yt,Plane:Rs,bitmap:es}}var Pi=class{constructor(e,t){this.stage=e;this.own=t;this.visible=[];this.items=[];this.qb=new WeakMap}get all(){return this.items}of(e){return this.qb.get(e)}list(e){return!e||e===document?this.items.slice():this.items.filter(t=>e.contains(t.el))}add(e){this.items.push(e),this.qb.set(e.el,e)}forget(e){this.qb.get(e.el)===e&&this.qb.delete(e.el)}detach(e){let t=this.items.indexOf(e);t!==-1&&this.items.splice(t,1),this.stage.scheduler.markDirty()}attach(e){this.items.includes(e)||this.items.push(e),e.stale=!0,this.stage.scheduler.markDirty()}discard(e){this.detach(e),e.el.isConnected||this.stage.chunks.video?.release(e),this.own.destroy(e)}remove(e){this.items=this.items.filter(t=>t!==e),this.own.destroy(e),this.stage.scheduler.markDirty()}ph(e){let t=this.of(e);t&&this.remove(t)}prune(){let e=[],t=this.stage.chunks.morph;for(let s of this.items)if(s.el.isConnected)e.push(s);else{if(t?.holds(s)||t?.keep(s))continue;this.stage.chunks.video?.release(s),this.own.destroy(s)}this.items=e,this.stage.scheduler.markDirty()}clear(){for(let e of this.items)this.own.destroy(e);this.items=[]}ca(e){this.remove(e),this.own.create(e.el)}defined(e,t){let s=e==="effect"?t:`${e}:${t}`;for(let i of this.items.slice())(i.missing.includes(s)||e==="layer"&&i.kind==="layer"&&!i.layer&&Qe(i.el)===t)&&i.el.isConnected&&this.ca(i)}redefined(e,t){let s=this.stage.gpu.programs.drop(e,t),i=i=>{switch(e){case"effect":return i.effects.some(e=>e.name===t);case"shader":return i.shader?.name===t;case"chunk":return!!i.program&&s.includes(i.program);case"layer":return i.kind==="layer"&&!!i.layer&&Qe(i.el)===t}};for(let e of this.items.slice())i(e)&&e.el.isConnected&&this.ca(e);if(!this.stage.chunks.morph?.busy)for(let e of s)this.items.some(t=>t.program===e)||e.dispose()}};var Ci=class{constructor(e,t,s,i=0){this.vars=t;this.ld=i;this.from=0;this.progress=0;this.done=!1;this.paused=!1;this.qa=NaN;this.velocity=0;this.at=1/0;this.now=NaN;this.list=null;this.Kc=null;this.resolve=null;this.promise=null;this.target=e,this.to=t.value,this.duration=Math.max(0,(t.duration??1)||0),this.delay=Math.max(0,(t.delay??0)||0),this.ease=ws(t.ease,s);let r=this.ease.spring;r&&this.duration>0&&(this.Kc=[r[0],r[1]/this.duration])}step(e){if(this.done)return!1;if(this.now=e,this.paused)return!0;Number.isNaN(this.qa)&&(this.qa=e);let t=e-this.qa-this.delay;if(t<0)return!0;this.progress===0&&(this.from=Number(this.target.value)||0),this.progress=this.duration>0?Math.min(1,t/this.duration):1;let s=this.Kc?this.Mh(this.Kc,t):this.Zf(e);return this.at=e,this.vars.onUpdate?.(),s?(this.finish(),this.vars.onComplete?.(),!1):!0}Zf(e){let t=this.from+(this.to-this.from)*this.ease(this.progress);return e>this.at&&(this.velocity=(t-(Number(this.target.value)||0))/(e-this.at)),this.target.value=t,this.progress>=1}Mh(e,t){let s=e[1],i=this.from-this.to,[r,n]=as(e,i,this.ld,t),a=.001*Math.max(Math.abs(i),Math.abs(this.ld)/s,1e-9),l=Math.abs(r)<a&&Math.abs(n)<a*s;return this.target.value=l?this.to:this.to+r,this.velocity=l?0:n,l}pause(){return!this.done&&!this.paused&&(this.paused=!0,this.qa=this.time-this.qa),this}play(){return this.paused&&(this.paused=!1,this.qa=this.time-this.qa,this.list?.wake()),this}get time(){return this.list?this.list.now:this.now}kill(){return this.finish(),this}then(e,t){return this.promise??=new Promise(e=>{this.done?e(void 0):this.resolve=()=>{e(void 0)}}),this.promise.then(e,t)}finish(){this.done||(this.done=!0,this.resolve?.(),this.resolve=null)}},Fi=class{constructor(e,t=()=>{},s=null){this.say=e;this.wake=t;this.clock=s;this.list=[];this.time=0;this.stepped=!1}get now(){return this.clock?this.clock():this.time}to(e,t){(typeof t.value!="number"||!Number.isFinite(t.value))&&this.say("tween",[t.value]);let s=this.of(e);this.qd(e);let i=new Ci(e,t,this.say,s&&!(Number(t.delay)>0)?s.velocity:0);return i.duration===0&&i.delay===0?(i.step(this.time),i):(i.qa=this.clock||this.stepped?this.now:NaN,i.list=this,this.list.push(i),this.wake(),i)}step(e){if(this.time=e,this.stepped=!0,!this.list.length)return!1;let t=!1;for(let s of this.list.slice())s.step(e)&&!s.paused&&(t=!0);return this.list=this.list.filter(e=>!e.done),t}qd(e){let t=new Set(Array.isArray(e)?e:[e]);for(let e of this.list)t.has(e.target)&&e.kill();this.list=this.list.filter(e=>!e.done)}of(e){return this.list.find(t=>t.target===e&&!t.done)??null}get size(){return this.list.length}clear(){for(let e of this.list)e.kill();this.list=[]}};var Li=class{constructor(){this.scrollX=0;this.scrollY=0;this.pageX=0;this.pageY=0;this.scrolled=!1;this.velocity=0;this.pointer={x:-1,y:-1};this.time=0;this.screen={width:1,height:1};this.Va=new Map}};var Ii=class{constructor(e,t,s,i){this.host=e;this.kit=t;this.stats=s;this.frame=new Li;this.onInvalidate=new Set;this.cleanups=[];this.destroyed=!1;this.options=e.options,this.registry=e.registry,this.lib=e.lib,this.tweens=new Fi(e.lib.say,i,()=>e.ticker.frame.time)}get reducedMotion(){return this.options.reducedMotion!=="off"&&this.host.env.reducedMotion}get now(){return this.host.ticker.frame.time*1e3}listen(e,t,s,i=!0){e.addEventListener(t,s,{passive:i}),this.cleanups.push(()=>{e.removeEventListener(t,s)})}};var Ni=/\.ktx2(?:[?#]|$)/i,Di=null,$i=null,Bi=()=>Di??=import(new URL("./basis.js",import.meta.url).href).then(e=>$i=e),Oi=()=>document.querySelector('meta[name="umber-assets"]')?.content??"",Hi=1.25,qi=e=>Hi*e.zoom,Gi=1.5,Vi=4,Wi=8*2**20,ji=.9;function Xi(e){n()?a().then(e):"requestIdleCallback"in window?requestIdleCallback(e,{timeout:2e3}):setTimeout(e,200)}var Yi=(...e)=>e.find(e=>!!e)??"";var Ki=class{constructor(e){this.stage=e;this.place=Oe;this.uploads=[];this.nb=new Map;this.Lb=new Map;this.images=new Map;this.warned=!1;this.Gd=null;this.loadPrepared=()=>import(new URL("./prepared.js",import.meta.url).href)}get yf(){return this.nb.size+this.images.size}get jd(){let e=0;for(let t of this.images.values())e+=t.bytes;return e}release(e){let t=e.texture;return e.texture=null,this.free(t)}free(e){if(!e||--e.refs>0)return!1;for(let[t,s]of this.images)s===e&&this.images.delete(t);return e.dispose(),!0}loadImage(e,t){if(t&&e.textureState==="error")return;let s=this.stage,i=e.media,r=e.el.getAttribute("data-umber-src"),n=()=>Yi(r,i?.currentSrc,i?.src),a=n(),l=++e.loads;e.textureState="loading";let o=i=>{if(l!==e.loads||e.destroyed||s.gpu.context.gone)return;if(e.loads++,!i){this.stage.env.lib.say("image",[]),e.textureState="error",e.setStatus("error");return}let r=this.images.get(i);if(!r||e.texture!==r){t&&e.texture?.ready&&!e.prev?(e.prev=e.texture,e.texture=null):this.release(e);let n=!r;r||this.images.set(i,r=new Yt(s.gpu.gl)),r.refs++,e.texture=r,n&&this.fetch(i,r)}this.sharpen(e),r.ready&&(e.textureState="ready",Oe(e),e._i(),e.prev&&s.transitions.swap(e),s.scheduler.markDirty())};if(!r&&i&&(t||!i.currentSrc)&&!i.complete){let e=new AbortController,t=()=>{e.abort(),clearTimeout(r),o(n())};i.addEventListener("load",t,{signal:e.signal}),i.addEventListener("error",t,{signal:e.signal});let r=setTimeout(()=>{if(!i.currentSrc){if(!i.srcset){o(i.src);return}s.chunks.loadWarm().then(e=>{i.currentSrc||o((e?e.pick(i):"")||i.src)})}},4e3);return}o(a)}fetch(e,t,s,i=!1){let r=this.stage,n={src:e,tex:t,was:s,box:[0,0]},a=()=>{for(let e of this.na(t))n.box[0]=Math.max(n.box[0],e.doc.w*r.canvasHost.dpr*qi(e)),n.box[1]=Math.max(n.box[1],e.doc.h*r.canvasHost.dpr*qi(e));return i&&s?.[0]&&(n.box[0]=Math.max(n.box[0],ee(s,0)*2),n.box[1]=Math.max(n.box[1],ee(s,1)*2)),n.box[0]?n.box:this.cap(n.box)};if(Ni.test(e)){this.transcode(n,a);return}let l=Oi();(l?this.ig(l,n,a):es(e,r.gpu.tier.maxTexture,a)).then(e=>{this.decoded(n,e)}).catch(e=>{this.Lc(n,e)})}transcode(e,t){let s=this.stage;Bi().then(i=>i.loadKtx2(s.gpu.gl,e.src,t)).then(({image:t,box:s})=>{e.box=s,this.decoded(e,t)}).catch(i=>{let r=this.na(e.tex).find(e=>e.media instanceof HTMLImageElement)?.media,n=Yi(r?.currentSrc,r?.src);if(!n||e.tex.ready){this.Lc(e,i);return}this.stage.env.lib.say("ktx2",[e.src],i),es(n,s.gpu.tier.maxTexture,t).then(t=>{this.decoded(e,t)}).catch(t=>{this.Lc(e,t)})})}async ig(e,t,s){let r=this.stage,n=r.gpu.tier.maxTexture;try{let i=await(this.Gd??=await this.loadPrepared()).get(r.gpu.gl,{manifest:e,src:t.src,size:s,maxTexture:n});if(i&&"image"in i)return t.box=i.box,i.image;if(i)return await es(i.avif,n,s)}catch(e){i.info("prepared failed",t.src,e)}return es(this.jg(t)??t.src,n,s)}jg(e){for(let t of this.na(e.tex)){let e=t.el.querySelector("[data-umber-tiny]+source")?.srcset.trim().split(/[\s,]/)[0];if(e)return e}return null}na(e){return this.stage.planes.all.filter(t=>t.texture===e)}decoded({src:e,tex:t,was:s,box:i},r){let n=this.stage;t.box=i,(ee(i,2)>n.gpu.tier.maxTexture||ee(i,3)>n.gpu.tier.maxTexture)&&n.chunks.loadWarm().then(t=>t?.note(e,i));let a=this.na(t),l=a.find(e=>e.status!=="error"||e.slow||t.ready&&e.domReason);if(!l){"close"in r&&r.close(),this.unclaimed(e,t,s,a);return}for(let e of a)e.textureState==="loading"&&(e.textureState="queued");this.Ac(l,r,t),a.some(e=>e.visible||e.zone.screen)?n.scheduler.markDirty():n.scheduler.request()}unclaimed(e,t,s,i){if(t.ready){s&&(t.box=s);return}this.images.get(e)===t&&this.images.delete(e);for(let e of i)e.domReason&&e.textureState==="loading"&&(e.textureState="none")}Lc({src:e,tex:t,was:s},i){if(t.ready){s&&(t.box=s);return}this.images.get(e)===t&&this.images.delete(e);for(let s of this.na(t))this.stage.env.lib.say("cors",[s.el,e],i),s.textureState="error",s.setStatus("error"),this.stage.env.lib.showFullImages(s.el)}cap(e,t=0){let s=this.stage.canvasHost.dpr*Hi;return e[0]=(t||innerWidth)*s,e[1]=t?0:innerHeight*s,e}sharpen(e){let t=this.stage,s=e.texture,i=t.canvasHost.dpr;if(!s?.box[2]||!s.ready)return;let r=s.box,[n=0]=r,a=e.zoom;if(n&&(e.doc.w*i*a>n||e.doc.h*i*a>ee(r,1))){this.again(s,r,!0);return}let l=ee(r,2),o=ee(r,3),h=this.need(s,l,o);if(!h||(n||l)<=Gi*h*l)return;s.box=[];let u=e=>{if(t.env.destroyed||!s.texture)return;let i=this.need(s,l,o);t.chunks.morph?.busy||i&&i!==e?Xi(()=>{u(i)}):this.again(s,r)};Xi(()=>{u(h)})}need(e,t,s){let i=this.stage.canvasHost.dpr,r=0;for(let n of this.stage.planes.all)if(n.texture===e){if(!n.measured)return 0;r=Math.max(r,n.doc.w*i*qi(n)/t,n.doc.h*i*qi(n)/s)}return r}again(e,t=e.box,s=!1){e.box=[];for(let[i,r]of this.images)if(r===e){this.fetch(i,r,t,s);return}}forget(e){let t=this.uploads.findIndex(t=>t.plane===e&&!t.tex);if(t<0)return;let[s]=this.uploads.splice(t,1);s&&"close"in s.source&&s.source.close()}Ac(e,t,s){let i=this.uploads.find(t=>s?t.tex===s:!t.tex&&t.plane===e);if(!i)return void this.uploads.push({plane:e,source:t,tex:s});i.source!==t&&"close"in i.source&&i.source.close(),i.source=t}di(e){if(!this.uploads.length)return!1;let t=performance.now(),s=0,i=!1;do{let e=this.Sg();if(!e)break;let t=this.fi(e);t&&(this.gi(t,e),s+=t.bytes,this.landed(t)&&(i=!0)),"close"in e.source&&e.source.close()}while(this.uploads.length&&s<Wi&&Math.min(e,Vi)+performance.now()-t<Vi);return this.Wb(),i}gi(e,t){let s=this.stage.gpu.gl;"levels"in t.source?($i??this.Gd)?.upload(s,e,t.source):e.upload(t.source,t.plane._k?{mipmaps:!1}:{}),t.plane.raster?.upload(s),this.stage.env.stats.uploads++}Sg(){let e=this.uploads.findIndex(e=>!(e.tex??e.plane.texture)?.ready);return this.uploads.splice(Math.max(0,e),1)[0]}fi(e){let t=this.stage;if(e.tex)return e.tex.texture?e.tex:null;let s=e.plane;return!t.planes.all.includes(s)||s.status==="error"&&!s.slow?null:s.texture??=new Yt(t.gpu.gl)}landed(e){let t=!1;for(let s of this.stage.planes.all)s.texture!==e||s.textureState==="error"||(s.textureState="ready",Oe(s),s._i(),s.prev&&this.stage.transitions.swap(s),Ce(this.stage.env.lib,s),t||=s.visible||s.zone.screen);return t}Wb(){let e=this.stage,t=e.gpu.tier.textureBudget,s=e.chunks.fx,i=e.chunks.video,r=0;for(let t of e.planes.all)t.texture?.refs||(r+=t.texture?.bytes??0);r+=this.jd;let n=s?.pool.bytes??0,a=i?.ac()??0;s&&r+n+a>t&&(n-=s.pool.trim()),r+n+a>t&&(r=this.hg(r,t*ji-n-a)),i&&(a-=i.fit(t-r-n)),r+n+a>t&&!this.warned&&(this.warned=!0,e.chunks.loadWarm().then(e=>e?.note("",[r,n+a]))),e.env.stats.textureMB=Math.round(r/2**20)}hg(e,t){let s=this.stage.env.frame,i=s.scrollX+s.screen.width/2,r=s.scrollY+s.screen.height/2,n=e=>Math.abs(e.doc.x+e.doc.w/2-i)+Math.abs(e.doc.y+e.doc.h/2-r)+(e.zone.near?0:1e9),a=this.stage.planes.all.filter(e=>e.kind==="image"&&!e.zone.soon&&!e.zone.screen&&e.texture?.ready).sort((e,t)=>n(t)-n(e));for(let s of a){if(e<=t)break;let i=s.texture?.bytes??0;this.release(s)&&(e-=i),s.textureState!=="error"&&(s.textureState="none"),s.status!=="error"&&(s.setStatus(null),s.wait())}return e}Wd(e){let t=this.stage,s=this.nb.get(e);if(s)return s;s=new Yt(t.gpu.gl),this.nb.set(e,s),this.Lb.set(s,e);let i=s;return es(e,t.gpu.tier.maxTexture,void 0,!0).then(e=>{i.upload(e,{straight:!0}),"close"in e&&e.close(),t.scheduler.markDirty()}).catch(t=>{this.stage.env.lib.say("uniformImage",[],e,t)}),s}vc(){this.nb.clear(),this.images.clear();for(let e of this.uploads)"close"in e.source&&e.source.close();this.uploads.length=0}dispose(){this.nb.forEach(e=>{e.dispose()}),this.images.forEach(e=>{e.dispose()}),this.Lb.clear(),this.vc()}};var Ji=[["aUmberRect",1],["aUmberA",2],["aUmberB",3],["aUmberRadius",4],["aUmberC",5],["aUmberD",6],["aUmberM",7],["aUmberXf",10],["aUmberClipBox",13],["aUmberClipRadius",14]],Zi={uRect:"aUmberRect",uSize:"aUmberA.xy",uMouse:"aUmberA.zw",uBleed:"aUmberB.x",uProgress:"aUmberB.y",uPlaneMatrix:"aUmberM"},Qi={uRect:"vUmberRect",uSize:"vUmberA.xy",uMouse:"vUmberA.zw",uProgress:"vUmberB.y",uAlpha:"vUmberB.z",uRadiusKy:"vUmberB.w",uRadius:"vUmberRadius",uFit:"vUmberC.x",uFitPosition:"vUmberC.yz",uImageSize:"vUmberD.xy"},er=["Rect","A","B","Radius","C","D","ClipBox","ClipRadius"],tr=/\b(gl_InstanceID|vUmber\w*|aUmber\w*|uUmberImages|umberImage)\b/;function sr(e,t){return e.replace(new RegExp(`^uniform\\s+\\w+\\s+(${t.join("|")});.*$`,"gm"),"")}var ir=/^uniform\s+\w+\s+(uUmberClips|uUmberClipXf\[2\]|uUmberClipBox\[2\]|uUmberClipRadius\[2\]);.*$/gm,rr=`int uUmberClips;\nmat3 uUmberClipXf[2];\nvec4 uUmberClipBox[2];\nvec4 uUmberClipRadius[2];`,nr=` uUmberClips = int(vUmberD.z + 0.5);\n uUmberClipXf[0] = vUmberXf;\n uUmberClipBox[0] = vUmberClipBox;\n uUmberClipRadius[0] = vUmberClipRadius;`,ar=/void\s+main\s*\(\s*\)\s*\{/g,lr=/vec4\s+c\s*=\s*texture\(\s*uImage\s*,\s*f\s*\)\s*;/,or=/vec2\s+fitUv\s*\(\s*vec2\s+uv\s*\)\s*\{/,hr=/precision\s+highp\s+float\s*;(?:\s*precision\s+highp\s+\w+\s*;)*/;function ur(e,t){let s=[...e.matchAll(ar)].at(-1);if(!s)return null;let i=s.index+s[0].length;return e.slice(0,i)+`\n`+t+e.slice(i)}function dr(e,t){let s=hr.exec(e);if(!s)return null;let i=s.index+s[0].length;return e.slice(0,i)+`\n`+t+e.slice(i)}var cr=e=>Object.entries(e).map(([e,t])=>`#define ${e} ${t}`).join(`\n`);function fr(e,t){if((t.match(/\buImage\b/g)??[]).length!==2||tr.test(e+t)||!lr.test(t)||!or.test(t))return null;let s=[...er,"Xf"].map(e=>` vUmber${e} = aUmber${e};`).join(`\n`),i=ur(e,s),r=ur(t,nr);if(!i||!r)return null;let n=dr(sr(i,Object.keys(Zi)),[...er.map(e=>`in vec4 aUmber${e};`),"in mat3 aUmberM;","in mat3 aUmberXf;",...er.map(e=>`flat out vec4 vUmber${e};`),"flat out mat3 vUmberXf;",cr(Zi)].join(`\n`)),a=`vec4 umberImage(vec2 f) {\n vec2 dx = dFdx(f);\n vec2 dy = dFdy(f);\n int i = int(vUmberC.w + 0.5);\n vec4 c = vec4(0.0);\n${Array.from({length:8},(e,t)=>` ${t?"else ":""}if (i == ${t}) c = textureGrad(uUmberImages[${t}], f, dx, dy);`).join(`\n`)}\n return c;\n}\n\n`,l=sr(r,[...Object.keys(Qi),"uImage"]).replace(ir,"").replace(lr,"vec4 c = umberImage(f);").replace(or,e=>a+e),o=dr(l,[...er.map(e=>`flat in vec4 vUmber${e};`),"flat in mat3 vUmberXf;",rr,"uniform sampler2D uUmberImages[8];",cr(Qi)].join(`\n`));return n&&o?{vertex:n,fragment:o}:null}function mr(e,t){if(e===t)return!0;if(!ArrayBuffer.isView(e)&&!Array.isArray(e)||!ArrayBuffer.isView(t)&&!Array.isArray(t))return!1;let s=e,i=t;if(s.length!==i.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==i[e])return!1;return!0}function pr(e,t){for(let s in e.uniforms)if(!mr(e.uniforms[s]?.value,t.uniforms[s]?.value))return!1;return!0}function gr(e){return e.kind==="image"&&!e.backdrop&&!e.modules.frames&&!e.instancing&&!e._k&&!e.shader&&e.level!==2&&(!e.clips?.count||e.clips.count===1&&(e.clips.polyInfo[0]??-1)<0)}var vr=class{constructor(e){this.gl=e;this.data=new Float32Array(3200);this.buffer=null;this.Nb=new Map;this.pictures=[]}unit(e){let t=this.pictures.indexOf(e);return t>=0?t:this.pictures.length>=8?-1:this.pictures.push(e)-1}write(e,t,s,i){let r=this.data,n=e*50,a=t.level&&!t.xfReason?t._v:t.rect;r.set(a,n),n+=4,r[n++]=t.size[0],r[n++]=t.size[1],r[n++]=t.mouse[0],r[n++]=t.mouse[1],r[n++]=t.bleed,r[n++]=t.progress,r[n++]=t.opacity,r[n++]=t._b,r.set(t.radius,n),n+=4,r[n++]=t.fit,r[n++]=t._g[0],r[n++]=t._g[1],r[n++]=i,r[n++]=(s.box?.[2]??0)||s.width,r[n++]=(s.box?.[3]??0)||s.height;let l=t.clips,o=l?.count??0;r[n++]=o,r[n++]=0,r.set(t._c,n),n+=9;for(let e=0;e<17;e++)r[n+e]=0;if(l&&o){for(let e=0;e<9;e++)r[n+e]=l.xf[e]??0;for(let e=0;e<4;e++)r[n+9+e]=l.box[e]??0,r[n+13+e]=l.radius[e]??0}}draw(e,t){let s=this.gl;this.buffer??=s.createBuffer(),s.bindVertexArray(this.vao(e)),s.bindBuffer(s.ARRAY_BUFFER,this.buffer),s.bufferData(s.ARRAY_BUFFER,this.data.subarray(0,t*50),s.STREAM_DRAW),s.drawElementsInstanced(s.TRIANGLES,e.count,s.UNSIGNED_SHORT,0,t)}vao(e){let t=this.Nb.get(e);if(t!==void 0)return t;let s=this.gl;t=s.createVertexArray(),this.Nb.set(e,t),s.bindVertexArray(t);let[i,r]=e.buffers;s.bindBuffer(s.ARRAY_BUFFER,i??null),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,0,0),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,r??null),this.buffer??=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,this.buffer);let n=200,a=(e,t,i)=>{s.enableVertexAttribArray(e),s.vertexAttribPointer(e,t,s.FLOAT,!1,n,i),s.vertexAttribDivisor(e,1)};for(let e=0;e<6;e++)a(e+1,4,e*16);for(let e=0;e<6;e++)a(e+7,3,96+e*12);return a(13,4,168),a(14,4,184),s.bindVertexArray(null),t}lost(){this.Nb.clear(),this.buffer=null}dispose(){for(let e of this.Nb.values())this.gl.deleteVertexArray(e);this.gl.deleteBuffer(this.buffer),this.lost()}};function br(e){let t="";for(let s in e.uniforms){if(O.has(s))continue;let i=q(e.uniforms[s]?.value);i!=="float"&&(t+=`,${s}:${i??"-"}`)}return t&&`|u${t}`}var yr=4,wr=class{constructor(e,t,s=new Map,i=()=>[]){this.gl=e;this.lib=t;this.chunks=s;this.planes=i;this.ea=new Map;this.grids=new Map;this.included=new Map;this.glsl=null;this.textKey="";this.Sc=new WeakMap;this.later=new Set;this.hc=!1;this.batched=new Map;this.pump=()=>{this.hc=!1;for(let e of this.later)e.started&&this.later.delete(e);let[e]=this.later;if(!e)return;let t=!1;for(let e of this.ea.values())e.started&&!e.compiled()&&(t=!0);t||this.begin(e);let[s]=this.later;s&&this.soon(s)}}get size(){let e=0;for(let t of this.ea.values())t.started&&!t.failed&&e++;return e}prepare(e){let t=e.kind==="shader"||e.kind==="video"||e.kind==="text"?e.kind:"image",s=`${t}|${e.shader?.name??""}|${e.effects.map(e=>e.name).join(",")}${e.instancing?.key??""}${br(e)}${t==="text"?this.textKey:""}`;e.programKey=s;let i=this.ea.get(s)??this.build(e,s,t);if(!i)return!1;let r=!e.zone.near&&!e.zone.soon&&!e.zone.screen&&this.size<yr;if(e.zone.screen||e.zone.soon||r?this.begin(i):e.zone.near&&this.soon(i),i.failed)return e.setStatus("error"),!1;e.program=i;let n=this.grid(e.segments);return e.grid=e.instancing?e.instancing.wrap(n):n,e.bends=!!e.instancing||e.effects.some(e=>!!e.def.vertex?.main),!0}build(e,t,s){let r={};for(let[t,s]of Object.entries(e.uniforms))r[t]=s.value;let n={kind:s,effects:e.effects.map(e=>({name:e.name,def:e.def})),shader:e.shader?{name:e.shader.name,def:e.shader.def}:void 0,uniforms:r};if(e.glsl){let s=this.glsl?.(n,e,this.chunks);if(!s)return null;this.included.set(t,s.included),n=s}e.instancing&&(n=e.instancing.build(n));let{vertex:a,fragment:l}=L(n),o=t+","+a+l,h=this.ea.get(o);if(h)return h;let u;try{u=new Nt(this.gl,a,l,{label:t,lazy:!0})}catch(t){return i.error(t instanceof Error?t.message:t),e.setStatus("error"),null}return this.ea.set(t,u),this.Sc.set(u,o),u}want(e,t){let s=e.program;!s||s.started||(t?this.begin(s):this.soon(s))}begin(e){this.later.delete(e),!e.started&&(e.start(),e.failed&&this.fail(e,this.planes()))}soon(e){e.started||(this.later.add(e),!this.hc&&(this.hc=!0,Xi(this.pump)))}fail(e,t){e.error&&this.lib.tell("glsl",e.error,i.error),e.state="failed";for(let[t,s]of this.ea)s===e&&this.ea.delete(t);let s=this.Sc.get(e);s&&this.ea.set(s,e);for(let s of t)s.program===e&&s.setStatus("error")}batch(e){let t=e.program;if(!t?.ready())return null;let s=this.batched.get(t);if(s===void 0){let i=fr(t.vertex,t.fragment);if(s=null,i)try{s=new Nt(this.gl,i.vertex,i.fragment,{label:`${e.programKey} (batched)`,attributes:Ji})}catch{s=null}this.batched.set(t,s)}return!s||s.failed?null:s.ready()?s:null}grid(e){let t=Gt(e),s=this.grids.get(t);return s||(s=new Vt(this.gl,t),this.grids.set(t,s)),s}failed(e,t){let s=e.program;s&&this.fail(s,t)}drop(e,t){let s=[];for(let[i,r]of this.ea)if(this.uses(i,e,t)){this.ea.delete(i),s.push(r);let e=this.batched.get(r);e&&s.push(e),this.batched.delete(r)}return s}uses(e,t,s){let[,i,r=""]=e.split("|");switch(t){case"effect":return r.split(",").includes(s);case"shader":return i===s;case"chunk":return!!this.included.get(e)?.includes(s);case"layer":return!1}}lost(){this.later.clear(),this.batched.clear(),this.ea.clear(),this.grids.clear(),this.included.clear()}dispose(e){e&&(this.ea.forEach(e=>{e.dispose()}),this.grids.forEach(e=>{e.dispose()}),this.batched.forEach(e=>{e?.dispose()})),this.lost()}};var xr=e=>typeof e=="object"&&e!==null&&"texture"in e&&e.texture!==void 0,kr=Array.from({length:8},(e,t)=>t),_r=[-1,0];function Er(e,t){let s=e.clips?.ia?e.clips.scissorPx:null,i=t.clips?.ia?t.clips.scissorPx:null;return!s||!i?s===i:s[0]===i[0]&&s[1]===i[1]&&s[2]===i[2]&&s[3]===i[3]}var Mr=(e,t)=>e.order-t.order||e.index-t.index,Sr=class{constructor(e,t){this.host=e;this.list=[];this.adaptive=new Ri;this.va=null;this.program=null;this.unit=0;this.bound=[];this.fixed=!1;this.ia=-1;this.Bh=Q(4);this.view=new Int32Array(2);this.Mc=new Float32Array(2);this.Ha=new Float32Array(2);this.imageSize=new Float32Array(2);this.surface=new Float32Array(4);this.Aa=0;this.draws=0;this.probe=null;this.run=[];this.Sf=e=>{e.kind==="layer"||!e.program?.ready()||!e.grid||e.kind!=="shader"&&!e.texture?.ready||this.Ia(e,!0)};this.blank=new Yt(t),this.timer=new Wt(t),this.batches=new vr(t),this.ua=Qt(t)}draw(e){let t=this.host,s=t.gpu.gl,i=this.list;i.length=0;for(let e of t.planes.visible)e.destroyed||i.push(e);i.sort(Mr);let r=this.probe;this.timer.poll(),r||this.timer.begin(),this.bound[this.unit]=void 0,this.begin(i,e);for(let t of i)this.Vf(t,e,r)&&(t._z.set(t.rect),t._D.set(t._c),t._y=t.opacity,t.drawnIn(e.frame));return this.flush(),t.chunks.fx?.leave?.frame(),t.chunks.morph?.draw(this.Sf),t.chunks.fx?.post(),r?.(null),this.scissor(null),s.bindVertexArray(null),r||this.timer.end(),this.draws}begin(e,t){let s=this.host,i=s.gpu.gl,r=s.gpu.canvas,n=s.chunks.layers;n&&s.planes.all.some(e=>e.layer)&&(n.begin(e,t),this.reset());let a=this.view;(a[0]!==r.width||a[1]!==r.height)&&(a[0]=r.width,a[1]=r.height,i.viewport(0,0,a[0],a[1])),this.scissor(null),this.fixed||(i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(0,0,0,0),i.enable(i.BLEND),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),i.disable(i.DEPTH_TEST),this.fixed=!0),s.chunks.fx?.pre(e),i.clear(i.COLOR_BUFFER_BIT),this.draws=0;let l=this.Mc;l[0]=s.canvasHost.viewport.width,l[1]=s.canvasHost.viewport.height,this.surface[2]=l[0],this.surface[3]=l[1],this.Ha[0]=r.width,this.Ha[1]=r.height}Vf(e,t,s){if(e.morphHidden||e.viewTransition||e.hush||e.group||!this.Rg(e))return!1;if(e.kind==="layer")return this.flush(),this.Uf(e,t,s);if(!(e.kind==="shader"||e.texture?.ready===!0||e.prev?.ready===!0)||!this.Hd(e))return!1;if(e.backdrop){if(this.flush(),!this.host.chunks.fx?.copy(e))return!1;this.bound[this.unit]=void 0}return s?.(e),this.queue(e),!0}queue(e){let t=this.run;if(this.probe||!gr(e)||!(e.grid instanceof Vt)){this.flush(),this.Ia(e);return}let s=t[0];s&&(s.program!==e.program||s.grid!==e.grid||t.length>=64||!Er(s,e)||!pr(s,e))&&this.flush();let i=this.picture(e),r=this.batches.unit(i);r<0&&(this.flush(),r=this.batches.unit(i)),this.batches.write(t.length,e,i,r),t.push(e)}flush(){let e=this.run,[t]=e;if(!t)return;let s=e.length>1?this.host.gpu.programs.batch(t):null;if(s)this.Qf(s,e);else for(let t of e)this.Ia(t);e.length=0,this.batches.pictures.length=0}Qf(e,t){let s=this.host.gpu.gl,[i]=t;if(!(i?.grid instanceof Vt))return;this.scissor(i.clips?.ia?i.clips.scissorPx:null),this.program!==e.program&&(this.program=e.program,s.useProgram(e.program)),e.set("uViewport",this.Mc),e.set("uSurface",this.surface),e.set("uCanvas",this.Ha),e.set("uUmberHdr",this.Aa),e.set("uTime",this.host.env.frame.time),e.set("uScrollVelocity",this.host.env.frame.velocity),e.set("uDpr",this.host.canvasHost.dpr*this.adaptive.scale),e.set("uUmberClipPolyInfo",_r);let r=this.batches.pictures;for(let e=0;e<8;e++)this.Vc(r[e]??this.blank,e);e.set("uUmberImages",kr),this.Uc(e,i,8),this.batches.draw(i.grid,t.length),this.draws++}Rg(e){let t=e.modules.frames;if(t)t.pick(e)&&Oe(e);else if(e.kind==="video"){if(!this.host.chunks.video?.upload(e))return!1;this.bound[this.unit]=void 0}return!0}Hd(e){let t=this.host,s=e.program;return!s||!e.grid?!1:s.ready()?!0:(s.failed?t.gpu.programs.failed(e,t.planes.all):t.scheduler.oa(1),!1)}Uf(e,t,s){let i=this.host.chunks.layers;return!e.layer?.ready||!i?!1:(s?.(e),i.render(e,t),this.reset(),this.host.chunks.fx?.bind(),this.draws++,!0)}reset(){this.program=null,this.unit=-1,this.bound.length=0,this.fixed=!1,this.ia=-1,this.view[0]=-1}scissor(e){let t=this.host.gpu.gl,s=e?1:0;this.ia!==s&&(e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST));let i=this.Bh;e&&(this.ia!==s||i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]||i[3]!==e[3])&&(t.scissor(e[0],e[1],e[2],e[3]),i.set(e)),this.ia=s}bind(e,t,s,i){this.Vc(s,i),e.set(t,i)}Vc(e,t){let s=this.host.gpu.gl;this.bound[t]!==e.texture&&(this.unit!==t&&(this.unit=t,s.activeTexture(s.TEXTURE0+t)),this.bound[t]=e.texture,s.bindTexture(s.TEXTURE_2D,e.texture))}Ia(e,t=!1){let s=this.host,i=s.gpu.gl,r=e.program,n=e.grid;if(!r||!n)return;(e._k||e.kind==="text")&&!this.va&&s.chunks.text&&(this.va=s.chunks.text.blank(i),this.bound[this.unit]=void 0);let a=t?null:e.clips;this.scissor(a?.ia?a.scissorPx:null),this.program!==r.program&&(this.program=r.program,i.useProgram(r.program)),this.Fh(r,e,a);let l=this.picture(e);this.bind(r,"uImage",l,0),l instanceof Yt&&l.angle(e.level===2?this.ua:1);let o=this.imageSize;o[0]=(l.box?.[2]??0)||l.width,o[1]=(l.box?.[3]??0)||l.height,r.set("uImageSize",o),this.uf(r,e,l),n.draw(),this.draws++}Fh(e,t,s){let i=this.host;e.set("uViewport",this.Mc),e.set("uSurface",this.surface),e.set("uCanvas",this.Ha),e.set("uUmberHdr",this.Aa),e.set("uRect",t.level&&!t.xfReason?t._v:t.rect),e.set("uSize",t.size),e.set("uBleed",t.bleed),e.set("uPlaneMatrix",t._c),e.set("uTime",i.env.frame.time),e.set("uScrollVelocity",i.env.frame.velocity),e.set("uMouse",t.mouse),e.set("uProgress",t.progress),e.set("uAlpha",t.opacity),e.set("uRadius",t.radius),e.set("uRadiusKy",t._b),e.set("uUmberClips",s?s.count:0),s?.count&&(e.set("uUmberClipXf",s.xf),e.set("uUmberClipBox",s.box),e.set("uUmberClipRadius",s.radius),e.set("uUmberClipPoly",s.poly),e.set("uUmberClipPolyInfo",s.polyInfo)),e.set("uDpr",i.canvasHost.dpr*this.adaptive.scale),e.set("uFit",t.fit),e.set("uFitPosition",t._g)}picture(e){return e.texture?.ready?e.texture:e.prev?.ready?e.prev:this.blank}uf(e,t,s){let i=this.Uc(e,t,1);t._k&&(i=this.pf(e,t,i)),t.kind==="text"&&(i=this.tf(e,t,i));let r=t.modules.frames;if(r){let t=r.next;this.bind(e,"uFrameNext",t??s,i),e.set("uFrameMix",t?r.mix:0)}}Uc(e,t,s){for(let i in t.uniforms){let r=t.uniforms[i];if(!r)continue;let n=r.value;xr(n)?e.uniforms.has(i)&&this.bind(e,i,n,s++):e.set(i,typeof n=="boolean"?Number(n):n)}return s}pf(e,t,s){let i=this.va;if(!i)return s;let r=t.raster,n=r?.Ka?.ready?r.Ka:null,a=r?.ma?.ready?r.ma:null;return this.bind(e,"uGlyphIndex",n&&a?n:i.index,s),this.bind(e,"uGlyphData",n&&a?a:i.data,s+1),s+2}tf(e,t,s){let i=this.va;if(!i||!e.uniforms.has("uUmberTextLayout"))return s;let r=this.host.chunks.text,n=r?.samplers(t);this.bind(e,"uUmberTextLayout",n?.layout??i.data,s),this.bind(e,"uUmberTextColor",n?.color.texture?n.color:this.blank,s+1);let a=r?.curveTables;return a&&(this.bind(e,"uUmberCurves",a.curves,s+2),this.bind(e,"uUmberBands",a.bands,s+3),this.bind(e,"uUmberGlyphs",a.glyphs,s+4)),s+5}je(e){let t=this.host;if(t.env.options.adaptive===!1||t.chunks.za)return!1;let s=t.env.host.clock.held||t.scheduler.Na(performance.now())||t.gpu.media.uploads.length>0;return this.adaptive.frame(e,s,this.timer.ms,this.timer.supported)?(t.env.stats.scale=this.adaptive.scale,i.info(`GL render scale ${this.adaptive.scale}`),!0):!1}lost(){this.va=null,this.batches.lost(),this.run.length=0}restored(){this.reset(),this.blank=new Yt(this.host.gpu.gl),this.timer=new Wt(this.host.gpu.gl),this.ua=Qt(this.host.gpu.gl),this.adaptive.reset()}dispose(){this.timer.dispose(),this.blank.dispose(),this.batches.dispose(),this.va?.index.dispose(),this.va?.data.dispose()}};var Ar=class{constructor(e,t,s,i){this.canvas=t;this.gl=s;this.tier=i;this.context=new k;this.programs=new wr(s,e.env.lib,e.env.registry.chunks,()=>e.planes.all),this.renderer=new Sr(e,s),this.media=new Ki(e),this.subsystems=[this.programs,this.renderer]}};function Rr(e,t,s){switch(e){case"failed":case"failed-lost":return"off (error)";case"given-up":return"off (context lost)";case"live":case"lost":break}return t.has("host")?"off (canvas host)":t.size?"paused":s}function Tr(e,t){return{get state(){return e()},backend:"webgl2",tier:t.tier,gpu:t,fps:0,frameMs:0,renders:0,skipped:0,rendersPerSec:0,draws:0,planes:0,visible:0,textures:0,textureMB:0,gpuMB:0,uploads:0,programs:0,busy:[],dpr:1,scale:1,width:0,height:0}}var zr=class{constructor(e,{canvas:t,gl:s,hostEl:r,hostOwnership:a}){this.scheduler=new g(this,{showDom:()=>{S(this)},invalidate:()=>{this.factory.invalidate()}});this.planes=new Pi(this,{create:e=>{this.factory.create(e)},destroy:e=>{this.factory.Pf(e)}});this.xd=!1;this.chunks=new K(this);this.transitions=new Ws(this);this.fallbacks=new Ue(this);this.$h=new li(this,this.transitions,{stepTweens:e=>this.scheduler.tweening=this.env.tweens.step(e),dirty:()=>this.scheduler.dirty,Vd:()=>this.batches.Vd()});this.Kd=new Js(this,{drawn:()=>{this.scheduler.dirty=!1},resize:()=>{this.canvasHost.Ib()},mc:e=>{this.scheduler.mc(e)}});this.measure=e=>{if(!this.scheduler.inactive)try{this.measurePhase.run(e)}catch(e){M(this,"measure",e)}};this.update=e=>{if(!this.scheduler.inactive)try{this.xd=this.$h.run(e)}catch(e){M(this,"update",e)}};this.render=e=>{if(!this.scheduler.inactive)try{this.Kd.run(e,this.xd)}catch(e){M(this,"render",e)}};let l=m(e,s),o=Tr(()=>Rr(this.gpu.context.state,this.scheduler.pauses,this.scheduler.pb),l);this.env=new Ii(e,Ui(e.lib.say),o,()=>{this.scheduler.markDirty()}),this.gpu=new Ar(this,t,s,l),i.info("GL tier",l),this.canvasHost=new zi(this,r,a,{wd:(e,t)=>{this.observers.wd(e,t)}});let h=()=>{this.canvasHost.Ib()};this.observers=new _t(this,h),this.factory=new Ks(this,this.chunks,this.transitions,this.observers),this.measurePhase=new yt(this,this.observers,{resize:()=>{this.canvasHost.uh()}}),this.batches=new yi(this,{Xb:e=>{this.scheduler.Xb(e)}}),Et(this,{resized:h,following:()=>this.factory.following}),this.measurePhase.og(),this.canvasHost.check(),this.env.options.busy&&this.transitions.pi(this.env.options.busy),this.env.cleanups.push(e.ticker.add(this.measure,{phase:"measure",label:"umber"})),this.env.cleanups.push(e.ticker.add(this.update,{phase:"update",label:"umber"})),this.env.cleanups.push(e.ticker.add(this.render,{phase:"render",label:"umber"}));let u=n();u&&this.chunks.load({load:e.loadCapture,file:"capture",dom:"frames wait for nothing.",made:e=>this.chunks.za=e.capture(this,u)})}info(){let e=0,t=0;for(let s of this.planes.all)s.texture?.refs||(e+=s.texture?.bytes??0,s.texture?.ready&&t++);return e+=this.gpu.media.jd,this.env.stats.planes=this.planes.all.length,this.env.stats.rendersPerSec=this.Kd.Dd(performance.now()),this.env.stats.textures=t+this.gpu.media.yf,this.env.stats.textureMB=Math.round(e/2**20),e+=(this.chunks.fx?.pool.bytes??0)+(this.chunks.video?.ac()??0)+this.gpu.canvas.width*this.gpu.canvas.height*4,this.env.stats.gpuMB=Math.round(e/2**20),this.env.stats}destroy(){let e=this.env,t=this.gpu;e.destroyed||(this.chunks.morph?.cancel(),this.planes.clear(),this.chunks.mb.clear(),this.chunks.La.clear(),this.chunks.ob.clear(),e.destroyed=!0,e.tweens.clear(),this.observers.disconnect(),e.cleanups.forEach(e=>{e()}),e.cleanups=[],t.context.gone||(t.renderer.dispose(),this.chunks.layers?.fade.dispose(),t.media.dispose(),this.chunks.views?.dispose(),p(t.gl)),t.programs.dispose(!t.context.gone),t.canvas.remove())}};function Ur(e){r(e.log);let{lib:t}=e,{el:s,created:n}=Nr(e.options,t),a=document.createElement("canvas");a.setAttribute("aria-hidden","true"),a.setAttribute("data-umber-canvas",""),a.setAttribute("data-engine",`umber ${Fr(e.engine)}`);let l=Lr(a);if(!l)return t.say("webgl2",[]),n&&s.remove(),null;if(Cr(e,l))return l.getExtension("WEBGL_lose_context")?.loseContext(),n&&s.remove(),e.off("software"),null;s.appendChild(a);let o=new zr(e,{canvas:a,gl:l,hostEl:s,hostOwnership:n?"created":"site"});return i.info("GL mounted",{tier:o.gpu.tier.tier}),Pr(o,()=>{n&&s.remove()})}function Pr(e,t){return{apply:t=>{e.batches.apply(t)},scan:t=>{e.batches.scan(t)},prune:()=>{e.planes.prune()},remove:t=>{e.planes.ph(t)},invalidate:t=>{e.factory.invalidate(t)},live:t=>{e.scheduler.live(t)},wake:t=>{e.scheduler.wake(t)},keep:()=>e.canvasHost.keep(),begin:(t,{again:s=!1}={})=>{s||e.transitions.begin(),e.transitions.capture(t,s)},end:()=>e.transitions.end(),pause:()=>{e.scheduler.hold("user")},resume:()=>{e.scheduler.release("user")},plane:t=>e.planes.of(t),stage:e,planes:t=>e.planes.list(t),defined:(t,s)=>{e.planes.defined(t,s)},redefined:(t,s)=>{e.planes.redefined(t,s)},morph:{capture:t=>{e.transitions.capture(t)},settle:()=>{e.transitions.settle()}},renderer:(t,s)=>e.chunks.loadLayers().then(e=>e?e.create(t,s):null),view:t=>e.chunks.loadLayers().then(e=>e&&!t.destroyed?e.view(t):null),fx:(t,s)=>Ir(e)[t](s),flip:(t,s,i)=>e.transitions.flip(t,s,i),get info(){return e.info()},destroy(){e.destroy(),t()},get gl(){return e.gpu.context.gone?null:e.gpu.gl},get canvas(){return e.gpu.canvas}}}function Cr(e,t){return!(!!e.options.software||"occluzeCapture"in window||[document.documentElement,e.lib.bodyOrNull()].some(e=>e?.hasAttribute("data-umber-software")))&&!e.gpu&&!f(c(t))[0]}function Fr(e){return typeof e!="object"||e===null||!("version"in e)?"":typeof e.version=="string"?e.version:""}function Lr(e){try{return e.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!0,depth:!0,stencil:!0,powerPreference:"high-performance",preserveDrawingBuffer:!1})}catch{return null}}function Ir(e){return{target:t=>e.chunks.loadFx().then(e=>e?e.target(t):null),snapshot:t=>e.chunks.loadFx().then(e=>e?e.snapshot(t):null),setLeave:t=>e.chunks.loadFx().then(e=>(e?.setLeave(t),null)),sim:t=>e.chunks.loadFx().then(e=>e?e.sim(t):null),flow:t=>e.chunks.loadFx().then(e=>e?e.flow(t):null),preload:t=>e.chunks.loadWarm().then(e=>e?e.preload(t):null),warm:t=>e.chunks.loadWarm().then(e=>e?e.warm(t):null),placeholder:t=>e.chunks.loadWarm().then(e=>e?e.placeholder(t):null)}}function Nr(e,t){if(e.host instanceof HTMLElement)return{el:e.host,created:!1};let s=document.querySelector(typeof e.host=="string"?e.host:"[data-umber-host]");if(s)return{el:s,created:!1};typeof e.host=="string"&&t.say("hostless",[e.host]);let i=document.createElement("div");i.setAttribute("data-umber-host",""),i.style.zIndex=String(e.zIndex??(e.layer==="under"?-1:1));let r=t.bodyOrNull();return r?r.prepend(i):document.documentElement.appendChild(i),{el:i,created:!0}}export{Ur as mount};
|
|
1
|
+
/*! Umber v0.4.0 | (c) Ravi Klaassens | UNLICENSED */
|
|
2
|
+
var e=()=>{};var t=()=>Promise.reject(new Error("no words"));var s={configure:e,debug:!1,warnings:!1,info:e,warn:e,error:e,report:e,words:t},i=s;function r(e){i=e}var n=()=>{let e=typeof window<"u"?window.occluzeCapture:void 0;return e?.version===1?e:null},a=()=>new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(0)});var l=/(swiftshader|llvmpipe|software|basic render)|mali-4|mali-t|adreno \(tm\) [2-5]|powervr|intel\(r\) hd graphics [2-5]/i,o=[1400,1600];function h(e){return e<2?"low":e<4?"mid":"high"}var u=e=>typeof e=="string"?e:"";function d(e){let t=/^(m?)([0-5])$|^(low|mid|high)$/.exec(e.trim().toLowerCase());if(!t)return null;let[,s,i="",r]=t;return r?{level:"lmh".indexOf(r.charAt(0))*2+1,mobile:!1}:{level:+i,mobile:!!s}}function c(e){let t=u(e.getParameter(e.RENDERER));if(!t||/^(webkit webgl|mozilla|webgl)$/i.test(t.trim())){let s=e.getExtension("WEBGL_debug_renderer_info");s&&(t=u(e.getParameter(s.UNMASKED_RENDERER_WEBGL))||t)}return t}function f(e){let t=l.exec(e);return t?[t[1]?0:1,`rule: ${t[0]}`]:[2,"default"]}function m(e,t){let s=c(t),i=e.env.isTouch&&Math.min(screen.width,screen.height)<820,r,n="url",a=e.gpu?d(e.gpu):null;if(e.gpu&&!a&&e.lib.say("gpu",[e.gpu]),a)({level:r,mobile:i}=a);else{let[e,t]=f(s);r=e<2?e:e+(i?0:2),n=t}let l=r>3;return{level:r,tier:h(r),mobile:i,renderer:s,reason:n,maxTexture:Math.min(t.getParameter(t.MAX_TEXTURE_SIZE),l?4096:2048),textureBudget:(l?192:96)*2**20,wide:(i?void 0:o[r])??1/0}}function p(e){if(!(!e||typeof navigator<"u"&&/apple/i.test(navigator.vendor||"")))try{e.isContextLost()||e.getExtension("WEBGL_lose_context")?.loseContext()}catch{}}var g=class{constructor(e,t){this.stage=e;this.own=t;this.dirty=!0;this.de=!1;this.Ra="dormant";this.changing=0;this.onRequest=new Set;this.Zd=2;this.Hd=0;this.fl=!1;this.Fe=0;this.holds=new Set}markDirty(){this.dirty=!0,this.Fe=0,this.request()}request(){!this.inactive&&!document.hidden&&this.stage.env.host.ticker.wake(1);for(let e of this.onRequest)e()}wake(e=1){this.uc(e),this.markDirty()}get forced(){return this.Zd}uc(e){this.Zd=Math.max(this.Zd,e)}$d(){this.Zd>0&&this.Zd--}live(e){typeof e=="number"?(this.fl=!1,this.Hd=Math.max(this.Hd,performance.now()+e*1e3)):(this.fl=e,e||(this.Hd=0)),this.markDirty()}Xd(e){this.Hd=Math.max(this.Hd,performance.now()+e*1e3),this.markDirty()}Ug(e){return this.fl||this.changing>0||e<this.Hd}hold(e){this.holds.has(e)||(this.holds.add(e),!(this.holds.size>1)&&(this.stage.chunks.morph?.cancel(),this.own.showDom(),this.stage.env.lib.showFullImages()))}release(e){if(!(!this.holds.delete(e)||this.holds.size)){for(let e of this.stage.planes.all)e.status!=="error"&&e.setStatus("loading"),e._N();this.own.invalidate(),this.wake(2)}}get paused(){return this.holds.size>0}get pauses(){return this.holds}get inactive(){return this.paused||this.stage.gpu.context.state!=="live"||this.stage.env.destroyed}ic(e){let t=performance.now(),s=this.stage.planes.all;e?this.Fe=0:this.Fe++;let i=()=>s.some(e=>e.zone.screen);e||this.forced>0||this.stage.gpu.media.uploads.length>0||this.de||this.stage.chunks.morph?.busy===!0||this.Ug(t)||s.some(e=>e.visible&&e.status==="loading"&&(e.zone.near||e.zone.soon)&&!e.raster?.empty)||s.some(e=>t<e.animUntil&&(e.animUntil===1/0?e.zone.screen:e.zone.soon))||this.stage.chunks.ul||this.stage.env.frame.scrolled&&s.some(e=>e.live&&(e.zone.soon||e.visible))||this.Fe<60&&i()?this.request():(this.Ra=i()?"asleep":"dormant",this.stage.env.stats.busy=[])}};var v=8,b=6e4,y=2,w=2e3,x=6e4,k=class{constructor(){this.state="live";this.losses=0;this.recent=[]}lose(e=performance.now()){this.losses++,this.recent=this.recent.filter(t=>e-t<b),this.recent.push(e)}Yg(){let e=this.recent.length-y;return e>0?Math.min(x,w*2**(e-1)):0}get gone(){return this.state==="lost"||this.state==="failed-lost"||this.state==="given-up"}get off(){return this.state==="failed"||this.state==="failed-lost"||this.state==="given-up"}};function _(e,t){let s=e.gpu.context;s.lose(),s.losses<=v?(t.preventDefault(),s.state=s.off?"failed-lost":"lost"):(e.env.lib.say("losses",[s.losses]),s.state="given-up",document.documentElement.classList.remove("has-umber")),E(e),s.off&&e.env.host.off("context-lost")}function E(e){e.chunks.morph?.cancel();for(let t of e.planes.all){t.setStatus(null),t.status==="loading"&&t.wait(),t.el.removeAttribute("data-umber-morphing"),t.textureState!=="error"&&(t._E?.(),t._E=null,t.textureState="none"),t.texture=null,t.prev=null,t.program=null,t.grid=null;for(let e of t.parts())e?.lost?.()}for(let t of e.gpu.subsystems)t.lost?.();e.chunks.layers?.fade.forget(),e.gpu.media.Zk(),e.chunks.views?.lost(),e.env.host.emit("lost"),e.gpu.context.state==="lost"&&e.env.lib.say("lost",[])}function S(e,t,s){if(!e.gpu.context.off){e.env.lib.tell("failed",[t],i.error),e.gpu.context.state=e.gpu.context.gone?"failed-lost":"failed";try{e.chunks.morph?.cancel()}catch{}M(e),document.documentElement.classList.remove("has-umber"),e.env.host.off("error",s)}}function M(e){for(let t of e.planes.all)t.status!=="error"&&(t.setStatus(null),t.wait()),t.el.removeAttribute("data-umber-morphing");if(!e.gpu.context.gone)try{e.gpu.gl.clearColor(0,0,0,0),e.gpu.gl.clear(e.gpu.gl.COLOR_BUFFER_BIT)}catch{}}var z=/\b(?:(?:quad|cubic|quart|quint|sine|expo|circ)(?:In|Out|B)|stagger|[sp]noise|cellular|sd[A-Z]|op[A-Z]|aa|blend[A-Z]|bayer|blueNoise|dither|srgbTo|linearTo|oklabTo|mixOklab|noise|fbm|rotate2d|screen[UP]|samplePrev|flowSmooth|textureSmooth|umber[A-Z])\w*\s*\(|\buScreen\b/;var T=/\bu(Prev|Swap)\b/,A=/\bglyph\s*\(/;var R=`#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nlayout(location=0)in vec2 aPosition;\nuniform vec2 uViewport;\nuniform vec4 uSurface;\nuniform vec4 uRect;\nuniform vec2 uSize;\nuniform mat3 uPlaneMatrix;\nuniform float uTime;\nuniform float uScrollVelocity;\nuniform vec2 uMouse;\nuniform float uProgress;\nuniform vec4 uBleed;\nout vec2 vUv;\n#define PI 3.141592653589793\n/*__VERTEX_HEAD__*/\nvoid main(){\nvec2 uv=(aPosition*(uSize+uBleed.wx+uBleed.yz)-uBleed.wx)/uSize;\nvUv=uv;\nvec3 pos=vec3(0.0);\n/*__VERTEX_MAIN__*/\nvec3 h=uPlaneMatrix*vec3(uv*uSize+pos.xy,1.0);\nh.xy-=uSurface.xy*h.z;\ngl_Position=vec4(h.x/uSurface.z*2.0-h.z,h.z-h.y/uSurface.w*2.0,pos.z*0.0001*h.z,h.z);\n}\n`,P=`#version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n#define UMBER_FRAGMENT\nin vec2 vUv;\nout vec4 outColor;\nuniform vec2 uViewport;\nuniform vec4 uSurface;\nuniform vec4 uRect;\nuniform vec2 uSize;\nuniform float uTime;\nuniform float uScrollVelocity;\nuniform vec2 uMouse;\nuniform float uProgress;\nuniform float uAlpha;\nuniform vec4 uRadius;\nuniform float uRadiusKy;\nuniform float uDpr;\nuniform vec2 uCanvas;\nuniform float uUmberHdr;\nuniform int uUmberClips;\nuniform mat3 uUmberClipXf[2];\nuniform vec4 uUmberClipBox[2];\nuniform vec4 uUmberClipRadius[2];\nuniform vec4 uUmberClipPoly[4];\nuniform vec2 uUmberClipPolyInfo;\nuniform sampler2D uImage;\nuniform vec2 uImageSize;\nuniform float uFit;\nuniform vec2 uFitPosition;\n#define PI 3.141592653589793\nvec2 fitUv(vec2 uv){\nif(uFit>2.5)return(uv*uSize-uFitPosition)/uImageSize;\nif(uFit>1.5)return uv;\nvec2 ratio=uSize/max(uImageSize,vec2(1.0));\nfloat s=uFit<0.5?max(ratio.x,ratio.y):min(ratio.x,ratio.y);\nvec2 scaled=uImageSize*s;\nvec2 offset=(uSize-scaled)*uFitPosition;\nreturn(uv*uSize-offset)/scaled;\n}\nvec4 sampleImage(vec2 uv){\nvec2 f=fitUv(uv);\nvec4 c=texture(uImage,f);\nif(uFit>0.5&&uFit<1.5&&(f.x<0.0||f.y<0.0||f.x>1.0||f.y>1.0))c=vec4(0.0);\nc.rgb/=max(c.a,1e-5);\nreturn c;\n}\nfloat roundedBox(vec2 p,vec2 size,vec4 r){\nvec4 s=max(r+r.yzwx,1e-5);\nr*=min(1.0,min(min(size.x/s.x,size.y/s.y),min(size.x/s.z,size.y/s.w)));\nvec2 h=size*0.5;\nvec2 d=abs(p-h)-h;\nfloat o=length(max(d,0.0))+min(max(d.x,d.y),0.0);\nvec2 q=p;\nif(max(q.x,q.y)<r.x)o=max(o,length(q-r.x)-r.x);\nq=vec2(size.x-p.x,p.y);\nif(max(q.x,q.y)<r.y)o=max(o,length(q-r.y)-r.y);\nq=size-p;\nif(max(q.x,q.y)<r.z)o=max(o,length(q-r.z)-r.z);\nq=vec2(p.x,size.y-p.y);\nif(max(q.x,q.y)<r.w)o=max(o,length(q-r.w)-r.w);\nreturn o;\n}\nvec2 umberClipPoint(int i){\nvec4 v=uUmberClipPoly[i/2];\nreturn(i-(i/2)*2)==0?v.xy:v.zw;\n}\nfloat umberPolygon(vec2 p){\nint n=int(uUmberClipPolyInfo.y+0.5);\nfloat d=1e20;\nfloat s=1.0;\nfor(int i=0;i<8;i++){\nif(i>=n)break;\nvec2 a=umberClipPoint(i);\nvec2 b=umberClipPoint(i==0?n-1:i-1);\nvec2 e=b-a;\nvec2 w=p-a;\nvec2 q=w-e*clamp(dot(w,e)/max(dot(e,e),1e-8),0.0,1.0);\nd=min(d,dot(q,q));\nbvec3 c=bvec3(p.y>=a.y,p.y<b.y,e.x*w.y>e.y*w.x);\nif(all(c)||all(not(c)))s= -s;\n}\nreturn s*sqrt(d);\n}\nfloat umberClip(){\nfloat cover=1.0;\nfor(int i=0;i<2;i++){\nif(i>=uUmberClips)break;\nvec3 q=uUmberClipXf[i]*vec3(gl_FragCoord.xy,1.0);\nvec2 p=q.xy/q.z;\nfloat d=float(i)==uUmberClipPolyInfo.x\n?umberPolygon(p)\n:roundedBox(p-uUmberClipBox[i].xy,uUmberClipBox[i].zw,uUmberClipRadius[i]);\nfloat k=clamp(0.5-d/max(length(vec2(dFdx(d),dFdy(d))),1e-4),0.0,1.0);\ncover*=q.z<0.0?1.0-k:k;\n}\nreturn cover;\n}\n/*__FRAGMENT_HEAD__*/\nvoid main(){\nvec2 uv=vUv;\n/*__FRAGMENT_UV__*/\nvec4 color= /*__FRAGMENT_SOURCE__*/;\n/*__FRAGMENT_COLOR__*/\nfloat alpha=uAlpha;\nvec2 umberK=vec2(1.0,uRadiusKy>0.0?uRadiusKy:1.0);\nfloat umberD=roundedBox(vUv*uSize*umberK,uSize*umberK,uRadius);\nfloat umberW=max(length(vec2(dFdx(umberD),dFdy(umberD))),1e-4);\nif(uRadius.x+uRadius.y+uRadius.z+uRadius.w>0.0)alpha*=clamp(0.5-umberD/umberW,0.0,1.0);\n/*__FRAGMENT_ALPHA__*/\nif(uUmberClips>0)alpha*=umberClip();\nfloat a=clamp(color.a*alpha,0.0,1.0);\noutColor=vec4((uUmberHdr>0.5?max(color.rgb,0.0):clamp(color.rgb,0.0,1.0))*a,a);\n}\n`,C={};function U(e,t=C){let s=new Map,i=r=>{let n=t[r];if(!(!n||s.has(r)||n.defined.test(e))){for(let e of n.needs??[])i(e);s.set(r,n)}};for(let[s,r]of Object.entries(t))r.used.test(e)&&i(s);return[...s.values()].map(e=>e.code).join(`\n\n`)}var F="#define PI 3.141592653589793";function L(e,t,s){return e.map(({name:e,def:i})=>{let r=t(i);return r?`// ${s}: ${e}\n {\n${H(r)}\n }`:""}).filter(Boolean).join(`\n\n `)}function N(e,t){return e.map(({name:e,def:s})=>{let i=t(s);return i?`// ${e}\n${i}`:""}).filter(Boolean).join(`\n\n`)}function I(e){let{effects:t,shader:s,uniforms:i,chunks:r={vertex:"",fragment:""}}=e,n=[...t.map(({def:e})=>`${e.vertex?.head??""}\n${e.fragment?.head??""}`),s?.def.head??"",r.vertex+r.fragment].join(`\n`),a=G(i,n),l=e=>e.replace(F,`${F}\n\n${a}`);return{vertex:l(j(t,r)),fragment:l(B(e,r))}}function j(e,t){let s=e.map(({def:e})=>`${e.vertex?.head??""}\n${e.vertex?.main??""}`).join(`\n`)+t.vertex,i=U(s);return R.replace("/*__VERTEX_HEAD__*/",[i?`// helpers\n${i}`:"",t.vertex,N(e,e=>e.vertex?.head)].filter(Boolean).join(`\n\n`)).replace("/*__VERTEX_MAIN__*/",L(e,e=>e.vertex?.main,"vertex"))}function D(e){return`// shader: ${e.name}\n${e.def.head??""}\nvec4 umberSurface(vec2 uv) {\n vec4 color = vec4(0.0);\n {\n${H(e.def.fragment)}\n }\n return color;\n}`}function $(e,t){return e!=="text"?P:P.replace(/vec4 sampleImage\(vec2 uv\) ?\{/,e=>`${A.test(t)?`#define UMBER_TEXT_FLAT\n`:""}vec4 umberText(vec2 f);\n${e}`).replace(/texture\(uImage, ?f\)/,"umberText(f)")}function B({kind:e,effects:t,shader:s},i){let r=e==="shader"&&s?s:null,n=[...t.map(({def:e})=>Object.values(e.fragment??{}).join(`\n`)),s?`${s.def.head??""}\n${s.def.fragment}`:"",i.fragment,e==="text"?"umberText()":""].join(`\n`),a=U(n),l=/\bsampleRaw\s*\(/.test(n)&&!/vec4\s+sampleRaw\s*\(/.test(n)?"vec4 sampleRaw(vec2 uv) { vec4 c = sampleImage(uv); return vec4(c.rgb * c.a, c.a); }":"";return $(e,n).replace("/*__FRAGMENT_HEAD__*/",[a?`// helpers\n${a}`:"",l,i.fragment,r?D(r):"",N(t,e=>e.fragment?.head)].filter(Boolean).join(`\n\n`)).replace("/*__FRAGMENT_UV__*/",L(t,e=>e.fragment?.uv,"uv")).replace("/*__FRAGMENT_SOURCE__*/",r?"umberSurface(uv)":"sampleImage(uv)").replace("/*__FRAGMENT_COLOR__*/",L(t,e=>e.fragment?.color,"color")).replace("/*__FRAGMENT_ALPHA__*/",L(t,e=>e.fragment?.alpha,"alpha"))}function H(e){return e.trim().split(`\n`).map(e=>` ${e}`).join(`\n`)}var O=new Set(["uViewport","uSurface","uRect","uSize","uTime","uScrollVelocity","uMouse","uProgress","uAlpha","uRadius","uRadiusKy","uDpr","uImage","uImageSize","uFit","uFitPosition","uGlyphIndex","uGlyphData","uUmberTextLayout","uUmberTextColor","uUmberCurves","uUmberBands","uUmberGlyphs","uPlaneMatrix","uCanvas","uBleed","uUmberClips","uUmberClipXf","uUmberClipBox","uUmberClipRadius","uUmberClipPoly","uUmberClipPolyInfo","uUmberHdr"]);function W(e){if(typeof e=="number"||typeof e=="boolean")return"float";if(Array.isArray(e)||ArrayBuffer.isView(e)){let t=e.length;return t===2?"vec2":t===3?"vec3":t===4?"vec4":t===9?"mat3":t===16?"mat4":null}return typeof e=="string"?"sampler2D":e&&typeof e=="object"?"highp sampler2D":null}function q(e,t){let s=e=>e.charAt(0).toUpperCase()+e.slice(1),i=e=>e.split(/[-_\s]+/).map(s).join("");return`u${i(e)}${i(t)}`}var V=/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g;function X(e){let t=e.replace(/\\n/g,`\n`).replace(V," ");return e=>new RegExp(`\\buniform\\b[^;]*\\b${e}\\b`).test(t)}function G(e,t){let s=[],i=X(t);for(let t in e){if(O.has(t)||i(t))continue;let r=W(e[t]);r&&s.push(`uniform ${r} ${t};`)}return s.join(`\n`)}var K=5e3,Y=class{constructor(e){this.start=e;this.pending=null}get(){return this.pending??=this.start()}get asked(){return this.pending}forget(){this.pending=null}},Z=class{constructor(e){this.stage=e;this.text=null;this.gh=new Set;this.ae=new Set;this.shapes=null;this.shapesError=null;this.ul=!1;this.layers=null;this.views=null;this.video=null;this.Ml=new Set;this.morph=null;this.fx=null;this.flow=null;this.warm=null;this.instances=null;this.vl=null;this.flip=null;this.gone=new Map;this.ng=new Set;this.Pi=new Y(()=>this.load({load:this.stage.env.host.loadText,file:"text",made:(e,t)=>(C.umberText=e.TEXT_HELPER,e.textPlanes(this.stage,t),!0),failed:()=>{this.Vc()}}).then(e=>{e||(this.gone.delete("text"),this.Pi.forget())}));this.ye=new Y(()=>this.load({load:this.stage.env.host.loadLayers,file:"layers",made:e=>e.layers(this.stage),failed:()=>{for(let e of this.stage.planes.all)e.kind==="layer"&&!e.layer&&e.setStatus("error")}}));this.jk=new Y(()=>this.load({load:this.stage.env.host.loadVideo,file:"video",made:e=>{e.video(this.stage)},failed:()=>{this.Jl(this.Ml,{failed:!0})}}));this.X=new Y(()=>this.load({load:this.stage.env.host.loadGlsl,file:"glsl",made:e=>{this.stage.gpu.programs.glsl=e.glsl(this.stage),Object.assign(C,e.GLSL_HELPERS),this.stage.planes.defined("chunk","")},failed:()=>{for(let e of this.stage.planes.all)e.missing.includes("chunk:")&&e.setStatus("error")}}));this.nj=new Y(()=>this.load({load:this.stage.env.host.loadInstances,file:"instances",made:e=>{this.instances=e.instances(this.stage),this.Jl(this.ng)},failed:()=>{this.Jl(this.ng,{failed:!0})}}));this.ig=new Y(()=>this.load({load:this.stage.env.host.loadFlip,file:"flip",made:e=>this.flip=e.flip(this.stage)}));this.Hl=new Y(()=>this.load({load:this.stage.env.host.loadFx,file:"fx",made:(e,t)=>e.fx(this.stage,C,t),failed:()=>{for(let e of this.stage.planes.all)e.backdrop&&e.setStatus("error")}}));this.Ve=new Y(()=>this.load({load:this.stage.env.host.loadWarm,file:"warm",made:e=>this.warm=e.warm(this.stage)}));this.Sl=new Y(()=>this.load({load:this.stage.env.host.loadMorph,file:"morph",made:e=>e.morph(this.stage)}));this.ra=new Y(()=>this.load({load:this.stage.env.host.loadShapes,file:"shapes",made:e=>{this.ul=!1,e.shapes(this.stage)},failed:e=>{this.W(e??"")}}))}load({load:e,file:t,made:s,failed:r,wait:n=(r?K:0)}){let a=!1,l=(e,s)=>(this.stage.env.destroyed||a||(a=!0,this.stage.env.lib.tell("chunkGone",[e,t],i.error,...s===void 0?[]:[s]),this.gone.set(t,r),r?.(e)),null),o=()=>l(`chunks/${t}.js took more than ${n/1e3} s to load`),h=e=>l(`chunks/${t}.js failed to load`,e);return n&&setTimeout(o,n),e?e().then(e=>(a=!0,this.stage.env.destroyed?null:s(e,this.gone.delete(t))),h):Promise.resolve().then(()=>l(`this build has no chunks/${t}.js`))}jb(e,t){C.glyph=e,this.stage.gpu.programs.lean=t,this.Jl(this.ae)}uh(e){this.gone.get(e)?.()}Jl(e,{failed:t=!1}={}){let s=[...e];t||e.clear();for(let i of s)i.destroyed?e.delete(i):t?i.setStatus("error"):i.el.isConnected&&this.stage.planes.pe(i)}loadText(){if(!this.text){if(this.Pi.asked){this.uh("text");return}this.Pi.get()}}loadLayers(){return this.ye.get()}loadVideo(){this.jk.get(),this.uh("video")}loadGlsl(){this.X.get()}loadInstances(e){this.ng.add(e),this.nj.get(),this.uh("instances")}loadFlip(){return this.ig.get()}loadFx(){return this.Hl.get()}loadWarm(){return this.Ve.get()}loadMorph(){return this.Sl.get()}get Xc(){return this.Sl.asked}loadShapes(){this.ra.get()}Vc(){this.gh.clear(),this.Jl(this.ae,{failed:!0});for(let e of this.stage.planes.all)e.kind==="text"&&(this.ae.delete(e),e.textureState="error",e.status!=="error"&&e.setStatus("error"))}W(e){this.shapesError=e,this.ul=!1;for(let e of this.stage.planes.all)e.shapeWait&&(e.stale=!0);this.stage.scheduler.markDirty()}};function J(e){return typeof e=="number"?new Float64Array(e):new Float64Array(e)}function Q(e){return typeof e=="number"?new Float32Array(e):new Float32Array(e)}function ee(e){return new Int32Array(e)}var te=(e,t)=>e[t]??NaN;var se=e=>parseFloat(e??"0")||0,ie=(e,t)=>e===void 0||e===""?t:e,re=e=>!!e&&e!=="none";function ne(e){try{return e.matches(":modal")||e.matches(":popover-open")}catch{return!1}}function ae(e,t){let s=t.get(e);if(s)return s;let i=getComputedStyle(e),r=[i.maskImage,i.getPropertyValue("-webkit-mask-image"),i.maskBorderSource,i.getPropertyValue("-webkit-mask-box-image-source")].some(re),n={el:e,tag:e.localName||e.tagName.toLowerCase(),display:i.display,position:ie(i.position,"static"),overflowX:ie(i.overflowX,"visible"),overflowY:ie(i.overflowY,"visible"),contain:ie(i.contain,"none"),contentVisibility:ie(i.contentVisibility,"visible"),willChange:ie(i.willChange,"auto"),filter:ie(i.filter,"none"),backdropFilter:ie(i.backdropFilter||i.webkitBackdropFilter,"none"),clipPath:ie(i.clipPath,"none"),clip:ie(i.getPropertyValue("clip"),"auto"),mask:r,transform:ie(i.transform,"none"),translate:ie(i.translate,"none"),rotate:ie(i.rotate,"none"),scale:ie(i.scale,"none"),perspective:ie(i.perspective,"none"),transformOrigin:ie(i.transformOrigin,""),perspectiveOrigin:ie(i.perspectiveOrigin,""),transformStyle:ie(i.transformStyle,"flat"),backfaceVisibility:ie(i.backfaceVisibility||i.getPropertyValue("-webkit-backface-visibility"),"visible"),offsetPath:ie(i.offsetPath,"none"),opacity:ie(i.opacity,"1"),isolation:ie(i.isolation,"auto"),mixBlendMode:ie(i.mixBlendMode,"normal"),zoom:ie(i.zoom,"1"),zIndex:i.zIndex,topLayer:ne(e)};return t.set(e,n),n}var le=new Float64Array(64);var oe=e=>(e.overflowY==="auto"||e.overflowY==="scroll")&&e.el.scrollHeight>e.el.clientHeight;function he(e){let t=e.width.endsWith("px")?se(e.width):NaN,s=e.height.endsWith("px")?se(e.height):NaN;return e.boxSizing!=="border-box"&&(t+=se(e.paddingLeft)+se(e.paddingRight)+se(e.borderLeftWidth)+se(e.borderRightWidth),s+=se(e.paddingTop)+se(e.paddingBottom)+se(e.borderTopWidth)+se(e.borderBottomWidth)),[t,s]}function ue(e){return e.assignedSlot??e.parentElement??e.parentNode?.host??null}function de(e,t){let s=[],i=e;for(;i;){let e=ae(i,t);if(s.push(e),e.tag==="html"||e.topLayer)break;i=ue(i)}return s}var ce=(e,...t)=>t.some(t=>new RegExp(`\\b${t}\\b`).test(e)),fe=e=>e.tag==="html",me=e=>{let t=fe(e)?e.willChange.replace(/(^|,)\s*(backdrop-)?filter\s*(?=,|$)/g,"$1"):e.willChange;return ce(t,"transform","perspective","filter","translate","rotate","scale")},pe=["transform","translate","rotate","scale","perspective","filter","backdropFilter"];function ge(e,{countZoom:t=!0}={}){for(let t of pe)if(e[t]!=="none"&&!(fe(e)&&t.endsWith("ilter")))return`${t==="backdropFilter"?"backdrop-filter":t}: ${e[t]}`;if(ce(e.contain,"layout","paint","strict","content"))return`contain: ${e.contain}`;if(e.contentVisibility==="auto"||e.contentVisibility==="hidden")return`content-visibility: ${e.contentVisibility}`;if(me(e))return`will-change: ${e.willChange}`;let s=parseFloat(e.zoom??"1");return t&&Number.isFinite(s)&&Math.abs(s-1)>1e-6?`zoom: ${e.zoom}`:null}var ve=e=>ge(e,{countZoom:!1})!==null;function be(e,t=null){for(let[s,i]of e.entries()){if(i.tag==="html")break;if(i.position==="fixed"&&!ye(e,s)||i.position==="sticky"&&we(e,s,t))return!0}return!1}function ye(e,t){return e.some((e,s)=>s>t&&ve(e))}function we(e,t,s){for(let i=t+1;i<e.length;i++){let t=e[i];if(!t)break;if(t.el===s||t.tag==="html"||t.tag==="body")return!0;if(Me(t))return!1}return!0}function xe(e){if(e==="none"||e==="")return!0;let t=/^matrix\((.*)\)$/.exec(e);if(!t)return!1;let[,s=""]=t,[i,r,n,a]=s.split(",").map(Number);return i===void 0||r===void 0||n===void 0||a===void 0?!1:Math.abs(r)<=1e-9&&Math.abs(n)<=1e-9&&i>1e-9&&a>1e-9}function ke(e,t=()=>!1){let s=_e(e);for(let[i,r]of e.entries())if(!Se(r)||i>0&&ze(r)&&!(Ee(r,s)||r.tag==="body"&&r.zoom==="1"&&t(r)))return!1;return!0}function _e(e){let t=e.at(-1);return t?.tag!=="html"||t.overflowX==="visible"&&t.overflowY==="visible"}function Ee(e,t){return e.tag==="html"||e.tag==="body"&&(t||oe(e))}function Se(e){if(e.mask||e.clipPath!=="none"||e.clip!=="auto"&&e.clip!==""||e.topLayer||e.rotate!=="none"||e.perspective!=="none"||e.offsetPath!=="none"&&e.offsetPath!==""||e.el.namespaceURI==="http://www.w3.org/2000/svg")return!1;let t=e.scale.split(" ");return!xe(e.transform)||e.translate.split(" ").length>2?!1:e.scale==="none"||t.length<=2&&t.every(e=>parseFloat(e)>1e-9)}function Me(e){let t=e=>e==="hidden"||e==="auto"||e==="scroll"||e==="overlay";return e.display!=="inline"&&e.display!=="contents"&&(t(e.overflowX)||t(e.overflowY))}function ze(e){return e.display==="inline"?!1:e.overflowX!=="visible"||e.overflowY!=="visible"||ce(e.contain,"paint","strict","content")||e.contentVisibility==="auto"||e.contentVisibility==="hidden"}var Te=3e3;function Ae(e,t){e.setStatus(t?"loading":null),e.wait()}function Re(e,t){return{el:e.el,reason:t==="oval"?"its rounded corners have different shapes, so its DOM shows":t}}var Pe=e=>e.xfReason??e._y??e._I??e._e??e._t,Ce=class{constructor(e){this.stage=e}Ja(e,t){e.warned.has(t)||(e.warned.add(t),i.warn(t,e.el))}E(e,t){let s=this.stage;s.env.lib.tell("threw",[e.el],i.error,t),e.setStatus("error",String(t)),s.planes.remove(e)}decide(e){if(e.kind==="layer"){e.level&&this.stage.chunks.layers?.upright(e);return}this.Ik(e,Pe(e))}report(e,t=e.domReason){this.stage.env.lib.showFullImages(e.el),this.stage.env.host.emit("fallback",Re(e,t))}Ik(e,t){if(t===e.domReason)return;let s=e.domReason;e.domReason=t,t?(this.Ja(e,t),e.setStatus("error"),s&&s===e._t&&(e.emit("error"),this.report(e)),this.stage.env.lib.unmarkMedia(e.el)):s&&e.textureState!=="error"&&(e.media&&this.stage.env.lib.markMedia(e.el,e.media),Ae(e),e.zone.near&&e.textureState==="none"&&this.stage.factory.load(e)),(!t||!s)&&this.stage.scheduler.markDirty()}};function Ue(e,t,s){let i=t.state;if(i.status==="loading"){if(!Ne(t)){i.waitingSince=null;return}i.waitingSince===null&&(i.waitingSince=s,t.emit("wait")),!(s-i.waitingSince<Te)&&(e.say("slow",[Te/1e3],t.el),Fe(t)?(t.slow=!0,t.setStatus("error"),e.unmarkMedia(t.el)):(e.showFullImages(t.el),Ae(t)))}}var Fe=e=>!/ready|error/.test(e.textureState);function Le(e,t){t.slow&&(t.slow=!1,!t.domReason&&(t.media&&e.markMedia(t.el,t.media),Ae(t)))}function Ne(e){let t=(Fe(e)||!e.program?.ready())&&!e.raster?.empty,s=!e.modules.feed||e.plays.za.size>0;return e.kind!=="layer"&&e.visible&&!!e.opacity&&t&&s&&e.el.getAttribute("data-umber-status")==="loading"}function Ie(e,t,s){let i=/^(static|relative)$/.test(getComputedStyle(e).position),r=document.documentElement,n=s.bodyOrNull(),a=new Map,l=e=>ge(ae(e,a));if(t==="created"&&n&&e.parentElement===n&&l(n)?.startsWith("zoom:")&&r.insertBefore(e,n),i)return"umber.css";for(let t=e.parentElement;t;t=t.parentElement){let e=l(t);if(e)return`${t===r||t===n?`<${t.localName}>`:s.describe(t)} has ${e}`}return null}function je(e,t,s,i){if(!e||e===document.documentElement||s&&e.contains(s))return 1;let r=getComputedStyle(e);if(!i&&r.visibility==="hidden")return 0;let n=t.get(e);if(n!==void 0)return n;let a=r.display==="none"?0:parseFloat(r.opacity);Number.isFinite(a)||(a=1);let l=a===0?0:a*je(e.parentElement,t,s,1);return t.set(e,l),l}function De(e,t){if(e._e=null,e.kind==="text"||e.kind==="layer"){e.fit=2,e.radius.fill(0);return}let s=e.el,i=e.media,r=getComputedStyle(s),n=i&&i!==s?getComputedStyle(i):r,a=e._u,l=e._F,o=$e(e,a,l),h=a>0?a:e.doc.w,u=l>0?l:e.doc.h,d=(e=>e===s?r:e===i?n:getComputedStyle(e))(e.geomEl),c=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"],f=(e,t)=>e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0,m=[0,0,0,0],p=[0,0,0,0],g=0,v=!1;for(let[e,t]of c.entries()){let[s="",i=s]=(d[t]||"0px").trim().split(/\s+/),r=f(s,h),n=f(i,u);r>0&&n>0?g?v||=Math.abs(r-n*g)>1:g=r/n:(r=0,n=0),m[e]=r,p[e]=n}e._w=g||1;let b=(e,t)=>t>0?e/t:1,y=Math.min(1,b(h,m[0]+m[1]),b(u,p[1]+p[2]),b(h,m[2]+m[3]),b(u,p[3]+p[0]));m.forEach((t,s)=>{e.radius[s]=t*y*o}),v&&(e._e="oval",e.warned.add(e._e),t("oval",[e.geomEl],e.el));let w=s.getAttribute("data-umber-fit"),x=(w??"")||n.objectFit;e.fit=Be(x,!!w),e.objectPosition=(n.objectPosition||"50% 50%").split(/\s+/),Oe(e)}function $e(e,t,s){return e.level?e.edge[0]:t>0&&s>0&&Math.abs(e.doc.w-t)>.01?Math.min(e.doc.w/t,e.doc.h/s):1}function Be(e,t){return e==="contain"?1:e==="fill"&&t?2:0}function He(e,t){let s=parseFloat(e);return e.endsWith("%")?s/100:e.endsWith("px")?t*t>.25?s/t:0:.5}function Oe(e){let t=e.objectPosition;if(!t)return;let s=e._u>0?e._u:e.doc.w,i=e._F>0?e._F:e.doc.h,r=e.texture?.ready?e.texture:null,n=e.media,a=NaN,l=NaN;r?(a=(r.box?.[2]??0)||r.width,l=(r.box?.[3]??0)||r.height):n&&(a=n.naturalWidth||n.videoWidth,l=n.naturalHeight||n.videoHeight);let o=(e.fit?Math.min:Math.max)(s/a,i/l);t.forEach((t,r)=>{e._M[r]=He(t,r?i-l*o:s-a*o)})}function We(e){let t=e.media;return(e.kind==="image"||e.kind==="video")&&t&&t!==e.el&&e.el.contains(t)&&t.getClientRects().length>0?t:e.el}function qe(e,t,s,i=e.rect){let r=e.offset;if(i[0]=e.doc.x-t+(r?r[0]:0),i[1]=e.doc.y-s+(r?r[1]:0),e.pixelGrid&&(i[1]=Math.round(i[1]*e.pixelGrid)/e.pixelGrid),i[2]=e.doc.w,i[3]=e.doc.h,e.pad){let t=e.pad*(e.layoutW?e.doc.w/e.layoutW:1),s=e.pad*(e.layoutH?e.doc.h/e.layoutH:1);i[0]-=t,i[1]-=s,i[2]+=t/e.pad*(e.pad*2+e.rounding[0]),i[3]+=s/e.pad*(e.pad*2+e.rounding[1])}return i}var Ve=/^(transform|translate|rotate|scale|perspective|offset[A-Z]|left|top|right|bottom|inset|width|height|min[WH]|max[WH]|margin|padding|flex|grid|clipPath|clip$|opacity|visibility|display|fontSize|letterSpacing|lineHeight|border\w*(Width|Radius)|all$|zoom)/,Xe=/^(rotate|perspective|offset|clip|display|border\w*Radius|all$|zoom)/,Ge={transform:/^(none|((translate[XY]?\([^()]*\)|scale[XY]?\([^()-]*\)) ?)+)$/,translate:/^\S+( \S+)?$/,scale:/^[^-\s]+( [^-\s]+)?$/},Ke=new WeakMap;function Ye(e){let t=Ke.get(e);if(t!==void 0)return t;try{let s=e.effect.getKeyframes();t=0;for(let e of new Set(s.flatMap(e=>Object.keys(e)))){if(!Ve.test(e))continue;let i=s.map(t=>t[e]).filter(e=>e!=null),r=Ge[e];t=Math.max(t,Xe.test(e)||r&&!(i.length&&i.every(e=>r.test(String(e).trim())))?2:1)}}catch{t=2}return Ke.set(e,t),t}function Ze(e,t){let s=(t-e[1])/Math.max(t+e[3],1);return Math.min(1,Math.max(0,s))}var Je="model",Qe=e=>e===Je?"layer":e,et=e=>e.matches("[data-umber~=model]"),tt=e=>et(e)?Je:e.getAttribute("data-umber-layer")??"";function st(e,t){let s=e.raster,i=e.zone.soon||e.visible||t.jump||!!e.wrap,r=e.animUntil,n=!!r,a=n&&t.now<r;return{near:i,settling:e.zone.screen&&e.status==="loading"&&!e.backHidden,textWatch:e.zone.soon&&!!s?.Bc,colorWatch:it(e,t),innerScrolled:i&&!!t.inside?.(e.geomEl),animating:e.heldMoved||a&&rt(e,t,i),animationEnded:n&&!a,scrollDriven:e.scrollLinked&&i&&(t.scrolled||t.wi),rewalk:t.ul&&i}}var it=(e,t)=>e.kind==="text"&&e.zone.soon&&!!e.raster&&t.now<e.raster.U;function rt(e,t,s){return e.animUntil!==1/0?s:e.zone.screen||t.scrolled&&s||e.visible}function nt(e,t,s){let i=lt(e,s),r=i||e.morphHidden||s.animating||s.scrollDriven;if(e.status==="error"&&!r&&!s.innerScrolled)return null;let n=r||s.settling||s.textWatch,a=n||at(e,t,s),l=a&&(n||t.live),o=t.Hh&&e.zone.soon&&!e.opacitySettled,h=l||s.colorWatch||o;return!a&&!h?null:{rect:a,style:l,opacity:h,swept:o,full:a&&ot(e,t,s,i)}}var at=(e,t,s)=>t.live&&e.zone.soon||e.live&&s.near&&e.opacity>0||s.innerScrolled,lt=(e,t)=>e.stale||t.rewalk||t.animationEnded,ot=(e,t,s,i)=>i||!e.chained||s.animating&&t.W;var ht=new Set,ut=null;function dt(e){for(let t of ht)try{e(t)}catch{}}var ct="play pause finish reverse cancel updatePlaybackRate currentTime startTime playbackRate",ft="scrollTo scroll scrollBy scrollIntoView scrollTop scrollLeft";function mt(e,t,s,i){for(let r of t?s.split(" "):[]){let s=Object.getOwnPropertyDescriptor(t,r),n=s?.set?"set":"value",a=s&&Reflect.get(s,n);if(!s?.configurable||typeof a!="function")continue;let l=function(...t){let s=a.apply(this,t);return e.live&&i(this),s};Object.defineProperty(t,r,{...s,[n]:l}),e.undo.push(()=>{let e=Object.getOwnPropertyDescriptor(t,r);e&&Reflect.get(e,n)===l&&Object.defineProperty(t,r,s)})}}function pt(e){if(ht.add(e),!ut){let e={live:!0,undo:[]},t=()=>{dt(e=>{e.scrolled()})},s=Element.prototype;mt(e,s,"animate",e=>{dt(t=>{t.animate(e)})}),mt(e,window.Animation?.prototype,ct,e=>{dt(t=>{t.animation(e)})}),mt(e,s,ft,t),mt(e,window,ft,t),ut=e}return()=>{if(!(!ht.delete(e)||ht.size||!ut)){ut.live=!1;for(let e of ut.undo)e();ut=null}}}var gt=6,vt=12,bt=100,yt=50,wt=class{constructor(e,t,s){this.stage=e;this.observers=t;this.own=s;this.rh=!1;this.at={full:!1,restyle:!1,r:new DOMRect,sx:0,sy:0,now:0};this.Me=!1;this.ta=new Map;this.je=new Set;this.Yk=0;this.Ua=null;this.Lh=null;this.wi=!1;this.zh=NaN;this.Uk=NaN;this.tg=!1;this.cb=null;this.covers=!1;this.Nj=!1}ma(){this.rh=!0}get F(){return this.rh}cd(){this.rh=!1}ue(){let e=this.stage;for(let t of["pointerover","pointerout","pointerdown","focusin","focusout","keydown","input"])e.env.listen(document,t,e=>{this.hook(e)});e.env.cleanups.push(pt({animate:e=>{this.Vh(e)},animation:e=>{this.Ad(e)},scrolled:()=>{this.Nj||queueMicrotask(()=>{let t=e.env.host;t.ticker.running||!t.scroll.moved()||(this.Nj=!0,t.ticker.tick(),this.Nj=!1)})}}));let t=e=>{this._f(e)};document.addEventListener("scroll",t,{capture:!0,passive:!0}),e.env.cleanups.push(()=>{document.removeEventListener("scroll",t,{capture:!0})}),e.env.cleanups.push(e.env.host.env.onForcedColorsChange(t=>{t?e.scheduler.hold("forced"):e.scheduler.release("forced")}))}run(e){let t=this.stage,s=performance.now(),i=t.scheduler.Ug(s);if(this.Me&&!i)for(let e of t.planes.all)e.stale=!0;this.Me=i,this.own.resize();let r=this.ib(e);this.ta.clear(),t.env.frame.cc.clear(),this.cb=null,!t.env.frame.scrolled&&(this.Lh??this.Ua)&&this.hovered(s),this.Ii(e,s);let n={now:s,live:i,jump:r,Hh:e.frame%vt===0,scrolled:t.env.frame.scrolled,wi:this.wi,ul:t.chunks.ul,W:t.chunks.shapesError!==null,inside:this.je.size>0?e=>this.ve(e):null},a=this.zi(n);(a||this.tg)&&t.chunks.shapes?.zl(),this.tg=a,this.je.clear()}zi(e){let t=!1;for(let s of this.stage.planes.all)try{this.measurePlane(s,e)&&(t=!0)}catch(e){this.stage.fallbacks.E(s,e)}return t}Ii(e,t){e.woke&&this.ma();let s=this.F||e.frame%gt===0&&this.stage.planes.all.some(e=>e.zone.soon);this.stage.chunks.shapes?this.stage.chunks.shapes.start(t,s):s&&this.oi(t)}ib(e){let t=this.stage;t.env.frame.screen.width=window.innerWidth||t.canvasHost.viewport.width,t.env.frame.screen.height=window.innerHeight||t.canvasHost.viewport.height,t.env.frame.scrollX=e.scroll.x,t.env.frame.scrollY=e.scroll.y,t.env.host.scroll.root?(t.env.frame.pageX=window.scrollX||0,t.env.frame.pageY=window.scrollY||0):(t.env.frame.pageX=t.env.frame.scrollX,t.env.frame.pageY=t.env.frame.scrollY),this.wi=t.env.frame.scrolled,t.env.frame.scrolled=t.env.frame.scrollX!==this.zh||t.env.frame.scrollY!==this.Uk;let s=Math.abs(t.env.frame.scrollY-this.Uk)>t.env.frame.screen.height/4;return this.zh=t.env.frame.scrollX,this.Uk=t.env.frame.scrollY,s}measurePlane(e,t){let s=this.stage;if(e.destroyed||!e.el.isConnected||!e.program&&e.kind!=="layer")return!1;let i=st(e,t);i.settling&&Ue(s.env.lib,e,t.now),e.heldMoved=!1,i.animationEnded&&(e.animUntil=0),lt(e,i)&&(e.stale=!0);let r=nt(e,t,i);if(!r)return!1;let n=r.rect&&this.Jd(e,r.full,r.style,t.now);return r.opacity&&this.Gf(e,r.style),e.stale&&(De(e,s.env.lib.say),e.order=s.env.lib.attr.num(e.el,"data-umber-order",0)),r.rect&&(e._I=s.chunks.shapes?s.chunks.shapes.Fb(e,r.full,r.style):null,s.fallbacks.decide(e)),e.kind==="text"&&s.chunks.text&&e.zone.near&&e.textureState!=="loading"&&e.textureState!=="error"&&s.chunks.text.check(e,t.now,r.swept),e.stale=!1,n}Jd(e,t,s,i){let r=this.stage;t&&(this.observers.Ee(e,We(e)),e.gen=r.batches.jc);let n=e.geomEl.getBoundingClientRect(),a=e.offset;a&&(n=new DOMRect(n.x-a[0],n.y-a[1],n.width,n.height));let l=e.scrolls?r.env.frame.scrollX:r.env.frame.pageX,o=e.scrolls?r.env.frame.scrollY:r.env.frame.pageY,h=e.doc.w!==n.width||e.doc.h!==n.height;if(e.doc.x=n.left+l,e.doc.y=n.top+o,e.doc.w=n.width,e.doc.h=n.height,e.measured=!0,h&&(e._V!==-1&&e.emit("resize"),r.gpu.media.sharpen(e)),r.chunks.shapes){let a=this.at;a.full=t,a.restyle=s,a.r=n,a.sx=l,a.sy=o,a.now=i,r.chunks.shapes.gi(e,a)}else this.kc(e,t,n);return t&&(e.live=(e.pinned=be(e.nodes,r.env.host.scroll.root))||r.env.lib.attr.bool(e.el,"data-umber-live")),e.wrap&&xt(e,e.wrap,l,o),!!e.scene}Gf(e,t){let s=e.media===e.el,i=je(s?e.el.parentElement:e.el,this.ta,this.stage.canvasHost.el);if(s){let t=parseFloat(e.el.style.opacity);t>=0?i*=Math.min(t,1):e.status!=="ready"&&!e.el.hasAttribute("data-umber-play")&&+(getComputedStyle(e.el).opacity||1)<1&&this.stage.env.lib.say("fade",[],e.el)}e.opacitySettled=!t&&i===e.opacity,e.opacity=i}kc(e,t,s){let i=this.stage;if(!t&&!e._J)return;let r=t?!this.Ll(e,s):!this._J(document.body,s);r&&i.chunks.loadShapes(),e.xfReason=e._T=r&&i.chunks.shapesError?`${i.env.lib.describe(e.el)}: it is cut, turned or tilted by CSS, and ${i.chunks.shapesError}, so its DOM shows.`:null;let n=r&&!i.chunks.shapesError;n!==e.shapeWait&&(e.shapeWait=n,n&&e.status==="ready"&&Ae(e),i.scheduler.markDirty())}Ll(t,s){let i=t.nodes=de(t.geomEl,this.stage.env.frame.cc);t.chained=!0;let[r,n]=he(getComputedStyle(t.geomEl));return t._u=Number.isFinite(r)&&r>0?r:s.width,t._F=Number.isFinite(n)&&n>0?n:s.height,t._J=!1,!this.covers&&!this.stage.chunks.ra.asked&&i.some(e=>+e.zIndex>0)&&(this.covers=!0,this.stage.env.host.loadCovers?.().then(e=>{e.plain(this.stage)},e)),ke(i,e=>t._J=this._J(e.el,s))}_J(e,t){let s=this.cb??=e.getBoundingClientRect(),{clientLeft:i,clientTop:r,clientWidth:n,clientHeight:a}=e;return!/[1-9]/.test(getComputedStyle(e).borderRadius)&&t.left>=s.left+i-.5&&t.top>=s.top+r-.5&&t.right<=s.left+i+n+.5&&t.bottom<=s.top+r+a+.5}hook(e){let t=this.stage;if(!t.planes.all.some(e=>e.zone.screen))return;let s=e.target;if((e.type==="pointerover"||e.type==="pointerout")&&(t.env.frame.scrolled||this.wi)&&s instanceof Element){e.type==="pointerout"?this.Ua??=s:this.Lh=s;return}let i=!1;s instanceof Element&&e.type!=="keydown"&&e.type!=="pointerdown"&&e.type!=="input"&&(i=this.$k(s));let r=performance.now();(i||r-this.Yk>=bt)&&(this.Yk=r,this.ma(),t.scheduler.request())}_f(e){let t=this.stage,s=e.target;!(s instanceof Element)||s===t.env.host.scroll.root||s===document.documentElement||s===document.body||(t.batches._f(),t.planes.all.some(e=>e.zone.soon&&s.contains(e.el))&&(this.je.add(s),t.scheduler.markDirty()))}ui(e){this.je.add(e)}$k(e){let t=this.stage;if(e===document.documentElement||e===document.body||e===t.env.host.scroll.root)return!1;let s=!1;for(let i of t.planes.all)i.zone.screen&&(i.el.contains(e)||e.contains(i.el))&&(i.stale=!0,s=!0);return s}hovered(e){let t=this.Ua,s=this.Lh;this.Ua=null,this.Lh=null;let i=!1;t?.isConnected&&(i=this.$k(t)),s?.isConnected&&this.$k(s)&&(i=!0),i&&this.ma(),this.Yk=e}ve(e){for(let t of this.je)if(t.contains(e))return!0;return!1}oi(e){let t=this.stage;if(this.cd(),typeof document.getAnimations=="function"){for(let e of t.planes.all)(e._B=e.animUntil===1/0)&&(e.animUntil=0);for(let t of document.getAnimations())if(!this.dl(t,e))return;for(let e of t.planes.all)e._B&&(e._B=!1,e.animUntil!==1/0&&(e.stale=!0))}}dl(e,t){let s=this.stage,i=e.effect,r=i?.target;if(!i||!r||i.pseudoElement||e.playState==="idle")return!0;let n=Ye(e);if(!n)return!0;let a=e.playState==="running"&&!!e.playbackRate,l=kt(e);for(let o of s.planes.all){if(!o.zone.soon||!(r===o.el||r.contains(o.geomEl)))continue;if(!s.chunks.shapesError&&(l||!a||o.shapeWait||n>1))return s.chunks.ul=!0,s.chunks.loadShapes(),!1;if(!a)continue;let h=l?1/0:_t(e,i,t);h>o.animUntil&&(o.animUntil=h,o.animLabel=`animation on ${s.env.lib.describe(r)}`)}return!0}Ad(e){let t=this.stage;if(t.scheduler.inactive)return;if(t.chunks.shapes){t.chunks.shapes.Ad(e);return}let s=e.effect?.target;s&&Ye(e)&&this.Vh(s)}Vh(e){let t=this.stage;if(!(t.scheduler.inactive||!(e instanceof Element))){for(let s of t.planes.all)if(s.zone.soon&&(e===s.el||e.contains(s.geomEl))){this.ma(),t.scheduler.request();return}}}};function xt(e,t,s,i){let r=e.el.closest("[data-umber-wrap]");if(!r)throw new Error("no data-umber-wrap track");let n=r.getBoundingClientRect(),a=new DOMMatrixReadOnly(getComputedStyle(r).transform);t.period=t.axis?r.offsetHeight:r.offsetWidth,t.start=t.axis?n.top-a.m42+i:n.left-a.m41+s}function kt(e){let t=typeof DocumentTimeline<"u"?DocumentTimeline:null;return!!(e.timeline&&t&&!(e.timeline instanceof t))}function _t(e,t,s){let i=t.getComputedTiming(),r=Number(i.endTime);if(r===1/0)return 1/0;let n=Number(i.localTime)||0;return s+Math.max(0,e.playbackRate<0?n:r-n)/Math.abs(e.playbackRate)+yt}var Et=class{constructor(e,t){this.stage=e;this.xh=new WeakMap;this.io=new IntersectionObserver(e=>{this.e(e)},{rootMargin:"25% 0px 25% 0px"}),this.Sa=new IntersectionObserver(t=>{for(let s of t){let t=e.planes.of(s.target);!t||t.zone.screen===s.isIntersecting||t.wrap?.period||(t.zone.screen=s.isIntersecting,t.zone.screen&&e.gpu.programs.want(t,!0),t.modules.tell(e=>e.visible?.(t.zone.screen)),t.emit(t.zone.screen?"enter":"leave"))}e.scheduler.markDirty()}),this.we=new IntersectionObserver(t=>{for(let s of t){let t=e.planes.of(s.target);if(t){if(!s.isIntersecting&&!t.wrap){t.zone.near&&t.modules.tell(e=>e.near?.(!1)),t.zone.near=!1,t._K=performance.now();continue}t.zone.near||t.modules.tell(e=>e.near?.(!0)),t.zone.near=!0,e.factory.load(t)}}},{rootMargin:"150%"}),this.ro=new ResizeObserver(s=>{for(let i of s){if(i.target===e.canvasHost.el){t(),e.factory.invalidate();continue}if(i.target===document.documentElement){e.factory.invalidate();continue}let s=e.planes.of(i.target)??this.xh.get(i.target);s&&(s.stale=!0)}e.scheduler.markDirty()}),this.ro.observe(e.canvasHost.el),this.ro.observe(document.documentElement)}e(e){let t=!1,s=!1;for(let i of e){let e=this.stage.planes.of(i.target);if(!e)continue;let r=this.soon(e,i.isIntersecting);r!=="quiet"&&(t=!0),r==="shows"&&(s=!0)}s?this.stage.scheduler.markDirty():t&&this.stage.scheduler.request()}soon(e,t){let s=this.stage,i=e.animUntil===1/0&&!e.zone.screen;return t&&!e.zone.soon&&!i&&s.measurePhase.ma(),e.zone.soon=t,t&&(s.gpu.programs.want(e,!0),e.zone.near&&s.factory.load(e)),(t&&e.gen!==s.batches.jc||s.transitions.ongoing)&&(e.stale=!0),this.jh(e,t),i?"quiet":e.zone.screen||e.visible?"shows":"news"}jh(e,t){e.modules.feed||e.kind!=="video"||(t&&(e.videoFrame=!0),e.media&&this.stage.chunks.video?.Rh(e,t))}observe(e){this.io.observe(e.el),this.Sa.observe(e.el),this.we.observe(e.el),this.ro.observe(e.el)}forget(e){this.io.unobserve(e.el),this.Sa.unobserve(e.el),this.we.unobserve(e.el),this.ro.unobserve(e.el),e.geomEl!==e.el&&(this.ro.unobserve(e.geomEl),this.xh.delete(e.geomEl))}Ee(e,t){t!==e.geomEl&&(e.geomEl!==e.el&&(this.ro.unobserve(e.geomEl),this.xh.delete(e.geomEl)),e.geomEl=t,t!==e.el&&(this.xh.set(t,e),this.ro.observe(t)))}Ab(e,t){this.ro.unobserve(e),this.ro.observe(t)}disconnect(){this.io.disconnect(),this.Sa.disconnect(),this.we.disconnect(),this.ro.disconnect()}};function St(e,t){Mt(e,t),e.env.listen(window,"resize",()=>{t.resized(),(!e.env.host.env.isTouch||innerWidth!==e.env.frame.screen.width)&&e.factory.invalidate()}),e.env.listen(window,"pointermove",s=>{let i=s;e.env.frame.pointer.x=i.clientX,e.env.frame.pointer.y=i.clientY,t.following()&&e.scheduler.request()}),e.env.listen(document,"visibilitychange",()=>{if(!document.hidden){for(let t of e.planes.all)t._N();e.gpu.renderer.adaptive.rest(30),e.factory.invalidate(),e.scheduler.wake(2)}}),e.env.listen(e.gpu.canvas,"webglcontextlost",t=>{_(e,t)},!1),e.env.listen(e.gpu.canvas,"webglcontextrestored",()=>{let t=()=>{e.env.destroyed||e.chunks.load({load:e.env.host.loadRestore,file:"restore",made:t=>{t.restored(e)}})},s=e.gpu.context.Yg();s?setTimeout(t,s):t()});let s=document.fonts;typeof s?.addEventListener=="function"&&e.env.listen(s,"loadingdone",()=>{for(let t of e.planes.all)t.raster&&(t.raster.Ze=!0);e.factory.invalidate()}),zt(e)}function Mt(e,t){let s=null,i=()=>{let r=matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),n=()=>{t.resized(),e.scheduler.markDirty(),i()};typeof r.addEventListener=="function"&&(r.addEventListener("change",n,{once:!0}),s=()=>{r.removeEventListener("change",n)})};i(),e.env.cleanups.push(()=>s?.())}function zt(e){let t=t=>t instanceof Element&&e.planes.all.some(e=>t===e.el||t.contains(e.geomEl)),s=s=>{t(s.target)&&(e.measurePhase.ma(),e.scheduler.markDirty())},i=t=>{let s=t.target;if(!(s instanceof Element))return;let i=!1;for(let t of e.planes.all)(s===t.el||s.contains(t.geomEl))&&(t.stale=!0,i=!0);i&&(e.measurePhase.ma(),e.scheduler.markDirty())};for(let t of["transitionrun","animationstart"])e.env.listen(document,t,s);for(let t of["transitionend","animationend","transitioncancel","animationcancel"])e.env.listen(document,t,i)}var Tt={scrub:"modules/scrub.js"};var At=null,Rt=(e,t)=>e.replace(/var\(\s*(--[\w-]+)\s*(?:,((?:[^()]|\([^()]*\))*))?\)/g,(e,s,i)=>getComputedStyle(t).getPropertyValue(s).trim()||Rt(i??"",t));function Pt(e,t,s){let i=Rt(e,t).trim().replace(/currentcolor/gi,getComputedStyle(t).color);return typeof CSS>"u"||i.includes("var(")||!CSS.supports("color",i)?e.includes("var(")?(s("var",[e],t),new Float32Array(4)):null:(At??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),At?(At.clearRect(0,0,1,1),At.fillStyle=i,At.fillRect(0,0,1,1),Float32Array.from(At.getImageData(0,0,1,1).data,e=>e/255)):null)}var Ct=e=>e,Ut=["uniformMatrix2fv","uniformMatrix3fv","uniformMatrix4fv",void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,"uniformMatrix2x3fv","uniformMatrix2x4fv","uniformMatrix3x2fv","uniformMatrix3x4fv","uniformMatrix4x2fv","uniformMatrix4x3fv"],Ft=["uniform1iv","uniform2iv","uniform3iv","uniform4iv"],Lt=["uniform1uiv","uniform2uiv","uniform3uiv","uniform4uiv"];function Nt(e,t,s){return(t===e.UNSIGNED_INT||t>=e.UNSIGNED_INT_VEC2&&t<=e.UNSIGNED_INT_VEC4?Lt:Ft)[s-1]}var It=(...e)=>e.find(e=>!!e)??0,jt=0,Dt=0,$t=0,Bt=3e3,Ht=.02,Ot=Ht,Wt=.001,qt=!1,Vt=4,Xt=500,Gt=300,Kt=()=>performance.now()<jt,Yt=class{constructor(e,t,s,i="program"){this.gl=e;this.vertex=t;this.fragment=s;this.uniforms=new Map;this.state="pending";this.started=!1;this.error=null;this.shaders=[];this.options=typeof i=="string"?{label:i}:i;let r=globalThis.occluzeCapture;this.now=r?.version===1,this.Uf=this.now?null:e.getExtension("KHR_parallel_shader_compile");let n=Ct(e.createProgram());if(!n)throw new Error("the WebGL context is lost");this.program=n,this.options.lazy||this.start()}start(e){if(this.started||!e&&Kt())return;this.started=!0;let t=this.gl,s=this.program,i,r;try{i=es(t,t.VERTEX_SHADER,this.vertex),r=es(t,t.FRAGMENT_SHADER,this.fragment)}catch{this.state="failed";return}t.attachShader(s,i),t.attachShader(s,r),t.bindAttribLocation(s,0,"aPosition");for(let[e,i]of this.options.attributes??[])t.bindAttribLocation(s,i,e);if(t.linkProgram(s),this.shaders=[i,r],this.Uf)return;if(this.now){this.T();return}t.flush(),Kt()||(Dt=jt=performance.now(),$t=0);let n=Bt+this.vertex.length+this.fragment.length;$t+=n,jt+=Math.min(Xt,Ot*n)}ready(){return this.state!=="pending"?this.state==="ok":this.compiled()?(this.T(),this.state==="ok"):!1}compiled(){return this.start(),this.state!=="pending"?!0:this.Uf?!!this.gl.getProgramParameter(this.program,this.Uf.COMPLETION_STATUS_KHR):this.started&&!Kt()}get failed(){return this.state==="failed"}get eh(){return!this.Uf&&!this.now}T(){if(this.start(!0),this.state!=="pending")return;let e=this.gl,t=this.program,s=performance.now(),i=e.getProgramParameter(t,e.LINK_STATUS),r=performance.now();if(r-s>Vt?(Ot=Math.max(Ht,(Math.min(r,jt+r-s)-Dt)/$t),jt=r,qt=!0):!qt&&!this.Uf&&(Ot=Math.max(Wt,Ot/2)),!i){this.error=this.ze(),this.ob(),e.deleteProgram(t),this.state="failed";return}this.ob();let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;s++){let i=e.getActiveUniform(t,s);if(!i)continue;let r=i.name.replace(/\[0\]$/,""),n=e.getUniformLocation(t,i.name);n&&this.uniforms.set(r,{location:n,type:i.type,size:i.size})}this.state="ok"}ze(){let e=this.gl,[t,s]=this.shaders,i=ts(e,t);if(i!==null)return["vertex",this.options.label,i,this.vertex];let r=ts(e,s);return r!==null?["fragment",this.options.label,r,this.fragment]:["link",this.options.label,e.getProgramInfoLog(this.program)??"",""]}ob(){for(let e of this.shaders)this.gl.deleteShader(e);this.shaders=[]}set(e,t){let s=this.state==="ok"?this.uniforms.get(e):void 0;!s||t==null||(typeof t=="number"?Zt(this.gl,s,t):Qt(this.gl,s,t))}dispose(){this.ob(),this.state!=="failed"&&this.gl.deleteProgram(this.program)}};function Zt(e,t,s){if(t.last===s)return;t.last=s;let{type:i,location:r}=t;i===e.FLOAT?e.uniform1f(r,s):i===e.UNSIGNED_INT?e.uniform1ui(r,s):e.uniform1i(r,s)}function Jt(e,t){let s=e.last;if(s?.length===t.length){let e=t.length;for(;e--&&s[e]===t[e];);if(e<0)return!1}else s=[],e.last=s;for(let e=0;e<t.length;e++)s[e]=te(t,e);return!0}function Qt(e,t,s){if(!Jt(t,s))return;let{type:i,location:r}=t,n=Ut[i-e.FLOAT_MAT2];if(i===e.FLOAT_VEC2)e.uniform2fv(r,s);else if(i===e.FLOAT_VEC3)e.uniform3fv(r,s,0,Math.min(s.length,t.size*3));else if(i===e.FLOAT_VEC4)e.uniform4fv(r,s);else if(n)e[n](r,!1,s);else if(i===e.FLOAT)e.uniform1fv(r,s);else{let n=Nt(e,i,s.length/t.size);n&&e[n](r,s)}}function es(e,t,s){let i=Ct(e.createShader(t));if(!i)throw new Error("the WebGL context is lost");return e.shaderSource(i,s),e.compileShader(i),i}function ts(e,t){return t&&!e.getShaderParameter(t,e.COMPILE_STATUS)?e.getShaderInfoLog(t)??"":null}var ss=255,is=e=>Math.min(ss,Math.max(1,Math.round(e)||1)),rs=class{constructor(e,t){this.gl=e;this.segments=t;this.buffers=[];let s=is(t),i=new Float32Array((s+1)*(s+1)*2),r=0;for(let e=0;e<=s;e++)for(let t=0;t<=s;t++)i[r++]=t/s,i[r++]=e/s;let n=new Uint16Array(s*s*6);r=0;for(let e=0;e<s;e++)for(let t=0;t<s;t++){let i=e*(s+1)+t,a=i+1,l=i+(s+1),o=l+1;n[r++]=i,n[r++]=l,n[r++]=a,n[r++]=a,n[r++]=l,n[r++]=o}this.vao=Ct(e.createVertexArray()),e.bindVertexArray(this.vao);let a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,i,e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);let l=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,l),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW),e.bindVertexArray(null),this.buffers.push(a,l),this.count=n.length}draw(){let e=this.gl;e.bindVertexArray(this.vao),e.drawElements(e.TRIANGLES,this.count,e.UNSIGNED_SHORT,0)}dispose(){this.gl.deleteVertexArray(this.vao),this.buffers.forEach(e=>{this.gl.deleteBuffer(e)})}};function ns(e){let t=e;return[It(t.displayWidth,t.videoWidth,t.naturalWidth,t.width),It(t.displayHeight,t.videoHeight,t.naturalHeight,t.height)]}var as=e=>e instanceof HTMLVideoElement||"displayWidth"in e,ls=class{constructor(e){this.gl=e;this.width=1;this.height=1;this.ready=!1;this.packed=0;this.il=1;this.refs=0;this.box=[];this.mipmaps=!1;this.texture=Ct(e.createTexture()),e.bindTexture(e.TEXTURE_2D,this.texture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4)),this.params(!1)}params(e){let t=this.gl;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR)}get bytes(){return this.ready?this.packed||this.width*this.height*4*(this.mipmaps?4/3:1):0}adopt(e,t){this.texture!==e&&this.gl.deleteTexture(this.texture),this.texture=e,this.width=t.width,this.height=t.height,this.packed=t.bytes,this.mipmaps=t.mipmaps,this.il=1,this.ready=!0}upload(e,t={}){let s=this.gl,i=t.mipmaps??!as(e),[r,n]=ns(e);return!r||!n||!this.texture||this.packed&&(s.deleteTexture(this.texture),this.texture=Ct(s.createTexture()),this.packed=0,this.il=1,this.ready=!1,!this.texture)?!1:(s.bindTexture(s.TEXTURE_2D,this.texture),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!t.straight),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),this.ready&&r===this.width&&n===this.height&&(!i||this.mipmaps)?s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,e):s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i&&s.generateMipmap(s.TEXTURE_2D),(i!==this.mipmaps||!this.ready)&&this.params(i),this.mipmaps=i,this.width=r,this.height=n,this.ready=!0,!0)}angle(e){e===this.il||!this.mipmaps||!this.ready||(this.il=e,this.gl.texParameterf(this.gl.TEXTURE_2D,os,e))}dispose(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.ready=!1}},os=34046,hs=34047,us=8;function ds(e){if(!e.getExtension("EXT_texture_filter_anisotropic"))return 1;let t=e.getParameter(hs);return Math.max(1,Math.min(us,t??1))}var cs={load:()=>import(new URL("./resize.js",import.meta.url).href)};async function fs(t,s,r,n=!1){let a=[],l,o="",h=(e,t,i)=>{a[2]=e,a[3]=t;let[r=0]=a,n=r?Math.max(r/e,te(a,1)/t):1,l=2**Math.floor(Math.log2(n));return n<l*1.1&&(n=l,n<=.8&&a[0]&&(a[0]=e*n,a[1]=t*n)),n>.8&&!i?(n=1,a[0]=0):a[1]||=te(a,0)*t/e,Math.min(n,s/Math.max(e,t))},u=cs.load();u.catch(e);try{let e=await fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);let s=await e.blob();o=s.type,r&&(a=r());let i={premultiplyAlpha:n?"none":"premultiply"};l=await createImageBitmap(s,i);let d=h(l.width,l.height);return d<1?await(await u).resize(s,l,d,i):l}catch(e){return l?.close(),i.info("fetch decode failed, trying <img>",t,e),(await cs.load()).viaImg(t,(e,t)=>(r&&!a[2]&&(a=r()),h(e,t,o.includes("svg"))))}}var ms=e=>e,ps=(e,t)=>{let s=3*e,i=3*(t-e)-s,r=1-s-i;return e=>((r*e+i)*e+s)*e};function gs(e,t,s,i){let r=ps(e,s),n=ps(t,i);return e=>{if(e<=0||e>=1)return e;let t=0,s=1;for(let i=0;i<24;i++){let i=(t+s)/2;r(i)<e?t=i:s=i}return n((t+s)/2)}}function vs(e){let t=[],s=[];for(let i of e.split(",")){let[e="",...r]=i.trim().split(/\s+/);if(r.length>2||!(parseFloat(e)>=-1/0)||r.some(e=>!e.endsWith("%")))return null;for(let i of r.length?r:[""])t.push(i?parseFloat(i)/100:NaN),s.push(+e)}let i=t.length;return i<2?null:(bs(t),e=>{let r=0;for(let s=0;s<i;s++)te(t,s)<=e&&(r=s);r===i-1&&r--;let n=te(t,r),a=te(t,r+1),l=te(s,r),o=te(s,r+1);return n===a?o:l+(e-n)/(a-n)*(o-l)})}function bs(e){let t=e.length;te(e,0)>=-1/0||(e[0]=0),te(e,t-1)>=-1/0||(e[t-1]=Math.max(1,...e.filter(e=>e>=-1/0)));for(let s=1;s<t;s++){let t=s;for(;!(te(e,t)>=-1/0);)t++;let i=te(e,s-1);e[s]=i+Math.max(0,te(e,t)-i)/(t-s+1)}}function ys([e,t],s,i,r){let n=t*Math.sqrt(Math.max(1-e*e,1e-8)),a=Math.exp(-e*t*r),l=(i+e*t*s)/n,o=Math.cos(n*r),h=Math.sin(n*r),u=a*(s*o+l*h);return[u,-e*t*u+a*n*(l*o-s*h)]}function ws(e){let t=1-Math.min(.95,Math.max(0,e||0)),s=[t,1],i=0;for(let e=0;e<12/t;e+=.01)Math.abs(ys(s,1,0,e)[0])>.001&&(i=e);let r=[t,i],n=e=>e>=1?1:1-ys(r,1,0,e)[0];return n.spring=r,n}var xs=e=>t=>Math.pow(t,e),ks={quad:xs(2),cubic:xs(3),quart:xs(4),quint:xs(5),sine:e=>1-Math.cos(e*Math.PI/2),expo:e=>e===0?0:Math.pow(2,10*e-10),circ:e=>1-Math.sqrt(1-e*e)},_s={power1:"quad",power2:"cubic",power3:"quart",power4:"quint"},Es=e=>t=>1-e(1-t),Ss=e=>t=>t<.5?e(t*2)/2:1-e((1-t)*2)/2,Ms="umber",zs=[.625,.05,0,1],Ts={umber:zs,ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]},As=new Map;function Rs(e){if(e==="linear"||e==="none")return ms;let t=Ts[e];if(t)return gs(...t);let s=/^linear\((.*)\)$/.exec(e)?.[1];if(s!==void 0)return vs(s);let i=/^spring(?:\(([^)]*)\))?$/.exec(e);if(i)return ws(i[1]?parseFloat(i[1]):.2);let r=(/^cubic-bezier\(([^)]*)\)$/.exec(e)??/^([-\d.\s]+,[-\d.\s]+,[-\d.\s]+,[-\d.\s]+)$/.exec(e))?.[1];return r!==void 0?Ps(r):Cs(e)}function Ps(e){let t=e.split(",").map(e=>parseFloat(e)),[s=NaN,i=NaN,r=NaN,n=NaN]=t;return t.length===4&&t.every(Number.isFinite)&&s>=0&&s<=1&&r>=0&&r<=1?gs(s,i,r,n):null}function Cs(e){let t=/^([a-z]+\d?)(?:\.(in|out|inout))?$/.exec(e);if(!t)return null;let[,s="",i="out"]=t,r=ks[_s[s]??s];return r?i==="in"?r:i==="out"?Es(r):Ss(r):null}function Us(e,t){if(typeof e=="function")return e;let s=(e??Ms).trim().toLowerCase(),i=As.get(s);if(i)return i;let r=Rs(s||Ms);return r||(t("ease",[e]),r=gs(...zs)),As.set(s,r),r}var Fs=class{constructor(e,t){this.ya=t;this.v=e}get value(){return this.v}set value(e){e!==this.v&&(this.v=e,this.ya())}},Ls=class extends Fs{constructor(e,t){super(e.value,t);this.source=e;this.last=[];this.changed()}get value(){return this.source.value}set value(e){this.source.value=e,this.ya()}changed(){let e=this.source.value,t=this.last;if(typeof e=="number"||typeof e=="boolean"){let s=Number(e);return t.length===1&&t[0]===s?!1:(t.length=1,t[0]=s,!0)}if(Array.isArray(e)||ArrayBuffer.isView(e)){let s=e,i=t.length===s.length;for(let e=0;e<s.length;e++)t[e]!==s[e]&&(i=!1),t[e]=s[e];return t.length=s.length,!i}return!1}};function Ns(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&!ArrayBuffer.isView(e)&&"value"in e&&typeof e.value!="string"}var Is=new Set,js=()=>({status:"loading",drawnFrame:null,waitingSince:null}),Ds=0,$s=class e{constructor(e,t,s){this.id=++Ds;this.order=0;this.effects=[];this.shader=null;this.uniforms={};this.missing=[];this.backdrop=null;this.doc={x:0,y:0,w:0,h:0};this.rect=Q(4);this.size=Q(2);this.level=0;this.nodes=[];this._k=[];this._u=0;this._F=0;this._G=J(9);this.edge=J([1,1]);this._O=J(9);this._q=J(9);this._s=Q([1,0,0,0,1,0,0,0,1]);this._p=Q(9);this._x=Q(4);this.backHidden=!1;this.scene=null;this._T=null;this.xfReason=null;this._I=null;this._y=null;this._e=null;this._w=1;this.warned=new Set;this.animUntil=0;this._B=!1;this.scrollLinked=!1;this._v=[];this.animLabel="";this.heldMoved=!1;this._A=0;this._l=Q([NaN,NaN,NaN,NaN]);this.progress=0;this.scrolls=!0;this.clips=null;this.chained=!1;this.domReason=null;this._t=null;this.slow=!1;this.bends=!1;this.shapeWait=!1;this._J=!1;this.stale=!0;this.gen=-1;this.measured=!1;this.live=!1;this.offset=null;this.pinned=!1;this.zone={near:!1,soon:!1,screen:!1};this._K=0;this._j=!1;this.visible=!1;this.listed=-1;this.opacity=1;this.opacitySettled=!1;this._V=-1;this.radius=Q(4);this.fit=0;this._M=Q([.5,.5]);this.media=null;this.layer=null;this.pad=0;this.rounding=[0,0];this.pixelGrid=0;this.bleed=[0,0,0,0];this.zoom=1;this.wrap=null;this.layoutW=0;this.layoutH=0;this.raster=null;this.texture=null;this.prev=null;this.fly=null;this.textureState="none";this.loads=0;this.videoFrame=!1;this._E=null;this.modules=new Os;this.state=js();this._C=!1;this.destroyed=!1;this.sets=new Map;this.plays=new Hs;this._D=!1;this.morphHidden=!1;this.viewTransition=!1;this.listeners=[];this._U=new Set;this._S=!1;this.mouse=Q([.5,.5]);this._m=Q([.5,.5]);this.reads=Is;this._Z=!1;this.programKey="";this.program=null;this.grid=null;this.glsl=!1;this.segments=1;this.el=e,this.kind=t,this.host=s,this.handlers=s.env.lib.createEmitter(!1,"plane "),this.geomEl=e,this.loaded=new Promise(e=>{this._o=()=>{this._C=!0,e()}})}get inView(){return this.zone.screen}drawable(){return this.status==="error"||this.textureState==="error"?!1:this.kind==="layer"?!!this.layer?.ready:(this.kind==="shader"||!!this.texture?.ready)&&!!this.grid&&!!this.program?.ready()}get _z(){return this.reads.has("glyph")}_R(e){let t=this.shader?.def.head?1:0;for(let{def:e}of this.effects)(e.vertex?.head||e.fragment?.head)&&t++;this.glsl||=t>1||e.includes("#include")||z.test(e);let s=new Set;e.includes("uScrollVelocity")&&s.add("velocity"),e.includes("uTime")&&s.add("time"),e.includes("uProgress")&&s.add("progress"),A.test(e)&&s.add("glyph"),this.reads=s.size?s:Is}set(e,t){return this.sets.delete(e),this.sets.set(e,t),this.put(e,t)}reset(t){let{handlers:s,sets:i,loaded:r,_o:n,_C:a}=this,l=this.zone.screen,o=new e(this.el,t,this.host);for(let e of Object.keys(this))e in o||Reflect.deleteProperty(this,e);return Object.assign(this,o),Object.assign(this,{handlers:s,sets:i,loaded:r,_o:n,_C:a}),this.zone.screen=l,this}replay(){for(let[e,t]of this.sets)this.put(e,t,!0)}put(e,t,s=!1){typeof t=="string"&&(t=Pt(t,this.el,this.host.env.lib.say)??t);let i=this._r(e);return Ns(t)&&!(i instanceof Ls&&i.source===t)?(!i&&!O.has(e)&&!s&&this._P(e),this.uniforms[e]=new Ls(t,()=>{this.host.scheduler.markDirty()}),this._Z=!0):i?i.value=t:this._n(e,t,s),this.host.scheduler.markDirty(),this}_n(e,t,s=!1){!O.has(e)&&!s&&this._P(e);let i=new Fs(t,()=>{this.host.scheduler.markDirty()});return this.uniforms[e]=i,i}_P(e){this.host.env.lib.say("set",[this.el,e,Object.keys(this.uniforms),this.effects.map(e=>e.name).join(", ")||"none"],this.el)}_r(e){return this.uniforms[e]}get(e){return this._r(e)?.value}tween(e,t){let s=this._r(e);return s||(s=this._n(e,0),this.host.scheduler.markDirty()),this.host.env.tweens.to(s,t)}play(e={}){let{uniform:t,...s}=e,i=t?[t]:[...this.plays.za.keys()];if(!i.length)return this.host.env.lib.say("play",[],this.el),null;let r=null;for(let e of i){let t=this.plays.za.get(e)??{},i=this.host.env.reducedMotion?this.tween(e,{value:1,...s,duration:0,delay:0}):this.tween(e,{value:1,duration:typeof t.duration=="number"?t.duration:1.4,delay:typeof t.delay=="number"?t.delay:void 0,ease:t.ease??Ms,...s});!i.done&&!this._C&&(i.pause(),this.loaded.then(()=>{i.play(),this.host.scheduler.wake()})),r??=i}return r}lift(){return this.host.chunks.loadFlip().then(e=>e&&!this.destroyed?e.lift(this):null)}land(e){return this.host.chunks.loadFlip().then(t=>t?.land(this,e))}on(e,t){return this.handlers.on(e,t)}off(e,t){this.handlers.off(e,t)}emit(e){this.handlers.emit(e,this)}destroy(){this.destroyed||this.host.planes.remove(this)}revert(){this.destroy()}wake(e=1){this.host.scheduler.wake(e)}parts(){return[this.plays,this.layer,this.modules,this.raster]}get status(){return this.state.status}wait(){this.state=js()}_N(){this.state.status==="loading"&&(this.state.waitingSince=null)}drawnIn(e){this.state.status==="loading"&&this.state.drawnFrame===null&&(this.state.drawnFrame=e)}setStatus(e,t){let s=this.status;e&&e!==s&&(this.state=e==="loading"?js():{status:e}),e===null?this.el.removeAttribute("data-umber-status"):this.el.setAttribute("data-umber-status",e),e&&e!==s&&(e==="ready"||e==="error"&&!this._t)&&(this.emit(e),e==="error"&&this.host.fallbacks.report(this,t))}};function Bs(e){for(let t of e)try{t()}catch(e){i.error("plane cleanup failed",e)}}var Hs=class{constructor(){this.za=new Map;this.cleanups=[]}dispose(){Bs(this.cleanups),this.cleanups=[]}},Os=class{constructor(){this.list=[];this.feed=null;this.frames=null}tell(e){for(let t of this.list)try{e(t.binding)}catch(e){i.error(`module "${t.name}" failed`,e)}}lost(){this.frames?.forget(),this.tell(e=>e.lost?.())}dispose(e){this.tell(e=>e.destroy?.()),this.list=[],this.feed=null,this.frames&&(this.frames.dispose(),this.frames=null,e.texture=null)}};var Ws={duration:1.4,delay:0,ease:Ms,start:"top 90%",trigger:"auto",repeat:"",hide:!0};function qs(e,t){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):t}function Vs(e,t){let s=qs(e,"").trim().toLowerCase();return s==="scroll"||s==="load"||s==="manual"||s==="hover"?s:(s===""||s==="auto"||t("trigger",[e]),"auto")}function Xs(e){let t=e.getBoundingClientRect();return(t.width>0||t.height>0)&&t.top<window.innerHeight&&t.bottom>0}function Gs(e,t){let s=qs(e,Ws.start).trim().toLowerCase().split(/\s+/),[i="",r="bottom"]=s,n=i||"top",a=Ks(n);n!=="top"&&n!=="center"&&n!=="bottom"&&t("edge",[e]);let l="0px";return r==="top"?l="-100%":r==="center"?l="-50%":r==="bottom"?l="0px":/^-?[\d.]+%$/.test(r)?l=`-${Math.max(0,100-parseFloat(r))}%`:/^-?[\d.]+(px)?$/.test(r)?l=`${-Math.max(0,(window.innerHeight||800)-parseFloat(r))}px`:t("line",[e]),{rootMargin:`${a?1e3:0}% 0px ${l} 0px`,threshold:a}}function Ks(e){return e==="center"?.5:e==="bottom"?1:0}var Ys=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t;function Zs(e){let t=qs(e,"").trim().toLowerCase();return t==="reverse"?"reverse":t===""||t==="false"||t==="none"||t==="0"?"":"replay"}function Js(){}function Qs(e,t,s){let i=e.closest("a, button")??e,r=()=>{s(1,t)},n=()=>{s(0,0)};return i.addEventListener("pointerenter",r),i.addEventListener("pointerleave",n),()=>{i.removeEventListener("pointerenter",r),i.removeEventListener("pointerleave",n)}}function ei(e,t,s,i){let r=!0,n=new IntersectionObserver(e=>{let t=e[e.length-1];t&&s(t,r),r=!1},i);return n.observe(e),t.push(n),n}function ti(e,t,s,i){let r=e.uniforms[t];if(!r)return Js;let n=Vs(s.trigger,i.lib.say),a=Ys(s.delay,0),l=(e,t)=>i.tweens.to(r,{value:e,duration:i.reducedMotion?0:Ys(s.duration,Ws.duration),delay:t,ease:s.ease});if(n==="hover")return Qs(e.el,a,l);if(e._D||i.reducedMotion)return r.value=1,Js;if(n==="manual")return Js;let o=!0,h=Zs(s.repeat),u=!1,d=[],c=t=>(u=!0,e.loaded.then(()=>{o&&u&&l(1,Math.max(0,a-(performance.now()-t)/1e3))})),f=(t,s)=>ei(e.el,d,t,s),m=()=>{if(!o||((n==="load"||n==="auto"&&Xs(e.el))&&c(performance.now()),u&&!h))return;let{rootMargin:t,threshold:a}=Gs(s.start,i.lib.say),d=f((e,t)=>{if(e.isIntersecting&&e.intersectionRatio>=a){if(u)return;h||d.disconnect(),c(performance.now());return}h!=="reverse"||!u||t||e.boundingClientRect.top>=(e.rootBounds?.bottom??innerHeight)&&(u=!1,l(0,0))},{rootMargin:t,threshold:a});h==="replay"&&f((e,t)=>{e.isIntersecting||!u||t||(u=!1,i.tweens.to(r,{value:0,duration:0}))},{threshold:0})},p=i.clock.whenOpen(m);return()=>{o=!1,p();for(let e of d)e.disconnect()}}var si={texture:null},ii=4e3,ri=class{constructor(e){this.stage=e;this.settles=0;this.landing=[]}get ongoing(){return this.stage.env.host.clock.held||this.stage.scheduler.Ug(performance.now())}begin(e,t){let s=this.stage;if(e||(s.scheduler.changing++,s.scheduler.markDirty(),s.chunks.fx?.leave?.Cj()),t)this.leaving=t;else if(e)return;for(let e of s.planes.all)this.named(e)}end(){let e=this.stage;if(--e.scheduler.changing<1){e.scheduler.changing=0,this.stage.scheduler.Xd(1),this.retry(),this.settle(),e.chunks.fx?.leave?.play(),this.leaving=null;for(let t of e.planes.all)this.named(t)}return new Promise(t=>{this.landing.push(t),setTimeout(t,ii),e.scheduler.markDirty()})}land(e,t){if(!(!this.landing.length||e||t.some(e=>e.status==="loading"&&!e.viewTransition))){for(let e of this.landing)e();this.landing.length=0}}named(e){let t=this.stage.scheduler.changing>0&&(!!this.leaving?.contains(e.el)||e.kind!=="layer"&&!/^(none)?$/.test(getComputedStyle(e.el).getPropertyValue("view-transition-name")));t!==e.viewTransition&&(e.viewTransition=t,e.status!=="error"&&(t&&this.stage.env.lib.showFullImages(e.el),Ae(e,!t),this.stage.scheduler.markDirty()))}capture(e,t=!1){let s=s=>t?s?.known(e):s?.capture(e),i=this.settles;this.stage.chunks.morph?s(this.stage.chunks.morph):this.stage.chunks.Xc?.then(e=>{i===this.settles&&s(e)})}settle(){this.settles++,this.stage.chunks.morph?.settle()}retry(){for(let e of this.stage.chunks.morph?.retry()??[])e.zone.near=!0,this.stage.factory.load(e)}flip(e,t,s){let r=ni(e),n=this.stage.planes.all.filter(e=>e.measured&&r.some(t=>t.contains(e.el))),a=n.map(e=>{let t=this.where(e);return e.fly=(e,s,i)=>{e[0]=t[0]-s,e[1]=t[1]-i,e[2]=t[2],e[3]=t[3]},e.stale=!0,t});try{t?.()}catch(e){i.error("umber.flip(): change() threw",e)}return this.stage.scheduler.markDirty(),this.stage.chunks.loadFlip().then(e=>{if(e)return e.fly(n,a,s);for(let e of n)e.fly=null})}where(e){let t=Q(9);return t.set(e.rect),t[0]+=e.scrolls?this.stage.env.frame.scrollX:this.stage.env.frame.pageX,t[1]+=e.scrolls?this.stage.env.frame.scrollY:this.stage.env.frame.pageY,t.set(e.radius,4),t[8]=e._w,t}swap(e){let t=e.prev,s=this.stage.chunks.flip;if(!t)return;let i=e.uniforms,r=()=>{e.prev!==t||!e.texture?.ready||(this.stage.gpu.media.free(t),e.prev=null,i.uPrev&&(i.uPrev.value=si),this.stage.scheduler.markDirty())};if(!i.uSwap||this.stage.env.reducedMotion||!s){r();return}s.swap(e,t,r)}};function ni(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)):e instanceof Element?[e]:Array.from(e??[])}var ai=3e3,li=896;function oi(e,t){let s=String(t).split(/[\s,]+/).map(Number);e.bleed.forEach((t,i)=>{let r=(s.length<4?s[0]:s[i])??0;e.bleed[i]=r>t?r:t})}var hi=class{constructor(e,t,s,i){this.stage=e;this.chunks=t;this.transitions=s;this.observers=i;this.le=0}load(e){let t=this.stage;if(t.gpu.programs.want(e,!1),!(e.textureState!=="none"||t.gpu.context.gone)){if(e.modules.feed){e.textureState="loading";return}switch(e.kind){case"video":t.chunks.video?.load(e);return;case"layer":e.layer&&t.chunks.layers?.setup(e);return;case"text":if(t.chunks.text){t.chunks.text.load(e);return}e.textureState="loading",t.chunks.gh.add(e),t.chunks.loadText();return;case"image":case"shader":case"group":t.gpu.media.loadImage(e)}}}invalidate(e){let t=this.stage;for(let s of t.env.onInvalidate)s(e);for(let s of e?[t.planes.of(e)]:t.planes.all)s&&(s.stale=!0,this.Kk(s));t.scheduler.markDirty()}get following(){return this.le>0}create(e,t){try{this.build(e,t)}catch(t){this.stage.env.lib.tell("threw",[e],i.error,t),e.setAttribute("data-umber-status","error")}}build(e,t){let s=this.stage,i=this.he(e,t),r=i.kind;if(r==="layer"){this.hi(i);return}if(!s.chunks.video&&(r==="video"||this.zb(e).length)){s.chunks.Ml.add(i),this.chunks.loadVideo(),this.track(i,!1);return}let n={glsl:"",segments:1};this.Eb(i,n),this.Kc(i,n),this.cg(i)&&(r==="shader"&&!this.eb(i,n)||(this.qk(i,s.gpu.programs.glsl?.reads(n.glsl)??n.glsl),i.segments=n.segments,this.qd(i)&&(this.track(i),this.arrived(i),this.setUp(i))))}he(e,t){let s=this.stage,i=Qe(this.stage.env.lib.kindOf(e)||"image"),r=this.stage.env.lib.findMedia(e),n=t?t.reset(i):new $s(e,i,s),a=i==="group";n.media=i==="shader"||i==="text"||a?null:r,a||this.stage.env.lib.unmarkMedia(e),n.media&&this.stage.env.lib.markMedia(e,n.media),e.hasAttribute("data-umber-placeholder")&&s.chunks.loadWarm().then(t=>t?.paint(e));let l=e.closest("[data-umber-wrap]");return l&&(n.wrap={axis:l.getAttribute("data-umber-wrap")==="y"?1:0,period:0,start:0}),n.live=this.stage.env.lib.attr.bool(e,"data-umber-live")||this.stage.env.lib.needsLive(e),n.scrolls=s.env.host.scroll.contains(e),n.setStatus(s.scheduler.inactive?null:"loading"),i==="text"&&(s.chunks.text?s.chunks.text.units(n):this.chunks.loadText()),n}hi(e){let t=this.stage.chunks.layers;t?this.track(e,t.create(e)):(this.stage.chunks.loadLayers(),this.track(e,!1),this.chunks.uh("layers"))}Eb(e,t){for(let{name:s,binding:i}of this.be(e)){let r=i.effect;r&&(this.th(e,r.uniforms??{}),t.segments=Math.max(t.segments,this.ec(s,r)),t.glsl+=JSON.stringify([r.vertex,r.fragment]),e.effects.push({name:s,def:r,options:{},ctx:null}))}}Kc(e,t){let s=e.el,i=this.stage.env.registry;for(let r of this.stage.env.lib.attr.list(s,"data-umber-effect")){let n=i.effects.get(r);if(!n){e.missing.push(r),this.stage.env.lib.say("effect",[s,r,[...i.effects.keys()]],s);continue}let a=n.play??"",l=this.Wi(s,r,n);e.glsl||="perspective"in l,this.th(e,n.uniforms??{}),a&&!(a in e.uniforms)&&this.th(e,{[a]:0}),this.wh(e,r,l),n.reduced&&this.stage.env.reducedMotion&&this.th(e,n.reduced),t.segments=Math.max(t.segments,this.ec(r,n)),t.glsl+=JSON.stringify([n.vertex,n.fragment]),e.effects.push({name:r,def:n,options:l,ctx:null}),a&&!e.plays.za.has(a)&&e.plays.za.set(a,l)}}cg(e){let t=e.el;if([...e.plays.za.values()].some(e=>e.hide))t.setAttribute("data-umber-play","");else{if(e.missing.length&&t.hasAttribute("data-umber-play"))return e._L=setTimeout(()=>{e.setStatus(null)},Te),this.track(e,!1),!1;t.removeAttribute("data-umber-play")}return!0}eb(e,t){let s=e.el,i=this.stage.env.registry.shaders,r=s.getAttribute("data-umber-shader")??"",n=i.get(r);if(!n)return e.missing.push(`shader:${r}`),this.stage.env.lib.say("shader",[s,r,[...i.keys()]],s),e.setStatus("error"),this.track(e,!1),!1;let a=this.Qe(s,n);return this.th(e,n.uniforms??{}),this.wh(e,"",a),t.glsl+=n.fragment+(n.head??""),e.shader={name:r,def:n,options:a,ctx:null},!0}qk(e,t){let s=this.stage;e._R(t),this.rd(e,t),t.includes("uBackdrop")&&(this.th(e,{uBackdrop:e.backdrop={texture:null}}),s.chunks.loadFx()),t.includes("uFlow")&&(this.th(e,{uFlow:s.chunks.flow??={texture:s.gpu.renderer.blank.texture}}),s.chunks.loadFx().then(e=>e?.flow())),T.test(t)&&(this.th(e,{uPrev:si,uPrevSize:[1,1],uSwap:1}),s.chunks.loadFlip()),e._z&&e.kind!=="text"&&this.stage.env.lib.say("glyph",[],e.el)}rd(e,t){let s=X(t);for(let[i,r]of Object.entries(e.uniforms)){let e=r.value;ArrayBuffer.isView(e)&&!W(e)&&t.includes(i)&&!s(i)&&this.stage.env.lib.say("texture",[i])}}qd(e){let t=this.stage;if((e._z||e.kind==="text")&&!t.chunks.text)return t.chunks.ae.add(e),this.chunks.loadText(),this.track(e,!1),!1;if(e._z&&!t.chunks.text?.yk.ready())return t.chunks.ae.add(e),this.track(e,!1),!1;if(e.glsl&&!t.gpu.programs.glsl)return e.missing.push("chunk:"),this.chunks.loadGlsl(),this.track(e,!1),this.chunks.uh("glsl"),!1;let s=e.el.getAttribute("data-umber-instances")??e.effects.find(e=>e.def.instances!=null)?.def.instances;if(s!=null){if(!t.chunks.instances)return this.chunks.loadInstances(e),this.track(e,!1),!1;t.chunks.instances.part(e,s)}return t.gpu.programs.prepare(e)?!0:(this.track(e,!1),!1)}arrived(e){let t=this.stage;e.backdrop&&this.chunks.uh("fx"),e.kind==="group"&&(e.textureState="ready",e._o(),t.chunks.loadFx()),e.el.hasAttribute("data-umber-id")&&t.chunks.loadMorph(),t.scheduler.changing&&this.transitions.named(e),(!e.viewTransition&&t.chunks.morph?.claim(e)||e.wrap)&&(e.zone.near=!0,e.kind!=="shader"&&this.load(e))}setUp(e){let t=this.stage;for(let t of e.effects){let s=this.context(e,t.name,t.options);t.ctx=s;try{t.cleanup=t.def.setup?.(s)}catch(e){i.error(`effect "${t.name}" setup failed`,e)}}for(let[s,i]of e.plays.za)e.plays.cleanups.push(ti(e,s,i,{lib:t.env.lib,clock:t.env.host.clock,reducedMotion:t.env.reducedMotion,tweens:t.env.tweens}));let s=e.shader;if(!s)return;let r=this.context(e,s.name,s.options);s.ctx=r;try{s.cleanup=s.def.setup?.(r)}catch(e){i.error(`shader "${s.name}" setup failed`,e)}e.textureState="ready",e._o()}track(e,t=!0){this.stage.planes.add(e),t&&(e._L=setTimeout(()=>{this.dj(e)},ai),this.observers.observe(e))}dj(e){e._L=void 0,!(e.destroyed||!e.measured||!e.el.isConnected||e.status==="error")&&(e.doc.w>0&&e.doc.h>0||this.stage.env.host.loadInspect?.().then(t=>{i.warn(t.zero(e,ai),e.el)},()=>{}))}Gl(e,t){let s=this.stage,i=new $s(e,"layer",s);if(i.live=this.stage.env.lib.needsLive(e),i.scrolls=s.env.host.scroll.contains(e),i.setStatus("loading"),!s.chunks.layers)throw new Error("umber.view(): chunks/layers.js is not here");return s.chunks.layers.build(i,"view",t,{}),this.track(i),s.scheduler.markDirty(),i}Wi(e,t,s){return this.stage.env.lib.config(e,`data-umber-${t}`,s.play?{...Ws,...s.options}:s.options??{})}Qe(e,t){return this.stage.env.lib.config(e,"data-umber-shader",t.options??{})}Kk(e){let t=(t,s,i)=>{let r={};for(let e in t.options)JSON.stringify(s[e])!==JSON.stringify(t.options[e])&&(t.options[e]=s[e],r[e]=s[e]);this.wh(e,i,r)};for(let s of e.effects)t(s,this.Wi(e.el,s.name,s.def),s.name);e.shader&&t(e.shader,this.Qe(e.el,e.shader.def),"")}wh(e,t,s){for(let i in s){let r=s[i];if(i==="bleed"){oi(e,r);continue}let n=typeof r=="string"?Pt(r,e.el,this.stage.env.lib.say)??(r.includes("/")?r:null):r;i==="zoom"&&(e.zoom=Math.max(e.zoom,Number(n)||1)),(typeof n=="number"||typeof n=="boolean"||typeof n=="string"||Array.isArray(n)||n instanceof Float32Array)&&this.th(e,{[q(t,i)]:typeof n=="boolean"?Number(n):n})}}th(e,t){let s=()=>{this.stage.scheduler.markDirty()};for(let i in t){let r=t[i];if(Ns(r)){e.uniforms[i]=new Ls(r,s),e._Z=!0;continue}Array.isArray(r)&&(r=new Float32Array(r)),typeof r=="string"?r=Pt(r,e.el,this.stage.env.lib.say)??this.stage.gpu.media.Wk(r):r instanceof Object&&!("texture"in r)&&!(r instanceof Float32Array&&r.length<=li)&&this.stage.env.lib.say("texture",[i]),e.uniforms[i]=new Fs(r,s)}}context(e,t,s){let i=this.stage,r=e=>{this.le+=e?1:-1};return{name:t,el:e.el,plane:e,engine:i.env.host.engine,options:s,uniforms:e.uniforms,get reducedMotion(){return i.env.reducedMotion},viewport:i.canvasHost.viewport,frame:null,trackMouse(t){if(t!==e._S){if(e._S=t,r(t),t){let t=e.rect;e._m[0]=(i.env.frame.pointer.x-t[0])/Math.max(t[2],1),e.mouse[0]=e._m[0],e._m[1]=(i.env.frame.pointer.y-t[1])/Math.max(t[3],1),e.mouse[1]=e._m[1]}i.scheduler.markDirty()}},busy(s){s?e._U.add(t):e._U.delete(t),i.scheduler.markDirty()},wake(e){i.scheduler.wake(e)},listen(t,s){for(let[e,i]of Object.entries(s))t.addEventListener(e,i);let i=!1,r=()=>{if(!i){i=!0;for(let[e,i]of Object.entries(s))t.removeEventListener(e,i)}};return e.listeners.push(r),r}}}zb(e){return[...this.stage.env.registry.modules].filter(([t,s])=>s.module.plane&&(s.module.attributes?.length?s.module.attributes:[t]).some(t=>e.hasAttribute(`data-umber-${t}`)))}be(e){let t=e.el,s=this.stage.env.registry.modules;this.stage.chunks.video?.bind(e);for(let i in Tt)s.has(i)||!t.hasAttribute(`data-umber-${i}`)||(e.missing.push(`module:${i}`),this.stage.env.lib.say("module",[t,i],t));return e.modules.list}ec(e,t){let s=Number(t.segments)||1;return s<=ss?s:(this.stage.env.lib.say("segments",[e,s,ss]),ss)}j(e,t=!1){if(e.destroyed)return;let s=this.stage;e.destroyed=!0,clearTimeout(e._L);for(let t of e.effects)try{typeof t.cleanup=="function"&&t.cleanup()}catch(e){i.error(`effect "${t.name}" cleanup failed`,e)}Bs(e.listeners),e.listeners=[];try{typeof e.shader?.cleanup=="function"&&e.shader.cleanup()}catch(t){i.error(`shader "${e.shader?.name}" cleanup failed`,t)}for(let t of e.parts())t?.dispose(e);e._S&&this.le--,e._S=!1,e._E?.(),e._E=null,s.gpu.media.forget(e),s.gpu.media.release(e),s.gpu.media.free(e.prev),e.prev=null,this.observers.forget(e),s.planes.forget(e),t||s.env.tweens.Bj(Object.values(e.uniforms)),e.status!=="error"&&e.setStatus(null),e.el.removeAttribute("data-umber-morphing"),e.el.removeAttribute("data-umber-play"),this.stage.env.lib.unmarkMedia(e.el),t||e.emit("destroy")}};var ui=1e3,di=class{constructor(e,t){this.stage=e;this.own=t;this.Ki=[];this.Y=0;this.hold=0}run(e,t){let s=this.stage,i=performance.now(),r=s.env.stats;r.planes=s.planes.all.length,r.visible=s.planes.visible.length,r.programs=s.gpu.programs.size,this.upload()&&(t=!0);let n=!1;if(t&&s.gpu.programs.turn()&&this.hold>=0&&(i<(this.hold||=i+Gt)?(s.scheduler.uc(1),t=!1,n=!0):this.hold=-1),s.gpu.programs.Kj(n),!t){this.Y=0,r.skipped++,s.scheduler.Ra="idle",this.own.ic(!1);return}let a=s.gpu.renderer.draw(e);a&&(this.hold=-1,s.gpu.programs.opened());for(let e of s.planes.all)e.visible||(e._l[0]=NaN);this.own.drawn(),s.scheduler.$d(),s.gpu.renderer.list.some(ci)&&s.scheduler.uc(1);let l=performance.now();this.Y=l-i,r.renders++,r.draws=a,s.scheduler.Ra="active",r.frameMs=Math.round(e.dt*1e4)/10,r.fps=Math.round(1/e.dt),this.Ki.push(l),r.rendersPerSec=this.perSecond(l),s.gpu.renderer.fd(e)&&this.own.resize(),this.own.ic(!0)}upload(){let e=this.stage,t=!1;do{e.gpu.media.Mg(e.chunks.vl?0:this.Y)&&(t=!0)}while(e.chunks.vl&&e.gpu.media.uploads.length);let s=e.chunks.video;if(s)for(let i of e.planes.all)i.modules.frames?.pending&&s.feed(i)&&(t=!0);return t}perSecond(e){let t=this.Ki;for(let s=t[0];s!==void 0&&e-s>ui;s=t[0])t.shift();return t.length}},ci=e=>e.state.status==="loading"&&e.state.drawnFrame!==null;function fi(e,t,s,i){let r=1-Math.min(1,Math.max(0,s));return e+(t-e)*(1-Math.pow(r,Math.max(0,i)*60))}var mi=3600,pi=2,gi=.12,vi=5e-4,bi=.15,yi=5e-4,wi=e=>{let t=e.uniforms;for(let[s,i]of e.plays.za)if(i.trigger==="hover"&&t[s]?.value>0)return!0;return!1},xi=class{constructor(e,t,s){this.stage=e;this.transitions=t;this.own=s;this.xj={changed:!1,busy:!1}}result(e,t){let s=this.xj;return s.changed=e,s.busy=t,s}run(e){let t=this.stage,s=t.env.reducedMotion;s||(t.env.frame.time=e.time);let i=t.canvasHost.viewport.width,r=t.canvasHost.viewport.height,n=this.own.stepTweens(e.time),a=this.Bk(e,s),l=this.own.dirty()||t.scheduler.forced>0||n,o=!1;t.chunks.shapes?.frame(i,r),t.planes.hb();let h=t.planes.visible,u=h.length;h.length=0;let d=t.env.frame.velocity!==0||a!==0,c={frame:e,vw:i,vh:r,still:s,scrolling:d,sx:0,sy:0};for(let e of t.planes.all)if(!e.destroyed)try{let t=this.Pd(e,c,l);t.changed&&(l=!0),t.busy&&(o=!0)}catch(s){t.fallbacks.E(e,s)}!o&&t.gpu.media.uploads.some(Mi)&&(o=!0),h.length!==u&&(l=!0);let f=!!t.chunks.morph?.update(t.env.now);f&&(l=!0),this.transitions.land(f,h),Ci(h,e);let m=t.scheduler.Ug(performance.now()),p=l||o||m;return t.env.stats.busy=this._U(h,m,f,n),[n,f,d].includes(!0)&&t.gpu.programs.moved(),p}Bk(e,t){let s=this.stage,i=t?0:Math.max(-1,Math.min(1,(e.scroll.velocity||0)/mi)),r=s.env.frame.velocity;return s.env.frame.velocity=fi(s.env.frame.velocity,i,gi,e.dt),Math.abs(s.env.frame.velocity)<vi&&i===0&&(s.env.frame.velocity=0),s.env.host.velocity.value=s.env.frame.velocity,r}Pd(e,t,s){let i=this.stage,r=t.sx=e.scrolls?i.env.frame.scrollX:i.env.frame.pageX,n=t.sy=e.scrolls?i.env.frame.scrollY:i.env.frame.pageY,a=qe(e,r,n);ki(e,a,t),e.fly?.(a,r,n),this.fh(e,a,r,n);let l=this.Sf(e,t.frame,a);e.visible=Ei(e,a,t),this.clip(e,a)&&(l=!0);let o=e.visible?i.planes.visible.push(e)-1:-1;return o!==e.listed&&(e.listed=o,l=!0),o<0?this.result(l,!1):(this.sd(e,a,t,s||l)&&(l=!0),this.result(l,Ri(e,t.still)))}clip(e,t){let s=this.stage.chunks.shapes;if(!e.clips||!s||(e.clips.Sh=null,!e.visible))return!1;let i=s.clip(e.clips,t,e.bends);return i.visible||(e.visible=!1),i.moved}sd(e,t,s,i){let r=Si(e,t);r&&this.stage.gpu.programs.moved();let n=!i&&r,a=Ze(t,this.stage.env.frame.screen.height);return a!==e.progress&&(e.progress=a,e.reads.has("progress")&&(n=!0)),Ti(e)&&(n=!0),e.kind==="video"&&e._U.has("video")&&(e.videoFrame=!0),e._S&&this.Pe(e,t,s)&&(n=!0),Ai(e,s.frame),e.kind==="video"&&e.videoFrame&&Pi(e)&&(n=!0),s.scrolling&&(e.reads.has("velocity")||e.layer)&&(n=!0),n}fh(e,t,s,i){let r=this.stage.chunks.shapes;if(e.level&&!e.xfReason&&r){r.fh(e,s,i);return}let n=e._s;n[0]=1,n[4]=1,n[8]=1,n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=t[0],n[7]=t[1],e.size[0]=t[2],e.size[1]=t[3]}Sf(e,t,s){let r=!1;if(!e.modules.list.length||!(e.zone.near||e.zone.soon)||e.status==="error")return r;for(let n of e.modules.list)if(n.binding.update)try{n.binding.update(t,s,this.stage.env.frame.screen)&&(r=!0)}catch(e){i.error(`module "${n.name}" update failed`,e),n.binding.update=void 0}return r}Pe(e,t,{sx:s,sy:i,frame:r}){let n=r.dt,a=this.stage,l=a.env.frame.pointer;e.level&&!e.xfReason&&a.chunks.shapes?a.chunks.shapes.pointer(e,l.x+s,l.y+i):(e._m[0]=(l.x-t[0])/Math.max(t[2],1),e._m[1]=(l.y-t[1])/Math.max(t[3],1));let o=e._m[0],h=e._m[1],u=Math.abs(o-e.mouse[0])+Math.abs(h-e.mouse[1])<yi,d=u?o:fi(e.mouse[0],o,bi,n),c=u?h:fi(e.mouse[1],h,bi,n);return Math.fround(d)===e.mouse[0]&&Math.fround(c)===e.mouse[1]?!1:(e.mouse[0]=d,e.mouse[1]=c,!0)}_U(e,t,s,i){let r=this.stage,n=[];t&&n.push("live"),r.gpu.media.uploads.length&&n.push("upload"),r.env.frame.velocity!==0&&n.push("scroll"),s&&n.push("morph"),i&&n.push("tween");let a=this.own.ch();a&&n.push(`dom-watch:${this.stage.env.lib.describe(a)}`);for(let t of e)t._U.forEach(e=>n.push(e)),t.reads.has("time")&&wi(t)&&n.push("hover"),t.shader&&t.shader.def.animate!==!1&&n.push(`shader:${t.shader.name}`);return n}};function ki(e,t,s){let i=e.wrap;if(!i?.period)return;let r=i.axis,n=r?t[3]:t[2],a=i.start-(r?s.sy:s.sx);t[r]=a+((t[r]-a+n)%i.period+i.period)%i.period-n;let l=_i(t,s);l!==e.zone.screen&&(e.zone.screen=l,e.modules.tell(e=>e.visible?.(l)),e.emit(l?"enter":"leave")),!l&&e.status==="loading"&&e.texture?.ready&&e.program?.ready()&&e.setStatus("ready")}var _i=(e,t)=>e[0]<t.vw&&e[0]+e[2]>0&&e[1]<t.vh&&e[1]+e[3]>0;function Ei(e,t,s){return e.el.isConnected&&e.status!=="error"&&e.textureState!=="error"&&(!!e.program||!!e.layer)&&t[2]>0&&t[3]>0&&(e.opacity>.001||e.layer?.def.followOpacity===!1)&&!e.backHidden&&!e.shapeWait&&_i(t,s)}function Si(e,t){if(zi(e))return!1;let s=e._l;if(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])return!0;if(e.level){let t=e._s,s=e._p;for(let e=0;e<9;e++)if(t[e]!==s[e])return!0}return e.opacity!==e._V}var Mi=e=>e.plane.visible||e.plane.zone.screen;function zi(e){if(e.modules.feed||e.kind==="shader"||e.kind==="layer"||e.texture?.ready||e.prev?.ready)return!1;let t=e.kind==="video"?e.media:null;return!(t&&e.videoFrame&&(t.readyState||0)>=pi)}function Ti(e){if(!e._Z)return!1;let t=!1;for(let s in e.uniforms){let i=e.uniforms[s];i instanceof Ls&&i.changed()&&(t=!0)}return t}function Ai(e,t){for(let s of e.effects){let e=s.ctx;if(!(!s.def.update||!e)){e.frame=t;try{s.def.update(e)}catch(e){i.error(`effect "${s.name}" update failed`,e),s.def={...s.def,update:void 0}}}}let s=e.shader,r=s?.ctx;if(!(!s?.def.update||!r)){r.frame=t;try{s.def.update(r)}catch(e){i.error(`shader "${s.name}" update failed`,e),s.def={...s.def,update:void 0}}}}function Ri(e,t){return e._U.size?!0:t?!1:e.reads.has("time")&&wi(e)?!0:!!e.shader&&e.shader.def.animate!==!1||!!e.layer?.ready&&e.layer.def.animate!==!1}var Pi=e=>(e.media?.readyState??0)>=pi;function Ci(e,t){for(let s of e){let e=s.state;e.status==="loading"&&e.drawnFrame!==null&&e.drawnFrame<t.frame&&s.setStatus("ready"),s._D&&s.status==="ready"&&!s.morphHidden&&s.el.removeAttribute("data-umber-morphing")}}var Ui=1.5,Fi=1,Li=60,Ni=1.5,Ii="[data-umber~=group],[data-umber-wrap]";function ji(e){let t=e.getBoundingClientRect();return Math.max(0,-t.bottom/innerHeight,t.top/innerHeight-1,-t.right/innerWidth,t.left/innerWidth-1)}var Di=250,$i=class{constructor(e,t){this.stage=e;this.own=t;this.watched=null;this.slides=new Oi;this.batches=0;this.arrived=!1;this.first=0}get gk(){return this.batches}get jc(){return this.batches+(this.stage.env.host.changes?.()??0)}_f(){this.batches++}scan(e){this.Od();let t=!!n()||this.stage.scheduler.inactive,s=this.stage.env.lib.findGL(e).filter(e=>!this.stage.planes.of(e)),i=s.map(e=>t||this.pa(e));s.forEach((e,t)=>{i[t]?this.stage.factory.create(e):this.arrived=!!this.stage.planes.later.add(e)}),this.stage.scheduler.markDirty()}pa(e){let t=e.getAttribute("data-umber-id");return!!e.closest(Ii)||!!t&&!!this.stage.chunks.morph?.flies(t)||ji(e)<=Ni}later(){let{planes:e,scheduler:t}=this.stage;if(!e.later.size)return;if(t.request(),this.arrived)return this.first=Li,void(this.arrived=!1);let s=performance.now(),i=[...e.later].map(e=>[e.isConnected?ji(e):0,e]),r=i.filter(([e])=>e>Ni);for(let[t,s]of i)t<=Ni&&e.build(s);if(!(this.first-- >0&&e.all.some(e=>e.zone.screen&&e.status==="loading"))){r.sort((e,t)=>e[0]-t[0]);for(let[,t]of r)if(e.build(t),performance.now()-s>Fi)break}}ch(){let e=this.watched;return this.watched=null,e}apply(e){e.still||this.batches++,(e.styles||e.added.length)&&this.Od();for(let t of e.pe){let e=this.stage.planes.of(t);e&&this.stage.planes.remove(e)}this.qa(e);let t=this.Be(e),s=this.Ka(e)||t;s&&(this.own.Xd(Ui),this.stage.chunks.fx?.leave?.swap()),e.touched.length&&this.ab(e.touched),this.Pg(e),s&&this.stage.measurePhase.ma()}Pg(e){if(e.look)for(let e of this.stage.planes.all)e.status==="error"&&(e.stale=!0);if(e.styles){for(let e of this.stage.planes.all)e.stale=!0;this.stage.measurePhase.ma(),this.stage.scheduler.markDirty()}(e.styles||e.touched.some(e=>e===document.documentElement||e===document.body))&&this.stage.canvasHost.check()}qa(e){for(let t of e.sources){let s=this.stage.planes.of(t);s?.kind==="image"&&s.textureState!=="none"?this.stage.gpu.media.loadImage(s,!0):s?.kind==="video"&&this.stage.chunks.video?.Ie(s,e.pe)}}Ka(e){if(!e.removed&&!(e.detached&&this.stage.planes.all.some(e=>!e.el.isConnected)))return!1;let t=this.stage.planes.all.length;return this.stage.planes.prune(),this.stage.planes.all.length>=t?!1:(this.stage.transitions.retry(),!0)}Be(e){let t=[...e.added,...e.pe];if(!t.length)return!1;for(let t of e.added)this.stage.chunks.video?.Lk(t);let s=[...new Set(t.flatMap(e=>this.stage.env.lib.findGL(e)))];this.stage.chunks.fx?.groups.moved();for(let e of s){let t=this.stage.planes.of(e);t&&(t.stale=!0,this.stage.planes.dd=!0,this.stage.chunks.morph?.forget(t)&&this.stage.planes.attach(t))}let i=s.filter(e=>!this.stage.planes.of(e));if(!i.length)return!1;i.some(e=>e.hasAttribute("data-umber-id"))&&this.stage.chunks.morph?.capture(null,!0);let r=!!n()||this.stage.scheduler.inactive,a=i.map(e=>r||this.pa(e));return i.forEach((e,t)=>{a[t]?this.stage.factory.create(e):this.arrived=!!this.stage.planes.later.add(e)}),this.stage.chunks.morph?.settle(!1),e.added.some(e=>e!==document.documentElement)}ab(e){let t=!1,s=new Map,i=e=>(s.has(e)||s.set(e,this.slides.slid(e)),s.get(e)??null);for(let s of this.stage.planes.all){let r=e.find(e=>Bi(e,s));if(r){if(s.status==="error"){this.va??=setTimeout(()=>{this.va=void 0;for(let e of this.stage.planes.all)e.status==="error"&&(e.stale=!0);this.stage.scheduler.request()},Di);continue}this.follow(s,e,i)||(s.stale=!0),t=!0,this.watched=r}}t&&(this.stage.measurePhase.ma(),this.stage.scheduler.markDirty())}follow(e,t,s){if(e.level)return!1;let i=0,r=0;for(let n of t){if(!Bi(n,e))continue;let t=n===e.el?null:s(n);if(!t)return!1;i+=t[0],r+=t[1],this.stage.measurePhase.ui(n)}return e.doc.x+=i,e.doc.y+=r,!0}Od(){!this.stage.chunks.shapes&&document.querySelector("[data-umber-occlude]")&&this.stage.chunks.loadShapes(),document.querySelector("[data-umber-pass]")&&this.stage.chunks.loadFx()}};function Bi(e,t){return e===t.el?!0:e.contains(t.geomEl)?t.zone.soon||t.visible||e!==document.documentElement&&e!==document.body:!1}var Hi=e=>!!e&&e!=="none",Oi=class{constructor(){this.seen=new WeakMap}slid(e){let{transform:t,translate:s,rotate:i,scale:r}=getComputedStyle(e),n=t.split(","),[a,l]=n.splice(n.length>6?12:4,2).map(parseFloat),[o=0,h=0]=Hi(s)?s.split(" ").map(parseFloat):[],u=!Hi(i)&&!Hi(r)&&!/[%(]/.test(s)&&(a!==void 0||Hi(s))?[(a??0)+o,(l??0)+h]:null,d=String(e.getAttribute("class"))+(e.getAttribute("style")??"").replace(/(^|;)\s*(transform|translate)\s*:[^;]*/g,"")+String(n),c=this.seen.get(e);return this.seen.set(e,{key:d,move:u}),c?.key===d&&u&&c.move?[u[0]-c.move[0],u[1]-c.move[1]]:null}};var Wi=.016666666666666666,qi=15,Vi=class{constructor(e){this.ask=e;this.scale=1;this.index=0;this.te=!1;this.settle=30;this.refresh=Wi;this.slow=0;this.last=1/0;this.fk=-1}frame(e,t){let s=e.frame-this.fk===1;this.fk=e.frame;let i=s?Math.max(this.last,e.dt):1/0;this.last=e.dt,i<this.refresh&&(this.refresh=i);let r=e.dt*60;return this.settle>0||t?this.settle=Math.max(0,this.settle-r):s&&(e.dt>this.refresh*1.5?this.slow+=Math.min(r,qi):e.dt<this.refresh*1.2&&(this.slow=Math.max(0,this.slow-r)),this.slow>qi&&this.ask()),!1}hj(){this.settle=30,this.slow=0}rest(e){this.settle=Math.max(this.settle,e)}reset(){this.refresh=Wi,this.last=1/0,this.settle=30}},Xi={high:2,mid:1.5,low:1},Gi=.8;function Ki({option:e,tier:t,width:s,height:i,budget:r=12e6,wide:n=1/0}){let a=0,l;typeof e=="number"&&e>0?l=e:Array.isArray(e)?(a=Math.max(0,e[0]||0),l=e[1]||Xi[t]):l=(e&&typeof e=="object"?e[t]:void 0)??Xi[t],s>n&&(l=Math.min(l,Gi));let o=Math.max(a,Math.min(typeof devicePixelRatio=="number"&&devicePixelRatio||1,l)),h=s*i;return h*o*o>r&&(o=Math.sqrt(r/Math.max(h,1))),o}var Yi=12e6,Zi=class{constructor(e,t,s,i){this.stage=e;this.ownership=s;this.own=i;this.reason=null;this.viewport={width:1,height:1};this.dpr=1;this.Cf=!0;this.ratio=1;this.el=t}Ae(){this.Cf=!0}Vk(){this.Cf&&this.resize()}check(){if(this.stage.env.destroyed)return;let e=Ie(this.el,this.ownership,this.stage.env.lib);e!==this.reason&&(this.reason=e,this.stage.gpu.canvas.style.display=e?"none":"",e&&this.stage.env.lib.say("host",[e,this.ownership==="created"]),e?this.stage.scheduler.hold("host"):this.stage.scheduler.release("host"))}keep(){if(this.stage.gpu.context.off||this.stage.env.destroyed)return!1;let e=document.documentElement;e.classList.contains("has-umber")||e.classList.add("has-umber");let t=this.stage.gpu.canvas;if(t.isConnected)return!1;document.querySelectorAll("[data-umber-canvas]").forEach(e=>{(this.ownership==="created"&&e.parentElement?.hasAttribute("data-umber-host")?e.parentElement:e).remove()});let s=this.el,r=this.ownership==="created"?null:this.Hb(),n=r?.isConnected?r:s;return n.isConnected||(document.body.prepend(n),this.ownership==="site"&&this.stage.env.host.loadInspect?.().then(e=>{i.warn(e.hostLeft)},()=>{})),n!==s&&(this.own.Ab(s,n),this.el=n),t.parentElement!==n&&n.appendChild(t),this.Cf=!0,this.check(),this.stage.factory.invalidate(),!0}Hb(){let e=this.stage.env.options.host;return e instanceof HTMLElement?e:document.querySelector(typeof e=="string"?e:"[data-umber-host]")}resize(){this.Cf=!1,this.stage.gpu.renderer.adaptive.hj();let e=this.el.clientWidth||window.innerWidth,t=this.el.clientHeight||window.innerHeight;this.viewport.width=e,this.viewport.height=t;let s=this.stage.chunks.vl?this.stage.chunks.vl.dpr(e,t):Ki({option:this.stage.env.options.dpr,tier:this.stage.gpu.tier.tier,width:e,height:t,budget:Number(this.stage.env.options.pixelBudget)||Yi,wide:this.stage.gpu.tier.wide});this.dpr=s,devicePixelRatio!==this.ratio&&(this.ratio=devicePixelRatio,this.stage.planes.all.forEach(e=>{this.stage.gpu.media.sharpen(e)}));let i=s*this.stage.gpu.renderer.adaptive.scale,r=Math.max(1,Math.round(e*i)),n=Math.max(1,Math.round(t*i));(this.stage.gpu.canvas.width!==r||this.stage.gpu.canvas.height!==n)&&(this.stage.gpu.canvas.width=r,this.stage.gpu.canvas.height=n,this.stage.chunks.views?.resized(r,n)),this.stage.env.stats.dpr=Math.round(s*100)/100,this.stage.env.stats.width=r,this.stage.env.stats.height=n,this.stage.scheduler.uc(1)}};function Ji(e){return{onScreen:Xs,ease:t=>Us(t,e),Texture:ls,Plane:$s,bitmap:fs}}function Qi(e,t){let s=e.el.compareDocumentPosition(t.el);return s&1?Number(t.el.isConnected)-Number(e.el.isConnected):s&2?1:-1}var er=class{constructor(e,t){this.stage=e;this.own=t;this.visible=[];this.items=[];this.dd=!1;this.Wj=new WeakMap;this.later=new Set}get all(){return this.items}of(e){return this.build(e),this.Wj.get(e)}build(e){this.later.delete(e)&&e.isConnected&&this.own.create(e)}list(e){for(let e of this.later)this.build(e);return!e||e===document?this.items.slice():this.items.filter(t=>e.contains(t.el))}hb(){this.dd&&(this.dd=!1,this.items=this.items.slice().sort(Qi))}add(e){this.dd=!0,this.items.push(e),this.Wj.set(e.el,e)}forget(e){this.Wj.get(e.el)===e&&this.Wj.delete(e.el)}detach(e){let t=this.items.indexOf(e);t!==-1&&this.items.splice(t,1),this.stage.scheduler.markDirty()}attach(e){this.items.includes(e)||this.items.push(e),this.dd=!0,e.stale=!0,this.stage.scheduler.markDirty()}discard(e){this.detach(e),e.el.isConnected||this.stage.chunks.video?.release(e),this.own.destroy(e)}remove(e){this.items=this.items.filter(t=>t!==e),this.own.destroy(e),this.stage.scheduler.markDirty()}Al(e){let t=this.of(e);t&&this.remove(t)}prune(){let e=[],t=this.stage.chunks.morph;for(let s of this.items)if(s.el.isConnected)e.push(s);else{if(t?.holds(s)||t?.keep(s))continue;this.stage.chunks.video?.release(s),this.own.destroy(s)}this.items=e,this.stage.scheduler.markDirty()}clear(){this.later.clear();for(let e of this.items)this.own.destroy(e);this.items=[]}pe(e){let t=this.stage.env.tweens,s=Object.entries(e.uniforms).filter(([,e])=>t.of(e)!==null);this.items=this.items.filter(t=>t!==e),this.own.destroy(e,!0),this.own.create(e.el,e),e.replay();for(let[t,i]of s)e.uniforms[t]=i;this.stage.scheduler.markDirty()}defined(e,t){let s=e==="effect"?t:`${e}:${t}`;for(let i of this.items.slice())(i.missing.includes(s)||e==="layer"&&i.kind==="layer"&&!i.layer&&tt(i.el)===t)&&i.el.isConnected&&this.pe(i)}redefined(e,t){let s=this.stage.gpu.programs.drop(e,t),i=i=>{switch(e){case"effect":return i.effects.some(e=>e.name===t);case"shader":return i.shader?.name===t;case"chunk":return!!i.program&&s.includes(i.program);case"layer":return i.kind==="layer"&&!!i.layer&&tt(i.el)===t}};for(let e of this.items.slice())i(e)&&e.el.isConnected&&this.pe(e);if(!this.stage.chunks.morph?.busy)for(let e of s)this.items.some(t=>t.program===e)||e.dispose()}};var tr=class{constructor(e,t,s,i=0){this.vars=t;this.P=i;this.from=0;this.progress=0;this.done=!1;this.paused=!1;this.vj=NaN;this.velocity=0;this.at=1/0;this.now=NaN;this.list=null;this.ci=null;this.resolve=null;this.promise=null;this.target=e,this.to=t.value,this.duration=Math.max(0,(t.duration??1)||0),this.delay=Math.max(0,(t.delay??0)||0),this.ease=Us(t.ease,s);let r=this.ease.spring;r&&this.duration>0&&(this.ci=[r[0],r[1]/this.duration])}step(e){if(this.done)return!1;if(this.now=e,this.paused)return!0;Number.isNaN(this.vj)&&(this.vj=e);let t=e-this.vj-this.delay;if(t<0)return!0;this.progress===0&&(this.from=Number(this.target.value)||0),this.progress=this.duration>0?Math.min(1,t/this.duration):1;let s=this.ci?this.yd(this.ci,t):this.El(e);return this.at=e,this.vars.onUpdate?.(),s?(this.finish(),this.vars.onComplete?.(),!1):!0}El(e){let t=this.from+(this.to-this.from)*this.ease(this.progress);return e>this.at&&(this.velocity=(t-(Number(this.target.value)||0))/(e-this.at)),this.target.value=t,this.progress>=1}yd(e,t){let s=e[1],i=this.from-this.to,[r,n]=ys(e,i,this.P,t),a=.001*Math.max(Math.abs(i),Math.abs(this.P)/s,1e-9),l=Math.abs(r)<a&&Math.abs(n)<a*s;return this.target.value=l?this.to:this.to+r,this.velocity=l?0:n,l}pause(){return!this.done&&!this.paused&&(this.paused=!0,this.vj=this.time-this.vj),this}play(){return this.paused&&(this.paused=!1,this.vj=this.time-this.vj,this.list?.wake()),this}get time(){return this.list?this.list.now:this.now}kill(){return this.finish(),this}then(e,t){return this.promise??=new Promise(e=>{this.done?e(void 0):this.resolve=()=>{e(void 0)}}),this.promise.then(e,t)}finish(){this.done||(this.done=!0,this.resolve?.(),this.resolve=null)}},sr=class{constructor(e,t=()=>{},s=null){this.say=e;this.wake=t;this.clock=s;this.list=[];this.time=0;this.stepped=!1}get now(){return this.clock?this.clock():this.time}to(e,t){(typeof t.value!="number"||!Number.isFinite(t.value))&&this.say("tween",[t.value]);let s=this.of(e);this.Bj(e);let i=new tr(e,t,this.say,s&&!(Number(t.delay)>0)?s.velocity:0);return i.duration===0&&i.delay===0?(i.step(this.time),i):(i.vj=this.clock||this.stepped?this.now:NaN,i.list=this,this.list.push(i),this.wake(),i)}step(e){if(this.time=e,this.stepped=!0,!this.list.length)return!1;let t=!1;for(let s of this.list.slice())s.step(e)&&!s.paused&&(t=!0);return this.list=this.list.filter(e=>!e.done),t}Bj(e){let t=new Set(Array.isArray(e)?e:[e]);for(let e of this.list)t.has(e.target)&&e.kill();this.list=this.list.filter(e=>!e.done)}of(e){return this.list.find(t=>t.target===e&&!t.done)??null}get size(){return this.list.length}clear(){for(let e of this.list)e.kill();this.list=[]}};var ir=class{constructor(){this.scrollX=0;this.scrollY=0;this.pageX=0;this.pageY=0;this.scrolled=!1;this.velocity=0;this.pointer={x:-1,y:-1};this.time=0;this.screen={width:1,height:1};this.cc=new Map}};var rr=class{constructor(e,t,s,i){this.host=e;this.kit=t;this.stats=s;this.frame=new ir;this.onInvalidate=new Set;this.cleanups=[];this.destroyed=!1;this.options=e.options,this.registry=e.registry,this.lib=e.lib;let r=0,n=0;this.tweens=new sr(e.lib.say,i,()=>e.ticker.frame.time-n),this.stepTweens=e=>{let t=e-r;return t>.05&&t<=.5&&(n+=t-.05),r=e,this.tweens.step(e-n)}}get reducedMotion(){return this.options.reducedMotion!=="off"&&this.host.env.reducedMotion}get now(){return this.host.ticker.frame.time*1e3}listen(e,t,s,i=!0){e.addEventListener(t,s,{passive:i}),this.cleanups.push(()=>{e.removeEventListener(t,s)})}};var nr=/\.ktx2(?:[?#]|$)/i,ar=null,lr=null,or=()=>ar??=import(new URL("./basis.js",import.meta.url).href).then(e=>lr=e),hr=()=>document.querySelector('meta[name="umber-assets"]')?.content??"",ur=1.25,dr=e=>ur*e.zoom,cr=1.5,fr=4,mr=8*2**20,pr=.9;function gr(e){n()?a().then(e):"requestIdleCallback"in window?requestIdleCallback(e,{timeout:2e3}):setTimeout(e,200)}var vr=(...e)=>e.find(e=>!!e)??"";var br=class{constructor(e){this.stage=e;this.place=Oe;this.idle=gr;this.uploads=[];this.kd=new Map;this.Ef=new Map;this.images=new Map;this.warned=!1;this.cl=null;this.loadPrepared=()=>import(new URL("./prepared.js",import.meta.url).href);this.manifests=new Map}get Sj(){return this.kd.size+this.images.size}get vc(){let e=0;for(let t of this.images.values())e+=t.bytes;return e}release(e){let t=e.texture;return e.texture=null,this.free(t)}free(e){if(!e||--e.refs>0)return!1;for(let[t,s]of this.images)s===e&&this.images.delete(t);return e.dispose(),!0}loadImage(e,t){if(t&&e.textureState==="error")return;let s=this.stage,i=e.media,r=e.el.getAttribute("data-umber-src"),n=()=>vr(r,i?.currentSrc,i?.src),a=n(),l=++e.loads;e.textureState="loading";let o=i=>{if(l!==e.loads||e.destroyed||s.gpu.context.gone)return;if(e.loads++,!i){this.stage.env.lib.say("image",[]),e.textureState="error",e.setStatus("error");return}let r=this.images.get(i);if(!r||e.texture!==r){t&&e.texture?.ready&&!e.prev?(e.prev=e.texture,e.texture=null):this.release(e);let n=!r;r||this.images.set(i,r=new ls(s.gpu.gl)),r.refs++,e.texture=r,n&&this.fetch(i,r)}this.sharpen(e),r.ready&&(e.textureState="ready",Oe(e),e._o(),e.prev&&s.transitions.swap(e),s.scheduler.markDirty())};if(!r&&i&&(t||!i.currentSrc)&&!i.complete){let e=new AbortController,t=()=>{e.abort(),clearTimeout(r),o(n())};i.addEventListener("load",t,{signal:e.signal}),i.addEventListener("error",t,{signal:e.signal});let r=setTimeout(()=>{if(!i.currentSrc){if(!i.srcset){o(i.src);return}s.chunks.loadWarm().then(e=>{i.currentSrc||o((e?e.pick(i):"")||i.src)})}},4e3);return}o(a)}fetch(e,t,s,i=!1){let r=this.stage,n={src:e,tex:t,was:s,box:[0,0]},a=()=>{for(let e of this.df(t))n.box[0]=Math.max(n.box[0],e.doc.w*r.canvasHost.dpr*dr(e)),n.box[1]=Math.max(n.box[1],e.doc.h*r.canvasHost.dpr*dr(e));return i&&s?.[0]&&(n.box[0]=Math.max(n.box[0],te(s,0)*2),n.box[1]=Math.max(n.box[1],te(s,1)*2)),n.box[0]?n.box:this.cap(n.box)},l=nr.test(e)?"":hr(),o;l?o=this.O(l,n,a):nr.test(e)?o=this.transcode(n,a):o=fs(e,r.gpu.tier.maxTexture,a),o.then(e=>{this.decoded(n,e)}).catch(e=>{this.Ec(n,e)})}async transcode(e,t){try{let{image:s,box:i}=await(await or()).loadKtx2(this.stage.gpu.gl,e.src,t);return e.box=i,s}catch(s){let i=this.df(e.tex).find(e=>e.media instanceof HTMLImageElement)?.media,r=vr(i?.currentSrc,i?.src);if(!r||e.tex.ready)throw s;return this.stage.env.lib.say("ktx2",[e.src],s),fs(r,this.stage.gpu.tier.maxTexture,t)}}async O(e,t,s){let r=this.stage,n=r.gpu.tier.maxTexture;try{let i=this.cl??=await this.loadPrepared(),a=this.manifests,l=await i.get(r.gpu.gl,{manifest:e,src:t.src,size:s,maxTexture:n,reads:a});if(l&&"image"in l)return t.box=l.box,l.image;if(l)return await fs(l.avif,n,s)}catch(e){i.info("prepared failed",t.src,e)}return fs(this.mi(t)??t.src,n,s)}mi(e){for(let t of this.df(e.tex)){let e=t.el.querySelector("[data-umber-tiny]+source")?.srcset.trim().split(/[\s,]/)[0];if(e)return e}return null}df(e){return this.stage.planes.all.filter(t=>t.texture===e)}decoded({src:e,tex:t,was:s,box:i},r){let n=this.stage;t.box=i,(te(i,2)>n.gpu.tier.maxTexture||te(i,3)>n.gpu.tier.maxTexture)&&n.chunks.loadWarm().then(t=>t?.note(e,i));let a=this.df(t),l=a.find(e=>e.status!=="error"||e.slow||t.ready&&e.domReason);if(!l){"close"in r&&r.close(),this.unclaimed(e,t,s,a);return}for(let e of a)e.textureState==="loading"&&(e.textureState="queued");this.Yh(l,r,t),a.some(e=>e.visible||e.zone.screen)?n.scheduler.markDirty():n.scheduler.request()}unclaimed(e,t,s,i){if(t.ready){s&&(t.box=s);return}this.images.get(e)===t&&this.images.delete(e);for(let e of i)e.domReason&&e.textureState==="loading"&&(e.textureState="none")}Ec({src:e,tex:t,was:s},i){if(t.ready){s&&(t.box=s);return}this.images.get(e)===t&&this.images.delete(e);for(let s of this.df(t))this.stage.env.lib.say("cors",[s.el,e],i),s.textureState="error",s.setStatus("error")}cap(e,t=0){let s=this.stage.canvasHost.dpr*ur;return e[0]=(t||innerWidth)*s,e[1]=t?0:innerHeight*s,e}sharpen(e){let t=this.stage,s=e.texture,i=t.canvasHost.dpr;if(!s?.box[2]||!s.ready)return;let r=s.box,[n=0]=r,a=e.zoom;if(n&&(e.doc.w*i*a>n||e.doc.h*i*a>te(r,1))){this.again(s,r,!0);return}let l=te(r,2),o=te(r,3),h=this.need(s,l,o);if(!h||(n||l)<=cr*h*l)return;s.box=[];let u=e=>{if(t.env.destroyed||!s.texture)return;let i=this.need(s,l,o);t.chunks.morph?.busy||i&&i!==e?gr(()=>{u(i)}):this.again(s,r)};gr(()=>{u(h)})}need(e,t,s){let i=this.stage.canvasHost.dpr,r=0;for(let n of this.stage.planes.all)if(n.texture===e){if(!n.measured)return 0;r=Math.max(r,n.doc.w*i*dr(n)/t,n.doc.h*i*dr(n)/s)}return r}again(e,t=e.box,s=!1){e.box=[];for(let[i,r]of this.images)if(r===e){this.fetch(i,r,t,s);return}}forget(e){let t=this.uploads.findIndex(t=>t.plane===e&&!t.tex);if(t<0)return;let[s]=this.uploads.splice(t,1);s&&"close"in s.source&&s.source.close()}Yh(e,t,s){let i=this.uploads.find(t=>s?t.tex===s:!t.tex&&t.plane===e);if(!i)return void this.uploads.push({plane:e,source:t,tex:s});i.source!==t&&"close"in i.source&&i.source.close(),i.source=t}Mg(e){if(!this.uploads.length)return!1;let t=performance.now(),s=0,i=!1;do{let e=this.jl();if(!e)break;let t=this.Zc(e);t&&(this.Pc(t,e),s+=t.bytes,this.landed(t)&&(i=!0)),"close"in e.source&&e.source.close()}while(this.uploads.length&&s<mr&&Math.min(e,fr)+performance.now()-t<fr);return this.Ea(),i}Pc(e,t){let s=this.stage.gpu.gl;"levels"in t.source?(lr??this.cl)?.upload(s,e,t.source):e.upload(t.source,t.plane._z?{mipmaps:!1}:{}),t.plane.raster?.upload(s),this.stage.env.stats.uploads++}jl(){let e=this.uploads.findIndex(e=>!(e.tex??e.plane.texture)?.ready);return this.uploads.splice(Math.max(0,e),1)[0]}Zc(e){let t=this.stage;if(e.tex)return e.tex.texture?e.tex:null;let s=e.plane;return!t.planes.all.includes(s)||s.status==="error"&&!s.slow?null:s.texture??=new ls(t.gpu.gl)}landed(e){let t=!1;for(let s of this.stage.planes.all)s.texture!==e||s.textureState==="error"||(s.textureState="ready",Oe(s),s._o(),s.prev&&this.stage.transitions.swap(s),Le(this.stage.env.lib,s),t||=s.visible||s.zone.screen);return t}Ea(){let e=this.stage,t=e.gpu.tier.textureBudget,s=e.chunks.fx,i=e.chunks.video,r=0;for(let t of e.planes.all)t.texture?.refs||(r+=t.texture?.bytes??0);r+=this.vc;let n=s?.pool.bytes??0,a=i?.Kl()??0;if(s&&r+n+a>t&&(n-=s.pool.trim()),r+n+a>t){let s=e.chunks.warm;if(!s){e.chunks.loadWarm().then(e=>{e&&this.Ea()});return}r=s.wb(r,t*pr-n-a)}i&&(a-=i.fit(t-r-n)),r+n+a>t&&!this.warned&&(this.warned=!0,e.chunks.warm?.note("",[r,n+a])),e.env.stats.textureMB=Math.round(r/2**20)}Wk(e){let t=this.stage,s=this.kd.get(e);if(s)return s;s=new ls(t.gpu.gl),this.kd.set(e,s),this.Ef.set(s,e);let i=s,r=()=>fs(e,t.gpu.tier.maxTexture,void 0,!0).then(e=>{i.upload(e,{straight:!0}),"close"in e&&e.close()}),n=hr();return(n?this.loadPrepared().then(s=>s.uniform(t.gpu.gl,i,{manifest:n,src:e,reads:this.manifests})).then(e=>e?void 0:r(),r):r()).then(()=>{t.scheduler.markDirty()}).catch(t=>{this.stage.env.lib.say("uniformImage",[],e,t)}),s}Zk(){this.kd.clear(),this.images.clear();for(let e of this.uploads)"close"in e.source&&e.source.close();this.uploads.length=0}dispose(){this.kd.forEach(e=>{e.dispose()}),this.images.forEach(e=>{e.dispose()}),this.Ef.clear(),this.Zk()}};function yr(e){let t="";for(let s in e.uniforms){if(O.has(s))continue;let i=W(e.uniforms[s]?.value);i!=="float"&&(t+=`,${s}:${i??"-"}`)}return t&&`|u${t}`}var wr=4,xr=250,kr=class{constructor(e,t,s=new Map,i=()=>[]){this.gl=e;this.lib=t;this.chunks=s;this.planes=i;this.byKey=new Map;this.grids=new Map;this.included=new Map;this.glsl=null;this.textKey="";this.lean=null;this.db=new WeakMap;this.later=new Set;this.La=!1;this.extra=new Set;this.opening=!0;this.qe=new WeakSet;this.Xe=!1;this.texts=new WeakSet;this.eager=0;this.ka=-1/0;this.batched=new Map;this.pump=()=>{this.La=!1;let e=this.turn();for(let e of this.later)e.started&&this.later.delete(e);let t=this.Xe?void 0:this.next(this.Zh());t&&!e&&!this.Dc()&&this.begin(t),(this.later.size||this.extra.size)&&this.Cj()}}get size(){let e=0;for(let t of this.byKey.values())(t.started||t.wanted)&&!t.failed&&e++;return e}prepare(e){let t=e.kind==="shader"||e.kind==="video"||e.kind==="text"?e.kind:"image",s=`${t}|${e.shader?.name??""}|${e.effects.map(e=>e.name).join(",")}${e.instancing?.key??""}${yr(e)}${t==="text"?this.textKey:""}`;e.programKey=s;let i=this.byKey.get(s)??this.build(e,s,t);if(!i)return!1;this.first(e,i,e.zone.near||e.zone.soon||e.zone.screen);let r=!e.zone.near&&!e.zone.soon&&!e.zone.screen&&this.eager<wr;if(e.zone.screen||e.zone.soon?this.begin(i):r?this.guess(i):e.zone.near&&this.soon(i),i.failed)return e.setStatus("error"),!1;e.program=i;let n=this.grid(e.segments);return e.grid=e.instancing?e.instancing.wrap(n):n,e.bends=!!e.instancing||e.effects.some(e=>!!e.def.vertex?.main),!0}build(e,t,s){let r={};for(let[t,s]of Object.entries(e.uniforms))r[t]=s.value;let n={kind:s,effects:e.effects.map(e=>({name:e.name,def:e.def})),shader:e.shader?{name:e.shader.name,def:e.shader.def}:void 0,uniforms:r};if(e.glsl){let s=this.glsl?.(n,e,this.chunks);if(!s)return null;this.included.set(t,s.included),n=s}e.instancing&&(n=e.instancing.build(n));let a=I(n),l=a.vertex,o=this.lean?.(a.fragment)??a.fragment,h=t+","+l+o,u=this.byKey.get(h);if(u)return u;let d;try{d=new Yt(this.gl,l,o,{label:t,lazy:!0})}catch(t){return i.error(t instanceof Error?t.message:t),e.setStatus("error"),null}return this.byKey.set(t,d),this.db.set(d,h),s==="text"&&this.texts.add(d),d}want(e,t){let s=e.program;!s||s.started||(this.first(e,s,!0),t?this.begin(s):this.soon(s))}begin(e){this.later.delete(e),this.extra.delete(e),!e.started&&(this.turn(),e.wanted=!0,(!this.Xe||!e.eh)&&e.start(),e.failed&&this.fail(e,this.planes()),this.soon(e))}guess(e){e.started||this.later.has(e)||(this.eager++,e.eh?this.soon(e):this.begin(e))}turn(){let e=Kt();if(!e)for(let e of this.byKey.values())e.started&&e.ready();return e}soon(e){e.started||(this.later.add(e),this.Cj())}Cj(){this.La||(this.La=!0,gr(this.pump))}moved(){this.ka=performance.now()}first(e,t,s){this.opening&&s&&this.qe.add(e),this.qe.has(e)&&this.qe.add(t)}Kj(e){this.Xe=e&&this.opening}opened(){if(this.opening){this.opening=!1;for(let e of this.planes())(e.zone.screen||e.zone.soon||e.zone.near)&&this.qe.add(e)}}Dc(){for(let e of this.byKey.values())if(e.started&&!e.compiled())return!0;return!1}Zh(){if(!this.opening)return!1;for(let e of this.byKey.values())if(e.wanted&&e.eh&&e.state==="pending")return this.Hc=void 0,!0;return this.later.values().next().value?.eh?(this.Hc??=performance.now(),performance.now()-this.Hc<Gt):!1}next(e){let t;for(let e of this.later)if(e.wanted){if(!this.texts.has(e))return e;t??=e}if(t)return t;if(e)return;for(let e of this.later)if(this.qe.has(e))return e;let s=performance.now()-this.ka>xr,[i]=this.later;return i?s||!i.eh?i:void 0:s?this.extra.values().next().value:void 0}fail(e,t){e.error&&this.lib.tell("glsl",e.error,i.error),e.state="failed";for(let[t,s]of this.byKey)s===e&&this.byKey.delete(t);let s=this.db.get(e);s&&this.byKey.set(s,e);for(let s of t)s.program===e&&s.setStatus("error")}batch(e,t){let s=e.program;if(!s?.ready())return null;let i=this.batched.get(s);if(i===void 0){let r=t.batchSource(s.vertex,s.fragment);if(i=null,r)try{i=new Yt(this.gl,r.vertex,r.fragment,{label:`${e.programKey} (batched)`,attributes:t.BATCH_ATTRIBUTES,lazy:!0}),i.eh?(this.extra.add(i),this.Cj()):i.start()}catch{i=null}this.batched.set(s,i)}return!i?.started||i.failed?null:i.ready()?i:null}grid(e){let t=is(e),s=this.grids.get(t);return s||(s=new rs(this.gl,t),this.grids.set(t,s)),s}failed(e,t){let s=e.program;s&&this.fail(s,t)}drop(e,t){let s=[];for(let[i,r]of this.byKey)if(this.uses(i,e,t)){this.byKey.delete(i),s.push(r);let e=this.batched.get(r);e&&s.push(e),this.batched.delete(r)}return s}uses(e,t,s){let[,i,r=""]=e.split("|");switch(t){case"effect":return r.split(",").includes(s);case"shader":return i===s;case"chunk":return!!this.included.get(e)?.includes(s);case"layer":return!1}}lost(){this.later.clear(),this.batched.clear(),this.byKey.clear(),this.grids.clear(),this.included.clear()}dispose(e){e&&(this.byKey.forEach(e=>{e.dispose()}),this.grids.forEach(e=>{e.dispose()}),this.batched.forEach(e=>{e?.dispose()})),this.lost()}};var _r=120,Er=e=>typeof e=="object"&&e!==null&&"texture"in e&&e.texture!==void 0,Sr=4,Mr=(e,t)=>e.order-t.order,zr=class{constructor(e,t){this.host=e;this.list=[];this.adaptive=new Vi(()=>{this.pace()});this.timer=null;this.ij=null;this.loadPace=()=>import(new URL("./pace.js",import.meta.url).href);this.Q=null;this.program=null;this.unit=0;this.bound=[];this.fixed=!1;this.lb=-1;this.Ag=ee(4);this.view=new Int32Array(2);this.viewportSize=new Float32Array(2);this.Lj=new Float32Array(2);this.imageSize=new Float32Array(2);this.surface=new Float32Array(4);this.ah=0;this.draws=0;this.probe=null;this.batches=null;this.batching=null;this.prior=null;this.alike=0;this.loadBatches=()=>import(new URL("./batches.js",import.meta.url).href);this.Yc=e=>{e.kind==="layer"||!e.program?.ready()||!e.grid||e.kind!=="shader"&&!e.texture?.ready||this.drawPlane(e,!0)};this.blank=new ls(t),this.il=ds(t)}draw(e){let t=this.host,s=t.gpu.gl,i=this.list;i.length=0,this.prior=null;for(let e of t.planes.visible)e.destroyed||i.push(e);i.sort(Mr);let r=this.probe;this.timer?.poll(),r||this.timer?.begin(),this.bound[this.unit]=void 0,this.begin(i,e);for(let t=0;t<=i.length;t++){let s=this.wa=i[t];try{s?this.ge(s,e,r)&&(s._l.set(s.rect),s._p.set(s._s),s._V=s.opacity,s.drawnIn(e.frame)):this.flush()}catch(e){this.Dd(e)}}return t.chunks.fx?.leave?.frame(),t.chunks.morph?.draw(this.Yc),t.chunks.fx?.post(),r?.(null),this.scissor(null),s.bindVertexArray(null),r||this.timer?.end(),this.draws}begin(e,t){let s=this.host,i=s.gpu.gl,r=s.gpu.canvas,n=s.chunks.layers;n&&s.planes.all.some(e=>e.layer)&&(n.begin(e,t),this.reset());let a=this.view;(a[0]!==r.width||a[1]!==r.height)&&(a[0]=r.width,a[1]=r.height,i.viewport(0,0,a[0],a[1])),this.scissor(null),this.fixed||(i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(0,0,0,0),i.enable(i.BLEND),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),i.disable(i.DEPTH_TEST),this.fixed=!0),s.chunks.fx?.pre(e),i.clear(i.COLOR_BUFFER_BIT),this.draws=0;let l=this.viewportSize;l[0]=s.canvasHost.viewport.width,l[1]=s.canvasHost.viewport.height,this.surface[2]=l[0],this.surface[3]=l[1],this.Lj[0]=r.width,this.Lj[1]=r.height}Dd(e){if(!this.wa)throw e;this.host.fallbacks.E(this.wa,e),this.batches?.drop(),this.reset(),this.host.chunks.fx?.bind()}ge(e,t,s){if(e.morphHidden||e.viewTransition||e.hush||e.group||!this.dc(e))return!1;if(e.kind==="layer")return this.flush(),this.od(e,t,s);if(!(e.kind==="shader"||e.texture?.ready===!0||e.prev?.ready===!0)||!this.qd(e))return!1;if(e.backdrop){if(this.flush(),!this.host.chunks.fx?.copy(e))return!1;this.bound[this.unit]=void 0}return s?.(e),this.queue(e),!0}queue(e){!this.probe&&this.batches?.take(e)||(this.flush(),!this.batching&&e.kind==="image"?(this.alike=this.prior===e.program?this.alike+1:1,this.alike>=Sr&&this.fc(),this.prior=e.program):this.prior=null,this.drawPlane(e))}flush(){this.batches?.flush()}dc(e){let t=e.modules.frames;if(t)t.pick(e)&&Oe(e);else if(e.kind==="video"){if(!this.host.chunks.video?.upload(e))return!1;this.bound[this.unit]=void 0}return!0}qd(e){let t=this.host,s=e.program;return!s||!e.grid?!1:s.ready()?!0:(s.failed?t.gpu.programs.failed(e,t.planes.all):t.scheduler.uc(1),!1)}od(e,t,s){let i=this.host.chunks.layers;return!e.layer?.ready||!i?!1:(s?.(e),i.render(e,t),this.reset(),this.host.chunks.fx?.bind(),this.draws++,!0)}reset(){this.program=null,this.unit=-1,this.bound.length=0,this.fixed=!1,this.lb=-1,this.view[0]=-1}scissor(e){let t=this.host.gpu.gl,s=e?1:0;this.lb!==s&&(e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST));let i=this.Ag;e&&(this.lb!==s||i[0]!==e[0]||i[1]!==e[1]||i[2]!==e[2]||i[3]!==e[3])&&(t.scissor(e[0],e[1],e[2],e[3]),i.set(e)),this.lb=s}bind(e,t,s,i){this.yb(s,i),e.set(t,i)}yb(e,t){let s=this.host.gpu.gl;this.bound[t]!==e.texture&&(this.unit!==t&&(this.unit=t,s.activeTexture(s.TEXTURE0+t)),this.bound[t]=e.texture,s.bindTexture(s.TEXTURE_2D,e.texture))}drawPlane(e,t=!1){let s=this.host,i=s.gpu.gl,r=e.program,n=e.grid;if(!r||!n)return;this.wa=e,(e._z||e.kind==="text")&&!this.Q&&s.chunks.text&&(this.Q=s.chunks.text.blank(i),this.bound[this.unit]=void 0);let a=t?null:e.clips;this.scissor(a?.lb?a.scissorPx:null),this.use(r),this.tj(r,e,a);let l=this.picture(e);this.bind(r,"uImage",l,0),l instanceof ls&&l.angle(e.level===2?this.il:1);let o=this.imageSize;o[0]=(l.box?.[2]??0)||l.width,o[1]=(l.box?.[3]??0)||l.height,r.set("uImageSize",o),this.ed(r,e,l),n.draw(),this.draws++}use(e){let t=this.host;this.program!==e.program&&(this.program=e.program,t.gpu.gl.useProgram(e.program)),e.set("uViewport",this.viewportSize),e.set("uSurface",this.surface),e.set("uCanvas",this.Lj),e.set("uUmberHdr",this.ah),e.set("uTime",t.env.frame.time),e.set("uScrollVelocity",t.env.frame.velocity),e.set("uDpr",t.canvasHost.dpr*this.adaptive.scale)}tj(e,t,s){e.set("uRect",t.level&&!t.xfReason?t._x:t.rect),e.set("uSize",t.size),e.set("uBleed",t.bleed),e.set("uPlaneMatrix",t._s),e.set("uMouse",t.mouse),e.set("uProgress",t.progress),e.set("uAlpha",t.opacity),e.set("uRadius",t.radius),e.set("uRadiusKy",t._w),e.set("uUmberClips",s?s.count:0),s?.count&&(e.set("uUmberClipXf",s.xf),e.set("uUmberClipBox",s.box),e.set("uUmberClipRadius",s.radius),e.set("uUmberClipPoly",s.poly),e.set("uUmberClipPolyInfo",s.polyInfo)),e.set("uFit",t.fit),e.set("uFitPosition",t._M)}picture(e){return e.texture?.ready?e.texture:e.prev?.ready?e.prev:this.blank}ed(e,t,s){let i=this.wj(e,t,1);t._z&&(i=this.Ce(e,t,i)),t.kind==="text"&&(i=this.nd(e,t,i));let r=t.modules.frames;if(r){let t=r.next;this.bind(e,"uFrameNext",t??s,i),e.set("uFrameMix",t?r.mix:0)}}wj(e,t,s){for(let i in t.uniforms){let r=t.uniforms[i];if(!r)continue;let n=r.value;Er(n)?e.uniforms.has(i)&&this.bind(e,i,n,s++):e.set(i,typeof n=="boolean"?Number(n):n)}return s}Ce(e,t,s){let i=this.Q;if(!i)return s;let r=t.raster,n=r?.jd?.ready?r.jd:null,a=r?.Ck?.ready?r.Ck:null;return this.bind(e,"uGlyphIndex",n&&a?n:i.index,s),this.bind(e,"uGlyphData",n&&a?a:i.data,s+1),s+2}nd(e,t,s){let i=this.Q;if(!i||!e.uniforms.has("uUmberTextLayout"))return s;let r=this.host.chunks.text,n=r?.samplers(t);this.bind(e,"uUmberTextLayout",n?.layout??i.data,s),this.bind(e,"uUmberTextColor",n?.color.texture?n.color:this.blank,s+1);let a=r?.curveTables;return a&&(this.bind(e,"uUmberCurves",a.curves,s+2),this.bind(e,"uUmberBands",a.bands,s+3),this.bind(e,"uUmberGlyphs",a.glyphs,s+4)),s+5}fd(e){let t=this.host;if(t.env.options.adaptive===!1||t.chunks.vl)return!1;(Kt()||t.gpu.programs.turn()||t.planes.visible.some(e=>e.status==="loading"))&&this.adaptive.rest(_r);let s=t.env.host.clock.held||t.scheduler.Ug(performance.now())||t.gpu.media.uploads.length>0;return t.scheduler.changing&&(this.adaptive.te=!1),this.adaptive.frame(e,s,this.timer?.ms??-1,!!this.timer?.supported)?(t.env.stats.scale=this.adaptive.scale,i.info(`GL render scale ${this.adaptive.scale}`),!0):!1}fc(){this.batching=this.loadBatches().then(e=>{this.batches=new e.Batches(this.host.gpu.gl,this)},()=>{})}pace(){this.ij??=this.loadPace().then(e=>{this.ij=e;let{refresh:t}=this.adaptive;this.adaptive=new e.AdaptiveResolution(this.host.env.host.ticker),this.adaptive.refresh=t,this.adaptive.settle=0,this.timer=new e.GPUTimer(this.host.gpu.gl)},()=>{})}lost(){this.Q=null,this.batches?.lost()}restored(){this.reset(),this.blank=new ls(this.host.gpu.gl),this.timer&&this.ij&&!(this.ij instanceof Promise)&&(this.timer=new this.ij.GPUTimer(this.host.gpu.gl)),this.il=ds(this.host.gpu.gl),this.adaptive.reset()}dispose(){this.timer?.dispose(),this.blank.dispose(),this.batches?.dispose(),this.Q?.index.dispose(),this.Q?.data.dispose()}};var Tr=class{constructor(e,t,s,i){this.canvas=t;this.gl=s;this.tier=i;this.context=new k;this.programs=new kr(s,e.env.lib,e.env.registry.chunks,()=>e.planes.all),this.renderer=new zr(e,s),this.media=new br(e),this.subsystems=[this.programs,this.renderer]}};function Ar(e,t,s){switch(e){case"failed":case"failed-lost":return"off (error)";case"given-up":return"off (context lost)";case"live":case"lost":break}return t.has("host")?"off (canvas host)":t.size?"paused":s}function Rr(e,t){return{get state(){return e()},backend:"webgl2",tier:t.tier,gpu:t,fps:0,frameMs:0,renders:0,skipped:0,rendersPerSec:0,draws:0,planes:0,visible:0,textures:0,textureMB:0,gpuMB:0,uploads:0,programs:0,busy:[],dpr:1,scale:1,width:0,height:0}}var Pr=class{constructor(e,{canvas:t,gl:s,hostEl:r,hostOwnership:a}){this.scheduler=new g(this,{showDom:()=>{M(this)},invalidate:()=>{this.factory.invalidate()}});this.planes=new er(this,{create:(e,t)=>{this.factory.create(e,t)},destroy:(e,t)=>{this.factory.j(e,t)}});this.Pf=!1;this.chunks=new Z(this);this.transitions=new ri(this);this.fallbacks=new Ce(this);this.Ih=new xi(this,this.transitions,{stepTweens:e=>this.scheduler.de=this.env.stepTweens(e),dirty:()=>this.scheduler.dirty,ch:()=>this.batches.ch()});this.Bd=new di(this,{drawn:()=>{this.scheduler.dirty=!1},resize:()=>{this.canvasHost.Ae()},ic:e=>{this.scheduler.ic(e)}});this.measure=e=>{if(!this.scheduler.inactive)try{this.batches.later(),this.measurePhase.run(e)}catch(e){S(this,"measure",e)}};this.update=e=>{if(!this.scheduler.inactive)try{this.Pf=this.Ih.run(e)}catch(e){S(this,"update",e)}};this.render=e=>{if(!this.scheduler.inactive)try{this.Bd.run(e,this.Pf||this.scheduler.dirty)}catch(e){S(this,"render",e)}};let l=m(e,s),o=Rr(()=>Ar(this.gpu.context.state,this.scheduler.pauses,this.scheduler.Ra),l);this.env=new rr(e,Ji(e.lib.say),o,()=>{this.scheduler.markDirty()}),this.gpu=new Tr(this,t,s,l),i.info("GL tier",l),this.canvasHost=new Zi(this,r,a,{Ab:(e,t)=>{this.observers.Ab(e,t)}});let h=()=>{this.canvasHost.Ae()};this.observers=new Et(this,h),this.factory=new hi(this,this.chunks,this.transitions,this.observers),this.measurePhase=new wt(this,this.observers,{resize:()=>{this.canvasHost.Vk()}}),this.batches=new $i(this,{Xd:e=>{this.scheduler.Xd(e)}}),St(this,{resized:h,following:()=>this.factory.following}),this.measurePhase.ue(),this.canvasHost.check(),this.env.cleanups.push(e.ticker.add(this.measure,{phase:"measure",label:"umber"})),this.env.cleanups.push(e.ticker.add(this.update,{phase:"update",label:"umber"})),this.env.cleanups.push(e.ticker.add(this.render,{phase:"render",label:"umber"}));let u=n();u&&this.chunks.load({load:e.loadCapture,file:"capture",made:e=>this.chunks.vl=e.capture(this,u)})}info(){let e=0,t=0;for(let s of this.planes.all)s.texture?.refs||(e+=s.texture?.bytes??0,s.texture?.ready&&t++);return e+=this.gpu.media.vc,this.env.stats.planes=this.planes.all.length+this.planes.later.size,this.env.stats.rendersPerSec=this.Bd.perSecond(performance.now()),this.env.stats.textures=t+this.gpu.media.Sj,this.env.stats.textureMB=Math.round(e/2**20),e+=(this.chunks.fx?.pool.bytes??0)+(this.chunks.video?.Kl()??0)+this.gpu.canvas.width*this.gpu.canvas.height*4,this.env.stats.gpuMB=Math.round(e/2**20),this.env.stats}destroy(){let e=this.env,t=this.gpu;e.destroyed||(this.chunks.morph?.cancel(),this.planes.clear(),this.chunks.gh.clear(),this.chunks.ae.clear(),this.chunks.Ml.clear(),e.destroyed=!0,e.tweens.clear(),this.observers.disconnect(),e.cleanups.forEach(e=>{e()}),e.cleanups=[],t.context.gone||(t.renderer.dispose(),this.chunks.layers?.fade.dispose(),t.media.dispose(),this.chunks.views?.dispose(),p(t.gl)),t.programs.dispose(!t.context.gone),t.canvas.remove())}};function Cr(e){r(e.log);let{lib:t}=e,{el:s,created:n}=jr(e.options,t),a=document.createElement("canvas");a.setAttribute("aria-hidden","true"),a.setAttribute("data-umber-canvas",""),a.setAttribute("data-engine",`umber ${Lr(e.engine)}`);let l=Nr(a);if(!l)return t.say("webgl2",[]),n&&s.remove(),null;if(Fr(e,l))return l.getExtension("WEBGL_lose_context")?.loseContext(),n&&s.remove(),e.off("software"),null;s.appendChild(a);let o=new Pr(e,{canvas:a,gl:l,hostEl:s,hostOwnership:n?"created":"site"});return i.info("GL mounted",{tier:o.gpu.tier.tier}),Ur(o,()=>{n&&s.remove()})}function Ur(e,t){return{apply:t=>{e.batches.apply(t)},scan:t=>{e.batches.scan(t)},prune:()=>{e.planes.prune()},remove:t=>{e.planes.Al(t)},invalidate:t=>{e.factory.invalidate(t)},live:t=>{e.scheduler.live(t)},wake:t=>{e.scheduler.wake(t)},keep:()=>e.canvasHost.keep(),begin:(t,{again:s=!1,leaving:i}={})=>{e.transitions.begin(s,i),e.transitions.capture(t,s)},end:()=>e.transitions.end(),pause:()=>{e.scheduler.hold("user")},resume:()=>{e.scheduler.release("user")},plane:t=>e.planes.of(t),stage:e,planes:t=>e.planes.list(t),defined:(t,s)=>{e.planes.defined(t,s)},redefined:(t,s)=>{e.planes.redefined(t,s)},morph:{capture:t=>{e.transitions.capture(t)},settle:()=>{e.transitions.settle()}},renderer:(t,s)=>e.chunks.loadLayers().then(e=>e?e.create(t,s):null),view:t=>e.chunks.loadLayers().then(e=>e&&!t.destroyed?e.view(t):null),fx:(t,s)=>Ir(e)[t](s),flip:(t,s,i)=>e.transitions.flip(t,s,i),get info(){return e.info()},destroy(){e.destroy(),t()},get gl(){return e.gpu.context.gone?null:e.gpu.gl},get canvas(){return e.gpu.canvas}}}function Fr(e,t){return!(!!e.options.software||"occluzeCapture"in window||[document.documentElement,e.lib.bodyOrNull()].some(e=>e?.hasAttribute("data-umber-software")))&&!e.gpu&&!f(c(t))[0]}function Lr(e){return typeof e!="object"||e===null||!("version"in e)?"":typeof e.version=="string"?e.version:""}function Nr(e){try{return e.getContext("webgl2",{stencil:!0,powerPreference:"high-performance"})}catch{return null}}function Ir(e){return{target:t=>e.chunks.loadFx().then(e=>e?e.target(t):null),snapshot:t=>e.chunks.loadFx().then(e=>e?e.snapshot(t):null),setLeave:t=>e.chunks.loadFx().then(e=>(e?.setLeave(t),null)),sim:t=>e.chunks.loadFx().then(e=>e?e.sim(t):null),flow:t=>e.chunks.loadFx().then(e=>e?e.flow(t):null),preload:t=>e.chunks.loadWarm().then(e=>e?e.preload(t):null),warm:t=>e.chunks.loadWarm().then(e=>e?e.warm(t):null),placeholder:t=>e.chunks.loadWarm().then(e=>e?e.placeholder(t):null)}}function jr(e,t){if(e.host instanceof HTMLElement)return{el:e.host,created:!1};let s=document.querySelector(typeof e.host=="string"?e.host:"[data-umber-host]");if(s)return{el:s,created:!1};typeof e.host=="string"&&t.say("hostless",[e.host]);let i=document.createElement("div");i.setAttribute("data-umber-host",""),i.style.zIndex=String(e.zIndex??(e.layer==="under"?-1:1));let r=t.bodyOrNull();return r?r.prepend(i):document.documentElement.appendChild(i),{el:i,created:!0}}export{Cr as mount};
|