import Index from"./index.js";import{DocumentInterface}from"./type.js";import Cache,{searchCache}from"./cache.js";import{create_object,is_array,is_string,is_object,parse_option,get_keys}from"./common.js";import apply_async from"./async.js";import{intersect,intersect_union}from"./intersect.js";import{exportDocument,importDocument}from"./serialize.js";import WorkerIndex from"./worker/index.js";function Document(a){if(!(this instanceof Document))return new Document(a);const b=a.document||a.doc||a;let c;this.tree=[],this.field=[],this.marker=[],this.register=create_object(),this.key=(c=b.key||b.id)&&parse_tree(c,this.marker)||"id",this.fastupdate=parse_option(a.fastupdate,!0),this.storetree=(c=b.store)&&!0!==c&&[],this.store=c&&create_object(),this.tag=(c=b.tag)&&parse_tree(c,this.marker),this.tagindex=c&&create_object(),this.cache=(c=a.cache)&&new Cache(c),a.cache=!1,this.worker=a.worker,this.async=!1,this.index=parse_descriptor.call(this,a,b)}export default Document;function parse_descriptor(a,b){const c=create_object();let d=b.index||b.field||b;is_string(d)&&(d=[d]);for(let e,f,g=0;g