/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{getEpsilon as t,RANDOM as n}from"./common.js";function r(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t}function a(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t}function o(t,n,r,a,o){return t[0]=n,t[1]=r,t[2]=a,t[3]=o,t}function u(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t[3]=n[3]+r[3],t}function e(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t[3]=n[3]-r[3],t}function c(t,n,r){return t[0]=n[0]*r[0],t[1]=n[1]*r[1],t[2]=n[2]*r[2],t[3]=n[3]*r[3],t}function i(t,n,r){return t[0]=n[0]/r[0],t[1]=n[1]/r[1],t[2]=n[2]/r[2],t[3]=n[3]/r[3],t}function s(t,n){return t[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t[2]=Math.ceil(n[2]),t[3]=Math.ceil(n[3]),t}function h(t,n){return t[0]=Math.floor(n[0]),t[1]=Math.floor(n[1]),t[2]=Math.floor(n[2]),t[3]=Math.floor(n[3]),t}function M(t,n,r){return t[0]=Math.min(n[0],r[0]),t[1]=Math.min(n[1],r[1]),t[2]=Math.min(n[2],r[2]),t[3]=Math.min(n[3],r[3]),t}function f(t,n,r){return t[0]=Math.max(n[0],r[0]),t[1]=Math.max(n[1],r[1]),t[2]=Math.max(n[2],r[2]),t[3]=Math.max(n[3],r[3]),t}function l(t,n){return t[0]=Math.round(n[0]),t[1]=Math.round(n[1]),t[2]=Math.round(n[2]),t[3]=Math.round(n[3]),t}function m(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=n[3]*r,t}function d(t,n,r,a){return t[0]=n[0]+r[0]*a,t[1]=n[1]+r[1]*a,t[2]=n[2]+r[2]*a,t[3]=n[3]+r[3]*a,t}function b(t,n){const r=n[0]-t[0],a=n[1]-t[1],o=n[2]-t[2],u=n[3]-t[3];return Math.sqrt(r*r+a*a+o*o+u*u)}function x(t,n){const r=n[0]-t[0],a=n[1]-t[1],o=n[2]-t[2],u=n[3]-t[3];return r*r+a*a+o*o+u*u}function q(t){const n=t[0],r=t[1],a=t[2],o=t[3];return Math.sqrt(n*n+r*r+a*a+o*o)}function p(t){const n=t[0],r=t[1],a=t[2],o=t[3];return n*n+r*r+a*a+o*o}function v(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=-n[3],t}function g(t,n){return t[0]=1/n[0],t[1]=1/n[1],t[2]=1/n[2],t[3]=1/n[3],t}function y(t,n){const r=n[0],a=n[1],o=n[2],u=n[3];let e=r*r+a*a+o*o+u*u;return e>0&&(e=1/Math.sqrt(e),t[0]=r*e,t[1]=a*e,t[2]=o*e,t[3]=u*e),t}function _(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]*n[3]}function j(t,n,r,a){const o=n[0],u=n[1],e=n[2],c=n[3];return t[0]=o+a*(r[0]-o),t[1]=u+a*(r[1]-u),t[2]=e+a*(r[2]-e),t[3]=c+a*(r[3]-c),t}function w(t,r=1){const a=n;let o,u,e,c,i,s;do{o=2*a()-1,u=2*a()-1,i=o*o+u*u}while(i>=1);do{e=2*a()-1,c=2*a()-1,s=e*e+c*c}while(s>=1);const h=Math.sqrt((1-i)/s);return t[0]=r*o,t[1]=r*u,t[2]=r*e*h,t[3]=r*c*h,t}function z(t,n,r){const a=n[0],o=n[1],u=n[2],e=n[3];return t[0]=r[0]*a+r[4]*o+r[8]*u+r[12]*e,t[1]=r[1]*a+r[5]*o+r[9]*u+r[13]*e,t[2]=r[2]*a+r[6]*o+r[10]*u+r[14]*e,t[3]=r[3]*a+r[7]*o+r[11]*u+r[15]*e,t}function A(t,n,r){const a=n[0],o=n[1],u=n[2],e=r[0],c=r[1],i=r[2],s=r[3],h=s*a+c*u-i*o,M=s*o+i*a-e*u,f=s*u+e*o-c*a,l=-e*a-c*o-i*u;return t[0]=h*s+l*-e+M*-i-f*-c,t[1]=M*s+l*-c+f*-e-h*-i,t[2]=f*s+l*-i+h*-c-M*-e,t[3]=n[3],t}function D(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function L(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function O(n,r){const a=n[0],o=n[1],u=n[2],e=n[3],c=r[0],i=r[1],s=r[2],h=r[3],M=t();return Math.abs(a-c)<=M*Math.max(1,Math.abs(a),Math.abs(c))&&Math.abs(o-i)<=M*Math.max(1,Math.abs(o),Math.abs(i))&&Math.abs(u-s)<=M*Math.max(1,Math.abs(u),Math.abs(s))&&Math.abs(e-h)<=M*Math.max(1,Math.abs(e),Math.abs(h))}const S=e,E=c,P=i,Q=b,T=x,V=q,k=p,B=Object.freeze(Object.defineProperty({__proto__:null,add:u,ceil:s,copy:r,copyVec3:a,dist:Q,distance:b,div:P,divide:i,dot:_,equals:O,exactEquals:L,floor:h,inverse:g,len:V,length:q,lerp:j,max:f,min:M,mul:E,multiply:c,negate:v,normalize:y,random:w,round:l,scale:m,scaleAndAdd:d,set:o,sqrDist:T,sqrLen:k,squaredDistance:x,squaredLength:p,str:D,sub:S,subtract:e,transformMat4:z,transformQuat:A},Symbol.toStringTag,{value:"Module"}));export{u as add,s as ceil,r as copy,a as copyVec3,Q as dist,b as distance,P as div,i as divide,_ as dot,O as equals,L as exactEquals,h as floor,g as inverse,V as len,q as length,j as lerp,f as max,M as min,E as mul,c as multiply,v as negate,y as normalize,w as random,l as round,m as scale,d as scaleAndAdd,o as set,T as sqrDist,k as sqrLen,x as squaredDistance,p as squaredLength,D as str,S as sub,e as subtract,z as transformMat4,A as transformQuat,B as v};
