var _checkActive;
import { __classPrivateFieldGet } from "tslib";
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { ZuiPermissionService } from './index.service';
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "./index.service";
export class ZuiPermissionGuard {
    constructor(router, zuiPermissionService) {
        this.router = router;
        this.zuiPermissionService = zuiPermissionService;
        _checkActive.set(this, (activatedRoute, state) => {
            const { isDisable, permission, notFoundPage } = this.zuiPermissionService;
            if (isDisable)
                return true;
            const permissionKey = activatedRoute.data.permission;
            if (!permission || permission[permissionKey])
                return true;
            if (notFoundPage)
                this.router.navigate(notFoundPage.commands, notFoundPage.extras);
            // this.router.navigate(['error', '404'])
            return false;
        });
    }
    canActivate(activatedRoute, state) {
        return __classPrivateFieldGet(this, _checkActive).call(this, activatedRoute, state);
    }
    canActivateChild(activatedRoute, state) {
        return __classPrivateFieldGet(this, _checkActive).call(this, activatedRoute, state);
    }
}
_checkActive = new WeakMap();
ZuiPermissionGuard.ɵprov = i0.ɵɵdefineInjectable({ factory: function ZuiPermissionGuard_Factory() { return new ZuiPermissionGuard(i0.ɵɵinject(i1.Router), i0.ɵɵinject(i2.ZuiPermissionService)); }, token: ZuiPermissionGuard, providedIn: "root" });
ZuiPermissionGuard.decorators = [
    { type: Injectable, args: [{ providedIn: 'root' },] }
];
ZuiPermissionGuard.ctorParameters = () => [
    { type: Router },
    { type: ZuiPermissionService }
];
//# sourceMappingURL=index.guard.js.map