import { AXComponent } from '@acorex/cdk/common';
import { AXButtonComponent, AXButtonModule } from '@acorex/components/button';
import { AXDecoratorGenericComponent, AXDecoratorIconComponent, AXDecoratorClearButtonComponent, AXDecoratorModule } from '@acorex/components/decorators';
import { AXTextBoxComponent, AXTextBoxModule } from '@acorex/components/text-box';
import * as i0 from '@angular/core';
import { signal, Injectable, inject, effect, ChangeDetectionStrategy, ViewEncapsulation, Component, afterNextRender, input, output, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { AXSelectionListComponent, AXSelectionListModule } from '@acorex/components/selection-list';
import { AXTextAreaComponent, AXTextAreaModule } from '@acorex/components/text-area';
import { AXSelectBoxComponent, AXSelectBoxModule } from '@acorex/components/select-box';
import { AXTabsComponent, AXTabItemComponent, AXTabContentDirective, AXTabsModule } from '@acorex/components/tabs';

class AXRestApiGeneratorService {
    constructor() {
        this.outPutJSON = signal({
            url: '',
            method: 'GET',
            headers: {
                Authorization: '',
                ContentType: '',
            },
            queries: [{}],
            body: '',
        }, ...(ngDevMode ? [{ debugName: "outPutJSON" }] : []));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorService, decorators: [{
            type: Injectable
        }] });

class AXQueryParamsComponent {
    constructor() {
        this.service = inject(AXRestApiGeneratorService);
        this.queryParamsArray = signal(this.service.outPutJSON().queries, ...(ngDevMode ? [{ debugName: "queryParamsArray" }] : []));
        this.#eff = effect(() => {
            this.service.outPutJSON.update((prev) => ({ ...prev, queries: this.queryParamsArray() }));
        }, ...(ngDevMode ? [{ debugName: "#eff" }] : []));
    }
    addQueryParamsHandler() {
        this.queryParamsArray.update((prev) => [...prev, { tempId: String(Math.random()) }]);
    }
    removeQueryParamsHandler(id) {
        this.queryParamsArray.update((prev) => {
            const copy = [...prev];
            const filter = copy.filter((item) => item.tempId !== id);
            return filter;
        });
    }
    queryParamsValueHandler(e, id) {
        this.queryParamsArray.update((prev) => {
            const copy = [...prev];
            const find = copy.find((item) => item.tempId === id);
            Object.keys(find).forEach((key) => {
                if (key !== 'tempId') {
                    find[key] = e.value;
                }
            });
            return copy;
        });
    }
    queryParamsKeyHandler(e, id) {
        this.queryParamsArray.update((prev) => {
            const copy = [...prev];
            const find = copy.find((item) => item.tempId === id);
            Object.keys(find).forEach((key) => {
                if (key !== 'tempId') {
                    delete find[key];
                }
            });
            find[e.value] = '';
            return copy;
        });
    }
    #eff;
    setInitialState(item, type) {
        for (const [key, value] of Object.entries(item)) {
            if (key !== 'tempId') {
                if (type === 'key') {
                    return key;
                }
                else if (type === 'value') {
                    return value;
                }
            }
        }
        return '';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXQueryParamsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: AXQueryParamsComponent, isStandalone: true, selector: "ax-query-params", providers: [{ provide: AXComponent, useExisting: AXQueryParamsComponent }], ngImport: i0, template: "<div class=\"ax-query-params-container\">\n  <div class=\"ax-query-params-header\">\n    <ax-text>Query Params</ax-text>\n    <ax-button look=\"blank\" class=\"ax-sm\" color=\"primary\" (onClick)=\"addQueryParamsHandler()\">\n      <ax-icon icon=\"ax-icon ax-icon-plus\"></ax-icon>\n    </ax-button>\n  </div>\n\n  <div class=\"ax-query-params-value-container\">\n    @for (item of queryParamsArray(); track item) {\n      <div class=\"ax-query-params-value\">\n        <ax-text-box\n          (onValueChanged)=\"queryParamsKeyHandler($event, item.tempId)\"\n          placeholder=\"key\"\n          [ngModel]=\"setInitialState(item, 'key')\"\n        ></ax-text-box>\n        <ax-text-box\n          (onValueChanged)=\"queryParamsValueHandler($event, item.tempId)\"\n          placeholder=\"value\"\n          [ngModel]=\"setInitialState(item, 'value')\"\n        ></ax-text-box>\n        <ax-button look=\"blank\" class=\"ax-md\" color=\"danger\" (onClick)=\"removeQueryParamsHandler(item.tempId)\">\n          <ax-prefix>\n            <ax-icon icon=\"ax-icon ax-icon-trash\"></ax-icon>\n          </ax-prefix>\n        </ax-button>\n      </div>\n    }\n  </div>\n</div>\n", styles: ["ax-query-params{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}ax-query-params .ax-query-params-container{width:100%}ax-query-params .ax-query-params-value-container{display:flex;flex-direction:column;gap:.5rem}ax-query-params .ax-query-params-value-container .ax-query-params-value{display:flex;gap:.5rem;align-items:center}ax-query-params .ax-query-params-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:.5rem}\n"], dependencies: [{ kind: "component", type: AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "component", type: AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "component", type: AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: AXTextBoxComponent, selector: "ax-text-box", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "id", "placeholder", "maxLength", "allowNull", "type", "autoComplete", "look", "maskPattern", "customTokens", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress", "onMaskChanged"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXQueryParamsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-query-params', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [AXDecoratorGenericComponent, AXButtonComponent, AXDecoratorIconComponent, AXTextBoxComponent, FormsModule], providers: [{ provide: AXComponent, useExisting: AXQueryParamsComponent }], template: "<div class=\"ax-query-params-container\">\n  <div class=\"ax-query-params-header\">\n    <ax-text>Query Params</ax-text>\n    <ax-button look=\"blank\" class=\"ax-sm\" color=\"primary\" (onClick)=\"addQueryParamsHandler()\">\n      <ax-icon icon=\"ax-icon ax-icon-plus\"></ax-icon>\n    </ax-button>\n  </div>\n\n  <div class=\"ax-query-params-value-container\">\n    @for (item of queryParamsArray(); track item) {\n      <div class=\"ax-query-params-value\">\n        <ax-text-box\n          (onValueChanged)=\"queryParamsKeyHandler($event, item.tempId)\"\n          placeholder=\"key\"\n          [ngModel]=\"setInitialState(item, 'key')\"\n        ></ax-text-box>\n        <ax-text-box\n          (onValueChanged)=\"queryParamsValueHandler($event, item.tempId)\"\n          placeholder=\"value\"\n          [ngModel]=\"setInitialState(item, 'value')\"\n        ></ax-text-box>\n        <ax-button look=\"blank\" class=\"ax-md\" color=\"danger\" (onClick)=\"removeQueryParamsHandler(item.tempId)\">\n          <ax-prefix>\n            <ax-icon icon=\"ax-icon ax-icon-trash\"></ax-icon>\n          </ax-prefix>\n        </ax-button>\n      </div>\n    }\n  </div>\n</div>\n", styles: ["ax-query-params{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}ax-query-params .ax-query-params-container{width:100%}ax-query-params .ax-query-params-value-container{display:flex;flex-direction:column;gap:.5rem}ax-query-params .ax-query-params-value-container .ax-query-params-value{display:flex;gap:.5rem;align-items:center}ax-query-params .ax-query-params-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:.5rem}\n"] }]
        }] });

