/* COPYRIGHT Esri - https://js.arcgis.com/5.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 u of i.symbols.values())for(const i of u)for(const u of i.colliders(t)){const t=(u.xScreen+u.dxScreen)*a,c=(u.yScreen+u.dyScreen)*a,x=u.width*a,l=u.height*a,p=i.uniqueSymbol?.parts[u.partIndex].targetOpacity>.5;if(!p&&"all"!==r)continue;const d=3,f=1,v=3,h=0,D=p?2:0,y=p?3:0,g=e.makeFlags(D,y);o.push(t,c,g,t+x,c,g,t,c+l,g,t+x,c+l,g),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4;const m=p?d:f,C=p?v:h,b=e.makeFlags(m,C);o.push(t,c,b,t+x,c,b,t,c+1,b,t+x,c+1,b),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4,o.push(t,c+l-1,b,t+x,c+l-1,b,t,c+l,b,t+x,c+l,b),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4,o.push(t,c,b,t+1,c,b,t,c+l,b,t+1,c+l,b),s.push(n,n+1,n+2,n+1,n+3,n+2),n+=4,o.push(t+x-1,c,b,t+x,c,b,t+x-1,c+l,b,t+x,c+l,b),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,u=e.makeFlags(2,3),c=256,x=256,l=c+s,p=x+i;for(const e of[-3,3])for(const t of[-3,3])r.push(c,x,u,c+e,x+t,u,l,p,u,l+e,p+t,u),n.push(o,o+1,o+2,o+1,o+3,o+2),o+=4},n=(e,t,n)=>{const{pixelRatio:o}=t.state,{vertexData:s,indexData:i,vertexCount:u}=a(e.featureContainer,o,n),c=e.view.labelManager.symbolFader;return c&&r(c,{vertexData:s,indexData:i,vertexCount:u}),{vertexData:new Int16Array(s),indexData:new Uint32Array(i)}},o=(e,t,n)=>{const{pixelRatio:o}=t.state,s=e._vectorTileContainer,{vertexData:i,indexData:u,vertexCount:c}=a(s,o,n),{symbolFader:x}=s;return x&&r(x,{vertexData:i,indexData:u,vertexCount:c}),{vertexData:new Int16Array(i),indexData:new Uint32Array(u)}},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};
