var _a;const REGISTRY_KEY="scIconLibraries",EVENT_REGISTERED="surecart:icon-library-registered",win="undefined"!=typeof window?window:void 0,watchedIcons=new Set;function readRegistry(){return win&&Array.isArray(win[REGISTRY_KEY])?win[REGISTRY_KEY]:[]}function writeRegistry(r){win&&(win[REGISTRY_KEY]=r)}function redrawForLibrary(r){watchedIcons.forEach((n=>{n.library===r&&n.redraw()}))}export function watchIcon(r){watchedIcons.add(r)}export function unwatchIcon(r){watchedIcons.delete(r)}export function getIconLibrary(r){try{return readRegistry().find((n=>(null==n?void 0:n.name)===r))}catch{return}}export function registerIconLibrary(r,n){const e=readRegistry().filter((n=>(null==n?void 0:n.name)!==r));e.push({name:r,...n}),writeRegistry(e);try{null==win||win.dispatchEvent(new CustomEvent(EVENT_REGISTERED,{detail:{name:r}}))}catch{}}export function unregisterIconLibrary(r){writeRegistry(readRegistry().filter((n=>(null==n?void 0:n.name)!==r)))}null===(_a=null==win?void 0:win.addEventListener)||void 0===_a||_a.call(win,EVENT_REGISTERED,(r=>{var n;const e=null===(n=r.detail)||void 0===n?void 0:n.name;e&&redrawForLibrary(e)})),win&&(win.ceRegisterIconLibrary=registerIconLibrary);