if(typeofopts==='function'){fetch=opts;}else{// fetch option is availble
if(opts.fetch){// fetch is a funciton
if(typeofopts.fetch==='function'){fetch=opts.fetch;}else{// configuration
fetch=opts.fetch.fn||defaultFetch;autoDecodeResponse=!!opts.fetch.autoDecodeResponse;}}getPublicPath=opts.getPublicPath||opts.getDomain||defaultGetPublicPath;getTemplate=opts.getTemplate||defaultGetTemplate;}
exportdefaultfunctionimportHTML(url,opts={}){letfetch=defaultFetch;letautoDecodeResponse=false;letgetPublicPath=defaultGetPublicPath;letgetTemplate=defaultGetTemplate;const{postProcessTemplate}=opts;// compatible with the legacy importHTML api
if(typeofopts==='function'){fetch=opts;}else{// fetch option is availble
if(opts.fetch){// fetch is a funciton
if(typeofopts.fetch==='function'){fetch=opts.fetch;}else{// configuration
fetch=opts.fetch.fn||defaultFetch;autoDecodeResponse=!!opts.fetch.autoDecodeResponse;}}getPublicPath=opts.getPublicPath||opts.getDomain||defaultGetPublicPath;getTemplate=opts.getTemplate||defaultGetTemplate;}returnembedHTMLCache[url]||(embedHTMLCache[url]=fetch(url).then(response=>readResAsString(response,autoDecodeResponse)).then(html=>{constassetPublicPath=getPublicPath(url);const{template,scripts,entry,styles}=processTpl(getTemplate(html),assetPublicPath,postProcessTemplate);returngetEmbedHTML(template,styles,{fetch}).then(embedHTML=>({template:embedHTML,assetPublicPath,getExternalScripts:()=>getExternalScripts(scripts,fetch),getExternalStyleSheets:()=>getExternalStyleSheets(styles,fetch),execScripts:(proxy,strictGlobal,opts={})=>{if(!scripts.length){returnPromise.resolve();}returnexecScripts(entry,scripts,proxy,{fetch,strictGlobal,...opts,});},}));}));}