/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{createScreenRect as t,screenRectIntersects as e}from"../../../core/screenUtils.js";import{polygonContainsPoint as r,extentContainsPoint as n,ringsContainsCoords as o}from"../../../geometry/support/contains.js";const i=t=>parseFloat(t)/100;function a(t,e,r){const n="string"==typeof t.left?i(t.left)*e:t.left??0,o="string"==typeof t.right?i(t.right)*e:t.right??0,a="string"==typeof t.top?i(t.top)*r:t.top??0,m="string"==typeof t.bottom?i(t.bottom)*r:t.bottom??0,h=a;return{xmin:n,xmax:Math.max(e-o,n),ymin:h,ymax:Math.max(r-m,a)}}function m(t,e,r){const{xmin:n,xmax:o,ymin:i,ymax:m}=a(t,e,r);return{x:n,y:i,width:o-n,height:m-i}}function h(t,e,i,m){switch(e.type){case"rect":{const{width:r,height:n}=t,{xmin:o,xmax:m,ymin:h,ymax:y}=a(e,r,n),{x:s,y:c}=i;return s>o&&s<m&&c>h&&c<y}case"path":return 0===e.path.length||!Array.isArray(e.path[0][0])||o(e.path,[i.x,i.y]);case"geometry":return null==e.geometry||("polygon"===e.geometry.type?r(e.geometry,m):n(e.geometry,m))}}function y(t,r,n){switch(r.type){case"rect":return e(m(r,t.width,t.height),n);case"path":case"geometry":return!0}}function s(e,r,n){switch(r.type){case"rect":{const{width:o,height:i}=e,{xmin:m,xmax:h,ymin:y,ymax:s}=a(r,o,i),c=n.x,x=n.y,p=c+n.width,g=x+n.height,u=Math.max(m,c),f=Math.min(h,p);if(u>=f)return null;const l=Math.max(y,x),w=Math.min(s,g);return l>=w?null:t(u,l,f-u,w-l)}case"path":case"geometry":return n}}export{h as clipContainsPoint,y as clipIntersectsScreenRect,s as computeClippedScreenRect,a as createScreenExtent};
