/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{extentContainsCoords2D as n,extentContainsPoint as t,ringsContainsCoords as e,extentContainsCoords3D as r}from"./contains.js";function i(n,e){return t(n,e)}function o(n,t){const e=n.hasZ&&t.hasZ;let r,i,o;if(n.xmin<=t.xmin){if(r=t.xmin,n.xmax<r)return!1}else if(r=n.xmin,t.xmax<r)return!1;if(n.ymin<=t.ymin){if(i=t.ymin,n.ymax<i)return!1}else if(i=n.ymin,t.ymax<i)return!1;if(e&&t.hasZ)if(n.zmin<=t.zmin){if(o=t.zmin,n.zmax<o)return!1}else if(o=n.zmin,t.zmax<o)return!1;return!0}function m(t,e){const{points:i,hasZ:o}=e,m=o?r:n;for(const n of i)if(m(t,n))return!0;return!1}const s=[0,0],u=[0,0],f=[0,0],c=[0,0],a=[s,u,f,c],x=[[f,s],[s,u],[u,c],[c,f]];function l(n,t){return y(n,t.rings)}function y(t,r){s[0]=t.xmin,s[1]=t.ymax,u[0]=t.xmax,u[1]=t.ymax,f[0]=t.xmin,f[1]=t.ymin,c[0]=t.xmax,c[1]=t.ymin;for(const n of a)if(e(r,n))return!0;for(const e of r){if(!e.length)continue;let r=e[0];if(n(t,r))return!0;for(let i=1;i<e.length;i++){const o=e[i];if(n(t,o)||p(r,o,x))return!0;r=o}}return!1}function h(t,e){s[0]=t.xmin,s[1]=t.ymax,u[0]=t.xmax,u[1]=t.ymax,f[0]=t.xmin,f[1]=t.ymin,c[0]=t.xmax,c[1]=t.ymin;const r=e.paths;for(const i of r){if(!r.length)continue;let e=i[0];if(n(t,e))return!0;for(let r=1;r<i.length;r++){const o=i[r];if(n(t,o)||p(e,o,x))return!0;e=o}}return!1}function p(n,t,e){for(let r=0;r<e.length;r++)if(g(n,t,e[r][0],e[r][1]))return!0;return!1}function g(n,t,e,r,i){const[o,m]=n,[s,u]=t,[f,c]=e,[a,x]=r,l=a-f,y=o-f,h=s-o,p=x-c,g=m-c,z=u-m,G=p*h-l*z;if(0===G)return!1;const P=(l*g-p*y)/G,Z=(h*g-z*y)/G;return P>=0&&P<=1&&Z>=0&&Z<=1&&(i&&(i[0]=o+P*(s-o),i[1]=m+P*(u-m)),!0)}function z(n){switch(n){case"esriGeometryEnvelope":case"extent":return o;case"esriGeometryMultipoint":case"multipoint":return m;case"esriGeometryPoint":case"point":return i;case"esriGeometryMultiPatch":case"multipatch":case"esriGeometryPolygon":case"polygon":return l;case"esriGeometryPolyline":case"polyline":return h}}export{o as extentIntersectsExtent,m as extentIntersectsMultipoint,i as extentIntersectsPoint,l as extentIntersectsPolygon,h as extentIntersectsPolyline,z as getFeatureExtentIntersector,g as segmentIntersects};
