import { IotizeConfigModel } from './model/iotize-config-model';
/**
 * Utility class to create iotize config model from XML or JSON file
 */
var IotizeConfigFactory = /** @class */ (function () {
    function IotizeConfigFactory() {
    }
    /**
     * Create IotizeConfigModel from a XML string
     * @param xml
     */
    IotizeConfigFactory.fromXML = function (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
     */
    IotizeConfigFactory.fromJson = function (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
     */
    IotizeConfigFactory.create = function (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);
        }
    };
    return IotizeConfigFactory;
}());
export { IotizeConfigFactory };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW90aXplLWNvbmZpZy1mYWN0b3J5LmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGlvdGl6ZS90YXAvY29uZmlnL2lvdGl6ZS1zdHVkaW8vIiwic291cmNlcyI6WyJsaWIvaW90aXplLWNvbmZpZy1mYWN0b3J5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFOztHQUVHO0FBQ0g7SUFBQTtJQTRDQSxDQUFDO0lBM0NHOzs7T0FHRztJQUNJLDJCQUFPLEdBQWQsVUFBZSxHQUFXO1FBQ3RCLE1BQU0sSUFBSSxLQUFLLENBQ1gsdUdBQXVHLENBQzFHLENBQUM7SUFDTixDQUFDO0lBRUQ7OztPQUd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