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E,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrF;CACD","sourcesContent":["import type { Api, Model } from \"./types.ts\";\n\nexport interface ModelsStoreEntry {\n\tmodels: readonly Model<Api>[];\n\t/** Unix timestamp from the remote catalog's Last-Modified header. */\n\tlastModified?: number;\n\t/** Unix timestamp of the last completed remote check. */\n\tcheckedAt?: number;\n\t/**\n\t * Opaque validator from the remote catalog's ETag header, stored verbatim\n\t * (quotes included) and echoed back as If-None-Match.\n\t */\n\tetag?: string;\n}\n\nexport interface ModelsStoreOperationOptions {\n\tsignal?: AbortSignal;\n}\n\n/** Persistent model catalogs keyed by provider ID. */\nexport interface ModelsStore {\n\tread(providerId: string, options?: ModelsStoreOperationOptions): Promise<ModelsStoreEntry | undefined>;\n\twrite(providerId: string, entry: ModelsStoreEntry, options?: ModelsStoreOperationOptions): Promise<void>;\n\tdelete(providerId: string, options?: ModelsStoreOperationOptions): Promise<void>;\n}\n\nexport class InMemoryModelsStore implements ModelsStore {\n\tprivate readonly entries = new Map<string, ModelsStoreEntry>();\n\n\tasync read(providerId: string, options?: ModelsStoreOperationOptions): Promise<ModelsStoreEntry | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst entry = this.entries.get(providerId);\n\t\treturn entry ? structuredClone(entry) : undefined;\n\t}\n\n\tasync write(providerId: string, entry: ModelsStoreEntry, options?: ModelsStoreOperationOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.entries.set(providerId, structuredClone(entry));\n\t}\n\n\tasync delete(providerId: string, options?: ModelsStoreOperationOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.entries.delete(providerId);\n\t}\n}\n"]}