class AXRequestBodyComponent {
    constructor() {
        this.service = inject(AXRestApiGeneratorService);
        this.value = signal(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
        this.selectedItem = signal({ id: null, text: '', placeHolder: '' }, ...(ngDevMode ? [{ debugName: "selectedItem" }] : []));
        this.#init = afterNextRender(() => {
            const type = this.service.outPutJSON().headers.ContentType;
            if (type) {
                switch (type) {
                    case 'text/plain':
                        this.value.set(1);
                        break;
                    case 'application/json':
                        this.value.set(2);
                        break;
                    case 'multipart/form-data':
                        this.value.set(3);
                        break;
                    case 'application/xml':
                        this.value.set(4);
                        break;
                }
            }
            else {
                this.value.set(2);
            }
        });
        this.items = [
            { id: 1, text: 'None', placeHolder: '' },
            { id: 2, text: 'Json', placeHolder: '{"key" : "value"}' },
            { id: 3, text: 'Form', placeHolder: 'key1=value1' },
            { id: 4, text: 'XML', placeHolder: '<data></data>' },
        ];
    }
    #init;
    bodyReqHandler(e) {
        const find = this.items.find((item) => item.id === e.value);
        this.selectedItem.set(find);
    }
    bodyTextHandler(e) {
        const type = this.selectedItem().text;
        let contentType;
        switch (type) {
            case 'None':
                contentType = 'text/plain';
                break;
            case 'Json':
                contentType = 'application/json';
                break;
            case 'Form':
                contentType = 'multipart/form-data';
                break;
            case 'XML':
                contentType = 'application/xml';
                break;
        }
        this.service.outPutJSON.update((prev) => ({ ...prev, body: e.value }));
        this.service.outPutJSON.update((prev) => {
            const copy = { ...prev };
            copy.headers.ContentType = contentType;
            return copy;
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRequestBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.3", type: AXRequestBodyComponent, isStandalone: true, selector: "ax-request-body", providers: [{ provide: AXComponent, useExisting: AXRequestBodyComponent }], ngImport: i0, template: "<ax-selection-list\n  [showControl]=\"true\"\n  look=\"solid\"\n  [items]=\"items\"\n  [(ngModel)]=\"value\"\n  (onValueChanged)=\"bodyReqHandler($event)\"\n>\n</ax-selection-list>\n<ax-text-area\n  [(ngModel)]=\"service.outPutJSON().body\"\n  (onValueChanged)=\"bodyTextHandler($event)\"\n  [placeholder]=\"selectedItem().placeHolder\"\n>\n</ax-text-area>\n", styles: ["ax-request-body{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}\n"], dependencies: [{ kind: "component", type: AXSelectionListComponent, selector: "ax-selection-list", inputs: ["id", "name", "disabled", "readonly", "tabIndex", "size", "value", "valueField", "textField", "disabledField", "readonlyField", "multiple", "direction", "customTemplate", "showControl", "items", "look"], outputs: ["onValueChanged", "onBlur", "onFocus"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: AXTextAreaComponent, selector: "ax-text-area", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "placeholder", "maxLength", "look", "rows", "allowResize", "showCounter", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRequestBodyComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-request-body', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [AXSelectionListComponent, FormsModule, AXTextAreaComponent], providers: [{ provide: AXComponent, useExisting: AXRequestBodyComponent }], template: "<ax-selection-list\n  [showControl]=\"true\"\n  look=\"solid\"\n  [items]=\"items\"\n  [(ngModel)]=\"value\"\n  (onValueChanged)=\"bodyReqHandler($event)\"\n>\n</ax-selection-list>\n<ax-text-area\n  [(ngModel)]=\"service.outPutJSON().body\"\n  (onValueChanged)=\"bodyTextHandler($event)\"\n  [placeholder]=\"selectedItem().placeHolder\"\n>\n</ax-text-area>\n", styles: ["ax-request-body{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}\n"] }]
        }] });

class AXRequestHeadersComponent {
    constructor() {
        this.service = inject(AXRestApiGeneratorService);
        this.headersArray = signal(this.filterUnnecessaryKey(), ...(ngDevMode ? [{ debugName: "headersArray" }] : []));
        this.#eff = effect(() => {
            this.service.outPutJSON.update((prev) => {
                const copy = { ...prev };
                const copyHeader = { Authorization: copy.headers.Authorization, ContentType: copy.headers.ContentType };
                copy.headers = copyHeader;
                this.headersArray().forEach((item) => {
                    Object.assign(copy.headers, item);
                });
                return copy;
            });
        }, ...(ngDevMode ? [{ debugName: "#eff" }] : []));
    }
    addHeadersHandler() {
        this.headersArray.update((prev) => [...prev, { tempId: String(Math.random()) }]);
    }
    removeHeadersHandler(id) {
        this.headersArray.update((prev) => {
            const copy = [...prev];
            const filter = copy.filter((item) => item.tempId !== id);
            return filter;
        });
    }
    headersValueHandler(e, id) {
        this.headersArray.update((prev) => {
            const copy = [...prev];
            const find = copy.find((item) => item.tempId === id);
            Object.keys(find).forEach((key) => {
                if (key !== 'tempId') {
                    find[key] = e.value;
                }
            });
            return copy;
        });
    }
    headersKeyHandler(e, id) {
        this.headersArray.update((prev) => {
            const copy = [...prev];
            const find = copy.find((item) => item.tempId === id);
            Object.keys(find).forEach((key) => {
                if (key !== 'tempId') {
                    delete find[key];
                }
            });
            find[e.value] = '';
            return copy;
        });
    }
    #eff;
    setInitialState(item, type) {
        for (const [key, value] of Object.entries(item)) {
            if (key !== 'tempId') {
                if (type === 'key') {
                    return key;
                }
                else if (type === 'value') {
                    return value;
                }
            }
        }
        return '';
    }
    filterUnnecessaryKey() {
        const allHeaders = { ...this.service.outPutJSON().headers };
        Object.keys(allHeaders).forEach((key) => {
            if (key === 'Authorization' || key === 'ContentType') {
                delete allHeaders[key];
            }
        });
        return [allHeaders];
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRequestHeadersComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: AXRequestHeadersComponent, isStandalone: true, selector: "ax-request-headers", providers: [{ provide: AXComponent, useExisting: AXRequestHeadersComponent }], ngImport: i0, template: "<div class=\"ax-headers-container\">\n  <div class=\"ax-headers-header\">\n    <ax-text>Headers</ax-text>\n    <ax-button look=\"blank\" class=\"ax-sm\" color=\"primary\" (onClick)=\"addHeadersHandler()\">\n      <ax-icon icon=\"ax-icon ax-icon-plus\"></ax-icon>\n    </ax-button>\n  </div>\n\n  <div class=\"ax-headers-value-container\">\n    @for (item of headersArray(); track item.tempId) {\n      <div class=\"ax-headers-value\">\n        <ax-text-box\n          [ngModel]=\"setInitialState(item, 'key')\"\n          (onValueChanged)=\"headersKeyHandler($event, item.tempId)\"\n          placeholder=\"key\"\n        ></ax-text-box>\n        <ax-text-box\n          [ngModel]=\"setInitialState(item, 'value')\"\n          (onValueChanged)=\"headersValueHandler($event, item.tempId)\"\n          placeholder=\"value\"\n        ></ax-text-box>\n        <ax-button look=\"blank\" class=\"ax-md\" color=\"danger\" (onClick)=\"removeHeadersHandler(item.tempId)\">\n          <ax-prefix>\n            <ax-icon icon=\"ax-icon ax-icon-trash\"></ax-icon>\n          </ax-prefix>\n        </ax-button>\n      </div>\n    }\n  </div>\n</div>\n", styles: ["ax-request-headers{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}ax-request-headers .ax-headers-container{width:100%}ax-request-headers .ax-headers-value-container{display:flex;flex-direction:column;gap:.5rem}ax-request-headers .ax-headers-value-container .ax-headers-value{display:flex;gap:.5rem;align-items:center}ax-request-headers .ax-headers-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:.5rem}\n"], dependencies: [{ kind: "component", type: AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "component", type: AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "component", type: AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: AXTextBoxComponent, selector: "ax-text-box", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "id", "placeholder", "maxLength", "allowNull", "type", "autoComplete", "look", "maskPattern", "customTokens", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress", "onMaskChanged"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRequestHeadersComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-request-headers', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [AXDecoratorGenericComponent, AXButtonComponent, AXDecoratorIconComponent, AXTextBoxComponent, FormsModule], providers: [{ provide: AXComponent, useExisting: AXRequestHeadersComponent }], template: "<div class=\"ax-headers-container\">\n  <div class=\"ax-headers-header\">\n    <ax-text>Headers</ax-text>\n    <ax-button look=\"blank\" class=\"ax-sm\" color=\"primary\" (onClick)=\"addHeadersHandler()\">\n      <ax-icon icon=\"ax-icon ax-icon-plus\"></ax-icon>\n    </ax-button>\n  </div>\n\n  <div class=\"ax-headers-value-container\">\n    @for (item of headersArray(); track item.tempId) {\n      <div class=\"ax-headers-value\">\n        <ax-text-box\n          [ngModel]=\"setInitialState(item, 'key')\"\n          (onValueChanged)=\"headersKeyHandler($event, item.tempId)\"\n          placeholder=\"key\"\n        ></ax-text-box>\n        <ax-text-box\n          [ngModel]=\"setInitialState(item, 'value')\"\n          (onValueChanged)=\"headersValueHandler($event, item.tempId)\"\n          placeholder=\"value\"\n        ></ax-text-box>\n        <ax-button look=\"blank\" class=\"ax-md\" color=\"danger\" (onClick)=\"removeHeadersHandler(item.tempId)\">\n          <ax-prefix>\n            <ax-icon icon=\"ax-icon ax-icon-trash\"></ax-icon>\n          </ax-prefix>\n        </ax-button>\n      </div>\n    }\n  </div>\n</div>\n", styles: ["ax-request-headers{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}ax-request-headers .ax-headers-container{width:100%}ax-request-headers .ax-headers-value-container{display:flex;flex-direction:column;gap:.5rem}ax-request-headers .ax-headers-value-container .ax-headers-value{display:flex;gap:.5rem;align-items:center}ax-request-headers .ax-headers-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:.5rem}\n"] }]
        }] });

