import { get, writable } from 'svelte/store'; import type { AltchaGlobal, Configuration } from './types/'; function store(defaultValue: T) { const scope = { get: (name: K) => { return get(scope.store)[name]; }, set: (name: N | T, value?: T[N]) => { if (typeof name === 'string') { Object.assign(get(scope.store), { [name]: value }); } else { Object.assign(get(scope.store), name); } scope.store.set(get(scope.store)); }, store: writable(defaultValue) }; return scope; } globalThis.$altcha = globalThis.$altcha || ({ algorithms: new Map(), defaults: store>({}), i18n: store>>({}), instances: new Set(), plugins: new Set() } satisfies AltchaGlobal);