|  | import Dexie, { type Table } from 'dexie'; | 
					
						
						|  | import type { Monster, PicletInstance, Encounter, GameState } from './schema'; | 
					
						
						|  |  | 
					
						
						|  | export class PicletDatabase extends Dexie { | 
					
						
						|  |  | 
					
						
						|  | monsters!: Table<Monster>; | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | picletInstances!: Table<PicletInstance>; | 
					
						
						|  | encounters!: Table<Encounter>; | 
					
						
						|  | gameState!: Table<GameState>; | 
					
						
						|  |  | 
					
						
						|  | constructor() { | 
					
						
						|  | super('PicletGameDB'); | 
					
						
						|  |  | 
					
						
						|  | this.version(1).stores({ | 
					
						
						|  | monsters: '++id, name, createdAt' | 
					
						
						|  | }); | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | this.version(2).stores({ | 
					
						
						|  | monsters: '++id, name, createdAt' | 
					
						
						|  | }).upgrade(tx => { | 
					
						
						|  |  | 
					
						
						|  | return tx.table('monsters').toCollection().modify(monster => { | 
					
						
						|  | monster.imageData = monster.imageData || null; | 
					
						
						|  | }); | 
					
						
						|  | }); | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | this.version(3).stores({ | 
					
						
						|  | monsters: '++id, name, createdAt' | 
					
						
						|  | }).upgrade(tx => { | 
					
						
						|  |  | 
					
						
						|  | return tx.table('monsters').toCollection().modify(monster => { | 
					
						
						|  | monster.stats = monster.stats || null; | 
					
						
						|  | }); | 
					
						
						|  | }); | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | this.version(4).stores({ | 
					
						
						|  | monsters: '++id, name, createdAt', | 
					
						
						|  | picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', | 
					
						
						|  | encounters: '++id, type, createdAt', | 
					
						
						|  | gameState: '++id, lastPlayed' | 
					
						
						|  | }); | 
					
						
						|  | } | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | export const db = new PicletDatabase(); |