import * as tslib_1 from "tslib";
import { EventEmitter, Output } from '@angular/core';
import { delegateCombine } from './type';
import { ItfConverter as ItfConverter_internal } from "./ItfConverter";
import { IgxAsyncCompletedEventArgs } from './igx-async-completed-event-args';
import { Uri } from './Uri';
/**
 * Class for converting Itf files into enumerable triangulations.
*/
export class IgxTriangulationDataSource {
    constructor() {
        this._zoneRunner = null;
        this._importCompleted = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    createImplementation() {
        return new ItfConverter_internal();
    }
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    _provideImplementation(i) {
        this._implementation = i;
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    /**
     * Gets the string path specifying the location of the Itf file.
    */
    get source() {
        if (this.i.source == null)
            return null;
        return this.i.source.value;
    }
    /**
     * Sets the string path specifying the location of the Itf file.
    */
    set source(v) {
        if (v == null) {
            this.i.source = null;
        }
        else {
            this.i.source = new Uri(0, v);
        }
    }
    /**
    * Gets the point data.
    */
    getPointData() {
        let iv = this.i.getPointData();
        return iv._inner;
    }
    /**
    * Gets the triangle data.
    */
    getTriangleData() {
        let iv = this.i.getTriangleData();
        return iv._inner;
    }
    _runInZone(act) {
        if (this._zoneRunner != null) {
            this._zoneRunner(act);
        }
        else {
            act();
        }
    }
    /**
     * Event raised when the import operation has completed
    */
    get importCompleted() {
        if (this._importCompleted == null) {
            this._importCompleted = new EventEmitter();
            this.i.importCompleted = delegateCombine(this.i.importCompleted, (o, e) => {
                this._runInZone(() => {
                    let outerArgs = new IgxAsyncCompletedEventArgs();
                    outerArgs._provideImplementation(e);
                    if (this.beforeImportCompleted) {
                        this.beforeImportCompleted(this, outerArgs);
                    }
                    this._importCompleted.emit({
                        sender: this,
                        args: outerArgs
                    });
                });
            });
        }
        return this._importCompleted;
    }
}
tslib_1.__decorate([
    Output(),
    tslib_1.__metadata("design:type", EventEmitter),
    tslib_1.__metadata("design:paramtypes", [])
], IgxTriangulationDataSource.prototype, "importCompleted", null);
//# sourceMappingURL=igx-triangulation-data-source.js.map