class AXRestApiAuthComponent {
    constructor() {
        this.service = inject(AXRestApiGeneratorService);
        this.value = signal(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
        this.#init = afterNextRender(() => {
            const token = this.service.outPutJSON().headers.Authorization;
            if (token) {
                this.value.set(2);
            }
            else {
                this.value.set(1);
            }
        });
        this.selectedItem = signal({ id: null, text: '', placeHolder: '' }, ...(ngDevMode ? [{ debugName: "selectedItem" }] : []));
        this.items = [
            { id: 1, text: 'None', placeHolder: '' },
            { id: 2, text: 'Bearer Token', placeHolder: 'Token' },
        ];
    }
    #init;
    authTypeHandler(e) {
        const find = this.items.find((item) => item.id === e.value);
        this.selectedItem.set(find);
        if (e.value === 1) {
            this.service.outPutJSON.update((prev) => {
                const copy = { ...prev };
                copy.headers.Authorization = '';
                return copy;
            });
        }
    }
    authInputHandler(e) {
        this.service.outPutJSON.update((prev) => {
            const copy = { ...prev };
            copy.headers.Authorization = e.value;
            return copy;
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiAuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: AXRestApiAuthComponent, isStandalone: true, selector: "ax-rest-api-auth", providers: [{ provide: AXComponent, useExisting: AXRestApiAuthComponent }], ngImport: i0, template: "<ax-selection-list\n  [showControl]=\"true\"\n  look=\"solid\"\n  [items]=\"items\"\n  [(ngModel)]=\"value\"\n  (onValueChanged)=\"authTypeHandler($event)\"\n>\n</ax-selection-list>\n\n@if (selectedItem().text !== 'None') {\n  <ax-text-box\n    [(ngModel)]=\"service.outPutJSON().headers.Authorization\"\n    (onValueChanged)=\"authInputHandler($event)\"\n    [placeholder]=\"selectedItem().placeHolder\"\n  >\n  </ax-text-box>\n}\n", styles: ["ax-rest-api-auth{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}\n"], dependencies: [{ kind: "component", type: AXSelectionListComponent, selector: "ax-selection-list", inputs: ["id", "name", "disabled", "readonly", "tabIndex", "size", "value", "valueField", "textField", "disabledField", "readonlyField", "multiple", "direction", "customTemplate", "showControl", "items", "look"], outputs: ["onValueChanged", "onBlur", "onFocus"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: AXTextBoxComponent, selector: "ax-text-box", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "id", "placeholder", "maxLength", "allowNull", "type", "autoComplete", "look", "maskPattern", "customTokens", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress", "onMaskChanged"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiAuthComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-rest-api-auth', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [AXSelectionListComponent, FormsModule, AXTextBoxComponent], providers: [{ provide: AXComponent, useExisting: AXRestApiAuthComponent }], template: "<ax-selection-list\n  [showControl]=\"true\"\n  look=\"solid\"\n  [items]=\"items\"\n  [(ngModel)]=\"value\"\n  (onValueChanged)=\"authTypeHandler($event)\"\n>\n</ax-selection-list>\n\n@if (selectedItem().text !== 'None') {\n  <ax-text-box\n    [(ngModel)]=\"service.outPutJSON().headers.Authorization\"\n    (onValueChanged)=\"authInputHandler($event)\"\n    [placeholder]=\"selectedItem().placeHolder\"\n  >\n  </ax-text-box>\n}\n", styles: ["ax-rest-api-auth{display:flex;flex-direction:column;align-items:flex-start;justify-content:center}\n"] }]
        }] });

