import{SCORE_FIELD as e,SCORE_FIELD_ORIGINAL as t}from"../../data/Feature.js";import{isArcGISGeocoder as r}from"../geocoding/utilities.js";import{GeocoderSearchProvider as s}from"./GeocoderSearchProvider.js";const a=.001;export class ArcGISGeocoderSearchProvider extends s{isSupported(e){return r(e)}async*_search(r,s,i){const[o]=r,{cancelToken:c,currentScale:n,initialSearchArea:u,outSpatialReference:l,maxResults:d}=i??{},f={cancelToken:c,searchPoint:n&&u?.extent?.center,searchArea:!n&&u,outFields:o.featureSettings.outFields,outSpatialReference:l,maxResults:d};if(!s)return;const p=s.replace(/^"*|"*$/g,"");let S=0,b=a;for await(const r of o.geocode(p,f)){if(r.attributes.get("Match_addr")===p)r.attributes.set(e,100),r.attributes.set(t,100);else{let s=r.attributes.get(e);s=s>99?99:s,r.attributes.set(e,s),r.attributes.set(t,s),s===S?(r.attributes.set(e,S-b),r.attributes.set(t,S-b),b+=a):(S=s,b=a)}yield r}}}