/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"./DebugOverlay.js";function t(t,a){t.container.addChild(new e({getMesh:e=>"vector-tile"===t.layer.type?o(t,e,a):n(t,e,a),getColors:s,getOpacities:i}))}const a=(t,a,r)=>{let n=0;const o=[],s=[];for(const i of t.children)if(i.symbols)for(const c of i.symbols.values())for(const i of c)for(const c of i.colliders(t)){const t=(c.xScreen+c.dxScreen)*a,u=(c.yScreen+c.dyScreen)*a,l=c.width*a,x=c.height*a,p=i.uniqueSymbol?.parts[c.partIndex].targetOpacity>.5;if(!p&&"all"!==r)continue;const f=3,d=1,h=3,v=0,D=p?2:0,y=p?3:0,g=e.makeFlags(D,y);o.push(t,u,g,t+l,u,g,t,u+x,g,t+l,u+x,g),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4;const m=p?f:d,C=p?h:v,w=e.makeFlags(m,C);o.push(t,u,w,t+l,u,w,t,u+1,w,t+l,u+1,w),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4,o.push(t,u+x-1,w,t+l,u+x-1,w,t,u+x,w,t+l,u+x,w),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4,o.push(t,u,w,t+1,u,w,t,u+x,w,t+1,u+x,w),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4,o.push(t+l-1,u,w,t+l,u,w,t+l-1,u+x,w,t+l,u+x,w),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4}return{vertexData:o,indexData:s,vertexCount:n}},r=(t,a)=>{let{vertexData:r,indexData:n,vertexCount:o}=a;const[s,i]=t.decluttererOffset,c=e.makeFlags(2,3),u=256,l=256,x=u+s,p=l+i;for(const e of[-3,3])for(const t of[-3,3])r.push(u,l,c,u+e,l+t,c,x,p,c,x+e,p+t,c),n.push(o,o+1,o+2,o+1,o+3,o+2),o+=4},n=(e,t,r)=>{const{pixelRatio:n}=t.state,{vertexData:o,indexData:s}=a(e.featureContainer,n,r);return{vertexData:new Int16Array(o),indexData:new Uint32Array(s)}},o=(e,t,n)=>{const{pixelRatio:o}=t.state,s=e._vectorTileContainer,{vertexData:i,indexData:c,vertexCount:u}=a(s,o,n),{symbolFader:l}=s;return l&&r(l,{vertexData:i,indexData:c,vertexCount:u}),{vertexData:new Int16Array(i),indexData:new Uint32Array(c)}},s=()=>[1,.5,0,1,1,0,0,1,0,1,.5,1,0,.5,0,1],i=()=>[.05,.01,.15,.2];export{t as showCollisionBoxes};
