@occluze/umber 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +93 -47
  2. package/THIRD-PARTY-NOTICES.md +33 -0
  3. package/dist/chunks/badge.js +2 -2
  4. package/dist/chunks/basis.js +2 -2
  5. package/dist/chunks/batches.js +2 -0
  6. package/dist/chunks/capture.js +2 -2
  7. package/dist/chunks/covers.js +2 -2
  8. package/dist/chunks/curves.js +2 -2
  9. package/dist/chunks/flip.js +2 -2
  10. package/dist/chunks/fx.js +2 -2
  11. package/dist/chunks/gl.js +2 -2
  12. package/dist/chunks/glsl.js +2 -2
  13. package/dist/chunks/glyphs.js +2 -0
  14. package/dist/chunks/inspect.js +2 -2
  15. package/dist/chunks/instances.js +2 -2
  16. package/dist/chunks/layers.js +2 -2
  17. package/dist/chunks/licence.js +2 -2
  18. package/dist/chunks/morph.js +2 -2
  19. package/dist/chunks/pace.js +2 -0
  20. package/dist/chunks/patch.js +2 -2
  21. package/dist/chunks/prepared.js +2 -2
  22. package/dist/chunks/profiler.js +2 -2
  23. package/dist/chunks/recheck.js +2 -0
  24. package/dist/chunks/resize.js +2 -0
  25. package/dist/chunks/restore.js +2 -2
  26. package/dist/chunks/shapes.js +2 -2
  27. package/dist/chunks/sim.js +2 -2
  28. package/dist/chunks/text.js +2 -2
  29. package/dist/chunks/video.js +2 -2
  30. package/dist/chunks/vocabulary.js +2 -2
  31. package/dist/chunks/warm.js +2 -2
  32. package/dist/modules/debug.js +2 -2
  33. package/dist/modules/debug.mjs +2 -2
  34. package/dist/modules/handoff.js +2 -2
  35. package/dist/modules/handoff.mjs +2 -2
  36. package/dist/modules/input.js +2 -2
  37. package/dist/modules/input.mjs +2 -2
  38. package/dist/modules/scrollfx.js +2 -2
  39. package/dist/modules/scrollfx.mjs +2 -2
  40. package/dist/modules/scrub.js +2 -2
  41. package/dist/modules/scrub.mjs +2 -2
  42. package/dist/modules/three.js +2 -2
  43. package/dist/modules/three.mjs +2 -2
  44. package/dist/node/assets.mjs +4 -2
  45. package/dist/node/astro.mjs +26 -18
  46. package/dist/node/cli.mjs +63 -10
  47. package/dist/node/shared-NFSQ5J4B.mjs +2116 -0
  48. package/dist/node/{shared-4FIU6DYP.mjs → shared-OUFNIXQ7.mjs} +106 -17
  49. package/dist/node/vite.mjs +7 -3
  50. package/dist/prepared.mjs +2 -0
  51. package/dist/umber.css +1 -1
  52. package/dist/umber.js +2 -2
  53. package/dist/umber.mjs +2 -2
  54. package/docs/AI-quick.md +43 -87
  55. package/docs/AI.md +1977 -1829
  56. package/docs/npm.md +13 -16
  57. package/package.json +32 -48
  58. package/types/assets.d.ts +109 -4
  59. package/types/astro.d.ts +20 -23
  60. package/types/debug.d.ts +1 -1
  61. package/types/esm.d.ts +2 -6
  62. package/types/input.d.ts +3 -3
  63. package/types/loop.d.ts +21 -9
  64. package/types/module.d.ts +0 -2
  65. package/types/scrollfx.d.ts +5 -41
  66. package/types/scrub.d.ts +2 -2
  67. package/types/three.d.ts +26 -1
  68. package/types/umber.d.ts +152 -155
  69. package/types/vite.d.ts +3 -3
  70. package/dist/chunks/views.js +0 -2
  71. package/dist/frameworks/astro.mjs +0 -2
  72. package/dist/frameworks/react.mjs +0 -2
  73. package/dist/frameworks/svelte.mjs +0 -2
  74. package/dist/frameworks/vue.mjs +0 -2
  75. package/dist/modules/router-swap.js +0 -2
  76. package/dist/modules/router.js +0 -2
  77. package/dist/modules/router.mjs +0 -2
  78. package/dist/modules/scroll-more.js +0 -2
  79. package/dist/modules/scroll-touch.js +0 -2
  80. package/dist/modules/scroll.js +0 -2
  81. package/dist/modules/scroll.mjs +0 -2
  82. package/dist/node/shared-3Q24RNIF.mjs +0 -602
  83. package/types/react.d.ts +0 -15
  84. package/types/router.d.ts +0 -223
  85. package/types/scroll.d.ts +0 -190
  86. package/types/svelte.d.ts +0 -16
  87. package/types/vue.d.ts +0 -14
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- function e(e,t,a){let[r]=a.levels,n=e.createTexture();if(!r||!n)return;e.bindTexture(e.TEXTURE_2D,n),e.pixelStorei(e.UNPACK_ALIGNMENT,1);let i=0;a.levels.forEach((t,r)=>{a.format?e.compressedTexImage2D(e.TEXTURE_2D,r,a.format,t.width,t.height,0,t.data):e.texImage2D(e.TEXTURE_2D,r,e.RGBA,t.width,t.height,0,e.RGBA,e.UNSIGNED_BYTE,t.data),i+=t.data.byteLength}),e.pixelStorei(e.UNPACK_ALIGNMENT,4);let l=a.levels.length>1;l||a.format?e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAX_LEVEL,a.levels.length-1):(e.generateMipmap(e.TEXTURE_2D),i*=4/3);let o=l||!a.format;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),t.adopt(n,{width:r.width,height:r.height,bytes:i,mipmaps:o})}var t={flag:2,name:"bc7",extension:"EXT_texture_compression_bptc",gl:[36492,36492],block:[16,16],vk:[145,145],samples:[1,1],whole:!0,side:4,slot:0},a={...t,name:"bc1",extension:"WEBGL_compressed_texture_s3tc",gl:[33776,33776],block:[8,8],vk:[131,131]},r={flag:8,name:"etc2",extension:"WEBGL_compressed_texture_etc",gl:[37492,37496],block:[8,16],vk:[147,151],samples:[1,2],whole:!1,side:4,slot:2},n={4:[37808,157],5:[37810,161],6:[37812,165],8:[37815,171],10:[37819,179],12:[37821,183]};function i([,,,,,e,i=4]){let[l=37808,o=157]=n[i]??[],s={...t,flag:4,name:"astc",extension:"WEBGL_compressed_texture_astc",gl:[l,l],vk:[o,o],whole:!1,side:i};return[e&32?a:t,s,r].filter(t=>e&t.flag)}var l=[171,75,84,88,32,50,48,187,13,10,26,10],o=new Map;function s(e){let t=o.get(e);return t||(t=fetch(e,{credentials:"same-origin"}).then(e=>e.ok?e.json():null).then(e=>e?.v===1?e:null).catch(()=>null),o.set(e,t)),t}var h=new WeakMap;function f(e,t){let a=h.get(e);a||h.set(e,a=new Map);let r=a.get(t);return r===void 0&&a.set(t,r=!!e.getExtension(t)),r}var m=e=>Math.ceil(e/16)*16,c=(e,t)=>Math.max(1,e>>t);function u(e){let t=4;return e>=512?t=32:e>=256&&(t=16),Math.max(4,Math.floor((e+t/2)/t)*t)}function E(e,t,a,r){let n=e.whole?u(a):a,i=e.whole?u(r):r;return{format:e,alpha:t,w:n,h:i,count:Math.floor(Math.log2(Math.max(n,i,1)))+1}}function g({format:e,alpha:t,w:a,h:r,count:n},i){let l=m(80+24*n+4+24+16*e.samples[t]);for(let o=n-1;o>=i;o--)l=m(l+Math.ceil(c(a,o)/e.side)*Math.ceil(c(r,o)/e.side)*e.block[t]);return l}function w({format:e,w:t,h:a,count:r},n,i){let[l=0,o=0]=n,s=r=>!e.whole||c(t,r)%4===0&&c(a,r)%4===0,h=0;for(;h+1<r&&Math.max(c(t,h),c(a,h))>i;)h++;for(let e=h+1;l&&e<r&&!(c(t,e)<l||c(a,e)<o);e++)s(e)&&(h=e);for(;h>0&&!s(h);)h--;return h}async function T(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}async function _(e,t,a){let r=new Uint8Array(e),n=new DataView(e);if(r.length<80||l.some((e,t)=>r[t]!==e)||n.getUint32(12,!0)!==t)throw new Error("not the KTX2 file the manifest names");let i=n.getUint32(20,!0),o=n.getUint32(24,!0),s=n.getUint32(40,!0),h=n.getUint32(44,!0)===3,f=[];for(let e=a;e<s;e++){let t=80+24*e,a=Number(n.getBigUint64(t,!0)),l=Number(n.getBigUint64(t+8,!0));if(a+l>r.length)throw new Error("the file ends early");let s=r.subarray(a,a+l);f.push({width:c(i,e),height:c(o,e),data:s})}return h&&await Promise.all(f.map(async e=>e.data=await T(e.data))),f}function d(e,t,a){if(!a?.length)return g(e,t);let r=a[0]??0;for(let e=0;e<Math.min(t,3);e++)r-=a[e+1]??0;return r}async function p(e,t){let a=new URL(t.manifest,document.baseURI),r=await s(a.href),n=new URL(t.src,document.baseURI),l=n.origin===a.origin?r?.images[n.pathname]:void 0;if(!l)return null;let[o,h,m,c,u,g]=l,T=e=>new URL(`${o}.${e}`,a).href,p=l[7],x=!p||"DecompressionStream"in globalThis?i(l).find(t=>f(e,t.extension)):void 0;if(!x)return g&16?{avif:T("avif")}:null;let R=E(x,g&1?1:0,c,u),U=w(R,t.size(),t.maxTexture),v;try{let e=await fetch(T(`${x.name}.ktx2`),{credentials:"same-origin",headers:U?{Range:`bytes=0-${d(R,U,p?.[x.slot])-1}`}:{}});if(!e.ok)throw new Error(`HTTP ${e.status}`);v=await _(await e.arrayBuffer(),x.vk[R.alpha],U)}catch(e){if(g&16)return{avif:T("avif")};throw e}let[M]=v;if(!M)throw new Error("no levels");return{image:{width:M.width,height:M.height,format:x.gl[R.alpha],levels:v},box:U?[M.width,M.height,h,m]:[0,0,h,m]}}export{p as get,w as levelFor,g as prefix,_ as read,e as upload};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function e(e,a,r){let[n]=r.levels,i=e.createTexture();if(!n||!i)return;e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_ALIGNMENT,1);let l=0;r.levels.forEach((t,a)=>{r.format?e.compressedTexImage2D(e.TEXTURE_2D,a,r.format,t.width,t.height,0,t.data):e.texImage2D(e.TEXTURE_2D,a,e.RGBA,t.width,t.height,0,e.RGBA,e.UNSIGNED_BYTE,t.data),l+=t.data.byteLength}),e.pixelStorei(e.UNPACK_ALIGNMENT,4);let o=r.levels.length>1;o||r.format?e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAX_LEVEL,r.levels.length-1):(e.generateMipmap(e.TEXTURE_2D),l*=4/3);let s=o||!r.format;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,s?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),a.adopt(i,{width:n.width,height:n.height,bytes:l,mipmaps:s});for(let e of r.levels)t(e.data.buffer)}function t(e){e.byteLength&&e.transfer?.(0)}var a=e=>fetch(e,e.startsWith(location.origin+"/")?{mode:"no-cors",credentials:"include"}:{});function r(e,t){let r=t.get(e);return r||(r=a(e).then(e=>e.ok?e.json():null).catch(()=>null),t.set(e,r)),r}var n={flag:2,name:"bc7",extension:"EXT_texture_compression_bptc",gl:[36492,36492],block:[16,16],vk:[145,145],samples:[1,1],whole:!0,side:4,slot:0},i={...n,name:"bc1",extension:"WEBGL_compressed_texture_s3tc",gl:[33776,33776],block:[8,8],vk:[131,131]},l={flag:8,name:"etc2",extension:"WEBGL_compressed_texture_etc",gl:[37492,37496],block:[8,16],vk:[147,151],samples:[1,2],whole:!1,side:4,slot:2},o={4:[37808,157],5:[37810,161],6:[37812,165],8:[37815,171],10:[37819,179],12:[37821,183]};function s([,,,,,e,t=4]){let[a=37808,r=157]=o[t]??[],s={...n,flag:4,name:"astc",extension:"WEBGL_compressed_texture_astc",gl:[a,a],vk:[r,r],whole:!1,side:t};return[e&32?i:n,s,l].filter(t=>e&t.flag)}var f=[171,75,84,88,32,50,48,187,13,10,26,10],h=new Map,u=(e,t=h)=>r(e,t).then(e=>e?.v===1?e:null),c=new WeakMap;function m(e,t){let a=c.get(e);a||c.set(e,a=new Map);let r=a.get(t);return r===void 0&&a.set(t,r=!!e.getExtension(t)),r}var g=e=>Math.ceil(e/16)*16,E=(e,t)=>Math.max(1,e>>t);function d(e,t){let a=e=>{let t=4;return e>=512?t=32:e>=256&&(t=16),[Math.max(4,Math.floor(e/t)*t),Math.max(4,Math.ceil(e/t)*t)]},r=e/Math.max(t,1),n=[0,0],i=[1/0,1/0];for(let l of a(e))for(let o of a(t)){let a=Math.abs(l/o-r),s=Math.abs(l-e)+Math.abs(o-t);(a<(i[0]??0)||a===i[0]&&s<(i[1]??0))&&(n=[l,o],i=[a,s])}return n}function w(e,t,a,r){let[n=0,i=0]=e.whole?d(a,r):[a,r];return{format:e,alpha:t,w:n,h:i,count:Math.floor(Math.log2(Math.max(n,i,1)))+1}}function T({format:e,alpha:t,w:a,h:r,count:n},i){let l=g(80+24*n+4+24+16*e.samples[t]);for(let o=n-1;o>=i;o--)l=g(l+Math.ceil(E(a,o)/e.side)*Math.ceil(E(r,o)/e.side)*e.block[t]);return l}function _({format:e,w:t,h:a,count:r},n,i){let[l=0,o=0]=n,s=r=>!e.whole||E(t,r)%4===0&&E(a,r)%4===0,f=0;for(;f+1<r&&Math.max(E(t,f),E(a,f))>i;)f++;for(let e=f+1;l&&e<r&&!(E(t,e)<l||E(a,e)<o);e++)s(e)&&(f=e);for(;f>0&&!s(f);)f--;return f}async function b(e){let a=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate")).getReader(),r=[],n=0;for(;;){let{done:e,value:t}=await a.read();if(e)break;r.push(t),n+=t.length}let i=new Uint8Array(n),l=0;for(let e of r)i.set(e,l),l+=e.length,t(e.buffer);return i}async function x(e,t,a){let r=new Uint8Array(e),n=new DataView(e);if(r.length<80||f.some((e,t)=>r[t]!==e)||n.getUint32(12,!0)!==t)throw new Error("not the KTX2 file the manifest names");let i=n.getUint32(20,!0),l=n.getUint32(24,!0),o=n.getUint32(40,!0),s=n.getUint32(44,!0)===3,h=[];for(let e=a;e<o;e++){let t=80+24*e,a=Number(n.getBigUint64(t,!0)),o=Number(n.getBigUint64(t+8,!0));if(a+o>r.length)throw new Error("the file ends early");let s=r.subarray(a,a+o);h.push({width:E(i,e),height:E(l,e),data:s})}return s&&await Promise.all(h.map(async e=>e.data=await b(e.data))),h}function R(e,t,a){if(!a?.length)return T(e,t);let r=a[0]??0;for(let e=0;e<Math.min(t,3);e++)r-=a[e+1]??0;return r}async function U(e,t){let a=/Gecko\/\d/.test(navigator.userAgent),r=await fetch(e,{credentials:"same-origin",headers:t&&!a?{Range:`bytes=0-${t-1}`}:{}});if(!r.ok)throw new Error(`HTTP ${r.status}`);if(!t||!a||!r.body)return r.arrayBuffer();let n=r.body.getReader(),i=new Uint8Array(t),l=0;for(;l<t;){let{done:e,value:a}=await n.read();if(e)break;i.set(a.subarray(0,t-l),l),l+=a.length}return n.cancel().catch(()=>{}),l<t?i.slice(0,l).buffer:i.buffer}async function p(e,a){let r=new URL(a.manifest,document.baseURI),n=await u(r.href,a.reads),i=new URL(a.src,document.baseURI),l=i.origin===r.origin?n?.images[i.pathname]:void 0;if(!l)return null;let[o,f,h,c,g,E]=l,d=e=>new URL(`${o}.${e}`,r).href,T=l[7],b=!T||"DecompressionStream"in globalThis?s(l).find(t=>m(e,t.extension)):void 0;if(!b)return E&16?{avif:d("avif")}:null;let p=w(b,E&1?1:0,c,g),M=_(p,a.size(),a.maxTexture),v;try{let e=await U(d(`${b.name}.ktx2`),M&&R(p,M,T?.[b.slot]));v=await x(e,b.vk[p.alpha],M),v[0]?.data.buffer!==e&&t(e)}catch(e){if(E&16)return{avif:d("avif")};throw e}let[A]=v;if(!A)throw new Error("no levels");return{image:{width:A.width,height:A.height,format:b.gl[p.alpha],levels:v},box:M?[A.width,A.height,f,h]:[0,0,f,h]}}async function M(t,a,r){let n=new URL(r.manifest,document.baseURI),i=new URL(r.src,document.baseURI),l=(i.origin===n.origin?await u(n.href,r.reads):null)?.images[i.pathname]?.[5];if(l===void 0||(l&65)!==64)return!1;let o=t.getParameter(t.MAX_TEXTURE_SIZE),s=await p(t,{...r,size:()=>[],maxTexture:o});return!s||!("image"in s)?!1:(e(t,a,s.image),a.box=s.box,!0)}export{p as get,_ as levelFor,u as manifestAt,T as prefix,x as read,M as uniform,e as upload,d as wholeBlocks};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- var e="page loops";function r(e=""){let r=new CSSStyleSheet;return r.replaceSync(e),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r],r}function t(e){e&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==e))}var o=1/60,a=3e3,n=250,l=["measure","update","render"],p=[200,145,32],i={"top-left":"top: 8px; left: 8px;","top-right":"top: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;"},s=`\n.umber-profiler {\n position: fixed; z-index: 2147483647; width: 300px; max-width: calc(100vw - 16px); box-sizing: border-box;\n padding: 8px 10px 9px; border-radius: 8px;\n background: rgba(12, 12, 14, 0.86); color: #e8e8ea;\n -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);\n box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 24px rgba(0,0,0,0.35);\n font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-variant-numeric: tabular-nums; letter-spacing: 0; text-align: left; pointer-events: auto;\n}\n.umber-profiler * { box-sizing: border-box; margin: 0; padding: 0; font: inherit; color: inherit; }\n.umber-profiler__head { display: flex; align-items: center; gap: 8px; color: #fff; }\n.umber-profiler__head span:first-of-type { flex: 1 1 auto; }\n.umber-profiler__head span:last-of-type { color: #8a8a90; }\n.umber-profiler button {\n width: 18px; height: 18px; border: 0; border-radius: 4px; background: rgba(255,255,255,0.1); cursor: pointer;\n}\n.umber-profiler__bar { position: relative; display: flex; height: 10px; margin: 6px 0; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,0.06); }\n.umber-profiler__bar i { display: block; height: 100%; min-width: 1px; }\n.umber-profiler__bar.is-over { box-shadow: inset 0 0 0 1px #f87171; }\n.umber-profiler__row { display: flex; gap: 8px; white-space: nowrap; }\n.umber-profiler__row b { flex: 0 0 64px; font-weight: 400; color: #8a8a90; overflow: hidden; }\n.umber-profiler__row span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }\n.umber-profiler__row em { font-style: normal; color: #8a8a90; }\n.umber-profiler__row span:last-child { flex: 0 0 auto; }\n`,d=null,u=(e,r="",t="")=>Object.assign(document.createElement(e),{className:r,textContent:t}),f=e=>"page"in e;function b(e){if(f(e))return{label:e.label,phase:e.phase,order:e.order,rate:"page"};let r=e;return{label:r.label??(r.fn.name||"callback"),phase:r.phase,order:r.order,rate:c(r.fps)}}function m(e){return e===1/0?"last":e===-1/0?"first":String(e)}function c(e){return e===void 0?"":typeof e=="number"?`${e} fps`:e}function x(r,t={}){let n=new Map,p=0,i=()=>[...n.values()].sort((e,r)=>e.phase-r.phase||e.order-r.order),s=()=>{let e=performance.now();p=0;for(let r of n.values())r.cost+=(r.frame-r.cost)*o,p+=r.cost,r.frame=0,e-r.seen>a&&n.delete(r.key)};r.meter=(r,t)=>{if(r.fn===s||r.label===e)return;let o=n.get(r);o||(o={key:r,...b(r),cost:t,frame:0,seen:0},n.set(r,o)),o.frame+=t,o.seen=performance.now()};let d=r.add(s,{phase:"render",order:1/0,always:!1}),u=()=>i().map(e=>({label:e.label,phase:l[e.phase]??"update",order:e.order,rate:e.rate,ms:e.cost})),f=()=>{d(),r.meter=null};if(t.panel===!1)return{read:u,destroy:f};let m=h(r,t,i,()=>p);return{read:u,destroy(){f(),m()}}}function h(e,o,a,f){d??=r(s);let b=u("div","umber-profiler");b.style.cssText=i[o.corner??"top-right"],b.setAttribute("data-umber-profiler","");let c=u("div","umber-profiler__head"),x=u("button");x.type="button";let h=u("span","","frame"),g=u("span");c.append(x,h,g);let y=u("div","umber-profiler__bar"),_=u("div");b.append(c,y,_),document.body.appendChild(b);let w=()=>{x.textContent=e.paused?"\u25b6":"\u2759\u2759",x.setAttribute("aria-label",e.paused?"Play the loop":"Pause the loop")};x.addEventListener("click",()=>{e.paused?e.play():e.pause(),w()});let v=()=>{w();let r=1e3/e.fps,t=a(),o=f();g.textContent=`${Math.round(e.fps)} fps ${o.toFixed(2)} / ${r.toFixed(1)} ms`,y.classList.toggle("is-over",o>r);let n=Math.max(r,o);y.replaceChildren(...t.map(e=>{let r=u("i");return r.style.width=`${e.cost/n*100}%`,r.style.background=`hsl(${p[e.phase]??0} 70% ${e.key===t[0]?.key?58:50}%)`,r.title=`${e.label} ${e.cost.toFixed(2)} ms`,r})),_.replaceChildren(...t.map(e=>{let r=u("div","umber-profiler__row");return r.append(u("b","",`${l[e.phase]??""} ${m(e.order)}`),u("span","",e.label),u("em","",e.rate),u("span","",`${e.cost.toFixed(2)} ms`)),r}))};v();let S=setInterval(v,n);return()=>{clearInterval(S),b.remove(),t(d),d=null}}export{x as profile};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e="page loops";function r(e=""){let r=new CSSStyleSheet;return r.replaceSync(e),document.adoptedStyleSheets=[...document.adoptedStyleSheets,r],r}function t(e){e&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(r=>r!==e))}var o=1/60,a=3e3,l=250,n=["step","measure","update","render"],p=[280,200,145,32],i={"top-left":"top: 8px; left: 8px;","top-right":"top: 8px; right: 8px;","bottom-left":"bottom: 8px; left: 8px;","bottom-right":"bottom: 8px; right: 8px;"},s=`\n.umber-profiler {\n position: fixed; z-index: 2147483647; width: 300px; max-width: calc(100vw - 16px); box-sizing: border-box;\n padding: 8px 10px 9px; border-radius: 8px;\n background: rgba(12, 12, 14, 0.86); color: #e8e8ea;\n -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);\n box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 24px rgba(0,0,0,0.35);\n font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n font-variant-numeric: tabular-nums; letter-spacing: 0; text-align: left; pointer-events: auto;\n}\n.umber-profiler * { box-sizing: border-box; margin: 0; padding: 0; font: inherit; color: inherit; }\n.umber-profiler__head { display: flex; align-items: center; gap: 8px; color: #fff; }\n.umber-profiler__head span:first-of-type { flex: 1 1 auto; }\n.umber-profiler__head span:last-of-type { color: #8a8a90; }\n.umber-profiler button {\n width: 18px; height: 18px; border: 0; border-radius: 4px; background: rgba(255,255,255,0.1); cursor: pointer;\n}\n.umber-profiler__bar { position: relative; display: flex; height: 10px; margin: 6px 0; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,0.06); }\n.umber-profiler__bar i { display: block; height: 100%; min-width: 1px; }\n.umber-profiler__bar.is-over { box-shadow: inset 0 0 0 1px #f87171; }\n.umber-profiler__row { display: flex; gap: 8px; white-space: nowrap; }\n.umber-profiler__row b { flex: 0 0 64px; font-weight: 400; color: #8a8a90; overflow: hidden; }\n.umber-profiler__row span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }\n.umber-profiler__row em { font-style: normal; color: #8a8a90; }\n.umber-profiler__row span:last-child { flex: 0 0 auto; }\n`,d=null,u=(e,r="",t="")=>Object.assign(document.createElement(e),{className:r,textContent:t}),f=e=>"page"in e;function b(e){if(f(e))return{label:e.label,phase:e.phase,order:e.order,rate:"page"};let r=e;return{label:r.label??(r.fn.name||"callback"),phase:r.phase,order:r.order,rate:c(r.fps)}}function m(e){return e===1/0?"last":e===-1/0?"first":String(e)}function c(e){return e===void 0?"":typeof e=="number"?`${e} fps`:e}function x(r,t={}){let l=new Map,p=0,i=()=>[...l.values()].sort((e,r)=>e.phase-r.phase||e.order-r.order),s=()=>{let e=performance.now();p=0;for(let r of l.values())r.cost+=(r.frame-r.cost)*o,p+=r.cost,r.frame=0,e-r.seen>a&&l.delete(r.key)};r.meter=(r,t)=>{if(r.fn===s||r.label===e)return;let o=l.get(r);o||(o={key:r,...b(r),cost:t,frame:0,seen:0},l.set(r,o)),o.frame+=t,o.seen=performance.now()};let d=r.add(s,{order:-1/0,always:!1},!0),u=()=>i().map(e=>({label:e.label,phase:n[e.phase+1]??"update",order:e.order,rate:e.rate,ms:e.cost})),f=()=>{d(),r.meter=null};if(t.panel===!1)return{read:u,destroy:f};let m=h(r,t,i,()=>p);return{read:u,destroy(){f(),m()}}}function h(e,o,a,f){d??=r(s);let b=u("div","umber-profiler");b.style.cssText=i[o.corner??"top-right"],b.setAttribute("data-umber-profiler","");let c=u("div","umber-profiler__head"),x=u("button");x.type="button";let h=u("span","","frame"),g=u("span");c.append(x,h,g);let y=u("div","umber-profiler__bar"),_=u("div");b.append(c,y,_),document.body.appendChild(b);let w=()=>{x.textContent=e.paused?"\u25b6":"\u2759\u2759",x.setAttribute("aria-label",e.paused?"Play the loop":"Pause the loop")};x.addEventListener("click",()=>{e.paused?e.play():e.pause(),w()});let v=()=>{w();let r=1e3/e.fps,t=a(),o=f();g.textContent=`${Math.round(e.fps)} fps ${o.toFixed(2)} / ${r.toFixed(1)} ms`,y.classList.toggle("is-over",o>r);let l=Math.max(r,o);y.replaceChildren(...t.map(e=>{let r=u("i");return r.style.width=`${e.cost/l*100}%`,r.style.background=`hsl(${p[e.phase+1]??0} 70% ${e.key===t[0]?.key?58:50}%)`,r.title=`${e.label} ${e.cost.toFixed(2)} ms`,r})),_.replaceChildren(...t.map(e=>{let r=u("div","umber-profiler__row");return r.append(u("b","",`${n[e.phase+1]??""} ${m(e.order)}`),u("span","",e.label),u("em","",e.rate),u("span","",`${e.cost.toFixed(2)} ms`)),r}))};v();let S=setInterval(v,l);return()=>{clearInterval(S),b.remove(),t(d),d=null}}export{x as profile};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e="umber-check:",t=t=>{parent.postMessage(e+t,"*")};fetch(window.name,{credentials:"omit"}).then(e=>e.ok?e.text():"").then(t,()=>{t("")});
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e=(e,t)=>({resizeWidth:e,resizeHeight:t,resizeQuality:"high"});function t(e,t){let a=new Uint8Array(t.width*t.height*4);return e.bindTexture(e.TEXTURE_2D,e.createTexture()),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.bindFramebuffer(e.FRAMEBUFFER,e.createFramebuffer()),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,e.getParameter(e.TEXTURE_BINDING_2D),0),e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,a),t.close(),a}var a;function r(){return a??=(async()=>{let a=document.createElement("canvas");a.width=a.height=32;let r=a.getContext("2d"),i=document.createElement("canvas").getContext("webgl2");if(!r||!i)return!1;r.fillStyle="#e33",r.arc(13,16,10,0,7),r.fill(),r.fillStyle="rgba(40,220,90,.5)",r.fillRect(16,5,11,22);let n=await new Promise(e=>{a.toBlob(e)});if(!n)return!1;let l={premultiplyAlpha:"premultiply"},o=t(i,await createImageBitmap(n,{...l,...e(12,12)})),c=await createImageBitmap(n,l),u=t(i,await createImageBitmap(c,e(12,12)));return c.close(),i.getExtension("WEBGL_lose_context")?.loseContext(),o.every((e,t)=>e===u[t])})().catch(()=>!1)}var i=(e,t)=>(e[t]??0)*2**24+((e[t+1]??0)<<16)+((e[t+2]??0)<<8)+(e[t+3]??0)>>>0;async function n(e){let t=new Uint8Array(await e.slice(0,16384).arrayBuffer()),a="";for(let e of t)a+=String.fromCharCode(e);if(e.type==="image/png"){let e=a.indexOf("IDAT");return(t[25]===2||t[25]===0)&&e>0&&!a.slice(0,e).includes("tRNS")}if(e.type==="image/webp"){let e=a.slice(12,16);return e==="VP8 "?!0:e==="VP8L"?!((t[24]??16)&16):e==="VP8X"&&!((t[20]??16)&16)}if(e.type==="image/avif"){let e=i(t,0);return a.slice(e+4,e+8)==="meta"&&e+i(t,e)<=t.length&&!/auxiliary:alpha|auxid:1/.test(a)}return!1}async function l(t,a,i,l){let o=e(Math.max(1,Math.round(a.width*i)),Math.max(1,Math.round(a.height*i))),c=t.type==="image/jpeg"||await r()||await n(t),u=await createImageBitmap(c?t:a,c?{...l,...o}:o);return a.close(),u}async function o(e,t){let a=await new Promise((t,a)=>{let r=new Image;r.crossOrigin="anonymous",r.decoding="async",r.onload=()=>{t(r)},r.onerror=()=>{a(new Error(`could not load ${e}`))},r.src=e}),r=a.width,i=a.height,n=t(r,i);if(n===1||!r)return a;let l=document.createElement("canvas");l.width=Math.round(r*n)||1,l.height=Math.round(i*n)||1;let o=l.getContext("2d");return o?(o.drawImage(a,0,0,l.width,l.height),l):a}export{n as opaque,l as resize,r as sameBothWays,o as viaImg};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- function e(e){if(e.gpu.context.state!=="lost"||e.env.destroyed||e.gpu.gl.isContextLost())return;e.gpu.context.state="live",e.gpu.media.vc();for(let t of e.gpu.subsystems)t.restored?.();e.planes.all.some(e=>e.layer)&&e.chunks.layers?.fade.get();let a=e.gpu.media.Lb;e.gpu.media.Lb=new Map;let o=e=>[e.zone.screen,e.zone.soon,e.zone.near,!0].indexOf(!0);for(let s of[...e.planes.all].sort((e,t)=>o(e)-o(t)))t(e,s,a),r(e,s);e.factory.invalidate(),e.scheduler.wake(2),e.chunks.views?.restored(),e.env.host.emit("restored")}function t(e,t,r){for(let a of Object.values(t.uniforms)){let t=r.get(a.value);t&&(a.value=e.gpu.media.Wd(t))}}function r(e,t){if(t.status==="error"){t._l&&e.gpu.programs.prepare(t);return}if(t.setStatus(e.scheduler.inactive?null:"loading"),t.wait(),t.layer){t.zone.near&&e.factory.load(t);return}e.gpu.programs.prepare(t),t.shader?t.textureState="ready":t.zone.near&&e.factory.load(t),t.modules.tell(e=>e.restored?.())}export{e as restored};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var e=e=>(e>3?192:96)*2**20;function t(t){if(t.gpu.context.state!=="lost"||t.env.destroyed||t.gpu.gl.isContextLost())return;t.gpu.context.state="live";let o=t.gpu.tier;o.textureBudget=Math.max(e(o.level),o.textureBudget/2),t.gpu.media.Zk();for(let e of t.gpu.subsystems)e.restored?.();t.planes.all.some(e=>e.layer)&&t.chunks.layers?.fade.get();let s=t.gpu.media.Ef;t.gpu.media.Ef=new Map;let l=e=>[e.zone.screen,e.zone.soon,e.zone.near,!0].indexOf(!0);for(let e of[...t.planes.all].sort((e,t)=>l(e)-l(t)))r(t,e,s),a(t,e);t.factory.invalidate(),t.scheduler.wake(2),t.chunks.views?.restored(),t.env.host.emit("restored")}function r(e,t,r){for(let a of Object.values(t.uniforms)){let t=r.get(a.value);t&&(a.value=e.gpu.media.Wk(t))}}function a(e,t){if(t.status==="error"){t._E&&e.gpu.programs.prepare(t);return}if(t.setStatus(e.scheduler.inactive?null:"loading"),t._l[0]=NaN,t.wait(),t.layer){t.zone.near&&e.factory.load(t);return}e.gpu.programs.prepare(t),t.shader?t.textureState="ready":t.zone.near&&e.factory.load(t),t.modules.tell(e=>e.restored?.())}export{t as restored};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- function e(e){return typeof e=="number"?new Float64Array(e):new Float64Array(e)}function t(e){return typeof e=="number"?new Float32Array(e):new Float32Array(e)}function n(e){return new Int32Array(e)}var r=(e,t)=>e[t]??NaN;function i(e){if(!e||typeof e.tagName!="string")return"<?>";let t=e.tagName.toLowerCase();if(e.id)return`<${t}#${e.id}>`;let n=typeof e.className=="string"?e.className.trim().split(/\s+/)[0]:"";return n?`<${t}.${n}>`:`<${t}>`}function o(e,t){let n=t[0],r=t[1],i=t[2],o=t[3],l=t[4],s=t[5],a=t[6],u=t[7],c=t[8],h=l*c-s*u,d=-(o*c-s*a),f=o*u-l*a,p=n*h+r*d+i*f;if(!p||!Number.isFinite(p))return!1;let m=1/p;return e[0]=h*m,e[1]=-(r*c-i*u)*m,e[2]=(r*s-i*l)*m,e[3]=d*m,e[4]=(n*c-i*a)*m,e[5]=-(n*s-i*o)*m,e[6]=f*m,e[7]=-(n*u-r*a)*m,e[8]=(n*l-r*o)*m,!0}function l(e,t,n,{r:r,sx:i,sy:o}){return e.fill(0),e[0]=t?r.width/t:1,e[4]=n?r.height/n:1,e[6]=r.left+i,e[7]=r.top+o,e[8]=1,e}function s(e,t){let n=e.trim();if(n.startsWith("calc(")&&n.endsWith(")"))n=n.slice(5,-1).trim();else if(n.includes("("))return NaN;let r=0,i=1,o=!0;for(let e of n.split(/\s+/))if(e){if(o)r+=i*a(e,t);else if(e==="+"||e==="-")i=e==="-"?-1:1;else return NaN;o=!o}return o?NaN:r}function a(e,t){let[,n,r]=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px|%)?$/i.exec(e)??[];if(n===void 0)return NaN;let i=parseFloat(n);return!r&&i!==0?NaN:r==="%"?i/100*t:i}function u(e){let t=[],n=0,r="";for(let i of e.trim())i==="("?n++:i===")"&&n--,/\s/.test(i)&&n===0?(r&&t.push(r),r=""):r+=i;return r&&t.push(r),t}function c(e){let t=[],n=0,r="";for(let i of e)i==="("?n++:i===")"&&n--,i===","&&n===0?(t.push(r.trim()),r=""):r+=i;return t.push(r.trim()),t}function h(e,t,n){let r={rx:[0,0,0,0],ry:[0,0,0,0]};for(let[i,o]of e.entries()){let[e="0px",l=e]=u(o||"0px"),a=s(e,t),c=s(l,n);if(!Number.isFinite(a)||!Number.isFinite(c))return null;a>0&&c>0&&d(r,i,a,c)}return f(r,t,n)}function d(e,t,n,r){e.rx[t]=n,e.ry[t]=r}function f(e,t,n){let{rx:r,ry:i}=e,o=[[t,r[0]+r[1]],[n,i[1]+i[2]],[t,r[2]+r[3]],[n,i[3]+i[0]]],l=1;for(let[e,t]of o)t>0&&(l=Math.min(l,Math.max(e,0)/t));return l<1&&(e.rx=[r[0]*l,r[1]*l,r[2]*l,r[3]*l],e.ry=[i[0]*l,i[1]*l,i[2]*l,i[3]*l]),e}function p(e,t,n,r){let[i,o,l,s]=t,a=[[s,i],[o,i],[o,l],[s,l]],u={rx:[0,0,0,0],ry:[0,0,0,0]};for(let[t,[n,r]]of a.entries()){let i=e.rx[t]??0,o=e.ry[t]??0;i<=0||o<=0||d(u,t,Math.max(0,i-n),Math.max(0,o-r))}return f(u,n,r)}function m(e){let t=0;for(let[n,r]of e.rx.entries()){let i=e.ry[n]??0;if(!(r<=0||i<=0)){if(!t)t=r/i;else if(Math.abs(r/t-i)>1)return NaN}}return t||1}var b=8;function g(e,t){let[n,r,i,o]=t.border,[l,s,a,u]=t.padding,[c,h,d,f]=t.margin;switch(e){case"padding-box":return{x:o,y:n,w:t.w-o-r,h:t.h-n-i,edges:[n,r,i,o]};case"content-box":case"fill-box":return{x:o+u,y:n+l,w:t.w-o-r-u-s,h:t.h-n-i-l-a,edges:[n+l,r+s,i+a,o+u]};case"margin-box":return{x:-f,y:-c,w:t.w+f+h,h:t.h+c+d,edges:[-c,-h,-d,-f]};default:return{x:0,y:0,w:t.w,h:t.h,edges:[0,0,0,0]}}}var v=/\s*\b(border-box|padding-box|content-box|margin-box|fill-box|stroke-box|view-box)\s*$/;function y({x:e,y:t,w:n,h:r},i){let o=i??{rx:[0,0,0,0],ry:[0,0,0,0]},l=m(o);return Number.isFinite(l)?{shape:{kind:0,box:[e,t*l,Math.max(0,n),Math.max(0,r)*l],radius:[...o.rx],points:null,ky:l}}:{reason:"mixed-corners"}}function w(e){let[t="",n]=e.split("/"),r=x(u(t)),i=n===void 0?r:x(u(n));return!r||!i?null:[`${r[0]} ${i[0]}`,`${r[1]} ${i[1]}`,`${r[2]} ${i[2]}`,`${r[3]} ${i[3]}`]}function x(e){let[t]=e;if(t===void 0)return null;let[,n=t,r=t,i=n]=e;return[t,n,r,i]}function k(e,t){let[n="",r]=e.split(/\bround\b/),i=u(n),[o]=i;if(o===void 0)return{reason:"unparsed"};let[,l=o,a=o,c=l]=i,d=s(o,t.h),p=s(l,t.w),m=s(a,t.h),b=s(c,t.w);if(![d,p,m,b].every(Number.isFinite))return{reason:"unparsed"};let g=Math.max(0,t.w-b-p),v=Math.max(0,t.h-d-m),x=null;if(r){let e=w(r),n=e&&h(e,t.w,t.h);if(!n)return{reason:"unparsed"};x=f(n,g,v)}return y({x:t.x+b,y:t.y+d,w:g,h:v},x)}function M(e,t){let[n,r,i,o]=e,l;if(n===void 0)l=[t.w/2,t.h/2];else if(i===void 0)l=N(n,r??"center",t);else if(e.length===4&&r!==void 0&&o!==void 0)l=S([n,r],[i,o],t);else return null;return Number.isFinite(l[0])&&Number.isFinite(l[1])?l:null}var $={left:[0,"x"],right:[1,"x"],top:[0,"y"],bottom:[1,"y"],center:[.5,""]};function N(e,t,n){($[e]?.[1]==="y"||$[t]?.[1]==="x")&&([e,t]=[t,e]);let r=$[e],i=$[t];return[r?r[0]*n.w:s(e,n.w),i?i[0]*n.h:s(t,n.h)]}function S(e,t,n){let[r,i]=$[e[0]]?.[1]==="y"?[t,e]:[e,t],o=([e,t],n)=>{let r=s(t,n);return e==="right"||e==="bottom"?n-r:r};return[o(r,n.w),o(i,n.h)]}function F(e,t,n,r){return!e||e==="closest-side"?Math.min(Math.abs(t),Math.abs(n-t)):e==="farthest-side"?Math.max(Math.abs(t),Math.abs(n-t)):s(e,r)}function C(e,t,n){let[r="",i]=t.split(/\bat\b/),o=u(r),l=M(u(i??""),n);if(!l)return{reason:"unparsed"};let[a,c]=l,h,d;if(e==="circle"){let e=o[0];h=!e||e.endsWith("-side")?(e==="farthest-side"?Math.max:Math.min)(F(e,a,n.w,0),F(e,c,n.h,0)):s(e,Math.hypot(n.w,n.h)/Math.SQRT2),d=h}else h=F(o[0],a,n.w,n.w),d=F(o[1],c,n.h,n.h);if(!Number.isFinite(h)||!Number.isFinite(d))return{reason:"unparsed"};h>0&&d>0||(h=0,d=0);let f=d>0?h/d:1,p=n.x+a,m=(n.y+c)*f;return{shape:{kind:0,box:[p-h,m-h,2*h,2*h],radius:[h,h,h,h],points:null,ky:f}}}function P(e,t,n){let i=e.length/2,o=(t+1)%i,l=(n+1)%i,s=r(e,t*2),a=r(e,t*2+1),u=r(e,o*2),c=r(e,o*2+1),h=r(e,n*2),d=r(e,n*2+1),f=r(e,l*2),p=r(e,l*2+1),m=(f-h)*(a-d)-(p-d)*(s-h),b=(f-h)*(c-d)-(p-d)*(u-h),g=(u-s)*(d-a)-(c-a)*(h-s),v=(u-s)*(p-a)-(c-a)*(f-s);return m*b<0&&g*v<0}function z(e){let t=e.length/2;for(let n=0;n<t;n++)for(let r=n+1;r<t;r++)if(!(n===(r+1)%t||(n+1)%t===r)&&P(e,n,r))return!0;return!1}function D(e){let[t,n,r,i,o,l,s,a]=e;if(e.length!==8||t===void 0||n===void 0||r===void 0||i===void 0||o===void 0||l===void 0||s===void 0||a===void 0)return null;let u=[t,r,o,s],c=[n,i,l,a];if(t!==r&&n!==i||r!==o&&i!==l||o!==s&&l!==a||s!==t&&a!==n||new Set(u).size>2||new Set(c).size>2)return null;let h=Math.min(...u),d=Math.min(...c);return{x:h,y:d,w:Math.max(...u)-h,h:Math.max(...c)-d}}function L(e,t){let n=c(e),r=!1,[i]=n;(i==="evenodd"||i==="nonzero")&&(r=n.shift()==="evenodd");let o=[];for(let e of n){let[n,r]=u(e),i=s(n??"",t.w),l=s(r??"",t.h);if(!Number.isFinite(i)||!Number.isFinite(l))return{reason:"unparsed"};o.push(t.x+i,t.y+l)}let l=D(o);return l?y(l,null):o.length/2>b?{reason:"polygon-points"}:!r&&z(o)?{reason:"polygon-nonzero"}:{shape:{kind:1,box:[0,0,0,0],radius:[0,0,0,0],points:o,ky:1}}}function O(e,t){let n=(e||"none").trim();if(n==="none"||n==="")return null;let r="border-box",i=v.exec(n),[,o]=i??[];i&&o&&(r=o,n=n.slice(0,i.index).trim());let l=g(r,t);if(!n){let e=h(t.radius,t.w,t.h);return e?y(l,p(e,l.edges,l.w,l.h)):{reason:"unparsed"}}let[,s,a]=/^([a-z-]+)\((.*)\)$/s.exec(n)??[];if(s===void 0||a===void 0)return{reason:"unsupported"};if(/\b(min|max|clamp|var|env)\(/.test(a))return{reason:"unparsed"};switch(s){case"inset":return k(a,l);case"rect":return _(a,l);case"xywh":return Y(a,l);case"circle":case"ellipse":return C(s,a,l);case"polygon":return L(a,l);default:return{reason:"unsupported"}}}function _(e,t){let[n="",r]=e.split(/\bround\b/),[i,o,l,a]=u(n);if(i===void 0||o===void 0||l===void 0||a===void 0)return{reason:"unparsed"};let c=(e,t,n)=>e==="auto"?n:s(e,t),h=c(i,t.h,0),d=t.w-c(o,t.w,t.w),f=t.h-c(l,t.h,t.h),p=c(a,t.w,0);return k(`${h}px ${d}px ${f}px ${p}px${r?` round ${r}`:""}`,t)}function Y(e,t){let[n="",r]=e.split(/\bround\b/),[i,o,l,a]=u(n).map((e,n)=>s(e,n%2?t.h:t.w));return i===void 0||o===void 0||l===void 0||a===void 0?{reason:"unparsed"}:k(`${o}px ${t.w-i-l}px ${t.h-o-a}px ${i}px${r?` round ${r}`:""}`,t)}function X(e,t,n){let[,r]=/^rect\((.*)\)$/.exec((e||"auto").trim())??[];if(r===void 0)return null;let i=r.split(/\s*,\s*|\s+/).filter(Boolean),[o,l,a,u]=i;if(i.length!==4||!o||!l||!a||!u)return{reason:"unparsed"};let c=(e,t)=>e==="auto"?t:s(e,0),h=c(o,0),d=c(l,t),f=c(a,n),p=c(u,0);return[h,d,f,p].every(Number.isFinite)?y({x:p,y:h,w:d-p,h:f-h},null):{reason:"unparsed"}}function H(e,t,{box:n,radius:r},i=0){let o=n[2],l=n[3],[s,a,u,c]=[r[0],r[1],r[2],r[3]],h=Math.min(1,o/Math.max(s+a,1e-5),l/Math.max(a+u,1e-5),o/Math.max(u+c,1e-5),l/Math.max(c+s,1e-5)),d=e-n[0],f=t-n[1],p=Math.abs(d-o/2)-o/2,m=Math.abs(f-l/2)-l/2,b=Math.hypot(Math.max(p,0),Math.max(m,0))+Math.min(Math.max(p,m),0);return b=A(b,d,f,s*h),b=A(b,o-d,f,a*h),b=A(b,o-d,l-f,u*h),b=A(b,d,l-f,c*h),b<=i}function A(e,t,n,r){return Math.max(t,n)>=r?e:Math.max(e,Math.hypot(t-r,n-r)-r)}function I(e,t,n){let i=n.length/2,o=!1;for(let l=0,s=i-1;l<i;s=l++){let i=r(n,l*2),a=r(n,l*2+1),u=r(n,s*2),c=r(n,s*2+1);a>t!=c>t&&e<(u-i)*(t-a)/(c-a)+i&&(o=!o)}return o}var W=e=>parseFloat(e??"0")||0,T=(e,t)=>e===void 0||e===""?t:e,E=e=>!!e&&e!=="none";function R(e){try{return e.matches(":modal")||e.matches(":popover-open")}catch{return!1}}function G(e,t){let n=t.get(e);if(n)return n;let r=getComputedStyle(e),i=[r.maskImage,r.getPropertyValue("-webkit-mask-image"),r.maskBorderSource,r.getPropertyValue("-webkit-mask-box-image-source")].some(E),o={el:e,tag:e.localName||e.tagName.toLowerCase(),display:r.display,position:T(r.position,"static"),overflowX:T(r.overflowX,"visible"),overflowY:T(r.overflowY,"visible"),contain:T(r.contain,"none"),contentVisibility:T(r.contentVisibility,"visible"),willChange:T(r.willChange,"auto"),filter:T(r.filter,"none"),backdropFilter:T(r.backdropFilter||r.webkitBackdropFilter,"none"),clipPath:T(r.clipPath,"none"),clip:T(r.getPropertyValue("clip"),"auto"),mask:i,transform:T(r.transform,"none"),translate:T(r.translate,"none"),rotate:T(r.rotate,"none"),scale:T(r.scale,"none"),perspective:T(r.perspective,"none"),transformOrigin:T(r.transformOrigin,""),perspectiveOrigin:T(r.perspectiveOrigin,""),transformStyle:T(r.transformStyle,"flat"),backfaceVisibility:T(r.backfaceVisibility||r.getPropertyValue("-webkit-backface-visibility"),"visible"),offsetPath:T(r.offsetPath,"none"),opacity:T(r.opacity,"1"),isolation:T(r.isolation,"auto"),mixBlendMode:T(r.mixBlendMode,"normal"),zoom:T(r.zoom,"1"),topLayer:R(e)};return t.set(e,o),o}function q(e,t){if(t.has(e.el))return;t.add(e.el);let n=getComputedStyle(e.el);e.transform=n.transform||"none",e.translate=n.translate||"none",e.rotate=n.rotate||"none",e.scale=n.scale||"none",e.transformOrigin=n.transformOrigin||"",e.perspective=n.perspective||"none",e.perspectiveOrigin=n.perspectiveOrigin||"",e.box=void 0}function V(e,t,n,r){let i=Math.min(n+1,e.length-1);U.length<i*2+2&&(U=new Float64Array(i*4+4));let o=U,{rel:l,sizes:s}=r;for(let n=t;n<=i;n++){let t=e[n];if(!t||!(t.el instanceof HTMLElement))return!1;let i=t.el;J(i,o,n*2,r.bodyOrNull);let l=Q(t);s[n*2]=Number.isFinite(l.width)?l.width:i.offsetWidth,s[n*2+1]=Number.isFinite(l.height)?l.height:i.offsetHeight}for(let n=t;n<i;n++){let t=e[n+1];if(!t)break;B(t,o,n,l)}return!0}var U=new Float64Array(64);function B(e,t,n,i){let o=e.tag!=="html"&&e.tag!=="body";i[n*2]=r(t,n*2)-r(t,(n+1)*2)-(o?e.el.scrollLeft:0),i[n*2+1]=r(t,n*2+1)-r(t,(n+1)*2+1)-(o?e.el.scrollTop:0)}var Z=e=>window.scrollX||(e()?.scrollLeft??0),j=e=>window.scrollY||(e()?.scrollTop??0),K=e=>(e.overflowY==="auto"||e.overflowY==="scroll")&&e.el.scrollHeight>e.el.clientHeight;function J(e,t,n,r){let i=0,o=0,l=e;for(;;){i+=l.offsetLeft,o+=l.offsetTop;let e=l.offsetParent;if(!e){getComputedStyle(l).position==="fixed"&&(i+=Z(r),o+=j(r));break}if(e===document.body)break;i+=e.clientLeft,o+=e.clientTop,l=e}t[n]=i,t[n+1]=o}function Q(e){if(e.box)return e.box;let t=e.el,n=getComputedStyle(t),r=(e,t="")=>[W(n[`${e}Top${t}`]),W(n[`${e}Right${t}`]),W(n[`${e}Bottom${t}`]),W(n[`${e}Left${t}`])],i=r("border","Width"),o=r("padding"),l=r("margin"),[s,a]=ee(n),u=[0,0],c=e=>e==="auto"||e==="scroll";if(t instanceof HTMLElement&&(c(e.overflowX)||c(e.overflowY))){let e=t.offsetWidth-t.clientWidth-i[1]-i[3],n=t.offsetHeight-t.clientHeight-i[0]-i[2];u=[e>=2?e:0,n>=2?n:0]}return e.box={border:i,padding:o,margin:l,radius:[n.borderTopLeftRadius||"0px",n.borderTopRightRadius||"0px",n.borderBottomRightRadius||"0px",n.borderBottomLeftRadius||"0px"],width:s,height:a,direction:n.direction||"ltr",overflowClipMargin:n.overflowClipMargin||"0px",scrollbar:u},e.box}function ee(e){let t=e.width.endsWith("px")?W(e.width):NaN,n=e.height.endsWith("px")?W(e.height):NaN;return e.boxSizing!=="border-box"&&(t+=W(e.paddingLeft)+W(e.paddingRight)+W(e.borderLeftWidth)+W(e.borderRightWidth),n+=W(e.paddingTop)+W(e.paddingBottom)+W(e.borderTopWidth)+W(e.borderBottomWidth)),[t,n]}function te(e){return e.assignedSlot??e.parentElement??e.parentNode?.host??null}function ne(e,t){let n=[],r=e;for(;r;){let e=G(r,t);if(n.push(e),e.tag==="html"||e.topLayer)break;r=te(r)}return n}var re=(e,...t)=>t.some(t=>new RegExp(`\\b${t}\\b`).test(e)),ie=e=>e.tag==="html",oe=e=>{let t=ie(e)?e.willChange.replace(/(^|,)\s*(backdrop-)?filter\s*(?=,|$)/g,"$1"):e.willChange;return re(t,"transform","perspective","filter","translate","rotate","scale")},le=["transform","translate","rotate","scale","perspective","filter","backdropFilter"];function se(e,{countZoom:t=!0}={}){for(let t of le)if(e[t]!=="none"&&!(ie(e)&&t.endsWith("ilter")))return`${t==="backdropFilter"?"backdrop-filter":t}: ${e[t]}`;if(re(e.contain,"layout","paint","strict","content"))return`contain: ${e.contain}`;if(e.contentVisibility==="auto"||e.contentVisibility==="hidden")return`content-visibility: ${e.contentVisibility}`;if(oe(e))return`will-change: ${e.willChange}`;let n=parseFloat(e.zoom??"1");return t&&Number.isFinite(n)&&Math.abs(n-1)>1e-6?`zoom: ${e.zoom}`:null}var ae=e=>se(e,{countZoom:!1})!==null;function ue(e,t=null){for(let[n,r]of e.entries()){if(r.tag==="html")break;if(r.tag!=="body"&&r.el.classList.contains("pin-spacer")||r.position==="fixed"&&!ce(e,n)||r.position==="sticky"&&he(e,n,t))return!0}return!1}function ce(e,t){return e.some((e,n)=>n>t&&ae(e))}function he(e,t,n){for(let r=t+1;r<e.length;r++){let t=e[r];if(!t)break;if(t.el===n||t.tag==="html"||t.tag==="body")return!0;if(pe(t))return!1}return!0}function de(e){let t=e.at(-1);return t?.tag!=="html"||t.overflowX==="visible"&&t.overflowY==="visible"}function fe(e,t){return e.tag==="html"||e.tag==="body"&&(t||K(e))}function pe(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 me(e){return e.position!=="static"||ae(e)}function be(e){return e.display==="inline"?!1:e.overflowX!=="visible"||e.overflowY!=="visible"||re(e.contain,"paint","strict","content")||e.contentVisibility==="auto"||e.contentVisibility==="hidden"}function ge(e,t=0,n=!1){let r=[],i=null,[o]=e;if(!o)return{sources:r,mask:i};let l=de(e),s=n?e.slice(0,t+1):e,a=o.position;for(let[e,t]of s.entries())t.display!=="contents"&&(e>0&&ye(a,t)&&(be(t)&&!fe(t,l)&&r.push({node:t,depth:e,by:"overflow"}),a=t.position),ve(t,e,r),t.mask&&!i&&(i=t));return{sources:r,mask:i}}function ve(e,t,n){e.clipPath!=="none"&&n.push({node:e,depth:t,by:"clip-path"}),e.clip!=="auto"&&e.clip!==""&&(e.position==="absolute"||e.position==="fixed")&&n.push({node:e,depth:t,by:"clip"})}function ye(e,t){return e==="static"||e==="relative"||e==="sticky"?!0:e==="absolute"?me(t):e==="fixed"&&ae(t)}function we(e,t){let[n,r,i,o]=t.padding,[l,s,a,u]=t.border;return e==="content-box"?[n,r,i,o]:e==="border-box"?[-l,-s,-a,-u]:[0,0,0,0]}function xe(e,t,n,r){let i=(t.overflowClipMargin||"0px").trim().split(/\s+/),o=i.find(e=>e.endsWith("-box"))??"padding-box",l=Math.max(0,s(i.find(e=>!e.endsWith("-box"))??"0px",0)||0),a=we(o,t),u=[a[0]-l,a[1]-l,a[2]-l,a[3]-l];return e.overflowX==="clip"&&(n[0]+=u[3],n[2]-=u[1]),e.overflowY==="clip"&&(n[1]+=u[0],n[3]-=u[2]),[r[0]+u[0],r[1]+u[1],r[2]+u[2],r[3]+u[3]]}var ke=1e6;function Me(e,t,n,r){let[i,o,l,s]=t.border,[a,u]=t.scrollbar,c=t.direction==="rtl",d=[s+(c?a:0),i,n-o-(c?0:a),r-l-u],f=[i,o,l,s];(e.overflowX==="clip"||e.overflowY==="clip")&&(f=xe(e,t,d,f));let m=re(e.contain,"paint","strict","content"),b=e.overflowX==="visible"&&!m,g=e.overflowY==="visible"&&!m;b&&(d[0]=-ke,d[2]=ke),g&&(d[1]=-ke,d[3]=ke);let v=null;if(!b&&!g){let e=h(t.radius,n,r);if(!e)return{reason:"unparsed"};v=p(e,f,d[2]-d[0],d[3]-d[1])}return $e(d,v)}function $e([e,t,n,r],i){let o=i?m(i):1;return Number.isFinite(o)?{shape:{kind:0,box:[e,t*o,Math.max(0,n-e),Math.max(0,r-t)*o],radius:i?[...i.rx]:[0,0,0,0],points:null,ky:o}}:{reason:"mixed-corners"}}var Ne=1e-9,Se=1e-6;function Fe(e){return e.fill(0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Ce(e,t,n){let i=Pe;for(let e=0;e<4;e++){let o=r(n,e*4),l=r(n,e*4+1),s=r(n,e*4+2),a=r(n,e*4+3);for(let n=0;n<4;n++)i[e*4+n]=r(t,n)*o+r(t,4+n)*l+r(t,8+n)*s+r(t,12+n)*a}return e.set(i),e}var Pe=e(16);function ze(e,t,n,i=0){for(let o=0;o<16;o+=4){let l=r(e,o+3);e[o]=r(e,o)+t*l,e[o+1]=r(e,o+1)+n*l,e[o+2]=r(e,o+2)+i*l}return e}var De=(e,t)=>t<e?t:t+1;function Le(e,t,n){let i=De(t,0),o=De(t,1),l=De(t,2),s=De(n,0)*4,a=De(n,1)*4,u=De(n,2)*4;return r(e,s+i)*(r(e,a+o)*r(e,u+l)-r(e,u+o)*r(e,a+l))-r(e,a+i)*(r(e,s+o)*r(e,u+l)-r(e,u+o)*r(e,s+l))+r(e,u+i)*(r(e,s+o)*r(e,a+l)-r(e,a+o)*r(e,s+l))}function Oe(e){let t=-e[3]*Le(e,3,0)+e[7]*Le(e,3,1)-e[11]*Le(e,3,2)+e[15]*Le(e,3,3);return!t||!Number.isFinite(t)?NaN:Le(e,2,2)/t}var _e=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?$/i;function Ye(e){let t=_e.exec(e.trim());if(!t)return NaN;let[,n="",r="deg"]=t,i=parseFloat(n);switch(r.toLowerCase()){case"rad":return i;case"grad":return i*Math.PI/200;case"turn":return i*2*Math.PI;default:return i*Math.PI/180}}function Xe(e,t){let n=e.trim();if(!n||n==="none")return null;let i=/^matrix(3d)?\((.*)\)$/.exec(n);if(!i)return null;let[,o,l=""]=i,s=l.split(",").map(Number);return s.some(e=>!Number.isFinite(e))?null:o?s.length!==16?null:(t.set(s),t):s.length!==6?null:(Fe(t),t[0]=r(s,0),t[1]=r(s,1),t[4]=r(s,2),t[5]=r(s,3),t[12]=r(s,4),t[13]=r(s,5),t)}function He(e,t){let n=e.trim().split(/\s+/),[r,i,o]=n,l=n.at(-1);if(!r||r==="none"||l===void 0)return null;let s=Ye(l);if(!Number.isFinite(s))return null;let a=[0,0,1];return n.length===2?a=[r==="x"?1:0,r==="y"?1:0,r==="z"?1:0]:n.length===4&&(a=[Number(r),Number(i),Number(o)]),Ae(t,a,s)}function Ae(e,t,n){let r=Math.hypot(t[0],t[1],t[2]);if(Fe(e),!r||!Number.isFinite(r))return e;let i=t[0]/r,o=t[1]/r,l=t[2]/r,s=Math.sin(n),a=Math.cos(n),u=1-a;return e[0]=a+i*i*u,e[1]=o*i*u+l*s,e[2]=l*i*u-o*s,e[4]=i*o*u-l*s,e[5]=a+o*o*u,e[6]=l*o*u+i*s,e[8]=i*l*u+o*s,e[9]=o*l*u-i*s,e[10]=a+l*l*u,e}function Ie(e,t){let n=e.trim().split(/\s+/);if(!n[0]||n[0]==="none")return null;let r=(e,t)=>e===void 0?t:e.endsWith("%")?parseFloat(e)/100:parseFloat(e),i=r(n[0],1),o=r(n[1],i),l=r(n[2],1);return[i,o,l].every(Number.isFinite)?(Fe(t),t[0]=i,t[5]=o,t[10]=l,t):null}function We(e,t,n,r){let i=u(e);if(!i[0]||i[0]==="none")return null;let o=s(i[0],t),l=i[1]===void 0?0:s(i[1],n),a=i[2]===void 0?0:s(i[2],0);return[o,l,a].every(Number.isFinite)?(Fe(r),r[12]=o,r[13]=l,r[14]=a,r):null}function Te(e,t,n){let r=u(e||""),i=r[0]===void 0?t/2:s(r[0],t),o=r[1]===void 0?n/2:s(r[1],n),l=r[2]===void 0?0:s(r[2],0);return[Number.isFinite(i)?i:t/2,Number.isFinite(o)?o:n/2,Number.isFinite(l)?l:0]}var Ee=new Set(["img","video","canvas","iframe","embed","object","svg","input","select","textarea","button"]);function Re(e){return!(e.display==="contents"||e.display==="none"||e.display==="inline"&&!Ee.has(e.tag))}function Ge(e){return Re(e)&&(e.transform!=="none"||e.translate!=="none"||e.rotate!=="none"||e.scale!=="none")}var qe=e(16);function Ve(e,t,n,r){if(!Ge(e))return null;let[i,o,l]=Te(e.transformOrigin,t,n);Fe(r),ze(r,i,o,l);let s=qe;We(e.translate,t,n,s)&&Ce(r,r,s),He(e.rotate,s)&&Ce(r,r,s),Ie(e.scale,s)&&Ce(r,r,s),Xe(e.transform,s)&&Ce(r,r,s);let a=s;return Fe(a),a[12]=-i,a[13]=-o,a[14]=-l,Ce(r,r,a),r}function Ue(e){return Math.abs(e[2])>Ne||Math.abs(e[3])>Ne||Math.abs(e[6])>Ne||Math.abs(e[7])>Ne||Math.abs(e[8])>Ne||Math.abs(e[9])>Ne||Math.abs(e[11])>Ne||Math.abs(e[10]-1)>Ne}function Be(e){return Math.abs(e[1])>Ne||Math.abs(e[4])>Ne||e[0]<=Ne||e[5]<=Ne}function Ze(e){return!(e.transformStyle!=="preserve-3d"||e.overflowX!=="visible"||e.overflowY!=="visible"||(parseFloat(e.opacity)||0)<1&&e.opacity!==""||e.filter!=="none"||e.clipPath!=="none"||e.mask||e.isolation==="isolate"||e.mixBlendMode&&e.mixBlendMode!=="normal"||/\b(paint|strict|content)\b/.test(e.contain))}var je=e(16);function Ke(e,t=0){let n=0,r=je;for(let i=t;i<e.length;i++){let t=e[i];if(!t)break;if(Ve(t,0,0,r)){if(Ue(r)||Math.abs(r[14])>Ne&&Qe(e,i))return 2;Be(r)&&(n=1)}}return n}function Je(e,t,n,r){for(let i=t;i<=n;i++){let t=e[i],n=e[i+1];if(!t||!n)break;if(!(!Ge(t)||n.perspective==="none"||!Re(n))&&!(n.overflowX==="visible"&&n.overflowY==="visible")&&r(i+1))return i+1}return-1}function Qe(e,t){for(let n=t+1;n<e.length;n++){let t=e[n];if(!t)break;if(t.perspective!=="none")return!0;if(!Ze(t))return!1}return!1}function et(e,t,n){n[0]=1,n[1]=0,n[2]=0,n[3]=1;let r=je;for(let i=t;i<e.length;i++){let t=e[i];if(!t)break;if(!Ve(t,0,0,r))continue;let o=r[0],l=r[1],s=r[4],a=r[5],u=n[0],c=n[1],h=n[2],d=n[3];n[0]=o*u+s*c,n[1]=l*u+a*c,n[2]=o*h+s*d,n[3]=l*h+a*d}return n}function tt(e,t){let n=t,r;for(let i=t;i<e.length;i++){let t=e[i];if(!t)break;(Ge(t)||t.perspective!=="none"&&r&&Ge(r))&&(n=i),r=t}return n}var nt=e(16),rt=e(16),it={m:e(16),backHidden:!1,scene:-1};function ot(e,t,n,r){let i=Fe(it.m);it.backHidden=!1,it.scene=-1;for(let o=t;o<=n&&o<e.length;o++){let t=e[o];if(!t)break;ut(i,e,o,r);let l=at(e,o);if(t.backfaceVisibility==="hidden"&&!it.backHidden&&dt(e,o,n,r)&&(it.backHidden=!0),l&&Ze(l)){it.scene=o+1;continue}ct(i)}return it}function lt(e,t,n){return st(e,0,0)||st(e,t,0)||st(e,t,n)||st(e,0,n)}function st(e,t,n){return e[3]*t+e[7]*n+e[15]<=Se}function at(e,t){return e[t+1]}function ut(e,t,n,{rel:i,sizes:o}){let l=t[n];if(!l)return;let s=Ve(l,r(o,n*2)||0,r(o,n*2+1)||0,nt);s&&Ce(e,s,e),ze(e,r(i,n*2)||0,r(i,n*2+1)||0,0);let a=at(t,n);if(a&&a.perspective!=="none"&&Re(a)){let t=parseFloat(a.perspective);if(t>0){let[i,l]=Te(a.perspectiveOrigin,r(o,(n+1)*2)||0,r(o,(n+1)*2+1)||0),s=Fe(rt);s[11]=-1/Math.max(t,1),ze(e,-i,-l,0),Ce(e,s,e),ze(e,i,l,0)}}}function ct(e){e[2]=0,e[6]=0,e[14]=0,e[8]=0,e[9]=0,e[11]=0,e[10]=1}var ht=e(16);function dt(e,t,n,r){let i=Fe(ht);for(let o=t;o<=Math.max(n,t)&&o<e.length;o++){ut(i,e,o,r);let t=at(e,o);if(!t||!Ze(t))break}return Oe(i)<0}function ft(e,t){return t[0]=e[0],t[1]=e[1],t[2]=e[3],t[3]=e[4],t[4]=e[5],t[5]=e[7],t[6]=e[12],t[7]=e[13],t[8]=e[15],t}function pt(e,t){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function mt(e,t,n,{r:r,sx:i,sy:o}){let l=r.left+i,s=r.top+o,a=1/0,u=1/0,c=-1/0,h=-1/0;for(let r=0;r<4;r++){let i=r===1||r===2?t:0,o=r>=2?n:0,l=e[2]*i+e[5]*o+e[8],s=(e[0]*i+e[3]*o+e[6])/l,d=(e[1]*i+e[4]*o+e[7])/l;s<a&&(a=s),s>c&&(c=s),d<u&&(u=d),d>h&&(h=d)}let d=l-a,f=s-u;return e[0]+=d*e[2],e[1]+=f*e[2],e[3]+=d*e[5],e[4]+=f*e[5],e[6]+=d*e[8],e[7]+=f*e[8],Math.max(Math.abs(c-a-r.width),Math.abs(h-u-r.height))}function bt(e,t,n,r){let i=t/2,o=n/2,l=e[2]*i+e[5]*o+e[8],s=(e[0]*i+e[3]*o+e[6])/l,a=(e[1]*i+e[4]*o+e[7])/l,u=(e[0]-s*e[2])/l,c=(e[1]-a*e[2])/l,h=(e[3]-s*e[5])/l,d=(e[4]-a*e[5])/l,f=Math.sqrt(Math.abs(u*d-c*h))||1;return r[0]=f,r[1]=f,r}function gt(e){return Math.abs(e[1])<Ne&&Math.abs(e[3])<Ne&&Math.abs(e[2])<Ne&&Math.abs(e[5])<Ne&&Math.abs(e[8]-1)<Ne}var vt=2,yt=8,wt=e=>e.shape!==null;function xt(){let r=e(8),i=t(4),o=t(4);return{list:[],occluders:[],occluderHow:[],noSlots:!1,occluderSlots:[],mask:null,scissorDoc:r,shaders:[],reason:null,fold:i,ownRadius:o,ownKy:1,count:0,xf:new Float32Array(9*vt),box:new Float32Array(4*vt),radius:new Float32Array(4*vt),poly:new Float32Array(2*yt),polyInfo:new Float32Array([-1,0]),ia:!1,scissorPx:n(4),ka:null,reshaped:!1}}function kt(e,{nodes:t,off:n,isInsideScroll:r,previous:i,occluders:o=[]}){let l=Math.max(0,t.findIndex(t=>t.el===e.el)),{sources:s,mask:a}=ge(t,l,n);if(!s.length&&!a&&!o.length)return null;let u=i??xt();u.occluders=o,u.occluderSlots.length=0,u.occluderHow.length=o.length,u.occluderHow.fill("pruned");let c=[];for(let e of s){let t=u.list.find(t=>t.el===e.node.el&&t.by===e.by),n=t??Mt();c.push({el:e.node.el,by:e.by,node:e.node,own:e.depth<=l,ignored:!1,depth:e.depth,key:t?.key??"",shape:t?.shape??null,reason:t?.reason??null,toDocument:n.toDocument,toShape:n.toShape,bounds:n.bounds,scrolls:r(e.node.el),square:!1,how:"shader"})}return u.list=c,u.mask=a,u}function Mt(){let t=e(9),n=e(9),r=e(4);return{toDocument:t,toShape:n,bounds:r}}function $t(e,t,{width:n,height:r,value:i}){let o=`${t.radius.join(" ")}|${t.border.join(" ")}|${t.padding.join(" ")}`;return e.by==="overflow"?`|${n}|${r}|${o}|${t.overflowClipMargin}|${t.scrollbar.join(" ")}|${t.direction}`:e.by==="clip-path"||e.by==="occlude"?`${i}|${n}|${r}|${o}|${t.margin.join(" ")}`:`${i}|${n}|${r}`}function Nt(e,t,{width:n,height:r,value:i}){return e.by==="overflow"?Me(e.node,t,n,r):e.by==="clip"?X(i,n,r):O(i,{w:n,h:r,border:t.border,padding:t.padding,margin:t.margin,radius:t.radius})}var St=e(4);function Ft(e,t){if(e.kind===0){let[n,r,i,o]=e.box;return t[0]=n,t[1]=r/e.ky,t[2]=n+i,t[3]=(r+o)/e.ky,t}let n=e.points;t[0]=1/0,t[1]=1/0,t[2]=-1/0,t[3]=-1/0;for(let e=0;e<n.length;e+=2){let i=r(n,e),o=r(n,e+1);t[0]=Math.min(t[0],i),t[2]=Math.max(t[2],i),t[1]=Math.min(t[1],o),t[3]=Math.max(t[3],o)}return t}function Ct(e,t,n){let r=Q(e.node),i=$t(e,r,n);if(i!==e.key||!e.shape&&!e.reason){e.key=i;let t=Nt(e,r,n);e.shape=t&&"shape"in t?t.shape:null,e.reason=t&&"reason"in t?t.reason:null,t||(e.reason="none")}t!==e.toDocument&&e.toDocument.set(t);let l=e.shape;if(l){if(!o(e.toShape,e.toDocument)){e.toShape.fill(0),e.bounds.fill(0),e.square=!0;return}e.toShape[1]*=l.ky,e.toShape[4]*=l.ky,e.toShape[7]*=l.ky,Pt(e.bounds,t,Ft(l,St)),e.square=l.kind===0&&l.radius.every(e=>e<=0)&&gt(t)}}function Pt(e,t,n){let r=n[0],i=n[1],o=n[2],l=n[3];e[0]=1/0,e[1]=1/0,e[2]=-1/0,e[3]=-1/0;let s=Math.max(Math.abs(r),Math.abs(o),Math.abs(i),Math.abs(l))>1e5;for(let n=0;n<4;n++){let a=n===1||n===2?o:r,u=n>=2?l:i,c=s?1:t[2]*a+t[5]*u+t[8],h=(t[0]*a+t[3]*u+t[6])/c,d=(t[1]*a+t[4]*u+t[7])/c;h<e[0]&&(e[0]=h),d<e[1]&&(e[1]=d),h>e[2]&&(e[2]=h),d>e[3]&&(e[3]=d)}}function zt(e,t,n){let r=e.shape,i=e.toShape,o=i[2]*t+i[5]*n+i[8],l=(i[0]*t+i[3]*n+i[6])/o,s=(i[1]*t+i[4]*n+i[7])/o;return r.kind===0?H(l,s,r,.01):I(l,s,r.points)}function Dt(e,t){let n=e.shape;return n.kind===1&&!Lt(n.points)?!1:zt(e,t[0],t[1])&&zt(e,t[2],t[1])&&zt(e,t[2],t[3])&&zt(e,t[0],t[3])}function Lt(e){let t=e.length/2,n=0;for(let i=0;i<t;i++){let o=i*2,l=(i+1)%t*2,s=(i+2)%t*2,a=(r(e,l)-r(e,o))*(r(e,s+1)-r(e,l+1))-(r(e,l+1)-r(e,o+1))*(r(e,s)-r(e,l));if(a!==0){if(n===0)n=Math.sign(a);else if(Math.sign(a)!==n)return!1}}return!0}var Ot=e(4);function _t(e,t,n,r){t.reason=null,t.scissorDoc.fill(NaN),t.shaders.length=0,t.fold.fill(0),t.mask&&(t.reason={code:"mask",clips:[]});let i=Ot,o=r?(n[2]-n[0])*.25:0,l=r?(n[3]-n[1])*.25:0;i[0]=n[0]-o,i[1]=n[1]-l,i[2]=n[2]+o,i[3]=n[3]+l;let s=Yt(e,t,i);for(let t=s.length-1;t>=0;t--){let n=s[t];n&&n.scrolls===e.scrolls&&Dt(n,i)&&(n.how="pruned",s.splice(t,1))}r||Ht(e,t,s,n);let a=s.filter(e=>e.shape.kind===1);(s.length>vt||a.length>1)&&(t.reason??={code:"too-many",clips:s});for(let e of s)e.how="shader",t.shaders.length<vt&&t.shaders.push(e);return At(t)&&(t.reshaped=!0),t.reason}function Yt(e,t,n){let r=[];for(let i of t.list){if(i.ignored){i.how="ignored";continue}if(i.reason==="none"){i.how="pruned";continue}if(i.reason||!wt(i)){t.reason??={code:i.reason??"unparsed",clips:[i]};continue}i.square?i.how=Xt(e,t,i,n):r.push(i)}return r}function Xt(e,t,n,i){let o=n.bounds;if(n.scrolls===e.scrolls&&o[0]<=i[0]&&o[1]<=i[1]&&o[2]>=i[2]&&o[3]>=i[3])return"pruned";let l=n.scrolls?0:4,s=t.scissorDoc;return Number.isNaN(s[l])?s.set(o,l):(s[l]=Math.max(s[l],o[0]),s[l+1]=Math.max(r(s,l+1),o[1]),s[l+2]=Math.min(r(s,l+2),o[2]),s[l+3]=Math.min(r(s,l+3),o[3])),"scissor"}function Ht(e,t,n,r){for(let i=n.length-1;i>=0;i--){let o=n[i];if(!o)continue;let l=o.shape,s=o.bounds,a=o.toDocument[0];if(!(e.level===0&&gt(o.toDocument)&&o.scrolls===e.scrolls&&l.kind===0&&l.ky===1&&Math.abs(a-o.toDocument[4])<.01*a&&Math.abs(s[0]-r[0])<.5&&Math.abs(s[1]-r[1])<.5&&Math.abs(s[2]-r[2])<.5&&Math.abs(s[3]-r[3])<.5))continue;let u=t.fold;u[0]=Math.max(u[0],l.radius[0]*a),u[1]=Math.max(u[1],l.radius[1]*a),u[2]=Math.max(u[2],l.radius[2]*a),u[3]=Math.max(u[3],l.radius[3]*a),o.how="corners",n.splice(i,1)}}function At(e){let t=!1,n=(e,n,r)=>{let i=Math.fround(r);e[n]!==i&&(e[n]=i,t=!0)};for(let t=0;t<e.shaders.length;t++){let i=e.shaders[t]?.shape;if(!i)break;let o=i.kind===0?i:It;for(let i=0;i<4;i++)n(e.box,t*4+i,r(o.box,i)),n(e.radius,t*4+i,r(o.radius,i))}let[i,o]=Wt(e);for(let t=0;t<2*yt;t++)n(e.poly,t,o[t]??0);return n(e.polyInfo,0,i),n(e.polyInfo,1,o.length/2),t}var It={box:[0,0,0,0],radius:[0,0,0,0]};function Wt(e){for(let t=e.shaders.length-1;t>=0;t--){let n=e.shaders[t]?.shape;if(n?.kind===1)return[t,n.points]}return[-1,[]]}var Tt={visible:!0,moved:!1},Et=e(9),Rt={moved:!1,x0:0,y0:0,x1:0,y1:0,any:!1,own0:0,own1:0,own2:0,own3:0,slots:0,cutter:null},Gt=e(4),qt=e(4);function Vt(e,t,n,r){return Rt.moved=e.reshaped,e.reshaped=!1,e.ka=null,Ut(e.scissorDoc,r),Tt.visible=Bt(e,t,n,r)&&tn(e,t,n,r)&&sn(e,t,n,r),Tt.moved=Rt.moved,Tt}function Ut(e,t){Rt.x0=-1/0,Rt.y0=-1/0,Rt.x1=1/0,Rt.y1=1/0,Rt.any=!1;for(let n=0;n<8;n+=4){if(Number.isNaN(e[n]))continue;Rt.any=!0;let i=n===0?t.scrollX:t.pageX,o=n===0?t.scrollY:t.pageY;Rt.x0=Math.max(Rt.x0,r(e,n)-i),Rt.y0=Math.max(Rt.y0,r(e,n+1)-o),Rt.x1=Math.min(Rt.x1,r(e,n+2)-i),Rt.y1=Math.min(Rt.y1,r(e,n+3)-o)}Rt.own0=Rt.x0,Rt.own1=Rt.y0,Rt.own2=Rt.x1,Rt.own3=Rt.y1}function Bt(e,t,n,r){Rt.slots=0,Rt.cutter=null;let i=e.occluders;if(i.length){let o=n?t[2]*.25:0,l=n?t[3]*.25:0,s=Gt;s[0]=t[0]-o,s[1]=t[1]-l,s[2]=t[0]+t[2]+o,s[3]=t[1]+t[3]+l;for(let t=0;t<i.length;t++){let n=i[t];if(!n)break;let o=Zt(e,n,s,r);if(e.occluderHow[t]=o??"pruned",!o)return e.ka=n,!1}}return e.occluderSlots.length>Rt.slots&&(e.occluderSlots.length=Rt.slots),!0}function Zt(e,t,n,r){let i=jt(t,r);if(t.ignored||!t.shape||Kt(i,n))return"pruned";let o=i[0]<=n[0]&&i[2]>=n[2],l=i[1]<=n[1]&&i[3]>=n[3],s=Qt(t,i,n);if(s&&o&&l)return null;let a=en(o,l,i,n),u=!e.noSlots&&e.shaders.length+Rt.slots<vt;return a&&(s||!u&&t.axis)?(Jt(a,i),Rt.cutter=t,"scissor"):u?(e.occluderSlots[Rt.slots++]=t,"shader"):"uncut"}function jt(e,t){let n=e.scrolls?t.scrollX:t.pageX,r=e.scrolls?t.scrollY:t.pageY,i=qt;return i[0]=e.bounds[0]-n,i[1]=e.bounds[1]-r,i[2]=e.bounds[2]-n,i[3]=e.bounds[3]-r,i}var Kt=(e,t)=>e[0]>=t[2]||e[2]<=t[0]||e[1]>=t[3]||e[3]<=t[1];function Jt(e,t){e===1?Rt.y0=Math.max(Rt.y0,t[3]):e===2?Rt.y1=Math.min(Rt.y1,t[1]):e===3?Rt.x0=Math.max(Rt.x0,t[2]):Rt.x1=Math.min(Rt.x1,t[0]),Rt.any=!0}function Qt(e,t,n){return e.axis?e.square||n[0]>=t[0]+e.radiusX&&n[2]<=t[2]-e.radiusX||n[1]>=t[1]+e.radiusY&&n[3]<=t[3]-e.radiusY:!1}function en(e,t,n,r){return e&&n[1]<=r[1]?1:e&&n[3]>=r[3]?2:t&&n[0]<=r[0]?3:t&&n[2]>=r[2]?4:0}function tn(e,t,n,r){let{x0:i,y0:o,x1:l,y1:s}=Rt,a=!1;if(Rt.any){if(l<=i||s<=o||!n&&(rn(t,i,l)||on(t,o,s)))return e.ka=nn(e,t,n),!1;if(a=n||t[0]<i||t[1]<o||t[0]+t[2]>l||t[1]+t[3]>s,a&&!ln(e,r))return e.ka=Rt.cutter??e.list.find(e=>e.how==="scissor")??null,!1}return a!==e.ia&&(e.ia=a,Rt.moved=!0),!0}function nn(e,t,n){return(Rt.own2<=Rt.own0||Rt.own3<=Rt.own1||!n&&(rn(t,Rt.own0,Rt.own2)||on(t,Rt.own1,Rt.own3))?null:Rt.cutter)??e.list.find(e=>e.how==="scissor")??Rt.cutter}var rn=(e,t,n)=>e[0]>=n||e[0]+e[2]<=t,on=(e,t,n)=>e[1]>=n||e[1]+e[3]<=t;function ln(e,t){let n=Math.min(t.canvasWidth,Math.max(0,Math.round(Rt.x0*t.canvasPerCssX))),r=Math.min(t.canvasWidth,Math.max(0,Math.round(Rt.x1*t.canvasPerCssX))),i=Math.min(t.canvasHeight,Math.max(0,Math.round(Rt.y0*t.canvasPerCssY))),o=Math.min(t.canvasHeight,Math.max(0,Math.round(Rt.y1*t.canvasPerCssY)));if(r<=n||o<=i)return!1;let l=e.scissorPx,s=t.canvasHeight-o;return(l[0]!==n||l[1]!==s||l[2]!==r-n||l[3]!==o-i)&&(l[0]=n,l[1]=s,l[2]=r-n,l[3]=o-i,Rt.moved=!0),!0}function sn(e,t,n,r){let i=e.shaders.length,o=i+Rt.slots;o!==e.count&&(e.count=o,Rt.moved=!0);for(let o=0;o<i;o++){let i=e.shaders[o];if(!i)break;if(!n&&an(i,t,r))return e.ka=i,!1;cn(e,o,i,r)&&(Rt.moved=!0)}for(let t=0;t<Rt.slots;t++){let n=e.occluderSlots[t];if(!n)break;un(e,i+t,n,r)}return!0}function an(e,t,n){let r=e.scrolls?n.scrollX:n.pageX,i=e.scrolls?n.scrollY:n.pageY,o=e.bounds;return t[0]>=o[2]-r||t[0]+t[2]<=o[0]-r||t[1]>=o[3]-i||t[1]+t[3]<=o[1]-i}function un(e,t,n,i){cn(e,t,n,i)&&(Rt.moved=!0);let o=n.shape;if(o)for(let n=0;n<4;n++){let i=Math.fround(r(o.box,n)),l=Math.fround(r(o.radius,n));(e.box[t*4+n]!==i||e.radius[t*4+n]!==l)&&(e.box[t*4+n]=i,e.radius[t*4+n]=l,Rt.moved=!0)}}function cn(e,t,n,i){let o=t<e.shaders.length?1:-1,l=n.scrolls?i.scrollX:i.pageX,s=n.scrolls?i.scrollY:i.pageY,a=1/i.canvasPerCssX,u=1/i.canvasPerCssY,c=n.toShape,h=i.canvasHeight*u+s,d=Et;d[0]=c[0]*a,d[1]=c[1]*a,d[2]=c[2]*a,d[3]=-c[3]*u,d[4]=-c[4]*u,d[5]=-c[5]*u,d[6]=c[0]*l+c[3]*h+c[6],d[7]=c[1]*l+c[4]*h+c[7],d[8]=c[2]*l+c[5]*h+c[8];let f=e.xf,p=!1;for(let e=0,n=t*9;e<9;e++,n++){let t=Math.fround(r(d,e)*o);f[n]!==t&&(f[n]=t,p=!0)}return p}function hn(e){let t=!!e.shape?.radius.some(e=>e>0);if(e.by==="occlude")return t?"data-umber-occlude, rounded":"data-umber-occlude";if(e.by==="overflow"){let n=dn(e.node);return t?`${n}, rounded`:n}let n=e.by==="clip"?e.node.clip:e.node.clipPath;return`${e.by==="clip"?"clip: ":""}${n.length>60?`${n.slice(0,57)}...`:n}`}function dn(e){let t=e.overflowX===e.overflowY?e.overflowX:`${e.overflowX} ${e.overflowY}`;return t!=="visible"?`overflow: ${t}`:e.contentVisibility!=="visible"?`content-visibility: ${e.contentVisibility}`:`contain: ${e.contain}`}function fn(e,t){let n=i(e.el),r=t.reason;if(!r)return`${n}: its clips can be drawn in GL.`;let o=e=>e.length>40?`${e.slice(0,37)}...`:e;if(r.code==="mask")return`${n}: GL can't draw the CSS mask on ${i(t.mask?.el)}, so its DOM shows. Move the mask off the parents of GL elements, or add data-umber-clip="false" to draw it unmasked.`;if(r.code==="too-many")return`${n}: cut by too many rounded or shaped parents (${r.clips.map(e=>i(e.el)).join(", ")}), so its DOM shows. Make one of them a straight overflow: hidden, keep one polygon (up to ${yt} points), or add data-umber-clip="false".`;let[l]=r.clips;if(!l)return`${n}: its clips can't be drawn in GL (${r.code}), so its DOM shows.`;switch(r.code){case"mixed-corners":return`${n}: ${i(l.el)}'s corners mix different horizontal / vertical radii; GL needs one ratio for all of them, so its DOM shows. Use the same radius both ways (or one shape for all corners).`;case"polygon-points":return`${n}: clip-path polygon() on ${i(l.el)} has more than ${yt} points; GL draws up to ${yt}, so its DOM shows. Simplify the polygon${l.own?"":', or add data-umber-clip="false" to draw it uncut'}.`;case"polygon-nonzero":return`${n}: clip-path polygon() on ${i(l.el)} crosses itself, and GL fills polygons even-odd, so its DOM shows. Write polygon(evenodd, ...) or untangle it.`;default:{let e=l.by==="clip"?l.node.clip:l.node.clipPath;return`${n}: ${l.by==="clip"?"clip":"clip-path"} ${o(e)} on ${i(l.el)} can't be drawn in GL, so its DOM shows. Use inset(), rect(), xywh(), circle(), ellipse() or polygon()${l.own?"":', or add data-umber-clip="false" to draw it uncut'}.`}}}function pn(e,t,n,r=e.rect){let i=e.offset;if(r[0]=e.doc.x-t+(i?i[0]:0),r[1]=e.doc.y-n+(i?i[1]:0),r[2]=e.doc.w,r[3]=e.doc.h,e.pad){let t=e.pad*(e.layoutW?e.doc.w/e.layoutW:1),n=e.pad*(e.layoutH?e.doc.h/e.layoutH:1);r[0]-=t,r[1]-=n,r[2]+=t*2,r[3]+=n*2}return r}var mn=/^(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)/,bn=/^(rotate|perspective|offset|clip|display|border\w*Radius|all$|zoom)/,gn={transform:/^(none|((translate[XY]?\([^()]*\)|scale[XY]?\([^()-]*\)) ?)+)$/,translate:/^\S+( \S+)?$/,scale:/^[^-\s]+( [^-\s]+)?$/},vn=new WeakMap;function yn(e){let t=vn.get(e);if(t!==void 0)return t;try{let n=e.effect.getKeyframes();t=0;for(let e of new Set(n.flatMap(e=>Object.keys(e)))){if(!mn.test(e))continue;let r=n.map(t=>t[e]).filter(e=>e!=null),i=gn[e];t=Math.max(t,bn.test(e)||i&&!(r.length&&r.every(e=>i.test(String(e).trim())))?2:1)}}catch{t=2}return vn.set(e,t),t}var wn=e=>yn(e)>0;var xn=50;function kn(e,{onlyHiding:t=!1}={}){try{return e.getKeyframes().some(e=>"opacity"in e&&!(t&&parseFloat(e.opacity)>0)||"visibility"in e||"clipPath"in e)}catch{return!0}}var Mn=/^(offset|computedOffset|easing|composite|opacity|filter|color|\w+(Color|Shadow))$/,$n=e=>!kn(e,{onlyHiding:!0})&&e.getKeyframes().every(e=>Object.keys(e).every(e=>Mn.test(e)));function Nn(e){return typeof CSSTransition<"u"&&e instanceof CSSTransition?"CSS transition":typeof CSSAnimation<"u"&&e instanceof CSSAnimation?"CSS animation":"Web Animation"}function Sn(e,t,n){let r=t.getComputedTiming(),i=Number(r.endTime);if(i===1/0)return 1/0;let o=Number(r.localTime??0)||0;return n+Math.max(0,e.playbackRate<0?o:i-o)/Math.abs(e.playbackRate)+xn}var Fn=class{constructor(e,t){this.stage=e;this.occluders=t;this.held=[]}scan(e){let t=this.stage;t.measurePhase.Oc();let n=this.held;if(this.held=[],typeof document.getAnimations=="function"){for(let e of this.occluders.list)e.until=0,e.linked=!1,e.fades=!1;if(this.th()){for(let t of document.getAnimations()){let r=Cn(t,e);r&&(this.Ng(r,r.fx),this.Og(r,n))}for(let e of t.planes.all)e._m&&(e._m=!1,e.animUntil!==1/0&&(e.stale=!0))}}}th(){let e=!1;for(let t of this.stage.planes.all)t.zone.soon&&(e=!0,t._m=t.animUntil===1/0,t._m&&(t.animUntil=0),t.scrollLinked=!1,t._p.length=0,t.animUntil||(t.animLabel=""));return e}Ng(e,t){for(let n of this.occluders.list)!e.target.contains(n.el)||e.until===1/0&&$n(t)||(n.fades||=kn(t,{onlyHiding:e.until===1/0}),e.scrollTimeline?n.linked=!0:e.until>n.until&&(n.until=e.until))}Og(e,t){let n=null;for(let r of this.stage.planes.all)!r.zone.soon||!(e.target===r.el||e.target.contains(r.geomEl))||(r._p.includes(e.target)||r._p.push(e.target),e.scrollTimeline?(r.scrollLinked=!0,r.animLabel||=`scroll-driven ${e.kind} on ${i(e.target)}`):e.running?Pn(r,e):(n??=this.hold(e,t),zn(r,e,t,n)))}hold(e,t){let n=t.find(t=>t.a===e.a),r={a:e.a,t:n?n.t:e.a.currentTime,state:e.state,planes:[]};return this.held.push(r),r}Zc(){for(let e of this.held){let t=e.a.playState;t!==e.state&&(e.state=t,this.stage.measurePhase.da(),this.stage.scheduler.request());let n=e.a.currentTime;if(n!==e.t){e.t=n;for(let t of e.planes)t.heldMoved=!0}}}uc(e){let t=this.stage;if(t.scheduler.inactive)return;if(this.held.some(t=>t.a===e)){t.scheduler.request();return}if(!wn(e))return;let n=e.effect?.target;if(n){if(this.occluders.holds(n)){t.measurePhase.da(),t.scheduler.request();return}t.measurePhase.tc(n)}}};function Cn(e,t){let n=e.playState;if(n==="idle")return null;let r=e.effect,i=r?.target;if(!r||!i||r.pseudoElement||!wn(e))return null;let o=n==="running"&&!!e.playbackRate,l=typeof DocumentTimeline<"u"?DocumentTimeline:null,s=!!(e.timeline&&l&&!(e.timeline instanceof l)),a=o&&!s?Sn(e,r,t):0;return{a:e,fx:r,target:i,state:n,running:o,scrollTimeline:s,until:a,kind:Nn(e)}}function Pn(e,t){t.until<=e.animUntil||(e.animUntil=t.until,e.animLabel=`${t.until===1/0?"infinite ":""}${t.kind} on ${i(t.target)}`)}function zn(e,t,n,r){n.some(e=>e.a===t.a)||(e.heldMoved=!0),r.planes.push(e),e.animLabel||=`${t.state} ${t.kind} on ${i(t.target)} (followed while a script moves its time)`}var Dn=e=>!!e.backgroundImage&&e.backgroundImage!=="none"||!/^(transparent|rgba\(.*,\s*0\))$/.test(e.backgroundColor||"transparent"),Ln=["transform","translate","rotate","scale","perspective","filter","backdropFilter","clipPath","maskImage","webkitMaskImage"],On=e=>e.position!=="static"&&e.zIndex!=="auto"||/fixed|sticky/.test(e.position)||parseFloat(e.opacity)<1||Ln.some(t=>(e[t]||"none")!=="none")||e.isolation==="isolate"||(e.mixBlendMode||"normal")!=="normal"||/\b(layout|paint|strict|content)\b/.test(e.contain)||/^(size|inline-size)$/.test(e.containerType)||/\b(transform|translate|rotate|scale|perspective|filter|opacity|clip-path|mask|isolation|mix-blend-mode|contain)\b/.test(e.willChange),_n=e=>e!==null&&e!==document.body&&e!==document.documentElement;function Yn(e,t){let n=parseInt(getComputedStyle(t).zIndex,10);if(!(n>0))return null;let r=null,o="auto",l=[];for(let t=e;_n(t);t=t.parentElement){let n=getComputedStyle(t);Dn(n)&&!(t===e&&e.matches("[data-umber~=shader]"))&&l.push(t),On(n)&&(r=t,o=n.position!=="static"?n.zIndex:"auto")}return!r||o==="auto"||+o<n||!l.some(e=>r.contains(e))?null:`${i(r)} (z-index ${o}, with a background) covers Umber's canvas (z-index ${n}): GL inside it is hidden. Drop that z-index (and give it data-umber-occlude if it must still cover the GL elements before it) or move the background behind the content.`}function Xn(e,t,n){let r=parseInt(getComputedStyle(n).zIndex,10);if(!(r>0)||t>=r||!On(getComputedStyle(e)))return null;let o=i(e);return[...e.querySelectorAll("[data-umber~=above]")].map(e=>[e,`data-umber="above" on ${i(e)} stays under Umber's canvas: ${o} around it is a stacking context (a pin, a transform, a fade) under the canvas (z-index ${r}). Give ${o} position: relative and z-index: ${r+1} (no background), or move it out.`])}function Hn(e){let t=[],n=!0;for(let r=e;_n(r);r=r.parentElement){let e=getComputedStyle(r),i=On(e),o=e.position!=="static";(i||n&&o)&&t.unshift([r,o&&e.zIndex!=="auto"&&+e.zIndex||0]),(i||o)&&(n=!1)}return t}function An(e,t,n,r){let i=0;for(;i<t.length&&i<r.length&&t[i]?.[0]===r[i]?.[0];)i++;let o=t[i]?.[1]??-.5,l=r[i]?.[1]??-.5;return o!==l?l>o:!!(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function In(e){let t=getComputedStyle(e),n=t.backgroundColor||"transparent";return(n!=="transparent"&&!n.startsWith("rgba(")&&!/\/\s*(0?\.\d+|0)\s*\)$/.test(n)||!!t.backgroundImage&&t.backgroundImage!=="none")&&parseFloat(t.opacity)>=1}var Wn={1:.75,2:1.5},Tn=3,En=typeof navigator<"u"&&navigator.userAgent.includes("AppleWebKit/")&&!/Chrome\/|Chromium\//.test(navigator.userAgent),Rn=e=>!!e&&Q(e).radius.some(e=>e.split(" ").every(e=>parseFloat(e)>0));function Gn(e){let t=null;for(let n of e)Ge(n)&&(n.transform!=="none"||n.rotate!=="none")&&(t=n.el);if(!t)for(let n of e)(Ge(n)||n.perspective!=="none")&&(t=n.el);return t}function qn(e,t,n){let r=i(e.el),o=i(n);switch(t){case"behind":return`${r}: part of it turns behind the viewer (3D transform on ${o}), so its DOM shows until it turns back. Lower the angle or raise the perspective.`;case"svg":return`${r}: GL elements can't sit inside an <svg> (${o}); its DOM shows. Move data-umber to an element outside the SVG.`;case"offset-path":return`${r}: offset-path on ${o} moves it along a path GL does not follow, so its DOM shows. Animate transform instead.`;case"scene":return`${r}: GL can't depth-sort several GL elements in one preserve-3d scene (${o}), so their DOM shows. Add backface-visibility: hidden to faces that turn away, or use transform-style: flat.`;case"rounded":return`${r}: WebKit draws a tilt flat when its perspective parent (${o}) also has overflow and border-radius, so its DOM shows. Put the perspective on an inner element, or round the corners with clip-path: inset(0 round <radius>).`;case"zoom":return`${r}: zoom on ${o} scales it in a way GL can't follow together with its transforms, so its DOM shows. Use transform: scale() instead of zoom.`;case"verify":return`${r}: its on-screen box doesn't match the transforms on ${o} (turned almost edge-on?), so its DOM shows until they agree again. Lower the angle or raise the perspective.`}}function Vn(e,t){for(let n of t){if(n.el.namespaceURI==="http://www.w3.org/2000/svg")return qn(e,"svg",n.el);if(n.offsetPath!=="none"&&n.offsetPath!==""&&Re(n))return qn(e,"offset-path",n.el)}return null}function Un(e,t,n){let r=Q(e);n.w=Number.isFinite(r.width)&&r.width>0?r.width:t.width,n.h=Number.isFinite(r.height)&&r.height>0?r.height:t.height}var Bn=class{constructor(t){this.stage=t;this.Dc=new Map;this.zc=new Map;this.Jc=new Set;this.td=e(4);this.wa={rel:new Float64Array(64),sizes:new Float64Array(64),bodyOrNull:()=>this.stage.env.lib.bodyOrNull()}}clear(){this.Dc.clear(),this.zc.clear(),this.Jc.clear()}tb(e){let t=this.Dc.get(e);return t||(t=e.getBoundingClientRect(),this.Dc.set(e,t)),t}grow(e){this.wa.rel.length>=e*2+2||(this.wa.rel=new Float64Array(e*4),this.wa.sizes=new Float64Array(e*4))}Ed(e,t,n,r){let{sx:i,sy:o,w:s,h:a}=n,u=e[t]?.el;if(!u)return!1;let c=this.zc.get(u);if(c!==void 0)return c&&r.set(c),!!c;let h=this.tb(u),d=Ke(e,t),f=!0,p={r:h,sx:i,sy:o};return d===0?l(r,s,a,p):(d===1?pt(et(e,t,this.td),r):f=this.Sh(e,t,n,r),f&&mt(r,s,a,p)),this.zc.set(u,f?r:null),f}Sh(e,t,n,r){let i=tt(e,t);if(this.grow(e.length),!V(e,t,i,this.wa))return!1;let{m:o}=ot(e,t,i,this.wa);return lt(o,n.w,n.h)?!1:(ft(o,r),!0)}ud(e,t){let{full:n,restyle:r,r:i}=t;(n||r)&&this.kh(e,n,r,i);let o=e.level;if(e.backHidden=!1,e.scene=null,e.xfReason=e._w,!o||e._w){e.edge[0]=1,e.edge[1]=1;return}let l=e._q,s=null;o===1?pt(et(e.nodes,0,this.td),l):s=this.tilt(e),s??=this.verify(e,o,t),s||bt(l,e._f,e._d,e.edge),e.xfReason=s}kh(e,t,n,r){let i=e.nodes;if(t)i=this.ki(e);else if(n&&(e.level&&e.dynamic.length||e._p.length))this.sh(e,i);else return;let[o]=i;if(!o)return;t||(o.box=void 0);let l=Q(o);e._f=Number.isFinite(l.width)&&l.width>0?l.width:r.width,e._d=Number.isFinite(l.height)&&l.height>0?l.height:r.height;let s=Ke(i,0);s!==e.level&&e.raster&&(e.raster.ja=!0),e.level=s}sh(e,t){if(e.level)for(let n of e.dynamic){let e=t[n];e&&q(e,this.Jc)}for(let n of e._p){let e=t.find(e=>e.el===n);e&&q(e,this.Jc)}}ki(e){let t=e.nodes=ne(e.geomEl,this.stage.env.frame.Va);e.chained=!0;let n=e.dynamic;return n.length=0,t.forEach((t,r)=>{(Ge(t)||t.perspective!=="none"||e._p.includes(t.el))&&n.push(r)}),e._w=Vn(e,t),t}tilt(e){let t=e.nodes,n=tt(t,0);if(this.grow(t.length),!V(t,0,n,this.wa))return qn(e,"svg",t[0]?.el??null);let r=ot(t,0,n,this.wa);if(ft(r.m,e._q),e.backHidden=r.backHidden,e.scene=t[r.scene]?.el??null,lt(r.m,e._f,e._d))return qn(e,"behind",Gn(t));if(!En)return null;let i=Je(t,0,n,e=>Rn(t[e]));return i>=0?qn(e,"rounded",t[i]?.el??null):null}verify(e,t,n){if(mt(e._q,e._f,e._d,n)<=Wn[t])return e._N=0,null;if((n.now<e.animUntil||e.scrollLinked)&&++e._N<Tn)return null;let r=e.nodes,i=r.find(e=>e.zoom&&Math.abs(parseFloat(e.zoom)-1)>1e-6);return i?qn(e,"zoom",i.el):qn(e,"verify",Gn(r))}};function Zn(t,n){if(!n.level||n.xfReason)return null;let r=e(9);if(!o(r,n._q))return null;let i=n.scrolls?t.env.host.scroll.root:null,l=i?i.scrollLeft:Z(t.env.lib.bodyOrNull),s=i?i.scrollTop:j(t.env.lib.bodyOrNull),a=n._q,u=n._f/2,c=n._d/2,h=a[2]*u+a[5]*c+a[8],d=(a[0]*u+a[3]*c+a[6])/h,f=(a[1]*u+a[4]*c+a[7])/h;return{width:n._f,height:n._d,ax:(a[0]-d*a[2])/h,ay:(a[1]-f*a[2])/h,bx:(a[3]-d*a[5])/h,by:(a[4]-f*a[5])/h,toLocal(e,t,n){let i=e+l,o=t+s,u=r[2]*i+r[5]*o+r[8],c=(r[0]*i+r[3]*o+r[6])/u,h=(r[1]*i+r[4]*o+r[7])/u;n[0]=c,n[1]=h;let d=a[2]*c+a[5]*h+a[8];n[2]=(a[0]-i*a[2])/d,n[3]=(a[1]-o*a[2])/d,n[4]=(a[3]-i*a[5])/d,n[5]=(a[4]-o*a[5])/d}}}function jn(e){let t=new Map;for(let n of e.planes.all)n.scene&&!n.backHidden&&!n.xfReason&&n.el.isConnected&&t.set(n.scene,(t.get(n.scene)??0)+1);for(let n of e.planes.all){let r=n.scene&&!n.backHidden&&(t.get(n.scene)??0)>1?qn(n,"scene",n.scene):null;r!==n._F&&(n._F=r,e.fallbacks.decide(n))}}function Kn(e){let t=getComputedStyle(e.el);e.by==="clip"?e.node.clip=t.getPropertyValue("clip")||"auto":e.node.clipPath=t.clipPath||"none"}var Jn=class{constructor(n,r,i,o){this.stage=n;this.placement=r;this.occluders=i;this.od=o;this.box={sx:0,sy:0,w:0,h:0};this.ad=new WeakSet;this.contexts=new WeakSet;this.quad=e(4);this.Id=t(4)}measure(e,t,n=!0){if(e.nodes[e.nodes.length-1]?.topLayer)return`${i(e.el)}: it is inside an open modal <dialog> or popover (the top layer), which paints over Umber's canvas, so its DOM shows.`;this.uncut(e),t&&this.ca(e);let o=e.clips;if(!o)return null;o.noSlots=e.kind==="layer",this.bh(e,t,n),pn(e,0,0,this.Id);let l=this.Id,s=this.quad;s[0]=l[0],s[1]=l[1],s[2]=l[0]+l[2],s[3]=l[1]+l[3];let a=_t(e,o,s,e.bends);e.stale&&(o.ownRadius.set(e.radius),o.ownKy=e._b);let u=!1;for(let t=0;t<4;t++){let n=r(o.ownRadius,t),i=r(o.fold,t);e.radius[t]=Math.max(n,i),u||=i>n}if(e._b=u?1:o.ownKy,e.kind!=="layer")return a?fn(e,o):null;if(a||o.shaders.length){let t=o.shaders[0]?.el??a?.clips[0]?.el??o.mask?.el;this.stage.fallbacks.Fa(e,`${i(e.el)}: a layer can't be cut by a rounded, shaped or masked parent (${i(t)}); it draws uncut. Make that parent's clip a straight overflow: hidden, or add data-umber-clip="false" to silence this.`),o.shaders.length=0,o.reason=null}return null}uncut(e){let t=e.clips,n=t?t.occluderHow.indexOf("uncut"):-1,r=t?.occluders[n];if(!t||!r)return;let o=i(r.el);this.stage.fallbacks.Fa(e,t.noSlots?`${i(e.el)}: a layer can only be cut straight, so data-umber-occlude on ${o} doesn't hide it where it passes through it or a rounded or turned corner overlaps it (GL draws over that panel there).`:`${i(e.el)}: its parents' rounded or shaped clips take both GL clip slots, so data-umber-occlude on ${o} doesn't hide it where they overlap (GL draws over that panel there). Make one of those parents' clips a straight overflow: hidden.`)}ca(e){let t=this.stage;if(!t.transitions.ongoing){if(!this.ad.has(e)){this.ad.add(e);let n=Yn(e.el,t.canvasHost.el);n&&t.fallbacks.Fa(e,`${i(e.el)}: ${n}`)}let n=Hn(e.el),r=n.length?n[0]:null,o=r&&r[0]!==e.el&&!this.contexts.has(r[0])&&Xn(r[0],r[1],t.canvasHost.el);if(o){this.contexts.add(r[0]);for(let[e,n]of o)t.env.host.log.warn(n,e)}}let n=(e.el.getAttribute("data-umber-clip")??"").trim().toLowerCase()==="false";e.clips=kt(e,{nodes:e.nodes,off:n,isInsideScroll:this.od,previous:e.clips,occluders:this.occluders.gg(e)})}bh(e,t,n){let r=this.stage;for(let i of e.clips?.list??[]){i.by!=="overflow"&&!t&&n&&Kn(i);let o=Qn(i),l=this.box;l.sx=i.scrolls?r.env.frame.scrollX:r.env.frame.pageX,l.sy=i.scrolls?r.env.frame.scrollY:r.env.frame.pageY,Un(i.node,this.placement.tb(i.el),l),i.ignored=!this.placement.Ed(e.nodes,i.depth,l,i.toDocument),i.ignored||Ct(i,i.toDocument,{width:l.w,height:l.h,value:o})}}};function Qn(e){return e.by==="overflow"?"":e.by==="clip"?e.node.clip:e.node.clipPath}var er=[],tr=4;function nr(e,t){if(t.contains(e)||e.contains(t))return!0;let n=e.parentElement;for(let e=t,r=0;e&&e!==document.body&&r<tr;e=e.parentElement,r++){let t=e.parentElement;if(t&&(n===t||n?.parentElement===t))return!0}return!1}var rr=/^(SPAN|B|I|EM|STRONG|SMALL|SUB|SUP|TIME|BR)$/;function ir(e){for(let t of e)if(t.nodeType===1&&!rr.test(t.nodeName))return!0;return!1}function or(t,n){let r=e(9),i=e(9),o=e(4),l=e(8);return{el:t,by:"occlude",node:n,nodes:[],own:!1,ignored:!0,depth:0,key:"",shape:null,reason:null,toDocument:r,toShape:i,bounds:o,scrolls:!0,square:!1,how:"pruned",live:!1,axis:!0,radiusX:0,radiusY:0,want:!1,over:!1,cuts:[],full:l,from:null,warned:!1,stack:[],hidden:!1,until:0,linked:!1,fades:!1,siblingOrParent:null}}var lr=(e,t,n)=>e.ignored===n&&e.bounds[0]===t[0]&&e.bounds[1]===t[1]&&e.bounds[2]===t[2]&&e.bounds[3]===t[3],sr=class{constructor(t,n,r){this.stage=t;this.placement=n;this.od=r;this.edges=e(4);this.was=e(4);this.box={sx:0,sy:0,w:0,h:0};this.list=[];this.zd=-1;this.hostZ=0;this.sc=!1;this.cb=!1;this.watch=null}Nh(){this.sc=!1;let e=this.stage;return e.batches.Tc!==this.zd?(this.zd=e.batches.Tc,this.find(),this.yc(),this.cb=!1,this.list.length>0):this.cb&&!e.env.frame.scrolled?(this.cb=!1,this.yc(),!0):!1}find(){let e=document.querySelectorAll("[data-umber-occlude]");if(!e.length&&!this.list.length)return;this.hostZ=+getComputedStyle(this.stage.canvasHost.el).zIndex||0;let t=e.length!==this.list.length,n=[];if(e.forEach((e,r)=>{let i=this.list.find(t=>t.el===e)??or(e,G(e,this.stage.env.frame.Va));this.list[r]!==i&&(t=!0),n.push(i)}),this.list=n,!!t){this.ri();for(let e of this.stage.planes.all)e.stale=!0;this.stage.scheduler.markDirty()}}follow(e){let t=this.list;for(let e of t)e.want=!1,e.over=!1,!e.ignored&&!e.el.isConnected&&(e.ignored=!0,this.stage.scheduler.markDirty());for(let e of this.stage.planes.all)(e.zone.soon||e.visible)&&dr(e);for(let n of t){let t=n.linked||e<n.until;!(n.live||t)||!n.want||!n.el.isConnected||(this.place(n,!1,t&&n.fades),e<n.until&&(n.until<1/0||n.over)&&this.stage.scheduler.oa(1))}}hook(e){if(e===document.body||e===document.documentElement)return!1;for(let t of this.list)if(nr(e,t.el))return this.cb=!0;return!1}holds(e){return this.list.some(t=>e.contains(t.el))}ri(){if(typeof MutationObserver>"u")return;let e=this.watch;if(e)e.disconnect();else{let t=new MutationObserver(e=>{for(let t of e)(t.type==="childList"?ir(t.addedNodes)||ir(t.removedNodes):this.hook(t.target))&&(this.cb=!0,this.stage.scheduler.request())});this.stage.env.cleanups.push(()=>{t.disconnect()}),this.watch=t,e=t}if(this.list.length){e.observe(document.documentElement,{subtree:!0,attributes:!0,attributeFilter:["aria-expanded","aria-hidden","open","data-state","hidden"]});for(let t of this.list)e.observe(t.el,{childList:!0,subtree:!0})}}place(e,t,n=t){let r=this.stage;if(t&&this.lh(e),!e.nodes.length||(n&&(e.hidden=ar(e,t)),t&&!e.hidden&&!e.warned&&!e.el.matches("[data-umber~=shader]")&&!In(e.el)&&(e.warned=!0,r.env.lib.say("occludeSeeThrough",[e.el],e.el)),e.ignored=e.hidden||!e.el.isConnected,e.ignored))return;let i=this.placement.tb(e.el);if(e.ignored=i.width<=0||i.height<=0,e.ignored)return;let o=this.box;Un(e.node,i,o);let l=o.sx=e.scrolls?r.env.frame.scrollX:r.env.frame.pageX,s=o.sy=e.scrolls?r.env.frame.scrollY:r.env.frame.pageY;e.ignored=!this.placement.Ed(e.nodes,0,o,e.toDocument),!e.ignored&&(ur(e,o.w,o.h),e.ignored=this.cut(e,l,s),!e.ignored&&(t&&e.reason==="mixed-corners"&&r.env.lib.say("occludeCorners",[e.el],e.el),e.axis=gt(e.toDocument),cr(e)))}lh(e){e.nodes=ne(e.el,this.stage.env.frame.Va);let[t]=e.nodes;t&&(e.node=t),e.scrolls=this.od(e.el),e.live=ue(e.nodes,this.stage.env.host.scroll.root)||e.el.hasAttribute("data-umber-live"),e.stack=Hn(e.el),e.cuts=e.nodes.length?ge(e.nodes).sources.filter(t=>t.by==="overflow"&&!Ke(e.nodes,t.depth)).map(e=>e.node):[]}cut(e,t,n){let r=e.bounds,i=e.shape,o=e.toDocument;if(!i)return!1;if(i.kind||o[1]||o[3]||o[2]||o[5]||!(o[0]>0&&o[4]>0))return r[2]<=r[0]||r[3]<=r[1];let l=this.edges;l.set(r),this.Zg(e,t,n,l);let s=l[0],a=l[1],u=l[2],c=l[3];return u<=s||c<=a?!0:(s===r[0]&&a===r[1]&&u===r[2]&&c===r[3]||(fr(i.radius,r,l),i.box[0]=(s-o[6])/o[0],i.box[1]=(a-o[7])/o[4]*i.ky,i.box[2]=(u-s)/o[0],i.box[3]=(c-a)/o[4]*i.ky,r.set(l)),!1)}Zg(e,t,n,r){for(let i of e.cuts){let e=this.placement.tb(i.el),{border:o,scrollbar:l,direction:s}=Q(i),a=s==="rtl"?l[0]:0;i.overflowX!=="visible"&&(r[0]=Math.max(r[0],e.left+t+o[3]+a),r[2]=Math.min(r[2],e.right+t-o[1]-l[0]+a)),i.overflowY!=="visible"&&(r[1]=Math.max(r[1],e.top+n+o[0]),r[3]=Math.min(r[3],e.bottom+n-o[2]-l[1]))}}yc(){if(!(this.sc||!this.list.length)){this.sc=!0;for(let e of this.list){this.was.set(e.bounds);let t=e.ignored,n=e.stack,r=e.siblingOrParent,i=e.nodes.length>0;if(this.place(e,!0),lr(e,this.was,t)||this.stage.scheduler.markDirty(),e.siblingOrParent=e.el.previousElementSibling??e.el.parentElement,i&&(e.siblingOrParent!==r||hr(n,e.stack))){for(let e of this.stage.planes.all)e.stale=!0;this.stage.scheduler.markDirty()}}}}gg(e){if(!this.list.length||this.hostZ<=0)return er;this.yc();let t=(e.el.getAttribute("data-umber-under")??"").trim();if(t==="none")return er;let n=t?this.picked(e,t):null,r=[],i=null;for(let t of n??this.list)this.Fg(e,t,!!n)&&(!n&&!An(e.el,i??=Hn(e.el),t.el,t.stack)||r.push(t));return r.length?r:er}Fg(e,t,n){return t.el.contains(e.el)?(n&&this.stage.fallbacks.Fa(e,`${i(e.el)}: data-umber-under names ${i(t.el)}, which holds it; a panel never cuts what is inside it.`),!1):!e.el.contains(t.el)||e.kind==="shader"}picked(e,t){let n;try{n=this.list.filter(e=>e.el.matches(t))}catch{n=[]}return n.length?n:(this.stage.fallbacks.Fa(e,`${i(e.el)}: data-umber-under="${t}" matches no [data-umber-occlude] element, so its occluders are the usual ones (those after it in the page).`),null)}};function ar(e,t){let n=getComputedStyle(e.el);t||(e.node.clipPath=n.clipPath||"none");let r=n.visibility==="hidden"||e.el.checkVisibility?.()===!1;for(let n of e.nodes){if(r)break;r=parseFloat(t?n.opacity:getComputedStyle(n.el).opacity)===0}return r}function ur(e,t,n){let i=e.full;if(e.shape&&e.shape===e.from)for(let t=0;t<4;t++)e.shape.box[t]=r(i,t),e.shape.radius[t]=r(i,t+4);if(Ct(e,e.toDocument,{width:t,height:n,value:/^(inset|circle|ellipse|rect|xywh)\(/.test(e.node.clipPath)?e.node.clipPath:"border-box"}),e.shape&&e.shape!==e.from){e.from=e.shape;for(let t=0;t<4;t++)i[t]=r(e.shape.box,t),i[t+4]=r(e.shape.radius,t)}}function cr(e){let t=e.shape,n=t?.kind===0?Math.max(t.radius[0],t.radius[1],t.radius[2],t.radius[3]):0;e.radiusX=n*e.toDocument[0],e.radiusY=t?n/t.ky*e.toDocument[4]:0}var hr=(e,t)=>e.length!==t.length||e.some((e,n)=>{let r=t[n];return r?e[0]!==r[0]||e[1]!==r[1]:!0});function dr(e){let t=e.clips;if(!t)return;let n=t.occluders;for(let e=0;e<n.length;e++){let r=n[e];r&&(r.want=!0,(t.occluderHow[e]!=="pruned"||t.ka===r)&&(r.over=!0))}}function fr(e,t,n){let r=n[1]>t[1],i=n[2]<t[2],o=n[3]<t[3],l=n[0]>t[0];(r||l)&&(e[0]=0),(r||i)&&(e[1]=0),(i||o)&&(e[2]=0),(o||l)&&(e[3]=0)}var pr=class{constructor(e){this.stage=e;this.$c={scrollX:0,scrollY:0,pageX:0,pageY:0,canvasPerCssX:1,canvasPerCssY:1,canvasWidth:1,canvasHeight:1};let t=t=>{let n=e.env.host.scroll.root;return n?n!==t&&n.contains(t):!0};this.placement=new Bn(e),this.occluders=new sr(e,this.placement,t),this.cuts=new Jn(e,this.placement,this.occluders,t),this.animations=new Fn(e,this.occluders);let n=t=>{let n=t.target;n instanceof Element&&(t.type!=="input"||/^(checkbox|radio|select-)/.test(n.type))&&this.occluders.hook(n)&&e.scheduler.request()};for(let t of["pointerover","pointerout","focusin","focusout","input"])e.env.listen(document,t,n)}start(e,t){this.placement.clear(),this.occluders.Nh()&&(t=!0),t&&this.animations.scan(e),this.occluders.list.length&&this.occluders.follow(e),this.animations.Zc()}ud(e,t){this.placement.ud(e,t)}Uh(e){return Zn(this.stage,e)}Df(){jn(this.stage)}Gg(e,t,n=!0){return this.cuts.measure(e,t,n)}Ah(e){this.animations.scan(e)}Zc(){this.animations.Zc()}uc(e){this.animations.uc(e)}frame(e,t){let n=this.stage,r=this.$c;r.scrollX=n.env.frame.scrollX,r.scrollY=n.env.frame.scrollY,r.pageX=n.env.frame.pageX,r.pageY=n.env.frame.pageY,r.canvasWidth=n.gpu.canvas.width,r.canvasHeight=n.gpu.canvas.height,r.canvasPerCssX=n.gpu.canvas.width/Math.max(e,1),r.canvasPerCssY=n.gpu.canvas.height/Math.max(t,1)}clip(e,t,n){return Vt(e,t,n,this.$c)}Fd(e,t,n){let r=e._c,i=e.pad,o=e.edge[0],l=e.size;l[0]=(e._f+2*i)*o,l[1]=(e._d+2*i)*o;let s=e._q,a=e._K,u=1/o;a[0]=s[0]*u,a[1]=s[1]*u,a[2]=s[2]*u,a[3]=s[3]*u,a[4]=s[4]*u,a[5]=s[5]*u,a[6]=s[6]-i*(s[0]+s[3]),a[7]=s[7]-i*(s[1]+s[4]),a[8]=s[8]-i*(s[2]+s[5]),r[0]=a[0]-t*a[2],r[1]=a[1]-n*a[2],r[2]=a[2],r[3]=a[3]-t*a[5],r[4]=a[4]-n*a[5],r[5]=a[5],r[6]=a[6]-t*a[8],r[7]=a[7]-n*a[8],r[8]=a[8];let c=l[0]/2,h=l[1]/2,d=r[2]*c+r[5]*h+r[8],f=e._v;f[0]=(r[0]*c+r[3]*h+r[6])/d-c,f[1]=(r[1]*c+r[4]*h+r[7])/d-h,f[2]=l[0],f[3]=l[1]}pointer(e,t,n){let r=e._O;if(!o(r,e._K))return;let i=r[2]*t+r[5]*n+r[8];e._h[0]=(r[0]*t+r[3]*n+r[6])/i/Math.max(e.size[0],1),e._h[1]=(r[1]*t+r[4]*n+r[7])/i/Math.max(e.size[1],1)}ka(e){return`it is entirely cut off by ${hn(e)} on ${i(e.el)}`}report(e,t){let n=e.clips,r=(n?.list??[]).map(e=>(e.ignored&&t.push(`the ${hn(e)} clip on ${i(e.el)} is skipped right now: part of that parent turns behind the viewer`),{el:e.el,by:e.by,shape:hn(e),how:e.how}));return n?.occluders.forEach((e,o)=>{let l=n.occluderHow[o]??"pruned";l==="uncut"&&t.push(`data-umber-occlude on ${i(e.el)} overlaps it, but ${n.noSlots?"a layer is only cut straight":"its parents' clips take both GL clip slots"}: GL draws over that panel there`),r.push({el:e.el,by:e.by,shape:hn(e),how:l})}),r}};function mr(e){e.chunks.shapesError=null,e.chunks.shapes=new pr(e),e.measurePhase.da();for(let t of e.planes.all)t.stale=!0,t.shapeWait=!1;e.scheduler.markDirty()}export{mr as shapes};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function e(e){return typeof e=="number"?new Float64Array(e):new Float64Array(e)}function t(e){return typeof e=="number"?new Float32Array(e):new Float32Array(e)}function n(e){return new Int32Array(e)}var r=(e,t)=>e[t]??NaN;function i(e){if(!e||typeof e.tagName!="string")return"<?>";let t=e.tagName.toLowerCase();if(e.id)return`<${t}#${e.id}>`;let n=typeof e.className=="string"?e.className.trim().split(/\s+/)[0]:"";return n?`<${t}.${n}>`:`<${t}>`}function o(e,t){let n=t[0],r=t[1],i=t[2],o=t[3],l=t[4],s=t[5],a=t[6],u=t[7],c=t[8],h=l*c-s*u,d=-(o*c-s*a),f=o*u-l*a,p=n*h+r*d+i*f;if(!p||!Number.isFinite(p))return!1;let m=1/p;return e[0]=h*m,e[1]=-(r*c-i*u)*m,e[2]=(r*s-i*l)*m,e[3]=d*m,e[4]=(n*c-i*a)*m,e[5]=-(n*s-i*o)*m,e[6]=f*m,e[7]=-(n*u-r*a)*m,e[8]=(n*l-r*o)*m,!0}function l(e,t,n,{r:r,sx:i,sy:o}){return e.fill(0),e[0]=t?r.width/t:1,e[4]=n?r.height/n:1,e[6]=r.left+i,e[7]=r.top+o,e[8]=1,e}function s(e,t){let n=e.trim();if(n.startsWith("calc(")&&n.endsWith(")"))n=n.slice(5,-1).trim();else if(n.includes("("))return NaN;let r=0,i=1,o=!0;for(let e of n.split(/\s+/))if(e){if(o)r+=i*a(e,t);else if(e==="+"||e==="-")i=e==="-"?-1:1;else return NaN;o=!o}return o?NaN:r}function a(e,t){let[,n,r]=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px|%)?$/i.exec(e)??[];if(n===void 0)return NaN;let i=parseFloat(n);return!r&&i!==0?NaN:r==="%"?i/100*t:i}function u(e){let t=[],n=0,r="";for(let i of e.trim())i==="("?n++:i===")"&&n--,/\s/.test(i)&&n===0?(r&&t.push(r),r=""):r+=i;return r&&t.push(r),t}function c(e){let t=[],n=0,r="";for(let i of e)i==="("?n++:i===")"&&n--,i===","&&n===0?(t.push(r.trim()),r=""):r+=i;return t.push(r.trim()),t}function h(e,t,n){let r={rx:[0,0,0,0],ry:[0,0,0,0]};for(let[i,o]of e.entries()){let[e="0px",l=e]=u(o||"0px"),a=s(e,t),c=s(l,n);if(!Number.isFinite(a)||!Number.isFinite(c))return null;a>0&&c>0&&d(r,i,a,c)}return f(r,t,n)}function d(e,t,n,r){e.rx[t]=n,e.ry[t]=r}function f(e,t,n){let{rx:r,ry:i}=e,o=[[t,r[0]+r[1]],[n,i[1]+i[2]],[t,r[2]+r[3]],[n,i[3]+i[0]]],l=1;for(let[e,t]of o)t>0&&(l=Math.min(l,Math.max(e,0)/t));return l<1&&(e.rx=[r[0]*l,r[1]*l,r[2]*l,r[3]*l],e.ry=[i[0]*l,i[1]*l,i[2]*l,i[3]*l]),e}function p(e,t,n,r){let[i,o,l,s]=t,a=[[s,i],[o,i],[o,l],[s,l]],u={rx:[0,0,0,0],ry:[0,0,0,0]};for(let[t,[n,r]]of a.entries()){let i=e.rx[t]??0,o=e.ry[t]??0;i<=0||o<=0||d(u,t,Math.max(0,i-n),Math.max(0,o-r))}return f(u,n,r)}function m(e){let t=0;for(let[n,r]of e.rx.entries()){let i=e.ry[n]??0;if(!(r<=0||i<=0)){if(!t)t=r/i;else if(Math.abs(r/t-i)>1)return NaN}}return t||1}var b=8;function g(e,t){let[n,r,i,o]=t.border,[l,s,a,u]=t.padding,[c,h,d,f]=t.margin;switch(e){case"padding-box":return{x:o,y:n,w:t.w-o-r,h:t.h-n-i,edges:[n,r,i,o]};case"content-box":case"fill-box":return{x:o+u,y:n+l,w:t.w-o-r-u-s,h:t.h-n-i-l-a,edges:[n+l,r+s,i+a,o+u]};case"margin-box":return{x:-f,y:-c,w:t.w+f+h,h:t.h+c+d,edges:[-c,-h,-d,-f]};default:return{x:0,y:0,w:t.w,h:t.h,edges:[0,0,0,0]}}}var v=/\s*\b(border-box|padding-box|content-box|margin-box|fill-box|stroke-box|view-box)\s*$/;function y({x:e,y:t,w:n,h:r},i){let o=i??{rx:[0,0,0,0],ry:[0,0,0,0]},l=m(o);return Number.isFinite(l)?{shape:{kind:0,box:[e,t*l,Math.max(0,n),Math.max(0,r)*l],radius:[...o.rx],points:null,ky:l}}:{reason:"mixed-corners"}}function w(e){let[t="",n]=e.split("/"),r=x(u(t)),i=n===void 0?r:x(u(n));return!r||!i?null:[`${r[0]} ${i[0]}`,`${r[1]} ${i[1]}`,`${r[2]} ${i[2]}`,`${r[3]} ${i[3]}`]}function x(e){let[t]=e;if(t===void 0)return null;let[,n=t,r=t,i=n]=e;return[t,n,r,i]}function k(e,t){let[n="",r]=e.split(/\bround\b/),i=u(n),[o]=i;if(o===void 0)return{reason:"unparsed"};let[,l=o,a=o,c=l]=i,d=s(o,t.h),p=s(l,t.w),m=s(a,t.h),b=s(c,t.w);if(![d,p,m,b].every(Number.isFinite))return{reason:"unparsed"};let g=Math.max(0,t.w-b-p),v=Math.max(0,t.h-d-m),x=null;if(r){let e=w(r),n=e&&h(e,t.w,t.h);if(!n)return{reason:"unparsed"};x=f(n,g,v)}return y({x:t.x+b,y:t.y+d,w:g,h:v},x)}function M(e,t){let[n,r,i,o]=e,l;if(n===void 0)l=[t.w/2,t.h/2];else if(i===void 0)l=S(n,r??"center",t);else if(e.length===4&&r!==void 0&&o!==void 0)l=N([n,r],[i,o],t);else return null;return Number.isFinite(l[0])&&Number.isFinite(l[1])?l:null}var $={left:[0,"x"],right:[1,"x"],top:[0,"y"],bottom:[1,"y"],center:[.5,""]};function S(e,t,n){($[e]?.[1]==="y"||$[t]?.[1]==="x")&&([e,t]=[t,e]);let r=$[e],i=$[t];return[r?r[0]*n.w:s(e,n.w),i?i[0]*n.h:s(t,n.h)]}function N(e,t,n){let[r,i]=$[e[0]]?.[1]==="y"?[t,e]:[e,t],o=([e,t],n)=>{let r=s(t,n);return e==="right"||e==="bottom"?n-r:r};return[o(r,n.w),o(i,n.h)]}function F(e,t,n,r){return!e||e==="closest-side"?Math.min(Math.abs(t),Math.abs(n-t)):e==="farthest-side"?Math.max(Math.abs(t),Math.abs(n-t)):s(e,r)}function P(e,t,n){let[r="",i]=t.split(/\bat\b/),o=u(r),l=M(u(i??""),n);if(!l)return{reason:"unparsed"};let[a,c]=l,h,d;if(e==="circle"){let e=o[0];h=!e||e.endsWith("-side")?(e==="farthest-side"?Math.max:Math.min)(F(e,a,n.w,0),F(e,c,n.h,0)):s(e,Math.hypot(n.w,n.h)/Math.SQRT2),d=h}else h=F(o[0],a,n.w,n.w),d=F(o[1],c,n.h,n.h);if(!Number.isFinite(h)||!Number.isFinite(d))return{reason:"unparsed"};h>0&&d>0||(h=0,d=0);let f=d>0?h/d:1,p=n.x+a,m=(n.y+c)*f;return{shape:{kind:0,box:[p-h,m-h,2*h,2*h],radius:[h,h,h,h],points:null,ky:f}}}function C(e,t,n){let i=e.length/2,o=(t+1)%i,l=(n+1)%i,s=r(e,t*2),a=r(e,t*2+1),u=r(e,o*2),c=r(e,o*2+1),h=r(e,n*2),d=r(e,n*2+1),f=r(e,l*2),p=r(e,l*2+1),m=(f-h)*(a-d)-(p-d)*(s-h),b=(f-h)*(c-d)-(p-d)*(u-h),g=(u-s)*(d-a)-(c-a)*(h-s),v=(u-s)*(p-a)-(c-a)*(f-s);return m*b<0&&g*v<0}function z(e){let t=e.length/2;for(let n=0;n<t;n++)for(let r=n+1;r<t;r++)if(!(n===(r+1)%t||(n+1)%t===r)&&C(e,n,r))return!0;return!1}function O(e){let[t,n,r,i,o,l,s,a]=e;if(e.length!==8||t===void 0||n===void 0||r===void 0||i===void 0||o===void 0||l===void 0||s===void 0||a===void 0)return null;let u=[t,r,o,s],c=[n,i,l,a];if(t!==r&&n!==i||r!==o&&i!==l||o!==s&&l!==a||s!==t&&a!==n||new Set(u).size>2||new Set(c).size>2)return null;let h=Math.min(...u),d=Math.min(...c);return{x:h,y:d,w:Math.max(...u)-h,h:Math.max(...c)-d}}function L(e,t){let n=c(e),r=!1,[i]=n;(i==="evenodd"||i==="nonzero")&&(r=n.shift()==="evenodd");let o=[];for(let e of n){let[n,r]=u(e),i=s(n??"",t.w),l=s(r??"",t.h);if(!Number.isFinite(i)||!Number.isFinite(l))return{reason:"unparsed"};o.push(t.x+i,t.y+l)}let l=O(o);return l?y(l,null):o.length/2>b?{reason:"polygon-points"}:!r&&z(o)?{reason:"polygon-nonzero"}:{shape:{kind:1,box:[0,0,0,0],radius:[0,0,0,0],points:o,ky:1}}}function _(e,t){let n=(e||"none").trim();if(n==="none"||n==="")return null;let r="border-box",i=v.exec(n),[,o]=i??[];i&&o&&(r=o,n=n.slice(0,i.index).trim());let l=g(r,t);if(!n){let e=h(t.radius,t.w,t.h);return e?y(l,p(e,l.edges,l.w,l.h)):{reason:"unparsed"}}let[,s,a]=/^([a-z-]+)\((.*)\)$/s.exec(n)??[];if(s===void 0||a===void 0)return{reason:"unsupported"};if(/\b(min|max|clamp|var|env)\(/.test(a))return{reason:"unparsed"};switch(s){case"inset":return k(a,l);case"rect":return D(a,l);case"xywh":return T(a,l);case"circle":case"ellipse":return P(s,a,l);case"polygon":return L(a,l);default:return{reason:"unsupported"}}}function D(e,t){let[n="",r]=e.split(/\bround\b/),[i,o,l,a]=u(n);if(i===void 0||o===void 0||l===void 0||a===void 0)return{reason:"unparsed"};let c=(e,t,n)=>e==="auto"?n:s(e,t),h=c(i,t.h,0),d=t.w-c(o,t.w,t.w),f=t.h-c(l,t.h,t.h),p=c(a,t.w,0);return k(`${h}px ${d}px ${f}px ${p}px${r?` round ${r}`:""}`,t)}function T(e,t){let[n="",r]=e.split(/\bround\b/),[i,o,l,a]=u(n).map((e,n)=>s(e,n%2?t.h:t.w));return i===void 0||o===void 0||l===void 0||a===void 0?{reason:"unparsed"}:k(`${o}px ${t.w-i-l}px ${t.h-o-a}px ${i}px${r?` round ${r}`:""}`,t)}function Y(e,t,n){let[,r]=/^rect\((.*)\)$/.exec((e||"auto").trim())??[];if(r===void 0)return null;let i=r.split(/\s*,\s*|\s+/).filter(Boolean),[o,l,a,u]=i;if(i.length!==4||!o||!l||!a||!u)return{reason:"unparsed"};let c=(e,t)=>e==="auto"?t:s(e,0),h=c(o,0),d=c(l,t),f=c(a,n),p=c(u,0);return[h,d,f,p].every(Number.isFinite)?y({x:p,y:h,w:d-p,h:f-h},null):{reason:"unparsed"}}function X(e,t,{box:n,radius:r},i=0){let o=n[2],l=n[3],[s,a,u,c]=[r[0],r[1],r[2],r[3]],h=Math.min(1,o/Math.max(s+a,1e-5),l/Math.max(a+u,1e-5),o/Math.max(u+c,1e-5),l/Math.max(c+s,1e-5)),d=e-n[0],f=t-n[1],p=Math.abs(d-o/2)-o/2,m=Math.abs(f-l/2)-l/2,b=Math.hypot(Math.max(p,0),Math.max(m,0))+Math.min(Math.max(p,m),0);return b=H(b,d,f,s*h),b=H(b,o-d,f,a*h),b=H(b,o-d,l-f,u*h),b=H(b,d,l-f,c*h),b<=i}function H(e,t,n,r){return Math.max(t,n)>=r?e:Math.max(e,Math.hypot(t-r,n-r)-r)}function A(e,t,n){let i=n.length/2,o=!1;for(let l=0,s=i-1;l<i;s=l++){let i=r(n,l*2),a=r(n,l*2+1),u=r(n,s*2),c=r(n,s*2+1);a>t!=c>t&&e<(u-i)*(t-a)/(c-a)+i&&(o=!o)}return o}var j=e=>parseFloat(e??"0")||0,I=(e,t)=>e===void 0||e===""?t:e,G=e=>!!e&&e!=="none";function W(e){try{return e.matches(":modal")||e.matches(":popover-open")}catch{return!1}}function E(e,t){let n=t.get(e);if(n)return n;let r=getComputedStyle(e),i=[r.maskImage,r.getPropertyValue("-webkit-mask-image"),r.maskBorderSource,r.getPropertyValue("-webkit-mask-box-image-source")].some(G),o={el:e,tag:e.localName||e.tagName.toLowerCase(),display:r.display,position:I(r.position,"static"),overflowX:I(r.overflowX,"visible"),overflowY:I(r.overflowY,"visible"),contain:I(r.contain,"none"),contentVisibility:I(r.contentVisibility,"visible"),willChange:I(r.willChange,"auto"),filter:I(r.filter,"none"),backdropFilter:I(r.backdropFilter||r.webkitBackdropFilter,"none"),clipPath:I(r.clipPath,"none"),clip:I(r.getPropertyValue("clip"),"auto"),mask:i,transform:I(r.transform,"none"),translate:I(r.translate,"none"),rotate:I(r.rotate,"none"),scale:I(r.scale,"none"),perspective:I(r.perspective,"none"),transformOrigin:I(r.transformOrigin,""),perspectiveOrigin:I(r.perspectiveOrigin,""),transformStyle:I(r.transformStyle,"flat"),backfaceVisibility:I(r.backfaceVisibility||r.getPropertyValue("-webkit-backface-visibility"),"visible"),offsetPath:I(r.offsetPath,"none"),opacity:I(r.opacity,"1"),isolation:I(r.isolation,"auto"),mixBlendMode:I(r.mixBlendMode,"normal"),zoom:I(r.zoom,"1"),zIndex:r.zIndex,topLayer:W(e)};return t.set(e,o),o}function R(e,t){if(t.has(e.el))return;t.add(e.el);let n=getComputedStyle(e.el);e.transform=n.transform||"none",e.translate=n.translate||"none",e.rotate=n.rotate||"none",e.scale=n.scale||"none",e.transformOrigin=n.transformOrigin||"",e.perspective=n.perspective||"none",e.perspectiveOrigin=n.perspectiveOrigin||"",e.box=void 0}function U(e,t,n,r){let i=Math.min(n+1,e.length-1);V.length<i*2+2&&(V=new Float64Array(i*4+4));let o=V,{rel:l,sizes:s}=r;for(let n=t;n<=i;n++){let t=e[n];if(!t||!(t.el instanceof HTMLElement))return!1;let i=t.el;Z(i,o,n*2,r.bodyOrNull);let l=Q(t);s[n*2]=Number.isFinite(l.width)?l.width:i.offsetWidth,s[n*2+1]=Number.isFinite(l.height)?l.height:i.offsetHeight}for(let n=t;n<i;n++){let t=e[n+1];if(!t)break;B(t,o,n,l)}return!0}var V=new Float64Array(64);function B(e,t,n,i){let o=e.tag!=="html"&&e.tag!=="body";i[n*2]=r(t,n*2)-r(t,(n+1)*2)-(o?e.el.scrollLeft:0),i[n*2+1]=r(t,n*2+1)-r(t,(n+1)*2+1)-(o?e.el.scrollTop:0)}var q=e=>window.scrollX||(e()?.scrollLeft??0),K=e=>window.scrollY||(e()?.scrollTop??0),J=e=>(e.overflowY==="auto"||e.overflowY==="scroll")&&e.el.scrollHeight>e.el.clientHeight;function Z(e,t,n,r){let i=0,o=0,l=e;for(;;){i+=l.offsetLeft,o+=l.offsetTop;let e=l.offsetParent;if(!e){getComputedStyle(l).position==="fixed"&&(i+=q(r),o+=K(r));break}if(e===document.body)break;i+=e.clientLeft,o+=e.clientTop,l=e}t[n]=i,t[n+1]=o}function Q(e){if(e.box)return e.box;let t=e.el,n=getComputedStyle(t),r=(e,t="")=>[j(n[`${e}Top${t}`]),j(n[`${e}Right${t}`]),j(n[`${e}Bottom${t}`]),j(n[`${e}Left${t}`])],i=r("border","Width"),o=r("padding"),l=r("margin"),[s,a]=ee(n),u=[0,0],c=e=>e==="auto"||e==="scroll";if(t instanceof HTMLElement&&(c(e.overflowX)||c(e.overflowY))){let e=t.offsetWidth-t.clientWidth-i[1]-i[3],n=t.offsetHeight-t.clientHeight-i[0]-i[2];u=[e>=2?e:0,n>=2?n:0]}return e.box={border:i,padding:o,margin:l,radius:[n.borderTopLeftRadius||"0px",n.borderTopRightRadius||"0px",n.borderBottomRightRadius||"0px",n.borderBottomLeftRadius||"0px"],width:s,height:a,direction:n.direction||"ltr",overflowClipMargin:n.overflowClipMargin||"0px",scrollbar:u},e.box}function ee(e){let t=e.width.endsWith("px")?j(e.width):NaN,n=e.height.endsWith("px")?j(e.height):NaN;return e.boxSizing!=="border-box"&&(t+=j(e.paddingLeft)+j(e.paddingRight)+j(e.borderLeftWidth)+j(e.borderRightWidth),n+=j(e.paddingTop)+j(e.paddingBottom)+j(e.borderTopWidth)+j(e.borderBottomWidth)),[t,n]}function te(e){return e.assignedSlot??e.parentElement??e.parentNode?.host??null}function ne(e,t){let n=[],r=e;for(;r;){let e=E(r,t);if(n.push(e),e.tag==="html"||e.topLayer)break;r=te(r)}return n}var re=(e,...t)=>t.some(t=>new RegExp(`\\b${t}\\b`).test(e)),ie=e=>e.tag==="html",oe=e=>{let t=ie(e)?e.willChange.replace(/(^|,)\s*(backdrop-)?filter\s*(?=,|$)/g,"$1"):e.willChange;return re(t,"transform","perspective","filter","translate","rotate","scale")},le=["transform","translate","rotate","scale","perspective","filter","backdropFilter"];function se(e,{countZoom:t=!0}={}){for(let t of le)if(e[t]!=="none"&&!(ie(e)&&t.endsWith("ilter")))return`${t==="backdropFilter"?"backdrop-filter":t}: ${e[t]}`;if(re(e.contain,"layout","paint","strict","content"))return`contain: ${e.contain}`;if(e.contentVisibility==="auto"||e.contentVisibility==="hidden")return`content-visibility: ${e.contentVisibility}`;if(oe(e))return`will-change: ${e.willChange}`;let n=parseFloat(e.zoom??"1");return t&&Number.isFinite(n)&&Math.abs(n-1)>1e-6?`zoom: ${e.zoom}`:null}var ae=e=>se(e,{countZoom:!1})!==null;function ue(e,t=null){for(let[n,r]of e.entries()){if(r.tag==="html")break;if(r.position==="fixed"&&!ce(e,n)||r.position==="sticky"&&he(e,n,t))return!0}return!1}function ce(e,t){return e.some((e,n)=>n>t&&ae(e))}function he(e,t,n){for(let r=t+1;r<e.length;r++){let t=e[r];if(!t)break;if(t.el===n||t.tag==="html"||t.tag==="body")return!0;if(pe(t))return!1}return!0}function de(e){let t=e.at(-1);return t?.tag!=="html"||t.overflowX==="visible"&&t.overflowY==="visible"}function fe(e,t){return e.tag==="html"||e.tag==="body"&&(t||J(e))}function pe(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 me(e){return e.position!=="static"||ae(e)}function be(e){return e.display==="inline"?!1:e.overflowX!=="visible"||e.overflowY!=="visible"||re(e.contain,"paint","strict","content")||e.contentVisibility==="auto"||e.contentVisibility==="hidden"}function ge(e,t=0,n=!1){let r=[],i=null,[o]=e;if(!o)return{sources:r,mask:i};let l=de(e),s=n?e.slice(0,t+1):e,a=o.position;for(let[e,t]of s.entries())t.display!=="contents"&&(e>0&&ye(a,t)&&(be(t)&&!fe(t,l)&&r.push({node:t,depth:e,by:"overflow"}),a=t.position),ve(t,e,r),t.mask&&!i&&(i=t));return{sources:r,mask:i}}function ve(e,t,n){e.clipPath!=="none"&&n.push({node:e,depth:t,by:"clip-path"}),e.clip!=="auto"&&e.clip!==""&&(e.position==="absolute"||e.position==="fixed")&&n.push({node:e,depth:t,by:"clip"})}function ye(e,t){return e==="static"||e==="relative"||e==="sticky"?!0:e==="absolute"?me(t):e==="fixed"&&ae(t)}function we(e,t){let[n,r,i,o]=t.padding,[l,s,a,u]=t.border;return e==="content-box"?[n,r,i,o]:e==="border-box"?[-l,-s,-a,-u]:[0,0,0,0]}function xe(e,t,n,r){let i=(t.overflowClipMargin||"0px").trim().split(/\s+/),o=i.find(e=>e.endsWith("-box"))??"padding-box",l=Math.max(0,s(i.find(e=>!e.endsWith("-box"))??"0px",0)||0),a=we(o,t),u=[a[0]-l,a[1]-l,a[2]-l,a[3]-l];return e.overflowX==="clip"&&(n[0]+=u[3],n[2]-=u[1]),e.overflowY==="clip"&&(n[1]+=u[0],n[3]-=u[2]),[r[0]+u[0],r[1]+u[1],r[2]+u[2],r[3]+u[3]]}var ke=1e6;function Me(e,t,n,r){let[i,o,l,s]=t.border,[a,u]=t.scrollbar,c=t.direction==="rtl",d=[s+(c?a:0),i,n-o-(c?0:a),r-l-u],f=[i,o,l,s];(e.overflowX==="clip"||e.overflowY==="clip")&&(f=xe(e,t,d,f));let m=re(e.contain,"paint","strict","content"),b=e.overflowX==="visible"&&!m,g=e.overflowY==="visible"&&!m;b&&(d[0]=-ke,d[2]=ke),g&&(d[1]=-ke,d[3]=ke);let v=null;if(!b&&!g){let e=h(t.radius,n,r);if(!e)return{reason:"unparsed"};v=p(e,f,d[2]-d[0],d[3]-d[1])}return $e(d,v)}function $e([e,t,n,r],i){let o=i?m(i):1;return Number.isFinite(o)?{shape:{kind:0,box:[e,t*o,Math.max(0,n-e),Math.max(0,r-t)*o],radius:i?[...i.rx]:[0,0,0,0],points:null,ky:o}}:{reason:"mixed-corners"}}var Se=1e-9,Ne=1e-6;function Fe(e){return e.fill(0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Pe(e,t,n){let i=Ce;for(let e=0;e<4;e++){let o=r(n,e*4),l=r(n,e*4+1),s=r(n,e*4+2),a=r(n,e*4+3);for(let n=0;n<4;n++)i[e*4+n]=r(t,n)*o+r(t,4+n)*l+r(t,8+n)*s+r(t,12+n)*a}return e.set(i),e}var Ce=e(16);function ze(e,t,n,i=0){for(let o=0;o<16;o+=4){let l=r(e,o+3);e[o]=r(e,o)+t*l,e[o+1]=r(e,o+1)+n*l,e[o+2]=r(e,o+2)+i*l}return e}var Oe=(e,t)=>t<e?t:t+1;function Le(e,t,n){let i=Oe(t,0),o=Oe(t,1),l=Oe(t,2),s=Oe(n,0)*4,a=Oe(n,1)*4,u=Oe(n,2)*4;return r(e,s+i)*(r(e,a+o)*r(e,u+l)-r(e,u+o)*r(e,a+l))-r(e,a+i)*(r(e,s+o)*r(e,u+l)-r(e,u+o)*r(e,s+l))+r(e,u+i)*(r(e,s+o)*r(e,a+l)-r(e,a+o)*r(e,s+l))}function _e(e){let t=-e[3]*Le(e,3,0)+e[7]*Le(e,3,1)-e[11]*Le(e,3,2)+e[15]*Le(e,3,3);return!t||!Number.isFinite(t)?NaN:Le(e,2,2)/t}var De=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?$/i;function Te(e){let t=De.exec(e.trim());if(!t)return NaN;let[,n="",r="deg"]=t,i=parseFloat(n);switch(r.toLowerCase()){case"rad":return i;case"grad":return i*Math.PI/200;case"turn":return i*2*Math.PI;default:return i*Math.PI/180}}function Ye(e,t){let n=e.trim();if(!n||n==="none")return null;let i=/^matrix(3d)?\((.*)\)$/.exec(n);if(!i)return null;let[,o,l=""]=i,s=l.split(",").map(Number);return s.some(e=>!Number.isFinite(e))?null:o?s.length!==16?null:(t.set(s),t):s.length!==6?null:(Fe(t),t[0]=r(s,0),t[1]=r(s,1),t[4]=r(s,2),t[5]=r(s,3),t[12]=r(s,4),t[13]=r(s,5),t)}function Xe(e,t){let n=e.trim().split(/\s+/),[r,i,o]=n,l=n.at(-1);if(!r||r==="none"||l===void 0)return null;let s=Te(l);if(!Number.isFinite(s))return null;let a=[0,0,1];return n.length===2?a=[r==="x"?1:0,r==="y"?1:0,r==="z"?1:0]:n.length===4&&(a=[Number(r),Number(i),Number(o)]),He(t,a,s)}function He(e,t,n){let r=Math.hypot(t[0],t[1],t[2]);if(Fe(e),!r||!Number.isFinite(r))return e;let i=t[0]/r,o=t[1]/r,l=t[2]/r,s=Math.sin(n),a=Math.cos(n),u=1-a;return e[0]=a+i*i*u,e[1]=o*i*u+l*s,e[2]=l*i*u-o*s,e[4]=i*o*u-l*s,e[5]=a+o*o*u,e[6]=l*o*u+i*s,e[8]=i*l*u+o*s,e[9]=o*l*u-i*s,e[10]=a+l*l*u,e}function Ae(e,t){let n=e.trim().split(/\s+/);if(!n[0]||n[0]==="none")return null;let r=(e,t)=>e===void 0?t:e.endsWith("%")?parseFloat(e)/100:parseFloat(e),i=r(n[0],1),o=r(n[1],i),l=r(n[2],1);return[i,o,l].every(Number.isFinite)?(Fe(t),t[0]=i,t[5]=o,t[10]=l,t):null}function je(e,t,n,r){let i=u(e);if(!i[0]||i[0]==="none")return null;let o=s(i[0],t),l=i[1]===void 0?0:s(i[1],n),a=i[2]===void 0?0:s(i[2],0);return[o,l,a].every(Number.isFinite)?(Fe(r),r[12]=o,r[13]=l,r[14]=a,r):null}function Ie(e,t,n){let r=u(e||""),i=r[0]===void 0?t/2:s(r[0],t),o=r[1]===void 0?n/2:s(r[1],n),l=r[2]===void 0?0:s(r[2],0);return[Number.isFinite(i)?i:t/2,Number.isFinite(o)?o:n/2,Number.isFinite(l)?l:0]}var Ge=new Set(["img","video","canvas","iframe","embed","object","svg","input","select","textarea","button"]);function We(e){return!(e.display==="contents"||e.display==="none"||e.display==="inline"&&!Ge.has(e.tag))}function Ee(e){return We(e)&&(e.transform!=="none"||e.translate!=="none"||e.rotate!=="none"||e.scale!=="none")}var Re=e(16);function Ue(e,t,n,r){if(!Ee(e))return null;let[i,o,l]=Ie(e.transformOrigin,t,n);Fe(r),ze(r,i,o,l);let s=Re;je(e.translate,t,n,s)&&Pe(r,r,s),Xe(e.rotate,s)&&Pe(r,r,s),Ae(e.scale,s)&&Pe(r,r,s),Ye(e.transform,s)&&Pe(r,r,s);let a=s;return Fe(a),a[12]=-i,a[13]=-o,a[14]=-l,Pe(r,r,a),r}function Ve(e){return Math.abs(e[2])>Se||Math.abs(e[3])>Se||Math.abs(e[6])>Se||Math.abs(e[7])>Se||Math.abs(e[8])>Se||Math.abs(e[9])>Se||Math.abs(e[11])>Se||Math.abs(e[10]-1)>Se}function Be(e){return Math.abs(e[1])>Se||Math.abs(e[4])>Se||e[0]<=Se||e[5]<=Se}function qe(e){return!(e.transformStyle!=="preserve-3d"||e.overflowX!=="visible"||e.overflowY!=="visible"||(parseFloat(e.opacity)||0)<1&&e.opacity!==""||e.filter!=="none"||e.clipPath!=="none"||e.mask||e.isolation==="isolate"||e.mixBlendMode&&e.mixBlendMode!=="normal"||/\b(paint|strict|content)\b/.test(e.contain))}var Ke=e(16);function Je(e,t=0){let n=0,r=Ke;for(let i=t;i<e.length;i++){let t=e[i];if(!t)break;if(Ue(t,0,0,r)){if(Ve(r)||Math.abs(r[14])>Se&&Qe(e,i))return 2;Be(r)&&(n=1)}}return n}function Ze(e,t,n,r){for(let i=t;i<=n;i++){let t=e[i],n=e[i+1];if(!t||!n)break;if(!(!Ee(t)||n.perspective==="none"||!We(n))&&!(n.overflowX==="visible"&&n.overflowY==="visible")&&r(i+1))return i+1}return-1}function Qe(e,t){for(let n=t+1;n<e.length;n++){let t=e[n];if(!t)break;if(t.perspective!=="none")return!0;if(!qe(t))return!1}return!1}function et(e,t,n){n[0]=1,n[1]=0,n[2]=0,n[3]=1;let r=Ke;for(let i=t;i<e.length;i++){let t=e[i];if(!t)break;if(!Ue(t,0,0,r))continue;let o=r[0],l=r[1],s=r[4],a=r[5],u=n[0],c=n[1],h=n[2],d=n[3];n[0]=o*u+s*c,n[1]=l*u+a*c,n[2]=o*h+s*d,n[3]=l*h+a*d}return n}function tt(e,t){let n=t,r;for(let i=t;i<e.length;i++){let t=e[i];if(!t)break;(Ee(t)||t.perspective!=="none"&&r&&Ee(r))&&(n=i),r=t}return n}var nt=e(16),rt=e(16),it={m:e(16),backHidden:!1,scene:-1};function ot(e,t,n,r){let i=Fe(it.m);it.backHidden=!1,it.scene=-1;for(let o=t;o<=n&&o<e.length;o++){let t=e[o];if(!t)break;ut(i,e,o,r);let l=at(e,o);if(t.backfaceVisibility==="hidden"&&!it.backHidden&&dt(e,o,n,r)&&(it.backHidden=!0),l&&qe(l)){it.scene=o+1;continue}ct(i)}return it}function lt(e,t,n){return st(e,0,0)||st(e,t,0)||st(e,t,n)||st(e,0,n)}function st(e,t,n){return e[3]*t+e[7]*n+e[15]<=Ne}function at(e,t){return e[t+1]}function ut(e,t,n,{rel:i,sizes:o}){let l=t[n];if(!l)return;let s=Ue(l,r(o,n*2)||0,r(o,n*2+1)||0,nt);s&&Pe(e,s,e),ze(e,r(i,n*2)||0,r(i,n*2+1)||0,0);let a=at(t,n);if(a&&a.perspective!=="none"&&We(a)){let t=parseFloat(a.perspective);if(t>0){let[i,l]=Ie(a.perspectiveOrigin,r(o,(n+1)*2)||0,r(o,(n+1)*2+1)||0),s=Fe(rt);s[11]=-1/Math.max(t,1),ze(e,-i,-l,0),Pe(e,s,e),ze(e,i,l,0)}}}function ct(e){e[2]=0,e[6]=0,e[14]=0,e[8]=0,e[9]=0,e[11]=0,e[10]=1}var ht=e(16);function dt(e,t,n,r){let i=Fe(ht);for(let o=t;o<=Math.max(n,t)&&o<e.length;o++){ut(i,e,o,r);let t=at(e,o);if(!t||!qe(t))break}return _e(i)<0}function ft(e,t){return t[0]=e[0],t[1]=e[1],t[2]=e[3],t[3]=e[4],t[4]=e[5],t[5]=e[7],t[6]=e[12],t[7]=e[13],t[8]=e[15],t}function pt(e,t){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function mt(e,t,n,{r:r,sx:i,sy:o}){let l=r.left+i,s=r.top+o,a=1/0,u=1/0,c=-1/0,h=-1/0;for(let r=0;r<4;r++){let i=r===1||r===2?t:0,o=r>=2?n:0,l=e[2]*i+e[5]*o+e[8],s=(e[0]*i+e[3]*o+e[6])/l,d=(e[1]*i+e[4]*o+e[7])/l;s<a&&(a=s),s>c&&(c=s),d<u&&(u=d),d>h&&(h=d)}let d=l-a,f=s-u;return e[0]+=d*e[2],e[1]+=f*e[2],e[3]+=d*e[5],e[4]+=f*e[5],e[6]+=d*e[8],e[7]+=f*e[8],Math.max(Math.abs(c-a-r.width),Math.abs(h-u-r.height))}function bt(e,t,n,r){let i=t/2,o=n/2,l=e[2]*i+e[5]*o+e[8],s=(e[0]*i+e[3]*o+e[6])/l,a=(e[1]*i+e[4]*o+e[7])/l,u=(e[0]-s*e[2])/l,c=(e[1]-a*e[2])/l,h=(e[3]-s*e[5])/l,d=(e[4]-a*e[5])/l,f=Math.sqrt(Math.abs(u*d-c*h))||1;return r[0]=f,r[1]=f,r}function gt(e){return Math.abs(e[1])<Se&&Math.abs(e[3])<Se&&Math.abs(e[2])<Se&&Math.abs(e[5])<Se&&Math.abs(e[8]-1)<Se}var vt=2,yt=8,wt=e=>e.shape!==null;function xt(){let r=e(8),i=t(4),o=t(4);return{list:[],occluders:[],occluderHow:[],noSlots:!1,occluderSlots:[],mask:null,scissorDoc:r,shaders:[],reason:null,fold:i,ownRadius:o,ownKy:1,count:0,xf:new Float32Array(9*vt),box:new Float32Array(4*vt),radius:new Float32Array(4*vt),poly:new Float32Array(2*yt),polyInfo:new Float32Array([-1,0]),lb:!1,scissorPx:n(4),Sh:null,reshaped:!1}}function kt(e,{nodes:t,off:n,isInsideScroll:r,previous:i,occluders:o=[]}){let l=Math.max(0,t.findIndex(t=>t.el===e.el)),{sources:s,mask:a}=ge(t,l,n);if(!s.length&&!a&&!o.length)return null;let u=i??xt();u.occluders=o,u.occluderSlots.length=0,u.occluderHow.length=o.length,u.occluderHow.fill("pruned");let c=[];for(let e of s){let t=u.list.find(t=>t.el===e.node.el&&t.by===e.by),n=t??Mt();c.push({el:e.node.el,by:e.by,node:e.node,own:e.depth<=l,ignored:!1,depth:e.depth,key:t?.key??"",shape:t?.shape??null,reason:t?.reason??null,toDocument:n.toDocument,toShape:n.toShape,bounds:n.bounds,scrolls:r(e.node.el),square:!1,how:"shader"})}return u.list=c,u.mask=a,u}function Mt(){let t=e(9),n=e(9),r=e(4);return{toDocument:t,toShape:n,bounds:r}}function $t(e,t,{width:n,height:r,value:i}){let o=`${t.radius.join(" ")}|${t.border.join(" ")}|${t.padding.join(" ")}`;return e.by==="overflow"?`|${n}|${r}|${o}|${t.overflowClipMargin}|${t.scrollbar.join(" ")}|${t.direction}`:e.by==="clip-path"||e.by==="occlude"?`${i}|${n}|${r}|${o}|${t.margin.join(" ")}`:`${i}|${n}|${r}`}function St(e,t,{width:n,height:r,value:i}){return e.by==="overflow"?Me(e.node,t,n,r):e.by==="clip"?Y(i,n,r):_(i,{w:n,h:r,border:t.border,padding:t.padding,margin:t.margin,radius:t.radius})}var Nt=e(4);function Ft(e,t){if(e.kind===0){let[n,r,i,o]=e.box;return t[0]=n,t[1]=r/e.ky,t[2]=n+i,t[3]=(r+o)/e.ky,t}let n=e.points;t[0]=1/0,t[1]=1/0,t[2]=-1/0,t[3]=-1/0;for(let e=0;e<n.length;e+=2){let i=r(n,e),o=r(n,e+1);t[0]=Math.min(t[0],i),t[2]=Math.max(t[2],i),t[1]=Math.min(t[1],o),t[3]=Math.max(t[3],o)}return t}function Pt(e,t,n){let r=Q(e.node),i=$t(e,r,n);if(i!==e.key||!e.shape&&!e.reason){e.key=i;let t=St(e,r,n);e.shape=t&&"shape"in t?t.shape:null,e.reason=t&&"reason"in t?t.reason:null,t||(e.reason="none")}t!==e.toDocument&&e.toDocument.set(t);let l=e.shape;if(l){if(!o(e.toShape,e.toDocument)){e.toShape.fill(0),e.bounds.fill(0),e.square=!0;return}e.toShape[1]*=l.ky,e.toShape[4]*=l.ky,e.toShape[7]*=l.ky,Ct(e.bounds,t,Ft(l,Nt)),e.square=l.kind===0&&l.radius.every(e=>e<=0)&&gt(t)}}function Ct(e,t,n){let r=n[0],i=n[1],o=n[2],l=n[3];e[0]=1/0,e[1]=1/0,e[2]=-1/0,e[3]=-1/0;let s=Math.max(Math.abs(r),Math.abs(o),Math.abs(i),Math.abs(l))>1e5;for(let n=0;n<4;n++){let a=n===1||n===2?o:r,u=n>=2?l:i,c=s?1:t[2]*a+t[5]*u+t[8],h=(t[0]*a+t[3]*u+t[6])/c,d=(t[1]*a+t[4]*u+t[7])/c;h<e[0]&&(e[0]=h),d<e[1]&&(e[1]=d),h>e[2]&&(e[2]=h),d>e[3]&&(e[3]=d)}}function zt(e,t,n){let r=e.shape,i=e.toShape,o=i[2]*t+i[5]*n+i[8],l=(i[0]*t+i[3]*n+i[6])/o,s=(i[1]*t+i[4]*n+i[7])/o;return r.kind===0?X(l,s,r,.01):A(l,s,r.points)}function Ot(e,t){let n=e.shape;return n.kind===1&&!Lt(n.points)?!1:zt(e,t[0],t[1])&&zt(e,t[2],t[1])&&zt(e,t[2],t[3])&&zt(e,t[0],t[3])}function Lt(e){let t=e.length/2,n=0;for(let i=0;i<t;i++){let o=i*2,l=(i+1)%t*2,s=(i+2)%t*2,a=(r(e,l)-r(e,o))*(r(e,s+1)-r(e,l+1))-(r(e,l+1)-r(e,o+1))*(r(e,s)-r(e,l));if(a!==0){if(n===0)n=Math.sign(a);else if(Math.sign(a)!==n)return!1}}return!0}var _t=e(4);function Dt(e,t,n,r){t.reason=null,t.scissorDoc.fill(NaN),t.shaders.length=0,t.fold.fill(0),t.mask&&(t.reason={code:"mask",clips:[]});let i=_t,o=r?(n[2]-n[0])*.25:0,l=r?(n[3]-n[1])*.25:0;i[0]=n[0]-o,i[1]=n[1]-l,i[2]=n[2]+o,i[3]=n[3]+l;let s=Tt(e,t,i);for(let t=s.length-1;t>=0;t--){let n=s[t];n&&n.scrolls===e.scrolls&&Ot(n,i)&&(n.how="pruned",s.splice(t,1))}r||Xt(e,t,s,n);let a=s.filter(e=>e.shape.kind===1);(s.length>vt||a.length>1)&&(t.reason??={code:"too-many",clips:s});for(let e of s)e.how="shader",t.shaders.length<vt&&t.shaders.push(e);return Ht(t)&&(t.reshaped=!0),t.reason}function Tt(e,t,n){let r=[];for(let i of t.list){if(i.ignored){i.how="ignored";continue}if(i.reason==="none"){i.how="pruned";continue}if(i.reason||!wt(i)){t.reason??={code:i.reason??"unparsed",clips:[i]};continue}i.square?i.how=Yt(e,t,i,n):r.push(i)}return r}function Yt(e,t,n,i){let o=n.bounds;if(n.scrolls===e.scrolls&&o[0]<=i[0]&&o[1]<=i[1]&&o[2]>=i[2]&&o[3]>=i[3])return"pruned";let l=n.scrolls?0:4,s=t.scissorDoc;return Number.isNaN(s[l])?s.set(o,l):(s[l]=Math.max(s[l],o[0]),s[l+1]=Math.max(r(s,l+1),o[1]),s[l+2]=Math.min(r(s,l+2),o[2]),s[l+3]=Math.min(r(s,l+3),o[3])),"scissor"}function Xt(e,t,n,r){for(let i=n.length-1;i>=0;i--){let o=n[i];if(!o)continue;let l=o.shape,s=o.bounds,a=o.toDocument[0];if(!(e.level===0&&gt(o.toDocument)&&o.scrolls===e.scrolls&&l.kind===0&&l.ky===1&&Math.abs(a-o.toDocument[4])<.01*a&&Math.abs(s[0]-r[0])<.5&&Math.abs(s[1]-r[1])<.5&&Math.abs(s[2]-r[2])<.5&&Math.abs(s[3]-r[3])<.5))continue;let u=t.fold;u[0]=Math.max(u[0],l.radius[0]*a),u[1]=Math.max(u[1],l.radius[1]*a),u[2]=Math.max(u[2],l.radius[2]*a),u[3]=Math.max(u[3],l.radius[3]*a),o.how="corners",n.splice(i,1)}}function Ht(e){let t=!1,n=(e,n,r)=>{let i=Math.fround(r);e[n]!==i&&(e[n]=i,t=!0)};for(let t=0;t<e.shaders.length;t++){let i=e.shaders[t]?.shape;if(!i)break;let o=i.kind===0?i:At;for(let i=0;i<4;i++)n(e.box,t*4+i,r(o.box,i)),n(e.radius,t*4+i,r(o.radius,i))}let[i,o]=jt(e);for(let t=0;t<2*yt;t++)n(e.poly,t,o[t]??0);return n(e.polyInfo,0,i),n(e.polyInfo,1,o.length/2),t}var At={box:[0,0,0,0],radius:[0,0,0,0]};function jt(e){for(let t=e.shaders.length-1;t>=0;t--){let n=e.shaders[t]?.shape;if(n?.kind===1)return[t,n.points]}return[-1,[]]}var It={visible:!0,moved:!1},Gt=e(9),Wt={moved:!1,x0:0,y0:0,x1:0,y1:0,any:!1,own0:0,own1:0,own2:0,own3:0,slots:0,cutter:null},Et=e(4),Rt=e(4);function Ut(e,t,n,r){return Wt.moved=e.reshaped,e.reshaped=!1,e.Sh=null,Vt(e.scissorDoc,r),It.visible=Bt(e,t,n,r)&&tn(e,t,n,r)&&sn(e,t,n,r),It.moved=Wt.moved,It}function Vt(e,t){Wt.x0=-1/0,Wt.y0=-1/0,Wt.x1=1/0,Wt.y1=1/0,Wt.any=!1;for(let n=0;n<8;n+=4){if(Number.isNaN(e[n]))continue;Wt.any=!0;let i=n===0?t.scrollX:t.pageX,o=n===0?t.scrollY:t.pageY;Wt.x0=Math.max(Wt.x0,r(e,n)-i),Wt.y0=Math.max(Wt.y0,r(e,n+1)-o),Wt.x1=Math.min(Wt.x1,r(e,n+2)-i),Wt.y1=Math.min(Wt.y1,r(e,n+3)-o)}Wt.own0=Wt.x0,Wt.own1=Wt.y0,Wt.own2=Wt.x1,Wt.own3=Wt.y1}function Bt(e,t,n,r){Wt.slots=0,Wt.cutter=null;let i=e.occluders;if(i.length){let o=n?t[2]*.25:0,l=n?t[3]*.25:0,s=Et;s[0]=t[0]-o,s[1]=t[1]-l,s[2]=t[0]+t[2]+o,s[3]=t[1]+t[3]+l;for(let t=0;t<i.length;t++){let n=i[t];if(!n)break;let o=qt(e,n,s,r);if(e.occluderHow[t]=o??"pruned",!o)return e.Sh=n,!1}}return e.occluderSlots.length>Wt.slots&&(e.occluderSlots.length=Wt.slots),!0}function qt(e,t,n,r){let i=Kt(t,r);if(t.ignored||!t.shape||Jt(i,n))return"pruned";let o=i[0]<=n[0]&&i[2]>=n[2],l=i[1]<=n[1]&&i[3]>=n[3],s=Qt(t,i,n);if(s&&o&&l)return null;let a=en(o,l,i,n),u=!e.noSlots&&e.shaders.length+Wt.slots<vt;return a&&(s||!u&&t.axis)?(Zt(a,i),Wt.cutter=t,"scissor"):u?(e.occluderSlots[Wt.slots++]=t,"shader"):"uncut"}function Kt(e,t){let n=e.scrolls?t.scrollX:t.pageX,r=e.scrolls?t.scrollY:t.pageY,i=Rt;return i[0]=e.bounds[0]-n,i[1]=e.bounds[1]-r,i[2]=e.bounds[2]-n,i[3]=e.bounds[3]-r,i}var Jt=(e,t)=>e[0]>=t[2]||e[2]<=t[0]||e[1]>=t[3]||e[3]<=t[1];function Zt(e,t){e===1?Wt.y0=Math.max(Wt.y0,t[3]):e===2?Wt.y1=Math.min(Wt.y1,t[1]):e===3?Wt.x0=Math.max(Wt.x0,t[2]):Wt.x1=Math.min(Wt.x1,t[0]),Wt.any=!0}function Qt(e,t,n){return e.axis?e.square||n[0]>=t[0]+e.radiusX&&n[2]<=t[2]-e.radiusX||n[1]>=t[1]+e.radiusY&&n[3]<=t[3]-e.radiusY:!1}function en(e,t,n,r){return e&&n[1]<=r[1]?1:e&&n[3]>=r[3]?2:t&&n[0]<=r[0]?3:t&&n[2]>=r[2]?4:0}function tn(e,t,n,r){let{x0:i,y0:o,x1:l,y1:s}=Wt,a=!1;if(Wt.any){if(l<=i||s<=o||!n&&(rn(t,i,l)||on(t,o,s)))return e.Sh=nn(e,t,n),!1;if(a=n||t[0]<i||t[1]<o||t[0]+t[2]>l||t[1]+t[3]>s,a&&!ln(e,r))return e.Sh=Wt.cutter??e.list.find(e=>e.how==="scissor")??null,!1}return a!==e.lb&&(e.lb=a,Wt.moved=!0),!0}function nn(e,t,n){return(Wt.own2<=Wt.own0||Wt.own3<=Wt.own1||!n&&(rn(t,Wt.own0,Wt.own2)||on(t,Wt.own1,Wt.own3))?null:Wt.cutter)??e.list.find(e=>e.how==="scissor")??Wt.cutter}var rn=(e,t,n)=>e[0]>=n||e[0]+e[2]<=t,on=(e,t,n)=>e[1]>=n||e[1]+e[3]<=t;function ln(e,t){let n=Math.min(t.canvasWidth,Math.max(0,Math.round(Wt.x0*t.canvasPerCssX))),r=Math.min(t.canvasWidth,Math.max(0,Math.round(Wt.x1*t.canvasPerCssX))),i=Math.min(t.canvasHeight,Math.max(0,Math.round(Wt.y0*t.canvasPerCssY))),o=Math.min(t.canvasHeight,Math.max(0,Math.round(Wt.y1*t.canvasPerCssY)));if(r<=n||o<=i)return!1;let l=e.scissorPx,s=t.canvasHeight-o;return(l[0]!==n||l[1]!==s||l[2]!==r-n||l[3]!==o-i)&&(l[0]=n,l[1]=s,l[2]=r-n,l[3]=o-i,Wt.moved=!0),!0}function sn(e,t,n,r){let i=e.shaders.length,o=i+Wt.slots;o!==e.count&&(e.count=o,Wt.moved=!0);for(let o=0;o<i;o++){let i=e.shaders[o];if(!i)break;if(!n&&an(i,t,r))return e.Sh=i,!1;cn(e,o,i,r)&&(Wt.moved=!0)}for(let t=0;t<Wt.slots;t++){let n=e.occluderSlots[t];if(!n)break;un(e,i+t,n,r)}return!0}function an(e,t,n){let r=e.scrolls?n.scrollX:n.pageX,i=e.scrolls?n.scrollY:n.pageY,o=e.bounds;return t[0]>=o[2]-r||t[0]+t[2]<=o[0]-r||t[1]>=o[3]-i||t[1]+t[3]<=o[1]-i}function un(e,t,n,i){cn(e,t,n,i)&&(Wt.moved=!0);let o=n.shape;if(o)for(let n=0;n<4;n++){let i=Math.fround(r(o.box,n)),l=Math.fround(r(o.radius,n));(e.box[t*4+n]!==i||e.radius[t*4+n]!==l)&&(e.box[t*4+n]=i,e.radius[t*4+n]=l,Wt.moved=!0)}}function cn(e,t,n,i){let o=t<e.shaders.length?1:-1,l=n.scrolls?i.scrollX:i.pageX,s=n.scrolls?i.scrollY:i.pageY,a=1/i.canvasPerCssX,u=1/i.canvasPerCssY,c=n.toShape,h=i.canvasHeight*u+s,d=Gt;d[0]=c[0]*a,d[1]=c[1]*a,d[2]=c[2]*a,d[3]=-c[3]*u,d[4]=-c[4]*u,d[5]=-c[5]*u,d[6]=c[0]*l+c[3]*h+c[6],d[7]=c[1]*l+c[4]*h+c[7],d[8]=c[2]*l+c[5]*h+c[8];let f=e.xf,p=!1;for(let e=0,n=t*9;e<9;e++,n++){let t=Math.fround(r(d,e)*o);f[n]!==t&&(f[n]=t,p=!0)}return p}function hn(e){let t=!!e.shape?.radius.some(e=>e>0);if(e.by==="occlude")return t?"data-umber-occlude, rounded":"data-umber-occlude";if(e.by==="overflow"){let n=dn(e.node);return t?`${n}, rounded`:n}let n=e.by==="clip"?e.node.clip:e.node.clipPath;return`${e.by==="clip"?"clip: ":""}${n.length>60?`${n.slice(0,57)}...`:n}`}function dn(e){let t=e.overflowX===e.overflowY?e.overflowX:`${e.overflowX} ${e.overflowY}`;return t!=="visible"?`overflow: ${t}`:e.contentVisibility!=="visible"?`content-visibility: ${e.contentVisibility}`:`contain: ${e.contain}`}function fn(e,t){let n=i(e.el),r=t.reason;if(!r)return`${n}: its clips can be drawn in GL.`;let o=e=>e.length>40?`${e.slice(0,37)}...`:e;if(r.code==="mask")return`${n}: GL can't draw the CSS mask on ${i(t.mask?.el)}, so its DOM shows. Move the mask off the parents of GL elements, or add data-umber-clip="false" to draw it unmasked.`;if(r.code==="too-many")return`${n}: cut by too many rounded or shaped parents (${r.clips.map(e=>i(e.el)).join(", ")}), so its DOM shows. Make one of them a straight overflow: hidden, keep one polygon (up to ${yt} points), or add data-umber-clip="false".`;let[l]=r.clips;if(!l)return`${n}: its clips can't be drawn in GL (${r.code}), so its DOM shows.`;switch(r.code){case"mixed-corners":return`${n}: ${i(l.el)}'s corners mix different horizontal / vertical radii; GL needs one ratio for all of them, so its DOM shows. Use the same radius both ways (or one shape for all corners).`;case"polygon-points":return`${n}: clip-path polygon() on ${i(l.el)} has more than ${yt} points; GL draws up to ${yt}, so its DOM shows. Simplify the polygon${l.own?"":', or add data-umber-clip="false" to draw it uncut'}.`;case"polygon-nonzero":return`${n}: clip-path polygon() on ${i(l.el)} crosses itself, and GL fills polygons even-odd, so its DOM shows. Write polygon(evenodd, ...) or untangle it.`;default:{let e=l.by==="clip"?l.node.clip:l.node.clipPath;return`${n}: ${l.by==="clip"?"clip":"clip-path"} ${o(e)} on ${i(l.el)} can't be drawn in GL, so its DOM shows. Use inset(), rect(), xywh(), circle(), ellipse() or polygon()${l.own?"":', or add data-umber-clip="false" to draw it uncut'}.`}}}function pn(e,t,n,r=e.rect){let i=e.offset;if(r[0]=e.doc.x-t+(i?i[0]:0),r[1]=e.doc.y-n+(i?i[1]:0),e.pixelGrid&&(r[1]=Math.round(r[1]*e.pixelGrid)/e.pixelGrid),r[2]=e.doc.w,r[3]=e.doc.h,e.pad){let t=e.pad*(e.layoutW?e.doc.w/e.layoutW:1),n=e.pad*(e.layoutH?e.doc.h/e.layoutH:1);r[0]-=t,r[1]-=n,r[2]+=t/e.pad*(e.pad*2+e.rounding[0]),r[3]+=n/e.pad*(e.pad*2+e.rounding[1])}return r}var mn=/^(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)/,bn=/^(rotate|perspective|offset|clip|display|border\w*Radius|all$|zoom)/,gn={transform:/^(none|((translate[XY]?\([^()]*\)|scale[XY]?\([^()-]*\)) ?)+)$/,translate:/^\S+( \S+)?$/,scale:/^[^-\s]+( [^-\s]+)?$/},vn=new WeakMap;function yn(e){let t=vn.get(e);if(t!==void 0)return t;try{let n=e.effect.getKeyframes();t=0;for(let e of new Set(n.flatMap(e=>Object.keys(e)))){if(!mn.test(e))continue;let r=n.map(t=>t[e]).filter(e=>e!=null),i=gn[e];t=Math.max(t,bn.test(e)||i&&!(r.length&&r.every(e=>i.test(String(e).trim())))?2:1)}}catch{t=2}return vn.set(e,t),t}var wn=e=>yn(e)>0;var xn=50;function kn(e,{onlyHiding:t=!1}={}){try{return e.getKeyframes().some(e=>"opacity"in e&&!(t&&parseFloat(e.opacity)>0)||"visibility"in e||"clipPath"in e)}catch{return!0}}var Mn=/^(offset|computedOffset|easing|composite|opacity|filter|color|\w+(Color|Shadow))$/,$n=e=>!kn(e,{onlyHiding:!0})&&e.getKeyframes().every(e=>Object.keys(e).every(e=>Mn.test(e)));function Sn(e){return typeof CSSTransition<"u"&&e instanceof CSSTransition?"CSS transition":typeof CSSAnimation<"u"&&e instanceof CSSAnimation?"CSS animation":"Web Animation"}function Nn(e,t,n){let r=t.getComputedTiming(),i=Number(r.endTime);if(i===1/0)return 1/0;let o=Number(r.localTime??0)||0;return n+Math.max(0,e.playbackRate<0?o:i-o)/Math.abs(e.playbackRate)+xn}var Fn=class{constructor(e,t){this.stage=e;this.occluders=t;this.held=[]}scan(e){let t=this.stage;t.measurePhase.cd();let n=this.held;if(this.held=[],typeof document.getAnimations=="function"){for(let e of this.occluders.list)e.until=0,e.linked=!1,e.fades=!1;if(this.Sg()){for(let t of document.getAnimations()){let r=Pn(t,e);r&&(this.Fi(r,r.fx),this._d(r,n))}for(let e of t.planes.all)e._B&&(e._B=!1,e.animUntil!==1/0&&(e.stale=!0))}}}Sg(){let e=!1;for(let t of this.stage.planes.all)t.zone.soon&&(e=!0,t._B=t.animUntil===1/0,t._B&&(t.animUntil=0),t.scrollLinked=!1,t._v.length=0,t.animUntil||(t.animLabel=""));return e}Fi(e,t){for(let n of this.occluders.list)!e.target.contains(n.el)||e.until===1/0&&$n(t)||(n.fades||=kn(t,{onlyHiding:e.until===1/0}),e.scrollTimeline?n.linked=!0:e.until>n.until&&(n.until=e.until))}_d(e,t){let n=null;for(let r of this.stage.planes.all)!r.zone.soon||!(e.target===r.el||e.target.contains(r.geomEl))||(r._v.includes(e.target)||r._v.push(e.target),e.scrollTimeline?(r.scrollLinked=!0,r.animLabel||=`scroll-driven ${e.kind} on ${i(e.target)}`):e.running?Cn(r,e):(n??=this.hold(e,t),zn(r,e,t,n)))}hold(e,t){let n=t.find(t=>t.a===e.a),r={a:e.a,t:n?n.t:e.a.currentTime,state:e.state,planes:[]};return this.held.push(r),r}Th(){for(let e of this.held){let t=e.a.playState;t!==e.state&&(e.state=t,this.stage.measurePhase.ma(),this.stage.scheduler.request());let n=e.a.currentTime;if(n!==e.t){e.t=n;for(let t of e.planes)t.heldMoved=!0}}}Ad(e){let t=this.stage;if(t.scheduler.inactive)return;if(this.held.some(t=>t.a===e)){t.scheduler.request();return}if(!wn(e))return;let n=e.effect?.target;if(n){if(this.occluders.holds(n)){t.measurePhase.ma(),t.scheduler.request();return}t.measurePhase.Vh(n)}}};function Pn(e,t){let n=e.playState;if(n==="idle")return null;let r=e.effect,i=r?.target;if(!r||!i||r.pseudoElement||!wn(e))return null;let o=n==="running"&&!!e.playbackRate,l=typeof DocumentTimeline<"u"?DocumentTimeline:null,s=!!(e.timeline&&l&&!(e.timeline instanceof l)),a=o&&!s?Nn(e,r,t):0;return{a:e,fx:r,target:i,state:n,running:o,scrollTimeline:s,until:a,kind:Sn(e)}}function Cn(e,t){t.until<=e.animUntil||(e.animUntil=t.until,e.animLabel=`${t.until===1/0?"infinite ":""}${t.kind} on ${i(t.target)}`)}function zn(e,t,n,r){n.some(e=>e.a===t.a)||(e.heldMoved=!0),r.planes.push(e),e.animLabel||=`${t.state} ${t.kind} on ${i(t.target)} (followed while a script moves its time)`}var On=e=>!!e.backgroundImage&&e.backgroundImage!=="none"||!/^(transparent|rgba\(.*,\s*0\))$/.test(e.backgroundColor||"transparent"),Ln=["transform","translate","rotate","scale","perspective","filter","backdropFilter","clipPath","maskImage","webkitMaskImage"],_n=e=>e.position!=="static"&&e.zIndex!=="auto"||/fixed|sticky/.test(e.position)||parseFloat(e.opacity)<1||Ln.some(t=>(e[t]||"none")!=="none")||e.isolation==="isolate"||(e.mixBlendMode||"normal")!=="normal"||/\b(layout|paint|strict|content)\b/.test(e.contain)||/^(size|inline-size)$/.test(e.containerType)||/\b(transform|translate|rotate|scale|perspective|filter|opacity|clip-path|mask|isolation|mix-blend-mode|contain)\b/.test(e.willChange),Dn=e=>e!==null&&e!==document.body&&e!==document.documentElement;function Tn(e,t){let n=parseInt(getComputedStyle(t).zIndex,10);if(!(n>0))return null;let r=null,o="auto",l=[];for(let t=e;Dn(t);t=t.parentElement){let n=getComputedStyle(t);On(n)&&!(t===e&&e.matches("[data-umber~=shader]"))&&l.push(t),_n(n)&&(r=t,o=n.position!=="static"?n.zIndex:"auto")}if(!r||o==="auto"||+o<n)return null;let s=l.filter(e=>r.contains(e)),a=s.find(t=>t!==e)??s[0];return a?a===e?`its own background covers Umber's canvas (z-index ${n}): ${i(r)} around it (z-index ${o}) is above the canvas, so that background paints over what GL draws of it. Remove its background (GL draws the element itself), or drop that z-index.`:`${a===r?`${i(r)} (z-index ${o}, with a background) covers Umber's canvas (z-index ${n})`:`${i(r)} (z-index ${o}) is above Umber's canvas (z-index ${n}), and the background of ${i(a)} inside it covers Umber's canvas`}: GL inside it is hidden. Drop that z-index (and give it data-umber-occlude if it must still cover the GL elements before it) or move the background behind the content.`:null}function Yn(e,t,n){if(!e.has(t)||e.get(t)){let r=Tn(t.el,n.canvasHost.el),o=t.kind==="layer",l=r&&`${i(t.el)}: ${r}${o?"":" Until then its DOM shows."}`;e.set(t,l),l&&o&&n.fallbacks.Ja(t,l)}return t.kind==="layer"?null:e.get(t)??null}function Xn(e,t,n){let r=parseInt(getComputedStyle(n).zIndex,10);if(!(r>0)||t>=r||!_n(getComputedStyle(e)))return null;let o=i(e);return[...e.querySelectorAll("[data-umber~=above]")].map(e=>[e,`data-umber="above" on ${i(e)} stays under Umber's canvas: ${o} around it is a stacking context (a pin, a transform, a fade) under the canvas (z-index ${r}). Give ${o} position: relative and z-index: ${r+1} (no background), or move it out.`])}function Hn(e){let t=[],n=!0;for(let r=e;Dn(r);r=r.parentElement){let e=getComputedStyle(r),i=_n(e),o=e.position!=="static";(i||n&&o)&&t.unshift([r,o&&e.zIndex!=="auto"&&+e.zIndex||0]),(i||o)&&(n=!1)}return t}function An(e,t,n,r){let i=0;for(;i<t.length&&i<r.length&&t[i]?.[0]===r[i]?.[0];)i++;let o=t[i]?.[1]??-.5,l=r[i]?.[1]??-.5;return o!==l?l>o:!!(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function jn(e){let t=getComputedStyle(e),n=t.backgroundColor||"transparent";return(n!=="transparent"&&!n.startsWith("rgba(")&&!/\/\s*(0?\.\d+|0)\s*\)$/.test(n)||!!t.backgroundImage&&t.backgroundImage!=="none")&&parseFloat(t.opacity)>=1}var In={1:.75,2:1.5},Gn=3,Wn=typeof navigator<"u"&&navigator.userAgent.includes("AppleWebKit/")&&!/Chrome\/|Chromium\//.test(navigator.userAgent),En=e=>!!e&&Q(e).radius.some(e=>e.split(" ").every(e=>parseFloat(e)>0));function Rn(e){let t=null;for(let n of e)Ee(n)&&(n.transform!=="none"||n.rotate!=="none")&&(t=n.el);if(!t)for(let n of e)(Ee(n)||n.perspective!=="none")&&(t=n.el);return t}function Un(e,t,n){let r=i(e.el),o=i(n);switch(t){case"behind":return`${r}: part of it turns behind the viewer (3D transform on ${o}), so its DOM shows until it turns back. Lower the angle or raise the perspective.`;case"svg":return`${r}: GL elements can't sit inside an <svg> (${o}); its DOM shows. Move data-umber to an element outside the SVG.`;case"offset-path":return`${r}: offset-path on ${o} moves it along a path GL does not follow, so its DOM shows. Animate transform instead.`;case"scene":return`${r}: GL can't depth-sort several GL elements in one preserve-3d scene (${o}), so their DOM shows. Add backface-visibility: hidden to faces that turn away, or use transform-style: flat.`;case"rounded":return`${r}: WebKit draws a tilt flat when its perspective parent (${o}) also has overflow and border-radius, so its DOM shows. Put the perspective on an inner element, or round the corners with clip-path: inset(0 round <radius>).`;case"zoom":return`${r}: zoom on ${o} scales it in a way GL can't follow together with its transforms, so its DOM shows. Use transform: scale() instead of zoom.`;case"verify":return`${r}: its on-screen box doesn't match the transforms on ${o} (turned almost edge-on?), so its DOM shows until they agree again. Lower the angle or raise the perspective.`}}function Vn(e,t){for(let n of t){if(n.el.namespaceURI==="http://www.w3.org/2000/svg")return Un(e,"svg",n.el);if(n.offsetPath!=="none"&&n.offsetPath!==""&&We(n))return Un(e,"offset-path",n.el)}return null}function Bn(e,t,n){let r=Q(e);n.w=Number.isFinite(r.width)&&r.width>0?r.width:t.width,n.h=Number.isFinite(r.height)&&r.height>0?r.height:t.height}var qn=class{constructor(t){this.stage=t;this.kj=new Map;this.Jf=new Map;this.hh=new Set;this.vi=e(4);this.jj={rel:new Float64Array(64),sizes:new Float64Array(64),bodyOrNull:()=>this.stage.env.lib.bodyOrNull()}}clear(){this.kj.clear(),this.Jf.clear(),this.hh.clear()}Td(e){let t=this.kj.get(e);return t||(t=e.getBoundingClientRect(),this.kj.set(e,t)),t}grow(e){this.jj.rel.length>=e*2+2||(this.jj.rel=new Float64Array(e*4),this.jj.sizes=new Float64Array(e*4))}yj(e,t,n,r){let{sx:i,sy:o,w:s,h:a}=n,u=e[t]?.el;if(!u)return!1;let c=this.Jf.get(u);if(c!==void 0)return c&&r.set(c),!!c;let h=this.Td(u),d=Je(e,t),f=!0,p={r:h,sx:i,sy:o};return d===0?l(r,s,a,p):(d===1?pt(et(e,t,this.vi),r):f=this.Ue(e,t,n,r),f&&mt(r,s,a,p)),this.Jf.set(u,f?r:null),f}Ue(e,t,n,r){let i=tt(e,t);if(this.grow(e.length),!U(e,t,i,this.jj))return!1;let{m:o}=ot(e,t,i,this.jj);return lt(o,n.w,n.h)?!1:(ft(o,r),!0)}gi(e,t){let{full:n,restyle:r,r:i}=t;(n||r)&&this.aj(e,n,r,i);let o=e.level;if(e.backHidden=!1,e.scene=null,e.xfReason=e._T,!o||e._T){e.edge[0]=1,e.edge[1]=1;return}let l=e._G,s=null;o===1?pt(et(e.nodes,0,this.vi),l):s=this.tilt(e),s??=this.verify(e,o,t),s||bt(l,e._u,e._F,e.edge),e.xfReason=s}aj(e,t,n,r){let i=e.nodes;if(t)i=this.og(e);else if(n&&(e.level&&e._k.length||e._v.length))this.Of(e,i);else return;let[o]=i;if(!o)return;t||(o.box=void 0);let l=Q(o);e._u=Number.isFinite(l.width)&&l.width>0?l.width:r.width,e._F=Number.isFinite(l.height)&&l.height>0?l.height:r.height;let s=Je(i,0);s!==e.level&&e.raster&&(e.raster.Ze=!0),e.level=s}Of(e,t){if(e.level)for(let n of e._k){let e=t[n];e&&R(e,this.hh)}for(let n of e._v){let e=t.find(e=>e.el===n);e&&R(e,this.hh)}}og(e){let t=e.nodes=ne(e.geomEl,this.stage.env.frame.cc);e.chained=!0;let n=e._k;return n.length=0,t.forEach((t,r)=>{(Ee(t)||t.perspective!=="none"||e._v.includes(t.el))&&n.push(r)}),e._T=Vn(e,t),t}tilt(e){let t=e.nodes,n=tt(t,0);if(this.grow(t.length),!U(t,0,n,this.jj))return Un(e,"svg",t[0]?.el??null);let r=ot(t,0,n,this.jj);if(ft(r.m,e._G),e.backHidden=r.backHidden,e.scene=t[r.scene]?.el??null,lt(r.m,e._u,e._F))return Un(e,"behind",Rn(t));if(!Wn)return null;let i=Ze(t,0,n,e=>En(t[e]));return i>=0?Un(e,"rounded",t[i]?.el??null):null}verify(e,t,n){if(mt(e._G,e._u,e._F,n)<=In[t])return e._A=0,null;if((n.now<e.animUntil||e.scrollLinked)&&++e._A<Gn)return null;let r=e.nodes,i=r.find(e=>e.zoom&&Math.abs(parseFloat(e.zoom)-1)>1e-6);return i?Un(e,"zoom",i.el):Un(e,"verify",Rn(r))}};function Kn(t,n){if(!n.level||n.xfReason)return null;let r=e(9);if(!o(r,n._G))return null;let i=n.scrolls?t.env.host.scroll.root:null,l=i?i.scrollLeft:q(t.env.lib.bodyOrNull),s=i?i.scrollTop:K(t.env.lib.bodyOrNull),a=n._G,u=n._u/2,c=n._F/2,h=a[2]*u+a[5]*c+a[8],d=(a[0]*u+a[3]*c+a[6])/h,f=(a[1]*u+a[4]*c+a[7])/h;return{width:n._u,height:n._F,ax:(a[0]-d*a[2])/h,ay:(a[1]-f*a[2])/h,bx:(a[3]-d*a[5])/h,by:(a[4]-f*a[5])/h,toLocal(e,t,n){let i=e+l,o=t+s,u=r[2]*i+r[5]*o+r[8],c=(r[0]*i+r[3]*o+r[6])/u,h=(r[1]*i+r[4]*o+r[7])/u;n[0]=c,n[1]=h;let d=a[2]*c+a[5]*h+a[8];n[2]=(a[0]-i*a[2])/d,n[3]=(a[1]-o*a[2])/d,n[4]=(a[3]-i*a[5])/d,n[5]=(a[4]-o*a[5])/d}}}function Jn(e){let t=new Map;for(let n of e.planes.all)n.scene&&!n.backHidden&&!n.xfReason&&n.el.isConnected&&t.set(n.scene,(t.get(n.scene)??0)+1);for(let n of e.planes.all){let r=n.scene&&!n.backHidden&&(t.get(n.scene)??0)>1?Un(n,"scene",n.scene):null;r!==n._y&&(n._y=r,e.fallbacks.decide(n))}}function Zn(e){let t=getComputedStyle(e.el);e.by==="clip"?e.node.clip=t.getPropertyValue("clip")||"auto":e.node.clipPath=t.clipPath||"none"}function Qn(e){return e.nodes[e.nodes.length-1]?.topLayer?`${i(e.el)}: it is inside an open modal <dialog> or popover (the top layer), which paints over Umber's canvas, so its DOM shows.`:null}var er=[null,-1,!1];function tr(e){let t=e.jc;return(er[0]!==e||er[1]!==t)&&(er=[e,t,!!document.querySelector("[data-umber~=above]")]),er[2]}var nr=class{constructor(n,r,i,o){this.stage=n;this.placement=r;this.occluders=i;this.Md=o;this.box={sx:0,sy:0,w:0,h:0};this.covers=new WeakMap;this.contexts=new WeakSet;this.quad=e(4);this.V=t(4)}measure(e,t,n=!0){let o=Qn(e);if(o)return o;this.uncut(e),t&&this.pe(e);let l=this.gb(e);if(l)return l;let s=e.clips;if(!s)return null;s.noSlots=e.kind==="layer",this.S(e,t,n),pn(e,0,0,this.V);let a=this.V,u=this.quad;u[0]=a[0],u[1]=a[1],u[2]=a[0]+a[2],u[3]=a[1]+a[3];let c=Dt(e,s,u,e.bends);e.stale&&(s.ownRadius.set(e.radius),s.ownKy=e._w);let h=!1;for(let t=0;t<4;t++){let n=r(s.ownRadius,t),i=r(s.fold,t);e.radius[t]=Math.max(n,i),h||=i>n}if(e._w=h?1:s.ownKy,e.kind!=="layer")return c?fn(e,s):null;if(c||s.shaders.length){let t=s.shaders[0]?.el??c?.clips[0]?.el??s.mask?.el;this.stage.fallbacks.Ja(e,`${i(e.el)}: a layer can't be cut by a rounded, shaped or masked parent (${i(t)}); it draws uncut. Make that parent's clip a straight overflow: hidden, or add data-umber-clip="false" to silence this.`),s.shaders.length=0,s.reason=null}return null}uncut(e){let t=e.clips,n=t?t.occluderHow.indexOf("uncut"):-1,r=t?.occluders[n];if(!t||!r)return;let o=i(r.el);this.stage.fallbacks.Ja(e,t.noSlots?`${i(e.el)}: a layer can only be cut straight, so data-umber-occlude on ${o} doesn't hide it where it passes through it or a rounded or turned corner overlaps it (GL draws over that panel there).`:`${i(e.el)}: its parents' rounded or shaped clips take both GL clip slots, so data-umber-occlude on ${o} doesn't hide it where they overlap (GL draws over that panel there). Make one of those parents' clips a straight overflow: hidden.`)}pe(e){let t=this.stage;if(!t.transitions.ongoing){Yn(this.covers,e,t);let n=tr(t.batches)?Hn(e.el):[],r=n.length?n[0]:null,i=r&&r[0]!==e.el&&!this.contexts.has(r[0])&&Xn(r[0],r[1],t.canvasHost.el);if(i){this.contexts.add(r[0]);for(let[e,n]of i)t.env.host.log.warn(n,e)}}let n=(e.el.getAttribute("data-umber-clip")??"").trim().toLowerCase()==="false";e.clips=kt(e,{nodes:e.nodes,off:n,isInsideScroll:this.Md,previous:e.clips,occluders:this.occluders.Nk(e)})}gb(e){return e.kind==="layer"?null:this.covers.get(e)}S(e,t,n){let r=this.stage;for(let i of e.clips?.list??[]){i.by!=="overflow"&&!t&&n&&Zn(i);let o=rr(i),l=this.box;l.sx=i.scrolls?r.env.frame.scrollX:r.env.frame.pageX,l.sy=i.scrolls?r.env.frame.scrollY:r.env.frame.pageY,Bn(i.node,this.placement.Td(i.el),l),i.ignored=!this.placement.yj(e.nodes,i.depth,l,i.toDocument),i.ignored||Pt(i,i.toDocument,{width:l.w,height:l.h,value:o})}}};function rr(e){return e.by==="overflow"?"":e.by==="clip"?e.node.clip:e.node.clipPath}var ir=[],or=4;function lr(e,t){if(t.contains(e)||e.contains(t))return!0;let n=e.parentElement;for(let e=t,r=0;e&&e!==document.body&&r<or;e=e.parentElement,r++){let t=e.parentElement;if(t&&(n===t||n?.parentElement===t))return!0}return!1}var sr=/^(SPAN|B|I|EM|STRONG|SMALL|SUB|SUP|TIME|BR)$/;function ar(e){for(let t of e)if(t.nodeType===1&&!sr.test(t.nodeName))return!0;return!1}function ur(t,n){let r=e(9),i=e(9),o=e(4),l=e(8);return{el:t,by:"occlude",node:n,nodes:[],own:!1,ignored:!0,depth:0,key:"",shape:null,reason:null,toDocument:r,toShape:i,bounds:o,scrolls:!0,square:!1,how:"pruned",live:!1,axis:!0,radiusX:0,radiusY:0,want:!1,over:!1,cuts:[],full:l,from:null,warned:!1,stack:[],hidden:!1,until:0,linked:!1,fades:!1,siblingOrParent:null}}var cr=(e,t,n)=>e.ignored===n&&e.bounds[0]===t[0]&&e.bounds[1]===t[1]&&e.bounds[2]===t[2]&&e.bounds[3]===t[3],hr=class{constructor(t,n,r){this.stage=t;this.placement=n;this.Md=r;this.edges=e(4);this.was=e(4);this.box={sx:0,sy:0,w:0,h:0};this.list=[];this.Pj=-1;this.hostZ=0;this.ik=!1;this.rk=!1;this.watch=null}ha(){this.ik=!1;let e=this.stage;return e.batches.gk!==this.Pj?(this.Pj=e.batches.gk,this.find(),this.zf(),this.rk=!1,this.list.length>0):this.rk&&!e.env.frame.scrolled?(this.rk=!1,this.zf(),!0):!1}find(){let e=document.querySelectorAll("[data-umber-occlude]");if(!e.length&&!this.list.length)return;this.hostZ=+getComputedStyle(this.stage.canvasHost.el).zIndex||0;let t=e.length!==this.list.length,n=[];if(e.forEach((e,r)=>{let i=this.list.find(t=>t.el===e)??ur(e,E(e,this.stage.env.frame.cc));this.list[r]!==i&&(t=!0),n.push(i)}),this.list=n,!!t){this.Ne();for(let e of this.stage.planes.all)e.stale=!0;this.stage.scheduler.markDirty()}}follow(e){let t=this.list;for(let e of t)e.want=!1,e.over=!1,!e.ignored&&!e.el.isConnected&&(e.ignored=!0,this.stage.scheduler.markDirty());for(let e of this.stage.planes.all)(e.zone.soon||e.visible)&&br(e);for(let n of t){let t=n.linked||e<n.until;!(n.live||t)||!n.want||!n.el.isConnected||(this.place(n,!1,t&&n.fades),e<n.until&&(n.until<1/0||n.over)&&this.stage.scheduler.uc(1))}}hook(e){if(e===document.body||e===document.documentElement)return!1;for(let t of this.list)if(lr(e,t.el))return this.rk=!0;return!1}holds(e){return this.list.some(t=>e.contains(t.el))}Ne(){if(typeof MutationObserver>"u")return;let e=this.watch;if(e)e.disconnect();else{let t=new MutationObserver(e=>{for(let t of e)(t.type==="childList"?ar(t.addedNodes)||ar(t.removedNodes):this.hook(t.target))&&(this.rk=!0,this.stage.scheduler.request())});this.stage.env.cleanups.push(()=>{t.disconnect()}),this.watch=t,e=t}if(this.list.length){e.observe(document.documentElement,{subtree:!0,attributes:!0,attributeFilter:["aria-expanded","aria-hidden","open","data-state","hidden"]});for(let t of this.list)e.observe(t.el,{childList:!0,subtree:!0})}}place(e,t,n=t){let r=this.stage;if(t&&this.M(e),!e.nodes.length||(n&&(e.hidden=dr(e,t)),t&&!e.hidden&&!e.warned&&!e.el.matches("[data-umber~=shader]")&&!jn(e.el)&&(e.warned=!0,r.env.lib.say("occludeSeeThrough",[e.el],e.el)),e.ignored=e.hidden||!e.el.isConnected,e.ignored))return;let i=this.placement.Td(e.el);if(e.ignored=i.width<=0||i.height<=0,e.ignored)return;let o=this.box;Bn(e.node,i,o);let l=o.sx=e.scrolls?r.env.frame.scrollX:r.env.frame.pageX,s=o.sy=e.scrolls?r.env.frame.scrollY:r.env.frame.pageY;e.ignored=!this.placement.yj(e.nodes,0,o,e.toDocument),!e.ignored&&(fr(e,o.w,o.h),e.ignored=this.cut(e,l,s),!e.ignored&&(t&&e.reason==="mixed-corners"&&r.env.lib.say("occludeCorners",[e.el],e.el),e.axis=gt(e.toDocument),pr(e)))}M(e){e.nodes=ne(e.el,this.stage.env.frame.cc);let[t]=e.nodes;t&&(e.node=t),e.scrolls=this.Md(e.el),e.live=ue(e.nodes,this.stage.env.host.scroll.root)||e.el.hasAttribute("data-umber-live"),e.stack=Hn(e.el),e.cuts=e.nodes.length?ge(e.nodes).sources.filter(t=>t.by==="overflow"&&!Je(e.nodes,t.depth)).map(e=>e.node):[]}cut(e,t,n){let r=e.bounds,i=e.shape,o=e.toDocument;if(!i)return!1;if(i.kind||o[1]||o[3]||o[2]||o[5]||!(o[0]>0&&o[4]>0))return r[2]<=r[0]||r[3]<=r[1];let l=this.edges;l.set(r),this.Oe(e,t,n,l);let s=l[0],a=l[1],u=l[2],c=l[3];return u<=s||c<=a?!0:(s===r[0]&&a===r[1]&&u===r[2]&&c===r[3]||(gr(i.radius,r,l),i.box[0]=(s-o[6])/o[0],i.box[1]=(a-o[7])/o[4]*i.ky,i.box[2]=(u-s)/o[0],i.box[3]=(c-a)/o[4]*i.ky,r.set(l)),!1)}Oe(e,t,n,r){for(let i of e.cuts){let e=this.placement.Td(i.el),{border:o,scrollbar:l,direction:s}=Q(i),a=s==="rtl"?l[0]:0;i.overflowX!=="visible"&&(r[0]=Math.max(r[0],e.left+t+o[3]+a),r[2]=Math.min(r[2],e.right+t-o[1]-l[0]+a)),i.overflowY!=="visible"&&(r[1]=Math.max(r[1],e.top+n+o[0]),r[3]=Math.min(r[3],e.bottom+n-o[2]-l[1]))}}zf(){if(!(this.ik||!this.list.length)){this.ik=!0;for(let e of this.list){this.was.set(e.bounds);let t=e.ignored,n=e.stack,r=e.siblingOrParent,i=e.nodes.length>0;if(this.place(e,!0),cr(e,this.was,t)||this.stage.scheduler.markDirty(),e.siblingOrParent=e.el.previousElementSibling??e.el.parentElement,i&&(e.siblingOrParent!==r||mr(n,e.stack))){for(let e of this.stage.planes.all)e.stale=!0;this.stage.scheduler.markDirty()}}}}Nk(e){if(!this.list.length||this.hostZ<=0)return ir;this.zf();let t=(e.el.getAttribute("data-umber-under")??"").trim();if(t==="none")return ir;let n=t?this.picked(e,t):null,r=[],i=null;for(let t of n??this.list){if(!this.K(e,t,!!n))continue;(!!n||(this.stage.planes.of(t.el)?this.drawnOver(e.el,t.el):An(e.el,i??=Hn(e.el),t.el,t.stack)))&&r.push(t)}return r.length?r:ir}drawnOver(e,t){let n=e=>this.stage.env.lib.attr.num(e,"data-umber-order",0),r=n(t)-n(e);return r?r>0:!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}K(e,t,n){return t.el.contains(e.el)?(n&&this.stage.fallbacks.Ja(e,`${i(e.el)}: data-umber-under names ${i(t.el)}, which holds it; a panel never cuts what is inside it.`),!1):!e.el.contains(t.el)||e.kind==="shader"}picked(e,t){let n;try{n=this.list.filter(e=>e.el.matches(t))}catch{n=[]}return n.length?n:(this.stage.fallbacks.Ja(e,`${i(e.el)}: data-umber-under="${t}" matches no [data-umber-occlude] element, so its occluders are the usual ones (those after it in the page).`),null)}};function dr(e,t){let n=getComputedStyle(e.el);t||(e.node.clipPath=n.clipPath||"none");let r=n.visibility==="hidden"||e.el.checkVisibility?.()===!1;for(let n of e.nodes){if(r)break;r=parseFloat(t?n.opacity:getComputedStyle(n.el).opacity)===0}return r}function fr(e,t,n){let i=e.full;if(e.shape&&e.shape===e.from)for(let t=0;t<4;t++)e.shape.box[t]=r(i,t),e.shape.radius[t]=r(i,t+4);if(Pt(e,e.toDocument,{width:t,height:n,value:/^(inset|circle|ellipse|rect|xywh)\(/.test(e.node.clipPath)?e.node.clipPath:"border-box"}),e.shape&&e.shape!==e.from){e.from=e.shape;for(let t=0;t<4;t++)i[t]=r(e.shape.box,t),i[t+4]=r(e.shape.radius,t)}}function pr(e){let t=e.shape,n=t?.kind===0?Math.max(t.radius[0],t.radius[1],t.radius[2],t.radius[3]):0;e.radiusX=n*e.toDocument[0],e.radiusY=t?n/t.ky*e.toDocument[4]:0}var mr=(e,t)=>e.length!==t.length||e.some((e,n)=>{let r=t[n];return r?e[0]!==r[0]||e[1]!==r[1]:!0});function br(e){let t=e.clips;if(!t)return;let n=t.occluders;for(let e=0;e<n.length;e++){let r=n[e];r&&(r.want=!0,(t.occluderHow[e]!=="pruned"||t.Sh===r)&&(r.over=!0))}}function gr(e,t,n){let r=n[1]>t[1],i=n[2]<t[2],o=n[3]<t[3],l=n[0]>t[0];(r||l)&&(e[0]=0),(r||i)&&(e[1]=0),(i||o)&&(e[2]=0),(o||l)&&(e[3]=0)}var vr=class{constructor(e){this.stage=e;this.sk={scrollX:0,scrollY:0,pageX:0,pageY:0,canvasPerCssX:1,canvasPerCssY:1,canvasWidth:1,canvasHeight:1};let t=t=>{let n=e.env.host.scroll.root;return n?n!==t&&n.contains(t):!0};this.placement=new qn(e),this.occluders=new hr(e,this.placement,t),this.cuts=new nr(e,this.placement,this.occluders,t),this.animations=new Fn(e,this.occluders);let n=t=>{let n=t.target;n instanceof Element&&(t.type!=="input"||/^(checkbox|radio|select-)/.test(n.type))&&this.occluders.hook(n)&&e.scheduler.request()};for(let t of["pointerover","pointerout","focusin","focusout","input"])e.env.listen(document,t,n)}start(e,t){this.placement.clear(),this.occluders.ha()&&(t=!0),t&&this.animations.scan(e),this.occluders.list.length&&this.occluders.follow(e),this.animations.Th()}gi(e,t){this.placement.gi(e,t)}yc(e){return Kn(this.stage,e)}zl(){Jn(this.stage)}Fb(e,t,n=!0){return this.cuts.measure(e,t,n)}Ii(e){this.animations.scan(e)}Th(){this.animations.Th()}Ad(e){this.animations.Ad(e)}frame(e,t){let n=this.stage,r=this.sk;r.scrollX=n.env.frame.scrollX,r.scrollY=n.env.frame.scrollY,r.pageX=n.env.frame.pageX,r.pageY=n.env.frame.pageY,r.canvasWidth=n.gpu.canvas.width,r.canvasHeight=n.gpu.canvas.height,r.canvasPerCssX=n.gpu.canvas.width/Math.max(e,1),r.canvasPerCssY=n.gpu.canvas.height/Math.max(t,1)}clip(e,t,n){return Ut(e,t,n,this.sk)}fh(e,t,n){let r=e._s,i=e.pad,o=e.edge[0],l=e.size;l[0]=(e._u+2*i+e.rounding[0])*o,l[1]=(e._F+2*i+e.rounding[1])*o;let s=e._G,a=e._O,u=1/o;a[0]=s[0]*u,a[1]=s[1]*u,a[2]=s[2]*u,a[3]=s[3]*u,a[4]=s[4]*u,a[5]=s[5]*u,a[6]=s[6]-i*(s[0]+s[3]),a[7]=s[7]-i*(s[1]+s[4]),a[8]=s[8]-i*(s[2]+s[5]),r[0]=a[0]-t*a[2],r[1]=a[1]-n*a[2],r[2]=a[2],r[3]=a[3]-t*a[5],r[4]=a[4]-n*a[5],r[5]=a[5],r[6]=a[6]-t*a[8],r[7]=a[7]-n*a[8],r[8]=a[8];let c=l[0]/2,h=l[1]/2,d=r[2]*c+r[5]*h+r[8],f=e._x;f[0]=(r[0]*c+r[3]*h+r[6])/d-c,f[1]=(r[1]*c+r[4]*h+r[7])/d-h,f[2]=l[0],f[3]=l[1]}pointer(e,t,n){let r=e._q;if(!o(r,e._O))return;let i=r[2]*t+r[5]*n+r[8];e._m[0]=(r[0]*t+r[3]*n+r[6])/i/Math.max(e.size[0],1),e._m[1]=(r[1]*t+r[4]*n+r[7])/i/Math.max(e.size[1],1)}Sh(e){return`it is entirely cut off by ${hn(e)} on ${i(e.el)}`}report(e,t){let n=e.clips,r=(n?.list??[]).map(e=>(e.ignored&&t.push(`the ${hn(e)} clip on ${i(e.el)} is skipped right now: part of that parent turns behind the viewer`),{el:e.el,by:e.by,shape:hn(e),how:e.how}));return n?.occluders.forEach((e,o)=>{let l=n.occluderHow[o]??"pruned";l==="uncut"&&t.push(`data-umber-occlude on ${i(e.el)} overlaps it, but ${n.noSlots?"a layer is only cut straight":"its parents' clips take both GL clip slots"}: GL draws over that panel there`),r.push({el:e.el,by:e.by,shape:hn(e),how:l})}),r}};function yr(e){e.chunks.shapesError=null,e.chunks.shapes=new vr(e),e.measurePhase.ma();for(let t of e.planes.all)t.stale=!0,t.shapeWait=!1;e.scheduler.markDirty()}export{yr as shapes};
@@ -1,2 +1,2 @@
1
- /*! Umber v0.3.0 | (c) Ravi Klaassens | UNLICENSED */
2
- var t=()=>{};var e=()=>Promise.reject(new Error("no words"));var s={configure:t,debug:!1,warnings:!1,info:t,warn:t,error:t,report:t,words:e},i=s;function r(t){i=t}var a=class{constructor(t=60){this.hz=t;this.ta=0;this.Qa=!1}advance(t){this.ta+=t>0?t:0;let e=Math.floor(this.ta*this.hz+.5);return e>4?(e=4,this.ta=0):!e&&this.Qa?(e=1,this.ta=0):this.ta-=e/this.hz,this.Qa=!1,e}due(){this.Qa=!0,this.ta=Math.min(this.ta,0)}},o=1/255;function h(t){return t<=0?1:t>=1?1/0:Math.ceil(Math.log(o)/Math.log(t))}function n(t,e){return t===void 0||t===0||Number.isNaN(t)?e:t}function l(t,e,s){if(Array.isArray(t)){let i=t[Math.max(0,Math.min(t.length-1,e))];return n(i,s)}return t!=null&&t>0?t:s}var u=16,f=/^[A-Za-z_]\w*$/;function m(t){return Array.isArray(t.passes)?t.passes:typeof t.next=="string"?[{into:null,next:t.next}]:null}var p=(t,e)=>/\bvoid\s+main\s*\(/.test(t)?t:`${t}\nvoid main() { outColor = ${e}(vUv); }`;function d(t){for(let e of t.values())return e;throw new Error("umber.sim(): a sim has no fields")}function c(t,e){let s=t.get(e);if(!s)throw new Error(`umber.sim(): no field "${e}"`);return s}function g(t){let e=t.read;t.read=t.write,t.write=e}var v=class{constructor(t,e,s,i){this.sims=t;this.options=e;this.fields=new Map;this.na=[];this.passes=[];this.yb=[];this.brushes=[];this.steps=0;this.idle=0;this.awake=!1;this.released=!1;this.ok=!1;this.aspect=0;this.clock=new a(Math.max(1,n(e.hz,60))),this.uniforms={...e.uniforms,uDt:1/this.clock.hz,uStep:0,uPointer:new Float32Array([-1,-1])};let r=e.fields??{state:{init:e.init}};for(let[t,e]of Object.entries(r))this.af(t,e,s);this.out=(e.output===void 0?void 0:this.fields.get(e.output))??d(this.fields);for(let t of i)this.passes.push({into:t.into===null?this.out:c(this.fields,t.into),source:p(t.next,"next"),iterations:Math.max(1,Math.round(l(t.iterations,s,1))),program:null});for(let t of this.fields.values())t.init&&this.yb.push({field:t,source:t.init,program:null});this.pointer=this.passes.some(t=>/\buPointer\b/.test(t.source)),this.own=!!this.yb.length||e.settle===!1||this.passes.some(t=>/\bu(Time|Step)\b/.test(t.source)),this.compile(),this.start()}af(t,e,s){let i=e.type??this.options.type??"half",r={...this.dims(e.size,s),type:i,msaa:0,attachments:1,quiet:!0},a=this.sims.fx,o={name:t,read:a.make(r),write:a.make(r),size:e.size,init:e.init,type:i,holder:{get texture(){return o.read.texture}}};this.fields.set(t,o),this.na.push(o.holder),this.uniforms[t]=o.holder}dims(t,e){let s=this.sims.fx.stage,i=s.gpu.gl.getParameter(s.gpu.gl.MAX_TEXTURE_SIZE)??4096,r=Math.min(i,Math.max(1,Math.round(l(t??this.options.size,e,128))));this.aspect=s.canvasHost.viewport.height/Math.max(1,s.canvasHost.viewport.width);let a=this.options.shape==="square"?r:Math.min(i,Math.max(1,Math.round(r*this.aspect)));return{width:r,height:a}}compile(){let t=this.sims.fx.passes,e=!0;for(let s of this.passes)s.program=t.program(s.source,this.uniforms),s.program||(e=!1);for(let s of this.yb)s.program=t.program(p(s.source,"init"),this.uniforms),s.program||(e=!1);return this.ok=e,e||(this.awake=!1,this.sims.fx.stage.env.lib.say("simCompile",[])),e}start(){let t=this.sims.fx.stage;for(let t of this.fields.values())t.read.clear(),t.write.clear();for(let t of this.yb)t.program&&this.draw(t.program,t.field);t.gpu.gl.bindFramebuffer(t.gpu.gl.FRAMEBUFFER,null),t.gpu.renderer.reset(),this.steps=0,this.uniforms.uStep=0,this.own?this.wake():this.awake=!1}draw(t,e){let s=this.sims.fx.stage,i=e.write.b;i&&(s.gpu.gl.bindFramebuffer(s.gpu.gl.FRAMEBUFFER,i.draw),this.sims.fx.passes.draw(t,i.spec,this.uniforms),g(e))}run(t){let e=this.sims.fx.stage,s=e.canvasHost.viewport;this.options.shape!=="square"&&Math.abs(s.height/Math.max(1,s.width)-this.aspect)>.01&&this.fit();let i=this.clock.advance(t);for(let t=0;t<i;t++)this.step();if(i){e.gpu.gl.bindFramebuffer(e.gpu.gl.FRAMEBUFFER,null),e.gpu.renderer.reset();let t=this.options.settle;t!==!1&&(typeof t=="function"?t(this):this.idle>=(t??2)-1e-6)&&(this.awake=!1)}return i>0}step(){let t=this.uniforms,e=this.sims.fx.stage,s=e.env.frame.pointer;this.steps++,t.uStep=this.steps,this.idle+=1/this.clock.hz,t.uPointer[0]=s.x<0?-1:s.x/e.canvasHost.viewport.width,t.uPointer[1]=s.y<0?-1:s.y/e.canvasHost.viewport.height;for(let t of this.brushes)t.apply();for(let t of this.passes)if(t.program)for(let e=0;e<t.iterations;e++)this.draw(t.program,t.into)}fit(){let t=this.sims.level;for(let e of this.fields.values()){let{width:s,height:i}=this.dims(e.size,t);e.read.resize(s,i),e.write.resize(s,i)}this.start()}get texture(){return this.released?null:this.out.read.texture}get width(){return this.out.read.width}get height(){return this.out.read.height}get type(){return this.out.read.type}field(t){let e=this.fields.get(t);return e||this.sims.fx.stage.env.lib.say("simField",[t,[...this.fields.keys()]]),e?e.holder:null}wake(){return this.released?this:(this.idle=0,(!this.awake||!this.steps)&&this.clock.due(),this.awake=this.ok,this.sims.fx.stage.scheduler.request(),this)}set(t,e){return this.uniforms[t]=e,this.wake()}reset(){return this.released||this.start(),this}brush(t){return this.released?null:new w(this,t??{})}seen(){if(this.Rb)return!0;for(let t of this.na)if(t.Rb)return!0;let t=this.sims.fx.stage,e=this.sims.ya===this?t.chunks.flow:null,s=!1;for(let i of t.planes.all){let t=i.zone.soon||i.visible;if(i.layer&&t)return!0;if(this.ih(i.uniforms,e)){if(t)return!0;s=!0}}return!s}ih(t,e){for(let s in t){let i=t[s];if(!i)continue;let r=i.value;if(r===this||e!==null&&r===e||this.holds(r))return!0}return!1}holds(t){for(let e of this.na)if(e===t)return!0;return!1}release(){let t=this.sims;if(!this.released){if(t.ya===this){if(t.fx.stage.planes.all.some(t=>"uFlow"in t.uniforms))return;t.ya=null,t.$b=null}this.released=!0,this.awake=!1;for(let t of this.fields.values())t.read.release(),t.write.release();this.brushes.length=0,t.list.delete(this)}}},w=class{constructor(t,e){this.sim=t;this.options=e;this.stamps=new Float32Array(u*4);this.count=0;this.last=[NaN,NaN];this.released=!1;let s=e.field===void 0?void 0:t.fields.get(e.field),i=s??d(t.fields);e.field&&!s&&t.sims.fx.stage.env.lib.say("brushField",[e.field,i.name]),this.field=i;let r=t.sims.fx.stage.canvasHost.viewport,a=e.color??[1,1,1,1];this.uniforms={[i.name]:i.holder,uStamps:this.stamps,uCount:0,uBrushRadius:Math.max(.5,n(e.radius,24)),uColor:new Float32Array([n(a[0],0),n(a[1],0),n(a[2],0),a[3]??1]),uMotion:n(e.motion,0),uView:new Float32Array([r.width,r.height]),uMix:e.mode==="mix"?1:0},this.source=p(x.replace("FIELD",i.name),"next"),t.brushes.push(this)}paint(t,e,s=0,i=0){if(this.released||this.count>=u)return this;let r=this.sim.sims.fx.stage.canvasHost.viewport,a=this.stamps,o=this.count++*4;return a[o]=t/r.width,a[o+1]=e/r.height,a[o+2]=s,a[o+3]=i,this.sim.wake(),this}follow(t,e){let[s,i]=this.last;if(this.last[0]=t,this.last[1]=e,s!==s||t===s&&e===i)return;let r=t-s,a=e-i,o=Math.min(u-this.count,Math.max(1,Math.ceil(Math.hypot(r,a)/(this.uniforms.uBrushRadius*.5))));for(let t=1;t<=o;t++)this.paint(s+r*t/o,i+a*t/o,r/o,a/o)}apply(){let t=this.sim.sims.fx.stage,e=t.env.frame.pointer;if(this.options.pointer!==!1&&e.x>=0&&this.follow(e.x,e.y),!this.count)return;this.program===void 0&&(this.program=this.sim.sims.fx.passes.program(this.source,this.uniforms));let s=this.uniforms.uView;s[0]=t.canvasHost.viewport.width,s[1]=t.canvasHost.viewport.height,this.uniforms.uCount=this.count,this.count=0;let i=this.field,r=i.write.b;!this.program||!r||(t.gpu.gl.bindFramebuffer(t.gpu.gl.FRAMEBUFFER,r.draw),this.sim.sims.fx.passes.draw(this.program,r.spec,this.uniforms),g(i),this.sim.idle=0)}lost(){this.program=void 0}release(){this.released=!0;let t=this.sim.brushes,e=t.indexOf(this);e>=0&&t.splice(e,1)}},x=`uniform vec4 uStamps[16];\nvec4 next(vec2 uv){\nvec4 c=texture(FIELD,uv);\nfor(int i=0;i<16;i++){\nif(float(i)>=uCount)break;\nvec2 d=(uv-uStamps[i].xy)*uView;\nfloat k=exp(-dot(d,d)/(uBrushRadius*uBrushRadius));\nvec4 v=uColor+vec4(uStamps[i].zw*uMotion,0.0,0.0);\nc=uMix>0.5?mix(c,v,k*uColor.a):c+v*k;\n}\nreturn c;\n}`,b=`vec4 next(vec2 uv){\nvec2 v=texture(push,uv).xy;\nfloat l=length(v);\nreturn vec4(l<1.0/255.0?vec2(0.0):v/max(l,1.0)*uFade,0.0,1.0);\n}`,y=`vec4 next(vec2 uv){\nvec2 v=texture(push,uv).xy;\nfloat l=length(v);\nreturn vec4(l>0.0?v/l*0.5+0.5:vec2(0.5),1.0,min(l,1.0));\n}`,k=t=>t.options.pointer!==!1,M=class{constructor(t){this.fx=t;this.list=new Set;this.ya=null;this.$b=null;this.tick=t=>{let e=this.fx.stage;if(e.scheduler.inactive)return;let s=!1,i=!1;for(let e of this.list)if(e.awake){if(!e.seen()){for(let t of e.brushes)t.last[0]=NaN;continue}s=e.run(t.dt)||s,i||=e.awake}s?e.scheduler.markDirty():i&&e.scheduler.request()};let e=t.stage;e.gpu.subsystems.push(this),e.env.cleanups.push(e.env.host.ticker.add(this.tick,{phase:"render",order:-1}));let s=t=>{let s=t,i=t.type==="pointerdown";i&&(e.env.frame.pointer.x=s.clientX,e.env.frame.pointer.y=s.clientY);let r=i||t.type==="pointerout"&&!s.relatedTarget;for(let e of this.list)if(r)for(let t of e.brushes)t.last[0]=NaN;else t.type==="pointermove"&&(e.pointer||e.brushes.some(k))&&e.seen()&&e.wake()},i=["pointermove","pointerdown","pointerout"];for(let t of i)addEventListener(t,s,{passive:!0});e.env.cleanups.push(()=>{for(let t of i)removeEventListener(t,s);this.list.clear()})}get level(){return this.fx.stage.env.stats.gpu?.level??4}sim(t){let e=t?m(t):null;if(!t||!e)return this.fx.stage.env.lib.say("simNext",[]),null;let s=Object.keys(t.fields??{state:0});if(!s.length)return this.fx.stage.env.lib.say("simFields",[]),null;let i=s.find(t=>!f.test(t))??e.map(t=>t.into).find(t=>t!==null&&!s.includes(t));return i!=null?(this.fx.stage.env.lib.say("simName",[i,s]),null):this.make(t,e)}make(t,e,{quiet:s=!1}={}){let r=new v(this,t,this.level,e);this.list.add(r);for(let e of r.fields.values()){let r=e.read.type;if(r==="float"&&e.read.b?.format.filter===this.fx.gl.NEAREST&&i.warn(`umber.sim(): this GPU can't filter "float" targets, so texture() gives the nearest texel (smooth sampling turns blocky; texelFetch() is fine). Ask for type: "half" to sample smoothly.`),!(s||r===e.type)){if(r==="u8"){i.warn(`umber.sim(): this GPU can't render to "${e.type}" targets, so sims run in 8 bits: values clip to 0..1 and slow fades stop short of 0. Ask for type: "u8" to skip this message.`);break}(t.fields?.[e.name]?.type??t.type)&&i.warn(`umber.sim(): this GPU can't render to "${e.type}" targets, so this sim runs in "${r}": values round to about 3 digits (particle positions jitter). Ask for type: "${r}" to skip this message.`)}}return r}flow(t={}){let e=Math.min(.999,Math.max(0,t.fade??.92));if(this.ya===null)return this.Bg(t,e);let s=this.ya;if(!s)return null;t.fade!=null&&(s.uniforms.uFade=e);let i=this.$b;return i&&t.radius!=null&&(i.uniforms.uBrushRadius=Math.max(.5,t.radius)),i&&t.motion!=null&&(i.uniforms.uMotion=t.motion),t.size!=null&&t.size!==s.options.size&&(s.options.size=t.size,s.fit()),this.patch(()=>s.texture),s}Bg(t,e){let s=this.fx.stage.canvasHost.viewport.width,i=t.radius??s*.08,r=[{into:"push",next:b},{into:"flow",next:y}],a=this.make({size:t.size??[32,48,64,64,96,128],fields:{push:{},flow:{}},output:"flow",passes:r,uniforms:{uFade:e},settle:t=>t.idle*t.clock.hz>=h(t.uniforms.uFade)+2},r,{quiet:!0});return a.type==="u8"?(a.release(),this.ya=!1,this.Th(e,i/s),null):(this.ya=a,this.$b=a.brush({field:"push",radius:i,motion:t.motion??.04}),this.patch(()=>a.texture),a)}Th(t,e){let s=this.fx.stage.env.host.engine.touch?.({fade:t,radius:e});this.patch(()=>s?.texture),s?i.warn("uFlow: this GPU can't render to half-float targets, so the flowmap is the input module's umber.touch() texture (drawn on the CPU, 8-bit)."):i.warn("uFlow: this GPU can't render to half-float targets, which the flowmap needs. Add the input module (modules/input.js, or umber.use(Input)) and uFlow falls back to its umber.touch() texture; until then uFlow stays still.")}patch(t){let e=this.fx.stage;e.chunks.flow??={texture:null},Object.defineProperty(e.chunks.flow,"texture",{configurable:!0,get:()=>t()??e.gpu.renderer.blank.texture})}lost(){for(let t of this.list)for(let e of t.brushes)e.lost()}restored(){for(let t of this.list)t.compile()&&t.reset()}};function F(t){return r(t.stage.env.host.log),new M(t)}export{w as Brush,v as Sim,M as Sims,F as sims};
1
+ /*! Umber v0.4.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var t=()=>{};var e=()=>Promise.reject(new Error("no words"));var s={configure:t,debug:!1,warnings:!1,info:t,warn:t,error:t,report:t,words:e},i=s;function r(t){i=t}var h=class{constructor(t=60){this.hz=t;this.Fh=0;this.Xe=!1}advance(t){this.Fh+=t>0?t:0;let e=Math.floor(this.Fh*this.hz+.5);return e>4?(e=4,this.Fh=0):!e&&this.Xe?(e=1,this.Fh=0):this.Fh-=e/this.hz,this.Xe=!1,e}due(){this.Xe=!0,this.Fh=Math.min(this.Fh,0)}},o=1/255;function n(t){return t<=0?1:t>=1?1/0:Math.ceil(Math.log(o)/Math.log(t))}function a(t,e){return t===void 0||t===0||Number.isNaN(t)?e:t}function l(t,e,s){if(Array.isArray(t)){let i=t[Math.max(0,Math.min(t.length-1,e))];return a(i,s)}return t!=null&&t>0?t:s}var u=16,f=/^[A-Za-z_]\w*$/;function p(t){return Array.isArray(t.passes)?t.passes:typeof t.next=="string"?[{into:null,next:t.next}]:null}var m=(t,e)=>/\bvoid\s+main\s*\(/.test(t)?t:`${t}\nvoid main() { outColor = ${e}(vUv); }`;function d(t){for(let e of t.values())return e;throw new Error("umber.sim(): a sim has no fields")}function c(t,e){let s=t.get(e);if(!s)throw new Error(`umber.sim(): no field "${e}"`);return s}function g(t){let e=t.read;t.read=t.write,t.write=e}var v=class{constructor(t,e,s,i){this.sims=t;this.options=e;this.fields=new Map;this.df=[];this.passes=[];this.ni=[];this.brushes=[];this.steps=0;this.idle=0;this.awake=!1;this.released=!1;this.ok=!1;this.aspect=0;this.clock=new h(Math.max(1,a(e.hz,60))),this.uniforms={...e.uniforms,uDt:1/this.clock.hz,uStep:0,uPointer:new Float32Array([-1,-1])};let r=e.fields??{state:{init:e.init}};for(let[t,e]of Object.entries(r))this.sc(t,e,s);this.out=(e.output===void 0?void 0:this.fields.get(e.output))??d(this.fields);for(let t of i)this.passes.push({into:t.into===null?this.out:c(this.fields,t.into),source:m(t.next,"next"),iterations:Math.max(1,Math.round(l(t.iterations,s,1))),program:null});for(let t of this.fields.values())t.init&&this.ni.push({field:t,source:t.init,program:null});this.pointer=this.passes.some(t=>/\buPointer\b/.test(t.source)),this.own=!!this.ni.length||e.settle===!1||this.passes.some(t=>/\bu(Time|Step)\b/.test(t.source)),this.compile(),this.start()}sc(t,e,s){let i=e.type??this.options.type??"half",r={...this.Wd(e.size,s),type:i,msaa:0,attachments:1,quiet:!0},h=this.sims.fx,o={name:t,read:h.make(r),write:h.make(r),size:e.size,init:e.init,type:i,holder:{get texture(){return o.read.texture}}};this.fields.set(t,o),this.df.push(o.holder),this.uniforms[t]=o.holder}Wd(t,e){let s=this.sims.fx.stage,i=s.gpu.gl.getParameter(s.gpu.gl.MAX_TEXTURE_SIZE)??4096,r=Math.min(i,Math.max(1,Math.round(l(t??this.options.size,e,128))));this.aspect=s.canvasHost.viewport.height/Math.max(1,s.canvasHost.viewport.width);let h=this.options.shape==="square"?r:Math.min(i,Math.max(1,Math.round(r*this.aspect)));return{width:r,height:h}}compile(){let t=this.sims.fx.passes,e=!0;for(let s of this.passes)s.program=t.program(s.source,this.uniforms),s.program||(e=!1);for(let s of this.ni)s.program=t.program(m(s.source,"init"),this.uniforms),s.program||(e=!1);return this.ok=e,e||(this.awake=!1,this.sims.fx.stage.env.lib.say("simCompile",[])),e}start(){let t=this.sims.fx.stage;for(let t of this.fields.values())t.read.clear(),t.write.clear();for(let t of this.ni)t.program&&this.draw(t.program,t.field);t.gpu.gl.bindFramebuffer(t.gpu.gl.FRAMEBUFFER,null),t.gpu.renderer.reset(),this.steps=0,this.uniforms.uStep=0,this.own?this.wake():this.awake=!1}draw(t,e){let s=this.sims.fx.stage,i=e.write.b;i&&(s.gpu.gl.bindFramebuffer(s.gpu.gl.FRAMEBUFFER,i.draw),this.sims.fx.passes.draw(t,i.spec,this.uniforms),g(e))}run(t){let e=this.sims.fx.stage,s=e.canvasHost.viewport;this.options.shape!=="square"&&Math.abs(s.height/Math.max(1,s.width)-this.aspect)>.01&&this.fit();let i=this.clock.advance(t);for(let t=0;t<i;t++)this.step();if(i){e.gpu.gl.bindFramebuffer(e.gpu.gl.FRAMEBUFFER,null),e.gpu.renderer.reset();let t=this.options.settle;t!==!1&&(typeof t=="function"?t(this):this.idle>=(t??2)-1e-6)&&(this.awake=!1)}return i>0}step(){let t=this.uniforms,e=this.sims.fx.stage,s=e.env.frame.pointer;this.steps++,t.uStep=this.steps,this.idle+=1/this.clock.hz,t.uPointer[0]=s.x<0?-1:s.x/e.canvasHost.viewport.width,t.uPointer[1]=s.y<0?-1:s.y/e.canvasHost.viewport.height;for(let t of this.brushes)t.apply();for(let t of this.passes)if(t.program)for(let e=0;e<t.iterations;e++)this.draw(t.program,t.into)}fit(){let t=this.sims.level;for(let e of this.fields.values()){let{width:s,height:i}=this.Wd(e.size,t);e.read.resize(s,i),e.write.resize(s,i)}this.start()}get texture(){return this.released?null:this.out.read.texture}get width(){return this.out.read.width}get height(){return this.out.read.height}get type(){return this.out.read.type}field(t){let e=this.fields.get(t);return e||this.sims.fx.stage.env.lib.say("simField",[t,[...this.fields.keys()]]),e?e.holder:null}wake(){return this.released?this:(this.idle=0,(!this.awake||!this.steps)&&this.clock.due(),this.awake=this.ok,this.sims.fx.stage.scheduler.request(),this)}set(t,e){return this.uniforms[t]=e,this.wake()}reset(){return this.released||this.start(),this}brush(t){return this.released?null:new w(this,t??{})}seen(){if(this.Z)return!0;for(let t of this.df)if(t.Z)return!0;let t=this.sims.fx.stage,e=this.sims.sh===this?t.chunks.flow:null;if(e?.Z)return!0;let s=!1;for(let i of t.planes.all){let t=i.zone.soon||i.visible;if(i.layer&&t)return!0;if(this.sg(i.uniforms,e)){if(t)return!0;s=!0}}return!s}sg(t,e){for(let s in t){let i=t[s];if(!i)continue;let r=i.value;if(r===this||e!==null&&r===e||this.holds(r))return!0}return!1}holds(t){for(let e of this.df)if(e===t)return!0;return!1}release(){let t=this.sims;if(!this.released){if(t.sh===this){if(t.fx.stage.planes.all.some(t=>"uFlow"in t.uniforms))return;t.sh=null,t.Db=null}this.released=!0,this.awake=!1;for(let t of this.fields.values())t.read.release(),t.write.release();this.brushes.length=0,t.list.delete(this)}}},w=class{constructor(t,e){this.sim=t;this.options=e;this.stamps=new Float32Array(u*4);this.count=0;this.last=[NaN,NaN];this.released=!1;let s=e.field===void 0?void 0:t.fields.get(e.field),i=s??d(t.fields);e.field&&!s&&t.sims.fx.stage.env.lib.say("brushField",[e.field,i.name]),this.field=i;let r=t.sims.fx.stage.canvasHost.viewport,h=e.color??[1,1,1,1];this.uniforms={[i.name]:i.holder,uStamps:this.stamps,uCount:0,uBrushRadius:Math.max(.5,a(e.radius,24)),uColor:new Float32Array([a(h[0],0),a(h[1],0),a(h[2],0),h[3]??1]),uMotion:a(e.motion,0),uView:new Float32Array([r.width,r.height]),uMix:e.mode==="mix"?1:0},this.source=m(x.replace("FIELD",i.name),"next"),t.brushes.push(this)}paint(t,e,s=0,i=0){if(this.released||this.count>=u)return this;let r=this.sim.sims.fx.stage.canvasHost.viewport,h=this.stamps,o=this.count++*4;return h[o]=t/r.width,h[o+1]=e/r.height,h[o+2]=s,h[o+3]=i,this.sim.wake(),this}follow(t,e){let[s,i]=this.last;if(this.last[0]=t,this.last[1]=e,s!==s||t===s&&e===i)return;let r=t-s,h=e-i,o=Math.min(u-this.count,Math.max(1,Math.ceil(Math.hypot(r,h)/(this.uniforms.uBrushRadius*.5))));for(let t=1;t<=o;t++)this.paint(s+r*t/o,i+h*t/o,r/o,h/o)}apply(){let t=this.sim.sims.fx.stage,e=t.env.frame.pointer;if(this.options.pointer!==!1&&e.x>=0&&this.follow(e.x,e.y),!this.count)return;this.program===void 0&&(this.program=this.sim.sims.fx.passes.program(this.source,this.uniforms));let s=this.uniforms.uView;s[0]=t.canvasHost.viewport.width,s[1]=t.canvasHost.viewport.height,this.uniforms.uCount=this.count,this.count=0;let i=this.field,r=i.write.b;!this.program||!r||(t.gpu.gl.bindFramebuffer(t.gpu.gl.FRAMEBUFFER,r.draw),this.sim.sims.fx.passes.draw(this.program,r.spec,this.uniforms),g(i),this.sim.idle=0)}lost(){this.program=void 0}release(){this.released=!0;let t=this.sim.brushes,e=t.indexOf(this);e>=0&&t.splice(e,1)}},x=`uniform vec4 uStamps[16];\nvec4 next(vec2 uv){\nvec4 c=texture(FIELD,uv);\nfor(int i=0;i<16;i++){\nif(float(i)>=uCount)break;\nvec2 d=(uv-uStamps[i].xy)*uView;\nfloat k=exp(-dot(d,d)/(uBrushRadius*uBrushRadius));\nvec4 v=uColor+vec4(uStamps[i].zw*uMotion,0.0,0.0);\nc=uMix>0.5?mix(c,v,k*uColor.a):c+v*k;\n}\nreturn c;\n}`,b=`vec4 next(vec2 uv){\nvec2 v=texture(push,uv).xy;\nfloat l=length(v);\nreturn vec4(l<1.0/255.0?vec2(0.0):v/max(l,1.0)*uFade,0.0,1.0);\n}`,y=`vec4 next(vec2 uv){\nvec2 v=texture(push,uv).xy;\nfloat l=length(v);\nreturn vec4(l>0.0?v/l*0.5+0.5:vec2(0.5),1.0,min(l,1.0));\n}`,k=t=>t.options.pointer!==!1,F=class{constructor(t){this.fx=t;this.list=new Set;this.sh=null;this.Db=null;this.tick=t=>{let e=this.fx.stage;if(e.scheduler.inactive)return;let s=!1,i=!1;for(let e of this.list)if(e.awake){if(!e.seen()){for(let t of e.brushes)t.last[0]=NaN;continue}s=e.run(t.dt)||s,i||=e.awake}s?e.scheduler.markDirty():i&&e.scheduler.request()};let e=t.stage;e.gpu.subsystems.push(this),e.env.cleanups.push(e.env.host.ticker.add(this.tick,{phase:"render",order:-1}));let s=t=>{let s=t,i=t.type==="pointerdown";i&&(e.env.frame.pointer.x=s.clientX,e.env.frame.pointer.y=s.clientY);let r=i||t.type==="pointerout"&&!s.relatedTarget;for(let e of this.list)if(r)for(let t of e.brushes)t.last[0]=NaN;else t.type==="pointermove"&&(e.pointer||e.brushes.some(k))&&e.seen()&&e.wake()},i=["pointermove","pointerdown","pointerout"];for(let t of i)addEventListener(t,s,{passive:!0});e.env.cleanups.push(()=>{for(let t of i)removeEventListener(t,s);this.list.clear()})}get level(){return this.fx.stage.env.stats.gpu?.level??4}sim(t){let e=t?p(t):null;if(!t||!e)return this.fx.stage.env.lib.say("simNext",[]),null;let s=Object.keys(t.fields??{state:0});if(!s.length)return this.fx.stage.env.lib.say("simFields",[]),null;let i=s.find(t=>!f.test(t))??e.map(t=>t.into).find(t=>t!==null&&!s.includes(t));return i!=null?(this.fx.stage.env.lib.say("simName",[i,s]),null):this.make(t,e)}make(t,e,{quiet:s=!1}={}){let r=new v(this,t,this.level,e);this.list.add(r);for(let e of r.fields.values()){let r=e.read.type;if(r==="float"&&e.read.b?.format.filter===this.fx.gl.NEAREST&&i.warn(`umber.sim(): this GPU can't filter "float" targets, so texture() gives the nearest texel (smooth sampling turns blocky; texelFetch() is fine). Ask for type: "half" to sample smoothly.`),!(s||r===e.type)){if(r==="u8"){i.warn(`umber.sim(): this GPU can't render to "${e.type}" targets, so sims run in 8 bits: values clip to 0..1 and slow fades stop short of 0. Ask for type: "u8" to skip this message.`);break}(t.fields?.[e.name]?.type??t.type)&&i.warn(`umber.sim(): this GPU can't render to "${e.type}" targets, so this sim runs in "${r}": values round to about 3 digits (particle positions jitter). Ask for type: "${r}" to skip this message.`)}}return r}flow(t={}){let e=Math.min(.999,Math.max(0,t.fade??.92));if(this.sh===null)return this.He(t,e);let s=this.sh;if(!s)return null;t.fade!=null&&(s.uniforms.uFade=e);let i=this.Db;return i&&t.radius!=null&&(i.uniforms.uBrushRadius=Math.max(.5,t.radius)),i&&t.motion!=null&&(i.uniforms.uMotion=t.motion),t.size!=null&&t.size!==s.options.size&&(s.options.size=t.size,s.fit()),this.patch(()=>s.texture),s}He(t,e){let s=this.fx.stage.canvasHost.viewport.width,i=t.radius??s*.08,r=[{into:"push",next:b},{into:"flow",next:y}],h=this.make({size:t.size??[32,48,64,64,96,128],fields:{push:{},flow:{}},output:"flow",passes:r,uniforms:{uFade:e},settle:t=>t.idle*t.clock.hz>=n(t.uniforms.uFade)+2},r,{quiet:!0});return h.type==="u8"?(h.release(),this.sh=!1,this._b(e,i/s),null):(this.sh=h,this.Db=h.brush({field:"push",radius:i,motion:t.motion??.04}),this.patch(()=>h.texture),h)}_b(t,e){let s=this.fx.stage.env.host.engine.touch?.({fade:t,radius:e});this.patch(()=>s?.texture),s?i.warn("uFlow: this GPU can't render to half-float targets, so the flowmap is the input module's umber.touch() texture (drawn on the CPU, 8-bit)."):i.warn("uFlow: this GPU can't render to half-float targets, which the flowmap needs. Add the input module (modules/input.js, or umber.use(Input)) and uFlow falls back to its umber.touch() texture; until then uFlow stays still.")}patch(t){let e=this.fx.stage;e.chunks.flow??={texture:null},Object.defineProperty(e.chunks.flow,"texture",{configurable:!0,get:()=>t()??e.gpu.renderer.blank.texture})}lost(){for(let t of this.list)for(let e of t.brushes)e.lost()}restored(){for(let t of this.list)t.compile()&&t.reset()}};function M(t){return r(t.stage.env.host.log),new F(t)}export{w as Brush,v as Sim,F as Sims,M as sims};