text: // Generated by CoffeeScript 2.4.1
  (function() {
    var Netuno;
  
    Netuno = (function() {
      class Netuno {
        addPageLoad(func) {
          return this.pageLoads.push(func);
        }
  
        removePageLoad(func) {
          return this.pageLoads = this.pageLoads.filter(function(e) {
            return e !== func;
          });
        }
  
        pageLoaded() {
          var i, len, pageLoad, ref, results;
          ref = this.pageLoads;
          results = [];
          for (i = 0, len = ref.length; i < len; i++) {
            pageLoad = ref[i];
            results.push(pageLoad());
          }
          return results;
        }
  
        addContentLoad(func) {
          return this.contentLoads.push(func);
        }
  
        removeContentLoad(func) {
          return this.contentLoads = this.contentLoads.filter(function(e) {
            return e !== func;
          });
        }
  
        contentLoaded(container) {
          var contentLoad, i, len, ref, results;
          ref = this.contentLoads;
          results = [];
          for (i = 0, len = ref.length; i < len; i++) {
            contentLoad = ref[i];
            results.push(contentLoad(container));
          }
          return results;
        }
  
        addNavigationLoad(func) {
          return this.navigationLoads.push(func);
        }
  
        removeNavigationLoad(func) {
          return this.navigationLoads = this.navigationLoads.filter(function(e) {
            return e !== func;
          });
        }
  
        navigationLoaded() {
          var i, len, navigationLoad, ref, results;
          ref = this.navigationLoads;
          results = [];
          for (i = 0, len = ref.length; i < len; i++) {
            navigationLoad = ref[i];
            results.push(navigationLoad());
          }
          return results;
        }
  
        urlWithParams(url, obj) {
          var params, str;
          params = Object.keys(obj).reduce(function(a, k) {
            var v;
            v = encodeURIComponent(obj[k]);
            a.push(`${k}=${v}`);
            return a;
          }, []).join('&');
          str = `${url}?${params}`;
          return str;
        }
  
        service(args) {
          var settings;
          settings = {
            url: '',
            method: 'GET',
            credentials: 'include',
            headers: {
              'Content-Type': 'application/json',
              'Accept': 'application/json'
            },
            success: function(data) {},
            fail: function(data) {}
          };
          $.extend(settings, args);
          if (settings.method === 'GET' && settings.data) {
            settings.url = this.urlWithParams(settings.url, settings.data);
          } else if (settings.data && settings.headers['Content-Type'] === 'application/json') {
            settings.body = JSON.stringify(settings.data);
          }
          return fetch(settings.url, settings).then(function(response) {
            var contentType;
            if (response.ok) {
              if (response.status === 204) {
                return settings.success();
              } else {
                contentType = response.headers.get("Content-Type");
                if (contentType && contentType.toLowerCase().indexOf("application/json") === 0) {
                  return response.json().then(function(data) {
                    return settings.success({
                      json: data
                    });
                  });
                } else {
                  return response.text().then(function(text) {
                    return settings.success({
                      text: text
                    });
                  });
                }
              }
            } else {
              return settings.fail({
                response: response
              });
            }
          }).catch(function(e) {
            return settings.fail({
              error: e
            });
          });
        }
  
      };
  
      Netuno.prototype.config = {};
  
      Netuno.prototype.pageLoads = [];
  
      Netuno.prototype.contentLoads = [];
  
      Netuno.prototype.navigationLoads = [];
  
      return Netuno;
  
    }).call(this);
  
    this.netuno = new Netuno();
  
  }).call(this);
  