{"version":3,"file":"js/8674.65285e27.js","mappings":"uIAEO,OAAMA,EACXC,YAAY,CAA0B,CAAE,C,KAAZC,EAAE,CAAFA,E,KAE5BC,MAAM,CAAG,IAAIC,GAF4B,CAIlCC,OAA0BC,CAAQ,CAAEC,CAAwB,CAAE,CACnE,IAAMC,EAAS,IAAI,CAACL,MAAM,CAACM,GAAG,CAACH,IAAU,EAAE,CACvCI,MAAMC,OAAO,CAACJ,GAChBC,EAAOI,IAAI,IAAIL,GAEfC,EAAOI,IAAI,CAACL,GAEd,IAAI,CAACJ,MAAM,CAACU,GAAG,CAACP,EAAOE,EACzB,CAEAC,IAAuBH,CAAQ,CAAiC,CAC9D,IAAME,EAAS,IAAI,CAACL,MAAM,CAACM,GAAG,CAACH,UAC/B,KAAeQ,IAAXN,EACF,OACSA,IAAAA,EAAOO,MAAM,CACfP,CAAM,CAAC,EAAE,CAETA,CAEX,CAEA,OAAOQ,KACLd,CAAU,CACVe,CAEmC,CACtB,CACb,IAAMC,EAAM,IAAIlB,EAASE,GAEzB,GAAIe,aAAeb,IACjB,IAAK,GAAM,CAACe,EAAKZ,EAAM,GAAIU,EACzBC,EAAIb,MAAM,CAACc,EAAKZ,QAGlB,IAAK,IAAMY,KAAOF,EAChBC,EAAIb,MAAM,CAACc,EAAKF,CAAG,CAACE,EAAI,EAG5B,OAAOD,CACT,CACF,C","sources":["webpack://@affine/web/../../common/infra/src/sync/indexer/document.ts"],"sourcesContent":["import type { Schema } from './schema';\n\nexport class Document {\n constructor(public readonly id: string) {}\n\n fields = new Map();\n\n public insert(field: F, value: string | string[]) {\n const values = this.fields.get(field) ?? [];\n if (Array.isArray(value)) {\n values.push(...value);\n } else {\n values.push(value);\n }\n this.fields.set(field, values);\n }\n\n get(field: F): string[] | string | undefined {\n const values = this.fields.get(field);\n if (values === undefined) {\n return undefined;\n } else if (values.length === 1) {\n return values[0];\n } else {\n return values;\n }\n }\n\n static from(\n id: string,\n map:\n | Partial>\n | Map\n ): Document {\n const doc = new Document(id);\n\n if (map instanceof Map) {\n for (const [key, value] of map) {\n doc.insert(key, value);\n }\n } else {\n for (const key in map) {\n doc.insert(key, map[key] as string | string[]);\n }\n }\n return doc;\n }\n}\n"],"names":["Document","constructor","id","fields","Map","insert","field","value","values","get","Array","isArray","push","set","undefined","length","from","map","doc","key"],"sourceRoot":""}