{"version":3,"file":"geometry.cjs","sources":["../../src/debug/geometry.ts"],"sourcesContent":["/**\n * Geometry primitives for the overlay's inline-styled surfaces.\n *\n * A leaf, like `layout.ts`: it imports nothing from the overlay, so `core.ts`,\n * `panel.ts`, `predict.ts` and `modal.ts` can all anchor boxes the same way without\n * an import cycle. That is why the edge helpers take the position string rather than\n * reaching into `preferences` themselves.\n *\n * Two browser quirks are absorbed here so no caller has to remember them:\n *\n * - **Safe-area insets.** `env()` resolves to 0 unless the host page opted into\n *   `viewport-fit=cover`, so `max(base, env(...))` is a no-op on ordinary pages and\n *   only grows under a notch.\n * - **`dvh`.** Mobile browsers count the collapsible URL bar inside `vh`, so a \"90vh\"\n *   box overflows the visible area. `dvh` fixes it where supported.\n *\n * Both use the same trick: write the plain value first, then the enhanced one. The\n * CSSOM setter silently drops a value it cannot parse, so an engine without\n * `max()`/`env()`/`dvh` keeps the fallback instead of losing the property entirely.\n */\n\n/** Distance from the viewport corner to the logo, and to anything anchored beside it. */\nexport const EDGE_INSET = 14;\n\nexport type VerticalEdge = 'top' | 'bottom';\nexport type HorizontalEdge = 'left' | 'right';\nexport type Edge = VerticalEdge | HorizontalEdge;\n\n/** Which horizontal/vertical edge a `panelPosition` preference names. */\nexport function verticalEdge(position: string): VerticalEdge {\n    return position.indexOf('top') === 0 ? 'top' : 'bottom';\n}\n\nexport function horizontalEdge(position: string): HorizontalEdge {\n    return position.indexOf('right') !== -1 ? 'right' : 'left';\n}\n\n/** Anchor `el`'s `side` at `base + extra` pixels, growing under a notch. */\nexport function setInset(el: HTMLElement, side: Edge, base: number, extra: number = 0) {\n    el.style[side] = (base + extra) + 'px';\n    const safe = `max(${base}px, env(safe-area-inset-${side}, 0px))`;\n    el.style[side] = extra ? `calc(${safe} + ${extra}px)` : safe;\n}\n\n/** Release every edge so a box can be re-anchored without inheriting the old corner. */\nexport function clearEdges(el: HTMLElement) {\n    el.style.top = 'auto';\n    el.style.right = 'auto';\n    el.style.bottom = 'auto';\n    el.style.left = 'auto';\n}\n\n/** Cap a box against the viewport, preferring `dvh` over the URL-bar-inclusive `vh`. */\nexport function setMaxViewportHeight(el: HTMLElement, vhExpression: string) {\n    el.style.maxHeight = vhExpression;\n    el.style.maxHeight = vhExpression.replace(/vh\\b/g, 'dvh');\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAEH;AACO,MAAM,UAAU,GAAG;AAM1B;AACM,SAAU,YAAY,CAAC,QAAgB,EAAA;AACzC,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,QAAQ;AAC3D;AAEM,SAAU,cAAc,CAAC,QAAgB,EAAA;AAC3C,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,MAAM;AAC9D;AAEA;AACM,SAAU,QAAQ,CAAC,EAAe,EAAE,IAAU,EAAE,IAAY,EAAE,KAAA,GAAgB,CAAC,EAAA;AACjF,IAAA,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,IAAI,IAAI;AACtC,IAAA,MAAM,IAAI,GAAG,CAAA,IAAA,EAAO,IAAI,CAAA,wBAAA,EAA2B,IAAI,SAAS;AAChE,IAAA,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAA,KAAA,EAAQ,IAAI,MAAM,KAAK,CAAA,GAAA,CAAK,GAAG,IAAI;AAChE;AAEA;AACM,SAAU,UAAU,CAAC,EAAe,EAAA;AACtC,IAAA,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM;AACrB,IAAA,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM;AACvB,IAAA,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM;AACxB,IAAA,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM;AAC1B;AAEA;AACM,SAAU,oBAAoB,CAAC,EAAe,EAAE,YAAoB,EAAA;AACtE,IAAA,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,YAAY;AACjC,IAAA,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC;AAC7D;;;;;;;;;"}