interface Storage { getItem ( k ) : string | null | undefined ; setItem ( k , v ) : void ; removeItem ( k ) : void ; } ( window as any ) . db = ( window as any ) . db ?? { } ; const db = ( window as any ) . db ; function getItem ( k ) { return db [ k ] ; } function setItem ( k , v ) { db [ k ] = v ; } function removeItem ( k ) { delete db [ k ] ; } export function defaultStorage ( ) { if ( navigator . userAgent . includes ( 'QtWebEngine' ) ) { return { setItem , getItem , removeItem } ; } return window . localStorage ?? window . sessionStorage ; } export function isStorageSupported ( s ) { try { const key = '__anki_canvas_store_check__' ; s . setItem ( key , key ) ; s . removeItem ( key ) ; return true ; } catch ( e ) { return false ; } } export const dump = JSON . stringify ; export const parse = JSON . parse ;