/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{zeroDegrees as t,createScalar as e,zeroSquareMeters as a,toUnit as n,createArea as r,zeroMeters as i,createLength as o,createAngle as s}from"../../../../core/quantity.js";import{parseLongitude as u,formatLongitudeDecimalDegreesForInputMode as f,parseLatitude as c,formatLatitudeDecimalDegreesForInputMode as l,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 I}from"../../../support/angularMeasurementUtils.js";function v(e){const a=t=>t.inputUnitInfos.angle.unit,r=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=r(e),n=I(t,a);switch(a){case"absolute":return e.formatters.direction(n);case"relative":return e.formatters.directionRelative(n);case"relative-bilateral":return e.formatters.directionRelativeBilateral(n)}},formatForInputMode:(t,e)=>{const i=I(t,r(e));return e.formatters.scalar(n(i,a(e)))},suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>{const e=r(t),{absolute:a,relative:n}=t.messages.sketch.direction;switch(e){case"absolute":return a;case"relative":case"relative-bilateral":return n}},...e})}function y(t){const e=t=>t.inputUnitInfos.length.unit;return new g({name:t?.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(n(t,e(a))),suffix:t=>t.inputUnitInfos.length.abbreviation,title:t=>t.messages.sketch.distance,...t})}function U(t){const e=t=>t.inputUnitInfos.length.unit;return new g({name:t?.name??"radius",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(n(t,e(a))),suffix:t=>t.inputUnitInfos.length.abbreviation,title:t=>t.messages.sketch.radius,...t})}function w(t){return y({format:(t,e)=>e.formatters.totalLength(t),title:t=>t.messages.sketch.totalLength,readOnly:!0,...t})}function x(t){return y({...t})}function F(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 M(t){return new d(t)}function k(t){return new h(t)}function j(t){return new b(t)}function Q(t){return q("scale",{name:"scale",actual:null,parse:m({createQuantity:t=>e(Math.abs(t))}),...t})}function D(t){const e=t=>t.inputUnitInfos.area.unit;return new g({name:"area",actual:a,parse:m({createQuantity:(t,a)=>r(t,e(a))}),format:(t,e)=>e.formatters.area(t),formatForInputMode:(t,a)=>a.formatters.scalar(n(t,e(a))),suffix:t=>t.inputUnitInfos.area.abbreviation,title:t=>t.messages.sketch.area,readOnly:!0,...t})}function O(e){return new g({name:"x",actual:t,parse:u,format:(t,e)=>e.formatters.longitudeDecimalDegrees(t),formatForInputMode:t=>f(t),suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>t.messages.sketch.longitude,...e})}function T(e){return new g({name:"y",actual:t,parse:c,format:(t,e)=>e.formatters.latitudeDecimalDegrees(t),formatForInputMode:t=>l(t),suffix:t=>t.inputUnitInfos.angle.abbreviation,title:t=>t.messages.sketch.latitude,...e})}function R(t){return q("x",{name:"x",...t})}function z(t){return q("y",{name:"y",...t})}function L(t){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:t=>t.messages.sketch.scale,...t})}function q(t,e){return L({title:e=>e.messages.sketch[t],...e})}export{D as makeAreaField,v as makeDirectionField,x as makeDistanceField,M as makeElevationField,T as makeLatitudeField,y as makeLengthField,O as makeLongitudeField,k as makeOrientationField,U as makeRadiusField,F as makeRelativeDistanceField,L as makeScalarField,Q as makeScaleField,j as makeSizeField,w as makeTotalLengthField,R as makeXField,z as makeYField};
