/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { CodeGeneratingComponentRendererHandlerEmitter } from "./CodeGeneratingComponentRendererHandlerEmitter";
import { markType } from "./type";
import { CodeGeneratingRegexHelper } from "./CodeGeneratingRegexHelper";
import { stringReplace, stringStartsWith, stringEndsWith } from "./string";
/**
 * @hidden
 */
export let TSCodeGeneratingComponentRendererHandlerEmitter = /*@__PURE__*/ (() => {
    class TSCodeGeneratingComponentRendererHandlerEmitter extends CodeGeneratingComponentRendererHandlerEmitter {
        constructor(a, b, c) {
            super(a, b);
            this.l = 0;
            this.l = c;
        }
        get m() {
            switch (this.l) {
                case 1: return "angular";
                case 2: return "react";
                case 3: return "webcomponents";
            }
            return "";
        }
        get n() {
            switch (this.l) {
                case 1: return "Igx";
                case 2: return "Igr";
                case 3: return "Igc";
            }
            return "";
        }
        k(a, b) {
            super.k(a, b);
            let c = new CodeGeneratingRegexHelper("import {([^}]+)}\\s+from\\s+['\"]([^'\"]+)['\"]");
            c.b(b, (d, e, f) => {
                let g = d(1);
                let h = d(2);
                h = stringReplace(h, "webcomponents", this.m);
                h = stringReplace(h, "react", this.m);
                h = stringReplace(h, "angular", this.m);
                let i = g.split(',');
                for (let k = 0; k < i.length; k++) {
                    let j = i[k];
                    let l = j.trim();
                    if (stringStartsWith(l, "Igc")) {
                        l = this.n + l.substr(3);
                    }
                    if (stringStartsWith(l, "Igr")) {
                        l = this.n + l.substr(3);
                    }
                    if (stringStartsWith(l, "Igx")) {
                        l = this.n + l.substr(3);
                    }
                    if (stringStartsWith(l, "Igr") && stringEndsWith(l, "Component")) {
                        l = l.substr(0, l.length - ("Component").length);
                    }
                    a.addPackageImport(h.trim(), l.trim());
                }
                return null;
            });
        }
        i(a) {
            return a;
        }
    }
    TSCodeGeneratingComponentRendererHandlerEmitter.$t = markType(TSCodeGeneratingComponentRendererHandlerEmitter, 'TSCodeGeneratingComponentRendererHandlerEmitter', CodeGeneratingComponentRendererHandlerEmitter.$);
    return TSCodeGeneratingComponentRendererHandlerEmitter;
})();
