/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../core/Error","../../core/maybe","./support/utils","../support/utils","../support/adapters/support/layerUtils"],(function(e,r,s,i,a,n){"use strict";function t(e){return u.apply(this,arguments)}function u(){return(u=e._asyncToGenerator((function*(e){if(!e||!e.layer||!e.field&&!e.valueExpression)throw new r("unique-values:missing-parameters","'layer' and 'field' or 'valueExpression' parameters are required");const t=e.valueExpression||e.sqlExpression,u=t&&!e.sqlExpression;if(t)if(u){if(!e.view)throw new r("unique-values:missing-parameters","View is required when 'valueExpression' is specified")}else if(!e.valueExpression)throw new r("unique-values:missing-parameters","'valueExpression' parameters are required");const{layer:l,...p}=e,o=n.createLayerAdapter(l,n.defaultSupportedLayerTypes),d={layerAdapter:o,...p};if(!o)throw new r("unique-values:invalid-parameters","'layer' must be one of these types: "+n.getLayerTypeLabels(n.defaultSupportedLayerTypes).join(", "));const y=s.isSome(d.signal)?{signal:d.signal}:null;yield o.load(y);const f=yield a.getFieldsList({field:d.field,valueExpression:d.valueExpression}),c=i.verifyBasicFieldValidity(o,f,"unique-values:invalid-parameters");if(c)throw c;return d}))).apply(this,arguments)}function l(e){return p.apply(this,arguments)}function p(){return(p=e._asyncToGenerator((function*(e){const{layerAdapter:r,...s}=yield t(e);return r.uniqueValues(s)}))).apply(this,arguments)}return l}));