class AXRestApiGeneratorComponent {
    constructor() {
        this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : []));
        this.onValueChange = output();
        this.service = inject(AXRestApiGeneratorService);
        this.#init = afterNextRender(() => {
            if (this.value()) {
                this.service.outPutJSON.set(this.value());
            }
        });
        this.#eff = effect(() => {
            this.onValueChange.emit(this.service.outPutJSON());
        }, ...(ngDevMode ? [{ debugName: "#eff" }] : []));
    }
    #init;
    #eff;
    urlHandler(e) {
        this.service.outPutJSON.update((prev) => ({ ...prev, url: e.value }));
    }
    methodHandler(e) {
        this.service.outPutJSON.update((prev) => ({ ...prev, method: e.value }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.3", type: AXRestApiGeneratorComponent, isStandalone: true, selector: "ax-rest-api-generator", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onValueChange: "onValueChange" }, providers: [AXRestApiGeneratorService, { provide: AXComponent, useExisting: AXRestApiGeneratorComponent }], ngImport: i0, template: "<div class=\"ax-url-input-container\">\n  <ax-text-box [(ngModel)]=\"service.outPutJSON().url\" placeholder=\"URL\" (onValueChanged)=\"urlHandler($event)\">\n    <ax-clear-button></ax-clear-button>\n    <ax-prefix>\n      <ax-select-box\n        [(ngModel)]=\"service.outPutJSON().method\"\n        (onValueChanged)=\"methodHandler($event)\"\n        [dataSource]=\"['GET', 'POST', 'DELETE', 'PUT', 'PATCH']\"\n      >\n      </ax-select-box\n    ></ax-prefix>\n  </ax-text-box>\n</div>\n\n<ax-tabs [content]=\"cronTab\" look=\"with-line\" [fitParent]=\"true\" location=\"bottom\">\n  <ax-tab-item key=\"1\" text=\"Params\">\n    <ax-content> <ax-query-params></ax-query-params> </ax-content>\n  </ax-tab-item>\n  <ax-tab-item key=\"2\" text=\"Body\">\n    <ax-content><ax-request-body></ax-request-body></ax-content>\n  </ax-tab-item>\n  <ax-tab-item key=\"3\" text=\"Auth\">\n    <ax-content> <ax-rest-api-auth></ax-rest-api-auth></ax-content>\n  </ax-tab-item>\n  <ax-tab-item key=\"4\" text=\"Headers\">\n    <ax-content> <ax-request-headers></ax-request-headers></ax-content>\n  </ax-tab-item>\n</ax-tabs>\n\n<ng-template [axTabContent] #cronTab=\"axTabContent\"> </ng-template>\n", styles: ["ax-rest-api-generator{display:flex;flex-direction:column;gap:1rem;min-width:40rem}@media screen and (max-width: 1024px){ax-rest-api-generator{min-width:100%}}ax-rest-api-generator ax-select-box ax-dropdown-box{--ax-comp-editor-border-width: 0px !important}ax-rest-api-generator ax-select-box ax-dropdown-box.ax-editor-container{--ax-comp-editor-box-outline-width: 0}ax-rest-api-generator .ax-select-box{border:0}\n"], dependencies: [{ kind: "component", type: AXTextBoxComponent, selector: "ax-text-box", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "id", "placeholder", "maxLength", "allowNull", "type", "autoComplete", "look", "maskPattern", "customTokens", "class"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress", "onMaskChanged"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: AXDecoratorClearButtonComponent, selector: "ax-clear-button", inputs: ["icon"] }, { kind: "component", type: AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "component", type: AXSelectBoxComponent, selector: "ax-select-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "minValue", "maxValue", "value", "state", "name", "id", "type", "look", "multiple", "valueField", "textField", "disabledField", "textTemplate", "selectedItems", "isItemTruncated", "showItemTooltip", "itemHeight", "maxVisibleItems", "dataSource", "minRecordsForSearch", "caption", "itemTemplate", "selectedTemplate", "emptyTemplate", "loadingTemplate", "dropdownWidth", "searchBoxAutoFocus"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onOpened", "onClosed", "onItemSelected", "onItemClick"] }, { kind: "component", type: AXTabsComponent, selector: "ax-tabs", inputs: ["look", "location", "fitParent", "minWidth", "content"], outputs: ["onActiveTabChanged"] }, { kind: "component", type: AXTabItemComponent, selector: "ax-tab-item", inputs: ["disabled", "text", "key", "headerTemplate", "active"], outputs: ["disabledChange", "onClick", "onBlur", "onFocus", "activeChange"] }, { kind: "component", type: AXQueryParamsComponent, selector: "ax-query-params" }, { kind: "component", type: AXRequestBodyComponent, selector: "ax-request-body" }, { kind: "component", type: AXRestApiAuthComponent, selector: "ax-rest-api-auth" }, { kind: "component", type: AXRequestHeadersComponent, selector: "ax-request-headers" }, { kind: "directive", type: AXTabContentDirective, selector: "[axTabContent]", inputs: ["axTabContent"], exportAs: ["axTabContent"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-rest-api-generator', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [AXRestApiGeneratorService, { provide: AXComponent, useExisting: AXRestApiGeneratorComponent }], imports: [
                        AXTextBoxComponent,
                        FormsModule,
                        AXDecoratorClearButtonComponent,
                        AXDecoratorGenericComponent,
                        AXSelectBoxComponent,
                        AXTabsComponent,
                        AXTabItemComponent,
                        AXQueryParamsComponent,
                        AXRequestBodyComponent,
                        AXRestApiAuthComponent,
                        AXRequestHeadersComponent,
                        AXTabContentDirective,
                    ], template: "<div class=\"ax-url-input-container\">\n  <ax-text-box [(ngModel)]=\"service.outPutJSON().url\" placeholder=\"URL\" (onValueChanged)=\"urlHandler($event)\">\n    <ax-clear-button></ax-clear-button>\n    <ax-prefix>\n      <ax-select-box\n        [(ngModel)]=\"service.outPutJSON().method\"\n        (onValueChanged)=\"methodHandler($event)\"\n        [dataSource]=\"['GET', 'POST', 'DELETE', 'PUT', 'PATCH']\"\n      >\n      </ax-select-box\n    ></ax-prefix>\n  </ax-text-box>\n</div>\n\n<ax-tabs [content]=\"cronTab\" look=\"with-line\" [fitParent]=\"true\" location=\"bottom\">\n  <ax-tab-item key=\"1\" text=\"Params\">\n    <ax-content> <ax-query-params></ax-query-params> </ax-content>\n  </ax-tab-item>\n  <ax-tab-item key=\"2\" text=\"Body\">\n    <ax-content><ax-request-body></ax-request-body></ax-content>\n  </ax-tab-item>\n  <ax-tab-item key=\"3\" text=\"Auth\">\n    <ax-content> <ax-rest-api-auth></ax-rest-api-auth></ax-content>\n  </ax-tab-item>\n  <ax-tab-item key=\"4\" text=\"Headers\">\n    <ax-content> <ax-request-headers></ax-request-headers></ax-content>\n  </ax-tab-item>\n</ax-tabs>\n\n<ng-template [axTabContent] #cronTab=\"axTabContent\"> </ng-template>\n", styles: ["ax-rest-api-generator{display:flex;flex-direction:column;gap:1rem;min-width:40rem}@media screen and (max-width: 1024px){ax-rest-api-generator{min-width:100%}}ax-rest-api-generator ax-select-box ax-dropdown-box{--ax-comp-editor-border-width: 0px !important}ax-rest-api-generator ax-select-box ax-dropdown-box.ax-editor-container{--ax-comp-editor-box-outline-width: 0}ax-rest-api-generator .ax-select-box{border:0}\n"] }]
        }] });

