/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../request","../../core/Error","../../core/maybe"],(function(e,o,n,r,t){"use strict";function s(e,o,n,r,t,s){return i.apply(this,arguments)}function i(){return(i=o._asyncToGenerator((function*(e,o,s,i,l,a){let d=null;if(t.isSome(s)){const o=`${e}/nodepages/`,r=o+Math.floor(s.rootIndex/s.nodesPerPage);try{return{type:"page",rootPage:(yield n(r,{query:{f:"json",token:i},responseType:"json",signal:a})).data,rootIndex:s.rootIndex,pageSize:s.nodesPerPage,lodMetric:s.lodSelectionMetricType,urlPrefix:o}}catch(p){t.isSome(l)&&l.warn("#fetchIndexInfo()","Failed to load root node page. Falling back to node documents.",r,p),d=p}}if(!o)return null;const u=`${e}/nodes/`,c=u+(o&&o.split("/").pop());try{return{type:"node",rootNode:(yield n(c,{query:{f:"json",token:i},responseType:"json",signal:a})).data,urlPrefix:u}}catch(p){throw new r("sceneservice:root-node-missing","Root node missing.",{pageError:d,nodeError:p,url:c})}}))).apply(this,arguments)}e.fetchIndexInfo=s,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
