import * as i1 from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
import * as i0 from '@angular/core';
import { PLATFORM_ID, Injectable, Inject } from '@angular/core';
import { MiddlewareEnum } from '@testlocallibrary/shared-kernel/models/enums';
import { isPlatformBrowser } from '@angular/common';
import * as i2 from 'ngx-cookie-service';

class MainApiActionService {
    constructor(http, cookie, platformId) {
        this.http = http;
        this.cookie = cookie;
        this.platformId = platformId;
        this.url = `${MiddlewareEnum.Engine_Host}${MiddlewareEnum.ScenrioBaseManagement}`;
        this.isBrowser = isPlatformBrowser(platformId);
    }
    post(actionBase) {
        if (this.isBrowser) {
            const afsrcCookie = this.cookie.get('afsrc');
            const aftokenCookie = this.cookie.get('afftoken');
            const af_idCookie = this.cookie.get('af_id');
            const httpOptions = {
                headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
            };
            if (afsrcCookie != null && aftokenCookie != null && af_idCookie != null) {
                actionBase.afsrc = afsrcCookie;
                actionBase.afftoken = aftokenCookie;
                actionBase.af_id = af_idCookie;
            }
            let body = JSON.stringify(actionBase);
            return this.http.post(this.url, body, httpOptions);
        }
    }
    postRedirect_url(url) {
        const httpOptions = {
            headers: new HttpHeaders({
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Headers': '*',
                'Accept': '*/*'
            })
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MainApiActionService, deps: [{ token: i1.HttpClient }, { token: i2.CookieService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MainApiActionService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MainApiActionService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.CookieService }, { type: Object, decorators: [{
                    type: Inject,
                    args: [PLATFORM_ID]
                }] }]; } });

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

export { MainApiActionService };
//# sourceMappingURL=testlocallibrary-shared-kernel-services-main-api-action.mjs.map
