{"version":3,"file":"wacom.mjs","sources":["../../../projects/wacom/src/interfaces/config.interface.ts","../../../projects/wacom/src/interfaces/http.interface.ts","../../../projects/wacom/src/interfaces/network.interface.ts","../../../projects/wacom/src/services/meta.service.ts","../../../projects/wacom/src/guard/meta.guard.ts","../../../projects/wacom/src/services/core.service.ts","../../../projects/wacom/src/crud/crud.component.ts","../../../projects/wacom/src/directives/click-outside.directive.ts","../../../projects/wacom/src/directives/manual-disabled.directive.ts","../../../projects/wacom/src/directives/manual-name.directive.ts","../../../projects/wacom/src/directives/manual-readonly.directive.ts","../../../projects/wacom/src/directives/manual-type.directive.ts","../../../projects/wacom/src/pipes/arr.pipe.ts","../../../projects/wacom/src/pipes/mongodate.pipe.ts","../../../projects/wacom/src/pipes/number.pipe.ts","../../../projects/wacom/src/pipes/pagination.pipe.ts","../../../projects/wacom/src/pipes/safe.pipe.ts","../../../projects/wacom/src/pipes/search.pipe.ts","../../../projects/wacom/src/pipes/splice.pipe.ts","../../../projects/wacom/src/pipes/split.pipe.ts","../../../projects/wacom/src/services/emitter.service.ts","../../../projects/wacom/src/services/http.service.ts","../../../projects/wacom/src/services/network.service.ts","../../../projects/wacom/src/services/store.service.ts","../../../projects/wacom/src/crud/crud.service.ts","../../../projects/wacom/src/services/dom.service.ts","../../../projects/wacom/src/services/rtc.service.ts","../../../projects/wacom/src/services/socket.service.ts","../../../projects/wacom/src/services/time.service.ts","../../../projects/wacom/src/services/util.service.ts","../../../projects/wacom/src/provide-wacom.ts","../../../projects/wacom/src/wacom.module.ts","../../../projects/wacom/public-api.ts","../../../projects/wacom/wacom.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\nimport { HttpConfig } from './http.interface';\r\nimport { MetaConfig } from './meta.interface';\r\nimport { NetworkConfig } from './network.interface';\r\nimport { StoreConfig } from './store.interface';\r\n\r\n/**\r\n * Root configuration object used to initialize the library.\r\n * Each property allows consumers to override the default\r\n * behavior of the corresponding service.\r\n */\r\nexport interface Config {\r\n\t/** Options for the key‑value storage service. */\r\n\tstore?: StoreConfig;\r\n\t/** Defaults applied to page metadata handling. */\r\n\tmeta?: MetaConfig;\r\n\t/** Base HTTP settings such as API URL and headers. */\r\n\thttp?: HttpConfig;\r\n\t/** Optional socket connection configuration. */\r\n\tsocket?: any;\r\n\t/** Raw Socket.IO client instance, if used. */\r\n\tio?: any;\r\n\tnetwork?: NetworkConfig;\r\n}\r\n\r\nexport const CONFIG_TOKEN = new InjectionToken<Config>('config');\r\n\r\nexport const DEFAULT_CONFIG: Config = {\r\n\tstore: {\r\n\t\tprefix: 'waStore',\r\n\t},\r\n\tmeta: {\r\n\t\tuseTitleSuffix: false,\r\n\t\twarnMissingGuard: false,\r\n\t\tdefaults: { links: {} },\r\n\t},\r\n\tsocket: false,\r\n\thttp: {\r\n\t\turl: '',\r\n\t\theaders: {},\r\n\t},\r\n};\r\n","export type HttpHeaderType = string | number | (string | number)[];\r\n\r\n/**\r\n * Configuration values used by the HTTP service when\r\n * issuing requests to a backend API.\r\n */\r\nexport interface HttpConfig {\r\n\t/** Map of default headers appended to each request. */\r\n\theaders?: Record<string, HttpHeaderType>;\r\n\t/** Base URL for all HTTP requests. */\r\n\turl?: string;\r\n}\r\n\r\nexport const DEFAULT_HTTP_CONFIG: HttpConfig = {\r\n\theaders: {},\r\n\turl: '',\r\n};\r\n","import { InjectionToken } from '@angular/core';\r\n\r\nexport type NetworkStatus = 'good' | 'poor' | 'none';\r\n\r\nexport interface NetworkConfig {\r\n\t/** Ordered list of endpoints to probe (first that succeeds wins). */\r\n\tendpoints: string[];\r\n\t/** Periodic re-check interval (ms). */\r\n\tintervalMs: number;\r\n\t/** Per-request timeout (ms). */\r\n\ttimeoutMs: number;\r\n\t/** Latency threshold (ms) to classify as \"good\". */\r\n\tgoodLatencyMs: number;\r\n\t/** Consecutive failures to flip status to \"none\". */\r\n\tmaxConsecutiveFails: number;\r\n}\r\n\r\nexport const DEFAULT_NETWORK_CONFIG: NetworkConfig = {\r\n\tendpoints: [\r\n\t\t'https://api.webart.work/status',\r\n\t\t// Opaque but useful reachability fallbacks:\r\n\t\t'https://www.google.com/generate_204',\r\n\t\t'https://www.gstatic.com/generate_204',\r\n\t\t'https://www.cloudflare.com/cdn-cgi/trace',\r\n\t],\r\n\tintervalMs: 30_000,\r\n\ttimeoutMs: 2_500,\r\n\tgoodLatencyMs: 300,\r\n\tmaxConsecutiveFails: 3,\r\n};\r\n\r\nexport const NETWORK_CONFIG = new InjectionToken<NetworkConfig>(\r\n\t'NETWORK_CONFIG',\r\n\t{\r\n\t\tfactory: () => DEFAULT_NETWORK_CONFIG,\r\n\t},\r\n);\r\n","import { Inject, Injectable, Optional } from '@angular/core';\r\nimport { Meta, Title } from '@angular/platform-browser';\r\nimport { Route, Router } from '@angular/router';\r\nimport {\r\n\tCONFIG_TOKEN,\r\n\tConfig,\r\n\tDEFAULT_CONFIG,\r\n} from '../interfaces/config.interface';\r\nimport { MetaConfig, MetaDefaults } from '../interfaces/meta.interface';\r\n\r\nconst isDefined = (val: any) => typeof val !== 'undefined';\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\nexport class MetaService {\r\n\tprivate _meta: MetaConfig;\r\n\r\n\tconstructor(\r\n\t\t@Inject(CONFIG_TOKEN) @Optional() private config: Config,\r\n\t\tprivate router: Router,\r\n\t\tprivate meta: Meta,\r\n\t\tprivate titleService: Title,\r\n\t) {\r\n\t\tthis.config = this.config || DEFAULT_CONFIG;\r\n\r\n\t\tthis._meta = this.config.meta || {};\r\n\r\n\t\tthis._warnMissingGuard();\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the default meta tags.\r\n\t *\r\n\t * @param defaults - The default meta tags.\r\n\t */\r\n\tsetDefaults(defaults: MetaDefaults) {\r\n\t\tthis._meta.defaults = {\r\n\t\t\t...this._meta.defaults,\r\n\t\t\t...defaults,\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the title and optional title suffix.\r\n\t *\r\n\t * @param title - The title to set.\r\n\t * @param titleSuffix - The title suffix to append.\r\n\t * @returns The MetaService instance.\r\n\t */\r\n\tsetTitle(title?: string, titleSuffix?: string): MetaService {\r\n\t\tlet titleContent = isDefined(title)\r\n\t\t\t? title || ''\r\n\t\t\t: this._meta.defaults?.['title'] || '';\r\n\r\n\t\tif (this._meta.useTitleSuffix) {\r\n\t\t\ttitleContent += isDefined(titleSuffix)\r\n\t\t\t\t? titleSuffix\r\n\t\t\t\t: this._meta.defaults?.['titleSuffix'] || '';\r\n\t\t}\r\n\r\n\t\tthis._updateMetaTag('title', titleContent);\r\n\r\n\t\tthis._updateMetaTag('og:title', titleContent);\r\n\r\n\t\tthis._updateMetaTag('twitter:title', titleContent);\r\n\r\n\t\tthis.titleService.setTitle(titleContent);\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Sets link tags.\r\n\t *\r\n\t * @param links - The links to set.\r\n\t * @returns The MetaService instance.\r\n\t */\r\n\tsetLink(links: { [key: string]: string }): MetaService {\r\n\t\tObject.keys(links).forEach((rel) => {\r\n\t\t\tlet link: HTMLLinkElement = document.createElement('link');\r\n\r\n\t\t\tlink.setAttribute('rel', rel);\r\n\r\n\t\t\tlink.setAttribute('href', links[rel]);\r\n\r\n\t\t\tdocument.head.appendChild(link);\r\n\t\t});\r\n\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a meta tag.\r\n\t *\r\n\t * @param tag - The meta tag name.\r\n\t * @param value - The meta tag value.\r\n\t * @param prop - The meta tag property.\r\n\t */\r\n\tsetTag(tag: string, value: string, prop?: string) {\r\n\t\tif (tag === 'title' || tag === 'titleSuffix') {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Attempt to set ${tag} through 'setTag': 'title' and 'titleSuffix' are reserved. Use 'MetaService.setTitle' instead.`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tconst content =\r\n\t\t\t(isDefined(value)\r\n\t\t\t\t? value || ''\r\n\t\t\t\t: this._meta.defaults?.[tag] || '') + '';\r\n\r\n\t\tthis._updateMetaTag(tag, content, prop);\r\n\r\n\t\tif (tag === 'description') {\r\n\t\t\tthis._updateMetaTag('og:description', content, prop);\r\n\r\n\t\t\tthis._updateMetaTag('twitter:description', content, prop);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Updates a meta tag.\r\n\t *\r\n\t * @param tag - The meta tag name.\r\n\t * @param value - The meta tag value.\r\n\t * @param prop - The meta tag property.\r\n\t */\r\n\tprivate _updateMetaTag(tag: string, value: string, prop?: string): void {\r\n\t\tprop =\r\n\t\t\tprop ||\r\n\t\t\t(tag.startsWith('og:') || tag.startsWith('twitter:')\r\n\t\t\t\t? 'property'\r\n\t\t\t\t: 'name');\r\n\r\n\t\tthis.meta.updateTag({ [prop]: tag, content: value });\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a meta tag.\r\n\t *\r\n\t * @param tag - The meta tag name.\r\n\t * @param prop - The meta tag property.\r\n\t */\r\n\tremoveTag(tag: string, prop?: string): void {\r\n\t\tprop =\r\n\t\t\tprop ||\r\n\t\t\t(tag.startsWith('og:') || tag.startsWith('twitter:')\r\n\t\t\t\t? 'property'\r\n\t\t\t\t: 'name');\r\n\r\n\t\tthis.meta.removeTag(`${prop}=\"${tag}\"`);\r\n\t}\r\n\r\n\t/**\r\n\t * Warns about missing meta guards in routes.\r\n\t */\r\n\tprivate _warnMissingGuard(): void {\r\n\t\tif (\r\n\t\t\tisDefined(this._meta.warnMissingGuard) &&\r\n\t\t\t!this._meta.warnMissingGuard\r\n\t\t) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tconst hasDefaultMeta = !!Object.keys(this._meta.defaults ?? {}).length;\r\n\r\n\t\tconst hasMetaGuardInArr = (it: any) =>\r\n\t\t\tit && it.IDENTIFIER === 'MetaGuard';\r\n\r\n\t\tlet hasShownWarnings = false;\r\n\r\n\t\tconst checkRoute = (route: Route) => {\r\n\t\t\tconst hasRouteMeta = route.data && route.data['meta'];\r\n\r\n\t\t\tconst showWarning =\r\n\t\t\t\t!isDefined(route.redirectTo) &&\r\n\t\t\t\t(hasDefaultMeta || hasRouteMeta) &&\r\n\t\t\t\t!(route.canActivate || []).some(hasMetaGuardInArr);\r\n\r\n\t\t\tif (showWarning) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t`Route with path \"${route.path}\" has ${\r\n\t\t\t\t\t\thasRouteMeta ? '' : 'default '\r\n\t\t\t\t\t}meta tags, but does not use MetaGuard. Please add MetaGuard to the canActivate array in your route configuration`,\r\n\t\t\t\t);\r\n\r\n\t\t\t\thasShownWarnings = true;\r\n\t\t\t}\r\n\r\n\t\t\t(route.children || []).forEach(checkRoute);\r\n\t\t};\r\n\r\n\t\tthis.router.config.forEach(checkRoute);\r\n\r\n\t\tif (hasShownWarnings) {\r\n\t\t\tconsole.warn(\r\n\t\t\t\t`To disable these warnings, set metaConfig.warnMissingGuard: false in your MetaConfig passed to MetaModule.forRoot()`,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n}\r\n","import { Inject, Injectable, Optional } from '@angular/core';\r\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\r\nimport {\r\n\tCONFIG_TOKEN,\r\n\tConfig,\r\n\tDEFAULT_CONFIG,\r\n} from '../interfaces/config.interface';\r\nimport { MetaService } from '../services/meta.service';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class MetaGuard {\r\n\tpublic static IDENTIFIER = 'MetaGuard';\r\n\tprivate _meta: any;\r\n\tpublic constructor(\r\n\t\tprivate metaService: MetaService,\r\n\t\t@Inject(CONFIG_TOKEN) @Optional() private config: Config,\r\n\t) {\r\n\t\tif (!this.config) this.config = DEFAULT_CONFIG;\r\n\t\tthis._meta = this.config.meta || {};\r\n\t\tthis._meta.defaults = this._meta.defaults || {};\r\n\t}\r\n\tpublic canActivate(\r\n\t\troute: ActivatedRouteSnapshot,\r\n\t\tstate: RouterStateSnapshot,\r\n\t): boolean {\r\n\t\tthis._processRouteMetaTags(route.data && route.data['meta']);\r\n\t\treturn true;\r\n\t}\r\n\tprivate _processRouteMetaTags(meta: any = {}) {\r\n\t\tif (meta.disableUpdate) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif (meta.title) {\r\n\t\t\tthis.metaService.setTitle(meta.title, meta.titleSuffix);\r\n\t\t}\r\n\t\tif (meta.links && Object.keys(meta.links).length) {\r\n\t\t\tthis.metaService.setLink(meta.links);\r\n\t\t}\r\n\t\tif (\r\n\t\t\tthis._meta.defaults?.links &&\r\n\t\t\tObject.keys(this._meta.defaults.links).length\r\n\t\t) {\r\n\t\t\tthis.metaService.setLink(this._meta.defaults.links);\r\n\t\t}\r\n\t\tObject.keys(meta).forEach((prop) => {\r\n\t\t\tif (\r\n\t\t\t\tprop === 'title' ||\r\n\t\t\t\tprop === 'titleSuffix' ||\r\n\t\t\t\tprop === 'links'\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tObject.keys(meta[prop]).forEach((key) => {\r\n\t\t\t\tthis.metaService.setTag(key, meta[prop][key], prop);\r\n\t\t\t});\r\n\t\t});\r\n\t\tObject.keys(this._meta.defaults).forEach((key) => {\r\n\t\t\tif (\r\n\t\t\t\tkey in meta ||\r\n\t\t\t\tkey === 'title' ||\r\n\t\t\t\tkey === 'titleSuffix' ||\r\n\t\t\t\tkey === 'links'\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tthis.metaService.setTag(key, this._meta.defaults[key] as string);\r\n\t\t});\r\n\t}\r\n}\r\n","// Core utilities and helpers for the Wacom app\r\nimport { Injectable, Signal, WritableSignal, signal } from '@angular/core';\r\n\r\n// Add capitalize method to String prototype if it doesn't already exist\r\nif (!String.prototype.capitalize) {\r\n\tString.prototype.capitalize = function (): string {\r\n\t\tif (this.length > 0) {\r\n\t\t\treturn this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();\r\n\t\t}\r\n\t\treturn '';\r\n\t};\r\n}\r\n\r\n// Extend the String interface to include the new method\r\ndeclare global {\r\n\tinterface String {\r\n\t\tcapitalize(): string;\r\n\t}\r\n}\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\nexport class CoreService {\r\n\tdeviceID =\r\n\t\tlocalStorage.getItem('deviceID') ||\r\n\t\t(typeof crypto?.randomUUID === 'function'\r\n\t\t\t? crypto.randomUUID()\r\n\t\t\t: this.UUID());\r\n\r\n\tconstructor() {\r\n\t\tlocalStorage.setItem('deviceID', this.deviceID);\r\n\r\n\t\tthis.detectDevice();\r\n\t}\r\n\r\n\t/**\r\n\t * Generates a UUID (Universally Unique Identifier) version 4.\r\n\t *\r\n\t * This implementation uses `Math.random()` to generate random values,\r\n\t * making it suitable for general-purpose identifiers, but **not** for\r\n\t * cryptographic or security-sensitive use cases.\r\n\t *\r\n\t * The format follows the UUID v4 standard: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`\r\n\t * where:\r\n\t * - `x` is a random hexadecimal digit (0–f)\r\n\t * - `4` indicates UUID version 4\r\n\t * - `y` is one of 8, 9, A, or B\r\n\t *\r\n\t * Example: `f47ac10b-58cc-4372-a567-0e02b2c3d479`\r\n\t *\r\n\t * @returns A string containing a UUID v4.\r\n\t */\r\n\tUUID(): string {\r\n\t\treturn 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(\r\n\t\t\t/[xy]/g,\r\n\t\t\t(c: string) => {\r\n\t\t\t\tconst r = (Math.random() * 16) | 0;\r\n\t\t\t\tconst v = c === 'x' ? r : (r & 0x3) | 0x8;\r\n\t\t\t\treturn v.toString(16);\r\n\t\t\t},\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Converts an object to an array. Optionally holds keys instead of values.\r\n\t *\r\n\t * @param {any} obj - The object to be converted.\r\n\t * @param {boolean} [holder=false] - If true, the keys will be held in the array; otherwise, the values will be held.\r\n\t * @returns {any[]} The resulting array.\r\n\t */\r\n\tota(obj: any, holder: boolean = false): any[] {\r\n\t\tif (Array.isArray(obj)) return obj;\r\n\t\tif (typeof obj !== 'object' || obj === null) return [];\r\n\t\tconst arr = [];\r\n\t\tfor (const each in obj) {\r\n\t\t\tif (\r\n\t\t\t\tobj.hasOwnProperty(each) &&\r\n\t\t\t\t(obj[each] ||\r\n\t\t\t\t\ttypeof obj[each] === 'number' ||\r\n\t\t\t\t\ttypeof obj[each] === 'boolean')\r\n\t\t\t) {\r\n\t\t\t\tif (holder) {\r\n\t\t\t\t\tarr.push(each);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tarr.push(obj[each]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn arr;\r\n\t}\r\n\r\n\t/**\r\n\t * Removes elements from `fromArray` that are present in `removeArray` based on a comparison field.\r\n\t *\r\n\t * @param {any[]} removeArray - The array of elements to remove.\r\n\t * @param {any[]} fromArray - The array from which to remove elements.\r\n\t * @param {string} [compareField='_id'] - The field to use for comparison.\r\n\t * @returns {any[]} The modified `fromArray` with elements removed.\r\n\t */\r\n\tsplice(\r\n\t\tremoveArray: any[],\r\n\t\tfromArray: any[],\r\n\t\tcompareField: string = '_id',\r\n\t): any[] {\r\n\t\tif (!Array.isArray(removeArray) || !Array.isArray(fromArray)) {\r\n\t\t\treturn fromArray;\r\n\t\t}\r\n\r\n\t\tconst removeSet = new Set(\r\n\t\t\tremoveArray.map((item) => item[compareField]),\r\n\t\t);\r\n\t\treturn fromArray.filter((item) => !removeSet.has(item[compareField]));\r\n\t}\r\n\r\n\t/**\r\n\t * Unites multiple _id values into a single unique _id.\r\n\t * The resulting _id is unique regardless of the order of the input _id values.\r\n\t *\r\n\t * @param {...string[]} args - The _id values to be united.\r\n\t * @returns {string} The unique combined _id.\r\n\t */\r\n\tids2id(...args: string[]): string {\r\n\t\targs.sort((a, b) => {\r\n\t\t\tif (\r\n\t\t\t\tNumber(a.toString().substring(0, 8)) >\r\n\t\t\t\tNumber(b.toString().substring(0, 8))\r\n\t\t\t) {\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\treturn -1;\r\n\t\t});\r\n\r\n\t\treturn args.join();\r\n\t}\r\n\r\n\t// After While\r\n\tprivate _afterWhile: Record<string, number> = {};\r\n\t/**\r\n\t * Delays the execution of a callback function for a specified amount of time.\r\n\t * If called again within that time, the timer resets.\r\n\t *\r\n\t * @param {string | object | (() => void)} doc - A unique identifier for the timer, an object to host the timer, or the callback function.\r\n\t * @param {() => void} [cb] - The callback function to execute after the delay.\r\n\t * @param {number} [time=1000] - The delay time in milliseconds.\r\n\t */\r\n\tafterWhile(\r\n\t\tdoc: string | object | (() => void),\r\n\t\tcb?: () => void,\r\n\t\ttime: number = 1000,\r\n\t): void {\r\n\t\tif (typeof doc === 'function') {\r\n\t\t\tcb = doc as () => void;\r\n\t\t\tdoc = 'common';\r\n\t\t}\r\n\r\n\t\tif (typeof cb === 'function' && typeof time === 'number') {\r\n\t\t\tif (typeof doc === 'string') {\r\n\t\t\t\tclearTimeout(this._afterWhile[doc]);\r\n\t\t\t\tthis._afterWhile[doc] = window.setTimeout(cb, time);\r\n\t\t\t} else if (typeof doc === 'object') {\r\n\t\t\t\tclearTimeout((doc as { __afterWhile: number }).__afterWhile);\r\n\t\t\t\t(doc as { __afterWhile: number }).__afterWhile =\r\n\t\t\t\t\twindow.setTimeout(cb, time);\r\n\t\t\t} else {\r\n\t\t\t\tconsole.warn('badly configured after while');\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Recursively copies properties from one object to another.\r\n\t * Handles nested objects, arrays, and Date instances appropriately.\r\n\t *\r\n\t * @param from - The source object from which properties are copied.\r\n\t * @param to - The target object to which properties are copied.\r\n\t */\r\n\tcopy(from: any, to: any) {\r\n\t\tfor (const each in from) {\r\n\t\t\tif (\r\n\t\t\t\ttypeof from[each] !== 'object' ||\r\n\t\t\t\tfrom[each] instanceof Date ||\r\n\t\t\t\tArray.isArray(from[each]) ||\r\n\t\t\t\tfrom[each] === null\r\n\t\t\t) {\r\n\t\t\t\tto[each] = from[each];\r\n\t\t\t} else {\r\n\t\t\t\tif (\r\n\t\t\t\t\ttypeof to[each] !== 'object' ||\r\n\t\t\t\t\tto[each] instanceof Date ||\r\n\t\t\t\t\tArray.isArray(to[each]) ||\r\n\t\t\t\t\tto[each] === null\r\n\t\t\t\t) {\r\n\t\t\t\t\tto[each] = {};\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.copy(from[each], to[each]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Device management\r\n\tdevice = '';\r\n\t/**\r\n\t * Detects the device type based on the user agent.\r\n\t */\r\n\tdetectDevice(): void {\r\n\t\tconst userAgent =\r\n\t\t\tnavigator.userAgent || navigator.vendor || (window as any).opera;\r\n\t\tif (/windows phone/i.test(userAgent)) {\r\n\t\t\tthis.device = 'Windows Phone';\r\n\t\t} else if (/android/i.test(userAgent)) {\r\n\t\t\tthis.device = 'Android';\r\n\t\t} else if (\r\n\t\t\t/iPad|iPhone|iPod/.test(userAgent) &&\r\n\t\t\t!(window as any).MSStream\r\n\t\t) {\r\n\t\t\tthis.device = 'iOS';\r\n\t\t} else {\r\n\t\t\tthis.device = 'Web';\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the device is a mobile device.\r\n\t * @returns {boolean} - Returns true if the device is a mobile device.\r\n\t */\r\n\tisMobile(): boolean {\r\n\t\treturn (\r\n\t\t\tthis.device === 'Windows Phone' ||\r\n\t\t\tthis.device === 'Android' ||\r\n\t\t\tthis.device === 'iOS'\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the device is a tablet.\r\n\t * @returns {boolean} - Returns true if the device is a tablet.\r\n\t */\r\n\tisTablet(): boolean {\r\n\t\treturn this.device === 'iOS' && /iPad/.test(navigator.userAgent);\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the device is a web browser.\r\n\t * @returns {boolean} - Returns true if the device is a web browser.\r\n\t */\r\n\tisWeb(): boolean {\r\n\t\treturn this.device === 'Web';\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the device is an Android device.\r\n\t * @returns {boolean} - Returns true if the device is an Android device.\r\n\t */\r\n\tisAndroid(): boolean {\r\n\t\treturn this.device === 'Android';\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the device is an iOS device.\r\n\t * @returns {boolean} - Returns true if the device is an iOS device.\r\n\t */\r\n\tisIos(): boolean {\r\n\t\treturn this.device === 'iOS';\r\n\t}\r\n\r\n\t// Version management\r\n\tversion = '1.0.0';\r\n\r\n\tappVersion = '';\r\n\r\n\tdateVersion = '';\r\n\r\n\t/**\r\n\t * Sets the combined version string based on appVersion and dateVersion.\r\n\t */\r\n\tsetVersion(): void {\r\n\t\tthis.version = this.appVersion || '';\r\n\r\n\t\tthis.version += this.version && this.dateVersion ? ' ' : '';\r\n\r\n\t\tthis.version += this.dateVersion || '';\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the app version and updates the combined version string.\r\n\t *\r\n\t * @param {string} appVersion - The application version to set.\r\n\t */\r\n\tsetAppVersion(appVersion: string): void {\r\n\t\tthis.appVersion = appVersion;\r\n\r\n\t\tthis.setVersion();\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the date version and updates the combined version string.\r\n\t *\r\n\t * @param {string} dateVersion - The date version to set.\r\n\t */\r\n\tsetDateVersion(dateVersion: string): void {\r\n\t\tthis.dateVersion = dateVersion;\r\n\r\n\t\tthis.setVersion();\r\n\t}\r\n\r\n\t// Locking management\r\n\tprivate _locked: Record<string, boolean> = {};\r\n\tprivate _unlockResolvers: Record<string, (() => void)[]> = {};\r\n\r\n\t/**\r\n\t * Locks a resource to prevent concurrent access.\r\n\t * @param which - The resource to lock, identified by a string.\r\n\t */\r\n\tlock(which: string): void {\r\n\t\tthis._locked[which] = true;\r\n\r\n\t\tif (!this._unlockResolvers[which]) {\r\n\t\t\tthis._unlockResolvers[which] = [];\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Unlocks a resource, allowing access.\r\n\t * @param which - The resource to unlock, identified by a string.\r\n\t */\r\n\tunlock(which: string): void {\r\n\t\tthis._locked[which] = false;\r\n\r\n\t\tif (this._unlockResolvers[which]) {\r\n\t\t\tthis._unlockResolvers[which].forEach((resolve) => resolve());\r\n\r\n\t\t\tthis._unlockResolvers[which] = [];\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a Promise that resolves when the specified resource is unlocked.\r\n\t * @param which - The resource to watch for unlocking, identified by a string.\r\n\t * @returns A Promise that resolves when the resource is unlocked.\r\n\t */\r\n\tonUnlock(which: string): Promise<void> {\r\n\t\tif (!this._locked[which]) {\r\n\t\t\treturn Promise.resolve();\r\n\t\t}\r\n\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tif (!this._unlockResolvers[which]) {\r\n\t\t\t\tthis._unlockResolvers[which] = [];\r\n\t\t\t}\r\n\r\n\t\t\tthis._unlockResolvers[which].push(resolve);\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if a resource is locked.\r\n\t * @param which - The resource to check, identified by a string.\r\n\t * @returns True if the resource is locked, false otherwise.\r\n\t */\r\n\tlocked(which: string): boolean {\r\n\t\treturn !!this._locked[which];\r\n\t}\r\n\r\n\t// Angular Signals //\r\n\t/**\r\n\t * Converts a plain object into a signal-wrapped object.\r\n\t * Optionally wraps specific fields of the object as individual signals,\r\n\t * and merges them into the returned signal for fine-grained reactivity.\r\n\t *\r\n\t * @template Document - The type of the object being wrapped.\r\n\t * @param {Document} document - The plain object to wrap into a signal.\r\n\t * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] -\r\n\t *        Optional map where each key is a field name and the value is a function\r\n\t *        to extract the initial value for that field. These fields will be wrapped\r\n\t *        as separate signals and embedded in the returned object.\r\n\t *\r\n\t * @returns {WritableSignal<Document>} A signal-wrapped object, possibly containing\r\n\t *          nested field signals for more granular control.\r\n\t *\r\n\t * @example\r\n\t * const user = { _id: '1', name: 'Alice', score: 42 };\r\n\t * const sig = toSignal(user, { score: (u) => u.score });\r\n\t * console.log(sig().name); // 'Alice'\r\n\t * console.log(sig().score()); // 42 — field is now a signal\r\n\t */\r\n\ttoSignal<Document>(\r\n\t\tdocument: Document,\r\n\t\tsignalFields: Record<string, (doc: Document) => unknown> = {},\r\n\t): WritableSignal<Document> {\r\n\t\tif (Object.keys(signalFields).length) {\r\n\t\t\tconst fields: Record<string, Signal<unknown>> = {};\r\n\r\n\t\t\tfor (const key in signalFields) {\r\n\t\t\t\tfields[key] = signal(signalFields[key](document));\r\n\t\t\t}\r\n\r\n\t\t\treturn signal({ ...document, ...fields });\r\n\t\t} else {\r\n\t\t\treturn signal(document);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Converts an array of objects into an array of Angular signals.\r\n\t * Optionally wraps specific fields of each object as individual signals.\r\n\t *\r\n\t * @template Document - The type of each object in the array.\r\n\t * @param {Document[]} arr - Array of plain objects to convert into signals.\r\n\t * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] -\r\n\t *        Optional map where keys are field names and values are functions that extract the initial value\r\n\t *        from the object. These fields will be turned into separate signals.\r\n\t *\r\n\t * @returns {WritableSignal<Document>[]} An array where each item is a signal-wrapped object,\r\n\t *          optionally with individual fields also wrapped in signals.\r\n\t *\r\n\t * @example\r\n\t * toSignalsArray(users, {\r\n\t *   name: (u) => u.name,\r\n\t *   score: (u) => u.score,\r\n\t * });\r\n\t */\r\n\ttoSignalsArray<Document>(\r\n\t\tarr: Document[],\r\n\t\tsignalFields: Record<string, (doc: Document) => unknown> = {},\r\n\t): WritableSignal<Document>[] {\r\n\t\treturn arr.map((obj) => this.toSignal(obj, signalFields));\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a new object to the signals array.\r\n\t * Optionally wraps specific fields of the object as individual signals before wrapping the whole object.\r\n\t *\r\n\t * @template Document - The type of the object being added.\r\n\t * @param {WritableSignal<Document>[]} signals - The signals array to append to.\r\n\t * @param {Document} item - The object to wrap and push as a signal.\r\n\t * @param {Record<string, (doc: Document) => unknown>} [signalFields={}] -\r\n\t *        Optional map of fields to be wrapped as signals within the object.\r\n\t *\r\n\t * @returns {void}\r\n\t */\r\n\tpushSignal<Document>(\r\n\t\tsignals: WritableSignal<Document>[],\r\n\t\titem: Document,\r\n\t\tsignalFields: Record<string, (doc: Document) => unknown> = {},\r\n\t): void {\r\n\t\tsignals.push(this.toSignal(item, signalFields));\r\n\t}\r\n\r\n\t/**\r\n\t * Removes the first signal from the array whose object's field matches the provided value.\r\n\t * @template Document\r\n\t * @param {WritableSignal<Document>[]} signals - The signals array to modify.\r\n\t * @param {unknown} value - The value to match.\r\n\t * @param {string} [field='_id'] - The object field to match against.\r\n\t * @returns {void}\r\n\t */\r\n\tremoveSignalByField<Document extends Record<string, unknown>>(\r\n\t\tsignals: WritableSignal<Document>[],\r\n\t\tvalue: unknown,\r\n\t\tfield: string = '_id',\r\n\t): void {\r\n\t\tconst idx = signals.findIndex((sig) => sig()[field] === value);\r\n\r\n\t\tif (idx > -1) signals.splice(idx, 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a generic trackBy function for *ngFor, tracking by the specified object field.\r\n\t * @template Document\r\n\t * @param {string} field - The object field to use for tracking (e.g., '_id').\r\n\t * @returns {(index: number, sig: Signal<Document>) => unknown} TrackBy function for Angular.\r\n\t */\r\n\ttrackBySignalField<Document extends Record<string, unknown>>(\r\n\t\tfield: string,\r\n\t) {\r\n\t\treturn (_: number, sig: Signal<Document>) => sig()[field];\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the first signal in the array whose object's field matches the provided value.\r\n\t * @template Document\r\n\t * @param {Signal<Document>[]} signals - Array of signals to search.\r\n\t * @param {unknown} value - The value to match.\r\n\t * @param {string} [field='_id'] - The object field to match against.\r\n\t * @returns {Signal<Document> | undefined} The found signal or undefined if not found.\r\n\t */\r\n\tfindSignalByField<Document extends Record<string, unknown>>(\r\n\t\tsignals: WritableSignal<Document>[],\r\n\t\tvalue: unknown,\r\n\t\tfield = '_id',\r\n\t): WritableSignal<Document> | undefined {\r\n\t\treturn signals.find(\r\n\t\t\t(sig) => sig()[field] === value,\r\n\t\t) as WritableSignal<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the first writable signal in the array whose object's field matches the provided value.\r\n\t * @template Document\r\n\t * @param {WritableSignal<Document>[]} signals - Array of writable signals to search.\r\n\t * @param {unknown} value - The value to match.\r\n\t * @param {(val: Document) => Document} updater - Function to produce the updated object.\r\n\t * @param {string} field - The object field to match against.\r\n\t * @returns {void}\r\n\t */\r\n\tupdateSignalByField<Document extends Record<string, unknown>>(\r\n\t\tsignals: WritableSignal<Document>[],\r\n\t\tvalue: unknown,\r\n\t\tupdater: (val: Document) => Document,\r\n\t\tfield: string,\r\n\t): void {\r\n\t\tconst sig = this.findSignalByField<Document>(\r\n\t\t\tsignals,\r\n\t\t\tvalue,\r\n\t\t\tfield,\r\n\t\t) as WritableSignal<Document>;\r\n\r\n\t\tif (sig) sig.update(updater);\r\n\t}\r\n}\r\n","import {\r\n\tChangeDetectorRef,\r\n\tinject,\r\n\tSignal,\r\n\tsignal,\r\n\tWritableSignal,\r\n} from '@angular/core';\r\nimport { firstValueFrom, take } from 'rxjs';\r\nimport { CoreService } from '../services/core.service';\r\nimport { CrudDocument, CrudOptions, TableConfig } from './crud.interface';\r\nimport { CrudService } from './crud.service';\r\n\r\n/**\r\n * Interface representing the shape of a form service used by the CrudComponent.\r\n * The consuming app must provide a service that implements this structure.\r\n */\r\ninterface FormServiceInterface<FormInterface> {\r\n\tmodal: <T>(form: FormInterface, options?: any, doc?: T) => Promise<T>;\r\n\tmodalDocs: <T>(docs: T[]) => Promise<T[]>;\r\n\tmodalUnique: <T>(collection: string, key: string, doc: T) => void;\r\n}\r\n\r\n/**\r\n * Abstract reusable base class for CRUD list views.\r\n * It encapsulates pagination, modals, and document handling logic.\r\n *\r\n * @template Service - A service implementing CrudServiceInterface for a specific document type\r\n * @template Document - The data model extending CrudDocument\r\n */\r\nexport abstract class CrudComponent<\r\n\tService extends CrudService<Document>,\r\n\tDocument extends CrudDocument<Document>,\r\n\tFormInterface,\r\n> {\r\n\t/** Service responsible for data fetching, creating, updating, deleting */\r\n\tprotected crudService: Service;\r\n\r\n\t/** The array of documents currently loaded and shown */\r\n\tprotected documents = signal<Signal<Document>[]>([]);\r\n\r\n\t/** Form schema/config used by the FormService modals */\r\n\tprotected form: FormInterface;\r\n\r\n\t/** Current pagination page */\r\n\tprotected page = 1;\r\n\r\n\t/** CoreService handles timing and copying helpers */\r\n\tprivate __core = inject(CoreService);\r\n\r\n\t/** ChangeDetectorRef handles on push strategy */\r\n\tprivate __cdr = inject(ChangeDetectorRef);\r\n\r\n\t/** Internal reference to form service matching FormServiceInterface */\r\n\tprivate __form: FormServiceInterface<FormInterface>;\r\n\r\n\t/**\r\n\t * Constructor\r\n\t *\r\n\t * @param formConfig - Object describing form title and its component structure\r\n\t * @param formService - Any service that conforms to FormServiceInterface (usually casted)\r\n\t * @param crudService - CRUD service implementing get/create/update/delete\r\n\t */\r\n\tconstructor(\r\n\t\tformConfig: unknown,\r\n\t\tformService: unknown,\r\n\t\tcrudService: Service,\r\n\t\tmodule = '',\r\n\t) {\r\n\t\tconst form = formConfig as FormInterface;\r\n\r\n\t\tthis.__form = formService as FormServiceInterface<FormInterface>;\r\n\r\n\t\tthis.form = form;\r\n\r\n\t\tthis.crudService = crudService;\r\n\r\n\t\tthis._module = module;\r\n\t}\r\n\r\n\t/**\r\n\t * Optional client-side predicate used when `configType === 'local'`.\r\n\t * Only documents for which this function returns `true` will be included\r\n\t * in the list returned by `setDocuments()` in local mode.\r\n\t */\r\n\tprotected localDocumentsFilter: (doc: Document) => boolean = () => true;\r\n\r\n\t/**\r\n\t * Loads documents for a given page.\r\n\t */\r\n\tprotected setDocuments(page = this.page, query = ''): Promise<void> {\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tif (this.configType === 'server') {\r\n\t\t\t\tthis.page = page;\r\n\r\n\t\t\t\tthis.__core.afterWhile(\r\n\t\t\t\t\tthis,\r\n\t\t\t\t\t() => {\r\n\t\t\t\t\t\tthis.crudService\r\n\t\t\t\t\t\t\t.get({ page, query }, this.getOptions())\r\n\t\t\t\t\t\t\t.subscribe((docs: Document[]) => {\r\n\t\t\t\t\t\t\t\tthis.documents.update(() =>\r\n\t\t\t\t\t\t\t\t\tdocs.map((doc) =>\r\n\t\t\t\t\t\t\t\t\t\tthis.crudService.getSignal(doc),\r\n\t\t\t\t\t\t\t\t\t),\r\n\t\t\t\t\t\t\t\t);\r\n\r\n\t\t\t\t\t\t\t\tresolve();\r\n\r\n\t\t\t\t\t\t\t\tthis.__cdr.markForCheck();\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t},\r\n\t\t\t\t\t250,\r\n\t\t\t\t);\r\n\t\t\t} else {\r\n\t\t\t\tthis.documents.update(() =>\r\n\t\t\t\t\tthis.crudService\r\n\t\t\t\t\t\t.getDocs(this.localDocumentsFilter)\r\n\t\t\t\t\t\t.map((doc) => this.crudService.getSignal(doc)),\r\n\t\t\t\t);\r\n\r\n\t\t\t\tthis.crudService.loaded.pipe(take(1)).subscribe(() => {\r\n\t\t\t\t\tresolve();\r\n\r\n\t\t\t\t\tthis.__cdr.markForCheck();\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/** Fields considered when performing bulk updates. */\r\n\tprotected updatableFields = ['_id', 'name', 'description', 'data'];\r\n\r\n\t/**\r\n\t * Clears temporary metadata before document creation.\r\n\t */\r\n\tprotected preCreate(doc: Document): void {\r\n\t\tdelete doc.__creating;\r\n\t}\r\n\r\n\t/**\r\n\t * Funciton which controls whether the create functionality is available.\r\n\t */\r\n\tprotected allowCreate(): boolean {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t/**\r\n\t * Funciton which controls whether the update and delete functionality is available.\r\n\t */\r\n\tprotected allowMutate(): boolean {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t/**\r\n\t * Funciton which controls whether the unique url functionality is available.\r\n\t */\r\n\tprotected allowUrl(): boolean {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t/** Determines whether manual sorting controls are available. */\r\n\tprotected allowSort(): boolean {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/**\r\n\t * Funciton which prepare get crud options.\r\n\t */\r\n\tprotected getOptions(): CrudOptions<Document> {\r\n\t\treturn {} as CrudOptions<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Handles bulk creation and updating of documents.\r\n\t * In creation mode, adds new documents.\r\n\t * In update mode, syncs changes and deletes removed entries.\r\n\t */\r\n\tprotected bulkManagement(isCreateFlow = true): () => void {\r\n\t\treturn (): void => {\r\n\t\t\tthis.__form\r\n\t\t\t\t.modalDocs<Document>(\r\n\t\t\t\t\tisCreateFlow\r\n\t\t\t\t\t\t? []\r\n\t\t\t\t\t\t: this.documents().map(\r\n\t\t\t\t\t\t\t\t(obj: any) =>\r\n\t\t\t\t\t\t\t\t\tObject.fromEntries(\r\n\t\t\t\t\t\t\t\t\t\tthis.updatableFields.map((key) => [\r\n\t\t\t\t\t\t\t\t\t\t\tkey,\r\n\t\t\t\t\t\t\t\t\t\t\tobj()[key],\r\n\t\t\t\t\t\t\t\t\t\t]),\r\n\t\t\t\t\t\t\t\t\t) as Document,\r\n\t\t\t\t\t\t\t),\r\n\t\t\t\t)\r\n\t\t\t\t.then(async (docs: Document[]) => {\r\n\t\t\t\t\tif (isCreateFlow) {\r\n\t\t\t\t\t\tfor (const doc of docs) {\r\n\t\t\t\t\t\t\tthis.preCreate(doc);\r\n\r\n\t\t\t\t\t\t\tawait firstValueFrom(this.crudService.create(doc));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tfor (const document of this.documents()) {\r\n\t\t\t\t\t\t\tif (!docs.find((d) => d._id === document()._id)) {\r\n\t\t\t\t\t\t\t\tawait firstValueFrom(\r\n\t\t\t\t\t\t\t\t\tthis.crudService.delete(document()),\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tfor (const doc of docs) {\r\n\t\t\t\t\t\t\tconst local = this.documents().find(\r\n\t\t\t\t\t\t\t\t(document) => document()._id === doc._id,\r\n\t\t\t\t\t\t\t);\r\n\r\n\t\t\t\t\t\t\tif (local) {\r\n\t\t\t\t\t\t\t\t(local as WritableSignal<Document>).update(\r\n\t\t\t\t\t\t\t\t\t(document) => {\r\n\t\t\t\t\t\t\t\t\t\tthis.__core.copy(doc, document);\r\n\r\n\t\t\t\t\t\t\t\t\t\treturn document;\r\n\t\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t);\r\n\r\n\t\t\t\t\t\t\t\tawait firstValueFrom(\r\n\t\t\t\t\t\t\t\t\tthis.crudService.update(local()),\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\tthis.preCreate(doc);\r\n\r\n\t\t\t\t\t\t\t\tawait firstValueFrom(\r\n\t\t\t\t\t\t\t\t\tthis.crudService.create(doc),\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.setDocuments();\r\n\t\t\t\t});\r\n\t\t};\r\n\t}\r\n\r\n\t/** Opens a modal to create a new document. */\r\n\tprotected create() {\r\n\t\tthis.__form.modal<Document>(this.form, {\r\n\t\t\tlabel: 'Create',\r\n\t\t\tclick: async (created: unknown, close: () => void) => {\r\n\t\t\t\tclose();\r\n\r\n\t\t\t\tthis.preCreate(created as Document);\r\n\r\n\t\t\t\tawait firstValueFrom(\r\n\t\t\t\t\tthis.crudService.create(created as Document),\r\n\t\t\t\t);\r\n\r\n\t\t\t\tthis.setDocuments();\r\n\t\t\t},\r\n\t\t});\r\n\t}\r\n\r\n\t/** Displays a modal to edit an existing document. */\r\n\tprotected update(doc: Document) {\r\n\t\tthis.__form.modal<Document>(\r\n\t\t\tthis.form,\r\n\t\t\t{\r\n\t\t\t\tlabel: 'Update',\r\n\t\t\t\tclick: (updated: unknown, close: () => void) => {\r\n\t\t\t\t\tclose();\r\n\r\n\t\t\t\t\tthis.__core.copy(updated, doc);\r\n\r\n\t\t\t\t\tthis.crudService.update(doc);\r\n\r\n\t\t\t\t\tthis.__cdr.markForCheck();\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t\tdoc,\r\n\t\t);\r\n\t}\r\n\r\n\t/** Requests confirmation before deleting the provided document. */\r\n\tprotected async delete(doc: Document) {\r\n\t\tthis.crudService.delete(doc).subscribe(() => {\r\n\t\t\tthis.setDocuments();\r\n\t\t});\r\n\t}\r\n\r\n\t/** Opens a modal to edit the document's unique URL. */\r\n\tprotected mutateUrl(doc: Document) {\r\n\t\tthis.__form.modalUnique<Document>(this._module, 'url', doc);\r\n\t}\r\n\r\n\t/** Moves the given document one position up and updates ordering. */\r\n\tprotected moveUp(doc: Document) {\r\n\t\tconst index = this.documents().findIndex(\r\n\t\t\t(document) => document()._id === doc._id,\r\n\t\t);\r\n\r\n\t\tif (index) {\r\n\t\t\tthis.documents.update((documents) => {\r\n\t\t\t\tdocuments.splice(index, 1);\r\n\r\n\t\t\t\tdocuments.splice(index - 1, 0, this.crudService.getSignal(doc));\r\n\r\n\t\t\t\treturn documents;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tfor (let i = 0; i < this.documents().length; i++) {\r\n\t\t\tif (this.documents()[i]().order !== i) {\r\n\t\t\t\tthis.documents()[i]().order = i;\r\n\r\n\t\t\t\tthis.crudService.update(this.documents()[i]());\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.__cdr.markForCheck();\r\n\t}\r\n\r\n\t/** Data source mode used for document retrieval. */\r\n\tprotected configType: 'server' | 'local' = 'server';\r\n\r\n\t/** Number of documents fetched per page when paginating. */\r\n\tprotected perPage = 20;\r\n\r\n\t/**\r\n\t * Configuration object used by the UI for rendering table and handling actions.\r\n\t */\r\n\tprotected getConfig(): TableConfig<Document> {\r\n\t\tconst config: TableConfig<Document> = {\r\n\t\t\tcreate: this.allowCreate()\r\n\t\t\t\t? (): void => {\r\n\t\t\t\t\t\tthis.create();\r\n\t\t\t\t\t}\r\n\t\t\t\t: null,\r\n\r\n\t\t\tupdate: this.allowMutate()\r\n\t\t\t\t? (doc: Document): void => {\r\n\t\t\t\t\t\tthis.update(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t: null,\r\n\r\n\t\t\tdelete: this.allowMutate()\r\n\t\t\t\t? (doc: Document): void => {\r\n\t\t\t\t\t\tthis.delete(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t: null,\r\n\r\n\t\t\tbuttons: [],\r\n\t\t\theaderButtons: [],\r\n\t\t\tallDocs: true,\r\n\t\t};\r\n\r\n\t\tif (this.allowUrl()) {\r\n\t\t\tconfig.buttons.push({\r\n\t\t\t\ticon: 'cloud_download',\r\n\t\t\t\tclick: (doc: Document) => {\r\n\t\t\t\t\tthis.mutateUrl(doc);\r\n\t\t\t\t},\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.allowSort()) {\r\n\t\t\tconfig.buttons.push({\r\n\t\t\t\ticon: 'arrow_upward',\r\n\t\t\t\tclick: (doc: Document) => {\r\n\t\t\t\t\tthis.moveUp(doc);\r\n\t\t\t\t},\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.allowCreate()) {\r\n\t\t\tconfig.headerButtons.push({\r\n\t\t\t\ticon: 'playlist_add',\r\n\t\t\t\tclick: this.bulkManagement(),\r\n\t\t\t\tclass: 'playlist',\r\n\t\t\t});\r\n\t\t}\r\n\t\tif (this.allowMutate()) {\r\n\t\t\tconfig.headerButtons.push({\r\n\t\t\t\ticon: 'edit_note',\r\n\t\t\t\tclick: this.bulkManagement(false),\r\n\t\t\t\tclass: 'edit',\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn this.configType === 'server'\r\n\t\t\t? {\r\n\t\t\t\t\t...config,\r\n\t\t\t\t\tpaginate: this.setDocuments.bind(this),\r\n\t\t\t\t\tperPage: this.perPage,\r\n\t\t\t\t\tsetPerPage: this.crudService.setPerPage?.bind(\r\n\t\t\t\t\t\tthis.crudService,\r\n\t\t\t\t\t),\r\n\t\t\t\t\tallDocs: false,\r\n\t\t\t\t}\r\n\t\t\t: config;\r\n\t}\r\n\r\n\t/** Name of the collection or module used for contextual actions. */\r\n\tprivate _module = '';\r\n}\r\n","import {\r\n\tChangeDetectorRef,\r\n\tDestroyRef,\r\n\tDirective,\r\n\tElementRef,\r\n\tinject,\r\n\toutput,\r\n} from '@angular/core';\r\n\r\n/**\r\n * Stand-alone “click outside” directive (zoneless-safe).\r\n *\r\n * Usage:\r\n * <div (clickOutside)=\"close()\">…</div>\r\n */\r\n@Directive({\r\n\tselector: '[clickOutside]',\r\n})\r\nexport class ClickOutsideDirective {\r\n\treadonly clickOutside = output<MouseEvent>();\r\n\r\n\tconstructor() {\r\n\t\tdocument.addEventListener('pointerdown', this.handler, true);\r\n\r\n\t\t// cleanup\r\n\t\tthis._dref.onDestroy(() =>\r\n\t\t\tdocument.removeEventListener('pointerdown', this.handler, true),\r\n\t\t);\r\n\t}\r\n\r\n\tprivate _host = inject(ElementRef<HTMLElement>);\r\n\r\n\tprivate _cdr = inject(ChangeDetectorRef);\r\n\r\n\tprivate _dref = inject(DestroyRef);\r\n\r\n\tprivate handler = (e: MouseEvent): void => {\r\n\t\tif (!this._host.nativeElement.contains(e.target as Node)) {\r\n\t\t\tthis.clickOutside.emit(e); // notify parent\r\n\t\t\tthis._cdr.markForCheck(); // trigger CD for OnPush comps\r\n\t\t}\r\n\t};\r\n}\r\n","import { Directive, ElementRef, effect, inject, input } from '@angular/core';\r\n\r\n@Directive({\r\n\tselector: 'input[manualDisabled], textarea[manualDisabled]',\r\n})\r\nexport class ManualDisabledDirective {\r\n\tprivate readonly el = inject(ElementRef) as ElementRef<HTMLInputElement>;\r\n\r\n\t// Bind as: [manualDisabled]=\"isDisabled\"\r\n\treadonly manualDisabled = input<boolean | null>(null, {\r\n\t\talias: 'manualDisabled',\r\n\t});\r\n\r\n\tprivate readonly syncDisabledEffect = effect(() => {\r\n\t\tconst disabled = this.manualDisabled();\r\n\t\tif (disabled == null) return;\r\n\r\n\t\tconst native = this.el.nativeElement;\r\n\t\tif (!native) return;\r\n\r\n\t\tnative.disabled = !!disabled;\r\n\t});\r\n}\r\n","import { Directive, ElementRef, effect, inject, input } from '@angular/core';\r\n\r\n@Directive({\r\n\tselector: 'input[manualName], textarea[manualName]',\r\n})\r\nexport class ManualNameDirective {\r\n\tprivate readonly el = inject(ElementRef) as ElementRef<HTMLInputElement>;\r\n\r\n\t// Bind as: manualName=\"email\" or [manualName]=\"expr\"\r\n\treadonly manualName = input<string | null>(null, { alias: 'manualName' });\r\n\r\n\tprivate readonly syncNameEffect = effect(() => {\r\n\t\tconst name = this.manualName();\r\n\t\tif (name == null) return;\r\n\r\n\t\tconst native = this.el.nativeElement;\r\n\t\tif (!native) return;\r\n\r\n\t\tif (native.name !== name) {\r\n\t\t\tnative.name = name;\r\n\t\t}\r\n\t});\r\n}\r\n","import { Directive, ElementRef, effect, inject, input } from '@angular/core';\r\n\r\n@Directive({\r\n\tselector: 'input[manualReadonly], textarea[manualReadonly]',\r\n})\r\nexport class ManualReadonlyDirective {\r\n\tprivate readonly el = inject(ElementRef) as ElementRef<HTMLInputElement>;\r\n\r\n\t// Bind as: [manualReadonly]=\"true\"\r\n\treadonly manualReadonly = input<boolean | null>(null, {\r\n\t\talias: 'manualReadonly',\r\n\t});\r\n\r\n\tprivate readonly syncReadonlyEffect = effect(() => {\r\n\t\tconst readonly = this.manualReadonly();\r\n\t\tif (readonly == null) return;\r\n\r\n\t\tconst native = this.el.nativeElement;\r\n\t\tif (!native) return;\r\n\r\n\t\tnative.readOnly = !!readonly;\r\n\t});\r\n}\r\n","import { Directive, ElementRef, effect, inject, input } from '@angular/core';\r\n\r\n@Directive({\r\n\tselector: 'input[manualType], textarea[manualType]',\r\n})\r\nexport class ManualTypeDirective {\r\n\tprivate readonly el = inject(ElementRef) as ElementRef<HTMLInputElement>;\r\n\r\n\t// Bind as: manualType=\"password\" or [manualType]=\"expr\"\r\n\treadonly manualType = input<string | null>(null, { alias: 'manualType' });\r\n\r\n\tprivate readonly syncTypeEffect = effect(() => {\r\n\t\tconst t = this.manualType();\r\n\t\tif (!t) return;\r\n\r\n\t\tconst native = this.el.nativeElement;\r\n\t\tif (!native) return;\r\n\r\n\t\tif (native.type !== t) {\r\n\t\t\tnative.type = t;\r\n\t\t}\r\n\t});\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'arr',\r\n})\r\nexport class ArrPipe implements PipeTransform {\r\n\ttransform(data: any, type?: any, refresh?: any): any {\r\n\t\tif (!data) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\tif (typeof data == 'string') return data.split(type || ' ');\r\n\r\n\t\tif (Array.isArray(data)) {\r\n\t\t\treturn data;\r\n\t\t}\r\n\r\n\t\tif (typeof data != 'object') {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\tlet arr = [];\r\n\r\n\t\tfor (let each in data) {\r\n\t\t\tif (!data[each]) continue;\r\n\r\n\t\t\tif (type == 'prop') {\r\n\t\t\t\tarr.push(each);\r\n\t\t\t} else if (type == 'value') {\r\n\t\t\t\tarr.push(data[each]);\r\n\t\t\t} else {\r\n\t\t\t\tarr.push({\r\n\t\t\t\t\tprop: each,\r\n\t\t\t\t\tvalue: data[each],\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn arr;\r\n\t}\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'mongodate',\r\n})\r\nexport class MongodatePipe implements PipeTransform {\r\n\ttransform(_id: any) {\r\n\t\tif (!_id) return new Date();\r\n\r\n\t\tlet timestamp = _id.toString().substring(0, 8);\r\n\r\n\t\treturn new Date(parseInt(timestamp, 16) * 1000);\r\n\t}\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'number',\r\n})\r\nexport class NumberPipe implements PipeTransform {\r\n\ttransform(value: unknown): number {\r\n\t\tconst result = Number(value); // Convert value to a number\r\n\r\n\t\treturn isNaN(result) ? 0 : result; // Return 0 if conversion fails\r\n\t}\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'page',\r\n\tpure: false,\r\n})\r\nexport class PaginationPipe implements PipeTransform {\r\n\ttransform(arr: any, config: any, sort: any, search = ''): any {\r\n\t\tif (!Array.isArray(arr)) return [];\r\n\r\n\t\tarr = arr.slice();\r\n\r\n\t\tfor (let i = 0; i < arr.length; i++) {\r\n\t\t\tarr[i].num = i + 1;\r\n\t\t}\r\n\r\n\t\tif (sort.direction) {\r\n\t\t\tarr.sort((a: any, b: any) => {\r\n\t\t\t\tif (a[sort.title] < b[sort.title]) {\r\n\t\t\t\t\treturn sort.direction == 'desc' ? 1 : -1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (a[sort.title] > b[sort.title]) {\r\n\t\t\t\t\treturn sort.direction == 'desc' ? -1 : 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn 0;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn arr.slice(\r\n\t\t\t(config.page - 1) * config.perPage,\r\n\t\t\tconfig.page * config.perPage,\r\n\t\t);\r\n\t}\r\n}\r\n","import { inject, Pipe } from '@angular/core';\r\nimport { DomSanitizer } from '@angular/platform-browser';\r\n@Pipe({\r\n\tname: 'safe',\r\n})\r\nexport class SafePipe {\r\n\ttransform(html: any) {\r\n\t\treturn this._sanitizer.bypassSecurityTrustResourceUrl(html);\r\n\t}\r\n\r\n\tprivate _sanitizer = inject(DomSanitizer);\r\n}\r\n","import { Pipe, PipeTransform, Signal, isSignal } from '@angular/core';\r\n\r\ntype Query =\r\n\t| string\r\n\t| string[]\r\n\t| Record<string, unknown>\r\n\t| Signal<string | string[] | Record<string, unknown> | undefined>;\r\n\r\ntype Field =\r\n\t| string\r\n\t| string[]\r\n\t| number\r\n\t| Signal<string | string[] | number | undefined>;\r\n\r\n@Pipe({ name: 'search', pure: true })\r\nexport class SearchPipe implements PipeTransform {\r\n\ttransform<T>(\r\n\t\titems: T[] | Record<string, T>,\r\n\t\tquery?: Query,\r\n\t\tfields?: Field,\r\n\t\tlimit?: number,\r\n\t\tignore = false,\r\n\t\t_reload?: unknown,\r\n\t): T[] {\r\n\t\t/* unwrap signals */\r\n\t\tconst q = isSignal(query) ? query() : query;\r\n\r\n\t\tlet f = isSignal(fields) ? fields() : fields;\r\n\r\n\t\t/* allow “fields” to be a number (=limit) */\r\n\t\tif (typeof f === 'number') {\r\n\t\t\tlimit = f;\r\n\r\n\t\t\tf = undefined;\r\n\t\t}\r\n\r\n\t\tconst docs = Array.isArray(items) ? items : Object.values(items);\r\n\r\n\t\tif (ignore || !q) return limit ? docs.slice(0, limit) : docs;\r\n\r\n\t\t/* normalise fields */\r\n\t\tconst paths: string[] = !f\r\n\t\t\t? ['name']\r\n\t\t\t: Array.isArray(f)\r\n\t\t\t\t? f\r\n\t\t\t\t: f.trim().split(/\\s+/);\r\n\r\n\t\t/* normalise query */\r\n\t\tconst needles: string[] = Array.isArray(q)\r\n\t\t\t? q.map((s) => s.toLowerCase())\r\n\t\t\t: typeof q === 'object'\r\n\t\t\t\t? Object.keys(q)\r\n\t\t\t\t\t\t.filter((k) => (q as any)[k])\r\n\t\t\t\t\t\t.map((k) => k.toLowerCase())\r\n\t\t\t\t: [q.toLowerCase()];\r\n\r\n\t\tconst txtMatches = (val: any) => {\r\n\t\t\tif (val == null) return false;\r\n\r\n\t\t\tconst hay = val.toString().toLowerCase();\r\n\r\n\t\t\treturn needles.some((n) => hay.includes(n) || n.includes(hay));\r\n\t\t};\r\n\r\n\t\tconst walk = (obj: any, parts: string[]): boolean => {\r\n\t\t\tif (!obj) return false;\r\n\r\n\t\t\tconst [head, ...rest] = parts;\r\n\r\n\t\t\tconst next = obj[head];\r\n\r\n\t\t\tif (Array.isArray(next))\r\n\t\t\t\treturn next.some((v) =>\r\n\t\t\t\t\trest.length ? walk(v, rest) : txtMatches(v),\r\n\t\t\t\t);\r\n\r\n\t\t\treturn rest.length ? walk(next, rest) : txtMatches(next);\r\n\t\t};\r\n\r\n\t\tconst out: T[] = [];\r\n\r\n\t\tconst seen = new Set<number | string>();\r\n\r\n\t\tconst check = (doc: T, key: number | string) => {\r\n\t\t\tfor (const p of paths) {\r\n\t\t\t\tif (walk(doc, p.split('.'))) {\r\n\t\t\t\t\tif (!seen.has(key)) {\r\n\t\t\t\t\t\tout.push(doc);\r\n\r\n\t\t\t\t\t\tseen.add(key);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tArray.isArray(items)\r\n\t\t\t? docs.forEach((d, i) => check(d, i))\r\n\t\t\t: Object.entries(items).forEach(([k, v]) => check(v, k));\r\n\r\n\t\treturn limit ? out.slice(0, limit) : out;\r\n\t}\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'splice',\r\n})\r\nexport class SplicePipe implements PipeTransform {\r\n\ttransform(from: any, which: any, refresh?: number): any {\r\n\t\tif (Array.isArray(from)) from = { arr: from, prop: '_id' };\r\n\r\n\t\tlet arr = (which.keep && []) || from.arr.slice();\r\n\r\n\t\tif (Array.isArray(which)) which = { arr: which, prop: '_id' };\r\n\r\n\t\tfor (let i = from.arr.length - 1; i >= 0; i--) {\r\n\t\t\tfor (let j = 0; j < which.arr.length; j++) {\r\n\t\t\t\tif (from.prop && which.prop) {\r\n\t\t\t\t\tif (from.arr[i][from.prop] == which.arr[j][which.prop]) {\r\n\t\t\t\t\t\tif (which.keep) {\r\n\t\t\t\t\t\t\tarr.push(from.arr[i]);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tarr.splice(i, 1);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t} else if (from.prop) {\r\n\t\t\t\t\tif (from.arr[i][from.prop] == which.arr[j]) {\r\n\t\t\t\t\t\tif (which.keep) {\r\n\t\t\t\t\t\t\tarr.push(from.arr[i]);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tarr.splice(i, 1);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t} else if (which.prop) {\r\n\t\t\t\t\tif (from.arr[i] == which.arr[j][which.prop]) {\r\n\t\t\t\t\t\tif (which.keep) {\r\n\t\t\t\t\t\t\tarr.push(from.arr[i]);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tarr.splice(i, 1);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t} else if (from.arr[i] == which.arr[j]) {\r\n\t\t\t\t\tif (which.keep) {\r\n\t\t\t\t\t\tarr.push(from.arr[i]);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tarr.splice(i, 1);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn arr;\r\n\t}\r\n}\r\n","import { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'split',\r\n})\r\nexport class SplitPipe implements PipeTransform {\r\n\ttransform(value: string, index = 0, devider = ':'): unknown {\r\n\t\tconst arr = value.split(devider);\r\n\r\n\t\treturn arr.length > index ? arr[index] : '';\r\n\t}\r\n}\r\n","import { Injectable, WritableSignal, signal } from '@angular/core';\r\nimport { toObservable } from '@angular/core/rxjs-interop';\r\nimport {\r\n\tObservable,\r\n\tSubject,\r\n\tcombineLatest,\r\n\tfilter,\r\n\tmap,\r\n\tmerge,\r\n\tshare,\r\n\tskip,\r\n\ttake,\r\n\ttakeUntil,\r\n\ttimeout,\r\n} from 'rxjs';\r\n\r\ntype Any = unknown;\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class EmitterService {\r\n\tprivate _signals = new Map<string, WritableSignal<Any>>();\r\n\tprivate _closers = new Map<string, Subject<void>>();\r\n\tprivate _streams = new Map<string, Observable<Any>>();\r\n\r\n\tprivate _getSignal(id: string): WritableSignal<Any> {\r\n\t\tlet s = this._signals.get(id);\r\n\t\tif (!s) {\r\n\t\t\t// emit even if same payload repeats\r\n\t\t\ts = signal<Any>(undefined, { equal: () => false });\r\n\t\t\tthis._signals.set(id, s);\r\n\t\t}\r\n\t\treturn s;\r\n\t}\r\n\r\n\tprivate _getCloser(id: string): Subject<void> {\r\n\t\tlet c = this._closers.get(id);\r\n\t\tif (!c) {\r\n\t\t\tc = new Subject<void>();\r\n\t\t\tthis._closers.set(id, c);\r\n\t\t}\r\n\t\treturn c;\r\n\t}\r\n\r\n\tprivate _getStream(id: string): Observable<Any> {\r\n\t\tlet obs$ = this._streams.get(id);\r\n\t\tif (!obs$) {\r\n\t\t\tconst sig = this._getSignal(id);\r\n\t\t\tconst closed$ = this._getCloser(id);\r\n\t\t\tobs$ = toObservable(sig).pipe(\r\n\t\t\t\t// Subject-like: don't replay the current value on subscribe\r\n\t\t\t\tskip(1),\r\n\t\t\t\ttakeUntil(closed$),\r\n\t\t\t\tshare(),\r\n\t\t\t);\r\n\t\t\tthis._streams.set(id, obs$);\r\n\t\t}\r\n\t\treturn obs$;\r\n\t}\r\n\r\n\t/** Emit an event */\r\n\temit<T = Any>(id: string, data?: T): void {\r\n\t\tthis._getSignal(id).set(data as Any);\r\n\t}\r\n\r\n\t/** Listen for events (hot, completes when off(id) is called) */\r\n\ton<T = Any>(id: string): Observable<T> {\r\n\t\treturn this._getStream(id) as Observable<T>;\r\n\t}\r\n\r\n\t/** Complete and remove a channel */\r\n\toff(id: string): void {\r\n\t\tconst closer = this._closers.get(id);\r\n\t\tif (closer) {\r\n\t\t\tcloser.next();\r\n\t\t\tcloser.complete();\r\n\t\t\tthis._closers.delete(id);\r\n\t\t}\r\n\t\tthis._signals.delete(id);\r\n\t\tthis._streams.delete(id);\r\n\t}\r\n\r\n\toffAll(): void {\r\n\t\tfor (const id of Array.from(this._closers.keys())) this.off(id);\r\n\t}\r\n\r\n\thas(id: string): boolean {\r\n\t\treturn this._signals.has(id);\r\n\t}\r\n\r\n\tprivate _done = new Map<string, WritableSignal<Any | undefined>>();\r\n\r\n\tprivate _getDoneSignal(id: string): WritableSignal<Any | undefined> {\r\n\t\tlet s = this._done.get(id);\r\n\t\tif (!s) {\r\n\t\t\ts = signal<Any | undefined>(undefined);\r\n\t\t\tthis._done.set(id, s);\r\n\t\t}\r\n\t\treturn s;\r\n\t}\r\n\r\n\t/** Mark task as completed with a payload (default: true) */\r\n\tcomplete<T = Any>(task: string, value: T = true as unknown as T): void {\r\n\t\tthis._getDoneSignal(task).set(value as Any);\r\n\t}\r\n\r\n\t/** Clear completion so it can be awaited again */\r\n\tclearCompleted(task: string): void {\r\n\t\tconst s = this._done.get(task) ?? this._getDoneSignal(task);\r\n\t\ts.set(undefined);\r\n\t}\r\n\r\n\t/** Read current completion payload (undefined => not completed) */\r\n\tcompleted(task: string): Any | undefined {\r\n\t\treturn this._getDoneSignal(task)();\r\n\t}\r\n\r\n\tisCompleted(task: string): boolean {\r\n\t\treturn this._getDoneSignal(task)() !== undefined;\r\n\t}\r\n\r\n\tonComplete(\r\n\t\ttasks: string | string[],\r\n\t\topts?: {\r\n\t\t\tmode?: 'all' | 'any';\r\n\t\t\ttimeoutMs?: number;\r\n\t\t\tabort?: AbortSignal;\r\n\t\t},\r\n\t): Observable<Any | Any[]> {\r\n\t\tconst list = (Array.isArray(tasks) ? tasks : [tasks]).filter(Boolean);\r\n\t\tconst streams = list.map((id) =>\r\n\t\t\ttoObservable(this._getDoneSignal(id)).pipe(\r\n\t\t\t\tfilter((v): v is Any => v !== undefined),\r\n\t\t\t\tmap((v) => v as Any),\r\n\t\t\t),\r\n\t\t);\r\n\r\n\t\tlet source$: Observable<Any | Any[]>;\r\n\r\n\t\tif (list.length <= 1) {\r\n\t\t\t// single-task await\r\n\t\t\tsource$ = streams[0]?.pipe(take(1)) ?? new Observable<never>();\r\n\t\t} else if (opts?.mode === 'any') {\r\n\t\t\tsource$ = merge(...streams).pipe(take(1));\r\n\t\t} else {\r\n\t\t\tsource$ = combineLatest(streams).pipe(take(1));\r\n\t\t}\r\n\r\n\t\tif (opts?.timeoutMs && Number.isFinite(opts.timeoutMs)) {\r\n\t\t\tsource$ = source$.pipe(timeout({ first: opts.timeoutMs }));\r\n\t\t}\r\n\r\n\t\tif (opts?.abort) {\r\n\t\t\tconst abort$ = new Observable<void>((sub) => {\r\n\t\t\t\tconst handler = () => {\r\n\t\t\t\t\tsub.next();\r\n\t\t\t\t\tsub.complete();\r\n\t\t\t\t};\r\n\t\t\t\topts.abort!.addEventListener('abort', handler);\r\n\t\t\t\treturn () => opts.abort!.removeEventListener('abort', handler);\r\n\t\t\t});\r\n\t\t\tsource$ = source$.pipe(takeUntil(abort$));\r\n\t\t}\r\n\r\n\t\treturn source$;\r\n\t}\r\n}\r\n","import {\r\n\tHttpClient,\r\n\tHttpErrorResponse,\r\n\tHttpHeaders,\r\n} from '@angular/common/http';\r\nimport { Inject, Injectable, Optional } from '@angular/core';\r\nimport { EMPTY, Observable, ReplaySubject } from 'rxjs';\r\nimport { catchError, first } from 'rxjs/operators';\r\nimport { CONFIG_TOKEN, Config } from '../interfaces/config.interface';\r\nimport {\r\n\tDEFAULT_HTTP_CONFIG,\r\n\tHttpConfig,\r\n\tHttpHeaderType,\r\n} from '../interfaces/http.interface';\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\nexport class HttpService {\r\n\t// An array of error handling callbacks\r\n\terrors: ((err: HttpErrorResponse, retry?: () => void) => {})[] = [];\r\n\r\n\t// Base URL for HTTP requests\r\n\turl = localStorage.getItem('wacom-http.url') || '';\r\n\r\n\t// Flag to lock the service to prevent multiple requests\r\n\tlocked = false;\r\n\r\n\t// Array to store setTimeout IDs for managing request locks\r\n\tawaitLocked: ReturnType<typeof setTimeout>[] = [];\r\n\r\n\t// Configuration object for HTTP settings\r\n\tprivate _config: HttpConfig;\r\n\r\n\t// Object to store HTTP headers\r\n\tprivate _headers: {\r\n\t\t[name: string]: HttpHeaderType;\r\n\t} = localStorage.getItem('wacom-http.headers')\r\n\t\t? JSON.parse(localStorage.getItem('wacom-http.headers') as string)\r\n\t\t: {};\r\n\r\n\t// Instance of HttpHeaders with current headers\r\n\tprivate _http_headers = new HttpHeaders(this._headers);\r\n\r\n\tconstructor(\r\n\t\t@Inject(CONFIG_TOKEN) @Optional() config: Config,\r\n\t\tprivate _http: HttpClient,\r\n\t) {\r\n\t\t// Initialize HTTP configuration and headers from injected config\r\n\t\tthis._config = {\r\n\t\t\t...DEFAULT_HTTP_CONFIG,\r\n\t\t\t...(config.http || {}),\r\n\t\t};\r\n\r\n\t\tif (typeof this._config.url === 'string') {\r\n\t\t\tthis.setUrl(this._config.url);\r\n\t\t}\r\n\r\n\t\tif (typeof this._config.headers === 'object') {\r\n\t\t\tfor (const header in this._config.headers) {\r\n\t\t\t\tthis._headers[header] = this._config.headers[header];\r\n\t\t\t}\r\n\r\n\t\t\tthis._http_headers = new HttpHeaders(this._headers);\r\n\t\t}\r\n\t}\r\n\r\n\t// Set a new base URL and save it in the store\r\n\tsetUrl(url: string) {\r\n\t\tthis.url = url;\r\n\r\n\t\tlocalStorage.setItem('wacom-http.url', url);\r\n\t}\r\n\r\n\t// Remove the base URL and revert to the default or stored one\r\n\tremoveUrl() {\r\n\t\tthis.url = this._config.url || '';\r\n\r\n\t\tlocalStorage.removeItem('wacom-http.url');\r\n\t}\r\n\r\n\t// Set a new HTTP header and update the stored headers\r\n\tset(key: any, value: any) {\r\n\t\tthis._headers[key] = value;\r\n\r\n\t\tlocalStorage.setItem(\r\n\t\t\t'wacom-http.headers',\r\n\t\t\tJSON.stringify(this._headers),\r\n\t\t);\r\n\r\n\t\tthis._http_headers = new HttpHeaders(this._headers);\r\n\t}\r\n\r\n\t// Get the value of a specific HTTP header\r\n\theader(key: any) {\r\n\t\treturn this._headers[key];\r\n\t}\r\n\r\n\t// Remove a specific HTTP header and update the stored headers\r\n\tremove(key: any) {\r\n\t\tdelete this._headers[key];\r\n\r\n\t\tlocalStorage.setItem(\r\n\t\t\t'wacom-http.headers',\r\n\t\t\tJSON.stringify(this._headers),\r\n\t\t);\r\n\r\n\t\tthis._http_headers = new HttpHeaders(this._headers);\r\n\t}\r\n\r\n\t// Internal method to make HTTP requests based on the method type\r\n\tprivate _httpMethod(\r\n\t\tmethod: string,\r\n\t\t_url: string,\r\n\t\tdoc: unknown,\r\n\t\theaders: any,\r\n\t): Observable<any> {\r\n\t\tif (method === 'post') {\r\n\t\t\treturn this._http.post<any>(_url, doc, headers);\r\n\t\t} else if (method === 'put') {\r\n\t\t\treturn this._http.put<any>(_url, doc, headers);\r\n\t\t} else if (method === 'patch') {\r\n\t\t\treturn this._http.patch<any>(_url, doc, headers);\r\n\t\t} else if (method === 'delete') {\r\n\t\t\treturn this._http.delete<any>(_url, headers);\r\n\t\t} else {\r\n\t\t\treturn this._http.get<any>(_url, headers);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Internal method to handle HTTP requests for various methods (POST, PUT, PATCH, DELETE, GET).\r\n\t *\r\n\t * Features:\r\n\t * - **Request Locking**: Manages request locking to prevent simultaneous requests.\r\n\t * - **Acceptance Check**: Validates the server response against a user-defined `acceptance` function.\r\n\t *   If the check fails, the response is rejected with an error.\r\n\t * - **Replace Logic**: Allows modification of specific parts of the response object, determined by a user-defined `replace` function.\r\n\t *   Can handle both objects and arrays within the response.\r\n\t * - **Field Filtering**: Supports extracting specific fields from response objects or arrays.\r\n\t * - **Legacy Support**: Compatible with callback-based usage alongside Observables.\r\n\t * - **ReplaySubject**: Ensures that the response can be shared across multiple subscribers.\r\n\t *\r\n\t * @param url - The endpoint to send the HTTP request to (relative to the base URL).\r\n\t * @param doc - The request payload for methods like POST, PUT, and PATCH.\r\n\t * @param callback - A legacy callback function to handle the response.\r\n\t * @param opts - Additional options:\r\n\t *   - `err`: Error handling callback.\r\n\t *   - `acceptance`: Function to validate the server response. Should return `true` for valid responses.\r\n\t *   - `replace`: Function to modify specific parts of the response data.\r\n\t *   - `fields`: Array of fields to extract from the response object(s).\r\n\t *   - `data`: Path in the response where the data resides for `replace` and `fields` operations.\r\n\t *   - `skipLock`: If `true`, bypasses request locking.\r\n\t *   - `url`: Overrides the base URL for this request.\r\n\t * @param method - The HTTP method (e.g., 'post', 'put', 'patch', 'delete', 'get').\r\n\t * @returns An Observable that emits the processed HTTP response or an error.\r\n\t */\r\n\tprivate _post(\r\n\t\turl: string,\r\n\t\tdoc: unknown,\r\n\t\tcallback = (resp: unknown) => {},\r\n\t\topts: any = {},\r\n\t\tmethod = 'post',\r\n\t): Observable<any> {\r\n\t\tif (typeof opts === 'function') {\r\n\t\t\topts = { err: opts };\r\n\t\t}\r\n\r\n\t\tif (!opts.err) {\r\n\t\t\topts.err = (err: HttpErrorResponse) => {};\r\n\t\t}\r\n\r\n\t\t// Handle request locking to avoid multiple simultaneous requests\r\n\t\tif (this.locked && !opts.skipLock) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tconst wait = setTimeout(() => {\r\n\t\t\t\t\tthis._post(url, doc, callback, opts, method).subscribe(\r\n\t\t\t\t\t\tobserver,\r\n\t\t\t\t\t);\r\n\t\t\t\t}, 100);\r\n\r\n\t\t\t\tthis.awaitLocked.push(wait);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst _url = (opts.url || this.url) + url;\r\n\r\n\t\tthis.prepare_handle(_url, doc);\r\n\r\n\t\t// Using ReplaySubject to allow multiple subscriptions without re-triggering the HTTP request\r\n\t\tconst responseSubject = new ReplaySubject(1);\r\n\r\n\t\tthis._httpMethod(method, _url, doc, { headers: this._http_headers })\r\n\t\t\t.pipe(\r\n\t\t\t\tfirst(),\r\n\t\t\t\tcatchError((error: HttpErrorResponse) => {\r\n\t\t\t\t\tthis.handleError(opts.err, () => {\r\n\t\t\t\t\t\tthis._post(url, doc, callback, opts, method).subscribe(\r\n\t\t\t\t\t\t\tresponseSubject,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t})(error);\r\n\r\n\t\t\t\t\tresponseSubject.error(error);\r\n\r\n\t\t\t\t\treturn EMPTY;\r\n\t\t\t\t}),\r\n\t\t\t)\r\n\t\t\t.subscribe({\r\n\t\t\t\tnext: (resp: unknown) => {\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\topts.acceptance &&\r\n\t\t\t\t\t\ttypeof opts.acceptance === 'function'\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tif (!opts.acceptance(resp)) {\r\n\t\t\t\t\t\t\tconst error = new HttpErrorResponse({\r\n\t\t\t\t\t\t\t\terror: 'Acceptance failed',\r\n\t\t\t\t\t\t\t\tstatus: 400,\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\tthis.handleError(opts.err, () => {})(error);\r\n\r\n\t\t\t\t\t\t\tresponseSubject.error(error);\r\n\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (opts.replace && typeof opts.replace === 'function') {\r\n\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\tArray.isArray(\r\n\t\t\t\t\t\t\t\tthis._getObjectToReplace(resp, opts.data),\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\tthis._getObjectToReplace(\r\n\t\t\t\t\t\t\t\t\tresp,\r\n\t\t\t\t\t\t\t\t\topts.data,\r\n\t\t\t\t\t\t\t\t) as Array<unknown>\r\n\t\t\t\t\t\t\t).map((item: unknown) => opts.replace(item));\r\n\t\t\t\t\t\t} else if (this._getObjectToReplace(resp, opts.data)) {\r\n\t\t\t\t\t\t\topts.replace(\r\n\t\t\t\t\t\t\t\tthis._getObjectToReplace(resp, opts.data),\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (Array.isArray(opts.fields)) {\r\n\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\tArray.isArray(\r\n\t\t\t\t\t\t\t\tthis._getObjectToReplace(resp, opts.data),\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\tthis._getObjectToReplace(\r\n\t\t\t\t\t\t\t\t\tresp,\r\n\t\t\t\t\t\t\t\t\topts.data,\r\n\t\t\t\t\t\t\t\t) as Array<unknown>\r\n\t\t\t\t\t\t\t).map((item: unknown) => {\r\n\t\t\t\t\t\t\t\treturn this._newDoc(item, opts.fields);\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t} else if (this._getObjectToReplace(resp, opts.data)) {\r\n\t\t\t\t\t\t\tconst newDoc = this._newDoc(\r\n\t\t\t\t\t\t\t\tthis._getObjectToReplace(resp, opts.data),\r\n\t\t\t\t\t\t\t\topts.fields,\r\n\t\t\t\t\t\t\t);\r\n\r\n\t\t\t\t\t\t\tif (opts.data) {\r\n\t\t\t\t\t\t\t\tthis._setObjectToReplace(\r\n\t\t\t\t\t\t\t\t\tresp,\r\n\t\t\t\t\t\t\t\t\topts.data,\r\n\t\t\t\t\t\t\t\t\tnewDoc,\r\n\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\tresp = newDoc;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.response_handle(_url, resp, () => callback(resp));\r\n\r\n\t\t\t\t\tresponseSubject.next(resp);\r\n\r\n\t\t\t\t\tresponseSubject.complete();\r\n\t\t\t\t},\r\n\t\t\t\terror: (err) => responseSubject.error(err),\r\n\t\t\t\tcomplete: () => responseSubject.complete(),\r\n\t\t\t});\r\n\r\n\t\treturn responseSubject.asObservable();\r\n\t}\r\n\r\n\t/**\r\n\t * Public method to perform a POST request.\r\n\t * - Supports legacy callback usage.\r\n\t * - Returns an Observable for reactive programming.\r\n\t */\r\n\tpost(\r\n\t\turl: string,\r\n\t\tdoc: any,\r\n\t\tcallback = (resp: any) => {},\r\n\t\topts: any = {},\r\n\t): Observable<any> {\r\n\t\treturn this._post(url, doc, callback, opts);\r\n\t}\r\n\r\n\t/**\r\n\t * Public method to perform a PUT request.\r\n\t * - Supports legacy callback usage.\r\n\t * - Returns an Observable for reactive programming.\r\n\t */\r\n\tput(\r\n\t\turl: string,\r\n\t\tdoc: any,\r\n\t\tcallback = (resp: any) => {},\r\n\t\topts: any = {},\r\n\t): Observable<any> {\r\n\t\treturn this._post(url, doc, callback, opts, 'put');\r\n\t}\r\n\r\n\t/**\r\n\t * Public method to perform a PATCH request.\r\n\t * - Supports legacy callback usage.\r\n\t * - Returns an Observable for reactive programming.\r\n\t */\r\n\tpatch(\r\n\t\turl: string,\r\n\t\tdoc: any,\r\n\t\tcallback = (resp: any) => {},\r\n\t\topts: any = {},\r\n\t): Observable<any> {\r\n\t\treturn this._post(url, doc, callback, opts, 'patch');\r\n\t}\r\n\r\n\t/**\r\n\t * Public method to perform a DELETE request.\r\n\t * - Supports legacy callback usage.\r\n\t * - Returns an Observable for reactive programming.\r\n\t */\r\n\tdelete(\r\n\t\turl: string,\r\n\t\tcallback = (resp: any) => {},\r\n\t\topts: any = {},\r\n\t): Observable<any> {\r\n\t\treturn this._post(url, null, callback, opts, 'delete');\r\n\t}\r\n\r\n\t/**\r\n\t * Public method to perform a GET request.\r\n\t * - Supports legacy callback usage.\r\n\t * - Returns an Observable for reactive programming.\r\n\t */\r\n\tget(\r\n\t\turl: string,\r\n\t\tcallback = (resp: any) => {},\r\n\t\topts: any = {},\r\n\t): Observable<any> {\r\n\t\treturn this._post(url, null, callback, opts, 'get');\r\n\t}\r\n\r\n\t// Clear all pending request locks\r\n\tclearLocked() {\r\n\t\tfor (const awaitLocked of this.awaitLocked) {\r\n\t\t\tclearTimeout(awaitLocked);\r\n\t\t}\r\n\t\tthis.awaitLocked = [];\r\n\t}\r\n\r\n\t// Lock the service to prevent multiple simultaneous requests\r\n\tlock() {\r\n\t\tthis.locked = true;\r\n\t}\r\n\r\n\t// Unlock the service to allow new requests\r\n\tunlock() {\r\n\t\tthis.locked = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Handles HTTP errors.\r\n\t * - Calls provided error callback and retries the request if needed.\r\n\t */\r\n\tprivate handleError(callback: any, retry: () => void) {\r\n\t\treturn (error: HttpErrorResponse): Promise<void> => {\r\n\t\t\treturn new Promise((resolve) => {\r\n\t\t\t\tthis.err_handle(error, callback, retry);\r\n\t\t\t\tresolve();\r\n\t\t\t});\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Internal method to trigger error handling callbacks.\r\n\t */\r\n\tprivate err_handle(\r\n\t\terr: HttpErrorResponse,\r\n\t\tnext: (err: HttpErrorResponse) => void,\r\n\t\tretry: () => void,\r\n\t) {\r\n\t\tif (typeof next === 'function') {\r\n\t\t\tnext(err);\r\n\t\t}\r\n\r\n\t\tfor (const callback of this.errors) {\r\n\t\t\tif (typeof callback === 'function') {\r\n\t\t\t\tcallback(err, retry);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Placeholder method for handling request preparation (can be customized)\r\n\tprivate prepare_handle(url: string, body: unknown) {}\r\n\r\n\t// Placeholder method for handling the response (can be customized)\r\n\tprivate response_handle(url: string, body: unknown, next: () => void) {\r\n\t\tif (typeof next === 'function') {\r\n\t\t\tnext();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves a nested object or property from the response based on a dot-separated path.\r\n\t *\r\n\t * @param resp - The response object to retrieve data from.\r\n\t * @param base - A dot-separated string indicating the path to the desired property within the response.\r\n\t *   - Example: `'data.items'` will navigate through `resp.data.items`.\r\n\t *   - If empty, the entire response is returned.\r\n\t * @returns The object or property located at the specified path within the response.\r\n\t */\r\n\tprivate _getObjectToReplace(resp: unknown, base = ''): unknown {\r\n\t\tif (base.includes('.')) {\r\n\t\t\tconst newBase = base.split('');\r\n\r\n\t\t\tconst currentBase: string = newBase.pop() || '';\r\n\r\n\t\t\treturn this._getObjectToReplace(\r\n\t\t\t\t(resp as Record<string, unknown>)[currentBase] || {},\r\n\t\t\t\tnewBase.join('.'),\r\n\t\t\t);\r\n\t\t} else if (base) {\r\n\t\t\treturn (resp as Record<string, unknown>)[base];\r\n\t\t} else {\r\n\t\t\treturn resp;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets or replaces a nested object or property in the response based on a dot-separated path.\r\n\t *\r\n\t * @param resp - The response object to modify.\r\n\t * @param base - A dot-separated string indicating the path to the property to replace.\r\n\t *   - Example: `'data.items'` will navigate through `resp.data.items`.\r\n\t * @param doc - The new data or object to set at the specified path.\r\n\t * @returns `void`.\r\n\t */\r\n\tprivate _setObjectToReplace(resp: unknown, base = '', doc: unknown): void {\r\n\t\twhile (base.includes('.')) {\r\n\t\t\tconst newBase = base.split('');\r\n\r\n\t\t\tconst currentBase: string = newBase.pop() || '';\r\n\r\n\t\t\tresp = (resp as Record<string, unknown>)[currentBase] || {};\r\n\r\n\t\t\tbase = newBase.join('.');\r\n\t\t}\r\n\r\n\t\t(resp as Record<string, unknown>)[base] = doc;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new object containing only specified fields from the input item.\r\n\t *\r\n\t * @param item - The input object to extract fields from.\r\n\t * @param fields - An array of field names to include in the new object.\r\n\t *   - Example: `['id', 'name']` will create a new object with only the `id` and `name` properties from `item`.\r\n\t * @returns A new object containing only the specified fields.\r\n\t */\r\n\tprivate _newDoc(item: unknown, fields: string[]): unknown {\r\n\t\tconst newDoc: Record<string, unknown> = {};\r\n\r\n\t\tfor (const field of fields) {\r\n\t\t\tnewDoc[field] = (item as Record<string, unknown>)[field];\r\n\t\t}\r\n\r\n\t\treturn newDoc;\r\n\t}\r\n}\r\n","// network.service.ts — Angular 20+ (zoneless) signal-based connectivity checker\r\nimport { inject, Inject, Injectable, Optional, signal } from '@angular/core';\r\nimport { Config, CONFIG_TOKEN } from '../interfaces/config.interface';\r\nimport {\r\n\tDEFAULT_NETWORK_CONFIG,\r\n\tNetworkConfig,\r\n\tNetworkStatus,\r\n} from '../interfaces/network.interface';\r\nimport { EmitterService } from './emitter.service';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class NetworkService {\r\n\t/** Internal mutable signals. */\r\n\tprivate _status = signal<NetworkStatus>(navigator.onLine ? 'poor' : 'none');\r\n\tprivate _latencyMs = signal<number | null>(null);\r\n\tprivate _isOnline = signal<boolean>(navigator.onLine);\r\n\r\n\t/** Public read-only signals. */\r\n\treadonly status = this._status.asReadonly();\r\n\treadonly latencyMs = this._latencyMs.asReadonly();\r\n\treadonly isOnline = this._isOnline.asReadonly();\r\n\r\n\t/** Failure counter to decide \"none\". */\r\n\tprivate fails = 0;\r\n\r\n\t/**\r\n\t * Creates the network monitor, binds browser/Capacitor events,\r\n\t * performs an immediate check, and starts periodic polling.\r\n\t */\r\n\tconstructor(@Inject(CONFIG_TOKEN) @Optional() config: Config) {\r\n\t\tthis._config = {\r\n\t\t\t...DEFAULT_NETWORK_CONFIG,\r\n\t\t\t...(config.network || ({} as NetworkConfig)),\r\n\t\t};\r\n\r\n\t\tthis._bindEvents();\r\n\r\n\t\tthis.recheckNow(); // fire once on start\r\n\r\n\t\twindow.setInterval(() => this.recheckNow(), this._config.intervalMs);\r\n\t}\r\n\r\n\t/**\r\n\t * Manually trigger a connectivity check.\r\n\t * - Measures latency against the first reachable endpoint.\r\n\t * - Updates `isOnline`, `latencyMs`, and `status` accordingly.\r\n\t */\r\n\tasync recheckNow(): Promise<void> {\r\n\t\tconst res = await this._pingAny();\r\n\r\n\t\tif (res.ok && res.latency != null) {\r\n\t\t\tthis.fails = 0;\r\n\r\n\t\t\tthis._latencyMs.set(res.latency);\r\n\r\n\t\t\tthis._isOnline.set(true);\r\n\t\t} else {\r\n\t\t\tthis.fails++;\r\n\r\n\t\t\tthis._latencyMs.set(null);\r\n\t\t\t// `isOnline` may still be true per OS; we let online/offline events keep it in sync.\r\n\t\t}\r\n\r\n\t\tthis._updateClassification();\r\n\t}\r\n\r\n\t// ─────────────────────────── Internals ───────────────────────────\r\n\r\n\t/**\r\n\t * Classifies current state into 'good' | 'poor' | 'none'.\r\n\t * - 'none' if offline or too many consecutive failures.\r\n\t * - 'good' if latency ≤ goodLatencyMs.\r\n\t * - otherwise 'poor'.\r\n\t */\r\n\tprivate _updateClassification(): void {\r\n\t\tif (\r\n\t\t\t!this._isOnline() ||\r\n\t\t\tthis.fails >= this._config.maxConsecutiveFails\r\n\t\t) {\r\n\t\t\tif (this._status() !== 'none') {\r\n\t\t\t\tthis._status.set('none');\r\n\r\n\t\t\t\tthis._emitterService.emit('wacom_offline');\r\n\t\t\t}\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tconst l = this._latencyMs();\r\n\r\n\t\tif (l != null && l <= this._config.goodLatencyMs) {\r\n\t\t\tif (this._status() !== 'good') {\r\n\t\t\t\tthis._status.set('good');\r\n\r\n\t\t\t\tthis._emitterService.emit('wacom_online');\r\n\t\t\t}\r\n\t\t} else if (this._status() !== 'poor') {\r\n\t\t\tthis._status.set('poor');\r\n\r\n\t\t\tthis._emitterService.emit('wacom_online');\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Binds browser events that can affect connectivity:\r\n\t * - online/offline (OS connectivity)\r\n\t * - visibilitychange (recheck on focus)\r\n\t * - NetworkInformation 'change' (if supported)\r\n\t */\r\n\tprivate _bindEvents(): void {\r\n\t\twindow.addEventListener('online', () => {\r\n\t\t\tthis._isOnline.set(true);\r\n\r\n\t\t\tthis.recheckNow();\r\n\t\t});\r\n\r\n\t\twindow.addEventListener('offline', () => {\r\n\t\t\tthis._isOnline.set(false);\r\n\r\n\t\t\tthis._updateClassification();\r\n\t\t});\r\n\r\n\t\t(navigator as any).connection?.addEventListener?.('change', () =>\r\n\t\t\tthis.recheckNow(),\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Tries endpoints in order until one responds (CORS or opaque).\r\n\t * Returns success with measured latency, or a failure result.\r\n\t */\r\n\tprivate async _pingAny(): Promise<{ ok: boolean; latency: number | null }> {\r\n\t\tfor (const url of this._config.endpoints) {\r\n\t\t\tconst noCors = !url.includes('api.webart.work'); // treat public fallbacks as opaque checks\r\n\r\n\t\t\tconst r = await this._measure(\r\n\t\t\t\turl,\r\n\t\t\t\tthis._config.timeoutMs,\r\n\t\t\t\tnoCors,\r\n\t\t\t).catch(() => null);\r\n\r\n\t\t\tif (r?.ok) return r;\r\n\t\t}\r\n\r\n\t\treturn { ok: false, latency: null };\r\n\t}\r\n\r\n\t/**\r\n\t * Measures a single fetch:\r\n\t * - Appends a timestamp to bypass caches.\r\n\t * - Uses `no-store` to avoid intermediaries caching.\r\n\t * - When `noCors` is true, uses `mode:'no-cors'` and treats a resolved fetch as reachable.\r\n\t */\r\n\tprivate async _measure(\r\n\t\turl: string,\r\n\t\ttimeoutMs: number,\r\n\t\tnoCors = false,\r\n\t): Promise<{ ok: boolean; latency: number | null }> {\r\n\t\tconst ctrl = new AbortController();\r\n\t\tconst timer = setTimeout(() => ctrl.abort(), timeoutMs);\r\n\t\tconst t0 = performance.now();\r\n\r\n\t\ttry {\r\n\t\t\tconst res = await fetch(\r\n\t\t\t\turl + (url.includes('?') ? '&' : '?') + 't=' + Date.now(),\r\n\t\t\t\t{\r\n\t\t\t\t\tmethod: 'GET',\r\n\t\t\t\t\tcache: 'no-store',\r\n\t\t\t\t\tcredentials: 'omit',\r\n\t\t\t\t\tsignal: ctrl.signal,\r\n\t\t\t\t\tmode: noCors ? 'no-cors' : 'cors',\r\n\t\t\t\t},\r\n\t\t\t);\r\n\r\n\t\t\tclearTimeout(timer);\r\n\r\n\t\t\tconst latency = Math.round(performance.now() - t0);\r\n\r\n\t\t\t// In no-cors, Response is opaque; treat as success if the fetch resolved.\r\n\t\t\tconst ok = noCors ? true : res.ok;\r\n\r\n\t\t\treturn { ok, latency };\r\n\t\t} catch {\r\n\t\t\tclearTimeout(timer);\r\n\r\n\t\t\treturn { ok: false, latency: null };\r\n\t\t}\r\n\t}\r\n\r\n\tprivate _config: NetworkConfig;\r\n\r\n\tprivate _emitterService = inject(EmitterService);\r\n}\r\n","import { Inject, Injectable, Optional } from '@angular/core';\r\nimport {\r\n\tCONFIG_TOKEN,\r\n\tConfig,\r\n\tDEFAULT_CONFIG,\r\n} from '../interfaces/config.interface';\r\nimport { StoreConfig } from '../interfaces/store.interface';\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\nexport class StoreService {\r\n\tconstructor(@Inject(CONFIG_TOKEN) @Optional() config: Config) {\r\n\t\tthis._config = {\r\n\t\t\t...DEFAULT_CONFIG,\r\n\t\t\t...(config?.store || {}),\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the prefix for storage keys.\r\n\t *\r\n\t * @param prefix - The prefix to set.\r\n\t */\r\n\tsetPrefix(prefix: string): void {\r\n\t\tthis._prefix = prefix;\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a value in storage asynchronously.\r\n\t *\r\n\t * @param key - The storage key.\r\n\t * @param value - The value to store.\r\n\t * @returns A promise that resolves to a boolean indicating success.\r\n\t */\r\n\tasync set(\r\n\t\tkey: string,\r\n\t\tvalue: string,\r\n\t\tcallback: () => void = () => {},\r\n\t\terrCallback: (err: unknown) => void = () => {},\r\n\t): Promise<boolean> {\r\n\t\tkey = this._applyPrefix(key);\r\n\r\n\t\ttry {\r\n\t\t\tif (this._config.set) {\r\n\t\t\t\tawait this._config.set(key, value, callback, errCallback);\r\n\t\t\t} else {\r\n\t\t\t\tlocalStorage.setItem(key, value);\r\n\r\n\t\t\t\tcallback();\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t} catch (err) {\r\n\t\t\tconsole.error(err);\r\n\r\n\t\t\terrCallback(err);\r\n\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a value from storage asynchronously.\r\n\t *\r\n\t * @param key - The storage key.\r\n\t * @returns A promise that resolves to the retrieved value or `null` if the key is missing.\r\n\t */\r\n\tasync get(\r\n\t\tkey: string,\r\n\t\tcallback?: (value: string | null) => void,\r\n\t\terrCallback: (err: unknown) => void = () => {},\r\n\t): Promise<string | null> {\r\n\t\tkey = this._applyPrefix(key);\r\n\r\n\t\ttry {\r\n\t\t\tif (this._config.get) {\r\n\t\t\t\tconst value = await this._config.get(\r\n\t\t\t\t\tkey,\r\n\t\t\t\t\t(val: string) => {\r\n\t\t\t\t\t\tcallback?.(val ?? null);\r\n\t\t\t\t\t},\r\n\t\t\t\t\terrCallback,\r\n\t\t\t\t);\r\n\r\n\t\t\t\treturn value ?? null;\r\n\t\t\t} else {\r\n\t\t\t\tconst value = localStorage.getItem(key);\r\n\r\n\t\t\t\tcallback?.(value ?? null);\r\n\r\n\t\t\t\treturn value ?? null;\r\n\t\t\t}\r\n\t\t} catch (err) {\r\n\t\t\tconsole.error(err);\r\n\r\n\t\t\terrCallback(err);\r\n\r\n\t\t\treturn null;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets a JSON value in storage asynchronously.\r\n\t *\r\n\t * @param key - The storage key.\r\n\t * @param value - The value to store.\r\n\t * @returns A promise that resolves to a boolean indicating success.\r\n\t */\r\n\tasync setJson<T>(\r\n\t\tkey: string,\r\n\t\tvalue: T,\r\n\t\tcallback: () => void = () => {},\r\n\t\terrCallback: (err: unknown) => void = () => {},\r\n\t): Promise<boolean> {\r\n\t\treturn await this.set(\r\n\t\t\tkey,\r\n\t\t\tJSON.stringify(value),\r\n\t\t\tcallback,\r\n\t\t\terrCallback,\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a JSON value from storage asynchronously.\r\n\t *\r\n\t * @param key - The storage key.\r\n\t * @returns A promise that resolves to the retrieved value.\r\n\t */\r\n\tasync getJson<T = any>(\r\n\t\tkey: string,\r\n\t\tcallback?: (value: string | null) => void,\r\n\t\terrCallback: (err: unknown) => void = () => {},\r\n\t): Promise<T | null> {\r\n\t\tconst value = await this.get(key);\r\n\r\n\t\tif (value === null) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tconst result = JSON.parse(value);\r\n\r\n\t\t\tcallback?.(result);\r\n\r\n\t\t\treturn result;\r\n\t\t} catch (err) {\r\n\t\t\terrCallback?.(err);\r\n\r\n\t\t\tconsole.error(err);\r\n\r\n\t\t\treturn null;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value from storage.\r\n\t *\r\n\t * @param key - The storage key.\r\n\t * @param callback - The callback to execute on success.\r\n\t * @param errCallback - The callback to execute on error.\r\n\t * @returns A promise that resolves to a boolean indicating success.\r\n\t */\r\n\tasync remove(\r\n\t\tkey: string,\r\n\t\tcallback: () => void = () => {},\r\n\t\terrCallback: (err: unknown) => void = () => {},\r\n\t): Promise<boolean> {\r\n\t\tkey = this._applyPrefix(key);\r\n\r\n\t\ttry {\r\n\t\t\tif (this._config.remove) {\r\n\t\t\t\treturn await this._config.remove(key, callback, errCallback);\r\n\t\t\t} else {\r\n\t\t\t\tlocalStorage.removeItem(key);\r\n\r\n\t\t\t\tcallback();\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t} catch (err) {\r\n\t\t\tconsole.error(err);\r\n\r\n\t\t\terrCallback(err);\r\n\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Clears all values from storage.\r\n\t *\r\n\t * @param callback - The callback to execute on success.\r\n\t * @param errCallback - The callback to execute on error.\r\n\t * @returns A promise that resolves to a boolean indicating success.\r\n\t */\r\n\tasync clear(\r\n\t\tcallback?: () => void,\r\n\t\terrCallback?: (err: unknown) => void,\r\n\t): Promise<boolean> {\r\n\t\ttry {\r\n\t\t\tif (this._config.clear) {\r\n\t\t\t\tawait this._config.clear();\r\n\t\t\t} else {\r\n\t\t\t\tlocalStorage.clear();\r\n\t\t\t}\r\n\r\n\t\t\tcallback?.();\r\n\r\n\t\t\treturn true;\r\n\t\t} catch (err) {\r\n\t\t\tconsole.error(err);\r\n\r\n\t\t\terrCallback?.(err);\r\n\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate _prefix = '';\r\n\r\n\tprivate _config: StoreConfig;\r\n\r\n\t/**\r\n\t * Applies the configured prefix to a storage key.\r\n\t *\r\n\t * @param key - The storage key.\r\n\t * @returns The prefixed storage key.\r\n\t */\r\n\tprivate _applyPrefix(key: string): string {\r\n\t\tif (this._config.prefix) {\r\n\t\t\tkey = this._config.prefix + key;\r\n\t\t}\r\n\r\n\t\tif (this._prefix) {\r\n\t\t\tkey = this._prefix + key;\r\n\t\t}\r\n\r\n\t\treturn key;\r\n\t}\r\n}\r\n","import { inject, signal, WritableSignal } from '@angular/core';\r\nimport { Observable } from 'rxjs';\r\nimport { CoreService } from '../services/core.service';\r\nimport { EmitterService } from '../services/emitter.service';\r\nimport { HttpService } from '../services/http.service';\r\nimport { NetworkService } from '../services/network.service';\r\nimport { StoreService } from '../services/store.service';\r\nimport { CrudDocument, CrudOptions } from './crud.interface';\r\n\r\ninterface CrudConfig<Document> {\r\n\tsignalFields?: Record<string, (doc: Document) => unknown>;\r\n\tname: string;\r\n\t_id?: string;\r\n\treplace?: (doc: Document) => void;\r\n\tunauthorized?: boolean;\r\n\tappId?: string;\r\n}\r\n\r\ninterface GetConfig {\r\n\tpage?: number;\r\n\tperPage?: number;\r\n\tquery?: string;\r\n}\r\n\r\n/**\r\n * Abstract class representing a CRUD (Create, Read, Update, Delete) service.\r\n *\r\n * This class provides methods for managing documents, interacting with an API,\r\n * and storing/retrieving data from local storage. It is designed to be extended\r\n * for specific document types.\r\n *\r\n * @template Document - The type of the document the service handles.\r\n */\r\nexport abstract class CrudService<Document extends CrudDocument<Document>> {\r\n\t/**\r\n\t * Base URL for the API collection associated with this service.\r\n\t */\r\n\tprivate _url = '/api/';\r\n\r\n\t/**\r\n\t * In-memory cache with all documents currently known by the service.\r\n\t */\r\n\tprivate _docs: Document[] = [];\r\n\r\n\t/**\r\n\t * Number of documents per page for paginated `get()` calls.\r\n\t */\r\n\tprivate _perPage = 20;\r\n\r\n\t/**\r\n\t * Registered callbacks that recompute filtered document views.\r\n\t */\r\n\tprivate _filteredDocumentsCallbacks: (() => void)[] = [];\r\n\r\n\t/**\r\n\t * HTTP client wrapper used for API communication.\r\n\t */\r\n\tprotected __httpService = inject(HttpService);\r\n\r\n\t/**\r\n\t * Key–value storage service used to persist documents locally.\r\n\t */\r\n\tprotected __storeService = inject(StoreService);\r\n\r\n\t/**\r\n\t * Core helper service with utility methods (copy, debounce, toSignal, etc.).\r\n\t */\r\n\tprotected __coreService = inject(CoreService);\r\n\r\n\t/**\r\n\t * Global event bus for cross-service communication.\r\n\t */\r\n\tprotected __emitterService = inject(EmitterService);\r\n\r\n\t/**\r\n\t * Network status service used to queue work while offline.\r\n\t */\r\n\tprotected __networkService = inject(NetworkService);\r\n\r\n\t/**\r\n\t * Emits once when documents are restored from local storage on startup.\r\n\t */\r\n\tloaded: Observable<unknown>;\r\n\r\n\t/**\r\n\t * Emits once when the initial `get()` (without page param) completes.\r\n\t */\r\n\tgetted: Observable<unknown>;\r\n\r\n\tconstructor(private _config: CrudConfig<Document>) {\r\n\t\tthis._config.signalFields = this._config.signalFields || {};\r\n\r\n\t\tthis._url += this._config.name;\r\n\r\n\t\tthis.loaded = this.__emitterService.onComplete(\r\n\t\t\tthis._config.name + '_loaded',\r\n\t\t);\r\n\r\n\t\tthis.getted = this.__emitterService.onComplete(\r\n\t\t\tthis._config.name + '_getted',\r\n\t\t);\r\n\r\n\t\tif (this._config.unauthorized) {\r\n\t\t\tthis.restoreDocs();\r\n\t\t} else if (localStorage.getItem('waw_user')) {\r\n\t\t\tconst user = JSON.parse(localStorage.getItem('waw_user') as string);\r\n\r\n\t\t\tif (\r\n\t\t\t\tuser._id ===\r\n\t\t\t\tlocalStorage.getItem(this._config.name + 'waw_user_id')\r\n\t\t\t) {\r\n\t\t\t\tthis.restoreDocs();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.__emitterService.on('wipe').subscribe((): void => {\r\n\t\t\tthis.clearDocs();\r\n\r\n\t\t\tthis._filterDocuments();\r\n\t\t});\r\n\r\n\t\tthis.__emitterService.on('wacom_online').subscribe(() => {\r\n\t\t\tfor (const callback of this._onOnline) {\r\n\t\t\t\tcallback();\r\n\t\t\t}\r\n\r\n\t\t\tthis._onOnline.length = 0;\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Cache of per-document signals indexed by document _id.\r\n\t * Prevents creating multiple signals for the same document.\r\n\t */\r\n\tprivate _signal: Record<string, WritableSignal<Document>> = {};\r\n\r\n\t/**\r\n\t * Cache of per (field,value) lists of document signals.\r\n\t * Key format: `${field}_${JSON.stringify(value)}`.\r\n\t */\r\n\tprivate _signals: Record<\r\n\t\tstring,\r\n\t\tWritableSignal<WritableSignal<Document>[]>\r\n\t> = {};\r\n\r\n\t/**\r\n\t * Cache of per-field maps: fieldValue -> array of document signals.\r\n\t */\r\n\tprivate _fieldSignals: Record<\r\n\t\tstring,\r\n\t\tWritableSignal<Record<string, WritableSignal<Document>[]>>\r\n\t> = {};\r\n\r\n\t/**\r\n\t * Returns a WritableSignal for a document by _id, creating it if absent.\r\n\t * Caches the signal to avoid redundant instances and initializes it\r\n\t * with the current snapshot of the document.\r\n\t * Work very carefully with this and localId, better avoid such flows.\r\n\t *\r\n\t * @param _id - Document identifier or a document instance.\r\n\t */\r\n\tgetSignal(_id: string | Document) {\r\n\t\tif (typeof _id !== 'string') {\r\n\t\t\t_id = this._id(_id);\r\n\t\t}\r\n\r\n\t\t// Reuse existing signal if present\r\n\t\tif (this._signal[_id]) {\r\n\t\t\treturn this._signal[_id];\r\n\t\t}\r\n\r\n\t\t// Always base the signal on the current canonical doc()\r\n\t\tconst doc = this.doc(_id);\r\n\r\n\t\tthis._signal[_id] = this.__coreService.toSignal(\r\n\t\t\tdoc,\r\n\t\t\tthis._config.signalFields,\r\n\t\t) as WritableSignal<Document>;\r\n\r\n\t\treturn this._signal[_id];\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a signal with an array of document signals that match\r\n\t * a given field/value pair.\r\n\t *\r\n\t * Example:\r\n\t *   const activitiesSig = service.getSignals('userId', currentUserId);\r\n\t */\r\n\tgetSignals(field: string, value: unknown) {\r\n\t\tconst id = field + '_' + JSON.stringify(value);\r\n\r\n\t\tif (!this._signals[id]) {\r\n\t\t\tthis._signals[id] = signal<WritableSignal<Document>[]>(\r\n\t\t\t\tthis._getSignals(id),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn this._signals[id];\r\n\t}\r\n\r\n\t/**\r\n\t * Builds the array of document signals for a given (field,value) key.\r\n\t * Only documents with a real _id are included.\r\n\t */\r\n\tprivate _getSignals(id: string): WritableSignal<Document>[] {\r\n\t\tconst sep = id.indexOf('_');\r\n\t\tif (sep === -1) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\tconst field = id.slice(0, sep) as keyof Document;\r\n\t\tconst valueJson = id.slice(sep + 1);\r\n\r\n\t\tconst list: WritableSignal<Document>[] = [];\r\n\r\n\t\tfor (const doc of this.getDocs()) {\r\n\t\t\tif (JSON.stringify(doc[field] as unknown) !== valueJson) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tconst docId = this._id(doc);\r\n\t\t\tif (!docId) continue;\r\n\r\n\t\t\tlist.push(this.getSignal(docId));\r\n\t\t}\r\n\r\n\t\treturn list;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a signal with a map: fieldValue -> array of document signals.\r\n\t *\r\n\t * Example:\r\n\t *   const byStatusSig = service.getFieldSignals('status');\r\n\t *   byStatusSig() might be { active: [sig1, sig2], draft: [sig3] }.\r\n\t */\r\n\tgetFieldSignals(field: string) {\r\n\t\tif (!this._fieldSignals[field]) {\r\n\t\t\tthis._fieldSignals[field] = signal<\r\n\t\t\t\tRecord<string, WritableSignal<Document>[]>\r\n\t\t\t>(this._getFieldSignals(field));\r\n\t\t}\r\n\r\n\t\treturn this._fieldSignals[field];\r\n\t}\r\n\r\n\t/**\r\n\t * Builds the map for a given field.\r\n\t * Only documents with a real _id are included.\r\n\t */\r\n\tprivate _getFieldSignals(\r\n\t\tfield: string,\r\n\t): Record<string, WritableSignal<Document>[]> {\r\n\t\tconst byFields: Record<string, WritableSignal<Document>[]> = {};\r\n\r\n\t\tfor (const doc of this.getDocs()) {\r\n\t\t\tconst docId = this._id(doc);\r\n\t\t\tif (!docId) continue;\r\n\r\n\t\t\tconst value = String(doc[field as keyof Document]);\r\n\r\n\t\t\tif (!byFields[value]) {\r\n\t\t\t\tbyFields[value] = [];\r\n\t\t\t}\r\n\r\n\t\t\tbyFields[value].push(this.getSignal(docId));\r\n\t\t}\r\n\r\n\t\treturn byFields;\r\n\t}\r\n\r\n\t/**\r\n\t * Clears cached document signals except those explicitly preserved.\r\n\t * Useful when changing routes or contexts to reduce memory.\r\n\t *\r\n\t * @param exceptIds - List of ids whose signals should be kept.\r\n\t */\r\n\tremoveSignals(exceptIds: string[] = []) {\r\n\t\tfor (const _id in this._signal) {\r\n\t\t\tif (!exceptIds.includes(_id)) {\r\n\t\t\t\tdelete this._signal[_id];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Restores documents from local storage (if present) and syncs\r\n\t * all existing signals with the restored data.\r\n\t */\r\n\tasync restoreDocs() {\r\n\t\tconst docs = await this.__storeService.getJson<Document[]>(\r\n\t\t\t'docs_' + this._config.name,\r\n\t\t);\r\n\r\n\t\tif (docs?.length) {\r\n\t\t\tthis._docs.length = 0;\r\n\r\n\t\t\tthis._docs.push(...docs);\r\n\r\n\t\t\tthis._filterDocuments();\r\n\r\n\t\t\tfor (const doc of this._docs) {\r\n\t\t\t\tif (doc.__deleted) {\r\n\t\t\t\t\tthis.delete(doc, doc.__options?.['delete'] || {});\r\n\t\t\t\t} else if (!doc._id) {\r\n\t\t\t\t\tthis.create(doc, doc.__options?.['create'] || {});\r\n\t\t\t\t} else if (doc.__modified?.length) {\r\n\t\t\t\t\tfor (const id of doc.__modified) {\r\n\t\t\t\t\t\tif (id.startsWith('up')) {\r\n\t\t\t\t\t\t\tthis.update(doc, doc.__options?.[id] || {});\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tthis.unique(doc, doc.__options?.[id] || {});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis.__emitterService.complete(\r\n\t\t\t\tthis._config.name + '_loaded',\r\n\t\t\t\tthis._docs,\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Saves the current set of documents to local storage.\r\n\t */\r\n\tsetDocs(): void {\r\n\t\tthis.__storeService.setJson<Document[]>(\r\n\t\t\t'docs_' + this._config.name,\r\n\t\t\tthis._docs,\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the current list of documents.\r\n\t *\r\n\t * @returns The list of documents.\r\n\t */\r\n\tgetDocs(filter: (doc: Document) => boolean = () => true): Document[] {\r\n\t\treturn this._docs.filter(filter);\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the first document that matches the given predicate.\r\n\t *\r\n\t * @param find - Predicate used to locate a specific document.\r\n\t */\r\n\tgetDoc(find: (doc: Document) => boolean): Document | undefined {\r\n\t\treturn this._docs.find(find);\r\n\t}\r\n\r\n\t/**\r\n\t * Clears the current list of documents, persists the empty state\r\n\t * and recomputes all derived signals.\r\n\t *\r\n\t * Empties the internal documents array and saves the updated state to local storage.\r\n\t */\r\n\tclearDocs(): void {\r\n\t\tthis._docs.splice(0, this._docs.length);\r\n\r\n\t\tthis.setDocs();\r\n\r\n\t\tthis._updateSignals();\r\n\t}\r\n\r\n\t/**\r\n\t * Adds multiple documents to the service and saves them to local storage.\r\n\t *\r\n\t * @param docs - An array of documents to add.\r\n\t */\r\n\taddDocs(docs: Document[]): void {\r\n\t\tif (Array.isArray(docs)) {\r\n\t\t\tfor (const doc of docs) {\r\n\t\t\t\tthis.addDoc(doc);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a single document to the service. If it already exists, it will be updated.\r\n\t *\r\n\t * @param doc - The document to add.\r\n\t */\r\n\taddDoc(doc: Document): void {\r\n\t\tif (this._config.replace) {\r\n\t\t\tthis._config.replace(doc);\r\n\t\t}\r\n\r\n\t\tconst existingDoc = this._docs.find(\r\n\t\t\t(d) =>\r\n\t\t\t\t(this._id(doc) && this._id(d) === this._id(doc)) ||\r\n\t\t\t\t(doc._localId && d._localId === doc._localId),\r\n\t\t);\r\n\r\n\t\tif (existingDoc) {\r\n\t\t\tthis.__coreService.copy(doc, existingDoc);\r\n\t\t\tthis.__coreService.copy(existingDoc, doc);\r\n\t\t\tthis._syncSignalForDoc(existingDoc);\r\n\t\t} else {\r\n\t\t\tthis._docs.push(doc);\r\n\t\t\tthis._syncSignalForDoc(doc);\r\n\t\t}\r\n\r\n\t\tthis.setDocs();\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new document with a temporary ID and status flags.\r\n\t *\r\n\t * @param doc - Optional base document to use for the new document.\r\n\t * @returns A new document instance with default properties.\r\n\t */\r\n\tnew(doc: Document = {} as Document): Document {\r\n\t\treturn {\r\n\t\t\t...doc,\r\n\t\t\t_id: undefined,\r\n\t\t\t_localId: this._localId(),\r\n\t\t\t__created: false,\r\n\t\t\t__modified: false,\r\n\t\t} as Document;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves a document by its unique ID or creates a new one if it doesn't exist.\r\n\t *\r\n\t * @param _id - The document ID to search for.\r\n\t * @returns The found document or a new document if not found.\r\n\t */\r\n\tdoc(_id: string): Document {\r\n\t\t// If we already have a signal for this id, use its current value\r\n\t\tif (this._signal[_id]) {\r\n\t\t\treturn this._signal[_id]();\r\n\t\t}\r\n\r\n\t\tlet doc =\r\n\t\t\tthis._docs.find(\r\n\t\t\t\t(d) =>\r\n\t\t\t\t\tthis._id(d) === _id ||\r\n\t\t\t\t\t(d._localId && d._localId === Number(_id)),\r\n\t\t\t) || null;\r\n\r\n\t\t// If doc not found, create + push into _docs so it is not detached\r\n\t\tif (!doc) {\r\n\t\t\tdoc = this.new({ _id } as Document);\r\n\t\t\tthis._docs.push(doc);\r\n\t\t\tthis.setDocs();\r\n\t\t}\r\n\r\n\t\tif (\r\n\t\t\t!this._docs.find((d) => this._id(d) === _id) &&\r\n\t\t\t!this._fetchingId[_id]\r\n\t\t) {\r\n\t\t\tthis._fetchingId[_id] = true;\r\n\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tthis.fetch({ _id }).subscribe((_doc: Document) => {\r\n\t\t\t\t\tthis._fetchingId[_id] = false;\r\n\r\n\t\t\t\t\tif (_doc) {\r\n\t\t\t\t\t\tthis.__coreService.copy(_doc, doc as Document);\r\n\t\t\t\t\t\tthis._syncSignalForDoc(doc as Document);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn doc as Document;\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the number of documents to display per page.\r\n\t *\r\n\t * @param _perPage - Number of documents per page.\r\n\t */\r\n\tsetPerPage(_perPage: number): void {\r\n\t\tthis._perPage = _perPage;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetches a list of documents from the API with optional pagination.\r\n\t *\r\n\t * @param config - Optional pagination configuration.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that resolves with the list of documents.\r\n\t */\r\n\tget(\r\n\t\tconfig: GetConfig = {},\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document[]> {\r\n\t\tif (!this.__networkService.isOnline()) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tthis._onOnline.push(() => {\r\n\t\t\t\t\tthis.get(config, options).subscribe(observer);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (!this._config.unauthorized && localStorage.getItem('waw_user')) {\r\n\t\t\tconst user = JSON.parse(localStorage.getItem('waw_user') as string);\r\n\r\n\t\t\tlocalStorage.setItem(this._config.name + 'waw_user_id', user._id);\r\n\t\t}\r\n\r\n\t\tconst url = `${this._url}/get${options.name || ''}`;\r\n\r\n\t\tconst params =\r\n\t\t\t(typeof config.page === 'number' || config.query ? '?' : '') +\r\n\t\t\t(config.query || '') +\r\n\t\t\t(typeof config.page === 'number'\r\n\t\t\t\t? `&skip=${this._perPage * (config.page - 1)}&limit=${this._perPage}`\r\n\t\t\t\t: '');\r\n\r\n\t\tconst obs = this.__httpService.get(`${url}${params}`);\r\n\r\n\t\tobs.subscribe({\r\n\t\t\tnext: (resp: unknown): void => {\r\n\t\t\t\tresp = resp || [];\r\n\r\n\t\t\t\tif (typeof config.page !== 'number') {\r\n\t\t\t\t\tthis.clearDocs();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t(resp as Document[]).forEach((doc) => this.addDoc(doc));\r\n\r\n\t\t\t\tif (options.callback) {\r\n\t\t\t\t\toptions.callback(resp as Document[]);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (typeof config.page !== 'number') {\r\n\t\t\t\t\tthis._filterDocuments();\r\n\r\n\t\t\t\t\tthis.__emitterService.complete(\r\n\t\t\t\t\t\tthis._config.name + '_getted',\r\n\t\t\t\t\t\tthis._docs,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.__emitterService.emit(\r\n\t\t\t\t\t`${this._config.name}_get`,\r\n\t\t\t\t\tthis._docs,\r\n\t\t\t\t);\r\n\r\n\t\t\t\tthis.__emitterService.emit(\r\n\t\t\t\t\t`${this._config.name}_changed`,\r\n\t\t\t\t\tthis._docs,\r\n\t\t\t\t);\r\n\t\t\t},\r\n\t\t\terror: (err: unknown): void => {\r\n\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\toptions.errCallback(err);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\treturn obs as Observable<Document[]>;\r\n\t}\r\n\r\n\t/**\r\n\t * Sends a request to the API to create a new document.\r\n\t *\r\n\t * @param doc - The document to create.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that resolves with the created document, or emits an error if already created.\r\n\t */\r\n\tcreate(\r\n\t\tdoc: Document = {} as Document,\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document> {\r\n\t\tif (doc._id) {\r\n\t\t\treturn this.update(doc, options);\r\n\t\t}\r\n\r\n\t\tdoc._localId ||= this._localId();\r\n\r\n\t\tdoc.__options ||= {};\r\n\r\n\t\tdoc.__options['create'] = options;\r\n\r\n\t\tthis.addDoc(doc);\r\n\r\n\t\tthis._filterDocuments();\r\n\r\n\t\tif (!this.__networkService.isOnline()) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tthis._onOnline.push(() => {\r\n\t\t\t\t\tthis.create(doc, options).subscribe(observer);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (doc.__creating) {\r\n\t\t\t// Emit an error observable if the document is already created\r\n\t\t\treturn new Observable<Document>((observer) => {\r\n\t\t\t\tobserver.error(\r\n\t\t\t\t\tnew Error('Document is currently already creating.'),\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this._config.appId) {\r\n\t\t\tdoc.appId = this._config.appId;\r\n\t\t}\r\n\r\n\t\tdoc.__creating = true;\r\n\r\n\t\tconst obs = this.__httpService.post(\r\n\t\t\t`${this._url}/create${options.name || ''}`,\r\n\t\t\tdoc,\r\n\t\t);\r\n\r\n\t\tobs.subscribe({\r\n\t\t\tnext: (resp: unknown) => {\r\n\t\t\t\tif (resp) {\r\n\t\t\t\t\tthis.__coreService.copy(resp, doc);\r\n\r\n\t\t\t\t\tthis.addDoc(doc);\r\n\r\n\t\t\t\t\tthis._filterDocuments();\r\n\r\n\t\t\t\t\tif (options.callback) {\r\n\t\t\t\t\t\toptions.callback(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tdoc.__creating = false;\r\n\r\n\t\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\t\toptions.errCallback(resp);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_create`, doc);\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_list`, doc);\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_changed`, doc);\r\n\t\t\t},\r\n\t\t\terror: (err: unknown) => {\r\n\t\t\t\tdoc.__creating = false;\r\n\r\n\t\t\t\tif (options.errCallback) options.errCallback(err);\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\treturn obs as Observable<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Fetches a document from the API based on a query.\r\n\t *\r\n\t * @param query - The query object used to filter documents.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that resolves with the fetched document.\r\n\t */\r\n\tfetch(\r\n\t\tquery: object = {},\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document> {\r\n\t\tif (!this.__networkService.isOnline()) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tthis._onOnline.push(() => {\r\n\t\t\t\t\tthis.fetch(query, options).subscribe(observer);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst obs = this.__httpService.post(\r\n\t\t\t`${this._url}/fetch${options.name || ''}`,\r\n\t\t\tquery,\r\n\t\t);\r\n\r\n\t\tobs.subscribe({\r\n\t\t\tnext: (doc: unknown) => {\r\n\t\t\t\tif (doc) {\r\n\t\t\t\t\tthis.addDoc(doc as Document);\r\n\r\n\t\t\t\t\tthis._filterDocuments();\r\n\r\n\t\t\t\t\tif (options.callback) options.callback(doc as Document);\r\n\r\n\t\t\t\t\tthis.__emitterService.emit(\r\n\t\t\t\t\t\t`${this._config.name}_changed`,\r\n\t\t\t\t\t\tdoc,\r\n\t\t\t\t\t);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\t\toptions.errCallback(doc as Document);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\terror: (err: unknown) => {\r\n\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\toptions.errCallback(err);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\treturn obs as Observable<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates a document after a specified delay and returns an observable.\r\n\t *\r\n\t * @param doc - The document to update.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that emits the updated document.\r\n\t */\r\n\tupdateAfterWhile(\r\n\t\tdoc: Document,\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document> {\r\n\t\treturn new Observable<Document>((observer) => {\r\n\t\t\tthis.__coreService.afterWhile(this._id(doc), () => {\r\n\t\t\t\tthis.update(doc, options).subscribe({\r\n\t\t\t\t\tnext: (updatedDoc) => {\r\n\t\t\t\t\t\tobserver.next(updatedDoc); // Emit the updated document\r\n\t\t\t\t\t},\r\n\t\t\t\t\terror: (err) => {\r\n\t\t\t\t\t\tobserver.error(err); // Forward the error\r\n\t\t\t\t\t},\r\n\t\t\t\t\tcomplete: () => {\r\n\t\t\t\t\t\tobserver.complete(); // Complete the observable\r\n\t\t\t\t\t},\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Updates a document in the API.\r\n\t *\r\n\t * @param doc - The document to update.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that resolves with the updated document.\r\n\t */\r\n\tupdate(\r\n\t\tdoc: Document,\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document> {\r\n\t\tthis._updateModified(doc, 'up' + (options.name || ''), options);\r\n\r\n\t\tif (!this.__networkService.isOnline()) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tthis._onOnline.push(() => {\r\n\t\t\t\t\tthis.update(doc, options).subscribe(observer);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst obs = this.__httpService.post(\r\n\t\t\t`${this._url}/update${options.name || ''}`,\r\n\t\t\tdoc,\r\n\t\t);\r\n\r\n\t\tobs.subscribe({\r\n\t\t\tnext: (resp: unknown) => {\r\n\t\t\t\tif (resp) {\r\n\t\t\t\t\tthis._removeModified(doc, 'up' + (options.name || ''));\r\n\r\n\t\t\t\t\tconst storedDoc = this.doc(doc._id as string);\r\n\r\n\t\t\t\t\tthis.__coreService.copy(resp, storedDoc);\r\n\t\t\t\t\tthis.__coreService.copy(resp, doc);\r\n\r\n\t\t\t\t\tthis._syncSignalForDoc(storedDoc);\r\n\r\n\t\t\t\t\tif (options.callback) {\r\n\t\t\t\t\t\toptions.callback(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\t\toptions.errCallback(resp);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_update`, doc);\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_changed`, doc);\r\n\t\t\t},\r\n\t\t\terror: (err: unknown) => {\r\n\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\toptions.errCallback(err);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\treturn obs as Observable<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Unique update a document field in the API.\r\n\t *\r\n\t * @param doc - The document to update.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that resolves with the updated document.\r\n\t */\r\n\tunique(\r\n\t\tdoc: Document,\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document> {\r\n\t\tthis._updateModified(doc, 'un' + (options.name || ''), options);\r\n\r\n\t\tif (!this.__networkService.isOnline()) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tthis._onOnline.push(() => {\r\n\t\t\t\t\tthis.unique(doc, options).subscribe(observer);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst obs = this.__httpService.post(\r\n\t\t\t`${this._url}/unique${options.name || ''}`,\r\n\t\t\tdoc,\r\n\t\t);\r\n\r\n\t\tobs.subscribe({\r\n\t\t\tnext: (resp: unknown) => {\r\n\t\t\t\tif (resp) {\r\n\t\t\t\t\tthis._removeModified(doc, 'un' + (options.name || ''));\r\n\r\n\t\t\t\t\t(doc as any)[options.name as string] = resp;\r\n\r\n\t\t\t\t\tthis._syncSignalForDoc(doc);\r\n\r\n\t\t\t\t\tif (options.callback) {\r\n\t\t\t\t\t\toptions.callback(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\t\toptions.errCallback(resp);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_unique`, doc);\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_changed`, doc);\r\n\t\t\t},\r\n\t\t\terror: (err: unknown) => {\r\n\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\toptions.errCallback(err);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\treturn obs as Observable<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Deletes a document from the API.\r\n\t *\r\n\t * @param doc - The document to delete.\r\n\t * @param options - Optional callback and error handling configuration.\r\n\t * @returns An observable that resolves with the deleted document.\r\n\t */\r\n\tdelete(\r\n\t\tdoc: Document,\r\n\t\toptions: CrudOptions<Document> = {},\r\n\t): Observable<Document> {\r\n\t\tdoc.__deleted = true;\r\n\r\n\t\tdoc.__options ||= {};\r\n\t\tdoc.__options['delete'] = options;\r\n\r\n\t\tthis.addDoc(doc);\r\n\t\tthis._filterDocuments();\r\n\r\n\t\tif (!this.__networkService.isOnline()) {\r\n\t\t\treturn new Observable((observer) => {\r\n\t\t\t\tthis._onOnline.push(() => {\r\n\t\t\t\t\tthis.delete(doc, options).subscribe(observer);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst obs = this.__httpService.post(\r\n\t\t\t`${this._url}/delete${options.name || ''}`,\r\n\t\t\tdoc,\r\n\t\t);\r\n\r\n\t\tobs.subscribe({\r\n\t\t\tnext: (resp: unknown) => {\r\n\t\t\t\tif (resp) {\r\n\t\t\t\t\tconst idx = this._docs.findIndex(\r\n\t\t\t\t\t\t(d) => this._id(d) === this._id(doc),\r\n\t\t\t\t\t);\r\n\t\t\t\t\tif (idx !== -1) {\r\n\t\t\t\t\t\tthis._docs.splice(idx, 1);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.setDocs();\r\n\r\n\t\t\t\t\t// We keep signal but mark it deleted and recompute mappings.\r\n\t\t\t\t\tthis._syncSignalForDoc({\r\n\t\t\t\t\t\t...doc,\r\n\t\t\t\t\t\t__deleted: true,\r\n\t\t\t\t\t} as Document);\r\n\r\n\t\t\t\t\tthis._filterDocuments();\r\n\r\n\t\t\t\t\tif (options.callback) {\r\n\t\t\t\t\t\toptions.callback(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\t\toptions.errCallback(resp);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_delete`, doc);\r\n\r\n\t\t\t\tthis.__emitterService.emit(`${this._config.name}_changed`, doc);\r\n\t\t\t},\r\n\t\t\terror: (err: unknown) => {\r\n\t\t\t\tif (options.errCallback) {\r\n\t\t\t\t\toptions.errCallback(err);\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\treturn obs as Observable<Document>;\r\n\t}\r\n\r\n\t/**\r\n\t * Registers a filtered view of documents and returns the recompute callback.\r\n\t *\r\n\t * The callback is called automatically whenever `_filterDocuments()` runs.\r\n\t */\r\n\tfilteredDocuments(\r\n\t\tstoreObjectOrArray: Record<string, Document[]> | Document[],\r\n\t\tconfig: {\r\n\t\t\tfield?: string | ((doc: Document) => string);\r\n\t\t\tvalid?: (doc: Document) => boolean;\r\n\t\t\tsort?: (a: Document, b: Document) => number;\r\n\t\t\tfiltered?: (\r\n\t\t\t\tstoreObjectOrArray: Record<string, Document[]> | Document[],\r\n\t\t\t) => void;\r\n\t\t} = {},\r\n\t) {\r\n\t\tconst callback = (): void => {\r\n\t\t\tif (Array.isArray(storeObjectOrArray)) {\r\n\t\t\t\tlet result = this._docs\r\n\t\t\t\t\t.filter((doc) => !doc.__deleted)\r\n\t\t\t\t\t.filter(config.valid ?? (() => true));\r\n\r\n\t\t\t\tstoreObjectOrArray.length = 0;\r\n\r\n\t\t\t\tif (typeof config.sort === 'function') {\r\n\t\t\t\t\tresult = result.sort(config.sort);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tstoreObjectOrArray.push(...result);\r\n\t\t\t} else {\r\n\t\t\t\tconst storeObject = storeObjectOrArray as Record<\r\n\t\t\t\t\tstring,\r\n\t\t\t\t\tDocument[]\r\n\t\t\t\t>;\r\n\r\n\t\t\t\t/* remove docs if they were removed */\r\n\t\t\t\tfor (const parentId in storeObject) {\r\n\t\t\t\t\tfor (\r\n\t\t\t\t\t\tlet i = storeObject[parentId].length - 1;\r\n\t\t\t\t\t\ti >= 0;\r\n\t\t\t\t\t\ti--\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tconst _field =\r\n\t\t\t\t\t\t\ttypeof config.field === 'function'\r\n\t\t\t\t\t\t\t\t? config.field(storeObject[parentId][i])\r\n\t\t\t\t\t\t\t\t: config.field || 'author';\r\n\t\t\t\t\t\tconst _doc: any = storeObject[parentId][i];\r\n\r\n\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t!this._docs.find((doc: any) =>\r\n\t\t\t\t\t\t\t\tArray.isArray(doc[_field])\r\n\t\t\t\t\t\t\t\t\t? doc[_field].includes(_doc[this._id(doc)])\r\n\t\t\t\t\t\t\t\t\t: doc[_field] === _doc[this._id(doc)],\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\tstoreObject[parentId].splice(i, 1);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t/* add docs if they are not added */\r\n\t\t\t\tfor (const doc of this._docs) {\r\n\t\t\t\t\tif (doc.__deleted) continue;\r\n\r\n\t\t\t\t\tconst _field =\r\n\t\t\t\t\t\ttypeof config.field === 'function'\r\n\t\t\t\t\t\t\t? config.field(doc)\r\n\t\t\t\t\t\t\t: config.field || 'author';\r\n\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\ttypeof config.valid === 'function'\r\n\t\t\t\t\t\t\t? !config.valid(doc)\r\n\t\t\t\t\t\t\t: Array.isArray((doc as any)[_field])\r\n\t\t\t\t\t\t\t\t? !(doc as any)[_field]?.length\r\n\t\t\t\t\t\t\t\t: !(doc as any)[_field]\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (typeof config.field === 'function') {\r\n\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\tconfig.field(doc) &&\r\n\t\t\t\t\t\t\t!storeObject[(doc as any)[_field]].find(\r\n\t\t\t\t\t\t\t\t(c) => c._id === doc._id,\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\tstoreObject[(doc as any)[_field]].push(doc);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else if (Array.isArray((doc as any)[_field])) {\r\n\t\t\t\t\t\t(doc as any)[_field].forEach((_field: string) => {\r\n\t\t\t\t\t\t\tstoreObject[_field] = storeObject[_field] || [];\r\n\r\n\t\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t\t!storeObject[_field].find(\r\n\t\t\t\t\t\t\t\t\t(c) => c._id === doc._id,\r\n\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t\tstoreObject[_field].push(doc);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tstoreObject[(doc as any)[_field]] =\r\n\t\t\t\t\t\t\tstoreObject[(doc as any)[_field]] || [];\r\n\r\n\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t!storeObject[(doc as any)[_field]].find(\r\n\t\t\t\t\t\t\t\t(c) => c._id === doc._id,\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\tstoreObject[(doc as any)[_field]].push(doc);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t/* sort the array's */\r\n\t\t\t\tif (typeof config.sort === 'function') {\r\n\t\t\t\t\tfor (const parentId in storeObject) {\r\n\t\t\t\t\t\tstoreObject[parentId].sort(config.sort);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconfig.filtered?.(storeObjectOrArray);\r\n\t\t};\r\n\r\n\t\tthis._filteredDocumentsCallbacks.push(callback);\r\n\r\n\t\treturn callback;\r\n\t}\r\n\r\n\t/**\r\n\t * Track pending fetch-by-id requests to avoid duplicate calls.\r\n\t */\r\n\tprivate _fetchingId: Record<string, boolean> = {};\r\n\r\n\t/**\r\n\t * Queue of operations that must be retried when network comes back online.\r\n\t */\r\n\tprivate _onOnline: (() => void)[] = [];\r\n\r\n\t/**\r\n\t * Local counter used to build unique local identifiers together with Date.now().\r\n\t */\r\n\tprivate _randomCount = 0;\r\n\r\n\t/**\r\n\t * Generates a unique ID for a document when using local-only identifiers.\r\n\t *\r\n\t * @returns The unique ID as a number.\r\n\t */\r\n\tprivate _localId() {\r\n\t\treturn Number(Date.now() + '' + this._randomCount++);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the configured identity field for the given document as string.\r\n\t *\r\n\t * @param doc - The document for which to generate the ID.\r\n\t * @returns The unique ID as a string.\r\n\t */\r\n\tprivate _id(doc: Document): string {\r\n\t\treturn (doc as unknown as Record<string, unknown>)[\r\n\t\t\tthis._config._id || '_id'\r\n\t\t]?.toString() as string;\r\n\t}\r\n\r\n\t/**\r\n\t * Executes all registered filter document callbacks and emits a\r\n\t * `<name>_filtered` event.\r\n\t */\r\n\tprivate _filterDocuments(): void {\r\n\t\tfor (const callback of this._filteredDocumentsCallbacks) {\r\n\t\t\tcallback();\r\n\t\t}\r\n\r\n\t\tthis.__emitterService.emit(`${this._config.name}_filtered`);\r\n\t}\r\n\r\n\t/**\r\n\t * Marks a document as modified for a given operation id and\r\n\t * keeps the document in the store until the operation is confirmed.\r\n\t */\r\n\tprivate _updateModified(\r\n\t\tdoc: Document,\r\n\t\tid: string,\r\n\t\toptions: CrudOptions<Document>,\r\n\t) {\r\n\t\tdoc.__modified ||= [];\r\n\r\n\t\tdoc.__options ||= {};\r\n\r\n\t\tdoc.__options[id] = options;\r\n\r\n\t\tif (!doc.__modified.find((m) => m === id)) {\r\n\t\t\tdoc.__modified.push(id);\r\n\r\n\t\t\tthis.addDoc(doc);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a modification mark from the document once the\r\n\t * server operation is confirmed.\r\n\t */\r\n\tprivate _removeModified(doc: Document, id: string) {\r\n\t\tdoc.__modified ||= [];\r\n\r\n\t\tif (doc.__modified.find((m) => m === id)) {\r\n\t\t\tdoc.__modified.splice(\r\n\t\t\t\tdoc.__modified.findIndex((m) => m === id),\r\n\t\t\t\t1,\r\n\t\t\t);\r\n\r\n\t\t\tthis.addDoc(doc);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Syncs a single document's signal (if exists) and refreshes all\r\n\t * derived collections (field/value lists and field maps).\r\n\t */\r\n\tprivate _syncSignalForDoc(doc: Document) {\r\n\t\tconst id = this._id(doc);\r\n\r\n\t\tif (id && this._signal[id]) {\r\n\t\t\tthis._signal[id].set(doc);\r\n\t\t}\r\n\r\n\t\tthis._updateSignals();\r\n\t}\r\n\r\n\t/**\r\n\t * Rebuilds all derived signal collections:\r\n\t *  - all per (field,value) lists of document signals\r\n\t *  - all per-field maps value -> [signals]\r\n\t *\r\n\t * This keeps `getSignals()` and `getFieldSignals()` in sync after\r\n\t * any mutation that touches `_docs`.\r\n\t */\r\n\tprivate _updateSignals() {\r\n\t\t// refresh all (field,value) collections\r\n\t\tfor (const key in this._signals) {\r\n\t\t\tthis._signals[key].set(this._getSignals(key));\r\n\t\t}\r\n\r\n\t\t// refresh all per-field maps\r\n\t\tfor (const field in this._fieldSignals) {\r\n\t\t\tthis._fieldSignals[field].set(this._getFieldSignals(field));\r\n\t\t}\r\n\t}\r\n}\r\n","import {\r\n\tApplicationRef,\r\n\tComponentRef,\r\n\tEmbeddedViewRef,\r\n\tEnvironmentInjector,\r\n\tInjectable,\r\n\tType,\r\n\tcreateComponent,\r\n\tinject,\r\n} from '@angular/core';\r\nimport { DomComponent } from '../interfaces/dom.interface';\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\n/**\r\n * Utility service for programmatically creating and interacting with Angular\r\n * components within the DOM.\r\n */\r\nexport class DomService {\r\n\t/**\r\n\t * Appends a component to a specified element by ID.\r\n\t *\r\n\t * @param component - The component to append.\r\n\t * @param options - The options to project into the component.\r\n\t * @param id - The ID of the element to append the component to.\r\n\t * @returns An object containing the native element and the component reference.\r\n\t */\r\n\tappendById<T>(\r\n\t\tcomponent: Type<T>,\r\n\t\toptions: Partial<T> = {},\r\n\t\tid: string,\r\n\t): DomComponent<T> {\r\n\t\tconst componentRef = createComponent(component, {\r\n\t\t\tenvironmentInjector: this._injector,\r\n\t\t});\r\n\r\n\t\tthis.projectComponentInputs(componentRef, options);\r\n\r\n\t\tthis._appRef.attachView(componentRef.hostView);\r\n\r\n\t\tconst domElem = (componentRef.hostView as EmbeddedViewRef<T>)\r\n\t\t\t.rootNodes[0] as HTMLElement;\r\n\r\n\t\tconst element = document.getElementById(id);\r\n\r\n\t\tif (element && typeof element.appendChild === 'function') {\r\n\t\t\telement.appendChild(domElem);\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tnativeElement: domElem,\r\n\t\t\tcomponentRef: componentRef,\r\n\t\t\tremove: () => this.removeComponent(componentRef),\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Appends a component to a specified element or to the body.\r\n\t *\r\n\t * @param component - The component to append.\r\n\t * @param options - The options to project into the component.\r\n\t * @param element - The element to append the component to. Defaults to body.\r\n\t * @returns An object containing the native element and the component reference.\r\n\t */\r\n\tappendComponent<T>(\r\n\t\tcomponent: Type<T>,\r\n\t\toptions: Partial<T & { providedIn?: string }> = {},\r\n\t\telement: HTMLElement = document.body,\r\n\t): DomComponent<T> | void {\r\n\t\tif (options.providedIn) {\r\n\t\t\tif (this._providedIn[options.providedIn]) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tthis._providedIn[options.providedIn] = true;\r\n\t\t}\r\n\r\n\t\tconst componentRef = createComponent(component, {\r\n\t\t\tenvironmentInjector: this._injector,\r\n\t\t});\r\n\r\n\t\tthis.projectComponentInputs(componentRef, options);\r\n\r\n\t\tthis._appRef.attachView(componentRef.hostView);\r\n\r\n\t\tconst domElem = (componentRef.hostView as EmbeddedViewRef<T>)\r\n\t\t\t.rootNodes[0] as HTMLElement;\r\n\r\n\t\tif (element && typeof element.appendChild === 'function') {\r\n\t\t\telement.appendChild(domElem);\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\tnativeElement: domElem,\r\n\t\t\tcomponentRef: componentRef,\r\n\t\t\tremove: () =>\r\n\t\t\t\tthis.removeComponent(componentRef, options.providedIn),\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Gets a reference to a dynamically created component.\r\n\t *\r\n\t * @param component - The component to create.\r\n\t * @param options - The options to project into the component.\r\n\t * @returns The component reference.\r\n\t */\r\n\tgetComponentRef<T>(\r\n\t\tcomponent: Type<T>,\r\n\t\toptions: Partial<T> = {},\r\n\t): ComponentRef<T> {\r\n\t\tconst componentRef = createComponent(component, {\r\n\t\t\tenvironmentInjector: this._injector,\r\n\t\t});\r\n\r\n\t\tthis.projectComponentInputs(componentRef, options);\r\n\r\n\t\tthis._appRef.attachView(componentRef.hostView);\r\n\r\n\t\treturn componentRef;\r\n\t}\r\n\r\n\t/**\r\n\t * Projects the inputs onto the component.\r\n\t *\r\n\t * @param component - The component reference.\r\n\t * @param options - The options to project into the component.\r\n\t * @returns The component reference with the projected inputs.\r\n\t */\r\n\tprivate projectComponentInputs<T>(\r\n\t\tcomponent: ComponentRef<T>,\r\n\t\toptions: Partial<T>,\r\n\t): ComponentRef<T> {\r\n\t\tif (options) {\r\n\t\t\tconst props = Object.getOwnPropertyNames(options);\r\n\r\n\t\t\tfor (const prop of props) {\r\n\t\t\t\t(component.instance as any)[prop] = (options as any)[prop];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn component;\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a previously attached component and optionally clears its\r\n\t * unique `providedIn` flag.\r\n\t *\r\n\t * @param componentRef - Reference to the component to be removed.\r\n\t * @param providedIn - Optional key used to track unique instances.\r\n\t */\r\n\tremoveComponent<T>(\r\n\t\tcomponentRef: ComponentRef<T>,\r\n\t\tprovidedIn?: string,\r\n\t): void {\r\n\t\tthis._appRef.detachView(componentRef.hostView);\r\n\r\n\t\tcomponentRef.destroy();\r\n\r\n\t\tif (providedIn) {\r\n\t\t\tdelete this._providedIn[providedIn];\r\n\t\t}\r\n\t}\r\n\r\n\t/** Reference to the root application used for view attachment. */\r\n\tprivate _appRef = inject(ApplicationRef);\r\n\r\n\t/** Injector utilized when creating dynamic components. */\r\n\tprivate _injector = inject(EnvironmentInjector);\r\n\r\n\t/**\r\n\t * Flags to ensure components with a specific `providedIn` key are only\r\n\t * instantiated once at a time.\r\n\t */\r\n\tprivate _providedIn: Record<string, boolean> = {};\r\n}\r\n","import { Injectable } from '@angular/core';\r\n\r\n/**\r\n * RtcService handles WebRTC peer connections and local media stream setup.\r\n * It provides functionality to initialize the user's camera/microphone,\r\n * manage multiple peer connections, and handle offer/answer negotiation.\r\n */\r\n@Injectable({ providedIn: 'root' })\r\nexport class RtcService {\r\n\t/**\r\n\t * Map of peer connections, keyed by peer ID.\r\n\t */\r\n\tprivate peers = new Map<string, RTCPeerConnection>();\r\n\r\n\t/**\r\n\t * Local media stream from user's camera and microphone.\r\n\t */\r\n\tprivate localStream: MediaStream | null = null;\r\n\r\n\t/**\r\n\t * Initializes the local media stream (audio/video).\r\n\t * Requests permissions and stores the stream internally.\r\n\t */\r\n\tasync initLocalStream(): Promise<MediaStream> {\r\n\t\tif (!this.localStream) {\r\n\t\t\tthis.localStream = await navigator.mediaDevices.getUserMedia({\r\n\t\t\t\tvideo: true,\r\n\t\t\t\taudio: true,\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn this.localStream;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a new RTCPeerConnection for the given ID and attaches local tracks.\r\n\t */\r\n\tasync createPeer(id: string): Promise<RTCPeerConnection> {\r\n\t\tconst peer = new RTCPeerConnection();\r\n\r\n\t\tthis.localStream\r\n\t\t\t?.getTracks()\r\n\t\t\t.forEach((track) => peer.addTrack(track, this.localStream!));\r\n\r\n\t\tthis.peers.set(id, peer);\r\n\r\n\t\treturn peer;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves an existing peer connection by ID.\r\n\t */\r\n\tgetPeer(id: string): RTCPeerConnection | undefined {\r\n\t\treturn this.peers.get(id);\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an SDP offer for the specified peer and sets it as the local description.\r\n\t */\r\n\tasync createOffer(id: string): Promise<RTCSessionDescriptionInit> {\r\n\t\tconst peer = this.peers.get(id);\r\n\r\n\t\tif (!peer) throw new Error('Peer not found');\r\n\r\n\t\tconst offer = await peer.createOffer();\r\n\r\n\t\tawait peer.setLocalDescription(offer);\r\n\r\n\t\treturn offer;\r\n\t}\r\n\r\n\t/**\r\n\t * Accepts an SDP offer, creates an answer, and sets it as the local description.\r\n\t */\r\n\tasync createAnswer(\r\n\t\tid: string,\r\n\t\toffer: RTCSessionDescriptionInit,\r\n\t): Promise<RTCSessionDescriptionInit> {\r\n\t\tconst peer = this.peers.get(id);\r\n\r\n\t\tif (!peer) throw new Error('Peer not found');\r\n\r\n\t\tawait peer.setRemoteDescription(new RTCSessionDescription(offer));\r\n\r\n\t\tconst answer = await peer.createAnswer();\r\n\r\n\t\tawait peer.setLocalDescription(answer);\r\n\r\n\t\treturn answer;\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the remote description with an SDP answer for the given peer.\r\n\t */\r\n\tasync setRemoteAnswer(id: string, answer: RTCSessionDescriptionInit) {\r\n\t\tconst peer = this.peers.get(id);\r\n\r\n\t\tif (!peer) throw new Error('Peer not found');\r\n\r\n\t\tawait peer.setRemoteDescription(new RTCSessionDescription(answer));\r\n\t}\r\n\r\n\t/**\r\n\t * Adds an ICE candidate to the specified peer connection.\r\n\t */\r\n\taddIceCandidate(id: string, candidate: RTCIceCandidateInit) {\r\n\t\tconst peer = this.peers.get(id);\r\n\r\n\t\tif (peer) peer.addIceCandidate(new RTCIceCandidate(candidate));\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the initialized local media stream.\r\n\t */\r\n\tgetLocalStream(): MediaStream | null {\r\n\t\treturn this.localStream;\r\n\t}\r\n\r\n\t/**\r\n\t * Closes a specific peer connection and removes it from the map.\r\n\t */\r\n\tclosePeer(id: string) {\r\n\t\tconst peer = this.peers.get(id);\r\n\r\n\t\tif (peer) {\r\n\t\t\tpeer.close();\r\n\r\n\t\t\tthis.peers.delete(id);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Closes all peer connections and stops the local media stream.\r\n\t */\r\n\tcloseAll() {\r\n\t\tthis.peers.forEach((peer) => peer.close());\r\n\r\n\t\tthis.peers.clear();\r\n\r\n\t\tthis.localStream?.getTracks().forEach((track) => track.stop());\r\n\r\n\t\tthis.localStream = null;\r\n\t}\r\n}\r\n","import { inject, Inject, Injectable, Optional } from '@angular/core';\r\nimport {\r\n\tConfig,\r\n\tCONFIG_TOKEN,\r\n\tDEFAULT_CONFIG,\r\n} from '../interfaces/config.interface';\r\nimport { EmitterService } from './emitter.service';\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\nexport class SocketService {\r\n\tprivate _url = '';\r\n\r\n\tprivate _io: any;\r\n\r\n\tprivate _connected = false;\r\n\r\n\tprivate _opts: any = {};\r\n\r\n\tconstructor(@Inject(CONFIG_TOKEN) @Optional() private _config: Config) {\r\n\t\tthis._config = { ...DEFAULT_CONFIG, ...(this._config || {}) };\r\n\r\n\t\tif (!this._config.io) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tconst url = new URL(window.location.origin);\r\n\r\n\t\tif (typeof this._config.socket === 'object') {\r\n\t\t\tif (this._config.socket.port) {\r\n\t\t\t\turl.port = this._config.socket.port;\r\n\t\t\t}\r\n\r\n\t\t\tif (this._config.socket.opts) {\r\n\t\t\t\tthis._opts = this._config.socket.opts;\r\n\t\t\t}\r\n\r\n\t\t\tthis._url = this._config.socket.url ?? url.origin;\r\n\t\t} else {\r\n\t\t\tthis._url = url.origin;\r\n\t\t}\r\n\r\n\t\tif (this._config.socket) {\r\n\t\t\tthis.load();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the URL for the WebSocket connection and reloads the socket.\r\n\t * @param url - The URL of the WebSocket server.\r\n\t */\r\n\tsetUrl(url: string): void {\r\n\t\tthis._url = url;\r\n\r\n\t\tif (!this._config.socket) {\r\n\t\t\tthis._config.socket = true;\r\n\t\t}\r\n\r\n\t\tthis.load();\r\n\t}\r\n\r\n\t/**\r\n\t * Loads and initializes the WebSocket connection.\r\n\t */\r\n\tprivate load(): void {\r\n\t\tif (this._config.io) {\r\n\t\t\tconst ioFunc = this._config.io.default\r\n\t\t\t\t? this._config.io.default\r\n\t\t\t\t: this._config.io;\r\n\r\n\t\t\tthis._io = ioFunc(this._url, this._opts);\r\n\r\n\t\t\tthis._io.on('connect', () => {\r\n\t\t\t\tthis._connected = true;\r\n\r\n\t\t\t\tthis._emitterService.complete('socket');\r\n\t\t\t});\r\n\r\n\t\t\tthis._io.on('disconnect', (reason: any) => {\r\n\t\t\t\tthis._connected = false;\r\n\r\n\t\t\t\tthis._emitterService.emit('socket_disconnect', reason);\r\n\r\n\t\t\t\tconsole.warn('Socket disconnected', reason);\r\n\t\t\t});\r\n\r\n\t\t\tthis._io.on('error', (err: any) => {\r\n\t\t\t\tthis._connected = false;\r\n\r\n\t\t\t\tthis._emitterService.emit('socket_error', err);\r\n\r\n\t\t\t\tconsole.warn('Socket error', err);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Disconnects the WebSocket connection and resets the connection state.\r\n\t */\r\n\tdisconnect(): void {\r\n\t\tif (this._io) {\r\n\t\t\tthis._io.disconnect();\r\n\t\t}\r\n\r\n\t\tthis._connected = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Subscribes to a WebSocket event.\r\n\t * @param to - The event to subscribe to.\r\n\t * @param cb - The callback function to execute when the event is received.\r\n\t */\r\n\ton(to: string, cb: (message: any) => void = () => {}): void {\r\n\t\tif (!this._config.socket) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!this._io) {\r\n\t\t\tconsole.warn('Socket client not loaded.');\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!this._connected) {\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tthis.on(to, cb);\r\n\t\t\t}, 100);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._io.on(to, cb);\r\n\t}\r\n\r\n\t/**\r\n\t * Emits a message to a WebSocket event.\r\n\t * @param to - The event to emit the message to.\r\n\t * @param message - The message to emit.\r\n\t * @param room - Optional room to emit the message to.\r\n\t */\r\n\temit(to: string, message: any, room: any = false): void {\r\n\t\tif (!this._config.socket) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!this._io) {\r\n\t\t\tconsole.warn('Socket client not loaded.');\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (!this._connected) {\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tthis.emit(to, message, room);\r\n\t\t\t}, 100);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._io.emit(to, message, room);\r\n\t}\r\n\r\n\tprivate _emitterService = inject(EmitterService);\r\n}\r\n","import { DatePipe } from '@angular/common';\r\nimport { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n\tprovidedIn: 'root',\r\n})\r\nexport class TimeService {\r\n\tprivate weekDays = [\r\n\t\t'Sunday',\r\n\t\t'Monday',\r\n\t\t'Tuesday',\r\n\t\t'Wednesday',\r\n\t\t'Thursday',\r\n\t\t'Friday',\r\n\t\t'Saturday',\r\n\t];\r\n\r\n\tprivate monthNames = [\r\n\t\t'January',\r\n\t\t'February',\r\n\t\t'March',\r\n\t\t'April',\r\n\t\t'May',\r\n\t\t'June',\r\n\t\t'July',\r\n\t\t'August',\r\n\t\t'September',\r\n\t\t'October',\r\n\t\t'November',\r\n\t\t'December',\r\n\t];\r\n\r\n\tconstructor(private datePipe: DatePipe) {}\r\n\r\n\t/**\r\n\t * Returns the name of the day of the week for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the day of the week.\r\n\t * @param format - The format in which to return the day name. Default is 'long'.\r\n\t * @returns The name of the day of the week.\r\n\t */\r\n\tgetDayName(date: Date, format: 'short' | 'long' = 'long'): string {\r\n\t\tconst dayIndex = date.getDay();\r\n\t\treturn format === 'short'\r\n\t\t\t? this.weekDays[dayIndex].substring(0, 3)\r\n\t\t\t: this.weekDays[dayIndex];\r\n\t}\r\n\t/**\r\n\t * Returns the name of the month for a given index.\r\n\t *\r\n\t * @param monthIndex - The month index (0-11).\r\n\t * @param format - The format in which to return the month name. Default is 'long'.\r\n\t * @returns The name of the month.\r\n\t */\r\n\tgetMonthName(\r\n\t\tmonthIndex: number,\r\n\t\tformat: 'short' | 'long' = 'long',\r\n\t): string {\r\n\t\tif (\r\n\t\t\t!Number.isInteger(monthIndex) ||\r\n\t\t\tmonthIndex < 0 ||\r\n\t\t\tmonthIndex > 11\r\n\t\t) {\r\n\t\t\tthrow new RangeError(\r\n\t\t\t\t'monthIndex must be an integer between 0 and 11',\r\n\t\t\t);\r\n\t\t}\r\n\t\treturn format === 'short'\r\n\t\t\t? this.monthNames[monthIndex].substring(0, 3)\r\n\t\t\t: this.monthNames[monthIndex];\r\n\t}\r\n\r\n\t/**\r\n\t * Formats a date according to the specified format and timezone.\r\n\t *\r\n\t * @param date - The date to format.\r\n\t * @param format - The format string (see Angular DatePipe documentation for format options).\r\n\t * @param timezone - The timezone to use for formatting.\r\n\t * @returns The formatted date string.\r\n\t */\r\n\tformatDate(\r\n\t\tdate: Date,\r\n\t\tformat: string = 'mediumDate',\r\n\t\ttimezone: string = 'UTC',\r\n\t): string {\r\n\t\treturn this.datePipe.transform(date, format, timezone) || '';\r\n\t}\r\n\r\n\t/**\r\n\t * Converts a date to a different timezone.\r\n\t *\r\n\t * @param date - The date to convert.\r\n\t * @param timezone - The timezone to convert to.\r\n\t * @returns The date in the new timezone.\r\n\t */\r\n\tconvertToTimezone(date: Date, timezone: string): Date {\r\n\t\treturn new Date(date.toLocaleString('en-US', { timeZone: timezone }));\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the start of the day for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the start of the day.\r\n\t * @returns The start of the day (midnight) for the given date.\r\n\t */\r\n\tstartOfDay(date: Date): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setHours(0, 0, 0, 0);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the end of the day for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the end of the day.\r\n\t * @returns The end of the day (one millisecond before midnight) for the given date.\r\n\t */\r\n\tendOfDay(date: Date): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setHours(23, 59, 59, 999);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the start of the week for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the start of the week.\r\n\t * @param locale - A BCP 47 language tag to determine the first day of the week. Defaults to the runtime locale.\r\n\t * @returns The start of the week adjusted for the locale.\r\n\t *\r\n\t * @example\r\n\t * const date = new Date('2024-05-15');\r\n\t * service.startOfWeek(date); // => Monday May 13 2024 00:00:00 for en-GB\r\n\t */\r\n\tstartOfWeek(date: Date, locale?: string): Date {\r\n\t\tconst newDate = this.startOfDay(date);\r\n\t\tconst dtf = new Intl.DateTimeFormat(locale);\r\n\t\tconst resolved = dtf.resolvedOptions().locale;\r\n\t\tconst region = resolved.split('-')[1]?.toUpperCase();\r\n\t\tconst sundayFirst = ['US', 'CA', 'AU', 'NZ', 'PH', 'BR'];\r\n\t\tconst firstDay = sundayFirst.includes(region) ? 0 : 1;\r\n\t\tconst day = newDate.getDay();\r\n\t\tconst diff = (day - firstDay + 7) % 7;\r\n\t\tnewDate.setDate(newDate.getDate() - diff);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the end of the week for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the end of the week.\r\n\t * @param locale - A BCP 47 language tag to determine the first day of the week. Defaults to the runtime locale.\r\n\t * @returns The end of the week adjusted for the locale.\r\n\t *\r\n\t * @example\r\n\t * const date = new Date('2024-05-15');\r\n\t * service.endOfWeek(date); // => Sunday May 19 2024 23:59:59.999 for en-GB\r\n\t */\r\n\tendOfWeek(date: Date, locale?: string): Date {\r\n\t\tconst start = this.startOfWeek(date, locale);\r\n\t\tconst end = this.addDays(start, 6);\r\n\t\treturn this.endOfDay(end);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the start of the month for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the start of the month.\r\n\t * @returns The start of the month.\r\n\t *\r\n\t * @example\r\n\t * const date = new Date('2024-05-15');\r\n\t * service.startOfMonth(date); // => May 1 2024 00:00:00\r\n\t */\r\n\tstartOfMonth(date: Date): Date {\r\n\t\tconst newDate = this.startOfDay(date);\r\n\t\tnewDate.setDate(1);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the end of the month for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the end of the month.\r\n\t * @returns The end of the month.\r\n\t *\r\n\t * @example\r\n\t * const date = new Date('2024-05-15');\r\n\t * service.endOfMonth(date); // => May 31 2024 23:59:59.999\r\n\t */\r\n\tendOfMonth(date: Date): Date {\r\n\t\tconst start = this.startOfMonth(date);\r\n\t\tconst end = new Date(start);\r\n\t\tend.setMonth(end.getMonth() + 1);\r\n\t\tend.setDate(0);\r\n\t\treturn this.endOfDay(end);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the start of the year for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the start of the year.\r\n\t * @returns The start of the year.\r\n\t *\r\n\t * @example\r\n\t * const date = new Date('2024-05-15');\r\n\t * service.startOfYear(date); // => Jan 1 2024 00:00:00\r\n\t */\r\n\tstartOfYear(date: Date): Date {\r\n\t\tconst newDate = this.startOfDay(date);\r\n\t\tnewDate.setMonth(0, 1);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the end of the year for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the end of the year.\r\n\t * @returns The end of the year.\r\n\t *\r\n\t * @example\r\n\t * const date = new Date('2024-05-15');\r\n\t * service.endOfYear(date); // => Dec 31 2024 23:59:59.999\r\n\t */\r\n\tendOfYear(date: Date): Date {\r\n\t\tconst end = new Date(date.getFullYear(), 11, 31);\r\n\t\treturn this.endOfDay(end);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the number of days in a given month and year.\r\n\t *\r\n\t * @param month - The month (0-11).\r\n\t * @param year - The year.\r\n\t * @returns The number of days in the month.\r\n\t */\r\n\tgetDaysInMonth(month: number, year: number): number {\r\n\t\treturn new Date(year, month + 1, 0).getDate();\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if a given year is a leap year.\r\n\t *\r\n\t * @param year - The year to check.\r\n\t * @returns True if the year is a leap year, false otherwise.\r\n\t */\r\n\tisLeapYear(year: number): boolean {\r\n\t\treturn (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a specified number of days to a date.\r\n\t *\r\n\t * @param date - The date to which to add days.\r\n\t * @param days - The number of days to add.\r\n\t * @returns The new date with the added days.\r\n\t */\r\n\taddDays(date: Date, days: number): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setDate(newDate.getDate() + days);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a specified number of months to a date.\r\n\t *\r\n\t * @param date - The date to which to add months.\r\n\t * @param months - The number of months to add.\r\n\t * @returns The new date with the added months.\r\n\t */\r\n\taddMonths(date: Date, months: number): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setMonth(newDate.getMonth() + months);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a specified number of years to a date.\r\n\t *\r\n\t * @param date - The date to which to add years.\r\n\t * @param years - The number of years to add.\r\n\t * @returns The new date with the added years.\r\n\t */\r\n\taddYears(date: Date, years: number): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setFullYear(newDate.getFullYear() + years);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a specified number of hours to a date.\r\n\t *\r\n\t * @param date - The date to which to add hours.\r\n\t * @param hours - The number of hours to add.\r\n\t * @returns The new date with the added hours.\r\n\t */\r\n\taddHours(date: Date, hours: number): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setHours(newDate.getHours() + hours);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a specified number of minutes to a date.\r\n\t *\r\n\t * @param date - The date to which to add minutes.\r\n\t * @param minutes - The number of minutes to add.\r\n\t * @returns The new date with the added minutes.\r\n\t */\r\n\taddMinutes(date: Date, minutes: number): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setMinutes(newDate.getMinutes() + minutes);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a specified number of seconds to a date.\r\n\t *\r\n\t * @param date - The date to which to add seconds.\r\n\t * @param seconds - The number of seconds to add.\r\n\t * @returns The new date with the added seconds.\r\n\t */\r\n\taddSeconds(date: Date, seconds: number): Date {\r\n\t\tconst newDate = new Date(date);\r\n\t\tnewDate.setSeconds(newDate.getSeconds() + seconds);\r\n\t\treturn newDate;\r\n\t}\r\n\r\n\t/**\r\n\t * Subtracts a specified number of days from a date.\r\n\t *\r\n\t * @param date - The date from which to subtract days.\r\n\t * @param days - The number of days to subtract.\r\n\t * @returns The new date with the subtracted days.\r\n\t */\r\n\tsubtractDays(date: Date, days: number): Date {\r\n\t\treturn this.addDays(date, -days);\r\n\t}\r\n\r\n\t/**\r\n\t * Subtracts a specified number of months from a date.\r\n\t *\r\n\t * @param date - The date from which to subtract months.\r\n\t * @param months - The number of months to subtract.\r\n\t * @returns The new date with the subtracted months.\r\n\t */\r\n\tsubtractMonths(date: Date, months: number): Date {\r\n\t\treturn this.addMonths(date, -months);\r\n\t}\r\n\r\n\t/**\r\n\t * Subtracts a specified number of years from a date.\r\n\t *\r\n\t * @param date - The date from which to subtract years.\r\n\t * @param years - The number of years to subtract.\r\n\t * @returns The new date with the subtracted years.\r\n\t */\r\n\tsubtractYears(date: Date, years: number): Date {\r\n\t\treturn this.addYears(date, -years);\r\n\t}\r\n\r\n\t/**\r\n\t * Subtracts a specified number of hours from a date.\r\n\t *\r\n\t * @param date - The date from which to subtract hours.\r\n\t * @param hours - The number of hours to subtract.\r\n\t * @returns The new date with the subtracted hours.\r\n\t */\r\n\tsubtractHours(date: Date, hours: number): Date {\r\n\t\treturn this.addHours(date, -hours);\r\n\t}\r\n\r\n\t/**\r\n\t * Subtracts a specified number of minutes from a date.\r\n\t *\r\n\t * @param date - The date from which to subtract minutes.\r\n\t * @param minutes - The number of minutes to subtract.\r\n\t * @returns The new date with the subtracted minutes.\r\n\t */\r\n\tsubtractMinutes(date: Date, minutes: number): Date {\r\n\t\treturn this.addMinutes(date, -minutes);\r\n\t}\r\n\r\n\t/**\r\n\t * Subtracts a specified number of seconds from a date.\r\n\t *\r\n\t * @param date - The date from which to subtract seconds.\r\n\t * @param seconds - The number of seconds to subtract.\r\n\t * @returns The new date with the subtracted seconds.\r\n\t */\r\n\tsubtractSeconds(date: Date, seconds: number): Date {\r\n\t\treturn this.addSeconds(date, -seconds);\r\n\t}\r\n\r\n\t/**\r\n\t * Calculates the difference in days between two dates.\r\n\t *\r\n\t * @param date1 - The earlier date.\r\n\t * @param date2 - The later date.\r\n\t * @returns The number of days between the two dates.\r\n\t */\r\n\tdifferenceInDays(date1: Date, date2: Date): number {\r\n\t\tconst diff = date2.getTime() - date1.getTime();\r\n\t\treturn diff / (1000 * 60 * 60 * 24);\r\n\t}\r\n\r\n\t/**\r\n\t * Calculates the difference in hours between two dates.\r\n\t *\r\n\t * @param date1 - The earlier date.\r\n\t * @param date2 - The later date.\r\n\t * @returns The number of hours between the two dates.\r\n\t */\r\n\tdifferenceInHours(date1: Date, date2: Date): number {\r\n\t\tconst diff = date2.getTime() - date1.getTime();\r\n\t\treturn diff / (1000 * 60 * 60);\r\n\t}\r\n\r\n\t/**\r\n\t * Calculates the difference in minutes between two dates.\r\n\t *\r\n\t * @param date1 - The earlier date.\r\n\t * @param date2 - The later date.\r\n\t * @returns The number of minutes between the two dates.\r\n\t */\r\n\tdifferenceInMinutes(date1: Date, date2: Date): number {\r\n\t\tconst diff = date2.getTime() - date1.getTime();\r\n\t\treturn diff / (1000 * 60);\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if two dates are on the same day.\r\n\t *\r\n\t * @param date1 - The first date.\r\n\t * @param date2 - The second date.\r\n\t * @returns True if the dates are on the same day, false otherwise.\r\n\t */\r\n\tisSameDay(date1: Date, date2: Date): boolean {\r\n\t\treturn (\r\n\t\t\tdate1.getFullYear() === date2.getFullYear() &&\r\n\t\t\tdate1.getMonth() === date2.getMonth() &&\r\n\t\t\tdate1.getDate() === date2.getDate()\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the ISO week number for a given date.\r\n\t *\r\n\t * @param date - The date for which to get the week number.\r\n\t * @returns The ISO week number (1-53).\r\n\t */\r\n\tgetWeekNumber(date: Date): number {\r\n\t\tconst tempDate = new Date(date.getTime());\r\n\t\ttempDate.setHours(0, 0, 0, 0);\r\n\t\t// Set to nearest Thursday: current date + 4 - current day number, making Thursday day 4\r\n\t\ttempDate.setDate(tempDate.getDate() + 4 - (tempDate.getDay() || 7));\r\n\t\tconst yearStart = new Date(tempDate.getFullYear(), 0, 1);\r\n\t\t// Calculate full weeks to nearest Thursday\r\n\t\treturn Math.ceil(\r\n\t\t\t((tempDate.getTime() - yearStart.getTime()) / 86400000 + 1) / 7,\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the number of weeks in a month for a given month and year.\r\n\t *\r\n\t * @param month - The month (0-11).\r\n\t * @param year - The year.\r\n\t * @returns The number of weeks in the month.\r\n\t */\r\n\tgetWeeksInMonth(month: number, year: number): number {\r\n\t\tconst firstDayOfMonth = new Date(year, month, 1);\r\n\t\tconst lastDayOfMonth = new Date(year, month + 1, 0);\r\n\t\t// Get ISO week numbers for the first and last day of the month\r\n\t\tconst firstWeek = this.getWeekNumber(firstDayOfMonth);\r\n\t\tlet lastWeek = this.getWeekNumber(lastDayOfMonth);\r\n\t\t// Special case: when January 1st is in the last week of the previous year\r\n\t\tif (firstWeek > lastWeek) {\r\n\t\t\tlastWeek = this.getWeekNumber(new Date(year, 11, 31)); // Get week of the last day of the year\r\n\t\t}\r\n\t\treturn lastWeek - firstWeek + 1;\r\n\t}\r\n}\r\n","import { Injectable, WritableSignal, signal } from '@angular/core';\r\n\r\ntype Dict<T = unknown> = Record<string, T>;\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class UtilService {\r\n\t// --- CSS variables (persisted) ---\r\n\tprivate readonly _storageKey = 'css_variables';\r\n\tprivate _css: Dict<string> = {};\r\n\tprivate _cssSig = signal<Dict<string>>({});\r\n\r\n\t// --- Forms store ---\r\n\tprivate _forms = new Map<string, WritableSignal<any>>();\r\n\r\n\t// --- Global bag for design/debug ---\r\n\tvar: Dict = {};\r\n\r\n\t/**\r\n\t * Initialize service state: load persisted CSS variables from localStorage\r\n\t * and apply them to the document root. Emits the initial CSS snapshot.\r\n\t */\r\n\tconstructor() {\r\n\t\tthis._loadCss();\r\n\t\t// apply on boot\r\n\t\tfor (const k of Object.keys(this._css))\r\n\t\t\tthis._setProperty(k, this._css[k]);\r\n\t\tthis._cssSig.set({ ...this._css });\r\n\t}\r\n\r\n\t// ===== Forms Management =====\r\n\r\n\t/** Get or create a form state as a writable signal */\r\n\tformSignal<T = any>(id: string): WritableSignal<T> {\r\n\t\tlet s = this._forms.get(id);\r\n\t\tif (!s) {\r\n\t\t\ts = signal<T>({} as T);\r\n\t\t\tthis._forms.set(id, s);\r\n\t\t}\r\n\t\treturn s as WritableSignal<T>;\r\n\t}\r\n\r\n\t/** Back-compat: returns the current form object (mutable reference). Prefer formSignal(). */\r\n\tform<T = any>(id: string): T {\r\n\t\tconst s = this.formSignal<T>(id);\r\n\t\tconst v = s();\r\n\t\tif (v && typeof v === 'object') return v;\r\n\t\tconst obj = {} as T;\r\n\t\ts.set(obj);\r\n\t\treturn obj;\r\n\t}\r\n\r\n\t/**\r\n\t * Check whether a form signal has been created for the given id.\r\n\t * @param id Unique form identifier.\r\n\t * @returns True if a signal exists for the id.\r\n\t */\r\n\thasForm(id: string): boolean {\r\n\t\treturn this._forms.has(id);\r\n\t}\r\n\r\n\t/**\r\n\t * Remove form state associated with the given id.\r\n\t * @param id Unique form identifier to clear.\r\n\t */\r\n\tclearForm(id: string): void {\r\n\t\tthis._forms.delete(id);\r\n\t}\r\n\r\n\t// ===== Validation =====\r\n\r\n\t/**\r\n\t * Validate a value against a specific kind.\r\n\t * - email: RFC-light pattern check.\r\n\t * - text: typeof string.\r\n\t * - array: Array.isArray.\r\n\t * - object: non-null plain object.\r\n\t * - number: finite number.\r\n\t * - password: strength tiers (extra 0..4).\r\n\t * @param value Input to validate.\r\n\t * @param kind Validation kind.\r\n\t * @param extra Additional constraint for passwords: 0..4 increasing strength.\r\n\t * @returns True if value passes validation.\r\n\t */\r\n\tvalid(\r\n\t\tvalue: any,\r\n\t\tkind:\r\n\t\t\t| 'email'\r\n\t\t\t| 'text'\r\n\t\t\t| 'array'\r\n\t\t\t| 'object'\r\n\t\t\t| 'number'\r\n\t\t\t| 'password' = 'email',\r\n\t\textra = 0,\r\n\t): boolean {\r\n\t\tswitch (kind) {\r\n\t\t\tcase 'email':\r\n\t\t\t\treturn /^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,10})+$/.test(\r\n\t\t\t\t\tvalue || '',\r\n\t\t\t\t);\r\n\t\t\tcase 'text':\r\n\t\t\t\treturn typeof value === 'string';\r\n\t\t\tcase 'array':\r\n\t\t\t\treturn Array.isArray(value);\r\n\t\t\tcase 'object':\r\n\t\t\t\treturn (\r\n\t\t\t\t\ttypeof value === 'object' &&\r\n\t\t\t\t\t!Array.isArray(value) &&\r\n\t\t\t\t\tvalue !== null\r\n\t\t\t\t);\r\n\t\t\tcase 'number':\r\n\t\t\t\treturn typeof value === 'number' && Number.isFinite(value);\r\n\t\t\tcase 'password':\r\n\t\t\t\tif (!value) return false;\r\n\t\t\t\tswitch (extra) {\r\n\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\treturn /^((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9]))/.test(\r\n\t\t\t\t\t\t\tvalue,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\tcase 2:\r\n\t\t\t\t\t\treturn /^(((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{8,})/.test(\r\n\t\t\t\t\t\t\tvalue,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\tcase 3:\r\n\t\t\t\t\t\treturn /^((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]))(?=.{8,})/.test(\r\n\t\t\t\t\t\t\tvalue,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\tcase 4:\r\n\t\t\t\t\t\treturn /^((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@#$%&!\\-_]))(?=.{8,})/.test(\r\n\t\t\t\t\t\t\tvalue,\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\treturn !!value;\r\n\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/** Password strength: 0..5 */\r\n\tlevel(value = ''): number {\r\n\t\tif (!value) return 0;\r\n\t\tlet lvl = 0;\r\n\t\tif (value.length > 8) lvl++;\r\n\t\tif (/[a-z]/.test(value)) lvl++;\r\n\t\tif (/[A-Z]/.test(value)) lvl++;\r\n\t\tif (/[0-9]/.test(value)) lvl++;\r\n\t\tif (/[`~!@#$%^&*()_\\-+=\\[\\]{};:'\",.<>/?\\\\|]/.test(value)) lvl++;\r\n\t\treturn lvl;\r\n\t}\r\n\r\n\t// ===== CSS Variables Management =====\r\n\r\n\t/** Set multiple CSS vars. opts: { local?: boolean; host?: string } */\r\n\tsetCss(\r\n\t\tvars: Dict<string>,\r\n\t\topts: { local?: boolean; host?: string } | string = {},\r\n\t): void {\r\n\t\tif (typeof opts === 'string') {\r\n\t\t\topts = opts === 'local' ? { local: true } : { host: opts };\r\n\t\t}\r\n\t\tconst { local = false, host } = opts as {\r\n\t\t\tlocal?: boolean;\r\n\t\t\thost?: string;\r\n\t\t};\r\n\t\tif (\r\n\t\t\thost &&\r\n\t\t\ttypeof window !== 'undefined' &&\r\n\t\t\twindow.location.host !== host\r\n\t\t)\r\n\t\t\treturn;\r\n\r\n\t\tfor (const k of Object.keys(vars)) {\r\n\t\t\tconst v = vars[k];\r\n\t\t\tif (local) {\r\n\t\t\t\tthis._css[k] = v;\r\n\t\t\t} else if (this._css[k]) {\r\n\t\t\t\t// keep persisted value unless explicitly local\r\n\t\t\t\tthis._setProperty(k, this._css[k]);\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tthis._setProperty(k, v);\r\n\t\t}\r\n\r\n\t\tif (local) {\r\n\t\t\tthis._saveCss();\r\n\t\t\tthis._cssSig.set({ ...this._css });\r\n\t\t}\r\n\t}\r\n\r\n\t/** Current persisted CSS vars snapshot */\r\n\tgetCss(): Dict<string> {\r\n\t\treturn { ...this._css };\r\n\t}\r\n\r\n\t/** Reactive signal with current persisted CSS vars */\r\n\tcssSignal(): WritableSignal<Dict<string>> {\r\n\t\treturn this._cssSig;\r\n\t}\r\n\r\n\t/** Remove persisted vars by key(s) and save */\r\n\tremoveCss(keys: string | string[]): void {\r\n\t\tconst list = Array.isArray(keys) ? keys : keys.split(' ');\r\n\t\tfor (const k of list) delete this._css[k];\r\n\t\tthis._saveCss();\r\n\t\tthis._cssSig.set({ ...this._css });\r\n\t}\r\n\r\n\t// ===== Generators =====\r\n\r\n\t/**\r\n\t * Generate an array of given length filled with sequential numbers (1..n),\r\n\t * random text, dates from today, or a constant value.\r\n\t * @param len Desired array length.\r\n\t * @param type 'number' | 'text' | 'date' | any other constant value to repeat.\r\n\t * @returns Generated array.\r\n\t */\r\n\tarr(len = 10, type: 'number' | 'text' | 'date' | string = 'number'): any[] {\r\n\t\tconst out: any[] = [];\r\n\t\tfor (let i = 0; i < len; i++) {\r\n\t\t\tswitch (type) {\r\n\t\t\t\tcase 'number':\r\n\t\t\t\t\tout.push(i + 1);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'text':\r\n\t\t\t\t\tout.push(this.text());\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'date':\r\n\t\t\t\t\tout.push(new Date(Date.now() + i * 86_400_000));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tout.push(type);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn out;\r\n\t}\r\n\r\n\t/**\r\n\t * Create a random alphanumeric string.\r\n\t * @param length Number of characters to generate.\r\n\t * @returns Random string of requested length.\r\n\t */\r\n\ttext(length = 10): string {\r\n\t\tconst chars =\r\n\t\t\t'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\r\n\t\tlet res = '';\r\n\t\tfor (let i = 0; i < length; i++)\r\n\t\t\tres += chars.charAt(Math.floor(Math.random() * chars.length));\r\n\t\treturn res;\r\n\t}\r\n\r\n\t// ===== Internals =====\r\n\r\n\t/** Persist current CSS variables to localStorage. */\r\n\tprivate _saveCss(): void {\r\n\t\ttry {\r\n\t\t\tif (typeof localStorage !== 'undefined') {\r\n\t\t\t\tlocalStorage.setItem(\r\n\t\t\t\t\tthis._storageKey,\r\n\t\t\t\t\tJSON.stringify(this._css),\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t} catch {}\r\n\t}\r\n\r\n\t/** Load CSS variables snapshot from localStorage into memory. */\r\n\tprivate _loadCss(): void {\r\n\t\ttry {\r\n\t\t\tif (typeof localStorage !== 'undefined') {\r\n\t\t\t\tconst raw = localStorage.getItem(this._storageKey);\r\n\t\t\t\tthis._css = raw ? JSON.parse(raw) : {};\r\n\t\t\t}\r\n\t\t} catch {\r\n\t\t\tthis._css = {};\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Apply a CSS variable to the :root element.\r\n\t * @param key CSS custom property name (e.g., --brand-color).\r\n\t * @param value CSS value to set.\r\n\t */\r\n\tprivate _setProperty(key: string, value: string): void {\r\n\t\ttry {\r\n\t\t\tif (typeof document !== 'undefined') {\r\n\t\t\t\tdocument.documentElement.style.setProperty(key, value);\r\n\t\t\t}\r\n\t\t} catch {}\r\n\t}\r\n}\r\n","import {\r\n\tprovideHttpClient,\r\n\twithInterceptorsFromDi,\r\n} from '@angular/common/http';\r\nimport { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\r\nimport {\r\n\tCONFIG_TOKEN,\r\n\tConfig,\r\n\tDEFAULT_CONFIG,\r\n} from './interfaces/config.interface';\r\n\r\nexport function provideWacom(\r\n\tconfig: Config = DEFAULT_CONFIG,\r\n): EnvironmentProviders {\r\n\treturn makeEnvironmentProviders([\r\n\t\t{ provide: CONFIG_TOKEN, useValue: config },\r\n\t\tprovideHttpClient(withInterceptorsFromDi()),\r\n\t]);\r\n}\r\n","/* initialize */\r\nimport { CommonModule } from '@angular/common';\r\nimport {\r\n\tprovideHttpClient,\r\n\twithInterceptorsFromDi,\r\n} from '@angular/common/http';\r\nimport { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { FormsModule } from '@angular/forms';\r\nimport {\r\n\tConfig,\r\n\tCONFIG_TOKEN,\r\n\tDEFAULT_CONFIG,\r\n} from './interfaces/config.interface';\r\n\r\n/* directives */\r\nimport { ClickOutsideDirective } from './directives/click-outside.directive';\r\nconst DIRECTIVES = [ClickOutsideDirective];\r\n\r\n/* pipes */\r\nimport { ArrPipe } from './pipes/arr.pipe';\r\nimport { MongodatePipe } from './pipes/mongodate.pipe';\r\nimport { PaginationPipe } from './pipes/pagination.pipe';\r\nimport { SafePipe } from './pipes/safe.pipe';\r\nimport { SearchPipe } from './pipes/search.pipe';\r\nimport { SplicePipe } from './pipes/splice.pipe';\r\nconst PIPES = [\r\n\tArrPipe,\r\n\tSafePipe,\r\n\tSplicePipe,\r\n\tSearchPipe,\r\n\tMongodatePipe,\r\n\tPaginationPipe,\r\n];\r\n\r\n@NgModule({\r\n\timports: [CommonModule, FormsModule, ...PIPES, ...DIRECTIVES],\r\n\texports: [...PIPES, ...DIRECTIVES],\r\n\tproviders: [\r\n\t\t{ provide: CONFIG_TOKEN, useValue: DEFAULT_CONFIG },\r\n\t\tprovideHttpClient(withInterceptorsFromDi()),\r\n\t],\r\n})\r\n/**\r\n * @deprecated Use provideWacom instead.\r\n */\r\nexport class WacomModule {\r\n\tstatic forRoot(\r\n\t\tconfig: Config = DEFAULT_CONFIG,\r\n\t): ModuleWithProviders<WacomModule> {\r\n\t\treturn {\r\n\t\t\tngModule: WacomModule,\r\n\t\t\tproviders: [\r\n\t\t\t\t{\r\n\t\t\t\t\tprovide: CONFIG_TOKEN,\r\n\t\t\t\t\tuseValue: config,\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t};\r\n\t}\r\n}\r\n","/*\r\n *\tInterfaces\r\n */\r\nexport * from './src/crud/crud.interface';\r\nexport * from './src/interfaces/config.interface';\r\nexport * from './src/interfaces/dom.interface';\r\nexport * from './src/interfaces/http.interface';\r\nexport * from './src/interfaces/meta.interface';\r\nexport * from './src/interfaces/network.interface';\r\nexport * from './src/interfaces/store.interface';\r\n/*\r\n *\tGuard\r\n */\r\nexport * from './src/guard/meta.guard';\r\n/*\r\n *\tComponents\r\n */\r\nexport * from './src/crud/crud.component';\r\n/*\r\n *\tDirectives\r\n */\r\nexport * from './src/directives/click-outside.directive';\r\nexport * from './src/directives/manual-disabled.directive';\r\nexport * from './src/directives/manual-name.directive';\r\nexport * from './src/directives/manual-readonly.directive';\r\nexport * from './src/directives/manual-type.directive';\r\n/*\r\n *\tPipes\r\n */\r\nexport * from './src/pipes/arr.pipe';\r\nexport * from './src/pipes/mongodate.pipe';\r\nexport * from './src/pipes/number.pipe';\r\nexport * from './src/pipes/pagination.pipe';\r\nexport * from './src/pipes/safe.pipe';\r\nexport * from './src/pipes/search.pipe';\r\nexport * from './src/pipes/splice.pipe';\r\nexport * from './src/pipes/split.pipe';\r\n/*\r\n *\tServices\r\n */\r\nexport * from './src/crud/crud.service';\r\nexport * from './src/services/core.service';\r\nexport * from './src/services/dom.service';\r\nexport * from './src/services/emitter.service';\r\nexport * from './src/services/http.service';\r\nexport * from './src/services/meta.service';\r\nexport * from './src/services/network.service';\r\nexport * from './src/services/rtc.service';\r\nexport * from './src/services/socket.service';\r\nexport * from './src/services/store.service';\r\nexport * from './src/services/time.service';\r\nexport * from './src/services/util.service';\r\n/*\r\n *\tInitial\r\n *\r\n *\tmake different kind of modules, one which import all, other for piece by piece\r\n */\r\nexport * from './src/provide-wacom';\r\nexport * from './src/wacom.module';\r\n/*\r\n *\tEnd of Support\r\n */\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1"],"mappings":";;;;;;;;;;;;;;MAyBa,YAAY,GAAG,IAAI,cAAc,CAAS,QAAQ;AAExD,MAAM,cAAc,GAAW;AACrC,IAAA,KAAK,EAAE;AACN,QAAA,MAAM,EAAE,SAAS;AACjB,KAAA;AACD,IAAA,IAAI,EAAE;AACL,QAAA,cAAc,EAAE,KAAK;AACrB,QAAA,gBAAgB,EAAE,KAAK;AACvB,QAAA,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;AACvB,KAAA;AACD,IAAA,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