import * as Cesium from 'cesium'; /** * One static Cesium credit per active provider: CC BY-SA imagery needs * visible attribution that goes away with the imagery. */ export function createCredits() { /** @type {Map} provider id → Cesium.Credit */ const shown = new Map(); function show(viewer, def) { if (shown.has(def.id) || !viewer?.creditDisplay) return; try { const credit = new Cesium.Credit(def.credit.html, true); viewer.creditDisplay.addStaticCredit(credit); shown.set(def.id, credit); } catch { /* credit display unavailable */ } } function hide(viewer, def) { const credit = shown.get(def.id); if (!credit) return; try { viewer?.creditDisplay?.removeStaticCredit?.(credit); } catch { /* credit display already torn down */ } shown.delete(def.id); } function hideAll(viewer) { for (const id of [...shown.keys()]) hide(viewer, { id }); } return { show, hide, hideAll }; }