/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/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 o,ConstantElevation as i,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?o(e)?new i(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}),d=new Map;function p(e){const[t,r,n,o,i,s,l,a,c,u,f,m,d,p,h,w,y,v,D,L,C,z]=e.slice(1);return{horizontalWKID:t,verticalWKID:r,x:n,y:o,z:i,omega:s,phi:l,kappa:a,...g([c,u,f,m,d,p],[w,y],[v,D,L],[C,z],h)}}d.set("1",w),d.set("3",y),d.set("2",p),d.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,o){const i=h(e),s=h(t),l=h(r),a=h(n);return{affineTransformations:6===i?.length?i:void 0,focalLength:6===i?.length?parseFloat(o):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,o,i,s,l,a,c,u,f,m,d,p,h,w,y,v,D,L,C,z]=e.slice(1);return{horizontalWKID:t,verticalWKID:r,x:n,y:o,z:i,heading:s,pitch:l,roll:a,...g([c,u,f,m,d,p],[w,y],[v,D,L],[C,z],h)}}function y(e){const[t,r,n,o,i,s,l,a,c,u,f,m,d,p,h,w,y,v,D,L,C,z]=e.slice(1);return{horizontalWKID:t,verticalWKID:r,x:n,y:o,z:i,yaw:s,pitch:l,roll:a,...g([c,u,f,m,d,p],[w,y],[v,D,L],[C,z],h)}}function v(e){const[t,r,o,i,s,...l]=e.slice(1),a=d.get(s),c=n.get(s)?.constructor;if(!a||!c)return null;return{latitude:t,longitude:r,ellipsoidRadius:o,squaredEccentricity:i,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 o=d.get(t[0]);if(!o)return null;return new(0,r.constructor)(o(t))}function L(e){return Array.isArray(e)&&e?.length>5&&!e.some(isNaN)}function C(e){for(e=e.slice(0,8);e.length<8;)e.push(0);return e}function z(e){return e.spatialReference.isGeographic?r(e):e.clone()}function N(e){return e.isGeographic?1:t(e)}function I(e){const t=e.match(/^(.*)\/rest\/services\/(.*)$/);return t?t[1]:null}const W="sequenceorder";function j(e,t){if(!e?.length)return null;return e.map(({field:e,order:r})=>{const n=t.find(t=>t.name.toLowerCase()===e.toLowerCase());return n?{fieldName:n.name,sortOrder:"desc"===r?.toLowerCase()?"desc":"asc"}:null}).filter(e=>null!=e)}function K(e,t,r){const n=j(r,t);if(n?.length)return n;if(!e){const e=t.find(e=>e.name.toLocaleLowerCase()===W.toLocaleLowerCase());return e?[{fieldName:e.name,sortOrder:"asc"}]:null}const o=t.find(t=>t.name.toLowerCase()===e.trim().toLowerCase());return o?[{fieldName:o.name,sortOrder:"asc"}]:null}export{l as appendPrefixAndSuffix,z as convertGeographicToWebMercator,D as createCameraOrientation,W as defaultSequenceOrderField,I as getArcGISServerUrl,c as getEffectiveElevationSource,N as getMetersPerUnitOfSR,L as isOrientationAccuracy,m as orientedImageryTypeMap,C as padAccuracyArray,K as parseSequenceOrderFields,a as processElevationSource,u as timeIntervalUnitTypeMap,d as transformersRegistry,f as verticalMeasurementTypeMap};
