/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{JSONMap as e}from"../../../core/jsonMap.js";import{getMetersPerUnitForSR as t}from"../../../core/units.js";import{geographicToWebMercator as r}from"../../../geometry/support/webMercatorUtils.js";import n from"./cameraOrientationRegistry.js";import{isConstantElevation as i,ConstantElevation as o,ElevationSource as s}from"./ElevationSourceDefinitions.js";function l(e,t,r){return t&&(e=`${t}${e}`),r&&(e+=`${r}`),e}function a(e,t,r){let{url:n}=e;return n?(n=l(n,t,r),new s({...e,url:n})):null}function c(e,t,r){return e?i(e)?new o(e):a(e,t,r):e}const u=new e({Minutes:"minutes",Hours:"hours",Days:"days",Weeks:"weeks",Months:"months",Years:"years"}),f=new e({Feet:"feet",Meter:"meter"}),m=new e({360:"360",Horizontal:"horizontal",Inspection:"inspection",Nadir:"nadir",Oblique:"oblique",Terrestrial360Video:"terrestrial-360-video",TerrestrialFrameVideo:"terrestrial-frame-video",Aerial360Video:"aerial-360-video",AerialFrameVideo:"aerial-frame-video","":null}),p=new Map;function d(e){const[t,r,n,i,o,s,l,a,c,u,f,m,p,d,h,w,y,v,D,z,L,C]=e.slice(1);return{horizontalWKID:t,verticalWKID:r,x:n,y:i,z:o,omega:s,phi:l,kappa:a,...g([c,u,f,m,p,d],[w,y],[v,D,z],[L,C],h)}}p.set("1",w),p.set("3",y),p.set("2",d),p.set("4",v);const h=e=>{const t=e.map(e=>parseFloat(e)).filter(e=>!isNaN(e));if(t.length===e.length)return t};function g(e,t,r,n,i){const o=h(e),s=h(t),l=h(r),a=h(n);return{affineTransformations:6===o?.length?o:void 0,focalLength:6===o?.length?parseFloat(i):void 0,principalOffsetPoint:2!==s?.length?[0,0]:s,radialDistortionCoefficients:3!==l?.length?[0,0,0]:l,tangentialDistortionCoefficients:2!==a?.length?[0,0]:a}}function w(e){const[t,r,n,i,o,s,l,a,c,u,f,m,p,d,h,w,y,v,D,z,L,C]=e.slice(1);return{horizontalWKID:t,verticalWKID:r,x:n,y:i,z:o,heading:s,pitch:l,roll:a,...g([c,u,f,m,p,d],[w,y],[v,D,z],[L,C],h)}}function y(e){const[t,r,n,i,o,s,l,a,c,u,f,m,p,d,h,w,y,v,D,z,L,C]=e.slice(1);return{horizontalWKID:t,verticalWKID:r,x:n,y:i,z:o,yaw:s,pitch:l,roll:a,...g([c,u,f,m,p,d],[w,y],[v,D,z],[L,C],h)}}function v(e){const[t,r,i,o,s,...l]=e.slice(1),a=p.get(s),c=n.get(s)?.constructor;if(!a||!c)return null;return{latitude:t,longitude:r,ellipsoidRadius:i,squaredEccentricity:o,properties:new c(a([s,"",...l]))}}function D(e){if(!e)return null;const t=`${e}`.split("|");if(0===t.length)return null;const r=n.get(t[0]);if(!r)return null;const i=p.get(t[0]);if(!i)return null;return new(0,r.constructor)(i(t))}function z(e){return Array.isArray(e)&&e?.length>5&&!e.some(isNaN)}function L(e){for(e=e.slice(0,8);e.length<8;)e.push(0);return e}function C(e){return e.spatialReference.isGeographic?r(e):e.clone()}function I(e){return e.isGeographic?1:t(e)}function N(e){const t=e.match(/^(.*)\/rest\/services\/(.*)$/);return t?t[1]:null}const W="sequenceorder";function j(e,t){if(!e){const e=t.find(e=>e.name.toLocaleLowerCase()===W.toLocaleLowerCase());return e?[{fieldName:e.name,sortOrder:"asc"}]:null}return e.split(";").map(e=>{const r=e.trim(),[n,i]=r.split(/\s+/).map(e=>e.trim()),o=t.find(e=>e.name.toLowerCase()===n.toLowerCase());return o?{fieldName:o?o.name:W,sortOrder:"desc"===i?.toLowerCase()?"desc":"asc"}:null}).filter(e=>null!=e)}export{l as appendPrefixAndSuffix,C as convertGeographicToWebMercator,D as createCameraOrientation,W as defaultSequenceOrderField,N as getArcGISServerUrl,c as getEffectiveElevationSource,I as getMetersPerUnitOfSR,z as isOrientationAccuracy,m as orientedImageryTypeMap,L as padAccuracyArray,j as parseSequenceOrderFields,a as processElevationSource,u as timeIntervalUnitTypeMap,p as transformersRegistry,f as verticalMeasurementTypeMap};
