import { NominatimClient } from './nominatim';
export class GeocodeController {
    constructor() {
        this.defaultClient = 'nominatim';
    }
    async forward(options, clientOptions) {
        let client = this.getClient(options.client);
        let res = await client.forward(options, clientOptions);
        this.glForwardGeocode.emit({
            options: options,
            response: res
        });
        return res;
    }
    async reverse(options, clientOptions) {
        let client = this.getClient(options.client);
        let res = await client.reverse(options, clientOptions);
        this.glReverseGeocode.emit({
            options: options,
            response: res
        });
        return res;
    }
    getClient(id) {
        return GeocodeController.clients[id || this.defaultClient];
    }
    static addClient(id, service) {
        GeocodeController.clients[id] = service;
    }
    static get is() { return "gl-geocode-controller"; }
    static get properties() { return {
        "defaultClient": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "default-client",
            "reflect": false,
            "defaultValue": "'nominatim'"
        }
    }; }
    static get events() { return [{
            "method": "glForwardGeocode",
            "name": "glForwardGeocode",
            "bubbles": true,
            "cancelable": true,
            "composed": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "complexType": {
                "original": "any",
                "resolved": "any",
                "references": {}
            }
        }, {
            "method": "glReverseGeocode",
            "name": "glReverseGeocode",
            "bubbles": true,
            "cancelable": true,
            "composed": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "complexType": {
                "original": "any",
                "resolved": "any",
                "references": {}
            }
        }]; }
    static get methods() { return {
        "forward": {
            "complexType": {
                "signature": "(options: ForwardGeocodeOptions, clientOptions?: any) => Promise<any>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    },
                    "ForwardGeocodeOptions": {
                        "location": "import",
                        "path": "./geocode-interface"
                    }
                },
                "return": "Promise<any>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        },
        "reverse": {
            "complexType": {
                "signature": "(options: ReverseGeocodeOptions, clientOptions?: any) => Promise<any>",
                "parameters": [{
                        "tags": [],
                        "text": ""
                    }, {
                        "tags": [],
                        "text": ""
                    }],
                "references": {
                    "Promise": {
                        "location": "global"
                    },
                    "ReverseGeocodeOptions": {
                        "location": "import",
                        "path": "./geocode-interface"
                    }
                },
                "return": "Promise<any>"
            },
            "docs": {
                "text": "",
                "tags": []
            }
        }
    }; }
}
GeocodeController.clients = {};
GeocodeController.addClient('nominatim', new NominatimClient());
