/*
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","../../../core/maybe","../../../core/PooledArray"],(function(e,t,n,i){"use strict";let r=function(){function e(){this._queue=new i,this._last=null,this.remove=()=>{}}var r=e.prototype;return r.resetOne=function(e){this._queue.clear(),this._queue.push(e),this._last=null},r.reset=function(e=null){this._queue.clear(),n.isSome(e)&&this._queue.pushArray(e),this._last=null},r.skipSubtree=function(){this._last=null},r.next=function(){return this._last&&!this._last.isLeaf&&this._queue.pushArray(this._last.children),this._last=this._queue.pop(),this._last},t._createClass(e,[{key:"done",get:function(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}}]),e}(),s=function(){function e(){this.q=new i}var r=e.prototype;return r.reset=function(e){if(this.q.clear(),!n.isNone(e)){this.q.pushArray(e);for(let e=0;e<this.q.length;++e){const t=this.q.data[e];t.isLeaf||this.q.pushArray(t.children)}}},r.next=function(){return this.q.pop()},t._createClass(e,[{key:"done",get:function(){return 0===this.q.length}}]),e}();function l(e,t){if(Array.isArray(e))for(let n=0;n<e.length;n++)o(e[n],t);else o(e,t)}function o(e,t){if(t(e),!e.isLeaf)for(const n of e.children)o(n,t)}function u(e,t,i){if(n.isNone(t)||n.isNone(t.fullExtent))return!1;const r=t.fullExtent,s=e.extent;if(i){if(s[0]<r.xmin||s[1]<r.ymin||s[2]>r.xmax||s[3]>r.ymax)return!1}else if(r.xmin>s[2]||r.ymin>s[3]||r.xmax<s[0]||r.ymax<s[1])return!1;const l=e.surface.tilingScheme.levels[e.level].scale;return!(t.minScale>0&&l>1.00000001*t.minScale)&&!(t.maxScale>0&&l<.99999999*t.maxScale)}function a(e,t){return e.lij[0]-t.lij[0]||e.lij[1]-t.lij[1]||e.lij[2]-t.lij[2]}function c(e,t){t.sort(((t,n)=>f(t,n,e)))}function f(e,t,n){const i=e.screenDepth,r=t.screenDepth;return i<r?-n:i>r?n:a(e,t)}function h(e,t){const n=new Map;e.forAll((e=>n.set(e.lij,e.distanceToSquared(t)))),e.sort(((e,t)=>n.get(e.lij)-n.get(t.lij)||a(e,t)))}function p(e,t,n){let i=1,r=0,s=0;for(;e!==t;)if(i*=.5,r*=.5,s*=.5,1&e.lij[2]&&(r+=.5),0==(1&e.lij[1])&&(s+=.5),null==(e=e.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(t,r,s,i)}function _(e){for(let t=0;t<e.length;t++){const n=e[t],i=n.parent;if(i)for(let e=0;e<4;e++){const t=i.children[e];if(t&&t!==n)return!0}}return!1}function d(e,t){if(!e||!t||e[0]===t[0])return!1;const n=e[0]<t[0],i=n?e:t,r=n?t:e,s=1<<r[0]-i[0];return Math.floor(r[1]/s)===i[1]&&Math.floor(r[2]/s)===i[2]}e.IteratorPostorder=s,e.IteratorPreorder=r,e.compareTiles=f,e.computeUpsampleInfo=p,e.fallsWithinLayer=u,e.hasLoadableSiblings=_,e.sortTiles=c,e.sortTilesByPOI=h,e.tilesAreRelated=d,e.traverseTilesPreorder=l,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
