import{IndexInterface,DocumentInterface}from"./type.js";import{create_object,is_string}from"./common.js";function async(a,b,c,d,e,f,g,h){setTimeout(function(){const i=a(c?c+"."+d:d,JSON.stringify(g));i&&i.then?i.then(function(){b.export(a,b,c,e,f+1,h)}):b.export(a,b,c,e,f+1,h)})}export function exportIndex(a,b,c,d,e,f){let g=!0;"undefined"==typeof f&&(g=new Promise(a=>{f=a}));let h,i;switch(e||(e=0)){case 0:if(h="reg",this.fastupdate)for(let a in i=create_object(),this.register)i[a]=1;else i=this.register;break;case 1:h="cfg",i={doc:0,opt:this.optimize?1:0};break;case 2:h="map",i=this.map;break;case 3:h="ctx",i=this.ctx;break;default:return void("undefined"==typeof c&&f&&f());}return async(a,b||this,c,h,d,e,i,f),g}export function importIndex(a,b){b&&(is_string(b)&&(b=JSON.parse(b)),"cfg"===a?this.optimize=!!b.opt:"reg"===a?(this.fastupdate=!1,this.register=b):"map"===a?this.map=b:"ctx"===a?this.ctx=b:void 0)}export function exportDocument(a,b,c,d,e,f){let g;if("undefined"==typeof f&&(g=new Promise(a=>{f=a})),e||(e=0),d||(d=0),d