/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import has from"../../../../core/has.js";import e from"./WGLContainer.js";import r from"./brushes/WGLBrushStencil.js";import s from"./brushes/WGLBrushTileDebugInfo.js";const t=(e,r)=>e.key.level-r.key.level!==0?e.key.level-r.key.level:e.key.row-r.key.row!==0?e.key.row-r.key.row:e.key.col-r.key.col;class n extends e{constructor(e){super(),this.tilingScheme=e,this.sortFunction=t}renderChildren(e){this.setStencilReference(e),super.renderChildren(e)}createRenderParams(e){const{state:r}=e,s=super.createRenderParams(e);return s.requiredLevel=this.tilingScheme.getClosestInfoForScale(r.scale).level,s.displayLevel=this.tilingScheme.scaleToZoom(r.scale),s}prepareRenderPasses(e){const t=super.prepareRenderPasses(e);return t.push(e.registerRenderPass({name:"stencil",brushes:[r],drawPhase:211,target:()=>this.getStencilTarget()})),has("esri-tiles-debug")&&t.push(e.registerRenderPass({name:"tileInfo",brushes:[s],drawPhase:64,target:()=>this.children})),t}getStencilTarget(){return this.children}setStencilReference(e){let r=1;for(const s of this.children)s.stencilRef=r++}}export{n as default};
