@abgin/abgin 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -2
  3. package/dist/THIRD-PARTY-NOTICES.txt +27 -0
  4. package/dist/abgin.js +3 -0
  5. package/dist/abgin.js.map +1 -0
  6. package/dist/chunks/appbar-LLcnVLph.js +3 -0
  7. package/dist/chunks/appbar-LLcnVLph.js.map +1 -0
  8. package/dist/chunks/behavior-PpBNSUmo.js +3 -0
  9. package/dist/chunks/behavior-PpBNSUmo.js.map +1 -0
  10. package/dist/chunks/dialog-wNqzWPiS.js +3 -0
  11. package/dist/chunks/dialog-wNqzWPiS.js.map +1 -0
  12. package/dist/chunks/direction-BDKiHYas.js +3 -0
  13. package/dist/chunks/direction-BDKiHYas.js.map +1 -0
  14. package/dist/chunks/drawer-ZmlA-nWk.js +3 -0
  15. package/dist/chunks/drawer-ZmlA-nWk.js.map +1 -0
  16. package/dist/chunks/dropdown-BAvgXY5r.js +3 -0
  17. package/dist/chunks/dropdown-BAvgXY5r.js.map +1 -0
  18. package/dist/chunks/engine-CLGg6TrP.js +3 -0
  19. package/dist/chunks/engine-CLGg6TrP.js.map +1 -0
  20. package/dist/chunks/focus-BezZcM_N.js +3 -0
  21. package/dist/chunks/focus-BezZcM_N.js.map +1 -0
  22. package/dist/chunks/glass-CrY_zpD7.js +3 -0
  23. package/dist/chunks/glass-CrY_zpD7.js.map +1 -0
  24. package/dist/chunks/modal-COcRYmWk.js +3 -0
  25. package/dist/chunks/modal-COcRYmWk.js.map +1 -0
  26. package/dist/chunks/motion-scene-BDU70ceZ.js +3 -0
  27. package/dist/chunks/motion-scene-BDU70ceZ.js.map +1 -0
  28. package/dist/chunks/optics-Dfs-jab-.js +3 -0
  29. package/dist/chunks/optics-Dfs-jab-.js.map +1 -0
  30. package/dist/chunks/overlay-C7vi0Jzf.js +3 -0
  31. package/dist/chunks/overlay-C7vi0Jzf.js.map +1 -0
  32. package/dist/chunks/popover-CEIndATO.js +3 -0
  33. package/dist/chunks/popover-CEIndATO.js.map +1 -0
  34. package/dist/chunks/position-Bf9Bk3ZK.js +3 -0
  35. package/dist/chunks/position-Bf9Bk3ZK.js.map +1 -0
  36. package/dist/chunks/sheet-C6pSKe8a.js +3 -0
  37. package/dist/chunks/sheet-C6pSKe8a.js.map +1 -0
  38. package/dist/chunks/sidebar-CF_I9jqC.js +3 -0
  39. package/dist/chunks/sidebar-CF_I9jqC.js.map +1 -0
  40. package/dist/chunks/tabbar-CRHZitw_.js +3 -0
  41. package/dist/chunks/tabbar-CRHZitw_.js.map +1 -0
  42. package/dist/chunks/tabs-1jFkGW6D.js +3 -0
  43. package/dist/chunks/tabs-1jFkGW6D.js.map +1 -0
  44. package/dist/chunks/toast-Cazk1MoR.js +3 -0
  45. package/dist/chunks/toast-Cazk1MoR.js.map +1 -0
  46. package/dist/chunks/toolbar-DJnAyNIW.js +3 -0
  47. package/dist/chunks/toolbar-DJnAyNIW.js.map +1 -0
  48. package/dist/chunks/tooltip-D-ySWdJM.js +3 -0
  49. package/dist/chunks/tooltip-D-ySWdJM.js.map +1 -0
  50. package/dist/chunks/webgl-backend-aGPldzh7.js +294 -0
  51. package/dist/chunks/webgl-backend-aGPldzh7.js.map +1 -0
  52. package/dist/css/abgin.css +2 -0
  53. package/dist/css/background.css +2 -0
  54. package/dist/css/base.css +2 -0
  55. package/dist/css/components/accordion.css +2 -0
  56. package/dist/css/components/alert.css +2 -0
  57. package/dist/css/components/appbar.css +2 -0
  58. package/dist/css/components/badge.css +2 -0
  59. package/dist/css/components/breadcrumbs.css +2 -0
  60. package/dist/css/components/button.css +2 -0
  61. package/dist/css/components/card.css +2 -0
  62. package/dist/css/components/checkbox.css +2 -0
  63. package/dist/css/components/code.css +2 -0
  64. package/dist/css/components/divider.css +2 -0
  65. package/dist/css/components/drawer.css +2 -0
  66. package/dist/css/components/dropdown.css +2 -0
  67. package/dist/css/components/field.css +2 -0
  68. package/dist/css/components/icon.css +2 -0
  69. package/dist/css/components/input.css +2 -0
  70. package/dist/css/components/join.css +2 -0
  71. package/dist/css/components/kbd.css +2 -0
  72. package/dist/css/components/link.css +2 -0
  73. package/dist/css/components/list.css +2 -0
  74. package/dist/css/components/menu.css +2 -0
  75. package/dist/css/components/modal.css +2 -0
  76. package/dist/css/components/navbar.css +2 -0
  77. package/dist/css/components/pagination.css +2 -0
  78. package/dist/css/components/popover.css +2 -0
  79. package/dist/css/components/progress.css +2 -0
  80. package/dist/css/components/radio.css +2 -0
  81. package/dist/css/components/range.css +2 -0
  82. package/dist/css/components/search.css +2 -0
  83. package/dist/css/components/segmented.css +2 -0
  84. package/dist/css/components/select.css +2 -0
  85. package/dist/css/components/sheet.css +2 -0
  86. package/dist/css/components/shell.css +2 -0
  87. package/dist/css/components/sidebar.css +2 -0
  88. package/dist/css/components/spinner.css +2 -0
  89. package/dist/css/components/tabbar.css +2 -0
  90. package/dist/css/components/table.css +2 -0
  91. package/dist/css/components/tabs.css +2 -0
  92. package/dist/css/components/textarea.css +2 -0
  93. package/dist/css/components/toast.css +2 -0
  94. package/dist/css/components/toggle.css +2 -0
  95. package/dist/css/components/toolbar.css +2 -0
  96. package/dist/css/components/tooltip.css +2 -0
  97. package/dist/css/glass/appbar.css +2 -0
  98. package/dist/css/glass/base.css +2 -0
  99. package/dist/css/glass/button.css +2 -0
  100. package/dist/css/glass/card.css +2 -0
  101. package/dist/css/glass/checkbox.css +2 -0
  102. package/dist/css/glass/drawer.css +2 -0
  103. package/dist/css/glass/dropdown.css +2 -0
  104. package/dist/css/glass/join.css +2 -0
  105. package/dist/css/glass/modal.css +2 -0
  106. package/dist/css/glass/navbar.css +2 -0
  107. package/dist/css/glass/popover.css +2 -0
  108. package/dist/css/glass/radio.css +2 -0
  109. package/dist/css/glass/range.css +2 -0
  110. package/dist/css/glass/search.css +2 -0
  111. package/dist/css/glass/segmented.css +2 -0
  112. package/dist/css/glass/sheet.css +2 -0
  113. package/dist/css/glass/sidebar.css +2 -0
  114. package/dist/css/glass/tabbar.css +2 -0
  115. package/dist/css/glass/tabs.css +2 -0
  116. package/dist/css/glass/toast.css +2 -0
  117. package/dist/css/glass/toggle.css +2 -0
  118. package/dist/css/glass/toolbar.css +2 -0
  119. package/dist/css/glass/tooltip.css +2 -0
  120. package/dist/css/glass/vivid.css +2 -0
  121. package/dist/css/glass.css +2 -0
  122. package/dist/css/layers.css +2 -0
  123. package/dist/css/prose.css +2 -0
  124. package/dist/css/standard.css +2 -0
  125. package/dist/css/themes/dark.css +2 -0
  126. package/dist/css/themes/light.css +2 -0
  127. package/dist/css/tokens.css +2 -0
  128. package/dist/css/utilities.css +2 -0
  129. package/dist/index.d.ts +67 -0
  130. package/dist/manifest.json +1195 -0
  131. package/package.json +69 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-CLGg6TrP.js","names":["REPLACED","resolve","createScope","readPrefix","isDisposedError","LifecycleDisposedError","MEDIA","MOTION_ATTRIBUTE","isElement","parentOf","prefixSelector","LAYER_ATTRIBUTE","isLayer","FITS_ATTRIBUTE","SHARED_ATTRIBUTE","__exportAll","HOSTLESS","containsFlat","names","parseToken","resolveQuality","deformShape","interpolateShape","SHAPE_KINDS","shapeField","DEFAULT_OPTICS","readCorners","mergeConstants","readOpticsTokens","boxShape","defaultRequest","callback","raf","defaultCancel","handle","caf","createFrameScheduler","options","request","cancel","tasks","disposed","run","time","due","errors","task","error","EMPTY_RECT","toRect","r","intersect","a","b","x","y","right","bottom","containsRect","outer","inner","tolerance","NUMBER","TERM","HORIZONTAL","VERTICAL","components","value","parts","depth","current","ch","offset","token","calc","percent","px","i","sign","term","n","parseObjectPosition","first","second","swapped","xs","ys","keyword","table","finite","values","v","isUsableRect","objectFitRect","content","naturalWidth","naturalHeight","fit","objectPosition","position","width","height","ratio","boxRatio","at","o","free","drawn","regionInSource","surface","sx","sy","region","isAxisAligned","m","scrollRelation","source","SCROLLING","ROOT_ANCHOR","FIXED_ANCHOR","STICKY_ANCHOR","anchorOf","element","memo","insideAnchor","node","known","style","anchor","UNIT_SCALE","UNSUPPORTED_SCALE","parseScale","part","z","ownScale","c","d","scale","zoom","scaleOf","parent","result","own","scaleAgrees","rect","layoutWidth","layoutHeight","PAINT_ONLY","KEYFRAME_KEYS","movesGeometry","property","name","SELF_ONLY","movesOthers","animationMoves","animation","moves","effect","frame","ownGeometryAnimation","keyframesMove","animations","animationMovesOthers","animatesGeometry","contentBox","left","top","toViewport","local","drawnImage","box","IMAGE_ATTRIBUTES","VIDEO_ATTRIBUTES","SOURCE_CHILD_ATTRIBUTES","MAX_OPACITY_PIXELS","pictureImage","picture","child","colorAlpha","css","slash","legacy","kindOf","img","staticRaster","url","src","createSourceRegistry","doc","events","resize","prefix","records","byMedia","opacity","sourceAttribute","nextId","invalidations","probe","isBackgroundMedia","backgroundPictureOf","imageIsCurrent","record","forgetOpacity","sizeTarget","track","target","previous","originClean","media","context","bitmapOpacity","bitmap","data","checkOpacity","check","attempt","view","late","cancelFrames","settleState","state","reason","cause","invalidateRecord","ready","acquireImage","reject","timer","selected","acquire","acquireVideo","video","acquireCanvas","canvas","acquireUniform","finish","wire","scope","type","arm","rebind","next","collapsePictureImage","videoDeclarationChanged","release","duplicate","refreshImage","registry","existing","kind","id","el","owner","lookupPicture","released","wanted","count","sourceInfo","backgroundSceneOf","REPLACED$1","outlineWidth","clipped","legacyClip","composited","rounded","radius","generatedPaint","pseudo","image","boxPaint","shadowExtent","extent","shadow","blur","spread","length","expand","topLayer","fallback","sourceId","createBackgroundCache","cache","viewport","scenes","owners","sceneMedia","paints","bounds","sceneComposition","sceneClass","mediaClass","contentClass","viewportClass","range","sceneOf","scene","mediaOwner","wrapper","mediaIn","readScene","elements","pending","paint","textRects","rects","readBounds","unknown","outline","extra","clipBox","padding","geometrySupported","containment","clipMargin","clipsOverflow","clip","imageElement","visible","scroller","composition","sceneStyle","imageStyle","orientation","surfacePath","inside","s","point","sources","geometry","overlaps","foreground","evidence","LEVELS","GOVERNOR","createGovernor","available","index","changes","raiseAt","cooldown","raisedAt","last","opened","frames","slow","behind","overloaded","restart","step","direction","elapsed","budget","heavy","combine","points","p","declared","GRID","MISSED","REPLACED","createSampleCache","styles","scales","anchors","queries","modal","background","readMedia","k","readPaint","query","hasText","color","alpha","samplePoint","root","stack","SAMPLES","REUSE_PASSES","sampledIn","pass","row","reusable","from","to","half","classify","reuse","backgroundPoint","py","sample","place","taken","over","complete","now","before","checked","overSource","_","found","claimSurface","layer","createLayer","group","suspendLayer","resumeLayer","placeLayer","borderLeft","borderTop","dpr","pad","placeLayerAt","origin","ensureAttached","removed","removeLayer","SPRING_LIMITS","springFromResponse","response","dampingRatio","w","DEFAULT_SPRING","clampSpring","base","pick","key","lo","hi","stiffness","mass","critical","advance","dt","w0","zeta","e","wd","cos","sin","r1","r2","c2","c1","e1","e2","createSpring","restDelta","restSpeed","parameters","velocity","settled","rest","resting","MOTION_TOKENS","MOTION_OFF","parseDrag","readMotion","read","spec","T","AT_REST","createLazyMotionScene","host","failed","loading","load","module","surfaces","g","targets","distance","pressed","ENGINE_ATTRIBUTES","ROLES","EMPTY_SHAPE","MEDIA_ATTRIBUTES","quietTransition","createController","hooks","N","manifest","entry","surfaceSelector","sourceSelector","glassSelector","grace","descriptor","aboveLite","quality","resolveOptions","groups","explicitRoles","roots","nextSurfaceId","stopped","paused","lastDemand","counters","backend","backendState","backendError","backendAttempt","releaseTimer","restoreUsed","governor","level","raiseTimer","consecutive","scheduler","h","schedule","passTime","updatingMotion","checks","checkWindow","checkTimer","watching","entries","staleSurface","invalidateWithin","sized","sizeObserver","releaseLayer","renderSource","intersection","engineStyle","noteEngineStyle","noteLayerStyle","suspendGroup","share","on","groupFor","releaseGroupLayer","changed","affected","invalidateAll","invalidateBackgroundPaint","authoredMutation","related","STYLESHEETS","hasStylesheet","attributeNames","configAttributes","onMutations","relevant","stylesheets","layout","presentation","authored","coversSurface","checkLayout","overflows","slack","hasMoved","boxes","differs","unblocked","comparePlaces","hide","moved","watchLayout","overlapped","reclassifyUnder","listenTransitions","observeRoot","observer","discoverSources","discoverRegions","roleOf","explicit","evaluateCandidate","unregisterSurface","role","glass","discoverWithin","container","discoverAdded","registerSource","disposeBackend","seen","prepared","prepareShapes","instance","motionWanted","ensureBackend","signal","factory","scheduleRelease","layerDemand","progressOf","updateShape","requestPass","settling","resolutionOf","sampleFrame","cpu","chained","levelChanged","armRaise","measure","beforeFill","beforeMaterial","wasDrawn","followed","groupElement","morphKind","ownsMaterial","config","filter","measureBox","readMorph","progress","shown","material","materialKey","moving","corners","restShape","classification","blocker","mediaRect","mediaScale","remeasure","lengthScale","words","rtl","axis","word","inline","morphedShape","t","side","fw","fh","radii","shape","decide","cls","overflowOf","backendSurface","pw","ph","sh","shapeInputs","backendSource","pointerIn","cx","cy","hw","hh","backendGroup","pointed","shapes","dx","dy","draw","list","groupList","batch","drawnGroups","item","started","planGroups","plans","candidates","bySource","same","best","smoothness","compare","grouped","members","demandLayers","resumed","render","decision","overflow","renderGroups","inUse","reach","x0","y0","x1","y1","ksx","ksy","demand","markAll","viewportChanged","scrollTimer","scrollSettled","onScroll","event","onTransition","starts","onLoad","onBackgroundState","onLayoutState","resolution","watchResolution","info","layered","dirty","work","engine_exports","createEngine","startGlass","KEY","documentOf","running","controller","owned","created","engine"],"sources":["../../../core/dist/scheduler.js","../../../glass/dist/geometry.js","../../../glass/dist/sources.js","../../../glass/dist/background.js","../../../glass/dist/governor.js","../../../glass/dist/classify.js","../../../glass/dist/layers.js","../../../glass/dist/spring.js","../../../glass/dist/motion-config.js","../../../glass/dist/motion-loader.js","../../../glass/dist/controller.js","../../../glass/dist/engine.js"],"sourcesContent":["// Frame scheduler (ARCHITECTURE.md section 2): runs tasks in the next animation frame and requests a frame\n// only while a task is pending, so an idle page does no work (D-05, D-21). Nothing runs at import time.\nfunction defaultRequest(callback) {\n const raf = globalThis.requestAnimationFrame;\n if (typeof raf === \"function\")\n return raf.call(globalThis, callback);\n return setTimeout(() => {\n callback(performance.now());\n }, 16);\n}\nfunction defaultCancel(handle) {\n const caf = globalThis.cancelAnimationFrame;\n if (typeof caf === \"function\" && typeof handle === \"number\")\n caf.call(globalThis, handle);\n else\n clearTimeout(handle);\n}\nexport function createFrameScheduler(options = {}) {\n const request = options.request ?? defaultRequest;\n const cancel = options.cancel ?? defaultCancel;\n let tasks = new Set();\n let handle = null;\n let disposed = false;\n const run = (time) => {\n handle = null;\n const due = tasks;\n tasks = new Set(); // tasks scheduled while running go to the next frame\n const errors = [];\n for (const task of due) {\n try {\n task(time);\n }\n catch (error) {\n if (options.onError)\n options.onError(error);\n else\n errors.push(error);\n }\n }\n if (errors.length === 1)\n throw errors[0];\n if (errors.length > 1)\n throw new AggregateError(errors, \"Frame tasks failed.\");\n };\n return {\n schedule(task) {\n if (disposed)\n return false;\n tasks.add(task);\n handle ??= request(run);\n return true;\n },\n cancel(task) {\n tasks.delete(task);\n if (tasks.size === 0 && handle !== null) {\n cancel(handle);\n handle = null;\n }\n },\n get pending() {\n return tasks.size;\n },\n get requested() {\n return handle !== null;\n },\n get disposed() {\n return disposed;\n },\n dispose() {\n if (disposed)\n return;\n disposed = true;\n tasks.clear();\n if (handle !== null)\n cancel(handle);\n handle = null;\n },\n };\n}\n//# sourceMappingURL=scheduler.js.map","// Scene geometry (RENDERING_STRATEGY.md sections 4 and 9). Everything is in physical viewport CSS pixels as the\n// DOM reports them, so RTL and LTR need no separate code: a mirrored layout produces mirrored rectangles.\n// The pure functions are unit-tested in Node; the DOM readers run only when the engine measures.\nimport { parentOf } from \"./dom.js\";\nexport const EMPTY_RECT = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });\nexport function toRect(r) {\n return { x: r.left, y: r.top, width: r.width, height: r.height };\n}\nexport function intersect(a, b) {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n const right = Math.min(a.x + a.width, b.x + b.width);\n const bottom = Math.min(a.y + a.height, b.y + b.height);\n return right > x && bottom > y ? { x, y, width: right - x, height: bottom - y } : EMPTY_RECT;\n}\n/** `inner` lies inside `outer`, allowing sub-pixel rounding. */\nexport function containsRect(outer, inner, tolerance = 0.5) {\n return (inner.x >= outer.x - tolerance &&\n inner.y >= outer.y - tolerance &&\n inner.x + inner.width <= outer.x + outer.width + tolerance &&\n inner.y + inner.height <= outer.y + outer.height + tolerance);\n}\nconst NUMBER = String.raw `[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`;\nconst TERM = new RegExp(`^(${NUMBER})(%|px)$`, \"i\");\nconst HORIZONTAL = { left: 0, center: 50, right: 100 };\nconst VERTICAL = { top: 0, center: 50, bottom: 100 };\n/** Splits at whitespace outside parentheses; null when parentheses do not balance. */\nfunction components(value) {\n const parts = [];\n let depth = 0;\n let current = \"\";\n for (const ch of value.trim()) {\n if (ch === \"(\")\n depth++;\n else if (ch === \")\" && --depth < 0)\n return null;\n if (depth === 0 && /\\s/.test(ch)) {\n if (current)\n parts.push(current);\n current = \"\";\n }\n else\n current += ch;\n }\n if (depth !== 0)\n return null;\n if (current)\n parts.push(current);\n return parts;\n}\n/** A length-percentage: `N%`, `Npx`, `0`, or `calc()` of a sum of such terms. Anything else is null. */\nfunction offset(token) {\n const calc = /^calc\\((.*)\\)$/i.exec(token);\n // Inside calc(), CSS requires whitespace around + and -, so terms and operators alternate.\n const parts = calc ? (calc[1] ?? \"\").trim().split(/\\s+/) : [token];\n if (parts.length % 2 === 0)\n return null;\n let percent = 0;\n let px = 0;\n for (let i = 0; i < parts.length; i += 2) {\n const sign = i === 0 || parts[i - 1] === \"+\" ? 1 : parts[i - 1] === \"-\" ? -1 : 0;\n const term = parts[i] === \"0\" ? [\"0\", \"0\", \"px\"] : TERM.exec(parts[i] ?? \"\");\n if (!sign || !term)\n return null;\n const n = sign * Number.parseFloat(term[1] ?? \"\");\n if (term[2] === \"%\")\n percent += n;\n else\n px += n;\n }\n // `+ 0` turns -0 into 0.\n return Number.isFinite(percent) && Number.isFinite(px) ? { percent: percent + 0, px: px + 0 } : null;\n}\n/**\n * Parses a computed `object-position`. Browsers serialize it as two offsets, horizontal then vertical, with\n * keywords and the four-value syntax resolved: `right 10px top 5px` becomes `calc(100% - 10px) 5px`. Accepted\n * offsets are percentages, pixels, and `calc()` sums of them; one- and two-keyword forms are accepted too.\n * Returns null for anything else (for example `min()` inside `calc()`), so callers can fall back instead of\n * producing wrong or non-finite geometry. The value is physical: `left` and `right` do not depend on direction.\n */\nexport function parseObjectPosition(value) {\n const parts = components(value.toLowerCase());\n if (!parts || parts.length < 1 || parts.length > 2)\n return null;\n const [first = \"\", second = \"center\"] = parts;\n // Keyword pairs may come in either order (\"top right\"); a vertical keyword first means swapped axes.\n const swapped = (first in VERTICAL && !(first in HORIZONTAL)) || (second in HORIZONTAL && !(second in VERTICAL));\n const [xs, ys] = swapped ? [second, first] : [first, second];\n const keyword = (token, table) => token in table ? { percent: table[token] ?? 50, px: 0 } : null;\n if (swapped && (!(xs in HORIZONTAL) || !(ys in VERTICAL)))\n return null;\n const x = xs in HORIZONTAL ? keyword(xs, HORIZONTAL) : xs in VERTICAL ? null : offset(xs);\n const y = ys in VERTICAL ? keyword(ys, VERTICAL) : ys in HORIZONTAL ? null : offset(ys);\n return x && y ? { x, y } : null;\n}\nconst finite = (...values) => values.every((v) => Number.isFinite(v));\n/** True when every coordinate is finite and the size is positive. */\nexport function isUsableRect(r) {\n return finite(r.x, r.y, r.width, r.height) && r.width > 0 && r.height > 0;\n}\n/**\n * Where the media's intrinsic image is drawn, given the content box, the intrinsic size, and computed\n * `object-fit` and `object-position`. Null when the inputs are not finite and positive or the position is not\n * supported (see `parseObjectPosition`): callers keep the CSS material then.\n */\nexport function objectFitRect(content, naturalWidth, naturalHeight, fit, objectPosition = \"50% 50%\") {\n if (!isUsableRect(content) || !finite(naturalWidth, naturalHeight) || naturalWidth <= 0 || naturalHeight <= 0)\n return null;\n const position = parseObjectPosition(objectPosition);\n if (!position)\n return null;\n let width = content.width;\n let height = content.height;\n const ratio = naturalWidth / naturalHeight;\n const boxRatio = content.width / content.height;\n if (fit === \"contain\" || fit === \"cover\") {\n const wide = fit === \"contain\" ? ratio > boxRatio : ratio < boxRatio;\n if (wide)\n height = content.width / ratio;\n else\n width = content.height * ratio;\n }\n else if (fit === \"none\" || fit === \"scale-down\") {\n width = naturalWidth;\n height = naturalHeight;\n if (fit === \"scale-down\" && (naturalWidth > content.width || naturalHeight > content.height)) {\n if (ratio > boxRatio) {\n width = content.width;\n height = content.width / ratio;\n }\n else {\n height = content.height;\n width = content.height * ratio;\n }\n }\n }\n const at = (o, free) => (free * o.percent) / 100 + o.px;\n const drawn = {\n x: content.x + at(position.x, content.width - width),\n y: content.y + at(position.y, content.height - height),\n width,\n height,\n };\n return isUsableRect(drawn) ? drawn : null;\n}\n/**\n * The part of the source's intrinsic image behind `surface`, in source pixels. Null unless every value is finite\n * and the size is positive, so a backend never receives NaN or Infinity.\n */\nexport function regionInSource(surface, drawn, naturalWidth, naturalHeight) {\n if (!isUsableRect(surface) || !isUsableRect(drawn))\n return null;\n const sx = naturalWidth / drawn.width;\n const sy = naturalHeight / drawn.height;\n const region = {\n x: (surface.x - drawn.x) * sx,\n y: (surface.y - drawn.y) * sy,\n width: surface.width * sx,\n height: surface.height * sy,\n };\n return isUsableRect(region) ? region : null;\n}\n/** A 2D affine matrix (CSS `matrix(a, b, c, d, e, f)`) is a scale plus a translation. */\nexport function isAxisAligned(m) {\n return m.is2D && Math.abs(m.b) < 1e-6 && Math.abs(m.c) < 1e-6 && m.a > 0 && m.d > 0;\n}\n/** D-54: GPU layers only where surface and source cannot move relative to each other. */\nexport function scrollRelation(surface, source) {\n if (surface.kind === \"sticky\" || source.kind === \"sticky\")\n return \"independent\";\n if (surface.kind === \"container\" && source.kind === \"container\")\n return surface.container === source.container ? \"together\" : \"independent\";\n return surface.kind === source.kind ? \"together\" : \"independent\";\n}\n// DOM readers (engine only).\nexport const SCROLLING = /^(auto|scroll|hidden|overlay)$/;\nconst ROOT_ANCHOR = Object.freeze({ kind: \"root\" });\nconst FIXED_ANCHOR = Object.freeze({ kind: \"fixed\" });\nconst STICKY_ANCHOR = Object.freeze({ kind: \"sticky\" });\n/** The nearest thing that moves the element when something scrolls. `memo` caches the ancestors' part for one pass. */\nexport function anchorOf(element, memo) {\n const { position } = getComputedStyle(element);\n if (position === \"fixed\")\n return FIXED_ANCHOR;\n if (position === \"sticky\")\n return STICKY_ANCHOR;\n return insideAnchor(parentOf(element), memo);\n}\n/** The anchor of the content of `node`. */\nfunction insideAnchor(node, memo) {\n if (!node)\n return ROOT_ANCHOR;\n const known = memo.get(node);\n if (known)\n return known;\n const style = getComputedStyle(node);\n let anchor;\n if (style.position === \"fixed\")\n anchor = FIXED_ANCHOR;\n else if (style.position === \"sticky\")\n anchor = STICKY_ANCHOR;\n else if (node !== node.ownerDocument.documentElement &&\n node !== node.ownerDocument.body &&\n (SCROLLING.test(style.overflowX) || SCROLLING.test(style.overflowY)))\n anchor = { kind: \"container\", container: node };\n else\n anchor = insideAnchor(parentOf(node), memo);\n memo.set(node, anchor);\n return anchor;\n}\nexport const UNIT_SCALE = Object.freeze({ x: 1, y: 1, ok: true });\nconst UNSUPPORTED_SCALE = Object.freeze({ x: 1, y: 1, ok: false });\n/** Factors of a computed individual `scale` (`none`, `1.5`, `1.5 2`); null for 3D or unknown values. */\nexport function parseScale(value) {\n const v = value.trim();\n if (!v || v === \"none\")\n return [1, 1];\n const parts = v.split(/\\s+/).map((part) => Number(part.endsWith(\"%\") ? Number.parseFloat(part) / 100 : part));\n if (parts.length > 3 || parts.some((n) => !Number.isFinite(n)))\n return null;\n const [x = 1, y = x, z = 1] = parts;\n return z === 1 ? [x, y] : null;\n}\n/** The scale one element's own computed style adds; null when it is not a positive scale with a translation. */\nexport function ownScale(style) {\n if (style.rotate && style.rotate !== \"none\")\n return null;\n if (style.offsetPath && style.offsetPath !== \"none\")\n return null;\n let x = 1;\n let y = 1;\n if (style.transform && style.transform !== \"none\") {\n const m = /^matrix\\(([^)]+)\\)$/.exec(style.transform)?.[1]?.split(\",\").map(Number) ?? [];\n const [a = Number.NaN, b = Number.NaN, c = Number.NaN, d = Number.NaN] = m;\n // A computed `matrix3d()` is never matched.\n if (!isAxisAligned({ is2D: m.length === 6, a, b, c, d }))\n return null;\n x = a;\n y = d;\n }\n const scale = parseScale(style.scale ?? \"\");\n const zoom = style.zoom ? Number.parseFloat(style.zoom) : 1;\n const z = Number.isFinite(zoom) && zoom > 0 ? zoom * (style.zoom?.endsWith(\"%\") ? 0.01 : 1) : 1;\n if (!scale || !(scale[0] > 0) || !(scale[1] > 0))\n return null;\n return [x * scale[0] * z, y * scale[1] * z];\n}\n/** The scale of an element, with its ancestors in the flat tree. `memo` caches results for one pass. */\nexport function scaleOf(element, memo) {\n if (!element)\n return UNIT_SCALE;\n const known = memo.get(element);\n if (known)\n return known;\n const parent = scaleOf(parentOf(element), memo);\n let result = parent;\n if (parent.ok) {\n const own = ownScale(getComputedStyle(element));\n result =\n own === null\n ? UNSUPPORTED_SCALE\n : own[0] === 1 && own[1] === 1\n ? parent\n : { x: parent.x * own[0], y: parent.y * own[1], ok: true };\n }\n memo.set(element, result);\n return result;\n}\n/**\n * Whether a measured box agrees with the scale computed from styles. Layout sizes (`offsetWidth`) are rounded to whole\n * pixels. A mismatch means something else transforms the element (for example an engine with a different `zoom`), so\n * the box cannot be used.\n */\nexport function scaleAgrees(rect, layoutWidth, layoutHeight, scale) {\n return (Math.abs(rect.width - layoutWidth * scale.x) <= 0.5 * scale.x + 0.75 &&\n Math.abs(rect.height - layoutHeight * scale.y) <= 0.5 * scale.y + 0.75);\n}\n// Animated properties that repaint an element without moving or resizing anything (normalized: no hyphens, lower\n// case). Keyframe metadata keys are ignored as well.\nconst PAINT_ONLY = new Set([\n \"opacity\",\n \"color\",\n \"backgroundcolor\",\n \"bordercolor\",\n \"bordertopcolor\",\n \"borderrightcolor\",\n \"borderbottomcolor\",\n \"borderleftcolor\",\n \"outlinecolor\",\n \"textdecorationcolor\",\n \"caretcolor\",\n \"accentcolor\",\n \"boxshadow\",\n \"textshadow\",\n \"fill\",\n \"stroke\",\n]);\nconst KEYFRAME_KEYS = new Set([\"offset\", \"easing\", \"composite\", \"computedoffset\"]);\nexport const STATE_COLOR_MIX = \"--ab-private-state-mix\";\n/** Whether animating this CSS property (any spelling) can move or resize content. */\nexport function movesGeometry(property) {\n if (property === STATE_COLOR_MIX)\n return false;\n const name = property.replace(/-/g, \"\").toLowerCase();\n return !PAINT_ONLY.has(name) && !KEYFRAME_KEYS.has(name);\n}\n/** Properties that move or resize only the element itself (and its content), never other elements. */\nconst SELF_ONLY = /^(transform|transformorigin|translate|rotate|scale|perspective|perspectiveorigin|offset.*|filter|backdropfilter|clippath|zindex|cursor|visibility|willchange|mask.*|.*color|background.*|textdecoration.*|outline.*|borderradius|border.*radius|cornershape|accentcolor|opacity)$/;\n/** Whether animating this CSS property (any spelling) can move elements other than the animated one (D-81). */\nexport function movesOthers(property) {\n return movesGeometry(property) && !SELF_ONLY.test(property.replace(/-/g, \"\").toLowerCase());\n}\nfunction animationMoves(animation, moves) {\n if (animation.playState !== \"running\")\n return false;\n if (\"transitionProperty\" in animation)\n return moves(animation.transitionProperty);\n const effect = animation.effect;\n // An effect whose properties cannot be read counts as moving: the CSS material is the safe choice.\n if (typeof effect?.getKeyframes !== \"function\")\n return true;\n return effect.getKeyframes().some((frame) => Object.keys(frame).some(moves));\n}\nfunction ownGeometryAnimation(element) {\n return element.getAnimations().some((animation) => animationMoves(animation, movesGeometry));\n}\n/** Whether one of an element's own animations is a CSS animation or Web Animation that moves or resizes it. */\nexport function keyframesMove(animations) {\n return animations.some((a) => !(\"transitionProperty\" in a) && animationMoves(a, movesGeometry));\n}\n/** Whether a running animation or transition of the element can move other elements. */\nexport function animationMovesOthers(element) {\n return element.getAnimations().some((animation) => animationMoves(animation, movesOthers));\n}\n/**\n * True if a running CSS transition, CSS animation, or Web Animation of `element` or of an ancestor (flat tree) can\n * move or resize it. Measured geometry would be outdated within a frame, so such surfaces keep the CSS material.\n * `memo` caches results per element for one pass.\n */\nexport function animatesGeometry(element, memo) {\n if (!element)\n return false;\n const known = memo.get(element);\n if (known !== undefined)\n return known;\n const result = ownGeometryAnimation(element) || animatesGeometry(parentOf(element), memo);\n memo.set(element, result);\n return result;\n}\n/** The content box of an element in its own CSS pixels, relative to its border box (`r`, in viewport px). */\nexport function contentBox(r, style, scale) {\n const px = (v) => Number.parseFloat(v) || 0;\n const left = px(style.borderLeftWidth) + px(style.paddingLeft);\n const top = px(style.borderTopWidth) + px(style.paddingTop);\n const right = px(style.borderRightWidth) + px(style.paddingRight);\n const bottom = px(style.borderBottomWidth) + px(style.paddingBottom);\n return {\n x: left,\n y: top,\n width: Math.max(0, r.width / scale.x - left - right),\n height: Math.max(0, r.height / scale.y - top - bottom),\n };\n}\n/** A rectangle in an element's own CSS pixels (relative to its border box `r`) in viewport CSS pixels. */\nexport function toViewport(local, r, scale) {\n return {\n x: r.x + local.x * scale.x,\n y: r.y + local.y * scale.y,\n width: local.width * scale.x,\n height: local.height * scale.y,\n };\n}\n/**\n * The image of a media element on screen; `rect` is its border box in viewport px. `object-fit` and `object-position` are resolved in the element's own CSS\n * pixels (intrinsic sizes and offsets are lengths there) and then scaled. Null when the geometry is not supported.\n */\nexport function drawnImage(rect, style, naturalWidth, naturalHeight, scale) {\n const box = contentBox(rect, style, scale);\n const drawn = objectFitRect(box, naturalWidth, naturalHeight, style.objectFit, style.objectPosition);\n if (!drawn)\n return null;\n return {\n drawn: toViewport(drawn, rect, scale),\n visible: toViewport(intersect(drawn, box), rect, scale),\n };\n}\n//# sourceMappingURL=geometry.js.map","// Declared backdrop sources (RENDERING_STRATEGY.md section 4, D-63, D-64, D-72). A source has a stable identity\n// (the registered element) and a content version that increases whenever its pixels change or become invalid. Every\n// acquisition attempt runs in its own child scope: a new change disposes the previous attempt, so a late `load`,\n// `decode()`, or `loadeddata` can never revive content that was already invalidated.\n//\n// The media element can change while the identity stays: when the `<img>` of a declared `<picture>` is replaced,\n// removed, or inserted, the record is rebound. Listeners on the previous element live in a binding scope that is\n// disposed at once, and the size observation follows the new element. The registry owns that observation: every\n// path that releases a record (removal, undeclaring, explicit unregistration, disposal) stops observing it.\nimport { createScope, isDisposedError } from \"@abgin/core/lifecycle\";\nconst IMAGE_ATTRIBUTES = new Set([\"src\", \"srcset\", \"sizes\", \"crossorigin\", \"referrerpolicy\"]);\nconst VIDEO_ATTRIBUTES = new Set([\"src\", \"crossorigin\"]);\nconst SOURCE_CHILD_ATTRIBUTES = new Set([\"src\", \"srcset\", \"sizes\", \"media\", \"type\"]);\nconst MAX_OPACITY_PIXELS = 4_194_304;\n/** `HTMLMediaElement.HAVE_CURRENT_DATA`: a frame is available. */\nconst HAVE_CURRENT_DATA = 2;\n/** The `<img>` child of a `<picture>`, the only image the picture's sources apply to. */\nfunction pictureImage(picture) {\n for (const child of picture.children)\n if (child.localName === \"img\")\n return child;\n return null;\n}\n/** Alpha of a computed CSS color; 1 when the format has no alpha component. */\nexport function colorAlpha(css) {\n const value = css.trim();\n if (value === \"transparent\")\n return 0;\n const slash = /\\/\\s*([\\d.]+)(%?)\\s*\\)$/.exec(value);\n if (slash)\n return Number.parseFloat(slash[1] ?? \"1\") / (slash[2] ? 100 : 1);\n const legacy = /^rgba?\\(([^)]*)\\)$/.exec(value);\n if (legacy) {\n const parts = (legacy[1] ?? \"\").split(\",\");\n if (parts.length === 4)\n return Number.parseFloat(parts[3] ?? \"1\");\n }\n return 1;\n}\nfunction kindOf(element) {\n switch (element.localName) {\n case \"img\":\n return { kind: \"image\", media: element };\n case \"picture\": {\n const img = pictureImage(element);\n return img ? { kind: \"image\", media: img } : { kind: \"unsupported\", media: null };\n }\n case \"video\":\n return { kind: \"video\", media: element };\n case \"canvas\":\n return { kind: \"canvas\", media: element };\n default:\n return { kind: \"uniform\", media: null };\n }\n}\n/** The author supplies a static raster image. Vector and known animated formats have no stable texel grid. */\nfunction staticRaster(url) {\n if (url.startsWith(\"data:\"))\n return /^data:image\\/(?:png|jpeg|bmp)[;,]/i.test(url);\n const src = new URL(url);\n return (src.protocol === \"https:\" || src.protocol === \"http:\") && /\\.(?:png|jpe?g|bmp)$/i.test(src.pathname);\n}\nexport function createSourceRegistry(doc, events, resize, prefix = \"\") {\n const records = new Map();\n const byMedia = new Map();\n const opacity = new Map();\n const sourceAttribute = `data-${prefix}backdrop-source`;\n let nextId = 1;\n let invalidations = 0;\n let probe = null;\n function isBackgroundMedia(element) {\n return (element.classList.contains(`${prefix}background-media`) &&\n element.parentElement?.classList.contains(`${prefix}background`) === true);\n }\n function backgroundPictureOf(element) {\n const picture = element.parentElement;\n return element.localName === \"img\" && picture?.localName === \"picture\" && isBackgroundMedia(picture)\n ? picture\n : null;\n }\n function imageIsCurrent(record) {\n const img = record.media;\n return (record.kind === \"image\" &&\n record.state === \"ready\" &&\n !!img?.isConnected &&\n img.complete &&\n img.currentSrc === record.url &&\n img.naturalWidth === record.width &&\n img.naturalHeight === record.height &&\n (record.element.localName !== \"picture\" || pictureImage(record.element) === img));\n }\n function forgetOpacity(record) {\n opacity.get(record)?.attempt?.dispose();\n opacity.delete(record);\n }\n /** The element to observe for a record: its media, or the declared element itself (not an empty picture). */\n const sizeTarget = (record) => record.media ?? (record.element.localName === \"picture\" ? null : record.element);\n /** Moves the record's size observation to `target` (null stops it). Each record observes at most one element. */\n function track(record, target) {\n const previous = record.observed;\n if (previous === target)\n return;\n record.observed = target;\n if (previous)\n resize?.unobserve(previous);\n if (target)\n resize?.observe(target);\n }\n /**\n * Origin-clean check: draws the source into a private 1 x 1 canvas and reads that pixel back. The browser\n * throws a SecurityError for a cross-origin source without CORS approval or a tainted canvas, so no\n * cross-origin pixel is ever read. A redirect to another origin is caught too, which a URL check would miss.\n */\n function originClean(media) {\n probe ??= Object.assign(doc.createElement(\"canvas\"), { width: 1, height: 1 });\n const context = probe.getContext(\"2d\", { willReadFrequently: true });\n if (!context)\n return false;\n try {\n context.clearRect(0, 0, 1, 1);\n context.drawImage(media, 0, 0, 1, 1);\n context.getImageData(0, 0, 1, 1);\n return true;\n }\n catch {\n // The failed draw tainted the probe canvas itself; a tainted canvas stays tainted, so replace it.\n probe.width = 0;\n probe = null;\n return false;\n }\n }\n /** Inspect actual bitmap texels. naturalWidth and naturalHeight can be density-corrected for srcset. */\n function bitmapOpacity(bitmap) {\n const { width, height } = bitmap;\n if (!width || !height || width * height > MAX_OPACITY_PIXELS)\n return \"unverified\";\n probe ??= doc.createElement(\"canvas\");\n probe.width = width;\n probe.height = height;\n try {\n const context = probe.getContext(\"2d\", { willReadFrequently: true });\n if (!context)\n return \"unverified\";\n context.drawImage(bitmap, 0, 0);\n const { data } = context.getImageData(0, 0, width, height);\n for (let i = 3; i < data.length; i += 4)\n if (data[i] !== 255)\n return \"transparent\";\n return \"opaque\";\n }\n finally {\n probe.width = 1;\n probe.height = 1;\n }\n }\n async function checkOpacity(record, check, attempt, view) {\n const img = record.media;\n let bitmap;\n let result = \"unverified\";\n try {\n bitmap = await attempt.settle(view.createImageBitmap(img), {\n discard(late) {\n late.close();\n },\n });\n if (!attempt.disposed && imageIsCurrent(record))\n result = bitmapOpacity(bitmap);\n }\n catch {\n // If pixels cannot be verified, the CSS material keeps the image's native composition.\n }\n finally {\n bitmap?.close();\n attempt.dispose();\n check.attempt = null;\n check.result = result;\n if (opacity.get(record) === check && imageIsCurrent(record))\n events.changed(record, \"image-opacity\");\n }\n }\n function cancelFrames(record) {\n if (record.frameHandle !== null && record.media?.localName === \"video\") {\n record.media.cancelVideoFrameCallback(record.frameHandle);\n }\n record.frameHandle = null;\n }\n function settleState(record, state, reason, cause) {\n if (record.state === \"disposed\")\n return;\n record.state = state;\n record.reason = reason;\n record.version++;\n events.changed(record, cause);\n }\n /** Content is no longer valid: drop it at once, before any further frame can use it. */\n function invalidateRecord(record, cause) {\n if (record.state === \"disposed\")\n return;\n invalidations++;\n forgetOpacity(record);\n record.attempt?.dispose();\n record.attempt = null;\n cancelFrames(record);\n settleState(record, \"pending\", cause, cause);\n }\n function ready(record, width, height, url) {\n record.width = width;\n record.height = height;\n record.url = url;\n settleState(record, \"ready\", \"ready\", \"ready\");\n }\n async function acquireImage(record, img, attempt) {\n if (!img.getAttribute(\"src\") && !img.getAttribute(\"srcset\") && !img.closest(\"picture\")?.querySelector(\"source\")) {\n settleState(record, \"error\", \"no-source\", \"no-source\");\n return;\n }\n try {\n // A src, srcset, or <source> change is applied by the element later (\"update the image data\"; Chromium\n // reselects a <picture> source after more than one task), and decoding earlier would resolve with the\n // previous image. Unless a different image is already complete, wait for the element's own load or error;\n // a change that starts no new load (the same URL set again) is accepted after a short timeout. The CSS\n // material shows meanwhile, so nothing stale is ever drawn.\n const previous = record.url;\n await attempt.settle(new Promise((resolve, reject) => {\n attempt.listen(attempt.signal, \"abort\", () => {\n reject(new Error(\"aborted\"));\n });\n setTimeout(resolve, 0);\n }));\n if (!img.complete || (previous && img.currentSrc === previous)) {\n await attempt.settle(new Promise((resolve, reject) => {\n const timer = setTimeout(resolve, img.complete ? 1000 : 30_000);\n attempt.onDispose(() => {\n clearTimeout(timer);\n });\n attempt.listen(img, \"load\", () => {\n resolve();\n });\n attempt.listen(img, \"error\", () => {\n reject(new Error(\"load-failed\"));\n });\n attempt.listen(attempt.signal, \"abort\", () => {\n reject(new Error(\"aborted\"));\n });\n }));\n }\n const selected = img.currentSrc;\n await attempt.settle(img.decode());\n if (!attempt.disposed && record.media === img && img.currentSrc !== selected) {\n acquire(record);\n return;\n }\n }\n catch (error) {\n if (isDisposedError(error) || attempt.disposed || record.media !== img)\n return;\n settleState(record, \"error\", \"decode-failed\", \"error\");\n return;\n }\n // A rebinding disposes this attempt; the check keeps a replaced image from ever being accepted.\n if (attempt.disposed || record.media !== img)\n return;\n if (!img.complete || img.naturalWidth === 0) {\n settleState(record, \"error\", \"not-decoded\", \"error\");\n return;\n }\n if (!originClean(img)) {\n settleState(record, \"ineligible\", \"cross-origin\", \"ineligible\");\n return;\n }\n ready(record, img.naturalWidth, img.naturalHeight, img.currentSrc);\n }\n async function acquireVideo(record, video, attempt) {\n // 2 is HAVE_CURRENT_DATA: a frame is available.\n if (video.readyState < 2) {\n try {\n await attempt.settle(new Promise((resolve, reject) => {\n attempt.listen(video, \"loadeddata\", () => {\n resolve();\n });\n attempt.listen(video, \"error\", () => {\n reject(new Error(\"media-error\"));\n });\n }));\n }\n catch (error) {\n if (isDisposedError(error) || attempt.disposed)\n return;\n settleState(record, \"error\", \"media-error\", \"error\");\n return;\n }\n }\n if (attempt.disposed)\n return;\n if (video.videoWidth === 0 || video.videoHeight === 0) {\n settleState(record, \"error\", \"no-video-frames\", \"error\");\n return;\n }\n if (!originClean(video)) {\n settleState(record, \"ineligible\", \"cross-origin\", \"ineligible\");\n return;\n }\n ready(record, video.videoWidth, video.videoHeight, video.currentSrc);\n }\n function acquireCanvas(record, canvas) {\n if (canvas.width === 0 || canvas.height === 0) {\n settleState(record, \"pending\", \"empty-canvas\", \"pending\");\n return;\n }\n if (!originClean(canvas)) {\n settleState(record, \"ineligible\", \"tainted-canvas\", \"ineligible\");\n return;\n }\n ready(record, canvas.width, canvas.height, \"\");\n }\n function acquireUniform(record) {\n const style = getComputedStyle(record.element);\n if (style.backgroundImage !== \"none\" || colorAlpha(style.backgroundColor) < 1) {\n // Gradients, images, and translucent colors need rasterization and are ineligible for the uniform path.\n record.kind = \"unsupported\";\n settleState(record, \"ineligible\", \"not-uniform\", \"ineligible\");\n return;\n }\n record.kind = \"uniform\";\n record.color = style.backgroundColor;\n ready(record, 0, 0, \"\");\n }\n /** Starts a new attempt; any previous one is disposed first. */\n function acquire(record) {\n if (record.state === \"disposed\")\n return;\n record.attempt?.dispose();\n const attempt = record.scope.child();\n record.attempt = attempt;\n const finish = () => {\n if (record.attempt === attempt) {\n record.attempt = null;\n attempt.dispose();\n }\n };\n const media = record.media;\n if (record.kind === \"image\" && media)\n void acquireImage(record, media, attempt).finally(finish);\n else if (record.kind === \"video\" && media)\n void acquireVideo(record, media, attempt).finally(finish);\n else {\n if (record.kind === \"canvas\" && media)\n acquireCanvas(record, media);\n else if (record.element.localName === \"picture\")\n settleState(record, \"ineligible\", \"picture-without-image\", \"ineligible\");\n else if (!media)\n acquireUniform(record);\n finish();\n }\n }\n /** Listens to the current media element in a fresh binding scope, so a rebinding can drop them all at once. */\n function wire(record) {\n const media = record.media;\n if (!media)\n return;\n const scope = record.scope.child();\n record.binding = scope;\n if (record.kind === \"image\") {\n // A load event means new pixels (a new src, a picture re-selection, or a reload).\n scope.listen(media, \"load\", () => {\n if (record.attempt)\n return;\n invalidateRecord(record, \"load\");\n acquire(record);\n });\n scope.listen(media, \"error\", () => {\n invalidateRecord(record, \"error\");\n settleState(record, \"error\", \"load-failed\", \"error\");\n });\n }\n else if (record.kind === \"video\") {\n for (const type of [\"emptied\", \"loadstart\"]) {\n scope.listen(media, type, () => {\n invalidateRecord(record, type);\n acquire(record);\n });\n }\n scope.listen(media, \"error\", () => {\n invalidateRecord(record, \"error\");\n settleState(record, \"error\", \"media-error\", \"error\");\n });\n scope.listen(media, \"resize\", () => {\n if (record.state === \"ready\")\n ready(record, media.videoWidth, media.videoHeight, record.url);\n });\n // A seek changes the shown frame even while paused.\n scope.listen(media, \"seeked\", () => {\n if (record.state !== \"ready\")\n return;\n record.version++;\n events.frame(record);\n });\n scope.listen(media, \"pause\", () => {\n cancelFrames(record);\n });\n scope.listen(media, \"play\", () => {\n if (record.framesWanted)\n arm(record);\n });\n }\n else if (record.kind === \"canvas\") {\n for (const type of [\"contextlost\", \"contextrestored\"]) {\n scope.listen(media, type, () => {\n invalidateRecord(record, type);\n acquire(record);\n });\n }\n }\n }\n function arm(record) {\n const video = record.media;\n if (record.frameHandle !== null || video.paused || video.ended || record.state !== \"ready\")\n return;\n if (typeof video.requestVideoFrameCallback !== \"function\")\n return;\n record.frameHandle = video.requestVideoFrameCallback(() => {\n record.frameHandle = null;\n if (record.state !== \"ready\" || !record.framesWanted)\n return;\n record.version++;\n events.frame(record);\n arm(record);\n });\n }\n /**\n * A declared `<picture>` whose `<img>` child was replaced, removed, or inserted keeps its record (identity and\n * id) with new media. The previous image is invalid at once: its acquisition attempt and listeners are disposed,\n * it leaves the lookup map, and its size is no longer observed. Returns false when the media did not change.\n */\n function rebind(record) {\n const next = pictureImage(record.element);\n const previous = record.media;\n if (next === previous)\n return false;\n invalidateRecord(record, next ? \"picture-image-replaced\" : \"picture-image-removed\");\n record.binding?.dispose();\n record.binding = null;\n if (previous && byMedia.get(previous) === record)\n byMedia.delete(previous);\n record.media = next;\n record.kind = next ? \"image\" : \"unsupported\";\n if (next)\n byMedia.set(next, record);\n collapsePictureImage(record);\n track(record, sizeTarget(record));\n wire(record);\n acquire(record);\n return true;\n }\n /**\n * A `<source>` child of a declared video changed. In the HTML media model this changes the declaration only: the\n * element keeps playing its selected media until it reloads (`load()`), which fires `emptied` and `loadstart`\n * (handled in `wire`). The pixels are still current, so the record keeps its version. If the element was already\n * reset in this task (a `load()` call next to the change), the content is invalid now, before any frame.\n */\n function videoDeclarationChanged(record, cause) {\n if (record.state !== \"ready\")\n return;\n if (record.media.readyState < HAVE_CURRENT_DATA) {\n invalidateRecord(record, cause);\n acquire(record);\n }\n else\n record.reason = \"source-declaration-changed\";\n }\n function release(record, cause) {\n if (record.state === \"disposed\")\n return;\n invalidations++;\n cancelFrames(record);\n forgetOpacity(record);\n records.delete(record.element);\n if (record.media && byMedia.get(record.media) === record)\n byMedia.delete(record.media);\n record.attempt = null;\n record.binding = null;\n record.state = \"disposed\";\n record.reason = cause;\n record.version++;\n try {\n track(record, null);\n }\n finally {\n try {\n record.scope.dispose();\n }\n finally {\n events.changed(record, cause);\n }\n }\n }\n /** Keep one identity when a Background picture and its image both carry the declaration. */\n function collapsePictureImage(record) {\n const media = record.media;\n if (!media || backgroundPictureOf(media) !== record.element)\n return;\n const duplicate = records.get(media);\n if (duplicate)\n release(duplicate, \"picture-source-preferred\");\n byMedia.set(media, record);\n }\n function refreshImage(record) {\n if (record.state !== \"ready\" || imageIsCurrent(record))\n return false;\n invalidateRecord(record, \"image-selection\");\n acquire(record);\n return true;\n }\n const registry = {\n register(element) {\n const picture = backgroundPictureOf(element);\n if (picture?.hasAttribute(sourceAttribute))\n return registry.register(picture);\n const existing = records.get(element);\n if (existing)\n return existing;\n const { kind, media } = kindOf(element);\n const record = {\n id: nextId++,\n element,\n media,\n kind,\n state: \"pending\",\n version: 0,\n reason: \"registered\",\n width: 0,\n height: 0,\n url: \"\",\n color: \"\",\n framesWanted: false,\n scope: createScope(),\n binding: null,\n observed: null,\n attempt: null,\n frameHandle: null,\n };\n records.set(element, record);\n if (media)\n byMedia.set(media, record);\n collapsePictureImage(record);\n track(record, sizeTarget(record));\n wire(record);\n acquire(record);\n return record;\n },\n unregister(element, cause) {\n const record = records.get(element);\n if (record)\n release(record, cause);\n },\n get: (element) => records.get(element),\n lookup: (element) => records.get(element) ?? byMedia.get(element),\n byId(id) {\n for (const record of records.values())\n if (record.id === id)\n return record;\n return undefined;\n },\n all: () => [...records.values()],\n isBackgroundImage(record) {\n const el = record.element;\n return (((el.localName === \"img\" || el.localName === \"picture\") && isBackgroundMedia(el)) ||\n backgroundPictureOf(el) !== null);\n },\n imageIsCurrent,\n imageOpacity(record) {\n if (!imageIsCurrent(record))\n return \"unverified\";\n const existing = opacity.get(record);\n if (existing)\n return existing.result;\n const view = doc.defaultView;\n const canCheck = typeof view?.createImageBitmap === \"function\" &&\n record.width * record.height <= MAX_OPACITY_PIXELS &&\n staticRaster(record.url);\n const attempt = canCheck ? record.scope.child() : null;\n const check = { attempt, result: attempt ? \"pending\" : \"unverified\" };\n opacity.set(record, check);\n if (attempt && view)\n void checkOpacity(record, check, attempt, view);\n return check.result;\n },\n refreshImages() {\n for (const record of opacity.keys())\n refreshImage(record);\n },\n attributeChanged(target, name) {\n const record = records.get(target) ?? byMedia.get(target);\n if (record) {\n const relevant = record.kind === \"image\"\n ? IMAGE_ATTRIBUTES.has(name)\n : record.kind === \"video\"\n ? VIDEO_ATTRIBUTES.has(name)\n : record.kind === \"canvas\"\n ? name === \"width\" || name === \"height\"\n : false;\n // `style` and `class` are presentation, not content: the controller re-measures the dependent surfaces and\n // calls presentationChanged(), which re-reads a uniform color without a version change when it is the same.\n if (!relevant)\n return;\n invalidateRecord(record, `attribute:${name}`);\n // A video attempt waits for the media element's own loadeddata after the reload the change started.\n acquire(record);\n return;\n }\n if (target.localName === \"source\" && SOURCE_CHILD_ATTRIBUTES.has(name) && target.parentElement) {\n const parent = target.parentElement;\n const owner = records.get(parent) ?? (parent.localName === \"picture\" ? lookupPicture(parent) : undefined);\n // A picture reselects its image when a <source> changes; a video does not (see videoDeclarationChanged).\n if (owner?.kind === \"image\") {\n invalidateRecord(owner, `source:${name}`);\n acquire(owner);\n }\n else if (owner?.kind === \"video\")\n videoDeclarationChanged(owner, `source:${name}`);\n }\n },\n childrenChanged(target) {\n if (target.localName === \"picture\") {\n const owner = lookupPicture(target);\n if (!owner)\n return;\n // The <img> itself changed: rebind. Otherwise <source> children changed and the image reselects.\n if (owner.element === target && rebind(owner))\n return;\n if (owner.kind === \"image\") {\n invalidateRecord(owner, \"picture-children\");\n acquire(owner);\n }\n return;\n }\n const record = records.get(target);\n if (record?.kind === \"video\")\n videoDeclarationChanged(record, \"video-children\");\n },\n presentationChanged(record) {\n collapsePictureImage(record);\n if (opacity.has(record))\n return refreshImage(record);\n if (record.state === \"disposed\" || record.media || record.element.localName === \"picture\")\n return false;\n const style = getComputedStyle(record.element);\n const uniform = style.backgroundImage === \"none\" && colorAlpha(style.backgroundColor) >= 1;\n const same = uniform\n ? record.kind === \"uniform\" && record.state === \"ready\" && record.color === style.backgroundColor\n : record.kind === \"unsupported\" && record.state === \"ineligible\";\n if (same)\n return false;\n invalidateRecord(record, \"presentation\");\n acquire(record);\n return true;\n },\n invalidate(element, cause) {\n const record = records.get(element) ?? byMedia.get(element);\n if (!record || record.state === \"disposed\")\n return false;\n if (record.kind === \"canvas\" && record.state === \"ready\") {\n // Canvas drawing replaces pixels in place: same validity, new version, no fallback flash.\n invalidations++;\n const canvas = record.media;\n if (canvas.width !== record.width || canvas.height !== record.height) {\n invalidateRecord(record, cause);\n acquire(record);\n return true;\n }\n // Drawing a cross-origin image without CORS approval taints a canvas for good: check before every use.\n if (!originClean(canvas)) {\n invalidateRecord(record, cause);\n settleState(record, \"ineligible\", \"tainted-canvas\", \"ineligible\");\n return true;\n }\n record.version++;\n events.frame(record);\n return true;\n }\n invalidateRecord(record, cause);\n acquire(record);\n return true;\n },\n checkConnected() {\n let released = 0;\n for (const record of [...records.values()]) {\n if (!record.element.isConnected) {\n release(record, \"removed\");\n released++;\n }\n }\n return released;\n },\n setFramesWanted(record, wanted) {\n if (record.kind !== \"video\")\n return;\n record.framesWanted = wanted;\n if (wanted)\n arm(record);\n else\n cancelFrames(record);\n },\n get invalidations() {\n return invalidations;\n },\n get resources() {\n let count = probe ? 1 : 0;\n for (const record of records.values()) {\n if (record.attempt)\n count++;\n if (opacity.get(record)?.attempt)\n count++;\n if (record.frameHandle !== null)\n count++;\n }\n return count;\n },\n dispose() {\n const errors = [];\n for (const record of [...records.values()]) {\n try {\n release(record, \"stopped\");\n }\n catch (error) {\n errors.push(error);\n }\n }\n if (probe) {\n probe.width = 0;\n probe.height = 0;\n probe = null;\n }\n if (errors.length)\n throw new AggregateError(errors, \"One or more backdrop sources failed to release.\");\n },\n };\n function lookupPicture(picture) {\n const record = records.get(picture);\n if (record)\n return record;\n const img = pictureImage(picture);\n return img ? records.get(img) : undefined;\n }\n return registry;\n}\nexport function sourceInfo(record) {\n return {\n id: record.id,\n element: record.element,\n kind: record.kind,\n state: record.state,\n version: record.version,\n reason: record.reason,\n width: record.width,\n height: record.height,\n url: record.url,\n };\n}\n//# sourceMappingURL=sources.js.map","// Background paint that is absent from hit testing. The scene's stacking context is the paint boundary.\nimport { containsFlat, isLayer, parentOf } from \"./dom.js\";\nimport { containsRect, intersect, isUsableRect, scrollRelation, toRect, } from \"./geometry.js\";\nimport { colorAlpha } from \"./sources.js\";\n/** The nearest scene owns the backdrop even if that scene has no declared media. */\nexport function backgroundSceneOf(element, prefix) {\n for (let current = element; current; current = parentOf(current)) {\n if (current.classList.contains(`${prefix}background`))\n return current;\n }\n return null;\n}\nconst REPLACED = new Set([\n \"img\",\n \"video\",\n \"canvas\",\n \"svg\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"input\",\n \"textarea\",\n \"select\",\n \"audio\",\n \"meter\",\n \"progress\",\n \"math\",\n \"hr\",\n]);\n// Bound the extra paint proof to the local scene. Large or opaque component trees keep their CSS material.\nconst SCENE_ELEMENT_LIMIT = 192;\nfunction effect(value) {\n return value !== \"\" && value !== \"none\";\n}\nfunction outlineWidth(style) {\n return style.outlineStyle === \"none\" ? 0 : Number.parseFloat(style.outlineWidth) || 0;\n}\nfunction clipped(style) {\n const legacyClip = style.getPropertyValue(\"clip\");\n return (effect(style.clipPath) ||\n effect(style.getPropertyValue(\"mask-image\")) ||\n effect(style.getPropertyValue(\"-webkit-mask-image\")) ||\n (legacyClip !== \"\" && legacyClip !== \"auto\"));\n}\nfunction composited(style) {\n return (style.opacity !== \"1\" ||\n style.mixBlendMode !== \"normal\" ||\n effect(style.filter) ||\n effect(style.getPropertyValue(\"backdrop-filter\")) ||\n effect(style.perspective));\n}\nfunction rounded(style) {\n return [\n style.borderTopLeftRadius,\n style.borderTopRightRadius,\n style.borderBottomRightRadius,\n style.borderBottomLeftRadius,\n ].some((radius) => radius.split(\" \").some((value) => Number.parseFloat(value) !== 0));\n}\nfunction generatedPaint(element, pseudo) {\n const style = getComputedStyle(element, pseudo);\n // Firefox exposes an alternative-text placeholder even when the decoded image supplies the paint.\n const image = element;\n if (style.content === \"-moz-alt-content\" && element.localName === \"img\" && image.complete && image.naturalWidth > 0)\n return false;\n return (style.content !== \"\" &&\n style.content !== \"none\" &&\n style.content !== \"normal\" &&\n style.display !== \"none\" &&\n style.visibility === \"visible\" &&\n style.opacity !== \"0\" &&\n (style.content !== '\"\"' ||\n boxPaint(style) ||\n outlineWidth(style) > 0 ||\n effect(style.boxShadow) ||\n composited(style) ||\n clipped(style)));\n}\nfunction boxPaint(style) {\n return (colorAlpha(style.backgroundColor) > 0 ||\n effect(style.backgroundImage) ||\n effect(style.borderImageSource) ||\n [style.borderTopWidth, style.borderRightWidth, style.borderBottomWidth, style.borderLeftWidth].some((width) => Number.parseFloat(width) > 0) ||\n effect(style.getPropertyValue(\"backdrop-filter\")));\n}\n/** Conservative exterior expansion for CSS box/text shadows; inset shadows stay in the box. */\nfunction shadowExtent(value) {\n let extent = 0;\n for (const shadow of value.split(/,(?![^()]*\\))/)) {\n if (/\\binset\\b/.test(shadow))\n continue;\n const [x = 0, y = 0, blur = 0, spread = 0] = [...shadow.matchAll(/(-?[\\d.]+)px/g)].map((length) => Number(length[1]));\n extent = Math.max(extent, Math.abs(x) + Math.abs(y) + 2 * blur + Math.abs(spread));\n }\n return extent;\n}\nfunction expand(rect, extent) {\n return { x: rect.x - extent, y: rect.y - extent, width: rect.width + 2 * extent, height: rect.height + 2 * extent };\n}\nfunction topLayer(element) {\n return (element.ownerDocument.fullscreenElement === element ||\n element.matches(\":modal\") ||\n (CSS.supports(\"selector(:popover-open)\") && element.matches(\":popover-open\")));\n}\nfunction fallback(reason, sourceId) {\n return { kind: \"unknown\", reason, ...(sourceId === undefined ? {} : { sourceId }) };\n}\nexport function createBackgroundCache(prefix, cache, media, viewport) {\n const scenes = new Map();\n const owners = new Map();\n const sceneMedia = new Map();\n const paints = new Map();\n const bounds = new Map();\n const sceneComposition = new Map();\n const sceneClass = `${prefix}background`;\n const mediaClass = `${prefix}background-media`;\n const contentClass = `${prefix}background-content`;\n const viewportClass = `${prefix}background-viewport`;\n let range = null;\n function sceneOf(element) {\n const known = scenes.get(element);\n if (known !== undefined)\n return known;\n const parent = parentOf(element);\n const scene = element.classList.contains(sceneClass) ? element : parent && sceneOf(parent);\n scenes.set(element, scene);\n return scene;\n }\n function mediaOwner(element) {\n const known = owners.get(element);\n if (known !== undefined)\n return known;\n const wrapper = element.localName === \"img\" && element.parentElement?.localName === \"picture\" ? element.parentElement : element;\n const scene = wrapper.parentElement;\n const owner = wrapper.classList.contains(mediaClass) && scene?.classList.contains(sceneClass) ? scene : null;\n owners.set(element, owner);\n return owner;\n }\n function mediaIn(scene) {\n let own = sceneMedia.get(scene);\n if (!own) {\n own = [...scene.children].filter((child) => child.classList.contains(mediaClass));\n sceneMedia.set(scene, own);\n }\n return own;\n }\n function readScene(scene) {\n const known = paints.get(scene);\n if (known)\n return known;\n const elements = [];\n const pending = [...scene.children].filter((child) => !child.classList.contains(mediaClass) && !isLayer(child));\n while (pending.length && pending.length + elements.length <= SCENE_ELEMENT_LIMIT) {\n const element = pending.pop();\n if (!element)\n break;\n if (cache.style(element).display === \"none\")\n continue;\n elements.push(element);\n if (pending.length + elements.length + element.childElementCount > SCENE_ELEMENT_LIMIT) {\n pending.push(element);\n break;\n }\n for (const child of element.children)\n if (!isLayer(child))\n pending.push(child);\n }\n const paint = { elements: pending.length ? null : elements };\n paints.set(scene, paint);\n return paint;\n }\n function textRects(element, style) {\n const rects = [];\n for (const node of element.childNodes) {\n if (node.nodeType !== Node.TEXT_NODE || !/\\S/.test(node.nodeValue ?? \"\"))\n continue;\n range ??= element.ownerDocument.createRange();\n range.selectNodeContents(node);\n const { x, y } = cache.scale(element);\n const extent = Math.max(x, y) * shadowExtent(style.textShadow);\n for (const rect of range.getClientRects())\n rects.push(expand(toRect(rect), extent));\n }\n return rects;\n }\n function readBounds(element) {\n const known = bounds.get(element);\n if (known)\n return known;\n const style = cache.style(element);\n const rects = [];\n let unknown = element.getAnimations().some((animation) => animation.pending || animation.playState === \"running\");\n if (!unknown && style.visibility === \"visible\" && style.opacity !== \"0\") {\n // Their children or generated paint can escape their measured boxes.\n unknown =\n element.childNodes.length > SCENE_ELEMENT_LIMIT ||\n element.localName.includes(\"-\") ||\n element.localName === \"slot\" ||\n Boolean(element.shadowRoot) ||\n style.display === \"list-item\" ||\n effect(style.filter) ||\n effect(style.perspective) ||\n generatedPaint(element, \"::before\") ||\n generatedPaint(element, \"::after\");\n if (!unknown) {\n const width = outlineWidth(style);\n const outline = width > 0 ? width + Math.abs(Number.parseFloat(style.outlineOffset) || 0) : 0;\n const { x, y } = cache.scale(element);\n const extra = Math.max(outline, shadowExtent(style.boxShadow)) * Math.max(x, y);\n if (extra > 0 || REPLACED.has(element.localName) || boxPaint(style)) {\n for (const rect of element.getClientRects())\n rects.push(expand(toRect(rect), extra));\n }\n rects.push(...textRects(element, style));\n }\n }\n const result = { unknown, rects };\n bounds.set(element, result);\n return result;\n }\n function clipBox(element) {\n const rect = toRect(element.getBoundingClientRect());\n const scale = cache.scale(element);\n const style = cache.style(element);\n const left = Number.parseFloat(style.borderLeftWidth) * scale.x || 0;\n const top = Number.parseFloat(style.borderTopWidth) * scale.y || 0;\n const right = Number.parseFloat(style.borderRightWidth) * scale.x || 0;\n const bottom = Number.parseFloat(style.borderBottomWidth) * scale.y || 0;\n const padding = {\n x: rect.x + left,\n y: rect.y + top,\n width: rect.width - left - right,\n height: rect.height - top - bottom,\n };\n if (!/^(auto|scroll|overlay)$/.test(style.overflowX) && !/^(auto|scroll|overlay)$/.test(style.overflowY))\n return padding;\n // Client sizes omit scrollbars. Round the reported clip inwards to allow subpixel layout sizes.\n return intersect(padding, {\n x: rect.x + (element.clientLeft + 0.5) * scale.x,\n y: rect.y + (element.clientTop + 0.5) * scale.y,\n width: (element.clientWidth - 1) * scale.x,\n height: (element.clientHeight - 1) * scale.y,\n });\n }\n function geometrySupported(element) {\n const style = cache.style(element);\n const containment = style.contain.split(\" \");\n const clipMargin = style.getPropertyValue(\"overflow-clip-margin\");\n // The image rectangle is already clipped to its content box, including the browser's default image clip.\n const clipsOverflow = element.localName !== \"img\" && (style.overflowX === \"clip\" || style.overflowY === \"clip\");\n return (!clipped(style) &&\n !containment.some((value) => value === \"paint\" || value === \"strict\" || value === \"content\") &&\n (!clipsOverflow || clipMargin === \"\" || clipMargin === \"0px\") &&\n style.transformStyle !== \"preserve-3d\" &&\n (!style.contentVisibility || style.contentVisibility === \"visible\") &&\n cache.scale(element).ok);\n }\n function clip(record, image) {\n const scene = mediaOwner(record.element);\n if (!scene)\n return image;\n const imageElement = record.media;\n if (!imageElement || rounded(cache.style(record.element)) || rounded(cache.style(imageElement)))\n return null;\n let visible = image.visible;\n if (viewport)\n visible = intersect(visible, viewport);\n if (record.element !== imageElement)\n visible = intersect(visible, clipBox(record.element));\n for (let element = scene; element; element = parentOf(element)) {\n const style = cache.style(element);\n const scroller = element !== scene.ownerDocument.documentElement &&\n element !== scene.ownerDocument.body &&\n (style.overflowX !== \"visible\" || style.overflowY !== \"visible\");\n if (!geometrySupported(element) || ((element === scene || scroller) && rounded(style)))\n return null;\n if (element === scene || scroller)\n visible = intersect(visible, clipBox(element));\n }\n return isUsableRect(visible) ? { drawn: image.drawn, visible } : null;\n }\n function composition(scene, element, image) {\n if (sceneComposition.has(scene))\n return sceneComposition.get(scene) ?? null;\n const sceneStyle = cache.style(scene);\n const style = cache.style(element);\n const imageStyle = cache.style(image);\n const orientation = imageStyle.getPropertyValue(\"image-orientation\");\n let reason = null;\n if (scene.classList.contains(viewportClass) || imageStyle.position === \"fixed\")\n reason = \"background-viewport\";\n else if (sceneStyle.position !== \"relative\" ||\n sceneStyle.isolation !== \"isolate\" ||\n style.position !== \"absolute\" ||\n style.zIndex !== \"-2\" ||\n style.pointerEvents !== \"none\" ||\n imageStyle.pointerEvents !== \"none\" ||\n ![\"cover\", \"contain\"].includes(imageStyle.objectFit) ||\n (element !== image && imageStyle.position !== \"static\"))\n reason = \"background-geometry\";\n else if (generatedPaint(scene, \"::before\") ||\n generatedPaint(scene, \"::after\") ||\n (element !== image && (generatedPaint(element, \"::before\") || generatedPaint(element, \"::after\"))) ||\n [scene, element, image].some((node) => composited(cache.style(node)) || node.getAnimations().length > 0) ||\n [sceneStyle, style, imageStyle].some((value) => value.content !== \"normal\") ||\n imageStyle.getPropertyValue(\"image-rendering\") !== \"auto\" ||\n (orientation !== \"\" && orientation !== \"from-image\") ||\n effect(imageStyle.getPropertyValue(\"object-view-box\")) ||\n imageStyle.visibility !== \"visible\" ||\n imageStyle.display === \"none\")\n reason = \"background-composition\";\n else if (!geometrySupported(element) || !geometrySupported(image))\n reason = \"background-geometry\";\n sceneComposition.set(scene, reason);\n return reason;\n }\n function surfacePath(surface, scene, image) {\n if (surface === scene || surface.getRootNode() !== scene.getRootNode())\n return \"background-ownership\";\n let inside = true;\n for (let element = surface; element; element = parentOf(element)) {\n const s = cache.style(element);\n if (element.assignedSlot || topLayer(element))\n return \"background-ownership\";\n if (s.position === \"fixed\" || s.position === \"sticky\" || !geometrySupported(element))\n return \"background-geometry\";\n if (element !== surface && (composited(s) || element.getAnimations().length > 0))\n return \"background-composition\";\n if (inside && element !== scene && element.parentElement === scene && !element.classList.contains(contentClass))\n return \"background-ownership\";\n if (element === scene)\n inside = false;\n }\n return inside || scrollRelation(cache.anchor(surface), cache.anchor(image)) !== \"together\"\n ? \"background-geometry\"\n : null;\n }\n function point(surface, scene, rect, sources) {\n if (scene.childElementCount > SCENE_ELEMENT_LIMIT)\n return fallback(\"background-intervening-paint\");\n const [element, second] = mediaIn(scene);\n if (!element || second)\n return fallback(\"background-composition\");\n const record = sources.get(element);\n if (!record)\n return fallback(\"background-source-undeclared\");\n if (record.state !== \"ready\")\n return fallback(`source-${record.state}`, record.id);\n if (!sources.imageIsCurrent(record))\n return fallback(\"source-pending\", record.id);\n const image = record.media;\n if (!image ||\n record.kind !== \"image\" ||\n image.localName !== \"img\" ||\n (element !== image &&\n (element.localName !== \"picture\" ||\n image.parentElement !== element ||\n [...element.children].some((child) => child !== image && child.localName !== \"source\"))))\n return fallback(\"background-geometry\", record.id);\n const reason = composition(scene, element, image) ?? surfacePath(surface, scene, image);\n if (reason)\n return fallback(reason, record.id);\n const geometry = media(record).image;\n if (!geometry)\n return fallback(\"background-geometry\", record.id);\n if (!containsRect(geometry.visible, rect, 0))\n return fallback(\"partial-overlap\", record.id);\n const { elements } = readScene(scene);\n const overlaps = (box) => isUsableRect(intersect(box, rect));\n if (!elements ||\n scene.childNodes.length > SCENE_ELEMENT_LIMIT ||\n textRects(scene, cache.style(scene)).some(overlaps))\n return fallback(\"background-intervening-paint\", record.id);\n for (const foreground of elements) {\n if (containsFlat(surface, foreground))\n continue;\n const evidence = readBounds(foreground);\n if (evidence.unknown || evidence.rects.some(overlaps))\n return { kind: \"unknown\", reason: \"background-intervening-paint\", element: foreground, sourceId: record.id };\n }\n switch (sources.imageOpacity(record)) {\n case \"pending\":\n return fallback(\"background-opacity-pending\", record.id);\n case \"transparent\":\n return fallback(\"background-image-transparency\", record.id);\n case \"unverified\":\n return fallback(\"background-image-unverified\", record.id);\n case \"opaque\":\n return { kind: \"source\", sourceId: record.id };\n }\n }\n return {\n sceneOf,\n mediaOwner,\n hasMedia: (scene) => scene.childElementCount > SCENE_ELEMENT_LIMIT || mediaIn(scene).length > 0,\n clip,\n point,\n };\n}\n//# sourceMappingURL=background.js.map","// Adaptive quality (D-84): decides the level of surfaces with quality `auto` from what rendering costs while it runs.\n// Pure: no DOM, no timers, no clock of its own. The controller reports every frame it draws; nothing is sampled, and\n// nothing runs, while the scene is idle.\n//\n// A frame counts as overloaded when the engine itself cannot keep 60 frames per second: its CPU time takes most of a\n// frame, the frame is late and its CPU time is a large part of it, or the GPU is several frames behind. A late frame\n// alone is never enough: the rest of the page, or a display that runs at a lower rate, is not the engine's load. Frames\n// that come slowly, whoever wants it so, may take a share of the time between them. A display with a higher rate does not\n// lower the budget: the level is not reduced while 60 frames per second hold.\n/** Levels of surfaces with quality `auto`, from the highest. */\nexport const LEVELS = [\"balanced\", \"economy\", \"lite\"];\nexport const GOVERNOR = Object.freeze({\n /** Milliseconds and frames a window has at least, and the share of overloaded frames that makes it overloaded. */\n window: 500,\n minFrames: 6,\n overloadShare: 0.75,\n /** Overloaded windows in a row that lower the level. */\n windows: 2,\n /** Frames further apart than this do not belong to one animation: the window starts again. */\n gap: 250,\n /**\n * The frame budget in milliseconds. A frame is late when it comes `late` budgets after the last one; the time between\n * frames that are `slow` budgets apart is the budget instead.\n */\n budget: 1000 / 60,\n late: 1.5,\n slow: 2.5,\n /** Share of the budget the engine's CPU time may take: in late frames, and in any frame. */\n lateShare: 0.5,\n share: 0.75,\n /** Frames the GPU may be behind. */\n backlog: 3,\n /** Milliseconds before a lowered level is raised again, doubled whenever raising it failed, and its bound. */\n cooldown: 10_000,\n maxCooldown: 300_000,\n /** A raised level that lasts this long did not fail. */\n stable: 60_000,\n});\n/** `available`: whether `economy` draws fewer pixels than `balanced`; otherwise it is skipped. */\nexport function createGovernor(available) {\n let index = 0;\n let changes = 0;\n let reason = \"initial\";\n let raiseAt = null;\n let cooldown = GOVERNOR.cooldown;\n let raisedAt = -Infinity;\n let last = -Infinity;\n let opened = -Infinity;\n let frames = 0;\n let slow = 0;\n let behind = 0;\n let overloaded = 0;\n const restart = (time) => {\n opened = time;\n frames = 0;\n slow = 0;\n behind = 0;\n };\n const step = (direction) => {\n let next = index + direction;\n while (next > 0 && next < LEVELS.length - 1 && !available(LEVELS[next]))\n next += direction;\n if (next < 0 || next >= LEVELS.length)\n return false;\n index = next;\n changes++;\n overloaded = 0;\n last = -Infinity;\n return true;\n };\n return {\n get level() {\n return LEVELS[index];\n },\n get changes() {\n return changes;\n },\n get reason() {\n return reason;\n },\n get raiseAt() {\n return raiseAt;\n },\n sample(frame) {\n const elapsed = frame.time - last;\n last = frame.time;\n if (!(elapsed > 0))\n return false;\n if (elapsed > GOVERNOR.gap) {\n restart(frame.time);\n overloaded = 0;\n return false;\n }\n const late = frame.consecutive && elapsed > GOVERNOR.budget * GOVERNOR.late;\n const budget = elapsed > GOVERNOR.budget * GOVERNOR.slow ? elapsed : GOVERNOR.budget;\n frames++;\n if (frame.cpu > budget * (late ? GOVERNOR.lateShare : GOVERNOR.share))\n slow++;\n else if (frame.backlog >= GOVERNOR.backlog)\n behind++;\n if (frames < GOVERNOR.minFrames || frame.time - opened < GOVERNOR.window)\n return false;\n const heavy = slow + behind >= frames * GOVERNOR.overloadShare;\n const cause = slow >= behind ? \"cpu\" : \"gpu\";\n restart(frame.time);\n overloaded = heavy ? overloaded + 1 : 0;\n if (overloaded < GOVERNOR.windows)\n return false;\n overloaded = 0;\n if (!step(1))\n return false;\n reason = cause;\n // Raising it again failed soon: wait longer before the next attempt.\n cooldown =\n frame.time - raisedAt < GOVERNOR.stable ? Math.min(GOVERNOR.maxCooldown, cooldown * 2) : GOVERNOR.cooldown;\n raiseAt = frame.time + cooldown;\n return true;\n },\n raise(time) {\n if (raiseAt === null || time < raiseAt || !step(-1))\n return false;\n reason = \"recovery\";\n raisedAt = time;\n raiseAt = index > 0 ? time + cooldown : null;\n return true;\n },\n };\n}\n//# sourceMappingURL=governor.js.map","// Backdrop classification (RENDERING_STRATEGY.md section 4). A surface is sampled on a 3 x 3 grid with\n// `elementsFromPoint`; each sample reports the first thing painted under the surface. For Background, the scene\n// can establish the paint of its pointer-transparent media. A declared source counts as B1 only when every\n// sample hits it, it is ready, and the surface lies entirely over its visible image.\nimport { createBackgroundCache } from \"./background.js\";\nimport { containsFlat } from \"./dom.js\";\nimport { anchorOf, containsRect, drawnImage, intersect, scaleOf, toRect, } from \"./geometry.js\";\nimport { colorAlpha } from \"./sources.js\";\n/** Combines the samples of one surface (pure; unit-tested). */\nexport function combine(points) {\n const inside = points.filter((p) => p.kind !== \"outside\");\n if (!inside.length)\n return { class: \"B0\", reason: \"not-in-viewport\" };\n const unknown = inside.find((p) => p.kind === \"unknown\");\n if (unknown)\n return {\n class: \"B0\",\n reason: unknown.reason,\n ...(unknown.sourceId === undefined ? {} : { sourceId: unknown.sourceId }),\n };\n const first = inside[0];\n if (first?.kind === \"source\") {\n return inside.every((p) => p.kind === \"source\" && p.sourceId === first.sourceId)\n ? { class: \"B1\", reason: \"declared-source\", sourceId: first.sourceId }\n : { class: \"B0\", reason: \"mixed\" };\n }\n if (first?.kind === \"uniform\") {\n const same = inside.every((p) => p.kind === \"uniform\" && p.color === first.color);\n if (!same)\n return { class: \"B0\", reason: \"mixed\" };\n const declared = inside.every((p) => p.kind === \"uniform\" && p.declared);\n return { class: \"B2\", reason: declared ? \"declared-uniform\" : \"uniform\", color: first.color, declared };\n }\n return { class: \"B0\", reason: \"unknown-content\" };\n}\n/** Sample positions as fractions of the surface's width and height. */\nexport const GRID = [1 / 6, 1 / 2, 5 / 6];\n/** Reason of a sample that did not hit the surface itself. */\nconst MISSED = \"surface-not-hit-testable\";\nconst REPLACED = new Set([\n \"img\",\n \"video\",\n \"canvas\",\n \"svg\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"input\",\n \"textarea\",\n \"select\",\n \"audio\",\n \"picture\",\n \"meter\",\n \"progress\",\n \"math\",\n]);\nexport function createSampleCache(prefix = \"\", viewport) {\n const styles = new Map();\n const paints = new Map();\n const scales = new Map();\n const anchors = new Map();\n const media = new Map();\n const queries = new Map();\n let modal = null;\n const style = (element) => {\n let value = styles.get(element);\n if (!value)\n styles.set(element, (value = getComputedStyle(element)));\n return value;\n };\n const scale = (element) => scaleOf(element, scales);\n const anchor = (element) => anchorOf(element, anchors);\n const background = createBackgroundCache(prefix, { style, scale, anchor }, readMedia, viewport);\n function readMedia(record) {\n let geometry = media.get(record);\n if (!geometry) {\n const element = record.media ?? record.element;\n const rect = toRect(element.getBoundingClientRect());\n const k = scale(element);\n const image = drawnImage(rect, style(element), record.width, record.height, k);\n media.set(record, (geometry = { rect, scale: k, image: image && background.clip(record, image) }));\n }\n return geometry;\n }\n return {\n blockers: new Map(),\n background,\n style,\n scale,\n anchor,\n paint(element) {\n let paint = paints.get(element);\n if (!paint)\n paints.set(element, (paint = readPaint(element, style(element), scale)));\n return paint;\n },\n media: readMedia,\n // The live list of dialogs, which costs nothing while there is none: this is asked in every pass.\n modal: () => (modal ??= [...document.getElementsByTagName(\"dialog\")].some((d) => d.open && d.matches(\":modal\"))),\n matches(query) {\n let result = queries.get(query);\n if (result === undefined)\n queries.set(query, (result = matchMedia(query).matches));\n return result;\n },\n };\n}\nfunction hasText(element) {\n for (const node of element.childNodes)\n if (node.nodeType === 3 && /\\S/.test(node.nodeValue ?? \"\"))\n return true;\n return false;\n}\n/** What an element paints that would make the backdrop non-uniform. */\nfunction readPaint(element, style, scale) {\n const color = style.backgroundColor;\n const alpha = colorAlpha(color);\n const paint = (reason, inner = null) => ({ reason, inner, color, alpha });\n if (REPLACED.has(element.localName))\n return paint(\"replaced-content\");\n if (style.backgroundImage !== \"none\")\n return paint(\"background-image\");\n if (style.filter !== \"none\" || style.mixBlendMode !== \"normal\")\n return paint(\"effect\");\n if (style.backdropFilter && style.backdropFilter !== \"none\")\n return paint(\"backdrop-filter\");\n if (hasText(element))\n return paint(\"text\");\n const px = (v) => Number.parseFloat(v) || 0;\n const top = px(style.borderTopWidth);\n const right = px(style.borderRightWidth);\n const bottom = px(style.borderBottomWidth);\n const left = px(style.borderLeftWidth);\n if (!(top > 0 || right > 0 || bottom > 0 || left > 0))\n return paint(null);\n const r = element.getBoundingClientRect();\n const k = scale(element);\n return paint(null, {\n left: r.left + left * k.x,\n top: r.top + top * k.y,\n right: r.right - right * k.x,\n bottom: r.bottom - bottom * k.y,\n });\n}\n/** The first thing painted under `surface` at viewport point (x, y). */\nexport function samplePoint(root, surface, x, y, sources, cache, background) {\n const stack = root.elementsFromPoint(x, y);\n const at = stack.indexOf(surface);\n if (at < 0)\n return { kind: \"unknown\", reason: MISSED };\n for (let i = at + 1; i < stack.length; i++) {\n const element = stack[i];\n if (containsFlat(surface, element))\n continue;\n // Reaching the isolated scene proves the position of its unseen media in the hit-test stack. The scene\n // also supplies bounds for foreground paint that is pointer-transparent or lies between grid samples.\n if (background?.scene === element)\n return background.point();\n if (background && containsFlat(background.scene, element))\n continue;\n const source = sources.lookup(element);\n if (source) {\n if (cache.background.mediaOwner(source.element))\n return { kind: \"unknown\", reason: \"background-ownership\" };\n if (source.kind === \"uniform\" && source.state === \"ready\")\n return { kind: \"uniform\", color: source.color, declared: true };\n if (source.kind === \"unsupported\" || source.kind === \"uniform\")\n return { kind: \"unknown\", reason: \"unsupported-source\" };\n return { kind: \"source\", sourceId: source.id };\n }\n const { reason, inner, color, alpha } = cache.paint(element);\n if (reason)\n return { kind: \"unknown\", reason, element };\n if (inner && (x < inner.left || x > inner.right || y < inner.top || y > inner.bottom))\n return { kind: \"unknown\", reason: \"border\", element };\n if (alpha >= 1) {\n cache.blockers.set(surface, element);\n return { kind: \"uniform\", color, declared: false };\n }\n if (alpha > 0)\n return { kind: \"unknown\", reason: \"translucent-background\", element };\n }\n return { kind: \"unknown\", reason: \"canvas-background\" };\n}\nconst SAMPLES = GRID.length ** 2;\n/** Passes a sample can be used in, its own included, and milliseconds after which it is not used at all. */\nexport const REUSE_PASSES = GRID.length;\nexport const REUSE_MS = 64;\n/** Whether sample `index` (row by row) is taken again in `pass`, however little the surface moved. */\nexport function sampledIn(index, pass) {\n const row = Math.floor(index / GRID.length);\n return ((index % GRID.length) + row + pass) % GRID.length === 0;\n}\n/** Whether a sample taken at `from` still stands for its cell at `to`. */\nexport function reusable(from, to, width, height) {\n const half = GRID.length * 2;\n return (to.pass - from.pass < REUSE_PASSES &&\n to.time - from.time <= REUSE_MS &&\n Math.abs(to.x - from.x) <= width / half &&\n Math.abs(to.y - from.y) <= height / half);\n}\n/**\n * Classifies one surface. `rect` is its border box in viewport pixels; `viewport` the visible area. `outline` is the\n * signed distance of the surface's shape at a point relative to `rect` (negative inside): hit testing follows rounded\n * corners, so a sample in a corner the shape cuts off misses the surface and says nothing about what lies under it.\n */\nexport function classify(surface, rect, viewport, sources, cache, outline, reuse) {\n if (rect.width <= 0 || rect.height <= 0)\n return { class: \"B0\", reason: \"empty\" };\n const root = surface.getRootNode();\n const scene = cache.background.sceneOf(surface);\n let backgroundPoint = null;\n const background = scene && cache.background.hasMedia(scene)\n ? { scene, point: () => (backgroundPoint ??= cache.background.point(surface, scene, rect, sources)) }\n : undefined;\n const px = (index) => rect.x + rect.width * (GRID[index % GRID.length] ?? 0);\n const py = (index) => rect.y + rect.height * (GRID[Math.floor(index / GRID.length)] ?? 0);\n const sample = (index) => {\n const x = px(index);\n const y = py(index);\n if (x < viewport.x || y < viewport.y || x >= viewport.x + viewport.width || y >= viewport.y + viewport.height)\n return { kind: \"outside\" };\n const point = samplePoint(root, surface, x, y, sources, cache, background);\n if (point.kind === \"unknown\" && point.element)\n cache.blockers.set(surface, point.element);\n // Within a pixel of the edge the browser's hit test may differ from the field.\n const cut = point.kind === \"unknown\" && point.reason === MISSED && outline && outline(x - rect.x, y - rect.y) > -1;\n return cut ? { kind: \"outside\" } : point;\n };\n const place = (index, media) => ({\n x: px(index) - media.x,\n y: py(index) - media.y,\n pass: reuse?.pass ?? 0,\n time: reuse?.time ?? 0,\n });\n const points = [];\n const taken = [];\n const previous = reuse?.previous ?? null;\n const record = previous ? sources.byId(previous.sourceId) : undefined;\n const over = record && cache.media(record).rect;\n let complete = true;\n if (!background && reuse && previous && over?.width === previous.mediaWidth && over.height === previous.mediaHeight) {\n complete = false;\n for (let i = 0; i < SAMPLES; i++) {\n const now = place(i, over);\n const before = previous.taken[i];\n const known = previous.points[i];\n if (before &&\n known?.kind === \"source\" &&\n !sampledIn(i, reuse.pass) &&\n reusable(before, now, rect.width, rect.height)) {\n points.push(known);\n taken.push(before);\n reuse.partial = true;\n continue;\n }\n const point = sample(i);\n points.push(point);\n taken.push(now);\n if (point.kind === \"source\" ? point.sourceId !== previous.sourceId : point.kind !== \"outside\") {\n complete = true;\n break;\n }\n }\n }\n if (complete) {\n // Nothing to use again, or the backdrop changed: all samples are taken now.\n points.length = 0;\n taken.length = 0;\n if (reuse)\n reuse.partial = false;\n for (let i = 0; i < SAMPLES; i++)\n points.push(sample(i));\n }\n const result = combine(points);\n if (result.class !== \"B1\" || result.sourceId === undefined) {\n // A declared source anywhere under a surface rules out B2: it may paint where no sample landed.\n if (result.class === \"B2\") {\n for (const record of sources.all()) {\n if (record.kind === \"uniform\" || !record.element.isConnected)\n continue;\n const r = record.element.getBoundingClientRect();\n if (intersect(rect, { x: r.left, y: r.top, width: r.width, height: r.height }).width > 0)\n return { class: \"B0\", reason: \"source-overlap\" };\n }\n }\n return result;\n }\n if (background && cache.background.mediaOwner(sources.byId(result.sourceId)?.element ?? surface) === background.scene)\n return { ...result, reason: \"background-source\" };\n const checked = overSource(rect, result, result.sourceId, sources, cache);\n if (checked.class === \"B1\" && reuse) {\n const media = cache.media(sources.byId(result.sourceId));\n reuse.next = {\n sourceId: result.sourceId,\n points,\n taken: points.map((_, i) => taken[i] ?? place(i, media.rect)),\n mediaWidth: media.rect.width,\n mediaHeight: media.rect.height,\n };\n }\n return checked;\n}\n/** Whether a surface over a source lies entirely over its visible image, and the source is ready. */\nexport function overSource(rect, result, sourceId, sources, cache) {\n const found = sources.byId(sourceId);\n if (!found)\n return { class: \"B0\", reason: \"source-unregistered\" };\n if (cache.background.mediaOwner(found.element))\n return { class: \"B0\", reason: \"background-ownership\", sourceId };\n if (found.state !== \"ready\")\n return { class: \"B0\", reason: `source-${found.state}`, sourceId };\n const media = cache.media(found);\n if (!(media.rect.width > 0 && media.rect.height > 0))\n return { class: \"B0\", reason: \"partial-overlap\", sourceId };\n if (!media.image)\n return { class: \"B0\", reason: \"geometry-unsupported\", sourceId };\n return containsRect(media.image.visible, rect) ? result : { class: \"B0\", reason: \"partial-overlap\", sourceId };\n}\n//# sourceMappingURL=classify.js.map","// Engine-owned rendering layers (D-51, BUILD_AND_DISTRIBUTION.md section 8.7). A layer is a canvas inserted as\n// the surface's first child, so it stacks correctly with the top layer and moves with the surface on the\n// compositor. It is hidden from assistive technology and from hit testing. The surface gets `position: relative`\n// (only if it was static) and `isolation: isolate` while a layer exists; both inline values are restored on\n// removal. A framework or morphing library may remove the layer; the engine puts it back once per pass.\n//\n// A glass group's shared layer (D-76) is a canvas inserted as the first child of the group element. The group\n// element gets only `isolation: isolate` (its stacking context keeps the layer behind the members); its\n// `position` is left alone, so absolutely positioned members keep their containing block, and the layer is placed\n// relative to its own containing block, which is measured (`placeLayerAt`).\nimport { LAYER_ATTRIBUTE } from \"./dom.js\";\n/** `position`: the computed position of the surface at its last measurement. */\nfunction claimSurface(layer, position) {\n const { style } = layer.surface;\n if (!layer.group && layer.savedPosition === null && position === \"static\") {\n layer.savedPosition = style.position;\n style.position = \"relative\";\n layer.wrote = true;\n }\n if (layer.savedIsolation === null) {\n layer.savedIsolation = style.isolation;\n style.isolation = \"isolate\";\n layer.wrote = true;\n }\n}\nexport function createLayer(surface, position, group = false) {\n const canvas = surface.ownerDocument.createElement(\"canvas\");\n canvas.setAttribute(LAYER_ATTRIBUTE, \"\");\n canvas.setAttribute(\"aria-hidden\", \"true\");\n const { style } = canvas;\n style.position = \"absolute\";\n style.zIndex = \"-1\";\n style.pointerEvents = \"none\";\n // A surface layer is clipped like its surface (corner shape included where supported); a group layer is not.\n style.borderRadius = group ? \"0\" : \"inherit\";\n if (!group)\n style.setProperty(\"corner-shape\", \"inherit\");\n style.display = \"block\";\n style.margin = \"0\";\n style.padding = \"0\";\n style.border = \"0\";\n const layer = {\n surface,\n canvas,\n pixelWidth: 0,\n pixelHeight: 0,\n savedPosition: null,\n savedIsolation: null,\n hadStyle: surface.hasAttribute(\"style\"),\n suspended: false,\n group,\n placed: null,\n wrote: false,\n };\n claimSurface(layer, position);\n surface.prepend(canvas);\n return layer;\n}\n/**\n * Hides a layer whose pixels were drawn for geometry that is no longer current, so the CSS material shows until the\n * layer is redrawn. Cheaper than removing it: the canvas and the backend's resources for it are kept.\n */\nexport function suspendLayer(layer) {\n if (layer.suspended)\n return;\n layer.suspended = true;\n layer.canvas.style.visibility = \"hidden\";\n}\n/** Shows a suspended layer again; called only after it was redrawn with current geometry. */\nexport function resumeLayer(layer) {\n if (!layer.suspended)\n return;\n layer.suspended = false;\n layer.canvas.style.visibility = \"\";\n}\n/** Writes the canvas position and size that changed. */\nfunction place(layer, left, top, width, height, clip) {\n const { style } = layer.canvas;\n const p = layer.placed;\n if (left !== p?.[0])\n style.left = `${left}px`;\n if (top !== p?.[1])\n style.top = `${top}px`;\n if (width !== p?.[2])\n style.width = `${width}px`;\n if (height !== p?.[3])\n style.height = `${height}px`;\n if (clip !== p?.[4])\n style.borderRadius = clip ? \"inherit\" : \"0\";\n layer.placed = [left, top, width, height, clip];\n}\n/**\n * Sizes the layer to the surface's border box, extended by `pad` viewport px on every side (a deformed shape may leave\n * the box). Three kinds of pixels meet here (D-78): `rect` is in viewport CSS px, as the DOM reports it; the canvas is a\n * child of the surface, so its styles are in the surface's own CSS px and `scale` (viewport px per own px) applies to\n * it again; the bitmap is in device px. `borderLeft` and `borderTop` (own px) offset it from the padding box, the\n * containing block of an absolutely positioned child. Returns whether the bitmap was resized.\n */\nexport function placeLayer(layer, rect, scale, borderLeft, borderTop, dpr, pad = 0) {\n place(layer, -borderLeft - pad / scale.x, -borderTop - pad / scale.y, (rect.width + 2 * pad) / scale.x, (rect.height + 2 * pad) / scale.y, \n // The corner clip belongs to the border box; an extended layer is shaped by its own pixels only.\n pad <= 0);\n const width = Math.max(1, Math.round((rect.width + 2 * pad) * dpr));\n const height = Math.max(1, Math.round((rect.height + 2 * pad) * dpr));\n if (width === layer.pixelWidth && height === layer.pixelHeight)\n return false;\n layer.canvas.width = layer.pixelWidth = width;\n layer.canvas.height = layer.pixelHeight = height;\n return true;\n}\n/**\n * Places a group layer over `rect` (viewport CSS px). Its containing block is found by placing the canvas at its\n * origin and measuring it, so the group element's `position` never has to change. `scale` is the group element's, as in\n * `placeLayer`. Returns whether the bitmap was resized.\n */\nexport function placeLayerAt(layer, rect, scale, dpr) {\n const { style } = layer.canvas;\n style.left = \"0px\";\n style.top = \"0px\";\n const origin = layer.canvas.getBoundingClientRect();\n style.left = `${(rect.x - origin.left) / scale.x}px`;\n style.top = `${(rect.y - origin.top) / scale.y}px`;\n style.width = `${rect.width / scale.x}px`;\n style.height = `${rect.height / scale.y}px`;\n const width = Math.max(1, Math.round(rect.width * dpr));\n const height = Math.max(1, Math.round(rect.height * dpr));\n if (width === layer.pixelWidth && height === layer.pixelHeight)\n return false;\n layer.canvas.width = layer.pixelWidth = width;\n layer.canvas.height = layer.pixelHeight = height;\n return true;\n}\n/** Puts a removed layer back and re-applies the surface styles; returns true if it had been removed. */\nexport function ensureAttached(layer, position) {\n const removed = layer.canvas.parentNode !== layer.surface;\n if (removed) {\n layer.surface.prepend(layer.canvas);\n layer.placed = null;\n }\n let current = position;\n // A morph may also have reset the surface's inline style, since it was measured.\n if (layer.savedIsolation !== null && layer.surface.style.isolation !== \"isolate\") {\n layer.savedIsolation = null;\n layer.savedPosition = null;\n layer.hadStyle = layer.surface.hasAttribute(\"style\");\n if (!layer.group)\n current = getComputedStyle(layer.surface).position;\n }\n claimSurface(layer, current);\n return removed;\n}\nexport function removeLayer(layer) {\n layer.canvas.remove();\n layer.canvas.width = 0;\n layer.canvas.height = 0;\n const { style } = layer.surface;\n if (layer.savedPosition !== null)\n style.position = layer.savedPosition;\n if (layer.savedIsolation !== null)\n style.isolation = layer.savedIsolation;\n layer.savedPosition = null;\n layer.savedIsolation = null;\n // Leave the markup as it was: no empty style attribute where there was none. Reading the attribute first\n // flushes the browser's pending CSSOM-to-attribute sync; otherwise Chromium can write `style=\"\"` back later.\n if (!layer.hadStyle && style.length === 0) {\n layer.surface.getAttribute(\"style\");\n layer.surface.removeAttribute(\"style\");\n }\n}\n//# sourceMappingURL=layers.js.map","// Spring solver (D-79): a damped harmonic oscillator, m x'' + c x' + k (x - target) = 0, advanced with its closed-form\n// solution. A step is exact for any duration, so the result does not depend on the frame rate, a long gap cannot make\n// it unstable, and the same inputs give the same motion. Pure functions and a small state object; no timers, no DOM,\n// nothing runs at import time.\n/** Ranges the parameters are clamped to. */\nexport const SPRING_LIMITS = Object.freeze({\n stiffness: [20, 10000],\n damping: [0, 1000],\n mass: [0.05, 5],\n});\n/** The smallest damping ratio: a spring below it would ring for too long, and without damping never stop. */\nexport const MIN_DAMPING_RATIO = 0.1;\n/** The largest damping ratio: a spring above it would only creep toward its target. */\nexport const MAX_DAMPING_RATIO = 3;\n/** A spring that has not come to rest by then is ended at its target, in seconds. */\nexport const MAX_DURATION = 10;\n/**\n * Stiffness and damping of a spring with mass 1 from the design parameters of the motion tokens (DESIGN_TOKENS.md):\n * the period of the undamped oscillation in seconds and the damping ratio.\n */\nexport function springFromResponse(response, dampingRatio) {\n const w = (2 * Math.PI) / response;\n return { stiffness: w * w, damping: 2 * dampingRatio * w, mass: 1 };\n}\n/** The default spring: the `snappy` preset of the motion tokens (response 0.3 s, damping ratio 0.86). */\nexport const DEFAULT_SPRING = Object.freeze(springFromResponse(0.3, 0.86));\n/** Valid parameters: non-finite values take `base`, every value is clamped, and the damping ratio is 0.1 to 3. */\nexport function clampSpring(values, base = DEFAULT_SPRING) {\n const pick = (key) => {\n const v = values[key];\n const [lo, hi] = SPRING_LIMITS[key];\n return Math.min(hi, Math.max(lo, typeof v === \"number\" && Number.isFinite(v) ? v : base[key]));\n };\n const stiffness = pick(\"stiffness\");\n const mass = pick(\"mass\");\n const critical = 2 * Math.sqrt(stiffness * mass);\n const damping = Math.min(MAX_DAMPING_RATIO * critical, Math.max(MIN_DAMPING_RATIO * critical, pick(\"damping\")));\n return { stiffness, mass, damping };\n}\n/**\n * Displacement and velocity after `dt` seconds, from a displacement `x` (value minus target) and velocity `v`. Exact for\n * every damping ratio; `dt` 0 or less, or a non-finite input, changes nothing.\n */\nexport function advance(x, v, p, dt) {\n if (!(dt > 0) || !Number.isFinite(x) || !Number.isFinite(v) || !Number.isFinite(dt))\n return [x, v];\n const w0 = Math.sqrt(p.stiffness / p.mass);\n const zeta = p.damping / (2 * Math.sqrt(p.stiffness * p.mass));\n if (Math.abs(zeta - 1) < 1e-4) {\n // Critically damped: (x + (v + w0 x) t) e^(-w0 t).\n const e = Math.exp(-w0 * dt);\n const b = v + w0 * x;\n return [(x + b * dt) * e, (v - w0 * b * dt) * e];\n }\n if (zeta < 1) {\n const wd = w0 * Math.sqrt(1 - zeta * zeta);\n const e = Math.exp(-zeta * w0 * dt);\n const cos = Math.cos(wd * dt);\n const sin = Math.sin(wd * dt);\n const b = (v + zeta * w0 * x) / wd;\n return [(x * cos + b * sin) * e, (v * cos - (zeta * w0 * b + wd * x) * sin) * e];\n }\n // Overdamped: two decaying exponentials.\n const root = w0 * Math.sqrt(zeta * zeta - 1);\n const r1 = -zeta * w0 + root;\n const r2 = -zeta * w0 - root;\n const c2 = (v - r1 * x) / (r2 - r1);\n const c1 = x - c2;\n const e1 = Math.exp(r1 * dt);\n const e2 = Math.exp(r2 * dt);\n return [c1 * e1 + c2 * e2, c1 * r1 * e1 + c2 * r2 * e2];\n}\nexport function createSpring(options = {}) {\n const restDelta = options.restDelta ?? 0.001;\n const restSpeed = options.restSpeed ?? restDelta * 10;\n let parameters = options.parameters ?? DEFAULT_SPRING;\n let value = options.value !== undefined && Number.isFinite(options.value) ? options.value : 0;\n let target = value;\n let velocity = 0;\n let settled = true;\n let elapsed = 0;\n const rest = () => {\n value = target;\n velocity = 0;\n settled = true;\n elapsed = 0;\n };\n const resting = () => Math.abs(value - target) <= restDelta && Math.abs(velocity) <= restSpeed;\n return {\n get value() {\n return value;\n },\n get velocity() {\n return velocity;\n },\n get target() {\n return target;\n },\n get settled() {\n return settled;\n },\n to(next, to = {}) {\n if (!Number.isFinite(next))\n return;\n if (to.parameters)\n parameters = to.parameters;\n if (to.velocity !== undefined && Number.isFinite(to.velocity))\n velocity = to.velocity;\n target = next;\n elapsed = 0;\n settled = false;\n if (resting())\n rest();\n },\n set(next) {\n if (!Number.isFinite(next))\n return;\n target = next;\n rest();\n },\n finish: rest,\n step(dt) {\n if (settled || !(dt > 0))\n return false;\n const [x, v] = advance(value - target, velocity, parameters, dt);\n elapsed += dt;\n if (!Number.isFinite(x) || !Number.isFinite(v) || elapsed >= MAX_DURATION) {\n rest();\n return true;\n }\n value = target + x;\n velocity = v;\n if (resting())\n rest();\n return true;\n },\n };\n}\n//# sourceMappingURL=spring.js.map","// Motion configuration (D-79): CSS tokens on each surface, like every other glass parameter (D-56), so defaults, presets\n// (`data-glass-motion`), subtrees, and single components are configured the same way and without JavaScript. Values are\n// parsed strictly, clamped, and replaced by their default when invalid. Nothing runs at import time.\nimport { parseToken } from \"./optics.js\";\nimport { clampSpring, DEFAULT_SPRING } from \"./spring.js\";\n/** Token, default, range, and unit of every parameter; the defaults equal the CSS token initial values. */\nexport const MOTION_TOKENS = {\n enabled: { token: \"--ab-motion-enabled\", default: 1, min: 0, max: 1, unit: \"\" },\n stiffness: {\n token: \"--ab-motion-stiffness\",\n default: DEFAULT_SPRING.stiffness,\n min: 20,\n max: 10000,\n unit: \"\",\n },\n damping: { token: \"--ab-motion-damping\", default: DEFAULT_SPRING.damping, min: 0, max: 1000, unit: \"\" },\n mass: { token: \"--ab-motion-mass\", default: 1, min: 0.05, max: 5, unit: \"\" },\n press: { token: \"--ab-motion-press\", default: 0.04, min: 0, max: 0.2, unit: \"\" },\n glow: { token: \"--ab-motion-glow\", default: 0.6, min: 0, max: 1, unit: \"\" },\n dragElasticity: { token: \"--ab-motion-drag-elasticity\", default: 0.6, min: 0, max: 1, unit: \"\" },\n dragLimit: { token: \"--ab-motion-drag-limit\", default: 64, min: 0, max: 400, unit: \"px\" },\n stretch: { token: \"--ab-motion-stretch\", default: 0.12, min: 0, max: 0.4, unit: \"\" },\n morph: { token: \"--ab-motion-morph\", default: 1, min: 0, max: 1, unit: \"\" },\n merge: { token: \"--ab-motion-merge\", default: 1, min: 0, max: 1, unit: \"\" },\n reducedLight: { token: \"--ab-motion-reduced-light\", default: 1, min: 0, max: 1, unit: \"\" },\n};\n/** Motion switched off: what surfaces use before they are measured. */\nexport const MOTION_OFF = Object.freeze({\n enabled: false,\n reduced: false,\n reducedLight: false,\n spring: DEFAULT_SPRING,\n press: 0,\n glow: 0,\n dragElasticity: 0,\n dragLimit: 0,\n stretch: 0,\n morph: false,\n merge: false,\n drag: null,\n});\n/** `data-glass-drag`: `x`, `y`, or `both` (also the empty value); anything else allows no drag. */\nexport function parseDrag(value) {\n const v = value?.trim().toLowerCase();\n if (v === \"\" || v === \"both\")\n return \"both\";\n return v === \"x\" || v === \"y\" ? v : null;\n}\n/** Reads the motion tokens of a computed style. */\nexport function readMotion(style, options) {\n const read = (spec) => {\n const n = parseToken(style.getPropertyValue(spec.token), spec.unit);\n return Math.min(spec.max, Math.max(spec.min, n ?? spec.default));\n };\n const T = MOTION_TOKENS;\n return {\n enabled: read(T.enabled) >= 0.5,\n reduced: options.reduced,\n reducedLight: read(T.reducedLight) >= 0.5,\n spring: clampSpring({ stiffness: read(T.stiffness), damping: read(T.damping), mass: read(T.mass) }),\n press: read(T.press),\n glow: read(T.glow),\n dragElasticity: read(T.dragElasticity),\n dragLimit: read(T.dragLimit),\n stretch: read(T.stretch),\n morph: read(T.morph) >= 0.5,\n merge: read(T.merge) >= 0.5,\n drag: parseDrag(options.drag),\n };\n}\n//# sourceMappingURL=motion-config.js.map","// The motion scene (motion-scene.ts) as a separate chunk (D-85). The engine loads it together with the backend when a\n// surface with motion is drawn on the GPU; pages whose surfaces all have `data-glass-motion=\"none\"`, or that never leave\n// the CSS material, never load it. Until it is there, and if it cannot be loaded, nothing moves: morphs and merge\n// distances take their token values at once, as they do with motion switched off.\nconst AT_REST = Object.freeze({\n managed: 0,\n pressed: 0,\n listening: false,\n targets: 0,\n channels: 0,\n updates: 0,\n lastUpdateMs: 0,\n maxUpdateMs: 0,\n});\nexport function createLazyMotionScene(host, failed) {\n let scene = null;\n let loading = null;\n let disposed = false;\n const load = () => (loading ??= import(\"./motion-scene.js\").then((module) => {\n if (disposed)\n return;\n scene = module.createMotionScene(host);\n host.request();\n }, failed));\n return {\n load,\n get active() {\n return scene?.active ?? false;\n },\n update(time) {\n scene?.update(time);\n },\n sync(surfaces) {\n if (scene) {\n scene.sync(surfaces);\n return;\n }\n if (disposed)\n return;\n for (const s of surfaces) {\n if (!host.eligible(s))\n continue;\n void load();\n return;\n }\n },\n morph: (s) => scene?.morph(s),\n merge: (g) => scene?.merge(g),\n morphTo(s, from, to) {\n scene?.morphTo(s, from, to);\n },\n mergeTo(g, from, to) {\n scene?.mergeTo(g, from, to);\n },\n moving: (s) => scene?.moving(s) ?? false,\n authored(s) {\n scene?.authored(s);\n },\n stopMorph(s) {\n scene?.stopMorph(s);\n },\n release(target) {\n scene?.release(target);\n },\n finish() {\n scene?.finish();\n },\n dispose() {\n disposed = true;\n scene?.dispose();\n },\n controller: {\n async animate(element, targets, options) {\n if (!scene) {\n const s = disposed ? null : host.surface(element);\n if (!s || !host.eligible(s))\n return false;\n await load();\n }\n return scene?.controller.animate(element, targets, options) ?? false;\n },\n async merge(element, distance, options) {\n if (!scene) {\n if (disposed || !host.group(element))\n return false;\n await load();\n }\n return scene?.controller.merge(element, distance, options) ?? false;\n },\n press(element, pressed) {\n scene?.controller.press(element, pressed);\n },\n pulse(element) {\n scene?.controller.pulse(element);\n },\n cancel(element) {\n scene?.controller.cancel(element);\n },\n inspect(element) {\n if (scene)\n return scene.controller.inspect(element);\n const s = host.surface(element);\n return (s && {\n enabled: s.motion.enabled,\n reduced: s.motion.reduced,\n managed: false,\n moving: false,\n pressed: false,\n hovered: false,\n focused: false,\n dragging: false,\n conflict: null,\n press: 0,\n glow: 0,\n x: 0,\n y: 0,\n scale: 1,\n morph: null,\n velocity: { x: 0, y: 0, scale: 0 },\n });\n },\n stats: () => scene?.controller.stats() ?? AT_REST,\n },\n };\n}\n//# sourceMappingURL=motion-loader.js.map","// Glass controller: the surface registry and scene engine (BUILD_AND_DISTRIBUTION.md section 8, D-46, D-56,\n// D-63, D-64). One observer set per document; mutation records and events only mark work as pending, and one\n// pass per frame (the core frame scheduler; a task while the page is hidden) processes it. The cost of a pass is\n// proportional to the inserted subtrees and the registered surfaces, never to the document size.\n//\n// A surface is upgraded to an engine layer only while CSS draws its glass material (D-56), its quality is above\n// `lite`, it is visible, its backdrop is a ready declared source (B1) that it lies over completely, its scroll\n// relationship to that source keeps them aligned (D-54), and a backend is ready. Every other surface keeps the\n// CSS material. Layers drawn from a source are removed synchronously when the source becomes invalid.\n//\n// Geometry (D-76): every layer draws shapes (shape.ts). A surface's shape is its border box with its computed\n// radii and corner exponent, or, while it morphs, an interpolation from its morph origin shape. The members of a\n// glass group (`data-glass-group`) that would each get a layer over the same source are drawn together on one\n// shared layer on the group element, as one smooth union; their CSS material is hidden meanwhile\n// (`data-abgin-shared`), and shown again before they are measured.\n//\n// Coordinates (D-78): rectangles and shapes are in viewport CSS px, as the DOM reports them (transforms and zoom\n// included); lengths of computed styles are in the element's own CSS px and are multiplied by its scale; layers are\n// styled in the own CSS px of the element they are in, and drawn in device px.\n//\n// Motion (D-79): the motion scene (motion-scene.ts) advances its springs at the start of a pass; the pass then draws\n// what changed in the same frame. A frame is requested only while something moves.\n//\n// Layout (D-81): anything on the page can move a surface without touching it (inserted content, a sibling's size, a\n// loaded image). After any change, the position of every surface relative to its source is compared with the one it was\n// measured at; only a surface that moved is measured again. The comparison reads rectangles and requests no frame.\n//\n// Quality (D-84): `lite`, `balanced`, and `ultra` are what the document says. `auto` is `balanced`, and lower while\n// drawing it takes more than its frames allow (governor.ts): samples are taken from frames that are drawn anyway.\nimport { MEDIA, readPrefix, resolve } from \"@abgin/core/config\";\nimport { createScope, isDisposedError, LifecycleDisposedError } from \"@abgin/core/lifecycle\";\nimport { createFrameScheduler } from \"@abgin/core/scheduler\";\nimport { backgroundSceneOf } from \"./background.js\";\nimport { createGovernor } from \"./governor.js\";\nimport { classify, createSampleCache, overSource } from \"./classify.js\";\nimport { containsFlat, FITS_ATTRIBUTE, HOSTLESS, isElement, isLayer, LAYER_ATTRIBUTE, MOTION_ATTRIBUTE, names, parentOf, prefixSelector, SHARED_ATTRIBUTE, } from \"./dom.js\";\nimport { animatesGeometry, animationMovesOthers, EMPTY_RECT, intersect, isUsableRect, keyframesMove, movesGeometry, movesOthers, regionInSource, scaleAgrees, SCROLLING, scrollRelation, STATE_COLOR_MIX, toRect, UNIT_SCALE, } from \"./geometry.js\";\nimport { createLayer, ensureAttached, placeLayer, placeLayerAt, removeLayer, resumeLayer, suspendLayer, } from \"./layers.js\";\nimport { MOTION_OFF, readMotion } from \"./motion-config.js\";\nimport { createLazyMotionScene } from \"./motion-loader.js\";\nimport { DEFAULT_OPTICS, readCorners, readOpticsTokens, resolveQuality, } from \"./optics.js\";\nimport { boxShape, CIRCULAR, deformShape, interpolateShape, MAX_SHAPES, mergeConstants, SHAPE_KINDS, shapeField, SQUIRCLE, } from \"./shape.js\";\nimport { createSourceRegistry, sourceInfo } from \"./sources.js\";\n/** Attributes the engine writes; their mutation records change no layout. */\nconst ENGINE_ATTRIBUTES = new Set([\n FITS_ATTRIBUTE,\n LAYER_ATTRIBUTE,\n MOTION_ATTRIBUTE,\n SHARED_ATTRIBUTE,\n]);\n/** Positions that differ by less are the same (layout units and scroll offsets are fractions of a pixel). */\nconst PLACE_TOLERANCE = 0.1;\n/** Layout comparisons outside a pass: at most `CHECKS` in `CHECK_WINDOW` milliseconds; a later one waits for a timer. */\nconst CHECKS = 4;\nconst CHECK_WINDOW = 16;\n/** Changed elements per batch that are tested for covering a surface's source. */\nconst MAX_COVER_CHECKS = 32;\n/** Frames a layout animation elsewhere is followed without any surface moving. */\nconst WATCH_FRAMES = 30;\n/** How long a backend waits for the motion chunk, in milliseconds. */\nconst MOTION_WAIT = 1000;\nconst ROLES = new Set([\"bar\", \"control\", \"overlay\", \"container\"]);\nconst EMPTY_SHAPE = boxShape(\"rect\", 0, 0, 0, 0);\nconst MEDIA_ATTRIBUTES = [\n \"src\",\n \"srcset\",\n \"sizes\",\n \"crossorigin\",\n \"referrerpolicy\",\n \"width\",\n \"height\",\n \"media\",\n \"type\",\n];\n/** Transitions of colors that respond to hover and press; they move nothing and the engine draws its own response. */\nfunction quietTransition(property) {\n return (property === STATE_COLOR_MIX ||\n /^(background-color|border(-(top|right|bottom|left))?-color|box-shadow|outline-color)$/.test(property));\n}\nexport function createController(options, hooks = {}) {\n const found = options.document ?? globalThis.document;\n if (!found?.documentElement)\n throw new TypeError(\"The glass controller needs a document.\");\n const doc = found;\n const view = (doc.defaultView ?? globalThis);\n const prefix = options.prefix ?? readPrefix(doc.documentElement);\n const N = names(prefix);\n // Containers are opaque content, and native controls have a CSS material only: nothing to observe. An explicit role still\n // makes a container a surface.\n const manifest = options.surfaces\n .filter((entry) => entry.role !== \"container\" && entry.layer !== false)\n .map((entry) => ({ selector: prefixSelector(entry.selector, prefix), role: entry.role }));\n const surfaceSelector = `:is(${[...manifest.map((m) => m.selector), `[${N.surface}]`].join(\", \")}):not(${HOSTLESS})`;\n const sourceSelector = `[${N.source}]`;\n const glassSelector = `[${N.appearance}=\"glass\"]`;\n const grace = options.gracePeriod ?? 2000;\n const descriptor = options.backend;\n const aboveLite = (quality) => quality !== \"lite\" && options.maxQuality !== \"lite\";\n const resolveOptions = { prefix };\n const scope = createScope();\n const surfaces = new Map();\n const groups = new Map();\n const explicitRoles = new Map();\n const roots = new Map();\n let nextSurfaceId = 1;\n let stopped = false;\n let paused = false;\n let lastDemand = null;\n const pending = {\n added: new Set(),\n config: new Set(),\n within: new Set(),\n candidates: new Set(),\n sourceChecks: new Set(),\n /** Sources whose presentation may have changed: re-read before measuring (D-73). */\n geometry: new Set(),\n removal: false,\n all: false,\n /** Something on the page changed: compare where the surfaces are (D-81). */\n layout: false,\n /** Elements that may have become visible between a surface and its source. */\n shown: new Set(),\n };\n const counters = { passes: 0, frames: 0, layers: 0, reinsertions: 0, lastPassMs: 0, maxPassMs: 0, error: \"\" };\n // Backend state (RENDERING_STRATEGY.md section 10): created lazily, released after the grace period.\n let backend = null;\n let backendState = \"none\";\n let backendError = \"\";\n let backendAttempt = null;\n let releaseTimer = null;\n let restoreUsed = false;\n // Adaptive quality of `auto` surfaces (D-84).\n const governor = createGovernor((level) => level !== \"economy\" || (view.devicePixelRatio || 1) > 1);\n let raiseTimer = null;\n /** The last pass asked for the next one: it is drawn one display interval later. */\n let consecutive = false;\n const scheduler = createFrameScheduler({\n request(callback) {\n counters.frames++;\n if (doc.hidden || typeof view.requestAnimationFrame !== \"function\") {\n return {\n timeout: view.setTimeout(() => {\n callback(performance.now());\n }, 0),\n };\n }\n return { frame: view.requestAnimationFrame(callback) };\n },\n cancel(handle) {\n const h = handle;\n if (h.timeout !== undefined)\n view.clearTimeout(h.timeout);\n if (h.frame !== undefined)\n view.cancelAnimationFrame(h.frame);\n },\n onError(error) {\n counters.error = error instanceof Error ? error.message : String(error);\n },\n });\n const schedule = () => {\n if (!stopped)\n scheduler.schedule(pass);\n };\n /** When the running pass started. */\n let passTime = 0;\n /** Changes made while the motion scene updates are drawn by the pass that runs it. */\n let updatingMotion = false;\n let checks = 0;\n let checkWindow = -Infinity;\n let checkTimer = null;\n /** Frames left to follow a layout animation elsewhere on the page. */\n let watching = 0;\n // One ResizeObserver for surfaces and sources. An element can be observed for more than one reason (a declared\n // picture and its declared <img>, or a surface that is also a source), so observation is reference-counted:\n // each owner releases its own reference and the element is unobserved when none is left.\n const resize = new view.ResizeObserver((entries) => {\n for (const entry of entries) {\n const s = surfaces.get(entry.target);\n if (s)\n staleSurface(s);\n else {\n // A source changed size: any surface may overlap it differently now, and those drawn from it are stale.\n pending.all = true;\n invalidateWithin(entry.target);\n }\n }\n schedule();\n });\n scope.track(resize);\n const sized = new Map();\n const sizeObserver = {\n observe(target) {\n const n = sized.get(target) ?? 0;\n sized.set(target, n + 1);\n if (n === 0)\n resize.observe(target);\n },\n unobserve(target) {\n const n = sized.get(target) ?? 0;\n if (n > 1)\n sized.set(target, n - 1);\n else if (n === 1) {\n sized.delete(target);\n resize.unobserve(target);\n }\n },\n };\n const sources = createSourceRegistry(doc, {\n changed(record, cause) {\n // Synchronous: a source that is no longer usable loses its layers before the next frame (D-63).\n if (record.state !== \"ready\") {\n backend?.releaseSource(record.id);\n for (const s of surfaces.values()) {\n if (s.source === record) {\n releaseLayer(s);\n s.source = null;\n s.path = \"css\";\n s.pathReason = `source-${record.state}`;\n }\n }\n }\n for (const s of surfaces.values()) {\n if (s.source === record || s.classification?.sourceId === record.id || cause === \"ready\")\n s.needsMeasure = true;\n }\n schedule();\n },\n frame(record) {\n renderSource(record);\n },\n }, sizeObserver, prefix);\n // Observers.\n const intersection = new view.IntersectionObserver((entries) => {\n for (const entry of entries) {\n const s = surfaces.get(entry.target);\n if (!s)\n continue;\n if (s.visible !== entry.isIntersecting) {\n s.visible = entry.isIntersecting;\n s.needsMeasure = true;\n }\n }\n schedule();\n }, { rootMargin: \"100px\" });\n scope.track(intersection);\n // Geometry invalidation (D-73). Layers hold pixels drawn for the geometry of the last measurement. A change that\n // can move or resize a surface or the image behind it makes the affected surfaces stale: their layers are hidden\n // at once (the CSS material shows) and they are re-measured in the next pass, which redraws them, or shows them\n // again unchanged when the geometry turns out to be the same. Observed: `style` and `class` changes of a surface,\n // a source, its media, or an ancestor of any of them; direction and theme changes; stylesheets inserted, removed,\n // edited as text, or loaded; size changes; CSS transitions and animations. Everything else needs `refresh()`.\n /** The engine's own last write to a surface's `style` attribute; the mutation record it causes is ignored. */\n const engineStyle = new WeakMap();\n const noteEngineStyle = (el) => {\n engineStyle.set(el, el.getAttribute(\"style\"));\n };\n const noteLayerStyle = (layer) => {\n if (!layer.wrote)\n return;\n layer.wrote = false;\n noteEngineStyle(layer.surface);\n };\n /** The layer of `s` may show pixels drawn for outdated geometry: hide it and re-measure. */\n function staleSurface(s) {\n s.needsMeasure = true;\n if (s.layer)\n suspendLayer(s.layer);\n const g = s.group;\n if (g?.layer && g.members.includes(s))\n suspendGroup(g);\n else if (s.shared)\n share(s, false);\n }\n /** Shows or hides the CSS material of a surface whose material the engine draws (D-76). */\n function share(s, on) {\n if (s.shared === on)\n return;\n s.shared = on;\n if (on)\n s.element.setAttribute(SHARED_ATTRIBUTE, \"\");\n else\n s.element.removeAttribute(SHARED_ATTRIBUTE);\n }\n /** Hides a group's shared layer; its members show their CSS material until it is drawn again. */\n function suspendGroup(g) {\n if (g.layer)\n suspendLayer(g.layer);\n for (const m of g.members)\n share(m, false);\n g.needsRender = true;\n }\n function groupFor(element) {\n let g = groups.get(element);\n if (!g) {\n g = {\n id: nextSurfaceId++,\n element,\n name: \"\",\n layer: null,\n members: [],\n rect: EMPTY_RECT,\n region: null,\n merge: { distance: 16, smoothness: 1 },\n mergeToken: null,\n motionConfig: MOTION_OFF,\n scale: UNIT_SCALE,\n needsRender: true,\n renderedVersion: -1,\n };\n groups.set(element, g);\n }\n return g;\n }\n function releaseGroupLayer(g) {\n for (const m of g.members)\n share(m, false);\n if (!g.layer)\n return;\n const layer = g.layer;\n g.layer = null;\n counters.layers--;\n try {\n backend?.removeSurface(g.id);\n }\n finally {\n removeLayer(layer);\n noteEngineStyle(g.element);\n }\n }\n /**\n * The presentation of `target` changed (style, class, direction, theme, an animation). Surfaces inside it and\n * surfaces over sources inside it become stale; the sources are re-read before the next measurement. Returns\n * whether anything was affected: an unrelated change costs containment checks and schedules nothing.\n */\n function invalidateWithin(target) {\n if (!target.isConnected)\n return false;\n const changed = new Set();\n for (const record of sources.all()) {\n if (containsFlat(target, record.media ?? record.element) || containsFlat(target, record.element)) {\n changed.add(record.id);\n pending.geometry.add(record);\n }\n }\n let affected = changed.size > 0;\n for (const s of surfaces.values()) {\n const sourceId = s.source?.id ?? s.classification?.sourceId;\n if (containsFlat(target, s.element) || (sourceId !== undefined && changed.has(sourceId))) {\n staleSurface(s);\n affected = true;\n }\n }\n return affected;\n }\n /** Something that can move anything changed (a stylesheet, or `refresh()` without an element). */\n function invalidateAll() {\n for (const s of surfaces.values())\n staleSurface(s);\n for (const record of sources.all())\n pending.geometry.add(record);\n }\n /** An authored mutation inside a surface can change its scene through an ancestor selector. */\n function invalidateBackgroundPaint(target, authoredMutation = false) {\n const owner = backgroundSceneOf(target, prefix);\n const modal = target.localName === \"dialog\";\n if (!owner && !modal)\n return false;\n let affected = false;\n for (const s of surfaces.values()) {\n if (s.needsMeasure || (!authoredMutation && containsFlat(s.element, target)))\n continue;\n const scene = backgroundSceneOf(s.element, prefix);\n if (!scene)\n continue;\n const related = owner && (containsFlat(scene, owner) || containsFlat(owner, scene));\n if (modal || related || (s.blocker && containsFlat(target, s.blocker))) {\n staleSurface(s);\n affected = true;\n }\n }\n return affected;\n }\n const STYLESHEETS = 'style, link[rel~=\"stylesheet\" i]';\n const hasStylesheet = (node) => node.matches(STYLESHEETS) || node.querySelector(STYLESHEETS) !== null;\n /** Attributes that need handling beyond layout and Background paint checks. */\n const attributeNames = new Set([\n N.appearance,\n N.quality,\n N.transparency,\n N.material,\n N.motion,\n N.theme,\n \"dir\",\n N.surface,\n N.source,\n N.group,\n N.merge,\n N.morph,\n N.shape,\n N.glassMotion,\n N.drag,\n \"class\",\n \"style\",\n \"open\",\n ...MEDIA_ATTRIBUTES,\n ]);\n const configAttributes = new Set([N.appearance, N.quality, N.transparency, N.material, N.motion, \"open\"]);\n function onMutations(records) {\n let relevant = false;\n let stylesheets = false;\n let layout = false;\n const presentation = new Set();\n const paint = new Set();\n for (const record of records) {\n const target = record.target;\n if (record.type === \"characterData\") {\n layout = true;\n const parent = target.parentElement;\n if (parent?.localName === \"style\")\n stylesheets = true;\n else if (parent && !isLayer(parent))\n paint.add(parent);\n continue;\n }\n if (record.type === \"attributes\" && !attributeNames.has(record.attributeName ?? \"\")) {\n if (ENGINE_ATTRIBUTES.has(record.attributeName ?? \"\") || isLayer(target))\n continue;\n layout = true;\n if (isElement(target)) {\n if (record.attributeName === \"hidden\")\n presentation.add(target);\n else if (backgroundSceneOf(target, prefix))\n paint.add(target);\n }\n continue;\n }\n if (isLayer(target))\n continue;\n if (record.type === \"childList\") {\n relevant = true;\n let authored = false;\n for (const node of record.addedNodes) {\n if (isLayer(node))\n continue;\n authored = true;\n layout = true;\n if (!isElement(node))\n continue;\n pending.added.add(node);\n if (hasStylesheet(node))\n stylesheets = true;\n }\n for (const node of record.removedNodes) {\n if (isLayer(node)) {\n const s = isElement(target) ? surfaces.get(target) : undefined;\n if (s)\n s.needsMeasure = true;\n continue;\n }\n authored = true;\n layout = true;\n if (isElement(node)) {\n pending.removal = true;\n if (hasStylesheet(node))\n stylesheets = true;\n }\n }\n if (isElement(target)) {\n if (authored)\n paint.add(target);\n // The text of a <style> element changed.\n if (target.localName === \"style\")\n stylesheets = true;\n sources.childrenChanged(target);\n }\n continue;\n }\n const name = record.attributeName ?? \"\";\n if (!isElement(target))\n continue;\n if (name === \"style\" || name === \"class\") {\n const value = target.getAttribute(name);\n // The same value written again, and the engine's own surface styles, change nothing.\n if (record.oldValue === value)\n continue;\n if (name === \"style\") {\n if (engineStyle.has(target) && engineStyle.get(target) === value)\n continue;\n // The author's value now: a later return to what the engine wrote is a change of its own.\n engineStyle.delete(target);\n }\n layout = true;\n presentation.add(target);\n // The engine may be moving this element: the author's values compose with its own (D-82).\n const s = surfaces.get(target);\n if (s)\n scene.authored(s);\n // A style change matters only through the surfaces it affects; a class change can also make an element a\n // surface (candidates, below).\n if (name === \"style\")\n continue;\n }\n else if (name === \"open\" || backgroundSceneOf(target, prefix))\n paint.add(target);\n relevant = true;\n if (configAttributes.has(name)) {\n pending.config.add(target);\n // Details can move a surface before the browser dispatches toggle.\n if (name === \"open\" && target.localName === \"details\")\n layout = true;\n // The CSS changes now (for example glass to standard): layers below must not outlive this task.\n for (const s of surfaces.values()) {\n if (s.layer && containsFlat(target, s.element)) {\n releaseLayer(s);\n s.path = \"css\";\n s.pathReason = \"reconfiguring\";\n }\n }\n }\n else if (name === N.theme ||\n name === \"dir\" ||\n name === N.group ||\n name === N.merge ||\n name === N.morph ||\n name === N.shape ||\n name === N.glassMotion ||\n name === N.drag) {\n pending.within.add(target);\n presentation.add(target);\n }\n else if (name === N.surface || name === \"class\")\n pending.candidates.add(target);\n else if (name === N.source) {\n pending.sourceChecks.add(target);\n const source = sources.get(target);\n if (source?.element === target && sources.isBackgroundImage(source) && !target.hasAttribute(N.source))\n sources.unregister(target, \"undeclared\");\n }\n // Media attribute changes invalidate a registered source synchronously (no stale frame).\n sources.attributeChanged(target, name);\n }\n let checked = 0;\n for (const target of presentation) {\n if (invalidateWithin(target))\n relevant = true;\n // It may lie between a surface and its source now. Bounded: a batch that changes more elements is an animation\n // or a rendering of its own, and the layout comparison below still covers what it moves.\n else if (checked++ < MAX_COVER_CHECKS && coversSurface(target)) {\n pending.shown.add(target);\n relevant = true;\n }\n paint.add(target);\n }\n for (const target of paint)\n if (invalidateBackgroundPaint(target, true))\n relevant = true;\n if (stylesheets) {\n invalidateAll();\n relevant = true;\n }\n // A removed source is released now, before any further frame could show its pixels. A node removed and\n // re-inserted by the same task is connected again here, so it keeps its registration.\n if (pending.removal)\n sources.checkConnected();\n if (layout)\n checkLayout();\n if (!relevant)\n return;\n // After \"no demand\", any change may bring demand back: say so at once, so a pending idle stop is cancelled\n // before the next pass has measured. The pass then reports the real value.\n if (lastDemand === false) {\n lastDemand = null;\n hooks.onDemand?.(true);\n }\n schedule();\n }\n // Layout changes elsewhere (D-81).\n /** Whether a scroll container has something to scroll. The layer is no content, but overflows by the border and its pad. */\n function overflows(s) {\n const el = s.element;\n const slack = s.layer ? 2 * Math.max(s.borderLeft, s.borderTop) + s.pad + 1 : 1;\n return el.scrollHeight - el.clientHeight > slack || el.scrollWidth - el.clientWidth > slack;\n }\n /** Whether the surface is somewhere else than it was measured: relative to its source, or (not drawn) on the page. */\n function hasMoved(s, boxes) {\n const p = s.place;\n if (!p)\n return false;\n const r = s.element.getBoundingClientRect();\n const differs = (a, b) => Math.abs(a - b) > PLACE_TOLERANCE;\n if (s.scroller && overflows(s) !== s.scrolls)\n return true;\n if (differs(r.width, p.surface.width) || differs(r.height, p.surface.height))\n return true;\n if (p.media && (s.path === \"layer\" || s.path === \"group\")) {\n // A drawn surface scrolls with its source (D-54), so its place relative to the source does not depend on scrolling.\n let m = boxes.get(p.media);\n if (!m)\n boxes.set(p.media, (m = p.media.getBoundingClientRect()));\n return (differs(r.left - m.left, p.surface.x - p.mediaRect.x) ||\n differs(r.top - m.top, p.surface.y - p.mediaRect.y) ||\n differs(m.width, p.mediaRect.width) ||\n differs(m.height, p.mediaRect.height));\n }\n if (view.scrollX !== p.scrollX || view.scrollY !== p.scrollY)\n return false;\n return differs(r.left, p.surface.x) || differs(r.top, p.surface.y);\n }\n /** The element that hid the source from a surface is gone, hidden, or elsewhere. */\n function unblocked(s) {\n if (!s.blocker)\n return false;\n if (!s.blocker.isConnected)\n return true;\n return !overlaps(s.blocker, toRect(s.element.getBoundingClientRect()));\n }\n /**\n * Compares the place of every visible surface with the one it was measured at. `hide`: outside a frame, the pixels\n * of a surface that moved must not be shown again before they are drawn. Returns whether any of them moved.\n */\n function comparePlaces(hide) {\n let moved = false;\n const boxes = new Map();\n for (const s of surfaces.values()) {\n if (!s.visible || s.needsMeasure || s.needsGeometry || !s.place)\n continue;\n if (!hasMoved(s, boxes) && !unblocked(s))\n continue;\n moved = true;\n if (hide)\n staleSurface(s);\n else {\n s.needsMeasure = true;\n s.followed = true;\n }\n }\n return moved;\n }\n /** Something on the page changed. Reads rectangles now, within a budget; requests a frame only if a surface moved. */\n function checkLayout() {\n if (stopped || doc.hidden || !surfaces.size)\n return;\n const now = performance.now();\n if (now - checkWindow >= CHECK_WINDOW) {\n checkWindow = now;\n checks = 0;\n }\n // A pass in this frame compares as well.\n pending.layout = true;\n if (checks >= CHECKS) {\n checkTimer ??= view.setTimeout(() => {\n checkTimer = null;\n checkLayout();\n }, CHECK_WINDOW);\n return;\n }\n checks++;\n if (comparePlaces(true))\n schedule();\n }\n /** A transition or animation elsewhere can move surfaces in every frame: follow it while they move. */\n function watchLayout() {\n for (const s of surfaces.values()) {\n if (s.path !== \"layer\" && s.path !== \"group\")\n continue;\n watching = WATCH_FRAMES;\n pending.layout = true;\n schedule();\n return;\n }\n }\n const overlaps = (el, rect) => intersect(toRect(el.getBoundingClientRect()), rect).width > 0;\n /** The drawn surfaces that `el` overlaps without containing them or being their source. */\n function overlapped(el) {\n if (!el.isConnected || isLayer(el))\n return [];\n const found = [];\n for (const s of surfaces.values()) {\n if (s.needsMeasure || (s.path !== \"layer\" && s.path !== \"group\"))\n continue;\n if (el === s.source?.element || containsFlat(el, s.element) || containsFlat(s.element, el))\n continue;\n if (overlaps(el, toRect(s.element.getBoundingClientRect())))\n found.push(s);\n }\n return found;\n }\n const coversSurface = (el) => overlapped(el).length > 0;\n /** Elements that appeared may lie between a surface and its source: classify the surfaces they overlap again. */\n function reclassifyUnder(elements) {\n for (const el of elements)\n for (const s of overlapped(el))\n s.needsMeasure = true;\n }\n let listenTransitions = null;\n function observeRoot(root) {\n if (roots.has(root))\n return;\n if (root !== doc)\n listenTransitions?.(root);\n const observer = new view.MutationObserver(onMutations);\n observer.observe(root === doc ? doc.documentElement : root, {\n childList: true,\n subtree: true,\n // Every attribute and text change: any of them can move a surface (D-81).\n attributes: true,\n characterData: true,\n // Old values let equivalent `style` and `class` writes be ignored.\n attributeOldValue: true,\n });\n roots.set(root, observer);\n scope.track(observer);\n discoverSources(root);\n discoverRegions(root);\n }\n // Discovery and registration.\n function roleOf(element) {\n if (element.matches(HOSTLESS))\n return null;\n const explicit = element.getAttribute(N.surface);\n if (explicit !== null)\n return ROLES.has(explicit) ? explicit : null;\n for (const entry of manifest)\n if (element.matches(entry.selector))\n return entry.role;\n return null;\n }\n function evaluateCandidate(element) {\n if (!isElement(element) || isLayer(element) || !(\"style\" in element))\n return;\n const el = element;\n const existing = surfaces.get(el);\n if (!el.isConnected) {\n if (existing)\n unregisterSurface(existing);\n return;\n }\n const explicit = explicitRoles.get(el);\n const role = explicit ?? roleOf(el);\n const glass = explicit !== undefined || resolve(el, resolveOptions).appearance === \"glass\";\n if (!role || !glass) {\n if (existing)\n unregisterSurface(existing);\n return;\n }\n if (existing) {\n existing.role = role;\n existing.needsMeasure = true;\n return;\n }\n const s = {\n id: nextSurfaceId++,\n element: el,\n role,\n materialActive: false,\n quality: \"auto\",\n reducedTransparency: false,\n visible: false,\n rect: EMPTY_RECT,\n place: null,\n scroller: false,\n scrolls: false,\n blocker: null,\n evidence: null,\n followed: false,\n unsettled: false,\n scale: UNIT_SCALE,\n translation: UNIT_SCALE,\n borderLeft: 0,\n borderTop: 0,\n position: \"\",\n dpr: 1,\n fill: \"\",\n classification: null,\n scroll: \"unknown\",\n transformsOk: true,\n cornersOk: true,\n transitioning: false,\n geometryAnimating: false,\n source: null,\n region: null,\n visibleRegion: null,\n material: \"\",\n radii: [0, 0, 0, 0],\n opticalQuality: \"balanced\",\n optics: DEFAULT_OPTICS,\n opticsReading: null,\n designFill: \"\",\n labelColor: \"\",\n path: \"css\",\n pathReason: \"pending\",\n layer: null,\n renderedVersion: -1,\n needsMeasure: true,\n needsGeometry: false,\n needsRender: false,\n quiet: false,\n quietRead: false,\n motion: MOTION_OFF,\n deformation: null,\n glow: 0,\n pointer: null,\n pad: 0,\n exponent: CIRCULAR,\n morph: null,\n morphProgress: 1,\n morphOverride: null,\n rest: EMPTY_SHAPE,\n shape: EMPTY_SHAPE,\n group: null,\n mergeOff: false,\n shared: false,\n };\n surfaces.set(el, s);\n intersection.observe(el);\n sizeObserver.observe(el);\n }\n function unregisterSurface(s) {\n scene.release(s);\n // A member leaving a group: hide the shared layer at once, so its shape is not shown without it.\n if (s.group?.layer && s.group.members.includes(s))\n suspendGroup(s.group);\n share(s, false);\n releaseLayer(s);\n intersection.unobserve(s.element);\n sizeObserver.unobserve(s.element);\n surfaces.delete(s.element);\n }\n /** Surfaces inside `container` (inclusive) that are in a glass region. */\n function discoverWithin(container) {\n if (isElement(container) && container.matches(surfaceSelector))\n evaluateCandidate(container);\n for (const el of container.querySelectorAll(surfaceSelector))\n evaluateCandidate(el);\n }\n function discoverRegions(root) {\n // Only glass regions are searched; a shadow root inherits the appearance of its host.\n const host = \"host\" in root ? root.host : null;\n if (host && resolve(host, resolveOptions).appearance === \"glass\") {\n discoverWithin(root);\n return;\n }\n for (const region of root.querySelectorAll(glassSelector))\n discoverWithin(region);\n }\n function discoverAdded(el) {\n if (el.matches(sourceSelector) || el.querySelector(sourceSelector))\n discoverSources(el);\n if (resolve(el, resolveOptions).appearance === \"glass\")\n discoverWithin(el);\n else\n for (const region of el.querySelectorAll(glassSelector))\n discoverWithin(region);\n }\n function discoverSources(container) {\n if (isElement(container) && container.matches(sourceSelector))\n registerSource(container);\n for (const el of container.querySelectorAll(sourceSelector))\n registerSource(el);\n }\n /** The registry observes the source's size itself and stops on every release path. */\n function registerSource(el) {\n if (sources.get(el))\n return;\n sources.register(el);\n pending.all = true;\n }\n function releaseLayer(s) {\n if (!s.group?.members.includes(s))\n share(s, false);\n if (!s.layer)\n return;\n const layer = s.layer;\n s.layer = null;\n s.pad = 0;\n counters.layers--;\n if (s.scroller)\n s.element.removeAttribute(FITS_ATTRIBUTE);\n // Measured with the engine's `position: relative`, which goes with the layer.\n if (layer.savedPosition !== null)\n s.position = \"static\";\n try {\n backend?.removeSurface(s.id);\n }\n finally {\n removeLayer(layer);\n noteEngineStyle(s.element);\n }\n }\n // Backend lifecycle.\n const host = {\n lost(reason) {\n if (!backend)\n return;\n backendError = reason;\n disposeBackend(\"context-lost\");\n if (restoreUsed)\n backendState = \"lost\";\n else {\n restoreUsed = true;\n backendState = \"none\";\n }\n for (const s of surfaces.values())\n s.needsMeasure = true;\n schedule();\n },\n redraw(sourceId) {\n const record = sources.byId(sourceId);\n if (record?.state === \"ready\")\n renderSource(record);\n },\n get groups() {\n const seen = new Set();\n for (const s of surfaces.values()) {\n if (!s.group || s.mergeOff)\n continue;\n if (seen.has(s.group))\n return true;\n seen.add(s.group);\n }\n return false;\n },\n };\n /** The backend that was asked for shapes; each is asked at most once, so a failure is not retried. */\n let prepared = null;\n /** A group needs shapes the backend cannot draw yet. Its members keep their own layers until it can (D-76). */\n function prepareShapes(instance) {\n if (prepared === instance || !instance.prepareShapes)\n return;\n prepared = instance;\n instance.prepareShapes().then(() => {\n if (backend === instance && !stopped)\n schedule();\n }, () => {\n // The members keep their own layers: complete glass, without merging.\n });\n }\n function motionWanted() {\n for (const s of surfaces.values())\n if (s.materialActive && s.motion.enabled)\n return true;\n return false;\n }\n function ensureBackend() {\n if (releaseTimer !== null) {\n view.clearTimeout(releaseTimer);\n releaseTimer = null;\n }\n if (!descriptor || backendState !== \"none\")\n return;\n if (!descriptor.supported()) {\n backendState = \"failed\";\n backendError = \"unsupported\";\n schedule();\n return;\n }\n backendState = \"loading\";\n const attempt = scope.child();\n backendAttempt = attempt;\n attempt\n .settle(async (signal) => {\n // Motion is part of what is shown: it is loaded along with the backend, not after the first frame. Glass does\n // not wait for it for long.\n const [factory] = await Promise.all([\n descriptor.load(),\n motionWanted()\n ? Promise.race([scene.load(), new Promise((resolve) => view.setTimeout(resolve, MOTION_WAIT))])\n : null,\n ]);\n // Cancelled while the module loaded (for example the source was removed): create nothing.\n if (signal.aborted)\n throw new LifecycleDisposedError(\"The backend is no longer needed.\");\n const instance = factory();\n try {\n await instance.init(host);\n }\n catch (error) {\n instance.dispose();\n throw error;\n }\n return instance;\n }, {\n discard: (instance) => {\n instance.dispose();\n },\n })\n .then((instance) => {\n backendAttempt = null;\n attempt.dispose();\n backend = instance;\n backendState = \"ready\";\n for (const s of surfaces.values())\n s.needsRender = true;\n schedule();\n }, (error) => {\n if (isDisposedError(error))\n return;\n backendAttempt = null;\n attempt.dispose();\n backendState = \"failed\";\n backendError = error instanceof Error ? error.message : String(error);\n schedule();\n });\n }\n /** Releases the backend; surfaces that lose their layer show the CSS material and report `reason`. */\n function disposeBackend(reason = \"backend-released\") {\n backendAttempt?.dispose();\n backendAttempt = null;\n for (const g of groups.values()) {\n for (const m of g.members) {\n m.path = \"css\";\n m.pathReason = reason;\n }\n releaseGroupLayer(g);\n g.members = [];\n }\n for (const s of surfaces.values()) {\n if (!s.layer)\n continue;\n releaseLayer(s);\n s.path = \"css\";\n s.pathReason = reason;\n }\n const instance = backend;\n backend = null;\n prepared = null;\n if (backendState === \"ready\" || backendState === \"loading\")\n backendState = \"none\";\n instance?.dispose();\n }\n function scheduleRelease() {\n if (releaseTimer !== null || (!backend && backendState !== \"loading\"))\n return;\n releaseTimer = view.setTimeout(() => {\n releaseTimer = null;\n if (!stopped && !layerDemand())\n disposeBackend();\n }, grace);\n }\n // Motion (D-79).\n const motionHost = {\n document: doc,\n scope,\n surface: (element) => surfaces.get(element) ?? null,\n group: (element) => groups.get(element) ?? null,\n eligible: (s) => !stopped &&\n s.motion.enabled &&\n s.materialActive &&\n aboveLite(s.quality) &&\n !s.reducedTransparency &&\n backendState === \"ready\",\n drawn: (s) => s.path === \"layer\" || s.path === \"group\",\n control: (s) => s.role === \"control\",\n translationScale: (s) => s.translation,\n progress: (s) => progressOf(s),\n mergeConfig: (g) => ({ distance: g.mergeToken ?? g.merge.distance, motion: g.motionConfig }),\n reshape(s) {\n updateShape(s);\n s.needsRender = true;\n requestPass();\n },\n relight(s) {\n s.needsRender = true;\n requestPass();\n },\n moved(s, settling) {\n // An authored transition now moves it there: nothing is drawn until it ends (D-82).\n if (settling)\n staleSurface(s);\n else\n s.needsGeometry = true;\n requestPass();\n },\n remorph(s) {\n updateShape(s);\n s.needsRender = true;\n requestPass();\n },\n remerge(g) {\n g.needsRender = true;\n requestPass();\n },\n wrote: noteEngineStyle,\n request: requestPass,\n };\n const scene = createLazyMotionScene(motionHost, (error) => {\n counters.error = error instanceof Error ? error.message : String(error);\n });\n function requestPass() {\n if (!updatingMotion)\n schedule();\n }\n // Adaptive quality (D-84).\n /** Device px per CSS px a surface is drawn with: fewer than the display's while `auto` is at `economy`. */\n function resolutionOf(s, dpr) {\n return s.quality === \"auto\" && governor.level === \"economy\" ? Math.max(Math.min(dpr, 1), dpr / 2) : dpr;\n }\n /** Reports a drawn frame; `time` is when it started. */\n function sampleFrame(time, cpu, chained, drawn) {\n if (!backend?.backlog)\n return;\n for (const s of drawn) {\n if (s.quality !== \"auto\")\n continue;\n if (governor.sample({ time, cpu, consecutive: chained, backlog: backend.backlog() }))\n levelChanged();\n return;\n }\n }\n /** Every surface is measured for the new level in the next pass, which redraws it or shows its CSS material. */\n function levelChanged() {\n pending.all = true;\n schedule();\n armRaise();\n }\n /** One timer for the next attempt to raise the level; none while it is at its highest. */\n function armRaise() {\n if (raiseTimer !== null)\n view.clearTimeout(raiseTimer);\n raiseTimer = null;\n const { raiseAt } = governor;\n if (raiseAt === null)\n return;\n raiseTimer = view.setTimeout(() => {\n raiseTimer = null;\n if (stopped)\n return;\n if (governor.raise(performance.now()))\n levelChanged();\n else\n armRaise();\n }, Math.max(0, raiseAt - performance.now()) + 1);\n }\n // Measurement and decisions.\n function measure(s, viewport, cache, dpr, animations) {\n const el = s.element;\n // What the layer was last drawn for: if the new measurement is the same, its pixels are still valid.\n const before = { source: s.source, region: s.region, width: s.rect.width, height: s.rect.height, dpr: s.dpr };\n const beforeFill = s.fill;\n const beforeMaterial = s.material;\n const wasDrawn = s.path === \"layer\" || s.path === \"group\";\n const followed = wasDrawn && s.followed;\n s.needsMeasure = false;\n s.needsGeometry = false;\n s.followed = false;\n s.unsettled = false;\n s.needsRender = true;\n s.geometryAnimating = false;\n // Geometry declarations (D-76): the glass group, merge participation, and the morph origin kind.\n const groupElement = el.parentElement?.closest(`[${N.group}]`) ?? null;\n // A surface with a material has its own layer; one that is declared a container has none.\n const host = groupElement ? surfaces.get(groupElement) : undefined;\n s.group = groupElement && (!host || host.role === \"container\") ? groupFor(groupElement) : null;\n if (s.group)\n s.group.name = groupElement?.getAttribute(N.group) ?? \"\";\n s.mergeOff = el.closest(`[${N.merge}]`)?.getAttribute(N.merge) === \"off\";\n const morphKind = el.getAttribute(N.morph);\n const style = getComputedStyle(el);\n // A surface whose material the engine draws (group member, morph) ignores transitions that move nothing: its CSS\n // material is hidden and the engine's fill is not transitioned. Others show the CSS material meanwhile (D-61).\n const ownsMaterial = s.group !== null || morphKind !== null;\n const config = resolve(el, { prefix, media: cache.matches });\n s.motion = readMotion(style, { reduced: config.reducedMotion, drag: el.getAttribute(N.drag) });\n const own = el.getAnimations();\n s.transitioning = own.some((a) => \"transitionProperty\" in a &&\n a.playState === \"running\" &&\n (!ownsMaterial || movesGeometry(a.transitionProperty)) &&\n // Hover and press colors: the engine shows the response itself (D-79).\n !(s.quiet && quietTransition(a.transitionProperty)));\n if (s.quiet)\n s.quietRead = true;\n s.quality = config.quality;\n s.reducedTransparency = config.reducedTransparency;\n const filter = style.backdropFilter || style.getPropertyValue(\"-webkit-backdrop-filter\");\n s.materialActive = Boolean(filter) && filter !== \"none\";\n s.rect = toRect(el.getBoundingClientRect());\n s.borderLeft = Number.parseFloat(style.borderLeftWidth) || 0;\n s.borderTop = Number.parseFloat(style.borderTopWidth) || 0;\n s.scroller = el.hasAttribute(FITS_ATTRIBUTE) || SCROLLING.test(style.overflowX) || SCROLLING.test(style.overflowY);\n s.scrolls = s.scroller && overflows(s);\n s.position = style.position;\n s.dpr = resolutionOf(s, dpr);\n s.fill = style.backgroundColor;\n s.source = null;\n s.region = null;\n s.place = null;\n s.blocker = null;\n s.scroll = \"unknown\";\n if (!s.materialActive || !aboveLite(s.quality) || s.reducedTransparency || !s.visible) {\n s.classification = null;\n s.evidence = null;\n return;\n }\n const record = measureBox(s, style, viewport, cache, followed);\n // Read through a function: `measureBox()` sets it, which control-flow narrowing ignores.\n const region = (() => s.region)();\n if (!record?.media || !region)\n return;\n const media = record.media;\n // Transitions of the surface itself are covered by `transitioning`; its keyframe animations, its ancestors, the\n // media, and the media's ancestors here.\n s.geometryAnimating =\n keyframesMove(own) || animatesGeometry(parentOf(el), animations) || animatesGeometry(media, animations);\n s.scroll = scrollRelation(cache.anchor(el), cache.anchor(media));\n // Material inputs of GPU backends (D-74): tokens, shape, label color, and the design fill without the\n // legibility floor. Read here, with the other measurements, never during a transition (D-61).\n s.opticalQuality = resolveQuality(s.quality, options.maxQuality);\n s.opticsReading = readOpticsTokens(style, s.opticsReading);\n s.optics = s.opticsReading.optics;\n s.labelColor = style.color;\n s.designFill = style.getPropertyValue(\"--ab-private-glass-fill\").trim() || s.fill;\n s.morph = readMorph(morphKind, style);\n const progress = Number.parseFloat(style.getPropertyValue(\"--ab-glass-morph-progress\"));\n const shown = progressOf(s);\n const token = Number.isFinite(progress) ? Math.min(1, Math.max(0, progress)) : 1;\n const changed = token !== s.morphProgress;\n s.morphProgress = token;\n if (s.morph && changed && s.morphOverride === null) {\n // A changed token moves there from the shape on screen; without motion, or before the first frame, it applies.\n if (wasDrawn && s.motion.enabled && s.motion.morph)\n scene.morphTo(s, shown, token);\n else\n scene.stopMorph(s);\n }\n updateShape(s);\n const material = materialKey(s);\n const r = before.region;\n if (before.source === record &&\n r?.x === region.x &&\n r.y === region.y &&\n r.width === region.width &&\n r.height === region.height &&\n before.width === s.rect.width &&\n before.height === s.rect.height &&\n before.dpr === s.dpr &&\n beforeFill === s.fill &&\n beforeMaterial === material)\n s.needsRender = false;\n s.material = material;\n }\n /**\n * The surface's box and scale, its corners, its backdrop, and the part of the source behind it: everything that\n * changes when it moves. Sets `s.source` and `s.region` when the surface lies over a usable source, and returns the\n * source. `moving`: the surface only moved, in consecutive passes, so samples of the last ones may be used (D-83).\n */\n function measureBox(s, style, viewport, cache, moving) {\n const el = s.element;\n s.source = null;\n s.region = null;\n s.scale = cache.scale(el);\n const parent = parentOf(el);\n const outer = parent ? cache.scale(parent) : UNIT_SCALE;\n const zoom = Number.parseFloat(style.zoom ?? \"\") || 1;\n s.translation = { x: outer.x * zoom, y: outer.y * zoom };\n s.transformsOk = s.scale.ok && scaleAgrees(s.rect, el.offsetWidth, el.offsetHeight, s.scale);\n // The corners CSS renders are the geometry reference; what the field cannot represent keeps the CSS material.\n const corners = readCorners(style, s.rect.width, s.rect.height, s.scale.x, s.scale.y);\n s.cornersOk = corners.supported;\n s.radii = corners.radii;\n s.exponent = corners.exponent;\n const outline = restShape(s);\n cache.blockers.delete(el);\n const reuse = {\n pass: counters.passes,\n time: passTime,\n previous: moving ? s.evidence : null,\n next: null,\n partial: false,\n };\n // Behind a modal dialog nothing can be hit: what is drawn stays drawn, at the place it is measured to have now (D-96).\n const drawn = s.path !== \"css\" && s.classification?.class === \"B1\" ? s.classification : null;\n const classification = drawn?.sourceId !== undefined &&\n drawn.reason !== \"background-source\" &&\n cache.modal() &&\n !el.closest(\"dialog:modal\")\n ? overSource(s.rect, drawn, drawn.sourceId, sources, cache)\n : classify(el, s.rect, viewport, sources, cache, (x, y) => shapeField(x, y, outline).d, reuse);\n s.classification = classification;\n s.evidence = reuse.next;\n s.unsettled = reuse.partial;\n const at = { surface: s.rect, scrollX: view.scrollX, scrollY: view.scrollY };\n s.place = { ...at, media: null, mediaRect: EMPTY_RECT };\n // Remembered only if its box overlaps: otherwise the box cannot say when it no longer does.\n const blocker = classification.class === \"B1\" ? undefined : cache.blockers.get(el);\n s.blocker = blocker && overlaps(blocker, s.rect) ? blocker : null;\n if (classification.class !== \"B1\" || classification.sourceId === undefined)\n return null;\n const record = sources.byId(classification.sourceId);\n if (!record?.media)\n return null;\n const media = record.media;\n const { rect: mediaRect, scale: mediaScale, image } = cache.media(record);\n s.place = { ...at, media, mediaRect };\n if (!mediaScale.ok || !scaleAgrees(mediaRect, media.offsetWidth, media.offsetHeight, mediaScale))\n s.transformsOk = false;\n const region = image && regionInSource(s.rect, image.drawn, record.width, record.height);\n const visible = image && regionInSource(image.visible, image.drawn, record.width, record.height);\n if (!region || !visible) {\n // Unsupported object-position or non-finite values: keep the CSS material rather than guess.\n s.classification = { class: \"B0\", reason: \"geometry-unsupported\", sourceId: record.id };\n return null;\n }\n s.source = record;\n s.region = region;\n s.visibleRegion = visible;\n return record;\n }\n /** The engine moved or scaled the element (D-79): its box is read again; its material, read at rest, is kept. */\n function remeasure(s, viewport, cache) {\n const { rect, region, material } = s;\n s.needsGeometry = false;\n s.rect = toRect(s.element.getBoundingClientRect());\n measureBox(s, getComputedStyle(s.element), viewport, cache, true);\n updateShape(s);\n s.material = materialKey(s);\n const same = rect.width === s.rect.width &&\n rect.height === s.rect.height &&\n region?.x === s.region?.x &&\n region?.y === s.region?.y &&\n region?.width === s.region?.width &&\n region?.height === s.region?.height &&\n material === s.material;\n if (!same)\n s.needsRender = true;\n }\n /** Geometric mean of a scale: CSS lengths without a direction (blur, bevel, merge distance) are multiplied by it. */\n function lengthScale(scale) {\n return Math.sqrt(scale.x * scale.y);\n }\n /** Everything besides the border box that changes a layer's pixels. */\n function materialKey(s) {\n return JSON.stringify([\n s.opticalQuality,\n s.opticsReading?.text,\n s.radii,\n s.labelColor,\n s.designFill,\n s.visibleRegion,\n s.shape,\n s.scale,\n ]);\n }\n /** Reads the morph origin (`data-glass-morph` and the `--ab-glass-morph-*` tokens); invalid values disable it. */\n function readMorph(kind, style) {\n if (kind === null || !SHAPE_KINDS.includes(kind))\n return null;\n const length = (name) => {\n const v = style.getPropertyValue(name).trim();\n const n = Number.parseFloat(v);\n return /px$/.test(v) && Number.isFinite(n) && n >= 0 ? n : null;\n };\n // Logical alignment: start, center, end (inline, then block); start follows the surface's direction.\n const words = style.getPropertyValue(\"--ab-glass-morph-align\").trim().toLowerCase().split(/\\s+/);\n const rtl = style.direction === \"rtl\";\n const axis = (word, inline) => {\n if (word === \"start\")\n return inline && rtl ? 1 : 0;\n if (word === \"end\")\n return inline && rtl ? 0 : 1;\n if (word === (inline ? \"left\" : \"top\"))\n return 0;\n if (word === (inline ? \"right\" : \"bottom\"))\n return 1;\n return 0.5;\n };\n return {\n kind: kind,\n width: length(\"--ab-glass-morph-width\"),\n height: length(\"--ab-glass-morph-height\"),\n radius: length(\"--ab-glass-morph-radius\"),\n x: axis(words[0], true),\n y: axis(words[1], false),\n };\n }\n /** The morph progress in use: `morph()` first, then the token; 1 without a morph origin. */\n function progressOf(s) {\n return s.morph ? (s.morphOverride ?? scene.morph(s) ?? s.morphProgress) : 1;\n }\n /** The surface's own shape: its border box with its computed corners (border-box CSS px). */\n function restShape(s) {\n const { width, height } = s.rect;\n return boxShape(s.exponent > CIRCULAR ? \"squircle\" : \"rect\", 0, 0, width, height, s.radii, s.exponent);\n }\n /** Recomputes the surface's own shape and the shape drawn now: own, morphing, or deformed (border-box viewport px). */\n function updateShape(s) {\n s.rest = restShape(s);\n const base = morphedShape(s);\n const d = s.deformation;\n s.shape = d ? deformShape(base, { ...d, maxInset: d.maxInset * lengthScale(s.scale) }) : base;\n }\n function morphedShape(s) {\n const w = s.rect.width;\n const h = s.rect.height;\n const t = progressOf(s);\n const m = s.morph;\n if (!m || t >= 1)\n return s.rest;\n // The origin box lies inside the border box; the morph never leaves the surface's own layer. Without a size a\n // circle is a square of the shorter side, aligned like any origin; other shapes take the whole box.\n const side = Math.min(w, h);\n const fw = Math.min(w, m.width === null ? (m.kind === \"circle\" ? side : w) : m.width * s.scale.x);\n const fh = Math.min(h, m.height === null ? (m.kind === \"circle\" ? side : h) : m.height * s.scale.y);\n const r = m.radius === null ? null : m.radius * lengthScale(s.scale);\n const radii = r === null ? s.rest.radii : [r, r, r, r];\n const origin = boxShape(m.kind, (w - fw) * m.x, (h - fh) * m.y, fw, fh, radii, m.kind === \"squircle\" ? SQUIRCLE : CIRCULAR);\n return interpolateShape(origin, s.rest, t);\n }\n /** The shape kind of a surface for diagnostics, from its geometry. */\n function kindOf(s) {\n const shape = s.shape;\n if (shape.exponent > CIRCULAR + 1e-6)\n return \"squircle\";\n const r = Math.min(...shape.radii);\n if (r >= Math.min(shape.hw, shape.hh) - 0.25)\n return Math.abs(shape.hw - shape.hh) < 0.25 ? \"circle\" : \"capsule\";\n return \"rect\";\n }\n /** The path a surface should take now, and why. `backend-loading` surfaces count as demand. */\n function decide(s) {\n const css = (reason) => ({ path: \"css\", reason });\n if (!s.materialActive)\n return css(\"css-material-inactive\");\n if (!aboveLite(s.quality))\n return css(\"quality-lite\");\n if (s.reducedTransparency)\n return css(\"reduced-transparency\");\n if (s.quality === \"auto\" && governor.level === \"lite\")\n return css(\"adaptive-lite\");\n if (doc.hidden || paused)\n return css(\"document-hidden\");\n if (!s.visible)\n return css(\"offscreen\");\n // Values read during a CSS transition are intermediate; the CSS material animates until it ends (D-61).\n if (s.transitioning)\n return css(\"transition\");\n if (!descriptor)\n return css(\"no-backend\");\n // Before the backdrop: a rotated box also misses some of its samples, which says nothing about the backdrop.\n if (!s.transformsOk)\n return css(\"transform-unsupported\");\n const cls = s.classification;\n if (!cls || cls.class !== \"B1\")\n return css(`backdrop-${(cls?.class ?? \"b0\").toLowerCase()}:${cls?.reason ?? \"unclassified\"}`);\n if (!s.source || s.source.state !== \"ready\")\n return css(`source-${s.source?.state ?? \"missing\"}`);\n // A GPU silhouette that differs from the CSS shape is never shown (D-77).\n if (!s.cornersOk)\n return css(\"corner-geometry-unsupported\");\n // Measured geometry would be outdated within a frame (D-73).\n if (s.geometryAnimating)\n return css(\"geometry-animating\");\n if (s.scroll !== \"together\")\n return css(\"scroll-independent\");\n if (cls.reason === \"background-source\" && overflowOf(s) > 0.01)\n return css(\"background-shape-overflow\");\n // A layer is a child of its surface: it would scroll away with the content.\n if (s.scrolls)\n return css(\"surface-scrolls\");\n if (backendState === \"failed\")\n return css(\"backend-failed\");\n if (backendState === \"lost\")\n return css(\"context-lost\");\n if (backendState !== \"ready\")\n return css(\"backend-loading\");\n return { path: \"layer\", reason: \"layer\" };\n }\n function layerDemand() {\n for (const s of surfaces.values()) {\n const d = decide(s);\n if (d.path === \"layer\" || d.reason === \"backend-loading\")\n return true;\n }\n return false;\n }\n function backendSurface(s) {\n const record = s.source;\n const layer = s.layer;\n // The last check before a backend: never pass non-finite or empty geometry.\n if (!record ||\n record.state !== \"ready\" ||\n !layer ||\n !s.region ||\n !isUsableRect(s.region) ||\n !s.visibleRegion ||\n !(layer.pixelWidth > 0 && layer.pixelHeight > 0) ||\n !record.media ||\n record.kind === \"uniform\" ||\n record.kind === \"unsupported\")\n return null;\n // The surface's own shape matches the layer's pixel size. The other shapes scale to the same coordinate space.\n const pw = layer.pixelWidth;\n const ph = layer.pixelHeight;\n const sh = s.shape;\n const { pad } = s;\n const w = Math.max(s.rect.width, 1e-6);\n const h = Math.max(s.rect.height, 1e-6);\n const sx = pw / (w + 2 * pad);\n const sy = ph / (h + 2 * pad);\n const shape = {\n ...shapeInputs(s),\n box: sh === s.rest && pad === 0\n ? [pw / 2, ph / 2, pw / 2, ph / 2]\n : [(sh.cx + pad) * sx, (sh.cy + pad) * sy, sh.hw * sx, sh.hh * sy],\n radii: [sh.radii[0] * s.dpr, sh.radii[1] * s.dpr, sh.radii[2] * s.dpr, sh.radii[3] * s.dpr],\n exponent: sh.exponent,\n };\n return {\n id: s.id,\n element: s.element,\n layer: layer.canvas,\n pixelWidth: pw,\n pixelHeight: ph,\n source: backendSource(record, record.media),\n region: pad === 0\n ? s.region\n : {\n x: s.region.x - (pad * s.region.width) / w,\n y: s.region.y - (pad * s.region.height) / h,\n width: (s.region.width * (w + 2 * pad)) / w,\n height: (s.region.height * (h + 2 * pad)) / h,\n },\n fill: s.fill,\n visible: s.visibleRegion,\n dpr: s.dpr * lengthScale(s.scale),\n radii: s.radii.map((r) => r / lengthScale(s.scale)),\n quality: s.opticalQuality,\n optics: s.optics,\n designFill: s.designFill,\n labelColor: s.labelColor,\n shapes: [shape],\n ...pointerIn(s, { x: s.rect.x - pad, y: s.rect.y - pad }, s.dpr),\n };\n }\n /** The pointer's light on a layer whose origin is at `origin` (viewport px). */\n function pointerIn(s, origin, k) {\n if (!s.pointer || s.glow <= 0)\n return {};\n const radius = Math.min(140, Math.max(24, Math.max(s.rect.width, s.rect.height) * 0.5));\n return { pointer: { x: (s.pointer.x - origin.x) * k, y: (s.pointer.y - origin.y) * k, radius: radius * k } };\n }\n /** How far the drawn shape leaves the surface's border box, in viewport px. */\n function overflowOf(s) {\n const { cx, cy, hw, hh } = s.shape;\n return Math.max(0, hw - cx, hh - cy, cx + hw - s.rect.width, cy + hh - s.rect.height);\n }\n function backendSource(record, media) {\n return {\n id: record.id,\n kind: record.kind,\n element: media,\n version: record.version,\n width: record.width,\n height: record.height,\n };\n }\n /** The per-shape material inputs of a surface. */\n function shapeInputs(s) {\n return {\n id: s.id,\n element: s.element,\n region: s.region,\n fill: s.fill,\n designFill: s.designFill,\n labelColor: s.labelColor,\n optics: s.optics,\n glow: s.glow,\n };\n }\n /** The backend view of a group's shared layer: every member's shape, offset into the layer (D-76). */\n function backendGroup(g) {\n const first = g.members[0];\n const record = first?.source;\n const layer = g.layer;\n if (!first ||\n !record ||\n record.state !== \"ready\" ||\n !record.media ||\n record.kind === \"uniform\" ||\n record.kind === \"unsupported\" ||\n !layer ||\n !g.region ||\n !isUsableRect(g.region) ||\n !first.visibleRegion ||\n !(layer.pixelWidth > 0 && layer.pixelHeight > 0) ||\n g.members.some((m) => m.source !== record || !m.region))\n return null;\n const sx = layer.pixelWidth / Math.max(g.rect.width, 1e-6);\n const sy = layer.pixelHeight / Math.max(g.rect.height, 1e-6);\n const pointed = g.members.find((m) => m.pointer && m.glow > 0);\n const shapes = g.members.map((m) => {\n const sh = m.shape;\n const dx = m.rect.x - g.rect.x;\n const dy = m.rect.y - g.rect.y;\n return {\n ...shapeInputs(m),\n box: [(sh.cx + dx) * sx, (sh.cy + dy) * sy, sh.hw * sx, sh.hh * sy],\n radii: [sh.radii[0] * sx, sh.radii[1] * sx, sh.radii[2] * sx, sh.radii[3] * sx],\n exponent: sh.exponent,\n };\n });\n return {\n id: g.id,\n element: g.element,\n layer: layer.canvas,\n pixelWidth: layer.pixelWidth,\n pixelHeight: layer.pixelHeight,\n source: backendSource(record, record.media),\n region: g.region,\n fill: first.fill,\n visible: first.visibleRegion,\n dpr: first.dpr * lengthScale(first.scale),\n radii: [0, 0, 0, 0],\n quality: first.opticalQuality,\n optics: first.optics,\n designFill: first.designFill,\n labelColor: first.labelColor,\n shapes,\n merge: mergeConstants({\n distance: g.merge.distance * lengthScale(g.scale) * sx,\n smoothness: g.merge.smoothness,\n }),\n ...(pointed ? pointerIn(pointed, g.rect, sx) : {}),\n };\n }\n function draw(list, groupList = []) {\n if (!backend || (!list.length && !groupList.length))\n return;\n const batch = [];\n const drawn = [];\n const drawnGroups = [];\n for (const s of list) {\n const item = backendSurface(s);\n if (!item)\n continue;\n batch.push(item);\n drawn.push(s);\n }\n for (const g of groupList) {\n const item = backendGroup(g);\n if (!item)\n continue;\n batch.push(item);\n drawnGroups.push(g);\n }\n if (!batch.length)\n return;\n try {\n backend.render(batch);\n for (const s of list) {\n s.needsRender = false;\n s.renderedVersion = s.source?.version ?? -1;\n }\n for (const s of drawn) {\n if (s.layer?.suspended)\n resumeLayer(s.layer);\n // A morph that differs from the surface's own shape hides the CSS material (it would show around it).\n share(s, s.shape !== s.rest);\n }\n for (const g of drawnGroups) {\n g.needsRender = false;\n g.renderedVersion = g.members[0]?.source?.version ?? -1;\n for (const m of g.members) {\n m.needsRender = false;\n m.renderedVersion = g.renderedVersion;\n }\n if (g.layer?.suspended)\n resumeLayer(g.layer);\n for (const m of g.members)\n share(m, true);\n }\n }\n catch (error) {\n backendError = error instanceof Error ? error.message : String(error);\n disposeBackend(\"backend-failed\");\n backendState = \"failed\";\n schedule();\n }\n }\n /** Redraws layers fed by `record` at once (video frames, canvas invalidation): same frame, no measurement. */\n function renderSource(record) {\n if (stopped || !backend)\n return;\n const list = [];\n for (const s of surfaces.values())\n if (s.source === record && s.layer && !s.layer.suspended && s.path === \"layer\")\n list.push(s);\n const groupList = [];\n for (const g of groups.values())\n if (g.layer && !g.layer.suspended && g.members[0]?.source === record)\n groupList.push(g);\n const started = performance.now();\n draw(list, groupList);\n const drawn = [...list, ...groupList.flatMap((g) => g.members)];\n sampleFrame(started, performance.now() - started, false, drawn);\n }\n /**\n * The members each group draws on its shared layer this pass (D-76): surfaces that would get their own layer,\n * take part in merging, and lie over the group's most common source; at least two, at most MAX_SHAPES, in\n * document order. Reads the group element's merge tokens.\n */\n function planGroups(cache) {\n const plans = new Map();\n const instance = backend;\n if (!instance || (!instance.shapes && !instance.prepareShapes))\n return plans;\n const candidates = new Map();\n for (const s of surfaces.values()) {\n if (!s.group || s.mergeOff || !s.source || decide(s).path !== \"layer\")\n continue;\n // The merged field can paint between the individually verified Background surfaces.\n if (s.classification?.reason === \"background-source\")\n continue;\n const list = candidates.get(s.group) ?? [];\n list.push(s);\n candidates.set(s.group, list);\n }\n for (const [g, list] of candidates) {\n if (!g.element.isConnected)\n continue;\n const bySource = new Map();\n for (const s of list) {\n const same = bySource.get(s.source) ?? [];\n same.push(s);\n bySource.set(s.source, same);\n }\n let best = [];\n for (const same of bySource.values())\n if (same.length > best.length)\n best = same;\n if (best.length < 2)\n continue;\n if (!instance.shapes) {\n prepareShapes(instance);\n return plans;\n }\n best.sort((a, b) => (a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));\n const style = getComputedStyle(g.element);\n const distance = Number.parseFloat(style.getPropertyValue(\"--ab-glass-merge-distance\"));\n const smoothness = Number.parseFloat(style.getPropertyValue(\"--ab-glass-merge-smoothness\"));\n g.scale = cache.scale(g.element);\n g.motionConfig = readMotion(style, { reduced: resolve(g.element, resolveOptions).reducedMotion, drag: null });\n const token = Number.isFinite(distance) ? Math.min(128, Math.max(0, distance)) : 16;\n if (g.mergeToken !== null && g.mergeToken !== token) {\n // A changed token moves there from the distance on screen; without motion, or before a layer, it applies.\n if (g.layer && g.motionConfig.enabled && g.motionConfig.merge)\n scene.mergeTo(g, g.merge.distance, token);\n else\n scene.release(g);\n }\n g.mergeToken = token;\n g.merge = {\n distance: Math.max(0, scene.merge(g) ?? token),\n smoothness: Number.isFinite(smoothness) ? Math.min(1, Math.max(0, smoothness)) : 1,\n };\n plans.set(g, best.slice(0, MAX_SHAPES));\n }\n return plans;\n }\n // The pass.\n function pass(time) {\n if (stopped)\n return;\n const chained = consecutive;\n const started = performance.now();\n passTime = started;\n counters.passes++;\n updatingMotion = true;\n try {\n scene.update(time);\n }\n finally {\n updatingMotion = false;\n }\n if (pending.removal) {\n pending.removal = false;\n sources.checkConnected();\n for (const s of [...surfaces.values()])\n if (!s.element.isConnected)\n unregisterSurface(s);\n for (const [root, observer] of roots) {\n if (root !== doc && !root.host.isConnected) {\n observer.disconnect();\n roots.delete(root);\n }\n }\n }\n for (const el of pending.sourceChecks) {\n if (el.isConnected && el.hasAttribute(N.source))\n registerSource(el);\n else if (sources.get(el))\n sources.unregister(el, \"undeclared\");\n }\n for (const el of pending.added)\n if (el.isConnected)\n discoverAdded(el);\n sources.refreshImages();\n for (const el of pending.config) {\n if (!el.isConnected)\n continue;\n for (const s of [...surfaces.values()])\n if (containsFlat(el, s.element))\n evaluateCandidate(s.element);\n discoverAdded(el);\n }\n for (const el of pending.within)\n for (const s of surfaces.values())\n if (containsFlat(el, s.element))\n s.needsMeasure = true;\n for (const el of pending.candidates) {\n evaluateCandidate(el);\n const s = surfaces.get(el);\n if (s)\n s.needsMeasure = true;\n }\n if (pending.all)\n for (const s of surfaces.values())\n s.needsMeasure = true;\n for (const record of pending.geometry) {\n if (record.state === \"disposed\")\n continue;\n sources.presentationChanged(record);\n // The source may now lie under surfaces that were not over it before.\n const el = record.media ?? record.element;\n if (!el.isConnected)\n continue;\n const box = toRect(el.getBoundingClientRect());\n for (const s of surfaces.values())\n if (!s.needsMeasure && intersect(s.rect, box).width > 0)\n s.needsMeasure = true;\n }\n reclassifyUnder(pending.added);\n reclassifyUnder(pending.shown);\n pending.shown.clear();\n const compare = pending.layout;\n pending.layout = false;\n let moved = false;\n if (compare)\n moved = comparePlaces(false);\n for (const s of surfaces.values()) {\n if (!s.unsettled || s.needsMeasure || s.needsGeometry)\n continue;\n // It rests: all of its samples are taken again.\n s.evidence = null;\n s.needsGeometry = true;\n }\n pending.geometry.clear();\n pending.added.clear();\n pending.config.clear();\n pending.within.clear();\n pending.candidates.clear();\n pending.sourceChecks.clear();\n pending.all = false;\n // A group is measured as a whole, so its members' rectangles come from the same layout. The CSS material of\n // surfaces whose material the engine draws is shown again first, so the measurement reads it as authored.\n for (const g of groups.values()) {\n if (g.members.some((m) => m.needsMeasure))\n for (const m of g.members)\n m.needsMeasure = true;\n }\n for (const s of surfaces.values())\n if (s.needsMeasure && s.shared)\n staleSurface(s);\n // Reads first: every measurement of the pass, then every write.\n const viewport = {\n x: 0,\n y: 0,\n width: doc.documentElement.clientWidth || view.innerWidth,\n height: doc.documentElement.clientHeight || view.innerHeight,\n };\n const cache = createSampleCache(prefix, viewport);\n const animations = new Map();\n const dpr = view.devicePixelRatio || 1;\n for (const s of surfaces.values()) {\n if (s.needsMeasure)\n measure(s, viewport, cache, dpr, animations);\n else if (s.needsGeometry) {\n // A moving surface that is drawn keeps its material; any other is measured as a whole.\n if (s.path === \"layer\" || s.path === \"group\")\n remeasure(s, viewport, cache);\n else\n measure(s, viewport, cache, dpr, animations);\n }\n }\n const plans = planGroups(cache);\n const grouped = new Set();\n for (const members of plans.values())\n for (const m of members)\n grouped.add(m);\n let demandLayers = false;\n let resumed = false;\n const render = [];\n for (const s of surfaces.values()) {\n const decision = grouped.has(s) ? { path: \"group\", reason: \"group\" } : decide(s);\n s.path = decision.path;\n s.pathReason = decision.reason;\n if (decision.reason === \"backend-loading\")\n demandLayers = true;\n if (decision.path === \"group\") {\n // Drawn on the group's shared layer; its own layer (if any) goes.\n demandLayers = true;\n if (s.layer) {\n releaseLayer(s);\n s.needsRender = true;\n }\n continue;\n }\n if (decision.path !== \"layer\") {\n releaseLayer(s);\n s.needsRender = false; // the CSS material needs no rendering\n continue;\n }\n demandLayers = true;\n if (!s.layer) {\n s.layer = createLayer(s.element, s.position);\n counters.layers++;\n s.element.toggleAttribute(FITS_ATTRIBUTE, s.scroller);\n s.needsRender = true;\n }\n else if (ensureAttached(s.layer, s.position)) {\n counters.reinsertions++;\n s.needsRender = true;\n }\n noteLayerStyle(s.layer);\n // The layer grows with a deformation, in steps, and returns to the border box when the motion ends.\n const overflow = overflowOf(s);\n const wanted = overflow > 0.02 ? Math.ceil((overflow + 1) / 8) * 8 : 0;\n const pad = s.deformation ? Math.max(s.pad, wanted) : wanted;\n if (pad !== s.pad) {\n s.pad = pad;\n s.needsRender = true;\n }\n if (placeLayer(s.layer, s.rect, s.scale, s.borderLeft, s.borderTop, s.dpr, s.pad))\n s.needsRender = true;\n if (s.needsRender || s.renderedVersion !== s.source?.version)\n render.push(s);\n else if (s.layer.suspended) {\n // Re-measured after an invalidation and nothing changed: the pixels are still valid.\n resumeLayer(s.layer);\n resumed = true;\n }\n }\n // Groups: the shared layer covers the members plus the furthest a junction can bulge (half the merge distance).\n const renderGroups = [];\n for (const g of [...groups.values()]) {\n const members = plans.get(g) ?? [];\n const inUse = [...surfaces.values()].some((s) => s.group === g);\n if (members.length < 2 || !g.element.isConnected) {\n if (g.layer || g.members.length) {\n releaseGroupLayer(g);\n for (const m of g.members)\n if (!grouped.has(m))\n m.needsRender = true;\n g.members = [];\n }\n if (!inUse) {\n scene.release(g);\n groups.delete(g.element);\n }\n continue;\n }\n if (members.length !== g.members.length || members.some((m, i) => m !== g.members[i])) {\n for (const m of g.members)\n if (!members.includes(m))\n share(m, false);\n g.needsRender = true;\n }\n g.members = members;\n const first = members[0];\n // While the distance is animated the layer covers the larger of both ends, so it is not resized every frame.\n const reach = Math.max(g.merge.distance, g.mergeToken ?? 0) * lengthScale(g.scale);\n let pad = reach / 2 + 2;\n for (const m of members)\n pad = Math.max(pad, reach / 2 + 2 + overflowOf(m));\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const m of members) {\n x0 = Math.min(x0, m.rect.x);\n y0 = Math.min(y0, m.rect.y);\n x1 = Math.max(x1, m.rect.x + m.rect.width);\n y1 = Math.max(y1, m.rect.y + m.rect.height);\n }\n let box = { x: x0 - pad, y: y0 - pad, width: x1 - x0 + pad * 2, height: y1 - y0 + pad * 2 };\n if (members.some((m) => scene.moving(m) || m.deformation)) {\n // Members in motion: the layer's edges move in steps of 16 px, so its bitmap is rarely reallocated.\n const step = 16;\n const x = Math.floor(box.x / step) * step;\n const y = Math.floor(box.y / step) * step;\n box = {\n x,\n y,\n width: Math.ceil((box.x + box.width) / step) * step - x,\n height: Math.ceil((box.y + box.height) / step) * step - y,\n };\n }\n if (!g.layer) {\n g.layer = createLayer(g.element, \"\", true);\n counters.layers++;\n g.needsRender = true;\n }\n else if (ensureAttached(g.layer, \"\")) {\n counters.reinsertions++;\n g.needsRender = true;\n }\n noteLayerStyle(g.layer);\n if (placeLayerAt(g.layer, box, g.scale, first.dpr))\n g.needsRender = true;\n if (box.x !== g.rect.x || box.y !== g.rect.y || box.width !== g.rect.width || box.height !== g.rect.height)\n g.needsRender = true;\n g.rect = box;\n // The layer's rectangle in source pixels, from the first member's mapping (all share the source and its fit).\n const r = first.region;\n const ksx = r.width / Math.max(first.rect.width, 1e-6);\n const ksy = r.height / Math.max(first.rect.height, 1e-6);\n g.region = {\n x: r.x + (box.x - first.rect.x) * ksx,\n y: r.y + (box.y - first.rect.y) * ksy,\n width: box.width * ksx,\n height: box.height * ksy,\n };\n if (members.some((m) => m.needsRender) || g.renderedVersion !== first.source?.version)\n g.needsRender = true;\n if (g.needsRender)\n renderGroups.push(g);\n else if (g.layer.suspended) {\n resumeLayer(g.layer);\n for (const m of members)\n share(m, true);\n resumed = true;\n }\n }\n if (demandLayers)\n ensureBackend();\n else if (backendState === \"loading\")\n disposeBackend(); // nothing was ready yet: cancel instead of waiting\n else\n scheduleRelease();\n for (const s of render)\n if (s.layer?.suspended)\n resumed = true;\n for (const g of renderGroups)\n if (g.layer?.suspended)\n resumed = true;\n draw(render, renderGroups);\n // After layers were shown again, look once more in the next frame: a change made later in this frame (by an\n // animation frame callback that runs after this one) is then measured before that frame is painted, instead\n // of one frame later. Nothing is scheduled once a frame passes without such a change.\n if (resumed)\n schedule();\n // Video frames only while a visible layer shows the video and the page is visible.\n for (const record of sources.all()) {\n if (record.kind !== \"video\")\n continue;\n let wanted = false;\n if (!doc.hidden && !paused)\n for (const s of surfaces.values())\n if (s.source === record && (s.path === \"layer\" || s.path === \"group\"))\n wanted = true;\n sources.setFramesWanted(record, wanted);\n }\n const demand = [...surfaces.values()].some((s) => s.materialActive && aboveLite(s.quality) && !s.reducedTransparency);\n if (demand !== lastDemand) {\n lastDemand = demand;\n hooks.onDemand?.(demand);\n }\n scene.sync(surfaces.values());\n if (scene.active || [...surfaces.values()].some((s) => s.unsettled))\n schedule();\n if (compare && watching > 0) {\n watching = moved ? WATCH_FRAMES : watching - 1;\n if (watching > 0) {\n pending.layout = true;\n schedule();\n }\n }\n consecutive = scene.active || watching > 0;\n counters.lastPassMs = performance.now() - started;\n counters.maxPassMs = Math.max(counters.maxPassMs, counters.lastPassMs);\n if (render.length || renderGroups.length)\n sampleFrame(time, counters.lastPassMs, chained, [...render, ...renderGroups.flatMap((g) => g.members)]);\n }\n // Document-level listeners (one each).\n const markAll = () => {\n pending.all = true;\n schedule();\n };\n const viewportChanged = () => {\n sources.refreshImages();\n for (const s of surfaces.values())\n if (s.classification?.reason === \"background-source\")\n staleSurface(s);\n markAll();\n };\n let scrollTimer = null;\n const scrollSettled = () => {\n if (scrollTimer !== null)\n view.clearTimeout(scrollTimer);\n scrollTimer = null;\n // Layered surfaces scroll with their source; only the others can see different content now.\n for (const s of surfaces.values())\n if (s.path !== \"layer\")\n s.needsMeasure = true;\n schedule();\n };\n const onScroll = (event) => {\n const target = event.target;\n let affected = false;\n for (const s of surfaces.values()) {\n if (s.needsMeasure || s.classification?.reason !== \"background-source\")\n continue;\n if (isElement(target) && !containsFlat(target, s.element))\n continue;\n // The source and surface move together, but a viewport or scroll clip can narrow the visible crop.\n staleSurface(s);\n affected = true;\n }\n if (affected)\n schedule();\n if (scrollTimer !== null)\n view.clearTimeout(scrollTimer);\n scrollTimer = view.setTimeout(scrollSettled, 150);\n };\n scope.listen(view, \"resize\", viewportChanged);\n if (view.visualViewport)\n scope.listen(view.visualViewport, \"resize\", viewportChanged);\n scope.listen(doc, \"visibilitychange\", () => {\n // Nothing is animated in the background: motion ends on its targets, and no frames run until the page returns.\n if (doc.hidden)\n scene.finish();\n markAll();\n });\n // Transitions of a surface's own properties (BUILD_AND_DISTRIBUTION.md section 8.3, geometry row). Events from\n // a shadow tree reach the document retargeted to the host, so the real target is taken from the composed path,\n // and observed shadow roots get the same listeners (closed roots hide their path).\n const onTransition = (event) => {\n const target = event.composedPath()[0] ?? event.target;\n if (!isElement(target) || isLayer(target))\n return;\n // It can also move surfaces outside the element (D-81): follow it, and compare once more when it ends.\n const starts = event.type === \"transitionrun\" || event.type === \"animationstart\";\n if (event.type.startsWith(\"transition\") && !movesOthers(event.propertyName)) {\n // Only the element itself moves, or nothing.\n }\n else if (!starts)\n checkLayout();\n else if (event.type === \"transitionrun\" || animationMovesOthers(target))\n watchLayout();\n const s = surfaces.get(target);\n if (invalidateBackgroundPaint(target))\n schedule();\n if (!s) {\n // A transition or animation of another element matters when it can move a surface or a source (D-73): the\n // affected surfaces are re-measured when it starts (the CSS material shows while it runs) and when it ends.\n if (event.type.startsWith(\"transition\") && !movesGeometry(event.propertyName))\n return;\n if (invalidateWithin(target))\n schedule();\n return;\n }\n // The engine draws the material of a group member or a morphing surface; a transition that moves nothing\n // (a hover color) does not change what it draws (D-76).\n if (event.type.startsWith(\"transition\") &&\n (s.group !== null || s.morph !== null) &&\n !movesGeometry(event.propertyName))\n return;\n // Hover and press colors of a drawn surface with motion: the engine shows the response itself (D-79). A change of\n // the configuration, theme, or class has invalidated the surface before its transition starts; D-61 applies to it.\n if (event.type.startsWith(\"transition\") && quietTransition(event.propertyName)) {\n if (event.type !== \"transitionrun\") {\n if (s.quiet) {\n s.quiet = false;\n if (s.quietRead) {\n s.quietRead = false;\n s.needsMeasure = true;\n schedule();\n }\n return;\n }\n }\n else if (s.motion.enabled &&\n (s.path === \"layer\" || s.path === \"group\") &&\n !s.needsMeasure &&\n s.layer?.suspended !== true) {\n s.quiet = true;\n return;\n }\n s.quiet = false;\n }\n if (event.type === \"transitionrun\") {\n s.transitioning = true;\n if (s.group?.layer && s.group.members.includes(s))\n suspendGroup(s.group);\n if (s.layer) {\n releaseLayer(s);\n s.path = \"css\";\n s.pathReason = \"transition\";\n }\n }\n else\n s.needsMeasure = true;\n schedule();\n };\n // A <link> stylesheet applies when it loads; `load` does not bubble, so it is captured.\n const onLoad = (event) => {\n const target = event.target;\n if (isElement(target) && target.localName === \"link\" && /\\bstylesheet\\b/i.test(target.getAttribute(\"rel\") ?? \"\")) {\n invalidateAll();\n schedule();\n }\n else\n checkLayout(); // an image or a frame that loaded may have a size now\n };\n listenTransitions = (root) => {\n for (const type of [\n \"transitionrun\",\n \"transitionend\",\n \"transitioncancel\",\n \"animationstart\",\n \"animationend\",\n \"animationcancel\",\n ]) {\n scope.listen(root, type, onTransition, { capture: true, passive: true });\n }\n scope.listen(root, \"load\", onLoad, { capture: true, passive: true });\n scope.listen(root, \"scroll\", onScroll, { capture: true, passive: true });\n scope.listen(root, \"scrollend\", scrollSettled, { capture: true, passive: true });\n };\n listenTransitions(doc);\n scope.listen(view, \"pagehide\", () => {\n paused = true;\n markAll();\n });\n scope.listen(view, \"pageshow\", () => {\n paused = false;\n pending.removal = true;\n markAll();\n });\n scope.listen(doc, \"toggle\", (event) => {\n if (isElement(event.target)) {\n pending.config.add(event.target);\n invalidateBackgroundPaint(event.target);\n }\n checkLayout();\n schedule();\n }, { capture: true });\n // States that change the layout without a mutation: form values, focus, and hover styles (D-81). Pointer events are\n // frequent, so the comparison is throttled and costs one rectangle per visible surface.\n const onBackgroundState = (event) => {\n const target = event.composedPath()[0] ?? event.target;\n const owner = isElement(target) && backgroundSceneOf(target, prefix);\n if (owner && invalidateBackgroundPaint(owner))\n schedule();\n };\n const onLayoutState = (event) => {\n onBackgroundState(event);\n checkLayout();\n };\n for (const type of [\"input\", \"change\", \"focusin\", \"focusout\", \"pointerover\"])\n scope.listen(doc, type, onLayoutState, { capture: true, passive: true });\n for (const type of [\"pointerout\", \"pointerdown\", \"pointerup\"])\n scope.listen(doc, type, onBackgroundState, { capture: true, passive: true });\n if (\"fonts\" in doc)\n scope.listen(doc.fonts, \"loadingdone\", checkLayout);\n for (const query of [\n MEDIA.reducedTransparency,\n MEDIA.moreContrast,\n MEDIA.forcedColors,\n MEDIA.reducedMotion,\n MEDIA.dark,\n ]) {\n scope.listen(view.matchMedia(query), \"change\", markAll);\n }\n let resolution = null;\n const watchResolution = () => {\n resolution?.dispose();\n resolution = scope.child();\n resolution.listen(view.matchMedia(`(resolution: ${view.devicePixelRatio || 1}dppx)`), \"change\", () => {\n watchResolution();\n viewportChanged();\n });\n };\n watchResolution();\n scope.onDispose(() => {\n if (scrollTimer !== null)\n view.clearTimeout(scrollTimer);\n if (releaseTimer !== null)\n view.clearTimeout(releaseTimer);\n if (checkTimer !== null)\n view.clearTimeout(checkTimer);\n if (raiseTimer !== null)\n view.clearTimeout(raiseTimer);\n });\n observeRoot(doc);\n schedule();\n const info = (s) => ({\n element: s.element,\n role: s.role,\n materialActive: s.materialActive,\n quality: s.quality,\n visible: s.visible,\n classification: s.classification,\n scroll: s.scroll,\n path: s.path,\n pathReason: s.pathReason,\n rect: s.rect,\n shape: { kind: kindOf(s), exponent: s.shape.exponent, morph: progressOf(s) },\n group: s.group ? s.group.name : null,\n scale: { x: s.scale.x, y: s.scale.y },\n });\n return {\n attach(element, role) {\n if (stopped || !ROLES.has(role))\n return;\n explicitRoles.set(element, role);\n evaluateCandidate(element);\n schedule();\n },\n detach(element) {\n explicitRoles.delete(element);\n const s = surfaces.get(element);\n if (s)\n unregisterSurface(s);\n schedule();\n },\n observe(root) {\n if (stopped)\n return;\n observeRoot(root);\n schedule();\n },\n invalidateSource(element) {\n if (stopped)\n return;\n sources.invalidate(element, \"explicit\");\n },\n refresh(element) {\n if (stopped)\n return;\n if (element)\n invalidateWithin(element);\n else\n invalidateAll();\n schedule();\n },\n morph(element, progress) {\n if (stopped)\n return;\n const s = surfaces.get(element);\n if (!s)\n return;\n // Clamped to 0..1; a non-finite value is ignored.\n if (progress !== null && !Number.isFinite(progress))\n return;\n const value = progress === null ? null : Math.min(1, Math.max(0, progress));\n const before = progressOf(s);\n // The progress is set directly: an animation of it ends.\n scene.stopMorph(s);\n s.morphOverride = value;\n if (progressOf(s) === before)\n return;\n updateShape(s);\n s.material = materialKey(s);\n s.needsRender = true;\n schedule();\n },\n motion: scene.controller,\n inspect(element) {\n const s = surfaces.get(element);\n return s ? info(s) : null;\n },\n sources: () => sources.all().map(sourceInfo),\n stats() {\n let layered = 0;\n let visible = 0;\n let dirty = 0;\n let grouped = 0;\n for (const s of surfaces.values()) {\n if (s.layer)\n layered++;\n if (s.path === \"group\")\n grouped++;\n if (s.visible)\n visible++;\n if (s.needsMeasure || s.needsRender)\n dirty++;\n }\n return {\n surfaces: surfaces.size,\n layered,\n visible,\n dirty,\n sources: sources.all().length,\n grouped,\n groups: [...groups.values()].filter((g) => g.layer).length,\n passes: counters.passes,\n framesRequested: counters.frames,\n invalidations: sources.invalidations,\n layers: counters.layers,\n layerReinsertions: counters.reinsertions,\n backend: {\n name: descriptor?.name ?? \"css\",\n state: backendState,\n resources: backend?.resources ?? 0,\n error: backendError || counters.error,\n },\n adaptive: { level: governor.level, changes: governor.changes, reason: governor.reason },\n lastPassMs: counters.lastPassMs,\n maxPassMs: counters.maxPassMs,\n };\n },\n get stopped() {\n return stopped;\n },\n stop() {\n if (stopped)\n return;\n stopped = true;\n const errors = [];\n const attempt = (work) => {\n try {\n work();\n }\n catch (error) {\n errors.push(error);\n }\n };\n attempt(() => {\n scheduler.dispose();\n });\n attempt(() => {\n scene.dispose();\n });\n for (const s of [...surfaces.values()])\n attempt(() => {\n unregisterSurface(s);\n });\n for (const g of [...groups.values()])\n attempt(() => {\n releaseGroupLayer(g);\n g.members = [];\n });\n groups.clear();\n attempt(() => {\n disposeBackend(\"stopped\");\n });\n backendState = \"none\";\n attempt(() => {\n sources.dispose();\n });\n attempt(() => {\n scope.dispose();\n });\n surfaces.clear();\n explicitRoles.clear();\n roots.clear();\n sized.clear();\n attempt(() => {\n hooks.onStop?.();\n });\n if (errors.length)\n throw new AggregateError(errors, \"The glass controller did not stop cleanly.\");\n },\n };\n}\n//# sourceMappingURL=controller.js.map","// Engine entry used by the loader (`createEngine`) and by applications that always use glass (`startGlass`,\n// the \"Glass enabled\" profile of BUILD_AND_DISTRIBUTION.md section 7). One controller per document: the running\n// controller is recorded under `Symbol.for(\"abgin.glass\")`, so a second start, or a second copy of the library,\n// reuses it instead of observing the document twice.\nimport { createController } from \"./controller.js\";\nconst KEY = Symbol.for(\"abgin.glass\");\nfunction documentOf(options) {\n const doc = options.document ?? globalThis.document;\n if (!doc)\n throw new TypeError(\"The glass engine needs a document.\");\n return doc;\n}\nfunction running(doc) {\n const existing = doc[KEY];\n return existing && !existing.stopped ? existing : null;\n}\nexport function createEngine(options) {\n let controller = null;\n let owned = false;\n let stopped = false;\n return {\n get controller() {\n return controller;\n },\n start() {\n if (stopped || controller)\n return Promise.resolve();\n const doc = documentOf(options);\n const existing = running(doc);\n if (existing) {\n console.warn(\"Abgin: a glass controller is already running for this document; reusing it.\");\n controller = existing;\n return Promise.resolve();\n }\n const created = createController(options, {\n ...(options.onDemand ? { onDemand: options.onDemand } : {}),\n // `stop()` may be called on the controller directly: the document marker goes with it.\n onStop: () => {\n if (doc[KEY] === created)\n Reflect.deleteProperty(doc, KEY);\n },\n });\n controller = created;\n owned = true;\n doc[KEY] = created;\n return Promise.resolve();\n },\n stop() {\n stopped = true;\n const current = controller;\n controller = null;\n if (!current || !owned)\n return;\n current.stop();\n },\n };\n}\n/** Starts the engine for a document, or returns the controller already running there. */\nexport async function startGlass(options) {\n const existing = running(documentOf(options));\n if (existing)\n return existing;\n const engine = createEngine(options);\n await engine.start();\n if (!engine.controller)\n throw new Error(\"The glass engine did not start.\");\n return engine.controller;\n}\n//# sourceMappingURL=engine.js.map"],"mappings":";A,0SAEA,SAAS8B,EAAeC,EAAU,CAC9B,IAAMC,EAAM,WAAW,sBAGvB,OAFI,OAAOA,GAAQ,WACRA,EAAI,KAAK,WAAYD,CAAQ,EACjC,eAAiB,CACpBA,EAAS,YAAY,IAAI,CAAC,CAC9B,EAAG,EAAE,CACT,CACA,SAASE,EAAcC,EAAQ,CAC3B,IAAMC,EAAM,WAAW,qBACnB,OAAOA,GAAQ,YAAc,OAAOD,GAAW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