@mhmo91/schmancy 0.2.128 → 0.2.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/card.cjs +1 -1
  2. package/dist/card.js +1 -1
  3. package/dist/content-drawer.cjs +1 -1
  4. package/dist/content-drawer.js +1 -1
  5. package/dist/{context-object-CD26Iary.js → context-object-BDXZ5EKJ.js} +6 -6
  6. package/dist/context-object-BDXZ5EKJ.js.map +1 -0
  7. package/dist/context-object-BIywslrO.cjs +2 -0
  8. package/dist/context-object-BIywslrO.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +3 -3
  11. package/dist/nav-drawer.cjs +1 -1
  12. package/dist/nav-drawer.js +1 -1
  13. package/dist/{selector-hook-9dSW11-1.js → selector-hook-C6VCezv7.js} +111 -112
  14. package/dist/selector-hook-C6VCezv7.js.map +1 -0
  15. package/dist/selector-hook-DDaYMsHs.cjs +2 -0
  16. package/dist/selector-hook-DDaYMsHs.cjs.map +1 -0
  17. package/dist/store.cjs +1 -1
  18. package/dist/store.js +2 -2
  19. package/dist/teleport.cjs +1 -1
  20. package/dist/{teleport.component-CplIV2h1.cjs → teleport.component-BB820TxP.cjs} +2 -2
  21. package/dist/{teleport.component-CplIV2h1.cjs.map → teleport.component-BB820TxP.cjs.map} +1 -1
  22. package/dist/{teleport.component-CBNKUZwe.js → teleport.component-aomutiMW.js} +2 -2
  23. package/dist/{teleport.component-CBNKUZwe.js.map → teleport.component-aomutiMW.js.map} +1 -1
  24. package/dist/teleport.js +1 -1
  25. package/package.json +11 -3
  26. package/types/src/store/context-collection.d.ts +0 -3
  27. package/dist/context-object-CD26Iary.js.map +0 -1
  28. package/dist/context-object-D81PeS3j.cjs +0 -2
  29. package/dist/context-object-D81PeS3j.cjs.map +0 -1
  30. package/dist/selector-hook-9dSW11-1.js.map +0 -1
  31. package/dist/selector-hook-CH-z8W2d.cjs +0 -2
  32. package/dist/selector-hook-CH-z8W2d.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-object-D81PeS3j.cjs","sources":["../src/store/types.ts","../src/store/storage-manager.ts","../src/store/context-collection.ts","../src/store/context-object.ts"],"sourcesContent":["// src/store/types.ts\nimport { BehaviorSubject, Observable } from 'rxjs'\n\n/**\n * Storage types supported by the store\n */\nexport type StorageType = 'memory' | 'local' | 'session' | 'indexeddb'\n\n/**\n * Base store options\n */\nexport interface StoreOptions<T> {\n\t/** Key used for persistent storage */\n\tkey: string\n\n\t/** Storage type */\n\tstorage: StorageType\n\n\t/** Initial state */\n\tinitialState: T\n\n\t/** Enable dev tools */\n\tdevTools?: boolean\n}\n\n/**\n * Enhanced store error with type information and better context handling\n */\nexport class StoreError<T = unknown> extends Error {\n\t/** Original error that caused this store error */\n\tpublic readonly cause?: T\n\n\t/** Additional contextual information */\n\tpublic readonly context?: Record<string, unknown>\n\n\t/** Timestamp when the error occurred */\n\tpublic readonly timestamp: Date\n\n\tconstructor(message: string, cause?: T, context?: Record<string, unknown>) {\n\t\tsuper(message)\n\t\tthis.name = 'StoreError'\n\t\tthis.cause = cause\n\t\tthis.context = context\n\t\tthis.timestamp = new Date()\n\n\t\t// Capture stack trace if available\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, StoreError)\n\t\t}\n\t}\n\n\t/**\n\t * Returns a JSON-serializable representation of the error\n\t */\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tcause: this.cause,\n\t\t\tcontext: this.context,\n\t\t\ttimestamp: this.timestamp.toISOString(),\n\t\t\tstack: this.stack,\n\t\t}\n\t}\n}\n\n/**\n * Core store interface with improved type definitions\n */\nexport interface IStore<T extends Record<string, any>> {\n\t/** Get the current store value */\n\treadonly value: T\n\n\t/** Observable stream of store values */\n\treadonly $: BehaviorSubject<T>\n\n\t/** The default/initial value of the store */\n\treadonly defaultValue: T\n\n\t/** Whether the store is ready (loaded from storage) */\n\tready: boolean\n\n\t/** Observable stream of store errors */\n\treadonly error$: Observable<StoreError | null>\n\n\t/**\n\t * Update store value with partial data\n\t * @param value Partial data to update\n\t * @param merge Whether to merge with existing data (default: true)\n\t */\n\tset(value: Partial<T>, merge?: boolean): void\n\n\t/**\n\t * Reset store to default value\n\t */\n\tclear(): void\n\n\t/**\n\t * Replace entire store value\n\t * @param newValue New value to set\n\t */\n\treplace(newValue: T): void\n\n\t/**\n\t * Delete a specific key from the store\n\t * @param key Key to delete\n\t */\n\tdelete<K extends keyof T>(key: K): void\n\n\t/**\n\t * Clean up resources\n\t */\n\tdestroy(): void\n}\n\n/**\n * Interface for collection stores with improved typing\n */\nexport interface ICollectionStore<T> {\n\t/** Get the current collection value */\n\treadonly value: Map<string, T>\n\n\t/** Observable stream of collection values */\n\treadonly $: BehaviorSubject<Map<string, T>>\n\n\t/** The default/initial value of the collection */\n\treadonly defaultValue: Map<string, T>\n\n\t/** Whether the store is ready (loaded from storage) */\n\tready: boolean\n\n\t/** Observable stream of store errors */\n\treadonly error$: Observable<StoreError | null>\n\n\t/**\n\t * Set a value in the collection\n\t * @param key Item key\n\t * @param value Item value\n\t */\n\tset<V = T>(key: string, value: V): void\n\n\t/**\n\t * Delete an item from the collection\n\t * @param key Item key to delete\n\t */\n\tdelete(key: string): void\n\n\t/**\n\t * Clear all items from the collection\n\t */\n\tclear(): void\n\n\t/**\n\t * Replace the entire collection\n\t * @param newValue New collection value\n\t */\n\treplace(newValue: Map<string, T>): void\n\n\t/**\n\t * Clean up resources\n\t */\n\tdestroy(): void\n}\n\n/**\n * Interface for a storage manager\n */\nexport interface IStorageManager<T> {\n\t/**\n\t * Load data from storage\n\t * @returns Promise resolving to stored data or null\n\t */\n\tload(): Promise<T | null>\n\n\t/**\n\t * Save data to storage\n\t * @param state Data to save\n\t */\n\tsave(state: T): Promise<void>\n\n\t/**\n\t * Clear data from storage\n\t */\n\tclear(): Promise<void>\n}\n\n/**\n * Factory function type for creating stores\n */\nexport type StoreFactory = <T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n) => IStore<T>\n\n/**\n * Factory function type for creating collection stores\n */\nexport type CollectionStoreFactory = <T>(\n\tinitialData: Map<string, T>,\n\tstorage: StorageType,\n\tkey: string,\n) => ICollectionStore<T>\n","import { IStorageManager, StorageType, StoreError } from './types'\n\n/**\n * Memory storage manager implementation\n */\nexport class MemoryStorageManager<T> implements IStorageManager<T> {\n\tprivate data: T | null = null\n\n\tasync load(): Promise<T | null> {\n\t\treturn this.data\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\tthis.data = state\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tthis.data = null\n\t}\n}\n\n/**\n * Local storage manager implementation\n */\nexport class LocalStorageManager<T> implements IStorageManager<T> {\n\tconstructor(private key: string) {}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst data = localStorage.getItem(this.key)\n\t\t\treturn data ? JSON.parse(data) : null\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from localStorage (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tlocalStorage.setItem(this.key, JSON.stringify(state))\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to localStorage (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to localStorage (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tlocalStorage.removeItem(this.key)\n\t}\n}\n\n/**\n * Session storage manager implementation\n */\nexport class SessionStorageManager<T> implements IStorageManager<T> {\n\tconstructor(private key: string) {}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst data = sessionStorage.getItem(this.key)\n\t\t\treturn data ? JSON.parse(data) : null\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from sessionStorage (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tsessionStorage.setItem(this.key, JSON.stringify(state))\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to sessionStorage (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to sessionStorage (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tsessionStorage.removeItem(this.key)\n\t}\n}\n\n/**\n * IndexedDB storage manager implementation with better error typing\n */\nexport class IndexedDBStorageManager<T> implements IStorageManager<T> {\n\tprivate static DB_NAME = 'StoreDB'\n\tprivate static STORE_NAME = 'states'\n\tprivate static DB_VERSION = 1\n\n\tconstructor(private key: string) {}\n\n\tprivate openDB(): Promise<IDBDatabase> {\n\t\treturn new Promise<IDBDatabase>((resolve, reject) => {\n\t\t\tconst request = indexedDB.open(IndexedDBStorageManager.DB_NAME, IndexedDBStorageManager.DB_VERSION)\n\n\t\t\trequest.onupgradeneeded = () => {\n\t\t\t\tconst db = request.result\n\t\t\t\tif (!db.objectStoreNames.contains(IndexedDBStorageManager.STORE_NAME)) {\n\t\t\t\t\tdb.createObjectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trequest.onsuccess = () => resolve(request.result)\n\t\t\trequest.onerror = () => reject(request.error)\n\t\t})\n\t}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<T | null>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readonly')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.get(this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve(request.result || null)\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from IndexedDB (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readwrite')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.put(state, this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve()\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to IndexedDB (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to IndexedDB (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readwrite')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.delete(this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve()\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to clear from IndexedDB (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to clear from IndexedDB (${this.key})`, err)\n\t\t}\n\t}\n}\n\n/**\n * Factory function to create the appropriate storage manager\n */\nexport function createStorageManager<T>(type: StorageType, key: string): IStorageManager<T> {\n\tswitch (type) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageManager<T>(key)\n\t\tcase 'session':\n\t\t\treturn new SessionStorageManager<T>(key)\n\t\tcase 'indexeddb':\n\t\t\treturn new IndexedDBStorageManager<T>(key)\n\t\tcase 'memory':\n\t\tdefault:\n\t\t\treturn new MemoryStorageManager<T>()\n\t}\n}\n","import { BehaviorSubject, Subject, throttleTime } from 'rxjs'\nimport { createStorageManager } from './storage-manager'\nimport { ICollectionStore, IStorageManager, StorageType, StoreError } from './types'\n\n/**\n * Enhanced collection store with better TypeScript support\n */\nexport default class SchmancyCollectionStore<V = any> implements ICollectionStore<V> {\n\tpublic static type = 'collection'\n\n\t// Static map to hold instances\n\tprivate static instances: Map<string, SchmancyCollectionStore<any>> = new Map()\n\n\t// State management\n\tprivate _ready: boolean = false\n\tprivate _destroy$ = new Subject<void>()\n\n\t// Observable streams - modified to match interface requirements\n\tpublic $: BehaviorSubject<Map<string, V>>\n\tpublic error$ = new BehaviorSubject<StoreError | null>(null)\n\n\t// Default value for the store\n\tpublic readonly defaultValue: Map<string, V>\n\n\t// Storage manager\n\tprivate storage: IStorageManager<Map<string, V>>\n\n\t/**\n\t * Get ready state\n\t */\n\tpublic get ready(): boolean {\n\t\treturn this._ready\n\t}\n\n\t/**\n\t * Set ready state\n\t */\n\tpublic set ready(value: boolean) {\n\t\tthis._ready = value\n\t\tthis.updateState(this.$.value)\n\t}\n\n\t/**\n\t * Private constructor to enforce singleton pattern\n\t */\n\tprivate constructor(\n\t\tprivate storageType: StorageType,\n\t\tprivate key: string,\n\t\tdefaultValue: Map<string, V>,\n\t) {\n\t\tthis.defaultValue = defaultValue\n\t\tthis.$ = new BehaviorSubject<Map<string, V>>(new Map<string, V>())\n\t\tthis.storage = createStorageManager<Map<string, V>>(storageType, key)\n\n\t\t// Initialize from storage\n\t\tthis.initializeFromStorage()\n\n\t\t// Set up persistence\n\t\tthis.setupPersistence()\n\n\t\t// Setup dev tools in development\n\t\tif (import.meta.env.MODE === 'development') {\n\t\t\tthis.setupDevTools()\n\t\t}\n\t}\n\n\t/**\n\t * Static method to get or create an instance with proper typing\n\t */\n\tpublic static getInstance<V = any>(\n\t\tstorage: StorageType,\n\t\tkey: string,\n\t\tdefaultValue: Map<string, V>,\n\t): SchmancyCollectionStore<V> {\n\t\tconst instanceKey = `${storage}:${key}`\n\t\tif (!this.instances.has(instanceKey)) {\n\t\t\tthis.instances.set(instanceKey, new SchmancyCollectionStore<V>(storage, key, defaultValue))\n\t\t}\n\t\treturn this.instances.get(instanceKey) as SchmancyCollectionStore<V>\n\t}\n\n\t/**\n\t * Get the current value\n\t */\n\tpublic get value(): Map<string, V> {\n\t\treturn this.$.getValue()\n\t}\n\n\t/**\n\t * Set a value in the collection with proper typing\n\t */\n\tpublic set<T = V>(key: string, value: T): void {\n\t\ttry {\n\t\t\tconst currentValue = new Map(this.value)\n\t\t\tcurrentValue.set(key, value as unknown as V)\n\t\t\tthis.updateState(currentValue)\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error setting value for key ${key} in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Delete a value from the collection\n\t */\n\tpublic delete(key: string): void {\n\t\ttry {\n\t\t\tconst currentValue = new Map(this.value)\n\t\t\tcurrentValue.delete(key)\n\t\t\tthis.updateState(currentValue)\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error deleting key ${key} from ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Clear the collection\n\t */\n\tpublic clear(): void {\n\t\tthis.updateState(new Map<string, V>())\n\t}\n\n\tpublic replace(newValue: Map<string, V>): void {\n\t\tthis.updateState(newValue)\n\t}\n\n\t/**\n\t * Update the state with error handling\n\t */\n\tprivate updateState(newValue: Map<string, V>): void {\n\t\ttry {\n\t\t\tthis.$.next(newValue)\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating state in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Initialize from persistent storage\n\t */\n\tprivate async initializeFromStorage(): Promise<void> {\n\t\tif (this.storageType === 'local' || this.storageType === 'session') {\n\t\t\ttry {\n\t\t\t\tconst storedValue = await this.storage.load()\n\t\t\t\tif (storedValue) {\n\t\t\t\t\tthis.updateState(storedValue)\n\t\t\t\t}\n\t\t\t\tthis._ready = true\n\t\t\t} catch (err) {\n\t\t\t\tconst error = new StoreError<unknown>(`Error loading from ${this.storageType} storage for ${this.key}`, err)\n\t\t\t\tthis.error$.next(error)\n\t\t\t\tconsole.error(error)\n\t\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t\t}\n\t\t} else if (this.storageType === 'indexeddb') {\n\t\t\tthis.loadFromIndexedDB()\n\t\t} else {\n\t\t\t// Memory storage doesn't need loading\n\t\t\tthis._ready = true\n\t\t}\n\t}\n\n\t/**\n\t * Load data from IndexedDB with better typing\n\t */\n\tprivate async loadFromIndexedDB(): Promise<void> {\n\t\ttry {\n\t\t\tconst result = await this.storage.load()\n\t\t\tthis.updateState(result || new Map<string, V>())\n\t\t\tthis._ready = true\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error loading from IndexedDB for ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t}\n\t}\n\n\t/**\n\t * Set up persistence to storage\n\t */\n\tprivate setupPersistence(): void {\n\t\tif (this.storageType === 'memory') return\n\n\t\tthis.$.pipe(throttleTime(100, undefined, { leading: true, trailing: true })).subscribe(currentValue => {\n\t\t\tthis.storage.save(currentValue).catch(err => {\n\t\t\t\tconst error = new StoreError<unknown>(`Error saving to ${this.storageType} storage for ${this.key}`, err)\n\t\t\t\tthis.error$.next(error)\n\t\t\t\tconsole.error(error)\n\t\t\t})\n\t\t})\n\t}\n\n\t/**\n\t * Setup development tools for debugging\n\t */\n\tprivate setupDevTools(): void {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t// Add to global store registry\n\t\t\t;(window as any).__STORES__ = (window as any).__STORES__ || {}\n\t\t\t;(window as any).__STORES__[this.key] = {\n\t\t\t\tgetState: () => this.value,\n\t\t\t\tset: this.set.bind(this),\n\t\t\t\tdelete: this.delete.bind(this),\n\t\t\t\tclear: this.clear.bind(this),\n\t\t\t\tsubscribe: (callback: (state: Map<string, V>) => void) => {\n\t\t\t\t\tconst subscription = this.$.subscribe(callback)\n\t\t\t\t\treturn () => subscription.unsubscribe()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources\n\t */\n\tpublic destroy(): void {\n\t\tthis._destroy$.next()\n\t\tthis._destroy$.complete()\n\t\tthis.$.complete()\n\t\tthis.error$.complete()\n\t}\n}\n","import { BehaviorSubject, Subject } from 'rxjs'\nimport { createStorageManager } from './storage-manager'\nimport { IStorageManager, IStore, StorageType, StoreError } from './types'\n\n/**\n * Enhanced store object with better TypeScript support\n */\nexport class SchmancyStoreObject<T extends Record<string, any>> implements IStore<T> {\n\tpublic static type = 'object'\n\n\t// Static map to hold instances with proper typing\n\tprivate static instances: Map<string, SchmancyStoreObject<any>> = new Map()\n\n\t// State tracking\n\tprivate _ready: boolean = false\n\tprivate _destroy$ = new Subject<void>()\n\n\t// Observable streams\n\tpublic $: BehaviorSubject<T>\n\tpublic error$ = new BehaviorSubject<StoreError | null>(null)\n\n\t// Default value for the store\n\tpublic readonly defaultValue: T\n\n\t// Storage manager\n\tprivate storage: IStorageManager<T>\n\n\t/**\n\t * Get store ready state\n\t */\n\tpublic get ready(): boolean {\n\t\treturn this._ready\n\t}\n\n\t/**\n\t * Set store ready state\n\t */\n\tpublic set ready(value: boolean) {\n\t\tthis._ready = value\n\t\tthis.updateState(this.$.value)\n\t}\n\n\t/**\n\t * Private constructor to enforce singleton pattern\n\t */\n\tprivate constructor(\n\t\tprivate storageType: StorageType,\n\t\tprivate key: string,\n\t\tdefaultValue: T,\n\t) {\n\t\tthis.defaultValue = defaultValue\n\t\tthis.$ = new BehaviorSubject<T>(defaultValue)\n\t\tthis.storage = createStorageManager<T>(storageType, key)\n\n\t\t// Initialize from storage\n\t\tthis.initializeFromStorage()\n\n\t\t// Setup dev tools in development\n\t\tif (import.meta.env.MODE === 'development') {\n\t\t\tthis.setupDevTools()\n\t\t}\n\t}\n\n\t/**\n\t * Static method to get or create an instance with strong typing\n\t */\n\tpublic static getInstance<T extends Record<string, any>>(\n\t\tstorage: StorageType,\n\t\tkey: string,\n\t\tdefaultValue: T,\n\t): SchmancyStoreObject<T> {\n\t\tconst instanceKey = `${storage}:${key}`\n\t\tif (!this.instances.has(instanceKey)) {\n\t\t\tthis.instances.set(instanceKey, new SchmancyStoreObject<T>(storage, key, defaultValue))\n\t\t}\n\t\treturn this.instances.get(instanceKey) as SchmancyStoreObject<T>\n\t}\n\n\t/**\n\t * Get the current value from the store\n\t */\n\tpublic get value(): T {\n\t\treturn this.$.getValue()\n\t}\n\n\t/**\n\t * Set state with proper typing\n\t */\n\tpublic set(value: Partial<T>, merge: boolean = true): void {\n\t\ttry {\n\t\t\tthis.updateState(merge ? { ...this.value, ...value } : (value as T))\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating store: ${this.key}`, err, { value, merge })\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Reset the store to its default value\n\t */\n\tpublic clear(): void {\n\t\tthis.set(this.defaultValue, false)\n\t}\n\n\t/**\n\t * Replace the store with a new value\n\t */\n\tpublic replace(newValue: T): void {\n\t\tthis.updateState(newValue)\n\t}\n\n\t/**\n\t * Delete a specific key from the store with type checking\n\t */\n\tpublic delete<K extends keyof T>(key: K): void {\n\t\tconst value = { ...this.value }\n\t\tdelete value[key]\n\t\tthis.updateState(value)\n\t}\n\n\t/**\n\t * Update the state with proper error handling\n\t */\n\tprivate updateState(newValue: T): void {\n\t\ttry {\n\t\t\tthis.$.next(newValue)\n\n\t\t\t// Persist to storage\n\t\t\tif (this.storageType !== 'memory') {\n\t\t\t\tthis.storage.save(newValue).catch(err => {\n\t\t\t\t\tconsole.error(`Error saving to ${this.storageType} storage:`, err)\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating state in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Initialize the store from persistent storage\n\t */\n\tprivate async initializeFromStorage(): Promise<void> {\n\t\ttry {\n\t\t\tconst storedValue = await this.storage.load()\n\t\t\tif (storedValue) {\n\t\t\t\tthis.updateState({ ...this.defaultValue, ...storedValue })\n\t\t\t}\n\t\t\tthis._ready = true\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error loading from ${this.storageType} storage for ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t}\n\t}\n\n\t/**\n\t * Setup development tools for debugging\n\t */\n\tprivate setupDevTools(): void {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t// Add to global store registry\n\t\t\t;(window as any).__STORES__ = (window as any).__STORES__ || {}\n\t\t\t;(window as any).__STORES__[this.key] = {\n\t\t\t\tgetState: () => this.value,\n\t\t\t\tset: this.set.bind(this),\n\t\t\t\tdelete: this.delete.bind(this),\n\t\t\t\tclear: this.clear.bind(this),\n\t\t\t\tsubscribe: (callback: (state: T) => void) => {\n\t\t\t\t\tconst subscription = this.$.subscribe(callback)\n\t\t\t\t\treturn () => subscription.unsubscribe()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources\n\t */\n\tpublic destroy(): void {\n\t\tthis._destroy$.next()\n\t\tthis._destroy$.complete()\n\t\tthis.$.complete()\n\t\tthis.error$.complete()\n\t}\n}\n"],"names":["StoreError","Error","message","cause","context","super","this","name","timestamp","Date","captureStackTrace","toJSON","toISOString","stack","MemoryStorageManager","data","save","state","LocalStorageManager","key","localStorage","getItem","JSON","parse","err","setItem","stringify","clear","removeItem","SessionStorageManager","load","sessionStorage","IndexedDBStorageManager","Promise","resolve","reject","request","indexedDB","open","DB_NAME","DB_VERSION","onupgradeneeded","db","result","objectStoreNames","contains","STORE_NAME","createObjectStore","onsuccess","onerror","error","openDB","transaction","objectStore","get","close","put","delete","_h","createStorageManager","type","SchmancyCollectionStore","storageType","defaultValue","_ready","_destroy$","Subject","error$","BehaviorSubject","$","Map","storage","initializeFromStorage","setupPersistence","ready","value","updateState","instanceKey","instances","has","set","getValue","currentValue","next","newValue","storedValue","loadFromIndexedDB","pipe","throttleTime","leading","trailing","subscribe","catch","window","__STORES__","getState","bind","callback","subscription","unsubscribe","complete","_o","SchmancyStoreObject","merge","setupDevTools","destroy","_a"],"mappings":"qCA4BO,MAAMA,UAAgCC,KAAAA,CAU5C,YAAYC,EAAiBC,EAAWC,EAAAA,CACvCC,MAAMH,CAAAA,EACNI,KAAKC,KAAO,aACZD,KAAKH,MAAQA,EACbG,KAAKF,QAAUA,EACVE,KAAAE,cAAgBC,KAGjBR,MAAMS,mBACHT,MAAAS,kBAAkBJ,KAAMN,CAAAA,CAC/B,CAMD,QAAAW,CACQ,MAAA,CACNJ,KAAMD,KAAKC,KACXL,QAASI,KAAKJ,QACdC,MAAOG,KAAKH,MACZC,QAASE,KAAKF,QACdI,UAAWF,KAAKE,UAAUI,YAC1BC,EAAAA,MAAOP,KAAKO,KAAAA,CACb,CCzDK,CAAA,MAAMC,CAAN,CAAA,cACNR,KAAQS,KAAiB,IAAA,CAE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H,MAAMmC,EAAoB/E,MAAAA,KAAKiE,QAAQzC,KAAAA,EACnCuD,GACH/E,KAAKsE,YAAY,CAAKtE,GAAAA,KAAKyD,aAAiBsB,GAAAA,CAAAA,CAAAA,EAE7C/E,KAAK0D,OAAAA,SACGxC,EACF,CAAA,MAAA0B,EAAQ,IAAIlD,EAAoB,sBAAsBM,KAAKwD,2BAA2BxD,KAAKa,GAAAA,GAAOK,CACnGlB,EAAAA,KAAA6D,OAAOgB,KAAKjC,CAAAA,EAEjB5C,KAAK0D,OAAAA,EAAS,CACf,CAMO,eAAAwC,QACIX,OAAW,MAEJA,OAAAC,WAAcD,OAAeC,YAAc,CAAC,EAC5CD,OAAAC,WAAWxF,KAAKa,GAAAA,EAAO,CACvC4E,SAAU,IAAMzF,KAAKqE,MACrBK,IAAK1E,KAAK0E,IAAIgB,KAAK1F,IAAAA,EACnBmD,OAAQnD,KAAKmD,OAAOuC,KAAK1F,IAAAA,EACzBqB,MAAOrB,KAAKqB,MAAMqE,KAAK1F,IACvBqF,EAAAA,UAAYM,IACX,MAAMC,EAAe5F,KAAK+D,EAAEsB,UAAUM,CAC/B,EAAA,MAAA,IAAMC,EAAaC,aAAY,CAGzC,EAAA,CAMM,SAAAM,CACNnG,KAAK2D,UAAUkB,KACf7E,EAAAA,KAAK2D,UAAUmC,SACf9F,EAAAA,KAAK+D,EAAE+B,SAAAA,EACP9F,KAAK6D,OAAOiC,SAAAA,CAAS,GAnLtB9F,EAAcsD,KAAO,SAGNtD,EAAAwE,cAAuDR,IAJhE,IAAMgC,EAANI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"selector-hook-9dSW11-1.js","sources":["../src/store/context-create.ts","../src/store/filter-directive.ts","../src/store/selectors.ts","../src/store/selector-hook.ts"],"sourcesContent":["// src/store/context-create.ts\nimport SchmancyCollectionStore from './context-collection'\nimport { SchmancyStoreObject } from './context-object'\nimport { ICollectionStore, IStore, StorageType, StoreError } from './types'\n\n/**\n * Type guard to check if an object is empty\n */\nfunction isEmptyObject(obj: unknown): boolean {\n\tif (typeof obj !== 'object' || obj === null) {\n\t\treturn false\n\t}\n\treturn Object.keys(obj).length === 0\n}\n\n/**\n * Type guard to check if object is an iterable collection\n */\n// function isCollection(obj: unknown): obj is Iterable<unknown> {\n// \t// Must be non-null and of type 'object'\n// \tif (obj == null || typeof obj !== 'object') {\n// \t\treturn false\n// \t}\n\n// \t// Exclude plain objects\n// \tconst proto = Object.getPrototypeOf(obj)\n// \tif (proto === Object.prototype || proto === null) {\n// \t\treturn false\n// \t}\n\n// \t// Check for Symbol.iterator method\n// \treturn typeof obj[Symbol.iterator] === 'function'\n// }\n\n/**\n * Type guard for Map objects\n */\nfunction isMap<K, V>(value: unknown): value is Map<K, V> {\n\treturn value instanceof Map\n}\n\n/**\n * Creates a regular object store\n */\nfunction createObjectStore<T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n): IStore<T> & SchmancyStoreObject<T> {\n\t// Validate storage type\n\tif (storage === 'indexeddb') {\n\t\tthrow new StoreError('IndexedDB storage is not supported for plain objects', null, { storage, key })\n\t}\n\n\t// Create the store instance\n\tconst store = SchmancyStoreObject.getInstance<T>(storage, key, initialData)\n\n\t// Initialize with provided data if store is empty\n\tif (isEmptyObject(store.value)) {\n\t\tstore.$.next(initialData)\n\t}\n\n\treturn store\n}\n\n/**\n * Creates a collection store\n */\nfunction createCollectionStore<V>(\n\tinitialData: Map<string, V>,\n\tstorage: StorageType,\n\tkey: string,\n): ICollectionStore<V> & SchmancyCollectionStore<V> {\n\t// Create the store instance\n\tconst store = SchmancyCollectionStore.getInstance(storage, key, initialData)\n\n\t// Initialize with provided data if store is empty\n\tif (!store.value.size) {\n\t\tstore.$.next(new Map(initialData))\n\t}\n\n\treturn store\n}\n\n/**\n * Creates a context for managing state with better type safety\n * Overload for object stores\n */\nexport function createContext<T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n): IStore<T> & SchmancyStoreObject<T>\n\n/**\n * Creates a context for managing state with better type safety\n * Overload for collection stores\n */\nexport function createContext<V>(\n\tinitialData: Map<string, V>,\n\tstorage: StorageType,\n\tkey: string,\n): ICollectionStore<V> & SchmancyCollectionStore<V>\n\n/**\n * Implementation of the createContext function\n */\nexport function createContext<T extends Record<string, any> | Map<string, any>>(\n\tinitialData: T | Map<string, any>,\n\tstorage: StorageType,\n\tkey: string,\n): (IStore<T> & SchmancyStoreObject<T>) | (ICollectionStore<any> & SchmancyCollectionStore<any>) {\n\t// Validate input\n\tif (initialData === null || initialData === undefined) {\n\t\tthrow new StoreError('Initial data cannot be null or undefined', null, { storage, key })\n\t}\n\n\t// Determine store type based on input data\n\tif (isMap(initialData)) {\n\t\treturn createCollectionStore(initialData as Map<string, any>, storage, key)\n\t} else if (typeof initialData === 'object') {\n\t\treturn createObjectStore(initialData, storage, key)\n\t} else {\n\t\tthrow new StoreError('Initial data must be an object or a Map', null, {\n\t\t\tstorage,\n\t\t\tkey,\n\t\t\tdataType: typeof initialData,\n\t\t})\n\t}\n}\n\n/**\n * Creates a context with type inference, simplifying common patterns\n */\nexport function createObjectContext<T extends Record<string, any>>(\n\tinitialData: T,\n\tkey: string,\n\tstorage: StorageType = 'local',\n): IStore<T> & SchmancyStoreObject<T> {\n\treturn createContext(initialData, storage, key)\n}\n\n/**\n * Creates a collection context with type inference\n */\nexport function createCollectionContext<V>(\n\tinitialData: Map<string, V> | V[],\n\tkey: string,\n\tstorage: StorageType = 'local',\n): ICollectionStore<V> & SchmancyCollectionStore<V> {\n\t// Convert array to Map if needed\n\tconst dataMap = Array.isArray(initialData)\n\t\t? new Map(initialData.map((item, index) => [String(index), item]))\n\t\t: initialData\n\n\treturn createContext<V>(dataMap, storage, key)\n}\n","// src/store/filter-directive.ts\n\n/** Supported comparison operators with TypeScript literal types */\nexport type ComparisonOperator =\n\t| '=='\n\t| '!='\n\t| '>'\n\t| '<'\n\t| '>='\n\t| '<='\n\t| 'includes'\n\t| 'notIncludes'\n\t| 'startsWith'\n\t| 'endsWith'\n\t| 'in'\n\t| 'notIn'\n\t| 'any' // fuzzy search operator\n\n/**\n * Type-safe condition tuple\n */\nexport type ConditionTuple = [field: string, op: ComparisonOperator, expected: unknown, strict?: boolean]\n\n/**\n * Type-safe condition object\n */\nexport interface ConditionObject {\n\tkey: string\n\toperator: ComparisonOperator\n\tvalue: unknown\n\tstrict?: boolean\n}\n\n/**\n * Unified query condition type\n */\nexport type QueryCondition = ConditionTuple | ConditionObject\n\n/**\n * Filter result with item and score\n */\nexport interface ScoredItem<T> {\n\titem: T\n\tscore: number\n}\n\n/**\n * Get a nested value from an object using a dot-separated path.\n * Checks explicitly for null/undefined so falsy values like 0 or false are preserved.\n */\nexport const getFieldValue = <T = any>(item: Record<string, any>, path: string): T => {\n\tif (!path) return item as unknown as T\n\n\tconst parts = path.split('.')\n\tlet value: any = item\n\n\tfor (const part of parts) {\n\t\tif (value == null) return undefined as unknown as T\n\t\tvalue = value[part]\n\t}\n\n\treturn value as T\n}\n\n/**\n * Compute the Levenshtein distance between two strings.\n */\nconst levenshtein = (a: string, b: string): number => {\n\tif (a === b) return 0\n\n\tconst matrix: number[][] = Array(b.length + 1)\n\t\t.fill(null)\n\t\t.map((_, i) => [i])\n\n\t// initialize the first row\n\tfor (let j = 0; j <= a.length; j++) {\n\t\tmatrix[0][j] = j\n\t}\n\n\tfor (let i = 1; i <= b.length; i++) {\n\t\tfor (let j = 1; j <= a.length; j++) {\n\t\t\tif (b.charAt(i - 1) === a.charAt(j - 1)) {\n\t\t\t\tmatrix[i][j] = matrix[i - 1][j - 1]\n\t\t\t} else {\n\t\t\t\tmatrix[i][j] = Math.min(\n\t\t\t\t\tmatrix[i - 1][j] + 1, // deletion\n\t\t\t\t\tmatrix[i][j - 1] + 1, // insertion\n\t\t\t\t\tmatrix[i - 1][j - 1] + 1, // substitution\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\treturn matrix[b.length][a.length]\n}\n\n/**\n * Check if string `sub` is a subsequence of string `str`.\n * All characters in `sub` must appear in order in `str` (they need not be contiguous).\n */\nconst isSubsequence = (sub: string, str: string): boolean => {\n\tif (!sub) return true\n\tif (!str) return false\n\n\tlet i = 0,\n\t\tj = 0\n\twhile (i < sub.length && j < str.length) {\n\t\tif (sub[i].toLowerCase() === str[j].toLowerCase()) i++\n\t\tj++\n\t}\n\treturn i === sub.length\n}\n\n/**\n * Check if every character (with frequency) in the query exists in the target.\n * For example, \"aovc\" matches \"avocados\".\n */\nconst anagramMatch = (query: string, target: string): boolean => {\n\tif (!query) return true\n\tif (!target) return false\n\n\tconst countChars = (s: string): Record<string, number> =>\n\t\ts\n\t\t\t.toLowerCase()\n\t\t\t.split('')\n\t\t\t.reduce(\n\t\t\t\t(acc, char) => {\n\t\t\t\t\tacc[char] = (acc[char] || 0) + 1\n\t\t\t\t\treturn acc\n\t\t\t\t},\n\t\t\t\t{} as Record<string, number>,\n\t\t\t)\n\n\tconst queryCount = countChars(query)\n\tconst targetCount = countChars(target)\n\treturn Object.keys(queryCount).every(char => (targetCount[char] || 0) >= queryCount[char])\n}\n\n/**\n * Generate bigrams for a string.\n */\nconst getBigrams = (s: string): string[] => {\n\tif (!s || s.length < 2) return []\n\n\tconst bigrams: string[] = []\n\tfor (let i = 0; i < s.length - 1; i++) {\n\t\tbigrams.push(s.substring(i, i + 2).toLowerCase())\n\t}\n\treturn bigrams\n}\n\n/**\n * Compute Dice's coefficient for two strings based on bigrams.\n * Returns a value between 0 (no similarity) and 1 (perfect match).\n */\nconst diceCoefficient = (s1: string, s2: string): number => {\n\tif (!s1 || !s2 || s1.length < 2 || s2.length < 2) return 0\n\n\tconst bigrams1 = getBigrams(s1)\n\tconst bigrams2 = getBigrams(s2)\n\n\tif (bigrams1.length === 0 || bigrams2.length === 0) return 0\n\n\tlet intersection = 0\n\tconst used = new Array(bigrams2.length).fill(false)\n\n\tfor (const bigram of bigrams1) {\n\t\tfor (let i = 0; i < bigrams2.length; i++) {\n\t\t\tif (!used[i] && bigrams2[i] === bigram) {\n\t\t\t\tintersection++\n\t\t\t\tused[i] = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (2 * intersection) / (bigrams1.length + bigrams2.length)\n}\n\n/**\n * Compute a fuzzy similarity score between two strings.\n * The score is computed by taking the maximum of several methods:\n * - Direct substring match (score 1)\n * - Subsequence check (score 0.8)\n * - Anagram subset match (score 0.7)\n * - Dice coefficient\n * - Normalized Levenshtein similarity\n */\nconst computeFuzzyScore = (actual: string, expected: string): number => {\n\tif (!actual || !expected) return 0\n\n\tconst a = actual.toLowerCase().trim()\n\tconst b = expected.toLowerCase().trim()\n\n\tif (a === b) return 1\n\n\tconst substringScore = a.includes(b) ? 1 : 0\n\tconst subsequenceScore = isSubsequence(b, a) ? 0.8 : 0\n\tconst anagramScore = anagramMatch(b, a) ? 0.7 : 0\n\tconst diceScore = diceCoefficient(a, b)\n\n\tconst maxLen = Math.max(a.length, b.length)\n\tconst levenshteinScore = maxLen ? 1 - levenshtein(a, b) / maxLen : 0\n\n\treturn Math.max(substringScore, subsequenceScore, anagramScore, diceScore, levenshteinScore)\n}\n\n/**\n * Safely coerce value to string if possible, or return empty string\n */\nconst safeString = (value: unknown): string => {\n\tif (value == null) return ''\n\treturn String(value)\n}\n\n/**\n * Type guard for arrays\n */\nconst isArray = (value: unknown): value is Array<unknown> => {\n\treturn Array.isArray(value)\n}\n\n/**\n * Compare two values based on a comparison operator.\n * For non-fuzzy operators, this returns a boolean.\n */\nexport function compareValues(op: ComparisonOperator, actual: unknown, expected: unknown): boolean {\n\t// Handle null/undefined cases\n\tif (actual == null && expected == null) return true\n\tif (actual == null || expected == null) {\n\t\t// For equality operators, null == null but null != non-null\n\t\tif (op === '==') return actual === expected\n\t\tif (op === '!=') return actual !== expected\n\t\t// Other operators should return false for null/undefined values\n\t\treturn false\n\t}\n\n\tswitch (op) {\n\t\tcase '==':\n\t\t\treturn actual === expected\n\t\tcase '!=':\n\t\t\treturn actual !== expected\n\t\tcase '>':\n\t\t\treturn (actual as number) > (expected as number)\n\t\tcase '<':\n\t\t\treturn (actual as number) < (expected as number)\n\t\tcase '>=':\n\t\t\treturn (actual as number) >= (expected as number)\n\t\tcase '<=':\n\t\t\treturn (actual as number) <= (expected as number)\n\t\tcase 'includes': {\n\t\t\tif (typeof actual === 'string') {\n\t\t\t\treturn safeString(actual).toLowerCase().includes(safeString(expected).toLowerCase())\n\t\t\t} else if (isArray(actual)) {\n\t\t\t\treturn actual.includes(expected)\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIncludes': {\n\t\t\tif (typeof actual === 'string') {\n\t\t\t\treturn !safeString(actual).toLowerCase().includes(safeString(expected).toLowerCase())\n\t\t\t} else if (isArray(actual)) {\n\t\t\t\treturn !actual.includes(expected)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tcase 'startsWith': {\n\t\t\tif (typeof actual === 'string' && typeof expected === 'string') {\n\t\t\t\treturn actual.toLowerCase().startsWith(expected.toLowerCase())\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'endsWith': {\n\t\t\tif (typeof actual === 'string' && typeof expected === 'string') {\n\t\t\t\treturn actual.toLowerCase().endsWith(expected.toLowerCase())\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'in': {\n\t\t\tif (isArray(expected)) {\n\t\t\t\treturn expected.includes(actual)\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIn': {\n\t\t\tif (isArray(expected)) {\n\t\t\t\treturn !expected.includes(actual)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tdefault: {\n\t\t\tconsole.warn(`Operator \"${op}\" is not supported in strict comparison.`)\n\t\t\treturn false\n\t\t}\n\t}\n}\n\n/**\n * Apply a query condition to an item and return score\n */\nfunction applyQueryCondition<T extends Record<string, any>>(\n\titem: T,\n\tquery: QueryCondition,\n\tfuzzyThreshold: number = 0.3,\n): { valid: boolean; score: number } {\n\tlet field: string,\n\t\top: ComparisonOperator,\n\t\texpected: unknown,\n\t\tstrict = false\n\n\tif (Array.isArray(query)) {\n\t\t;[field, op, expected, strict = false] = query\n\t} else {\n\t\tfield = query.key\n\t\top = query.operator\n\t\texpected = query.value\n\t\tstrict = query.strict || false\n\t}\n\n\t// Skip empty filters for non-strict queries\n\tif (!strict && (expected === '' || expected == null || (isArray(expected) && expected.length === 0))) {\n\t\treturn { valid: true, score: 1 }\n\t}\n\n\tconst actual = getFieldValue(item, field)\n\n\t// If strict mode is enabled, enforce exact equality\n\tif (strict) {\n\t\tif (actual !== expected) {\n\t\t\treturn { valid: false, score: 0 }\n\t\t}\n\t\treturn { valid: true, score: 1 }\n\t}\n\n\tif (op === 'any') {\n\t\t// Fuzzy search requires both values to be strings\n\t\tif (typeof actual !== 'string' || typeof expected !== 'string') {\n\t\t\treturn { valid: false, score: 0 }\n\t\t}\n\n\t\tconst score = computeFuzzyScore(actual, expected)\n\t\tif (score < fuzzyThreshold) {\n\t\t\treturn { valid: false, score: 0 }\n\t\t}\n\n\t\treturn { valid: true, score }\n\t} else {\n\t\t// For non-fuzzy operators, check condition\n\t\tconst matches = compareValues(op, actual, expected)\n\t\treturn {\n\t\t\tvalid: matches,\n\t\t\tscore: matches ? 1 : 0,\n\t\t}\n\t}\n}\n\n/**\n * Filter a Map of items given an array of query conditions.\n * For each query condition:\n * - If the expected value is empty/null/undefined, it is treated as a match.\n * - For non-fuzzy operators, the condition must strictly match.\n * - For the \"any\" operator, a fuzzy similarity score is computed.\n * Items with a fuzzy score below a given threshold (e.g., 0.3) are excluded.\n *\n * The overall item score is the average of the scores from all conditions.\n * The results are sorted in descending order of relevance.\n *\n * @param items - A Map containing items to filter.\n * @param queries - An array of query conditions to apply.\n * @param fuzzyThreshold - Minimum score required for fuzzy matches (default: 0.3)\n * @returns An array of items that match all query conditions, sorted by relevance.\n */\nexport function filterMapItems<T extends Record<string, any>>(\n\titems: Map<string, T>,\n\tqueries: QueryCondition[] = [],\n\tfuzzyThreshold: number = 0.3,\n): T[] {\n\t// If no queries, return all items unsorted\n\tif (!queries.length) {\n\t\treturn Array.from(items.values())\n\t}\n\n\t// Score and filter each item\n\tconst scoredItems: ScoredItem<T>[] = []\n\n\tfor (const [_, item] of items.entries()) {\n\t\tlet totalScore = 0\n\t\tlet matchCount = 0\n\t\tlet valid = true\n\n\t\tfor (const query of queries) {\n\t\t\tconst result = applyQueryCondition(item, query, fuzzyThreshold)\n\n\t\t\tif (!result.valid) {\n\t\t\t\tvalid = false\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ttotalScore += result.score\n\t\t\tmatchCount++\n\t\t}\n\n\t\tif (valid) {\n\t\t\tscoredItems.push({\n\t\t\t\titem,\n\t\t\t\tscore: matchCount > 0 ? totalScore / matchCount : 1,\n\t\t\t})\n\t\t}\n\t}\n\n\t// Sort by descending score\n\tscoredItems.sort((a, b) => b.score - a.score)\n\n\treturn scoredItems.map(x => x.item)\n}\n\n/**\n * Filter an array of items using query conditions\n */\nexport function filterArrayItems<T extends Record<string, any>>(\n\titems: T[],\n\tqueries: QueryCondition[] = [],\n\tfuzzyThreshold: number = 0.3,\n): T[] {\n\t// Create temporary map with numeric indices as keys\n\tconst map = new Map<string, T>()\n\titems.forEach((item, index) => map.set(String(index), item))\n\n\treturn filterMapItems(map, queries, fuzzyThreshold)\n}\n\n// Export a simpler alias for filterMapItems\nexport const filterMap = filterMapItems\n\n// Export an alias for filterArrayItems\nexport const filterArray = filterArrayItems\n","// src/store/selectors.ts\nimport { Observable, combineLatest, distinctUntilChanged, map, shareReplay } from 'rxjs'\nimport { IStore, ICollectionStore } from './types'\n\n/**\n * Deep equality comparison for maps and complex objects\n * More efficient than JSON.stringify for large objects\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n\tif (a === b) return true\n\n\tif (a instanceof Map && b instanceof Map) {\n\t\tif (a.size !== b.size) return false\n\t\tfor (const [key, value] of a) {\n\t\t\tif (!b.has(key) || !deepEqual(value, b.get(key))) return false\n\t\t}\n\t\treturn true\n\t}\n\n\tif (a instanceof Set && b instanceof Set) {\n\t\tif (a.size !== b.size) return false\n\t\tfor (const item of a) {\n\t\t\tif (!b.has(item)) return false\n\t\t}\n\t\treturn true\n\t}\n\n\tif (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null) {\n\t\tconst keysA = Object.keys(a)\n\t\tconst keysB = Object.keys(b)\n\n\t\tif (keysA.length !== keysB.length) return false\n\n\t\tfor (const key of keysA) {\n\t\t\t// @ts-ignore: Index signature\n\t\t\tif (!deepEqual(a[key], b[key])) return false\n\t\t}\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Creates a selector that derives a value from store state\n *\n * @param store The store to observe\n * @param selectorFn Function that transforms the state\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createSelector<T, R>(store: IStore<T>, selectorFn: (state: T) => R): Observable<R> {\n\treturn store.$.pipe(map(selectorFn), distinctUntilChanged<R>(deepEqual), shareReplay(1))\n}\n\n/**\n * Creates a selector for collection stores that derives a value from the collection\n *\n * @param store The collection store to observe\n * @param selectorFn Function that transforms the collection\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createCollectionSelector<T, R>(\n\tstore: ICollectionStore<T>,\n\tselectorFn: (state: Map<string, T>) => R,\n): Observable<R> {\n\treturn store.$.pipe(map(selectorFn), distinctUntilChanged<R>(deepEqual), shareReplay(1))\n}\n\n/**\n * Creates a selector that returns all items from a collection as an array\n *\n * @param store The collection store\n * @returns An observable of all items as an array\n */\nexport function createItemsSelector<T>(store: ICollectionStore<T>): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => Array.from(collection.values()))\n}\n\n/**\n * Creates a selector that filters items from a collection\n *\n * @param store The collection store\n * @param filterFn Function that returns true for items to include\n * @returns An observable of filtered items as an array\n */\nexport function createFilterSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn: (item: T, key: string) => boolean,\n): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\tconst result: T[] = []\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) {\n\t\t\t\tresult.push(item)\n\t\t\t}\n\t\t})\n\t\treturn result\n\t})\n}\n\n/**\n * Creates a selector that retrieves a single item from a collection\n *\n * @param store The collection store\n * @param itemKey The key of the item to select\n * @returns An observable of the selected item that emits when the item changes\n */\nexport function createItemSelector<T>(store: ICollectionStore<T>, itemKey: string): Observable<T | undefined> {\n\treturn createCollectionSelector(store, collection => collection.get(itemKey))\n}\n\n/**\n * Creates a selector that counts items in a collection, optionally filtered\n *\n * @param store The collection store\n * @param filterFn Optional function to filter which items to count\n * @returns An observable of the count\n */\nexport function createCountSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn?: (item: T, key: string) => boolean,\n): Observable<number> {\n\treturn createCollectionSelector(store, collection => {\n\t\tif (!filterFn) return collection.size\n\n\t\tlet count = 0\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) count++\n\t\t})\n\t\treturn count\n\t})\n}\n\n/**\n * Creates a compound selector that depends on multiple other selectors\n *\n * @param selectors Array of source selectors\n * @param combinerFn Function that combines all selector results\n * @returns An observable of the combined result\n */\nexport function createCompoundSelector<T extends unknown[], R>(\n\tselectors: { [K in keyof T]: Observable<T[K]> },\n\tcombinerFn: (...values: T) => R,\n): Observable<R> {\n\treturn combineLatest(selectors).pipe(\n\t\tmap(values => combinerFn(...(values as T))),\n\t\tdistinctUntilChanged<R>(deepEqual),\n\t\tshareReplay(1),\n\t)\n}\n\n/**\n * Creates a selector that returns all keys from a collection\n */\nexport function createKeysSelector<T>(store: ICollectionStore<T>): Observable<string[]> {\n\treturn createCollectionSelector(store, collection => Array.from(collection.keys()))\n}\n\n/**\n * Creates a selector that returns entries (key-value pairs) from a collection\n */\nexport function createEntriesSelector<T>(store: ICollectionStore<T>): Observable<[string, T][]> {\n\treturn createCollectionSelector(store, collection => Array.from(collection.entries()))\n}\n\n/**\n * Creates a selector that maps collection values through a transform function\n */\nexport function createMapSelector<T, R>(\n\tstore: ICollectionStore<T>,\n\tmapFn: (item: T, key: string) => R,\n): Observable<R[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\tconst result: R[] = []\n\t\tcollection.forEach((item, key) => {\n\t\t\tresult.push(mapFn(item, key))\n\t\t})\n\t\treturn result\n\t})\n}\n\n/**\n * Creates a selector that sorts collection items\n */\nexport function createSortSelector<T>(store: ICollectionStore<T>, compareFn: (a: T, b: T) => number): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\treturn Array.from(collection.values()).sort(compareFn)\n\t})\n}\n\n/**\n * Creates a selector that finds the first item matching a predicate\n */\nexport function createFindSelector<T>(\n\tstore: ICollectionStore<T>,\n\tpredicate: (item: T, key: string) => boolean,\n): Observable<T | undefined> {\n\treturn createCollectionSelector(store, collection => {\n\t\tfor (const [key, item] of collection.entries()) {\n\t\t\tif (predicate(item, key)) {\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t})\n}\n","// src/store/selector-hook.ts\nimport { property as litProperty } from 'lit/decorators.js'\nimport { Observable, Subject, Subscription } from 'rxjs'\nimport { takeUntil } from 'rxjs/operators'\nimport { createCollectionSelector, createSelector } from './selectors'\nimport { ICollectionStore, IStore } from './types'\n\n/**\n * Component lifecycle interface\n */\ninterface ComponentWithLifecycle {\n\t// Lifecycle hooks\n\tisConnected: boolean\n\tdisconnectedCallback?: () => void\n\tconnectedCallback?: () => void\n\trequestUpdate?: () => void\n\n\t// Internal properties\n\t_selectorCleanup?: Subject<void>\n\t_selectorSubscriptions?: Map<string, Subscription>\n\t_selectorInitialized?: Set<string>\n\n\t// Value storage\n\t[key: string]: any\n}\n\n/**\n * Property descriptor interface\n */\ntype PropertyDescriptor<T> = {\n\tget?: () => T\n\tset?: (value: T) => void\n\tvalue?: T\n\tconfigurable?: boolean\n\tenumerable?: boolean\n\twritable?: boolean\n}\n\n/**\n * Options for selecting from a store\n */\ninterface SelectOptions {\n\t/** If true, will wait for selector to emit a non-null value before calling connectedCallback */\n\trequired?: boolean\n\n\t/** If true, will only update the component and not set the property value */\n\tupdateOnly?: boolean\n\n\t/** If true, will use structuredClone to deeply clone values (prevents mutations) */\n\tdeepClone?: boolean\n\n\t/** Custom equality function to determine when to update */\n\tequals?: (a: any, b: any) => boolean\n}\n\n/**\n * Type guard to check if a store is a collection store\n */\nfunction isCollectionStore<T>(store: IStore<any> | ICollectionStore<T>): store is ICollectionStore<T> {\n\treturn 'set' in store && typeof store.set === 'function' && store.value instanceof Map\n}\n\n/**\n * Selector decorator that connects a component property to a store selector\n *\n * @param store The store to select from\n * @param selectorFn Optional function to transform the store state\n * @param options Additional options for the selector\n */\nexport function select<T, R>(\n\tstore: IStore<T> | ICollectionStore<T>,\n\tselectorFn: (state: any) => R = (state: R) => state,\n\toptions: SelectOptions = {},\n) {\n\treturn function (proto: Record<string, any>, propName: string, _descriptor?: PropertyDescriptor<R>) {\n\t\t// Register as a Lit property\n\t\tlitProperty({ attribute: false, type: Object })(proto, propName)\n\n\t\t// Store original lifecycle methods\n\t\tconst originalConnectedCallback = proto.connectedCallback\n\t\tconst originalDisconnectedCallback = proto.disconnectedCallback\n\n\t\t// Override connectedCallback to set up subscription\n\t\tproto.connectedCallback = function (this: ComponentWithLifecycle) {\n\t\t\t// Initialize tracking properties if needed\n\t\t\tif (!this._selectorCleanup || this._selectorCleanup.closed) {\n\t\t\t\tthis._selectorCleanup = new Subject<void>()\n\t\t\t}\n\n\t\t\tif (!this._selectorSubscriptions) {\n\t\t\t\tthis._selectorSubscriptions = new Map()\n\t\t\t}\n\n\t\t\tif (!this._selectorInitialized) {\n\t\t\t\tthis._selectorInitialized = new Set()\n\t\t\t}\n\n\t\t\t// Create the appropriate selector\n\t\t\tconst selector: Observable<R> = isCollectionStore(store)\n\t\t\t\t? createCollectionSelector(store, selectorFn)\n\t\t\t\t: createSelector(store as IStore<T>, selectorFn)\n\n\t\t\t// Call original connectedCallback immediately if not waiting for data\n\t\t\tif (!options.required && !this._selectorInitialized.has(propName)) {\n\t\t\t\toriginalConnectedCallback?.call(this)\n\t\t\t\tthis._selectorInitialized.add(propName)\n\t\t\t}\n\n\t\t\t// Clean up any existing subscription\n\t\t\tif (this._selectorSubscriptions.has(propName)) {\n\t\t\t\tthis._selectorSubscriptions.get(propName)?.unsubscribe()\n\t\t\t}\n\n\t\t\t// Create new subscription\n\t\t\tconst subscription = selector.pipe(takeUntil(this._selectorCleanup)).subscribe({\n\t\t\t\tnext: (value: R) => {\n\t\t\t\t\t// Handle value updates\n\t\t\t\t\tconst newValue = options.deepClone ? structuredClone(value) : value\n\n\t\t\t\t\tif (!options.updateOnly) {\n\t\t\t\t\t\tthis[propName] = newValue\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.requestUpdate?.()\n\n\t\t\t\t\t// If required and not initialized, call connectedCallback when we get a value\n\t\t\t\t\tif (\n\t\t\t\t\t\toptions.required &&\n\t\t\t\t\t\t!this._selectorInitialized.has(propName) &&\n\t\t\t\t\t\tnewValue !== null &&\n\t\t\t\t\t\tnewValue !== undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\toriginalConnectedCallback?.call(this)\n\t\t\t\t\t\tthis._selectorInitialized.add(propName)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: (err: Error) => {\n\t\t\t\t\tconsole.error(`Error in selector subscription for ${propName}:`, err)\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// Store the subscription for cleanup\n\t\t\tthis._selectorSubscriptions.set(propName, subscription)\n\t\t}\n\n\t\t// Override disconnectedCallback to clean up subscriptions\n\t\tproto.disconnectedCallback = function (this: ComponentWithLifecycle) {\n\t\t\t// Call original disconnectedCallback\n\t\t\toriginalDisconnectedCallback?.call(this)\n\n\t\t\t// Clean up subscriptions\n\t\t\tif (this._selectorCleanup) {\n\t\t\t\tthis._selectorCleanup.next()\n\t\t\t\tthis._selectorCleanup.complete()\n\t\t\t}\n\n\t\t\tif (this._selectorSubscriptions) {\n\t\t\t\tthis._selectorSubscriptions.forEach(sub => sub.unsubscribe())\n\t\t\t\tthis._selectorSubscriptions.clear()\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Creates a selector decorator that selects a specific item from a collection store\n *\n * @param store The collection store\n * @param keyGetter Function that returns the key to select\n * @param options Additional options\n */\nexport function selectItem<T>(\n\tstore: ICollectionStore<T>,\n\tkeyGetter: (component: any) => string,\n\toptions: SelectOptions = {},\n) {\n\treturn function (proto: Record<string, any>, propName: string, _descriptor?: PropertyDescriptor<T | undefined>) {\n\t\tselect(\n\t\t\tstore,\n\t\t\tstate => {\n\t\t\t\t// This will be evaluated during subscription, when 'this' is available\n\t\t\t\tconst itemKey = keyGetter(this)\n\t\t\t\treturn itemKey ? state.get(itemKey) : undefined\n\t\t\t},\n\t\t\toptions,\n\t\t)(proto, propName)\n\t}\n}\n"],"names":["createObjectStore","initialData","storage","key","StoreError","store","SchmancyStoreObject","getInstance","obj","value","Object","keys","length","$","next","createContext","Map","SchmancyCollectionStore","size","dataType","createObjectContext","createCollectionContext","Array","isArray","map","item","index","String","getFieldValue","path","parts","split","part","getBigrams","s","bigrams","i","push","substring","toLowerCase","computeFuzzyScore","actual","expected","a","trim","b","substringScore","includes","subsequenceScore","sub","str","j","anagramScore","query","target","countChars","reduce","acc","char","queryCount","targetCount","every","diceScore","s1","s2","bigrams1","bigrams2","intersection","used","fill","bigram","maxLen","Math","max","levenshteinScore","matrix","_","charAt","min","safeString","compareValues","op","startsWith","endsWith","applyQueryCondition","fuzzyThreshold","field","strict","operator","valid","score","matches","filterMapItems","items","queries","from","values","scoredItems","entries","totalScore","matchCount","result","sort","x","filterArrayItems","forEach","set","filterMap","filterArray","deepEqual","has","get","Set","keysA","keysB","createSelector","selectorFn","pipe","distinctUntilChanged","shareReplay","createCollectionSelector","createItemsSelector","collection","createFilterSelector","filterFn","createItemSelector","itemKey","createCountSelector","count","createCompoundSelector","selectors","combinerFn","combineLatest","createKeysSelector","createEntriesSelector","createMapSelector","mapFn","createSortSelector","compareFn","createFindSelector","predicate","select","state","options","proto","propName","_descriptor","litProperty","attribute","type","originalConnectedCallback","connectedCallback","originalDisconnectedCallback","disconnectedCallback","this","_selectorCleanup","closed","Subject","_selectorSubscriptions","_selectorInitialized","selector","required","call","add","unsubscribe","subscription","takeUntil","subscribe","newValue","deepClone","structuredClone","updateOnly","requestUpdate","error","err","complete","clear","selectItem","keyGetter"],"mappings":";;;;AA4CA,SAASA,EACRC,GACAC,GACAC,GAAAA;AAGA,MAAID,MAAY,YACf,OAAM,IAAIE,EAAW,wDAAwD,MAAM,EAAEF,SAASC,GAAAA,KAAAA,EAAAA,CAAAA;AAI/F,QAAME,IAAQC,EAAoBC,YAAeL,GAASC,GAAKF;AA/ChE,MAAuBO;AAsDf,SAtDeA,QAAAA,IAkDJH,EAAMI,UAjDL,YAAYD,MAAQ,QAGhCE,OAAOC,KAAKH,CAAAA,EAAKI,WAAW,KA+C5BP,EAAAQ,EAAEC,KAAKb,CAGPI,GAAAA;AACR;AA4CgB,SAAAU,EACfd,GACAC,GACAC,GAAAA;AAGI,MACH,KADGF,KACH,OAAM,IAAIG,EAAW,4CAA4C,MAAM,EAAEF,SAAAA,GAASC;AAI/E,MAAMF,aAhFce,IAiFhB,QAnDT,SACCf,GACAC,GACAC,GAAAA;AAGA,UAAME,IAAQY,EAAwBV,YAAYL,GAASC,GAAKF;AAOzD,WAJFI,EAAMI,MAAMS,QAChBb,EAAMQ,EAAEC,KAAK,IAAIE,IAAIf,CAAAA,CAAAA,GAGfI;AAAAA,EACR,EAqC+BJ,GAAiCC,GAASC,CAAAA;AACxE,MAAkBF,OAAAA,KAAgB,SAC1B,QAAAD,EAAkBC,GAAaC,GAASC,CAEzC;AAAA,QAAA,IAAIC,EAAW,2CAA2C,MAAM,EACrEF,YACAC,KACAgB,GAAAA,UAAAA,OAAiBlB;AAGpB;AAKO,SAASmB,EACfnB,GACAE,GACAD,IAAuB,SAEhB;AAAA,SAAAa,EAAcd,GAAaC,GAAS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iB7I,KACtB4I,GAAAA,KAAKC,iBAAiBoB,SAGnBrB,IAAAA,KAAKI,2BACRJ,KAAKI,uBAAuBrD,QAAexD,CAAAA,MAAAA,EAAImH,gBAC/CV,KAAKI,uBAAuBkB;IAE9B;AAAA,EACD;AACD;AASO,SAASC,GACf5K,GACA6K,GACAnC,IAAyB,CAAA,GAElB;AAAA,SAAA,SAAUC,GAA4BC,GAAkBC,GAC9DL;AAAAA,MACCxI,GACSyI,CAAAA,MAEF;AAAA,YAAAhB,IAAUoD,EAAUxB,IAAAA;AAC1B,aAAO5B,IAAUgB,EAAM/B,IAAIe,CAAW,IAAA;AAAA,IAAA,GAEvCiB,CAPDF,EAQEG,GAAOC,CACV;AAAA,EAAA;AACD;"}
