/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/mathUtils","../../chunks/vec2","../../chunks/vec2f64"],(function(t,e,n,r){"use strict";function s(t,e){return t[0]*e[1]-t[1]*e[0]}function c(t,e,r){const s=(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0]);return Math.abs(s)/n.distance(e,r)}function o(t,e,r){const s=n.dot(r,e)/n.squaredLength(r);return n.scale(t,r,s)}function a(t,e,r,s,c=r){return n.subtract(y,s,r),n.subtract(h,e,c),o(T,h,y),n.add(t,c,T)}function u(t,e,r,s){n.subtract(y,s,r),n.subtract(h,e,r);const c=n.dot(y,h)/n.squaredLength(y);return c>0?n.scaleAndAdd(t,r,y,c):n.copy(t,r)}function i(t,e,r,s){n.subtract(y,e,r);const c=s/n.length(y);return n.scaleAndAdd(t,r,y,c)}function d(t,n){return a(h,n,t.start,t.end),e.floatEqualAbsolute(h[0],n[0])&&e.floatEqualAbsolute(h[1],n[1])?[r.clone(n)]:[]}function l(t,n,s){return i(h,s,t,n),e.floatEqualAbsolute(h[0],s[0])&&e.floatEqualAbsolute(h[1],s[1])?[r.clone(s)]:[]}function L(e,r){const c=e.start,o=e.end,a=r.start,u=r.end,i=n.subtract(y,o,c),d=n.subtract(b,u,a),l=s(i,d);if(Math.abs(l)<=A)return[];const L=n.subtract(h,c,a),p=s(d,L)/l,f=s(i,L)/l;if(p>=0){if(f>=0||r.type===t.LineType.LINE)return[n.scaleAndAdd(T,c,i,p)]}else if(e.type===t.LineType.LINE&&(f>=0||r.type===t.LineType.LINE))return[n.scaleAndAdd(T,c,i,p)];return[]}function p(e,r,s){const c=[],o=n.subtract(y,e.end,e.start),a=n.subtract(b,e.start,r),u=n.squaredLength(o),i=2*n.dot(o,a),d=i*i-4*u*(n.squaredLength(a)-s*s);if(0===d){const r=-i/(2*u);(e.type===t.LineType.LINE||r>=0)&&c.push(n.scaleAndAdd(T,e.start,o,r))}else if(d>0){const r=Math.sqrt(d),s=(-i+r)/(2*u);(e.type===t.LineType.LINE||s>=0)&&c.push(n.scaleAndAdd(T,e.start,o,s));const a=(-i-r)/(2*u);(e.type===t.LineType.LINE||a>=0)&&c.push(n.scaleAndAdd(h,e.start,o,a))}return c}var f;t.LineType=void 0,(f=t.LineType||(t.LineType={}))[f.RAY=0]="RAY",f[f.LINE=1]="LINE";const A=1e-6,y=r.create(),b=r.create(),h=r.create(),T=r.create();t.cross=s,t.intersectCircleAndPoint=l,t.intersectLineAndPoint=d,t.intersectLineAndRay=L,t.intersectLineLikeAndCircle=p,t.pointToLineDistance=c,t.projectPoint=o,t.projectPointToCircle=i,t.projectPointToLine=a,t.projectPointToRay=u,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
