import * as i2 from '@angular/common';
import * as i0 from '@angular/core';
import { Directive, Optional, Inject, Attribute, Input, NgModule } from '@angular/core';
import * as i1 from '@angular/router';
import { RouterLink, RouterModule } from '@angular/router';
import { BASE_URL } from '@aztrix/sdk';
import { Capacitor } from '@capacitor/core';

class LinkDirective extends RouterLink {
    constructor(_baseUrl, router, route, tabIndexAttribute, renderer, el, locationStrategy) {
        super(router, route, tabIndexAttribute, renderer, el, locationStrategy);
        this._baseUrl = _baseUrl;
    }
    set axLink(commands) {
        if (window.location.origin.includes(this._baseUrl) || Capacitor.isNativePlatform()) {
            this.routerLink = commands;
        }
        else if (commands) {
            if (typeof commands === 'string') {
                this.href = this._baseUrl + commands;
            }
            else {
                this.href = this._baseUrl + commands.join('/');
            }
            super.ngOnChanges(null);
        }
    }
}
LinkDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LinkDirective, deps: [{ token: BASE_URL, optional: true }, { token: i1.Router }, { token: i1.ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i2.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
LinkDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.5", type: LinkDirective, selector: "a[axLink],area[axLink]", inputs: { axLink: "axLink" }, usesInheritance: true, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LinkDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'a[axLink],area[axLink]',
                }]
        }], ctorParameters: function () { return [{ type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [BASE_URL]
                }] }, { type: i1.Router }, { type: i1.ActivatedRoute }, { type: undefined, decorators: [{
                    type: Attribute,
                    args: ['tabindex']
                }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i2.LocationStrategy }]; }, propDecorators: { axLink: [{
                type: Input
            }] } });

class LinkModule {
}
LinkModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LinkModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
LinkModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.5", ngImport: i0, type: LinkModule, declarations: [LinkDirective], imports: [RouterModule], exports: [LinkDirective] });
LinkModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LinkModule, imports: [RouterModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: LinkModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [LinkDirective],
                    imports: [RouterModule],
                    exports: [LinkDirective],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { LinkDirective, LinkModule };
//# sourceMappingURL=aztrix-components-link.mjs.map
//# sourceMappingURL=aztrix-components-link.mjs.map
