{
  "version": 3,
  "sources": ["scroll-scene.js"],
  "sourcesContent": ["import { register } from \"../../core/components.js\";\n\nconst scenes = new Set();\nlet queued = false;\n\n/**\n * How far an element has travelled through the screen: 0 as its top comes up\n * from below, 1 as its bottom leaves at the top.\n */\nfunction progressOf(element) {\n    const height = window.innerHeight;\n    const box = element.getBoundingClientRect();\n    if (box.bottom < -height || box.top > height * 2) {\n        return null;\n    }\n    const progress = (height - box.top) / (height + box.height);\n    return Math.min(1, Math.max(0, progress));\n}\n\nfunction update() {\n    queued = false;\n    const measured = [];\n    scenes.forEach((element) => {\n        const progress = progressOf(element);\n        if (progress !== null) {\n            measured.push([element, progress.toFixed(4)]);\n        }\n    });\n    measured.forEach(([element, progress]) => {\n        element.style.setProperty(\"--scene-progress\", progress);\n    });\n}\n\nfunction queue() {\n    if (!queued) {\n        queued = true;\n        window.requestAnimationFrame(update);\n    }\n}\n\nwindow.addEventListener(\"scroll\", queue, { passive: true });\nwindow.addEventListener(\"resize\", queue, { passive: true });\n\n/**\n * An element whose look follows the scroll: it carries how far it has\n * travelled through the screen as `--scene-progress`, from 0 to 1, for its\n * stylesheet to move, tilt or fade things by. Where motion is not wanted the\n * stylesheet ignores it (`prefers-reduced-motion`).\n */\nregister(\"scroll-scene\", (root) => {\n    scenes.add(root[0]);\n    queue();\n});\n"],
  "mappings": "AAAA,OAAS,YAAAA,MAAgB,2BAEzB,MAAMC,EAAS,IAAI,IACnB,IAAIC,EAAS,GAMb,SAASC,EAAWC,EAAS,CACzB,MAAMC,EAAS,OAAO,YAChBC,EAAMF,EAAQ,sBAAsB,EAC1C,GAAIE,EAAI,OAAS,CAACD,GAAUC,EAAI,IAAMD,EAAS,EAC3C,OAAO,KAEX,MAAME,GAAYF,EAASC,EAAI,MAAQD,EAASC,EAAI,QACpD,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAGC,CAAQ,CAAC,CAC5C,CAEA,SAASC,GAAS,CACdN,EAAS,GACT,MAAMO,EAAW,CAAC,EAClBR,EAAO,QAASG,GAAY,CACxB,MAAMG,EAAWJ,EAAWC,CAAO,EAC/BG,IAAa,MACbE,EAAS,KAAK,CAACL,EAASG,EAAS,QAAQ,CAAC,CAAC,CAAC,CAEpD,CAAC,EACDE,EAAS,QAAQ,CAAC,CAACL,EAASG,CAAQ,IAAM,CACtCH,EAAQ,MAAM,YAAY,mBAAoBG,CAAQ,CAC1D,CAAC,CACL,CAEA,SAASG,GAAQ,CACRR,IACDA,EAAS,GACT,OAAO,sBAAsBM,CAAM,EAE3C,CAEA,OAAO,iBAAiB,SAAUE,EAAO,CAAE,QAAS,EAAK,CAAC,EAC1D,OAAO,iBAAiB,SAAUA,EAAO,CAAE,QAAS,EAAK,CAAC,EAQ1DV,EAAS,eAAiBW,GAAS,CAC/BV,EAAO,IAAIU,EAAK,CAAC,CAAC,EAClBD,EAAM,CACV,CAAC",
  "names": ["register", "scenes", "queued", "progressOf", "element", "height", "box", "progress", "update", "measured", "queue", "root"]
}