const COMPONENT = [
    AXRestApiGeneratorComponent,
    AXQueryParamsComponent,
    AXRequestBodyComponent,
    AXRestApiAuthComponent,
    AXRequestHeadersComponent,
];
const MODULES = [
    AXTextBoxModule,
    AXDecoratorModule,
    AXSelectBoxModule,
    AXTabsModule,
    AXButtonModule,
    AXTextAreaModule,
    AXSelectionListModule,
    FormsModule,
];
class AXRestApiGeneratorModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorModule, imports: [AXTextBoxModule,
            AXDecoratorModule,
            AXSelectBoxModule,
            AXTabsModule,
            AXButtonModule,
            AXTextAreaModule,
            AXSelectionListModule,
            FormsModule, AXRestApiGeneratorComponent,
            AXQueryParamsComponent,
            AXRequestBodyComponent,
            AXRestApiAuthComponent,
            AXRequestHeadersComponent], exports: [AXRestApiGeneratorComponent,
            AXQueryParamsComponent,
            AXRequestBodyComponent,
            AXRestApiAuthComponent,
            AXRequestHeadersComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorModule, imports: [MODULES, COMPONENT] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRestApiGeneratorModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [...MODULES, ...COMPONENT],
                    exports: [...COMPONENT],
                    providers: [],
                }]
        }] });

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

export { AXQueryParamsComponent, AXRequestBodyComponent, AXRequestHeadersComponent, AXRestApiAuthComponent, AXRestApiGeneratorComponent, AXRestApiGeneratorModule, AXRestApiGeneratorService };
//# sourceMappingURL=acorex-components-rest-api-generator.mjs.map
