/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{numericHash as t}from"../../../../core/string.js";import{isBarcodeScannerInput as n,isComboBoxInput as e,isRadioButtonsInput as i,isDatePickerInput as r,isDateTimePickerInput as o,isDateTimeOffsetPickerInput as $,isSwitchInput as u,isTextAreaInput as c,isTextBoxInput as s,isTimePickerInput as l,isMultipleChoiceInput as m}from"../../../../form/elements/inputs/inputUtils.js";import{isFieldElementTemplate as a,isGroupElementTemplate as f,isRelationshipElementTemplate as p,isTextElementTemplate as g,isAttachmentElementTemplate as d,isUtilityNetworkAssociationsElementTemplate as S,isExcludedFromSharedForm as h}from"./templateUtils.js";const y="",O="num:";function x(n){return a(n)?t(C(n)).toString():f(n)?t(N(n)).toString():p(n)?t(j(n)).toString():g(n)?t(J(n)).toString():d(n)?t(V(n)).toString():S(n)?t(v(n)).toString():t(JSON.stringify(n)).toString()}function C(t){return`${w(t)}.${D(t.field)}.${I(t.domain)}.${t.hint??y}.${A(t.input)}`}function N(t){const n=T(t);let e=y;for(const i of t.elements)h(i)||(e+="."+x(i).toString());return`${n}${e}`}function b(n){return t(T(n)).toString()}function T(t){return w(t)+`.${t.initialState}`}function j(t){const{displayCount:n,displayType:e,relationshipId:i}=t;return`${w(t)}.${n}.${e}.${i}.${U(t.orderByFields??[])}`}function J(t){const n=w(t),{compiledText:e}=t;return`${n}.${e??y}`}function V(t){return`${w(t)}.${t.allowUserRename}.${t.attachmentKeyword??y}.${t.displayFilename}.${F(t.input)}.${t.maxAttachmentCount??y}.${t.minAttachmentCount??y}.${t.useOriginalFilename}`}function v(t){return`${w(t)}.${L(t.associationTypes)}`}function w(t){return`${t.label??y}.${t.description??y}.${t.layerTimeZone??y}`}function A(t){if(!t)return y;const{type:a}=t;if(n(t))return a??y;if(e(t)||i(t)){const{showNoValueOption:n}=t;return`${a}.${n}.${t.noValueOptionLabel??y}`}if(r(t))return`${a}.${R(t)}`;if(o(t)){const n=t.min?.getTime(),e=t.max?.getTime(),{includeTime:i}=t;return`${a}.${n}.${e}.${i}`}if($(t)){const n=R(t),{includeTimeOffset:e,timeResolution:i}=t;return`${a}.${n}.${e}.${i}`}if(u(t)){const{offValue:n,onValue:e}=t;return`${a}.${Z(n)}.${Z(e)}`}if(c(t)||s(t)){return`${a}.${t.minLength?.toString()??y}.${t.maxLength?.toString()??y}`}if(l(t)){const n=R(t),{timeResolution:e}=t;return`${a}.${n}.${e}`}if(m(t)){return`${a}.${R({min:t.minimumChoices?.toString(),max:t.maximumChoices?.toString()})}.${t.choiceDelimiter??y}.${t.includeSelectAllChoices}.${t.otherChoice?.fieldName??y}.${t.otherChoice?.label??y}.${t.otherChoice?.hint??y}.${B(t)}`}return JSON.stringify(t)}function F(t){return t?JSON.stringify(t.toJSON()):y}function L(t){return t.map(t=>JSON.stringify(t.toJSON())).sort().join(".")}function R(t){return`${t.min??y}.${t.max??y}`}function U(t){return t.map(({field:t,order:n})=>`${t}.${n}`).sort().join(".")}function B(t){return(t.choices??[]).map(({label:t,value:n})=>`${t}.${n}`).sort().join(".")}function D(t){const n=t.name,e=t.alias??y;return`${n}.${e===n?y:e}.${t.nullable}.${t.type}.${t.length??y}.${t.description??y}.${t.editable}.${t.visible}`}function I(t){return t?"coded-value"===t.type?K(t):"range"===t.type?k(t):JSON.stringify(t):y}function K(t){const{type:n}=t;return`${n}.${t.codedValues.map(({code:t,name:n})=>`${Z(t)}.${n}`).sort().join(".")}`}function Z(t){return"number"==typeof t?`${O}${t}`:t}function k(t){const{maxValue:n,minValue:e,type:i}=t;return`${i}.${e}.${n}`}export{x as hashElementTemplate,b as hashGroupElementTemplateWithoutChildren};