@@ -1,2 +0,0 @@
1
- "use strict";const w=require("./context-object-D81PeS3j.cjs"),E=require("lit/decorators.js"),g=require("rxjs"),O=require("rxjs/operators");function q(n,e,t){if(e==="indexeddb")throw new w.StoreError("IndexedDB storage is not supported for plain objects",null,{storage:e,key:t});const r=w.SchmancyStoreObject.getInstance(e,t,n);var o;return typeof(o=r.value)=="object"&&o!==null&&Object.keys(o).length===0&&r.$.next(n),r}function I(n,e,t){if(n==null)throw new w.StoreError("Initial data cannot be null or undefined",null,{storage:e,key:t});if(n instanceof Map)return function(r,o,i){const u=w.SchmancyCollectionStore.getInstance(o,i,r);return u.value.size||u.$.next(new Map(r)),u}(n,e,t);if(typeof n=="object")return q(n,e,t);throw new w.StoreError("Initial data must be an object or a Map",null,{storage:e,key:t,dataType:typeof n})}const L=(n,e)=>{if(!e)return n;const t=e.split(".");let r=n;for(const o of t){if(r==null)return;r=r[o]}return r},k=n=>{if(!n||n.length<2)return[];const e=[];for(let t=0;t<n.length-1;t++)e.push(n.substring(t,t+2).toLowerCase());return e},U=(n,e)=>{if(!n||!e)return 0;const t=n.toLowerCase().trim(),r=e.toLowerCase().trim();if(t===r)return 1;const o=t.includes(r)?1:0,i=((l,c)=>{if(!l)return!0;if(!c)return!1;let a=0,s=0;for(;a<l.length&&s<c.length;)l[a].toLowerCase()===c[s].toLowerCase()&&a++,s++;return a===l.length})(r,t)?.8:0,u=((l,c)=>{if(!l)return!0;if(!c)return!1;const a=b=>b.toLowerCase().split("").reduce((S,y)=>(S[y]=(S[y]||0)+1,S),{}),s=a(l),h=a(c);return Object.keys(s).every(b=>(h[b]||0)>=s[b])})(r,t)?.7:0,f=((l,c)=>{if(!l||!c||l.length<2||c.length<2)return 0;const a=k(l),s=k(c);if(a.length===0||s.length===0)return 0;let h=0;const b=new Array(s.length).fill(!1);for(const S of a)for(let y=0;y<s.length;y++)if(!b[y]&&s[y]===S){h++,b[y]=!0;break}return 2*h/(a.length+s.length)})(t,r),p=Math.max(t.length,r.length),C=p?1-((l,c)=>{if(l===c)return 0;const a=Array(c.length+1).fill(null).map((s,h)=>[h]);for(let s=0;s<=l.length;s++)a[0][s]=s;for(let s=1;s<=c.length;s++)for(let h=1;h<=l.length;h++)c.charAt(s-1)===l.charAt(h-1)?a[s][h]=a[s-1][h-1]:a[s][h]=Math.min(a[s-1][h]+1,a[s][h-1]+1,a[s-1][h-1]+1);return a[c.length][l.length]})(t,r)/p:0;return Math.max(o,i,u,f,C)},v=n=>n==null?"":String(n),m=n=>Array.isArray(n);function M(n,e,t){if(e==null&&t==null)return!0;if(e==null||t==null)return n==="=="?e===t:n==="!="&&e!==t;switch(n){case"==":return e===t;case"!=":return e!==t;case">":return e>t;case"<":return e<t;case">=":return e>=t;case"<=":return e<=t;case"includes":return typeof e=="string"?v(e).toLowerCase().includes(v(t).toLowerCase()):!!m(e)&&e.includes(t);case"notIncludes":return typeof e=="string"?!v(e).toLowerCase().includes(v(t).toLowerCase()):!m(e)||!e.includes(t);case"startsWith":return typeof e=="string"&&typeof t=="string"&&e.toLowerCase().startsWith(t.toLowerCase());case"endsWith":return typeof e=="string"&&typeof t=="string"&&e.toLowerCase().endsWith(t.toLowerCase());case"in":return!!m(t)&&t.includes(e);case"notIn":return!m(t)||!t.includes(e);default:return!1}}function W(n,e,t=.3){let r,o,i,u=!1;if(Array.isArray(e)?[r,o,i,u=!1]=e:(r=e.key,o=e.operator,i=e.value,u=e.strict||!1),!u&&(i===""||i==null||m(i)&&i.length===0))return{valid:!0,score:1};const f=L(n,r);if(u)return f!==i?{valid:!1,score:0}:{valid:!0,score:1};if(o==="any"){if(typeof f!="string"||typeof i!="string")return{valid:!1,score:0};const p=U(f,i);return p<t?{valid:!1,score:0}:{valid:!0,score:p}}{const p=M(o,f,i);return{valid:p,score:p?1:0}}}function A(n,e=[],t=.3){if(!e.length)return Array.from(n.values());const r=[];for(const[o,i]of n.entries()){let u=0,f=0,p=!0;for(const C of e){const l=W(i,C,t);if(!l.valid){p=!1;break}u+=l.score,f++}p&&r.push({item:i,score:f>0?u/f:1})}return r.sort((o,i)=>i.score-o.score),r.map(o=>o.item)}function x(n,e=[],t=.3){const r=new Map;return n.forEach((o,i)=>r.set(String(i),o)),A(r,e,t)}const $=A,F=x;function _(n,e){if(n===e)return!0;if(n instanceof Map&&e instanceof Map){if(n.size!==e.size)return!1;for(const[t,r]of n)if(!e.has(t)||!_(r,e.get(t)))return!1;return!0}if(n instanceof Set&&e instanceof Set){if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;return!0}if(typeof n=="object"&&n!==null&&typeof e=="object"&&e!==null){const t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;for(const o of t)if(!_(n[o],e[o]))return!1;return!0}return!1}function z(n,e){return n.$.pipe(g.map(e),g.distinctUntilChanged(_),g.shareReplay(1))}function d(n,e){return n.$.pipe(g.map(e),g.distinctUntilChanged(_),g.shareReplay(1))}function j(n,e=r=>r,t={}){return function(r,o,i){E.property({attribute:!1,type:Object})(r,o);const u=r.connectedCallback,f=r.disconnectedCallback;r.connectedCallback=function(){var l;this._selectorCleanup&&!this._selectorCleanup.closed||(this._selectorCleanup=new g.Subject),this._selectorSubscriptions||(this._selectorSubscriptions=new Map),this._selectorInitialized||(this._selectorInitialized=new Set);const p=function(c){return"set"in c&&typeof c.set=="function"&&c.value instanceof Map}(n)?d(n,e):z(n,e);t.required||this._selectorInitialized.has(o)||(u==null||u.call(this),this._selectorInitialized.add(o)),this._selectorSubscriptions.has(o)&&((l=this._selectorSubscriptions.get(o))==null||l.unsubscribe());const C=p.pipe(O.takeUntil(this._selectorCleanup)).subscribe({next:c=>{var s;const a=t.deepClone?structuredClone(c):c;t.updateOnly||(this[o]=a),(s=this.requestUpdate)==null||s.call(this),t.required&&!this._selectorInitialized.has(o)&&a!=null&&(u==null||u.call(this),this._selectorInitialized.add(o))},error:c=>{}});this._selectorSubscriptions.set(o,C)},r.disconnectedCallback=function(){f==null||f.call(this),this._selectorCleanup&&(this._selectorCleanup.next(),this._selectorCleanup.complete()),this._selectorSubscriptions&&(this._selectorSubscriptions.forEach(p=>p.unsubscribe()),this._selectorSubscriptions.clear())}}}exports.compareValues=M,exports.createCollectionContext=function(n,e,t="local"){return I(Array.isArray(n)?new Map(n.map((r,o)=>[String(o),r])):n,t,e)},exports.createCollectionSelector=d,exports.createCompoundSelector=function(n,e){return g.combineLatest(n).pipe(g.map(t=>e(...t)),g.distinctUntilChanged(_),g.shareReplay(1))},exports.createContext=I,exports.createCountSelector=function(n,e){return d(n,t=>{if(!e)return t.size;let r=0;return t.forEach((o,i)=>{e(o,i)&&r++}),r})},exports.createEntriesSelector=function(n){return d(n,e=>Array.from(e.entries()))},exports.createFilterSelector=function(n,e){return d(n,t=>{const r=[];return t.forEach((o,i)=>{e(o,i)&&r.push(o)}),r})},exports.createFindSelector=function(n,e){return d(n,t=>{for(const[r,o]of t.entries())if(e(o,r))return o})},exports.createItemSelector=function(n,e){return d(n,t=>t.get(e))},exports.createItemsSelector=function(n){return d(n,e=>Array.from(e.values()))},exports.createKeysSelector=function(n){return d(n,e=>Array.from(e.keys()))},exports.createMapSelector=function(n,e){return d(n,t=>{const r=[];return t.forEach((o,i)=>{r.push(e(o,i))}),r})},exports.createObjectContext=function(n,e,t="local"){return I(n,t,e)},exports.createSelector=z,exports.createSortSelector=function(n,e){return d(n,t=>Array.from(t.values()).sort(e))},exports.filterArray=F,exports.filterArrayItems=x,exports.filterMap=$,exports.filterMapItems=A,exports.getFieldValue=L,exports.select=j,exports.selectItem=function(n,e,t={}){return function(r,o,i){j(n,u=>{const f=e(this);return f?u.get(f):void 0},t)(r,o)}};
2
- //# sourceMappingURL=selector-hook-CH-z8W2d.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selector-hook-CH-z8W2d.cjs","sources":["../src/store/context-create.ts","../src/store/filter-directive.ts","../src/store/selectors.ts","../src/store/selector-hook.ts"],"sourcesContent":["// src/store/context-create.ts\nimport SchmancyCollectionStore from './context-collection'\nimport { SchmancyStoreObject } from './context-object'\nimport { ICollectionStore, IStore, StorageType, StoreError } from './types'\n\n/**\n * Type guard to check if an object is empty\n */\nfunction isEmptyObject(obj: unknown): boolean {\n\tif (typeof obj !== 'object' || obj === null) {\n\t\treturn false\n\t}\n\treturn Object.keys(obj).length === 0\n}\n\n/**\n * Type guard to check if object is an iterable collection\n */\n// function isCollection(obj: unknown): obj is Iterable<unknown> {\n// \t// Must be non-null and of type 'object'\n// \tif (obj == null || typeof obj !== 'object') {\n// \t\treturn false\n// \t}\n\n// \t// Exclude plain objects\n// \tconst proto = Object.getPrototypeOf(obj)\n// \tif (proto === Object.prototype || proto === null) {\n// \t\treturn false\n// \t}\n\n// \t// Check for Symbol.iterator method\n// \treturn typeof obj[Symbol.iterator] === 'function'\n// }\n\n/**\n * Type guard for Map objects\n */\nfunction isMap<K, V>(value: unknown): value is Map<K, V> {\n\treturn value instanceof Map\n}\n\n/**\n * Creates a regular object store\n */\nfunction createObjectStore<T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n): IStore<T> & SchmancyStoreObject<T> {\n\t// Validate storage type\n\tif (storage === 'indexeddb') {\n\t\tthrow new StoreError('IndexedDB storage is not supported for plain objects', null, { storage, key })\n\t}\n\n\t// Create the store instance\n\tconst store = SchmancyStoreObject.getInstance<T>(storage, key, initialData)\n\n\t// Initialize with provided data if store is empty\n\tif (isEmptyObject(store.value)) {\n\t\tstore.$.next(initialData)\n\t}\n\n\treturn store\n}\n\n/**\n * Creates a collection store\n */\nfunction createCollectionStore<V>(\n\tinitialData: Map<string, V>,\n\tstorage: StorageType,\n\tkey: string,\n): ICollectionStore<V> & SchmancyCollectionStore<V> {\n\t// Create the store instance\n\tconst store = SchmancyCollectionStore.getInstance(storage, key, initialData)\n\n\t// Initialize with provided data if store is empty\n\tif (!store.value.size) {\n\t\tstore.$.next(new Map(initialData))\n\t}\n\n\treturn store\n}\n\n/**\n * Creates a context for managing state with better type safety\n * Overload for object stores\n */\nexport function createContext<T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n): IStore<T> & SchmancyStoreObject<T>\n\n/**\n * Creates a context for managing state with better type safety\n * Overload for collection stores\n */\nexport function createContext<V>(\n\tinitialData: Map<string, V>,\n\tstorage: StorageType,\n\tkey: string,\n): ICollectionStore<V> & SchmancyCollectionStore<V>\n\n/**\n * Implementation of the createContext function\n */\nexport function createContext<T extends Record<string, any> | Map<string, any>>(\n\tinitialData: T | Map<string, any>,\n\tstorage: StorageType,\n\tkey: string,\n): (IStore<T> & SchmancyStoreObject<T>) | (ICollectionStore<any> & SchmancyCollectionStore<any>) {\n\t// Validate input\n\tif (initialData === null || initialData === undefined) {\n\t\tthrow new StoreError('Initial data cannot be null or undefined', null, { storage, key })\n\t}\n\n\t// Determine store type based on input data\n\tif (isMap(initialData)) {\n\t\treturn createCollectionStore(initialData as Map<string, any>, storage, key)\n\t} else if (typeof initialData === 'object') {\n\t\treturn createObjectStore(initialData, storage, key)\n\t} else {\n\t\tthrow new StoreError('Initial data must be an object or a Map', null, {\n\t\t\tstorage,\n\t\t\tkey,\n\t\t\tdataType: typeof initialData,\n\t\t})\n\t}\n}\n\n/**\n * Creates a context with type inference, simplifying common patterns\n */\nexport function createObjectContext<T extends Record<string, any>>(\n\tinitialData: T,\n\tkey: string,\n\tstorage: StorageType = 'local',\n): IStore<T> & SchmancyStoreObject<T> {\n\treturn createContext(initialData, storage, key)\n}\n\n/**\n * Creates a collection context with type inference\n */\nexport function createCollectionContext<V>(\n\tinitialData: Map<string, V> | V[],\n\tkey: string,\n\tstorage: StorageType = 'local',\n): ICollectionStore<V> & SchmancyCollectionStore<V> {\n\t// Convert array to Map if needed\n\tconst dataMap = Array.isArray(initialData)\n\t\t? new Map(initialData.map((item, index) => [String(index), item]))\n\t\t: initialData\n\n\treturn createContext<V>(dataMap, storage, key)\n}\n","// src/store/filter-directive.ts\n\n/** Supported comparison operators with TypeScript literal types */\nexport type ComparisonOperator =\n\t| '=='\n\t| '!='\n\t| '>'\n\t| '<'\n\t| '>='\n\t| '<='\n\t| 'includes'\n\t| 'notIncludes'\n\t| 'startsWith'\n\t| 'endsWith'\n\t| 'in'\n\t| 'notIn'\n\t| 'any' // fuzzy search operator\n\n/**\n * Type-safe condition tuple\n */\nexport type ConditionTuple = [field: string, op: ComparisonOperator, expected: unknown, strict?: boolean]\n\n/**\n * Type-safe condition object\n */\nexport interface ConditionObject {\n\tkey: string\n\toperator: ComparisonOperator\n\tvalue: unknown\n\tstrict?: boolean\n}\n\n/**\n * Unified query condition type\n */\nexport type QueryCondition = ConditionTuple | ConditionObject\n\n/**\n * Filter result with item and score\n */\nexport interface ScoredItem<T> {\n\titem: T\n\tscore: number\n}\n\n/**\n * Get a nested value from an object using a dot-separated path.\n * Checks explicitly for null/undefined so falsy values like 0 or false are preserved.\n */\nexport const getFieldValue = <T = any>(item: Record<string, any>, path: string): T => {\n\tif (!path) return item as unknown as T\n\n\tconst parts = path.split('.')\n\tlet value: any = item\n\n\tfor (const part of parts) {\n\t\tif (value == null) return undefined as unknown as T\n\t\tvalue = value[part]\n\t}\n\n\treturn value as T\n}\n\n/**\n * Compute the Levenshtein distance between two strings.\n */\nconst levenshtein = (a: string, b: string): number => {\n\tif (a === b) return 0\n\n\tconst matrix: number[][] = Array(b.length + 1)\n\t\t.fill(null)\n\t\t.map((_, i) => [i])\n\n\t// initialize the first row\n\tfor (let j = 0; j <= a.length; j++) {\n\t\tmatrix[0][j] = j\n\t}\n\n\tfor (let i = 1; i <= b.length; i++) {\n\t\tfor (let j = 1; j <= a.length; j++) {\n\t\t\tif (b.charAt(i - 1) === a.charAt(j - 1)) {\n\t\t\t\tmatrix[i][j] = matrix[i - 1][j - 1]\n\t\t\t} else {\n\t\t\t\tmatrix[i][j] = Math.min(\n\t\t\t\t\tmatrix[i - 1][j] + 1, // deletion\n\t\t\t\t\tmatrix[i][j - 1] + 1, // insertion\n\t\t\t\t\tmatrix[i - 1][j - 1] + 1, // substitution\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\treturn matrix[b.length][a.length]\n}\n\n/**\n * Check if string `sub` is a subsequence of string `str`.\n * All characters in `sub` must appear in order in `str` (they need not be contiguous).\n */\nconst isSubsequence = (sub: string, str: string): boolean => {\n\tif (!sub) return true\n\tif (!str) return false\n\n\tlet i = 0,\n\t\tj = 0\n\twhile (i < sub.length && j < str.length) {\n\t\tif (sub[i].toLowerCase() === str[j].toLowerCase()) i++\n\t\tj++\n\t}\n\treturn i === sub.length\n}\n\n/**\n * Check if every character (with frequency) in the query exists in the target.\n * For example, \"aovc\" matches \"avocados\".\n */\nconst anagramMatch = (query: string, target: string): boolean => {\n\tif (!query) return true\n\tif (!target) return false\n\n\tconst countChars = (s: string): Record<string, number> =>\n\t\ts\n\t\t\t.toLowerCase()\n\t\t\t.split('')\n\t\t\t.reduce(\n\t\t\t\t(acc, char) => {\n\t\t\t\t\tacc[char] = (acc[char] || 0) + 1\n\t\t\t\t\treturn acc\n\t\t\t\t},\n\t\t\t\t{} as Record<string, number>,\n\t\t\t)\n\n\tconst queryCount = countChars(query)\n\tconst targetCount = countChars(target)\n\treturn Object.keys(queryCount).every(char => (targetCount[char] || 0) >= queryCount[char])\n}\n\n/**\n * Generate bigrams for a string.\n */\nconst getBigrams = (s: string): string[] => {\n\tif (!s || s.length < 2) return []\n\n\tconst bigrams: string[] = []\n\tfor (let i = 0; i < s.length - 1; i++) {\n\t\tbigrams.push(s.substring(i, i + 2).toLowerCase())\n\t}\n\treturn bigrams\n}\n\n/**\n * Compute Dice's coefficient for two strings based on bigrams.\n * Returns a value between 0 (no similarity) and 1 (perfect match).\n */\nconst diceCoefficient = (s1: string, s2: string): number => {\n\tif (!s1 || !s2 || s1.length < 2 || s2.length < 2) return 0\n\n\tconst bigrams1 = getBigrams(s1)\n\tconst bigrams2 = getBigrams(s2)\n\n\tif (bigrams1.length === 0 || bigrams2.length === 0) return 0\n\n\tlet intersection = 0\n\tconst used = new Array(bigrams2.length).fill(false)\n\n\tfor (const bigram of bigrams1) {\n\t\tfor (let i = 0; i < bigrams2.length; i++) {\n\t\t\tif (!used[i] && bigrams2[i] === bigram) {\n\t\t\t\tintersection++\n\t\t\t\tused[i] = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (2 * intersection) / (bigrams1.length + bigrams2.length)\n}\n\n/**\n * Compute a fuzzy similarity score between two strings.\n * The score is computed by taking the maximum of several methods:\n * - Direct substring match (score 1)\n * - Subsequence check (score 0.8)\n * - Anagram subset match (score 0.7)\n * - Dice coefficient\n * - Normalized Levenshtein similarity\n */\nconst computeFuzzyScore = (actual: string, expected: string): number => {\n\tif (!actual || !expected) return 0\n\n\tconst a = actual.toLowerCase().trim()\n\tconst b = expected.toLowerCase().trim()\n\n\tif (a === b) return 1\n\n\tconst substringScore = a.includes(b) ? 1 : 0\n\tconst subsequenceScore = isSubsequence(b, a) ? 0.8 : 0\n\tconst anagramScore = anagramMatch(b, a) ? 0.7 : 0\n\tconst diceScore = diceCoefficient(a, b)\n\n\tconst maxLen = Math.max(a.length, b.length)\n\tconst levenshteinScore = maxLen ? 1 - levenshtein(a, b) / maxLen : 0\n\n\treturn Math.max(substringScore, subsequenceScore, anagramScore, diceScore, levenshteinScore)\n}\n\n/**\n * Safely coerce value to string if possible, or return empty string\n */\nconst safeString = (value: unknown): string => {\n\tif (value == null) return ''\n\treturn String(value)\n}\n\n/**\n * Type guard for arrays\n */\nconst isArray = (value: unknown): value is Array<unknown> => {\n\treturn Array.isArray(value)\n}\n\n/**\n * Compare two values based on a comparison operator.\n * For non-fuzzy operators, this returns a boolean.\n */\nexport function compareValues(op: ComparisonOperator, actual: unknown, expected: unknown): boolean {\n\t// Handle null/undefined cases\n\tif (actual == null && expected == null) return true\n\tif (actual == null || expected == null) {\n\t\t// For equality operators, null == null but null != non-null\n\t\tif (op === '==') return actual === expected\n\t\tif (op === '!=') return actual !== expected\n\t\t// Other operators should return false for null/undefined values\n\t\treturn false\n\t}\n\n\tswitch (op) {\n\t\tcase '==':\n\t\t\treturn actual === expected\n\t\tcase '!=':\n\t\t\treturn actual !== expected\n\t\tcase '>':\n\t\t\treturn (actual as number) > (expected as number)\n\t\tcase '<':\n\t\t\treturn (actual as number) < (expected as number)\n\t\tcase '>=':\n\t\t\treturn (actual as number) >= (expected as number)\n\t\tcase '<=':\n\t\t\treturn (actual as number) <= (expected as number)\n\t\tcase 'includes': {\n\t\t\tif (typeof actual === 'string') {\n\t\t\t\treturn safeString(actual).toLowerCase().includes(safeString(expected).toLowerCase())\n\t\t\t} else if (isArray(actual)) {\n\t\t\t\treturn actual.includes(expected)\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIncludes': {\n\t\t\tif (typeof actual === 'string') {\n\t\t\t\treturn !safeString(actual).toLowerCase().includes(safeString(expected).toLowerCase())\n\t\t\t} else if (isArray(actual)) {\n\t\t\t\treturn !actual.includes(expected)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tcase 'startsWith': {\n\t\t\tif (typeof actual === 'string' && typeof expected === 'string') {\n\t\t\t\treturn actual.toLowerCase().startsWith(expected.toLowerCase())\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'endsWith': {\n\t\t\tif (typeof actual === 'string' && typeof expected === 'string') {\n\t\t\t\treturn actual.toLowerCase().endsWith(expected.toLowerCase())\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'in': {\n\t\t\tif (isArray(expected)) {\n\t\t\t\treturn expected.includes(actual)\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIn': {\n\t\t\tif (isArray(expected)) {\n\t\t\t\treturn !expected.includes(actual)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tdefault: {\n\t\t\tconsole.warn(`Operator \"${op}\" is not supported in strict comparison.`)\n\t\t\treturn false\n\t\t}\n\t}\n}\n\n/**\n * Apply a query condition to an item and return score\n */\nfunction applyQueryCondition<T extends Record<string, any>>(\n\titem: T,\n\tquery: QueryCondition,\n\tfuzzyThreshold: number = 0.3,\n): { valid: boolean; score: number } {\n\tlet field: string,\n\t\top: ComparisonOperator,\n\t\texpected: unknown,\n\t\tstrict = false\n\n\tif (Array.isArray(query)) {\n\t\t;[field, op, expected, strict = false] = query\n\t} else {\n\t\tfield = query.key\n\t\top = query.operator\n\t\texpected = query.value\n\t\tstrict = query.strict || false\n\t}\n\n\t// Skip empty filters for non-strict queries\n\tif (!strict && (expected === '' || expected == null || (isArray(expected) && expected.length === 0))) {\n\t\treturn { valid: true, score: 1 }\n\t}\n\n\tconst actual = getFieldValue(item, field)\n\n\t// If strict mode is enabled, enforce exact equality\n\tif (strict) {\n\t\tif (actual !== expected) {\n\t\t\treturn { valid: false, score: 0 }\n\t\t}\n\t\treturn { valid: true, score: 1 }\n\t}\n\n\tif (op === 'any') {\n\t\t// Fuzzy search requires both values to be strings\n\t\tif (typeof actual !== 'string' || typeof expected !== 'string') {\n\t\t\treturn { valid: false, score: 0 }\n\t\t}\n\n\t\tconst score = computeFuzzyScore(actual, expected)\n\t\tif (score < fuzzyThreshold) {\n\t\t\treturn { valid: false, score: 0 }\n\t\t}\n\n\t\treturn { valid: true, score }\n\t} else {\n\t\t// For non-fuzzy operators, check condition\n\t\tconst matches = compareValues(op, actual, expected)\n\t\treturn {\n\t\t\tvalid: matches,\n\t\t\tscore: matches ? 1 : 0,\n\t\t}\n\t}\n}\n\n/**\n * Filter a Map of items given an array of query conditions.\n * For each query condition:\n * - If the expected value is empty/null/undefined, it is treated as a match.\n * - For non-fuzzy operators, the condition must strictly match.\n * - For the \"any\" operator, a fuzzy similarity score is computed.\n * Items with a fuzzy score below a given threshold (e.g., 0.3) are excluded.\n *\n * The overall item score is the average of the scores from all conditions.\n * The results are sorted in descending order of relevance.\n *\n * @param items - A Map containing items to filter.\n * @param queries - An array of query conditions to apply.\n * @param fuzzyThreshold - Minimum score required for fuzzy matches (default: 0.3)\n * @returns An array of items that match all query conditions, sorted by relevance.\n */\nexport function filterMapItems<T extends Record<string, any>>(\n\titems: Map<string, T>,\n\tqueries: QueryCondition[] = [],\n\tfuzzyThreshold: number = 0.3,\n): T[] {\n\t// If no queries, return all items unsorted\n\tif (!queries.length) {\n\t\treturn Array.from(items.values())\n\t}\n\n\t// Score and filter each item\n\tconst scoredItems: ScoredItem<T>[] = []\n\n\tfor (const [_, item] of items.entries()) {\n\t\tlet totalScore = 0\n\t\tlet matchCount = 0\n\t\tlet valid = true\n\n\t\tfor (const query of queries) {\n\t\t\tconst result = applyQueryCondition(item, query, fuzzyThreshold)\n\n\t\t\tif (!result.valid) {\n\t\t\t\tvalid = false\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ttotalScore += result.score\n\t\t\tmatchCount++\n\t\t}\n\n\t\tif (valid) {\n\t\t\tscoredItems.push({\n\t\t\t\titem,\n\t\t\t\tscore: matchCount > 0 ? totalScore / matchCount : 1,\n\t\t\t})\n\t\t}\n\t}\n\n\t// Sort by descending score\n\tscoredItems.sort((a, b) => b.score - a.score)\n\n\treturn scoredItems.map(x => x.item)\n}\n\n/**\n * Filter an array of items using query conditions\n */\nexport function filterArrayItems<T extends Record<string, any>>(\n\titems: T[],\n\tqueries: QueryCondition[] = [],\n\tfuzzyThreshold: number = 0.3,\n): T[] {\n\t// Create temporary map with numeric indices as keys\n\tconst map = new Map<string, T>()\n\titems.forEach((item, index) => map.set(String(index), item))\n\n\treturn filterMapItems(map, queries, fuzzyThreshold)\n}\n\n// Export a simpler alias for filterMapItems\nexport const filterMap = filterMapItems\n\n// Export an alias for filterArrayItems\nexport const filterArray = filterArrayItems\n","// src/store/selectors.ts\nimport { Observable, combineLatest, distinctUntilChanged, map, shareReplay } from 'rxjs'\nimport { IStore, ICollectionStore } from './types'\n\n/**\n * Deep equality comparison for maps and complex objects\n * More efficient than JSON.stringify for large objects\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n\tif (a === b) return true\n\n\tif (a instanceof Map && b instanceof Map) {\n\t\tif (a.size !== b.size) return false\n\t\tfor (const [key, value] of a) {\n\t\t\tif (!b.has(key) || !deepEqual(value, b.get(key))) return false\n\t\t}\n\t\treturn true\n\t}\n\n\tif (a instanceof Set && b instanceof Set) {\n\t\tif (a.size !== b.size) return false\n\t\tfor (const item of a) {\n\t\t\tif (!b.has(item)) return false\n\t\t}\n\t\treturn true\n\t}\n\n\tif (typeof a === 'object' && a !== null && typeof b === 'object' && b !== null) {\n\t\tconst keysA = Object.keys(a)\n\t\tconst keysB = Object.keys(b)\n\n\t\tif (keysA.length !== keysB.length) return false\n\n\t\tfor (const key of keysA) {\n\t\t\t// @ts-ignore: Index signature\n\t\t\tif (!deepEqual(a[key], b[key])) return false\n\t\t}\n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Creates a selector that derives a value from store state\n *\n * @param store The store to observe\n * @param selectorFn Function that transforms the state\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createSelector<T, R>(store: IStore<T>, selectorFn: (state: T) => R): Observable<R> {\n\treturn store.$.pipe(map(selectorFn), distinctUntilChanged<R>(deepEqual), shareReplay(1))\n}\n\n/**\n * Creates a selector for collection stores that derives a value from the collection\n *\n * @param store The collection store to observe\n * @param selectorFn Function that transforms the collection\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createCollectionSelector<T, R>(\n\tstore: ICollectionStore<T>,\n\tselectorFn: (state: Map<string, T>) => R,\n): Observable<R> {\n\treturn store.$.pipe(map(selectorFn), distinctUntilChanged<R>(deepEqual), shareReplay(1))\n}\n\n/**\n * Creates a selector that returns all items from a collection as an array\n *\n * @param store The collection store\n * @returns An observable of all items as an array\n */\nexport function createItemsSelector<T>(store: ICollectionStore<T>): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => Array.from(collection.values()))\n}\n\n/**\n * Creates a selector that filters items from a collection\n *\n * @param store The collection store\n * @param filterFn Function that returns true for items to include\n * @returns An observable of filtered items as an array\n */\nexport function createFilterSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn: (item: T, key: string) => boolean,\n): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\tconst result: T[] = []\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) {\n\t\t\t\tresult.push(item)\n\t\t\t}\n\t\t})\n\t\treturn result\n\t})\n}\n\n/**\n * Creates a selector that retrieves a single item from a collection\n *\n * @param store The collection store\n * @param itemKey The key of the item to select\n * @returns An observable of the selected item that emits when the item changes\n */\nexport function createItemSelector<T>(store: ICollectionStore<T>, itemKey: string): Observable<T | undefined> {\n\treturn createCollectionSelector(store, collection => collection.get(itemKey))\n}\n\n/**\n * Creates a selector that counts items in a collection, optionally filtered\n *\n * @param store The collection store\n * @param filterFn Optional function to filter which items to count\n * @returns An observable of the count\n */\nexport function createCountSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn?: (item: T, key: string) => boolean,\n): Observable<number> {\n\treturn createCollectionSelector(store, collection => {\n\t\tif (!filterFn) return collection.size\n\n\t\tlet count = 0\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) count++\n\t\t})\n\t\treturn count\n\t})\n}\n\n/**\n * Creates a compound selector that depends on multiple other selectors\n *\n * @param selectors Array of source selectors\n * @param combinerFn Function that combines all selector results\n * @returns An observable of the combined result\n */\nexport function createCompoundSelector<T extends unknown[], R>(\n\tselectors: { [K in keyof T]: Observable<T[K]> },\n\tcombinerFn: (...values: T) => R,\n): Observable<R> {\n\treturn combineLatest(selectors).pipe(\n\t\tmap(values => combinerFn(...(values as T))),\n\t\tdistinctUntilChanged<R>(deepEqual),\n\t\tshareReplay(1),\n\t)\n}\n\n/**\n * Creates a selector that returns all keys from a collection\n */\nexport function createKeysSelector<T>(store: ICollectionStore<T>): Observable<string[]> {\n\treturn createCollectionSelector(store, collection => Array.from(collection.keys()))\n}\n\n/**\n * Creates a selector that returns entries (key-value pairs) from a collection\n */\nexport function createEntriesSelector<T>(store: ICollectionStore<T>): Observable<[string, T][]> {\n\treturn createCollectionSelector(store, collection => Array.from(collection.entries()))\n}\n\n/**\n * Creates a selector that maps collection values through a transform function\n */\nexport function createMapSelector<T, R>(\n\tstore: ICollectionStore<T>,\n\tmapFn: (item: T, key: string) => R,\n): Observable<R[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\tconst result: R[] = []\n\t\tcollection.forEach((item, key) => {\n\t\t\tresult.push(mapFn(item, key))\n\t\t})\n\t\treturn result\n\t})\n}\n\n/**\n * Creates a selector that sorts collection items\n */\nexport function createSortSelector<T>(store: ICollectionStore<T>, compareFn: (a: T, b: T) => number): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\treturn Array.from(collection.values()).sort(compareFn)\n\t})\n}\n\n/**\n * Creates a selector that finds the first item matching a predicate\n */\nexport function createFindSelector<T>(\n\tstore: ICollectionStore<T>,\n\tpredicate: (item: T, key: string) => boolean,\n): Observable<T | undefined> {\n\treturn createCollectionSelector(store, collection => {\n\t\tfor (const [key, item] of collection.entries()) {\n\t\t\tif (predicate(item, key)) {\n\t\t\t\treturn item\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t})\n}\n","// src/store/selector-hook.ts\nimport { property as litProperty } from 'lit/decorators.js'\nimport { Observable, Subject, Subscription } from 'rxjs'\nimport { takeUntil } from 'rxjs/operators'\nimport { createCollectionSelector, createSelector } from './selectors'\nimport { ICollectionStore, IStore } from './types'\n\n/**\n * Component lifecycle interface\n */\ninterface ComponentWithLifecycle {\n\t// Lifecycle hooks\n\tisConnected: boolean\n\tdisconnectedCallback?: () => void\n\tconnectedCallback?: () => void\n\trequestUpdate?: () => void\n\n\t// Internal properties\n\t_selectorCleanup?: Subject<void>\n\t_selectorSubscriptions?: Map<string, Subscription>\n\t_selectorInitialized?: Set<string>\n\n\t// Value storage\n\t[key: string]: any\n}\n\n/**\n * Property descriptor interface\n */\ntype PropertyDescriptor<T> = {\n\tget?: () => T\n\tset?: (value: T) => void\n\tvalue?: T\n\tconfigurable?: boolean\n\tenumerable?: boolean\n\twritable?: boolean\n}\n\n/**\n * Options for selecting from a store\n */\ninterface SelectOptions {\n\t/** If true, will wait for selector to emit a non-null value before calling connectedCallback */\n\trequired?: boolean\n\n\t/** If true, will only update the component and not set the property value */\n\tupdateOnly?: boolean\n\n\t/** If true, will use structuredClone to deeply clone values (prevents mutations) */\n\tdeepClone?: boolean\n\n\t/** Custom equality function to determine when to update */\n\tequals?: (a: any, b: any) => boolean\n}\n\n/**\n * Type guard to check if a store is a collection store\n */\nfunction isCollectionStore<T>(store: IStore<any> | ICollectionStore<T>): store is ICollectionStore<T> {\n\treturn 'set' in store && typeof store.set === 'function' && store.value instanceof Map\n}\n\n/**\n * Selector decorator that connects a component property to a store selector\n *\n * @param store The store to select from\n * @param selectorFn Optional function to transform the store state\n * @param options Additional options for the selector\n */\nexport function select<T, R>(\n\tstore: IStore<T> | ICollectionStore<T>,\n\tselectorFn: (state: any) => R = (state: R) => state,\n\toptions: SelectOptions = {},\n) {\n\treturn function (proto: Record<string, any>, propName: string, _descriptor?: PropertyDescriptor<R>) {\n\t\t// Register as a Lit property\n\t\tlitProperty({ attribute: false, type: Object })(proto, propName)\n\n\t\t// Store original lifecycle methods\n\t\tconst originalConnectedCallback = proto.connectedCallback\n\t\tconst originalDisconnectedCallback = proto.disconnectedCallback\n\n\t\t// Override connectedCallback to set up subscription\n\t\tproto.connectedCallback = function (this: ComponentWithLifecycle) {\n\t\t\t// Initialize tracking properties if needed\n\t\t\tif (!this._selectorCleanup || this._selectorCleanup.closed) {\n\t\t\t\tthis._selectorCleanup = new Subject<void>()\n\t\t\t}\n\n\t\t\tif (!this._selectorSubscriptions) {\n\t\t\t\tthis._selectorSubscriptions = new Map()\n\t\t\t}\n\n\t\t\tif (!this._selectorInitialized) {\n\t\t\t\tthis._selectorInitialized = new Set()\n\t\t\t}\n\n\t\t\t// Create the appropriate selector\n\t\t\tconst selector: Observable<R> = isCollectionStore(store)\n\t\t\t\t? createCollectionSelector(store, selectorFn)\n\t\t\t\t: createSelector(store as IStore<T>, selectorFn)\n\n\t\t\t// Call original connectedCallback immediately if not waiting for data\n\t\t\tif (!options.required && !this._selectorInitialized.has(propName)) {\n\t\t\t\toriginalConnectedCallback?.call(this)\n\t\t\t\tthis._selectorInitialized.add(propName)\n\t\t\t}\n\n\t\t\t// Clean up any existing subscription\n\t\t\tif (this._selectorSubscriptions.has(propName)) {\n\t\t\t\tthis._selectorSubscriptions.get(propName)?.unsubscribe()\n\t\t\t}\n\n\t\t\t// Create new subscription\n\t\t\tconst subscription = selector.pipe(takeUntil(this._selectorCleanup)).subscribe({\n\t\t\t\tnext: (value: R) => {\n\t\t\t\t\t// Handle value updates\n\t\t\t\t\tconst newValue = options.deepClone ? structuredClone(value) : value\n\n\t\t\t\t\tif (!options.updateOnly) {\n\t\t\t\t\t\tthis[propName] = newValue\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.requestUpdate?.()\n\n\t\t\t\t\t// If required and not initialized, call connectedCallback when we get a value\n\t\t\t\t\tif (\n\t\t\t\t\t\toptions.required &&\n\t\t\t\t\t\t!this._selectorInitialized.has(propName) &&\n\t\t\t\t\t\tnewValue !== null &&\n\t\t\t\t\t\tnewValue !== undefined\n\t\t\t\t\t) {\n\t\t\t\t\t\toriginalConnectedCallback?.call(this)\n\t\t\t\t\t\tthis._selectorInitialized.add(propName)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: (err: Error) => {\n\t\t\t\t\tconsole.error(`Error in selector subscription for ${propName}:`, err)\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// Store the subscription for cleanup\n\t\t\tthis._selectorSubscriptions.set(propName, subscription)\n\t\t}\n\n\t\t// Override disconnectedCallback to clean up subscriptions\n\t\tproto.disconnectedCallback = function (this: ComponentWithLifecycle) {\n\t\t\t// Call original disconnectedCallback\n\t\t\toriginalDisconnectedCallback?.call(this)\n\n\t\t\t// Clean up subscriptions\n\t\t\tif (this._selectorCleanup) {\n\t\t\t\tthis._selectorCleanup.next()\n\t\t\t\tthis._selectorCleanup.complete()\n\t\t\t}\n\n\t\t\tif (this._selectorSubscriptions) {\n\t\t\t\tthis._selectorSubscriptions.forEach(sub => sub.unsubscribe())\n\t\t\t\tthis._selectorSubscriptions.clear()\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Creates a selector decorator that selects a specific item from a collection store\n *\n * @param store The collection store\n * @param keyGetter Function that returns the key to select\n * @param options Additional options\n */\nexport function selectItem<T>(\n\tstore: ICollectionStore<T>,\n\tkeyGetter: (component: any) => string,\n\toptions: SelectOptions = {},\n) {\n\treturn function (proto: Record<string, any>, propName: string, _descriptor?: PropertyDescriptor<T | undefined>) {\n\t\tselect(\n\t\t\tstore,\n\t\t\tstate => {\n\t\t\t\t// This will be evaluated during subscription, when 'this' is available\n\t\t\t\tconst itemKey = keyGetter(this)\n\t\t\t\treturn itemKey ? state.get(itemKey) : undefined\n\t\t\t},\n\t\t\toptions,\n\t\t)(proto, propName)\n\t}\n}\n"],"names":["createObjectStore","initialData","storage","key","StoreError","store","SchmancyStoreObject","getInstance","obj","value","Object","keys","length","$","next","createContext","r","e","Map","SchmancyCollectionStore","size","dataType","getFieldValue","item","path","parts","split","part","getBigrams","s","bigrams","i","push","substring","toLowerCase","computeFuzzyScore","actual","expected","a","trim","b","substringScore","includes","subsequenceScore","sub","str","j","anagramScore","query","target","countChars","reduce","acc","char","queryCount","targetCount","every","diceScore","s1","s2","bigrams1","bigrams2","intersection","used","Array","fill","bigram","maxLen","Math","max","levenshteinScore","matrix","map","_","charAt","min","safeString","String","isArray","compareValues","op","startsWith","endsWith","applyQueryCondition","fuzzyThreshold","field","strict","operator","valid","score","matches","filterMapItems","items","queries","from","values","scoredItems","entries","totalScore","matchCount","result","sort","x","filterArrayItems","forEach","index","set","filterMap","filterArray","deepEqual","has","get","Set","keysA","keysB","createSelector","selectorFn","pipe","distinctUntilChanged","shareReplay","createCollectionSelector","select","state","options","proto","propName","_descriptor","litProperty","attribute","type","originalConnectedCallback","connectedCallback","originalDisconnectedCallback","disconnectedCallback","this","_selectorCleanup","closed","Subject","_selectorSubscriptions","_selectorInitialized","selector","required","call","add","unsubscribe","subscription","takeUntil","subscribe","newValue","deepClone","structuredClone","updateOnly","requestUpdate","error","err","complete","clear","selectors","combinerFn","combineLatest","filterFn","collection","count","predicate","itemKey","mapFn","compareFn","keyGetter"],"mappings":"2IA4CA,SAASA,EACRC,EACAC,EACAC,EAAAA,CAGA,GAAID,IAAY,YACf,MAAM,IAAIE,EAAWA,WAAA,uDAAwD,KAAM,CAAEF,QAASC,EAAAA,IAAAA,CAAAA,CAAAA,EAI/F,MAAME,EAAQC,EAAAA,oBAAoBC,YAAeL,EAASC,EAAKF,CA/ChE,EAAA,IAAuBO,EAsDf,OArDY,OADGA,EAkDJH,EAAMI,QAjDL,UAAYD,IAAQ,MAGhCE,OAAOC,KAAKH,CAAAA,EAAKI,SAAW,GA+C5BP,EAAAQ,EAAEC,KAAKb,CAGPI,EAAAA,CACR,CA4CgB,SAAAU,EACfd,EACAC,EACAC,EAAAA,CAGI,GACHa,GADGf,KACH,MAAM,IAAIG,EAAWA,WAAA,2CAA4C,KAAM,CAAEF,UAASC,IAI/Ec,CAAA,CAAA,EAAA,GAAMhB,aAhFciB,IAi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