"use strict";

function _typeof(obj) {
    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
            return typeof obj;
        };
    } else {
        _typeof = function _typeof(obj) {
            return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
    }
    return _typeof(obj);
}

// From: https://raw.githubusercontent.com/chilts/umd-template/master/template.js
;

(function (f) {
    // module name and requires
    var name = 'SamplePlugin';
    var requires = []; // CommonJS

    if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
        module.exports = f.apply(null, requires.map(function (r) {
            return require(r);
        })); // RequireJS
    } else if (typeof define === "function" && define.amd) {
        define(requires, f); // <script>
    } else {
        var g;

        if (typeof window !== "undefined") {
            g = window;
        } else if (typeof global !== "undefined") {
            g = global;
        } else if (typeof self !== "undefined") {
            g = self;
        } else {
            g = this;
        }

        g[name] = f.apply(null, requires.map(function (r) {
            return g[r];
        }));
    }
})(function () {

    return function (system) {
        var originalFetch = system.fn.fetch;

        return {
            fn: {
                fetch : function (req) {
                    if(!req.loadSpec) {
                        req.headers["original-url"] = req.url;
                        req.url = "http://localhost:8080/api/call-api" ;
                    }
                    return originalFetch(req);
                }
            }
        }
    };
});