import { IotizeConfigModel } from './model/iotize-config-model';
/**
 * Utility class to create iotize config model from XML or JSON file
 */
export class IotizeConfigFactory {
    /**
     * Create IotizeConfigModel from a XML string
     * @param xml
     */
    static fromXML(xml) {
        throw new Error(`Add import to @iotize/tap/config/iotize-studio/parser/xml to create configuration model from XML file`);
    }
    /**
     * Create IotizeConfigModel from a JSON string
     * @param json
     */
    static fromJson(json) {
        return new IotizeConfigModel(JSON.parse(json));
    }
    /**
     * Build and IotizeConfigModel
     * Input can either be
     * - A json string
     * - A XML string
     * - A JSON Object
     *
     * TODO create test
     * @param data
     */
    static create(data) {
        if (typeof data === 'string') {
            data.trim();
            if (data.length === 0) {
                throw new Error('Cannot create configuration from empty data');
            }
            if (data[0] === '{') {
                return IotizeConfigFactory.fromJson(data);
            }
            else {
                return IotizeConfigFactory.fromXML(data);
            }
        }
        else {
            return new IotizeConfigModel(data);
        }
    }
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW90aXplLWNvbmZpZy1mYWN0b3J5LmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGlvdGl6ZS90YXAvY29uZmlnL2lvdGl6ZS1zdHVkaW8vIiwic291cmNlcyI6WyJsaWIvaW90aXplLWNvbmZpZy1mYWN0b3J5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFOztHQUVHO0FBQ0gsTUFBTSxPQUFPLG1CQUFtQjtJQUM1Qjs7O09BR0c7SUFDSCxNQUFNLENBQUMsT0FBTyxDQUFDLEdBQVc7UUFDdEIsTUFBTSxJQUFJLEtBQUssQ0FDWCx1R0FBdUcsQ0FDMUcsQ0FBQztJQUNOLENBQUM7SUFFRDs7O09BR0c7SUFDSCxNQUFNLENBQUMsUUFBUSxDQUFDLElBQVk7UUFDeEIsT0FBTyxJQUFJLGlCQUFpQixDQUFDLElBQUksQ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