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(n){win&&(win[REGISTRY_KEY]=n)}function redrawForLibrary(n){watchedIcons.forEach((r=>{r.library===n&&r.redraw()}))}function watchIcon(n){watchedIcons.add(n)}function unwatchIcon(n){watchedIcons.delete(n)}function getIconLibrary(n){try{return readRegistry().find((r=>(null==r?void 0:r.name)===n))}catch{return}}function registerIconLibrary(n,r){const i=readRegistry().filter((r=>(null==r?void 0:r.name)!==n));i.push({name:n,...r}),writeRegistry(i);try{null==win||win.dispatchEvent(new CustomEvent(EVENT_REGISTERED,{detail:{name:n}}))}catch{}}null===(_a=null==win?void 0:win.addEventListener)||void 0===_a||_a.call(win,EVENT_REGISTERED,(n=>{var r;const i=null===(r=n.detail)||void 0===r?void 0:r.name;i&&redrawForLibrary(i)})),win&&(win.ceRegisterIconLibrary=registerIconLibrary);export{getIconLibrary as g,registerIconLibrary as r,unwatchIcon as u,watchIcon as w};