{"version":3,"file":"useFixedPopover-D6ex254e.js","sources":["../src/ratings/rating_scores.js","../src/composables/useFixedPopover.js"],"sourcesContent":["import { ref, shallowReactive } from \"vue\";\n\n// One shared ref per asset + rating type. Several RatingButton instances can be\n// mounted for the same asset at once - e.g. the gallery card and the open asset\n// detail both render a bookmark icon. Without a shared ref each instance keeps\n// its own score and they drift apart when one is toggled. Keying the ref on\n// `${assetId}::${slug}` lets every instance read and write the same value, so\n// toggling one icon updates them all.\n// A shallowReactive object, not a Map: a reader can then depend on a key\n// that does not exist yet (DidntUseCell reads its row's live score, and may\n// render before the rating cell creates the store), while `shallow` keeps the\n// stored refs themselves untouched - a reactive Map would hand back proxies\n// of the refs and break their identity.\nconst stores = shallowReactive({});\n\n/** The live score ref for an asset+type, or undefined if none exists yet.\n *\n * Unlike getRatingScore this never creates (and never seeds) a store, so a\n * reader cannot steal the seeding from the rating control that owns it. */\nexport function peekRatingScore(assetId, slug) {\n    return stores[`${assetId}::${slug}`];\n}\n\nexport function getRatingScore(assetId, slug, initial) {\n    const key = `${assetId}::${slug}`;\n    let store = stores[key];\n    if (!store) {\n        store = ref(initial);\n        stores[key] = store;\n    }\n    return store;\n}\n\n/** Test seam: the store outlives a component, so suites must reset it. */\nexport function resetRatingScores() {\n    for (const key of Object.keys(stores)) {\n        delete stores[key];\n    }\n}\n","import { onBeforeUnmount, ref } from \"vue\";\n\n/**\n * A popover anchored to an element but positioned `fixed`, so it escapes the\n * clipping and horizontal scrolling of a table cell — an inline panel would\n * either be cut off at the cell edge or widen its column.\n *\n * Closes on an outside pointerdown and on Escape; the listeners live only\n * while it is open.\n */\nexport function useFixedPopover(rootEl, { width = 360 } = {}) {\n    const open = ref(false);\n    const style = ref({});\n\n    function onOutside(event) {\n        if (rootEl.value && !rootEl.value.contains(event.target)) close();\n    }\n\n    function onKey(event) {\n        if (event.key === \"Escape\") close();\n    }\n\n    function openAt() {\n        const rect = rootEl.value.getBoundingClientRect();\n        style.value = {\n            position: \"fixed\",\n            top: `${rect.bottom + 6}px`,\n            // Keep the panel inside the viewport when the anchor sits near\n            // the right edge (the last columns of a wide table).\n            left: `${Math.max(\n                8,\n                Math.min(rect.left, window.innerWidth - width)\n            )}px`,\n        };\n        open.value = true;\n        document.addEventListener(\"pointerdown\", onOutside, true);\n        document.addEventListener(\"keydown\", onKey, true);\n    }\n\n    function close() {\n        open.value = false;\n        document.removeEventListener(\"pointerdown\", onOutside, true);\n        document.removeEventListener(\"keydown\", onKey, true);\n    }\n\n    onBeforeUnmount(close);\n\n    return { open, style, openAt, close };\n}\n"],"names":["stores","shallowReactive","peekRatingScore","assetId","slug","getRatingScore","initial","key","store","ref","useFixedPopover","rootEl","width","open","style","onOutside","event","close","onKey","openAt","rect","onBeforeUnmount"],"mappings":"yEAaA,MAAMA,EAASC,EAAgB,EAAE,EAM1B,SAASC,EAAgBC,EAASC,EAAM,CAC3C,OAAOJ,EAAO,GAAGG,CAAO,KAAKC,CAAI,EAAE,CACvC,CAEO,SAASC,EAAeF,EAASC,EAAME,EAAS,CACnD,MAAMC,EAAM,GAAGJ,CAAO,KAAKC,CAAI,GAC/B,IAAII,EAAQR,EAAOO,CAAG,EACtB,OAAKC,IACDA,EAAQC,EAAIH,CAAO,EACnBN,EAAOO,CAAG,EAAIC,GAEXA,CACX,CCrBO,SAASE,EAAgBC,EAAQ,CAAE,MAAAC,EAAQ,GAAG,EAAK,CAAA,EAAI,CAC1D,MAAMC,EAAOJ,EAAI,EAAK,EAChBK,EAAQL,EAAI,EAAE,EAEpB,SAASM,EAAUC,EAAO,CAClBL,EAAO,OAAS,CAACA,EAAO,MAAM,SAASK,EAAM,MAAM,GAAGC,EAAK,CACnE,CAEA,SAASC,EAAMF,EAAO,CACdA,EAAM,MAAQ,UAAUC,EAAK,CACrC,CAEA,SAASE,GAAS,CACd,MAAMC,EAAOT,EAAO,MAAM,sBAAqB,EAC/CG,EAAM,MAAQ,CACV,SAAU,QACV,IAAK,GAAGM,EAAK,OAAS,CAAC,KAGvB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