/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"../../PopupTemplate.js";import r from"../../core/Error.js";import{fetchMessageBundle as s}from"../../intl/messages.js";import{hasNormalizedField as a,getFieldAndExpressionInfos as n,getContentFromFieldInfos as t}from"./support/utils.js";async function o(e){const{layer:s,renderer:a}=e;await s.load();const n=a??("renderer"in s?s.renderer:void 0);if("class-breaks"!==n?.type)throw new r("class-breaks-popup:invalid-parameters","renderer.type must be 'class-breaks'");return{layer:s,renderer:n}}async function i(r,s,a="divide"){const{fieldInfos:o,expressionInfos:i}=await n({renderer:r,layer:s,normFieldExpressionTemplate:a});return new e({content:await t(s,{fieldInfos:o,expressionInfos:i}),fieldInfos:o,expressionInfos:i})}async function p(e){const[{renderer:r,layer:n},t]=await Promise.all([o(e),s("esri/smartMapping/t9n/smartMapping")]),p={name:"class-breaks",title:t.classBreaks,value:await i(r,n)},l=[];return a(r)&&l.push({name:"class-breaks-percent",title:t.classBreaksNormFieldAsPercent,value:await i(r,n,"percentage")}),{primaryTemplate:p,secondaryTemplates:l}}export{p as getTemplates};
