/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{zeroDegrees as t,createScalar as e,zeroSquareMeters as a,toUnit as r,createArea as n,zeroMeters as i,createLength as o,createAngle as s}from"../../../../core/quantity.js";import{formatLongitudeDecimalDegreesForInputMode as u,parseLongitude as l,formatLatitudeDecimalDegreesForInputMode as c,parseLatitude as f,makeQuantityParser as m,sanitizeAngle as p}from"./parsingAndFormattingUtils.js";import{TooltipField as g}from"./TooltipField.js";import{TooltipFieldElevation as d}from"./TooltipFieldElevation.js";import{TooltipFieldOrientation as h}from"./TooltipFieldOrientation.js";import{TooltipFieldSize as b}from"./TooltipFieldSize.js";import{getNormalizedDirection as v}from"../../../support/angularMeasurementUtils.js";function I(e){const a=t=>t.inputUnitInfos.angle.unit,n=t=>t.sketchOptions.values.effectiveDirectionMode;return new g({name:"direction",actual:t,parse:m({createQuantity:(t,e)=>s(t,a(e),"geographic"),sanitize:p}),format:(t,e)=>{const a=n(e),r=v(t,a);switch(a){case"absolute":return e.formatters.direction(r);case"relative":return e.formatters.directionRelative(r);case"relative-bilateral":return e.formatters.directionRelativeBilateral(r)}},formatForInputMode:(t,e)=>{const i=v(t,n(e));return e.formatters.scalar(r(i,a(e)))},suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>{const e=n(t),{absolute:a,relative:r}=t.messages.sketch.direction;switch(e){case"absolute":return a;case"relative":case"relative-bilateral":return r}},...e})}function y(t){const e=t=>t.inputUnitInfos.length.unit;return new g({name:"distance",actual:i,parse:m({createQuantity:(t,a)=>o(Math.max(t,0),e(a))}),format:(t,e)=>e.formatters.length(t),formatForInputMode:(t,a)=>a.formatters.scalar(r(t,e(a))),suffix:t=>t.inputUnitInfos.length.abbreviation,title:t=>t.messages.sketch.distance,...t})}function w(t){return y({format:(t,e)=>e.formatters.totalLength(t),title:t=>t.messages.sketch.totalLength,readOnly:!0,...t})}function F(t){return y({...t})}function U(t){const e=t=>t.inputUnitInfos.length.unit;return y({...t,parse:m({createQuantity:(t,a)=>o(t,e(a))}),format:(t,e)=>e.formatters.lengthRelative(t)})}function x(t){return new d(t)}function M(t){return new h(t)}function k(t){return new b(t)}function j(t){return z("scale",{name:"scale",actual:null,parse:m({createQuantity:t=>e(Math.abs(t))}),...t})}function Q(t){const e=t=>t.inputUnitInfos.area.unit;return new g({name:"area",actual:a,parse:m({createQuantity:(t,a)=>n(t,e(a))}),format:(t,e)=>e.formatters.area(t),formatForInputMode:(t,a)=>a.formatters.scalar(r(t,e(a))),suffix:t=>t.inputUnitInfos.area.abbreviation,title:t=>t.messages.sketch.area,readOnly:!0,...t})}function D(e){return new g({name:"x",actual:t,parse:l,format:(t,e)=>e.formatters.longitudeDecimalDegrees(t),formatForInputMode:t=>u(t),suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>t.messages.sketch.longitude,...e})}function O(e){return new g({name:"y",actual:t,parse:f,format:(t,e)=>e.formatters.latitudeDecimalDegrees(t),formatForInputMode:t=>c(t),suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>t.messages.sketch.latitude,...e})}function T(t){return z("x",{name:"x",...t})}function R(t){return z("y",{name:"y",...t})}function z(t,a){return new g({actual:e(0),parse:m({createQuantity:t=>e(t)}),format:(t,e)=>e.formatters.scalar(t),formatForInputMode:(t,e)=>e.formatters.scalar(t),title:e=>e.messages.sketch[t],...a})}export{Q as makeAreaField,I as makeDirectionField,F as makeDistanceField,x as makeElevationField,O as makeLatitudeField,y as makeLengthField,D as makeLongitudeField,M as makeOrientationField,U as makeRelativeDistanceField,j as makeScaleField,k as makeSizeField,w as makeTotalLengthField,T as makeXField,R as makeYField};
