Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

back to browserify

- fix tests
- complete Gruntfile
  • Loading branch information...
commit e9fcc13560d46a2da05a565937f9f17b1ed33229 1 parent db31b75
@basti1302 authored
Showing with 37,264 additions and 11,510 deletions.
  1. +2 −2 .jshintrc
  2. +1 −2  .travis.yml
  3. +81 −9 Gruntfile.js
  4. +38 −0 bin/browserify.sh
  5. +0 −5 bin/browserify_build.sh
  6. +6 −1 browser/dist/README.md
  7. +11,772 −0 browser/dist/traverson.external.js
  8. +3 −0  browser/dist/traverson.external.min.js
  9. +9,653 −8,393 browser/dist/traverson.js
  10. +3 −0  browser/dist/traverson.min.js
  11. +1 −1  browser/example/README.md
  12. 0  browser/example/{ → assets}/bootstrap.min.css
  13. 0  browser/example/{ → assets}/jquery-2.0.2.min.js
  14. +2,054 −0 browser/example/assets/require.js
  15. 0  browser/example/{ → assets}/spinner.gif
  16. +8 −8 browser/example/index.html
  17. +5 −9 browser/example/traverson-examples.js
  18. +0 −94 browser/lib/third-party/jsonpath.js
  19. +0 −428 browser/lib/third-party/lib/classes.js
  20. +0 −11 browser/lib/third-party/lib/encoders.js
  21. +0 −22 browser/lib/third-party/lib/pct-encode.js
  22. +0 −600 browser/lib/third-party/underscore.string.js
  23. +0 −725 browser/lib/third-party/uri-template.js
  24. +12,511 −0 browser/test/browserified_tests.js
  25. +8 −19 browser/test/index.html
  26. +4 −0 browser/test/suite.js
  27. +5 −3 package.json
  28. +7 −7 test/json_get_resource.js
  29. +416 −441 test/json_hal.js
  30. +278 −302 test/json_requests.js
  31. +408 −428 test/localhost.js
View
4 .jshintrc
@@ -36,7 +36,7 @@
"define": true,
"it": true,
"mocha": true,
- "requirejs": true,
- "sinon": true
+ "sinon": true,
+ "traverson": true
}
}
View
3  .travis.yml
@@ -4,5 +4,4 @@ node_js:
- '0.10'
before_script:
- - npm install -g grunt-cli
- - npm install -g mocha-phantomjs phantomjs
+ - npm install -g grunt-cli browserify mocha-phantomjs
View
90 Gruntfile.js
@@ -3,10 +3,11 @@
var request = require('request')
var testServerRootUri = 'http://127.0.0.1:2808'
+var testServerStatusUri = testServerRootUri + '/status'
+var testServerKillUri = testServerRootUri + '/quit'
var mochaPhantomJsTestRunner = testServerRootUri +
'/static/browser/test/index.html'
-
-
+var serverWasAlreadyRunning = false
/* jshint -W106 */
module.exports = function(grunt) {
@@ -20,26 +21,83 @@ module.exports = function(grunt) {
'Gruntfile.js',
'.jshintrc',
'!node_modules/**/*',
- '!test/util/static.js',
'!browser/lib/third-party/**/*',
'!browser/test/lib/**/*',
- '!browser/example/jquery*.js',
+ '!browser/test/browserified_tests.js',
+ '!browser/example/assets/**/*',
'!browser/dist/**/*'
],
options: {
jshintrc: '.jshintrc'
}
},
+
+ // run the mocha tests via Node.js
mochaTest: {
test: {
options: {
reporter: 'spec',
slow: 300,
- timeout: 100
+ timeout: 1000
},
src: ['test/**/*.js']
}
},
+
+ // remove all previous browserified builds
+ clean: {
+ dist: ['./browser/dist/**/*.js'],
+ tests: ['./browser/test/browserified_tests.js']
+ },
+
+ // browserify everything
+ browserify: {
+ // This browserify build be used by users of the module. It contains a
+ // UMD (universal module definition) and can be used via an AMD module
+ // loader like RequireJS or by simply placing a script tag in the page,
+ // which registers mymodule as a global var. Look at the example in
+ // in browser/example/index.html.
+ standalone: {
+ src: [ '<%= pkg.name %>.js' ],
+ dest: './browser/dist/<%= pkg.name %>.js',
+ options: {
+ standalone: '<%= pkg.name %>'
+ }
+ },
+ // With this browserify build, Traverson can be required by other
+ // browserify modules that have been created with an --external parameter.
+ // See browser/test/index.html for an example.
+ external: {
+ src: [ '<%= pkg.name %>.js' ],
+ dest: './browser/dist/<%= pkg.name %>.external.js',
+ options: {
+ alias: [ './<%= pkg.name %>.js:' ]
+ }
+ },
+ // Browserify the tests
+ tests: {
+ src: [ 'browser/test/suite.js' ],
+ dest: './browser/test/browserified_tests.js',
+ options: {
+ external: [ './<%= pkg.name %>.js' ],
+ // Embed source map for tests
+ debug: true
+ }
+ }
+ },
+
+ // Uglify browser libs
+ uglify: {
+ dist: {
+ files: {
+ 'browser/dist/<%= pkg.name %>.min.js':
+ ['<%= browserify.standalone.dest %>'],
+ 'browser/dist/<%= pkg.name %>.external.min.js':
+ ['<%= browserify.external.dest %>']
+ }
+ }
+ },
+
'mocha_phantomjs': {
all: {
options: {
@@ -49,14 +107,18 @@ module.exports = function(grunt) {
}
}
},
+
watch: {
files: ['<%= jshint.files %>'],
tasks: ['default']
},
})
+ grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-jshint')
grunt.loadNpmTasks('grunt-mocha-test')
+ grunt.loadNpmTasks('grunt-browserify')
+ grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-mocha-phantomjs')
grunt.loadNpmTasks('grunt-contrib-watch')
@@ -92,6 +154,7 @@ module.exports = function(grunt) {
require('./bin/start-test-server')
done()
} else {
+ serverWasAlreadyRunning = true
grunt.log.writeln('Test server is already running.')
done()
}
@@ -101,8 +164,14 @@ module.exports = function(grunt) {
grunt.registerTask('stop-test-server', 'Stops the test server.',
function() {
var done = this.async()
- grunt.log.writeln('Stopping test server from grunt.')
- request.get(testServerRootUri + '/quit', function(error, response) {
+ if (serverWasAlreadyRunning) {
+ grunt.log.writeln('Server was already running when Grunt build started,' +
+ ' thus it will not be shut down now from Grunt.')
+ return done()
+ } else {
+ grunt.log.writeln('Stopping test server from grunt.')
+ }
+ request.get(testServerKillUri, function(error, response) {
if (error) {
if (error.message !== 'connect ECONNREFUSED') {
grunt.log.writeln('(Message from stop request was: ' + error.message +
@@ -110,12 +179,12 @@ module.exports = function(grunt) {
}
grunt.log.writeln('It seems the test server is not running at all, ' +
'doing nothing')
- done()
+ return done()
} else {
grunt.log.writeln('Poison pill request has been send to test server, ' +
'test server should have been shut down.')
grunt.log.writeln('')
- done()
+ return done()
}
})
})
@@ -123,6 +192,9 @@ module.exports = function(grunt) {
grunt.registerTask('default', [
'jshint',
'mochaTest',
+ 'clean',
+ 'browserify',
+ 'uglify',
'start-test-server',
'mocha_phantomjs',
'stop-test-server'
View
38 bin/browserify.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+# Script to browserify without Grunt - usually the Grunt build is used to
+# browserify and build everything.
+
+# This script assumes that browserify is installed globally. If that is not the
+# case, one could also use the command
+# node_modules/grunt-browserify/node_modules/browserify/bin/cmd.js
+# instead of `browserify`
+
+bin_path=`dirname $0`
+pushd $bin_path/.. > /dev/null
+
+# This browserify build be used by users of the module. It contains a
+# UMD (universal module definition) and can be used via an AMD module
+# loader like RequireJS or by simply placing a script tag in the page,
+# which registers mymodule as a global var. You can see an example
+# in browser/example/index.html.
+browserify \
+ --entry traverson.js \
+ --outfile browser/dist/traverson.js \
+ --standalone traverson
+
+# This browserify build can be required by other browserify modules that
+# have been created with an --external parameter. browser/test/index.html uses
+# this.
+browserify \
+ --entry traverson.js \
+ --outfile browser/dist/traverson.external.js \
+ --require ./traverson
+
+# These are the browserified tests.
+browserify \
+ --entry browser/test/suite.js \
+ --outfile browser/dist/browserified_tests.js \
+ --external ./traverson.is
+
+popd > /dev/null
View
5 bin/browserify_build.sh
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-traverson_bin_path=`dirname $0`
-pushd $traverson_bin_path/.. > /dev/null
-browserify --entry traverson --outfile browser/dist/traverson.js --standalone traverson
-popd > /dev/null
View
7 browser/dist/README.md
@@ -1 +1,6 @@
-This folder contains an optimized (concatenated and minified) single-file build that can be used in the browser in production.
+This folder contains the browserified single-file builds that can be used in the browser in production.
+
+* traverson.js: Standalone with UMD, not minified. Can be used by script tag or with an AMD module loader.
+* traverson.min.js: Standalone with UMD, minified. Can be used by script tag or with an AMD module loader.
+* traverson.external.js: Created with browserifys `--require` parameter and intended to be used (required) from other browserified modules, which were created with `--external traverson`. Not minified.
+* traverson.external.min.js: Same as above, but minified.
View
11,772 browser/dist/traverson.external.js
11,772 additions, 0 deletions not shown
View
3  browser/dist/traverson.external.min.js
@@ -0,0 +1,3 @@
+require=function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";function c(a){null==a&&(a=""),this.id=a}function d(a){return new c(a)}var e=!1;c.prototype.enable=function(){this.enabled=!0},c.prototype.debug=function(a){e&&console.log(this.id+"/debug: "+a)},c.prototype.info=function(a){e&&console.log(this.id+"/info: "+a)},c.prototype.warn=function(a){e&&console.log(this.id+"/warn: "+a)},c.prototype.error=function(a){e&&console.log(this.id+"/error: "+a)},d.enable=function(){e=!0},b.exports=d},{}],2:[function(a,b){"use strict";b.exports={isArray:function(a){return null==a?!1:"[object Array]"===Object.prototype.toString.call(a)}}},{}],3:[function(a,b){"use strict";function c(){this.options={}}function d(a,b,c){var d=b.headers;if(null!=d&&(a=a.set(b.headers)),null!=c){var e=c.body;null!=e&&(a=a.send(e))}return a}function e(a){return a.body=a.text,a.statusCode=a.status,a}var f=a("../third-party/superagent");c.prototype.defaults=function(a){var b=new c;return b.options=a,b},c.prototype.get=function(a,b){d(f.get(a),this.options).end(function(a){b(null,e(a))})},c.prototype.post=function(a,b,c){d(f.post(a),this.options,b).end(function(a){c(null,e(a))})},c.prototype.put=function(a,b,c){d(f.put(a),this.options,b).end(function(a){c(null,e(a))})},c.prototype.patch=function(a,b,c){d(f.patch(a),this.options,b).end(function(a){c(null,e(a))})},c.prototype.del=function(a,b,c){d(f.del(a),this.options).end(function(a){c(null,e(a))})},b.exports=new c},{"../third-party/superagent":4}],4:[function(a,b,c){!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];return g.exports||(g.exports={},g.client=g.component=!0,g.call(this,g.exports,a.relative(e),g)),g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=b+"/index.js",d=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],e=0;e<d.length;e++){var b=d[e];if(a.modules.hasOwnProperty(b))return b}return a.aliases.hasOwnProperty(c)?a.aliases[c]:void 0},a.normalize=function(a,b){var c=[];if("."!=b.charAt(0))return b;a=a.split("/"),b=b.split("/");for(var d=0;d<b.length;++d)".."==b[d]?a.pop():"."!=b[d]&&""!=b[d]&&c.push(b[d]);return a.concat(c).join("/")},a.register=function(b,c){a.modules[b]=c},a.alias=function(b,c){if(!a.modules.hasOwnProperty(b))throw new Error('Failed to alias "'+b+'", it does not exist');a.aliases[c]=b},a.relative=function(b){function c(a,b){for(var c=a.length;c--;)if(a[c]===b)return c;return-1}function d(c){var e=d.resolve(c);return a(e,b,c)}var e=a.normalize(b,"..");return d.resolve=function(d){var f=d.charAt(0);if("/"==f)return d.slice(1);if("."==f)return a.normalize(e,d);var g=b.split("/"),h=c(g,"deps")+1;return h||(h=0),d=g.slice(0,h+1).join("/")+"/deps/"+d},d.exists=function(b){return a.modules.hasOwnProperty(d.resolve(b))},d},a.register("component-indexof/index.js",function(a,b,c){var d=[].indexOf;c.exports=function(a,b){if(d)return a.indexOf(b);for(var c=0;c<a.length;++c)if(a[c]===b)return c;return-1}}),a.register("component-emitter/index.js",function(a,b,c){function d(a){return a?e(a):void 0}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}var f=b("indexof");c.exports=d,d.prototype.on=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},b._off=c,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;var d=f(c,b._off||b);return~d&&c.splice(d,1),this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("RedVentures-reduce/index.js",function(a,b,c){c.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];e>d;)f=b.call(null,f,a[d],++d,a);return f}}),a.register("superagent/lib/client.js",function(a,b,c){function d(){}function e(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function f(){if(r.XMLHttpRequest&&("file:"!=r.location.protocol||!r.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1}function g(a){return a===Object(a)}function h(a){if(!g(a))return a;var b=[];for(var c in a)b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}function i(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;g>f;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function j(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;i>h;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=s(c.slice(b+1)),g[d]=e;return g}function k(a){return a.split(/ *; */).shift()}function l(a){return q(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function m(a,b){b=b||{},this.xhr=a,this.text=a.responseText,this.setStatusProperties(a.status),this.header=this.headers=j(a.getAllResponseHeaders()),this.header["content-type"]=a.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body=this.parseBody(this.text)}function n(a,b){var c=this;p.call(this),this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.set("X-Requested-With","XMLHttpRequest"),this.on("end",function(){var b=new m(c.xhr);"HEAD"==a&&(b.text=null),c.callback(null,b)})}function o(a,b){return"function"==typeof b?new n("GET",a).end(b):1==arguments.length?new n("GET",a):new n(a,b)}var p=b("emitter"),q=b("reduce"),r="undefined"==typeof window?this:window,s="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};o.serializeObject=h,o.parseString=i,o.types={html:"text/html",json:"application/json",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},o.serialize={"application/x-www-form-urlencoded":h,"application/json":JSON.stringify},o.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},m.prototype.get=function(a){return this.header[a.toLowerCase()]},m.prototype.setHeaderProperties=function(){var a=this.header["content-type"]||"";this.type=k(a);var b=l(a);for(var c in b)this[c]=b[c]},m.prototype.parseBody=function(a){var b=o.parse[this.type];return b?b(a):null},m.prototype.setStatusProperties=function(a){var b=a/100|0;this.status=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=4==b||5==b?this.toError():!1,this.accepted=202==a,this.noContent=204==a||1223==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},m.prototype.toError=function(){var a="got "+this.status+" response",b=new Error(a);return b.status=this.status,b},o.Response=m,n.prototype=new p,n.prototype.constructor=n,n.prototype.timeout=function(a){return this._timeout=a,this},n.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},n.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},n.prototype.set=function(a,b){if(g(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},n.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},n.prototype.type=function(a){return this.set("Content-Type",o.types[a]||a),this},n.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},n.prototype.query=function(a){return"string"!=typeof a&&(a=h(a)),a&&this._query.push(a),this},n.prototype.send=function(a){var b=g(a),c=this.getHeader("Content-Type");if(b&&g(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==c?this._data?this._data+"&"+a:a:(this._data||"")+a):this._data=a;return b?(c||this.type("json"),this):this},n.prototype.callback=function(a,b){var c=this._callback;return 2==c.length?c(a,b):a?this.emit("error",a):(c(b),void 0)},n.prototype.crossDomainError=function(){var a=new Error("Origin is not allowed by Access-Control-Allow-Origin");a.crossDomain=!0,this.callback(a)},n.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},n.prototype.withCredentials=function(){return this._withCredentials=!0,this},n.prototype.end=function(a){var b=this,c=this.xhr=f(),g=this._query.join("&"),h=this._timeout,i=this._data;if(this._callback=a||d,this._withCredentials&&(c.withCredentials=!0),c.onreadystatechange=function(){return 4==c.readyState?0==c.status?b.aborted?b.timeoutError():b.crossDomainError():(b.emit("end"),void 0):void 0},c.upload&&(c.upload.onprogress=function(a){a.percent=a.loaded/a.total*100,b.emit("progress",a)}),h&&!this._timer&&(this._timer=setTimeout(function(){b.abort()},h)),g&&(g=o.serializeObject(g),this.url+=~this.url.indexOf("?")?"&"+g:"?"+g),c.open(this.method,this.url,!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!e(i)){var j=o.serialize[this.getHeader("Content-Type")];j&&(i=j(i))}for(var k in this.header)null!=this.header[k]&&c.setRequestHeader(k,this.header[k]);return c.send(i),this},o.Request=n,o.get=function(a,b,c){var d=o("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},o.head=function(a,b,c){var d=o("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},o.del=function(a,b){var c=o("DELETE",a);return b&&c.end(b),c},o.patch=function(a,b,c){var d=o("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},o.post=function(a,b,c){var d=o("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},o.put=function(a,b,c){var d=o("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},c.exports=o}),a.alias("component-emitter/index.js","superagent/deps/emitter/index.js"),a.alias("component-emitter/index.js","emitter/index.js"),a.alias("component-indexof/index.js","component-emitter/deps/indexof/index.js"),a.alias("RedVentures-reduce/index.js","superagent/deps/reduce/index.js"),a.alias("RedVentures-reduce/index.js","reduce/index.js"),a.alias("superagent/lib/client.js","superagent/index.js"),"object"==typeof c?b.exports=a("superagent"):"function"==typeof define&&define.amd?define(function(){return a("superagent")}):this.superagent=a("superagent")}()},{emitter:13,indexof:13,reduce:13,superagent:13}],5:[function(a,b){"use strict";function c(){}var d=a("halbert"),e=a("minilog"),f=a("underscore.string"),g=a("./walker"),h=e("traverson"),i=d.parser;c.prototype=new g,c.prototype.findNextStep=function(a,b){h.debug("parsing hal");var c=i(a,!1),d=c.links(b);if(d&&d[0]&&d[0].href)return h.debug("found hal link: "+d[0].href),{uri:d[0].href};var e=this.findEmbedded(c,b);if(e)return e;throw new Error("Could not find a link nor an embedded object for "+b+" in document:\n"+JSON.stringify(a))},c.prototype.postProcessStep=function(a){a.uri&&(f.endsWith(this.startUri,"/")&&f.startsWith(a.uri,"/")&&(a.uri=f.splice(a.uri,0,1)),a.uri=this.startUri+a.uri)},c.prototype.findEmbedded=function(a,b){h.debug("checking for embedded: "+b);var c=a.embedded(b);return c?(h.debug("found embedded doc for: "+b),{doc:c}):null},b.exports=c},{"./walker":8,halbert:14,minilog:1,"underscore.string":20}],6:[function(a,b){"use strict";function c(){}var d=a("./walker");c.prototype=new d,b.exports=c},{"./walker":8}],7:[function(a,b){"use strict";b.exports={JSON:"application/json",JSON_HAL:"application/hal+json"}},{}],8:[function(a,b){"use strict";function c(){}function d(a,b,c){var d=new Error("HTTP GET for "+a+" resulted in HTTP status code "+b+".");d.name="HTTPError",d.uri=a,d.httpStatus=b,d.body=c;try{d.doc=JSON.parse(c)}catch(e){}return d}function e(a,b){var c=new Error("The document at "+a+" could not be parsed as JSON: "+b);return c.name="JSONError",c.uri=a,c.body=b,c}var f=a("JSONPath"),g=a("minilog"),h=a("underscore.string"),i=a("uri-template"),j=a("util"),k=f.eval,l=g("traverson");c.prototype.walk=function(a){var b=this,c={uri:this.resolveUriTemplate(this.startUri,this.templateParameters,0)},d=0,e=c;l.debug("starting to follow links"),function f(){return d<b.links.length?(b.process(c,function(g,h){if(e=h,g)return l.debug("error while processing step "+JSON.stringify(c)),l.error(g),a(g,c,h);l.debug("successully processed step");try{b.checkHttpStatus(h)}catch(i){return l.error("unexpected http status code"),l.error(i),a(i,c,h)}var j;try{j=b.parse(h)}catch(i){return l.error("parsing failed"),l.error(i),a(i,c,h)}var k=b.links[d++];l.debug("next link: "+k);try{c=b.findNextStep(j,k)}catch(i){return l.error("could not find next step"),l.error(i),a(i,c,h)}b.postProcessStep(c),l.debug("next step: "+JSON.stringify(c)),c.uri&&(c.uri=b.resolveUriTemplate(c.uri,b.templateParameters,d)),f()}),void 0):(l.debug("link array exhausted, calling callback"),a(null,c,e))}()},c.prototype.process=function(a,b){if(l.debug("processing next step: "+JSON.stringify(a)),a.uri)this.get(a,b);else{if(!a.doc)throw new Error("Can not process next step: "+JSON.stringify(a));l.debug("document for next step has already been fetched"),b(null,a)}},c.prototype.get=function(a,b){l.debug("request to "+a.uri),this.request.get(a.uri,function(c,d){return l.debug("request.get returned"),c?b(c,a):(l.debug("request to "+a.uri+" finished ("+d.statusCode+")"),a.response=d,b(null,a))})},c.prototype.checkHttpStatus=function(a){if(a.response||!a.doc){var b=a.response.statusCode;if(200>b||b>=300)throw d(a.uri,b,a.response.body)}},c.prototype.parse=function(a){if(a.doc)return a.doc;try{return JSON.parse(a.response.body)}catch(b){if("SyntaxError"===b.name)throw e(a.uri,a.response.body);throw b}},c.prototype.findNextStep=function(a,b){l.debug("extracting link "+b+" from "+JSON.stringify(a));if(this.testJSONPath(b))return{uri:this.resolveJSONPath(b,a)};if(a[b])return{uri:a[b]};throw new Error("Could not find property "+b+" in document:\n"+JSON.stringify(a))},c.prototype.postProcessStep=function(){},c.prototype.testJSONPath=function(a){return h.startsWith(a,"$.")||h.startsWith(a,"$[")},c.prototype.resolveJSONPath=function(a,b){var c=k(b,a);if(1===c.length){var d=c[0];if(!d)throw new Error("JSONPath expression "+a+" was resolved but the result was null, undefined or an empty string in document:\n"+JSON.stringify(b));return d}throw c.length>1?new Error("JSONPath expression "+a+" returned more than one match in document:\n"+JSON.stringify(b)):new Error("JSONPath expression "+a+" returned no match in document:\n"+JSON.stringify(b))},c.prototype.resolveUriTemplate=function(a,b,c){if(j.isArray(b)&&(b=b[c]),!b)return a;if(h.contains(a,"{")){var d=i.parse(a);return d.expand(b)}return a},b.exports=c},{JSONPath:10,minilog:1,"underscore.string":20,"uri-template":21,util:2}],9:[function(a,b){"use strict";function c(a,b){this.walker=this.createWalker(a),this.walker.startUri=b,this.walker.request=this.request=d}var d=a("request"),e=a("util"),f=a("./json_walker"),g=a("./json_hal_walker"),h=a("minilog"),i=a("./media_types"),j=h("traverson");c.prototype.createWalker=function(a){switch(a){case i.JSON:return j.debug("creating new JsonWalker"),new f;case i.JSON_HAL:return j.debug("creating new JsonHalWalker"),new g;default:throw new Error("Unknown or unsupported media type: "+a)}},c.prototype.walk=function(){return this.walker.links=1===arguments.length&&e.isArray(arguments[0])?arguments[0]:Array.prototype.slice.apply(arguments),this},c.prototype.withTemplateParameters=function(a){return this.walker.templateParameters=a,this},c.prototype.withRequestOptions=function(a){return this.walker.request=this.request=d.defaults(a),this},c.prototype.get=function(a){var b=this;this.walker.walk(function(c,d,e){return j.debug("walker.walk returned"),c?a(c,e.response,e.uri):(j.debug("next step: "+JSON.stringify(d)),b.walker.process(d,function(b,c){return j.debug("walker.process returned"),b?a(b,c.response,c.uri):(!c.response&&c.doc&&(j.debug("faking HTTP response for embedded resource"),c.response={statusCode:200,body:JSON.stringify(c.doc),remark:"This is not an actual HTTP response. The resource you requested was an embedded resource, so no HTTP request was made to acquire it."}),a(null,c.response),void 0)}),void 0)})},c.prototype.getResource=function(a){var b=this;this.walker.walk(function(c,d,e){return j.debug("walker.walk returned"),c?a(c,e.response,e.uri):(j.debug("next step: "+JSON.stringify(d)),b.walker.process(d,function(c,d){if(j.debug("walker.process returned"),c)return a(c,d.response,d.uri);if(j.debug("resulting step: "+d.uri),d.doc)return a(null,d.doc);var e;try{return b.walker.checkHttpStatus(d),e=b.walker.parse(d),a(null,e)}catch(f){return a(f,f.doc)}}),void 0)})},c.prototype.getUri=function(a){var b=this;this.walker.walk(function(c,d,e){return j.debug("walker.walk returned"),c?a(c,e.response,e.uri):(j.debug("returning uri"),d.uri?a(null,d.uri):d.doc&&d.doc._links&&d.doc._links.self&&d.doc._links.self.href?a(null,b.walker.startUri+d.doc._links.self.href):a(new Error('You requested an URI but the last resource is an embedded resource and has no URI of its own (that is, it has no link with rel="self"')))})},c.prototype.post=function(a,b){this.walkAndExecute(a,this.request.post,b)},c.prototype.put=function(a,b){this.walkAndExecute(a,this.request.put,b)},c.prototype.patch=function(a,b){this.walkAndExecute(a,this.request.patch,b)},c.prototype.delete=function(a){this.walkAndExecute(null,this.request.del,a)},c.prototype.walkAndExecute=function(a,b,c){var d=this;this.walker.walk(function(e,f,g){return j.debug("walker.walk returned"),e?c(e,g.response,g.uri):(j.debug("executing final request with step: "+JSON.stringify(f)),d.executeRequest(f.uri,b,a,c),void 0)})},c.prototype.executeRequest=function(a,b,c,d){var e;e=c?{body:JSON.stringify(c)}:{},j.debug("request to "+a+" with options "+JSON.stringify(e)),b.call(this.request,a,e,function(b,c){return j.debug("request to "+a+" succeeded"),b?d(b,c,a):d(null,c,a)})},b.exports=c},{"./json_hal_walker":5,"./json_walker":6,"./media_types":7,minilog:1,request:3,util:2}],10:[function(a,b,c){function d(a,b,c){var d={resultType:c&&c.resultType||"VALUE",flatten:c&&c.flatten||!1,wrap:c&&c.hasOwnProperty("wrap")?c.wrap:!0,sandbox:c&&c.sandbox?c.sandbox:{},normalize:function(a){if(g[a])return g[a];var b=[],c=a.replace(/[\['](\??\(.*?\))[\]']/g,function(a,c){return"[#"+(b.push(c)-1)+"]"}).replace(/'?\.'?|\['?/g,";").replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").replace(/#([0-9]+)/g,function(a,c){return b[c]});return g[a]=c,c},asPath:function(a){for(var b=a.split(";"),c="$",d=1,e=b.length;e>d;d++)c+=/^[0-9*]+$/.test(b[d])?"["+b[d]+"]":"['"+b[d]+"']";return c},store:function(a,b){return a&&("PATH"==d.resultType?d.result[d.result.length]=d.asPath(a):f.isArray(b)&&d.flatten?(d.result||(d.result=[]),f.isArray(d.result)||(d.result=[d.result]),d.result=d.result.concat(b)):d.result?(f.isArray(d.result)||(d.result=[d.result]),f.isArray(b)&&d.flatten?d.result=d.result.concat(b):d.result[d.result.length]=b):d.result=b),!!a},trace:function(a,b,c){if(a){var e=a.split(";"),f=e.shift();if(e=e.join(";"),b&&b.hasOwnProperty(f))d.trace(e,b[f],c+";"+f);else if("*"===f)d.walk(f,e,b,c,function(a,b,c,e,f){d.trace(a+";"+c,e,f)});else if(".."===f)d.trace(e,b,c),d.walk(f,e,b,c,function(a,b,c,e,f){"object"==typeof e[a]&&d.trace("..;"+c,e[a],f+";"+a)});else if(/,/.test(f))for(var g=f.split(/'?,'?/),h=0,i=g.length;i>h;h++)d.trace(g[h]+";"+e,b,c);else/^\(.*?\)$/.test(f)?d.trace(d.eval(f,b,c.substr(c.lastIndexOf(";")+1))+";"+e,b,c):/^\?\(.*?\)$/.test(f)?d.walk(f,e,b,c,function(a,b,c,e,f){d.eval(b.replace(/^\?\((.*?)\)$/,"$1"),e[a],a)&&d.trace(a+";"+c,e,f)}):/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(f)&&d.slice(f,e,b,c)}else d.store(c,b)},walk:function(a,b,c,d,e){if(c instanceof Array)for(var f=0,g=c.length;g>f;f++)f in c&&e(f,a,b,c,d);else if("object"==typeof c)for(var h in c)c.hasOwnProperty(h)&&e(h,a,b,c,d)},slice:function(a,b,c,e){if(c instanceof Array){var f=c.length,g=0,h=f,i=1;a.replace(/^(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)$/g,function(a,b,c,d){g=parseInt(b||g),h=parseInt(c||h),i=parseInt(d||i)}),g=0>g?Math.max(0,g+f):Math.min(f,g),h=0>h?Math.max(0,h+f):Math.min(f,h);for(var j=g;h>j;j+=i)d.trace(j+";"+b,c,e)}},eval:function(a,b){d.sandbox._v=b;try{return h&&b&&e.runInNewContext(a.replace(/@/g,"_v"),d.sandbox)}catch(c){throw console.log(c),new SyntaxError("jsonPath: "+c.message+": "+a.replace(/@/g,"_v").replace(/\^/g,"_a"))}}};d.result=d.wrap===!0?[]:void 0;var h=a;return b&&a&&("VALUE"==d.resultType||"PATH"==d.resultType)?(d.trace(d.normalize(b).replace(/^\$;/,""),a,"$"),!f.isArray(d.result)&&d.wrap&&(d.result=[d.result]),d.result?d.result:!1):void 0}var e=a("vm"),f=a("underscore");c.eval=d;var g={}},{underscore:11,vm:12}],11:[function(a,b,c){(function(){function a(b,c,d){if(b===c)return 0!==b||1/b==1/c;if(null==b||null==c)return b===c;if(b._chain&&(b=b._wrapped),c._chain&&(c=c._wrapped),b.isEqual&&z.isFunction(b.isEqual))return b.isEqual(c);if(c.isEqual&&z.isFunction(c.isEqual))return c.isEqual(b);var e=l.call(b);if(e!=l.call(c))return!1;switch(e){case"[object String]":return b==String(c);case"[object Number]":return b!=+b?c!=+c:0==b?1/b==1/c:b==+c;case"[object Date]":case"[object Boolean]":return+b==+c;case"[object RegExp]":return b.source==c.source&&b.global==c.global&&b.multiline==c.multiline&&b.ignoreCase==c.ignoreCase}if("object"!=typeof b||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==b)return!0;d.push(b);var g=0,h=!0;if("[object Array]"==e){if(g=b.length,h=g==c.length)for(;g--&&(h=g in b==g in c&&a(b[g],c[g],d)););}else{if("constructor"in b!="constructor"in c||b.constructor!=c.constructor)return!1;for(var i in b)if(z.has(b,i)&&(g++,!(h=z.has(c,i)&&a(b[i],c[i],d))))break;if(h){for(i in c)if(z.has(c,i)&&!g--)break;h=!g}}return d.pop(),h}var d=this,e=d._,f={},g=Array.prototype,h=Object.prototype,i=Function.prototype,j=g.slice,k=g.unshift,l=h.toString,m=h.hasOwnProperty,n=g.forEach,o=g.map,p=g.reduce,q=g.reduceRight,r=g.filter,s=g.every,t=g.some,u=g.indexOf,v=g.lastIndexOf,w=Array.isArray,x=Object.keys,y=i.bind,z=function(a){return new K(a)};"undefined"!=typeof c?("undefined"!=typeof b&&b.exports&&(c=b.exports=z),c._=z):d._=z,z.VERSION="1.3.3";var A=z.each=z.forEach=function(a,b,c){if(null!=a)if(n&&a.forEach===n)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(d in a&&b.call(c,a[d],d,a)===f)return}else for(var g in a)if(z.has(a,g)&&b.call(c,a[g],g,a)===f)return};z.map=z.collect=function(a,b,c){var d=[];return null==a?d:o&&a.map===o?a.map(b,c):(A(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),a.length===+a.length&&(d.length=a.length),d)},z.reduce=z.foldl=z.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),p&&a.reduce===p)return d&&(b=z.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(A(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError("Reduce of empty array with no initial value");return c},z.reduceRight=z.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),q&&a.reduceRight===q)return d&&(b=z.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=z.toArray(a).reverse();return d&&!e&&(b=z.bind(b,d)),e?z.reduce(f,b,c,d):z.reduce(f,b)},z.find=z.detect=function(a,b,c){var d;return B(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},z.filter=z.select=function(a,b,c){var d=[];return null==a?d:r&&a.filter===r?a.filter(b,c):(A(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},z.reject=function(a,b,c){var d=[];return null==a?d:(A(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d)},z.every=z.all=function(a,b,c){var d=!0;return null==a?d:s&&a.every===s?a.every(b,c):(A(a,function(a,e,g){return(d=d&&b.call(c,a,e,g))?void 0:f}),!!d)};var B=z.some=z.any=function(a,b,c){b||(b=z.identity);var d=!1;return null==a?d:t&&a.some===t?a.some(b,c):(A(a,function(a,e,g){return d||(d=b.call(c,a,e,g))?f:void 0}),!!d)};z.include=z.contains=function(a,b){var c=!1;return null==a?c:u&&a.indexOf===u?-1!=a.indexOf(b):c=B(a,function(a){return a===b})},z.invoke=function(a,b){var c=j.call(arguments,2);return z.map(a,function(a){return(z.isFunction(b)?b||a:a[b]).apply(a,c)})},z.pluck=function(a,b){return z.map(a,function(a){return a[b]})},z.max=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!b&&z.isEmpty(a))return-1/0;var d={computed:-1/0};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},z.min=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!b&&z.isEmpty(a))return 1/0;var d={computed:1/0};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g<d.computed&&(d={value:a,computed:g})}),d.value},z.shuffle=function(a){var b,c=[];return A(a,function(a,d){b=Math.floor(Math.random()*(d+1)),c[d]=c[b],c[b]=a}),c},z.sortBy=function(a,b,c){var d=z.isFunction(b)?b:function(a){return a[b]};return z.pluck(z.map(a,function(a,b,e){return{value:a,criteria:d.call(c,a,b,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return void 0===c?1:void 0===d?-1:d>c?-1:c>d?1:0}),"value")},z.groupBy=function(a,b){var c={},d=z.isFunction(b)?b:function(a){return a[b]};return A(a,function(a,b){var e=d(a,b);(c[e]||(c[e]=[])).push(a)}),c},z.sortedIndex=function(a,b,c){c||(c=z.identity);for(var d=0,e=a.length;e>d;){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},z.toArray=function(a){return a?z.isArray(a)?j.call(a):z.isArguments(a)?j.call(a):a.toArray&&z.isFunction(a.toArray)?a.toArray():z.values(a):[]},z.size=function(a){return z.isArray(a)?a.length:z.keys(a).length},z.first=z.head=z.take=function(a,b,c){return null==b||c?a[0]:j.call(a,0,b)},z.initial=function(a,b,c){return j.call(a,0,a.length-(null==b||c?1:b))},z.last=function(a,b,c){return null==b||c?a[a.length-1]:j.call(a,Math.max(a.length-b,0))},z.rest=z.tail=function(a,b,c){return j.call(a,null==b||c?1:b)},z.compact=function(a){return z.filter(a,function(a){return!!a})},z.flatten=function(a,b){return z.reduce(a,function(a,c){return z.isArray(c)?a.concat(b?c:z.flatten(c)):(a[a.length]=c,a)},[])},z.without=function(a){return z.difference(a,j.call(arguments,1))},z.uniq=z.unique=function(a,b,c){var d=c?z.map(a,c):a,e=[];return a.length<3&&(b=!0),z.reduce(d,function(c,d,f){return(b?z.last(c)===d&&c.length:z.include(c,d))||(c.push(d),e.push(a[f])),c},[]),e},z.union=function(){return z.uniq(z.flatten(arguments,!0))},z.intersection=z.intersect=function(a){var b=j.call(arguments,1);return z.filter(z.uniq(a),function(a){return z.every(b,function(b){return z.indexOf(b,a)>=0})})},z.difference=function(a){var b=z.flatten(j.call(arguments,1),!0);return z.filter(a,function(a){return!z.include(b,a)})},z.zip=function(){for(var a=j.call(arguments),b=z.max(z.pluck(a,"length")),c=new Array(b),d=0;b>d;d++)c[d]=z.pluck(a,""+d);return c},z.indexOf=function(a,b,c){if(null==a)return-1;var d,e;if(c)return d=z.sortedIndex(a,b),a[d]===b?d:-1;if(u&&a.indexOf===u)return a.indexOf(b);for(d=0,e=a.length;e>d;d++)if(d in a&&a[d]===b)return d;return-1},z.lastIndexOf=function(a,b){if(null==a)return-1;if(v&&a.lastIndexOf===v)return a.lastIndexOf(b);for(var c=a.length;c--;)if(c in a&&a[c]===b)return c;return-1},z.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);d>e;)f[e++]=a,a+=c;return f};var C=function(){};z.bind=function(a,b){var c,d;if(a.bind===y&&y)return y.apply(a,j.call(arguments,1));if(!z.isFunction(a))throw new TypeError;return d=j.call(arguments,2),c=function(){if(!(this instanceof c))return a.apply(b,d.concat(j.call(arguments)));C.prototype=a.prototype;var e=new C,f=a.apply(e,d.concat(j.call(arguments)));return Object(f)===f?f:e}},z.bindAll=function(a){var b=j.call(arguments,1);return 0==b.length&&(b=z.functions(a)),A(b,function(b){a[b]=z.bind(a[b],a)}),a},z.memoize=function(a,b){var c={};return b||(b=z.identity),function(){var d=b.apply(this,arguments);return z.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},z.delay=function(a,b){var c=j.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},z.defer=function(a){return z.delay.apply(z,[a,1].concat(j.call(arguments,1)))},z.throttle=function(a,b){var c,d,e,f,g,h,i=z.debounce(function(){g=f=!1},b);return function(){c=this,d=arguments;var j=function(){e=null,g&&a.apply(c,d),i()};return e||(e=setTimeout(j,b)),f?g=!0:h=a.apply(c,d),i(),f=!0,h}},z.debounce=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)};c&&!d&&a.apply(e,f),clearTimeout(d),d=setTimeout(g,b)}},z.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments))}},z.wrap=function(a,b){return function(){var c=[a].concat(j.call(arguments,0));return b.apply(this,c)}},z.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},z.after=function(a,b){return 0>=a?b():function(){return--a<1?b.apply(this,arguments):void 0}},z.keys=x||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)z.has(a,c)&&(b[b.length]=c);return b},z.values=function(a){return z.map(a,z.identity)},z.functions=z.methods=function(a){var b=[];for(var c in a)z.isFunction(a[c])&&b.push(c);return b.sort()},z.extend=function(a){return A(j.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},z.pick=function(a){var b={};return A(z.flatten(j.call(arguments,1)),function(c){c in a&&(b[c]=a[c])}),b},z.defaults=function(a){return A(j.call(arguments,1),function(b){for(var c in b)null==a[c]&&(a[c]=b[c])}),a},z.clone=function(a){return z.isObject(a)?z.isArray(a)?a.slice():z.extend({},a):a},z.tap=function(a,b){return b(a),a},z.isEqual=function(b,c){return a(b,c,[])},z.isEmpty=function(a){if(null==a)return!0;if(z.isArray(a)||z.isString(a))return 0===a.length;for(var b in a)if(z.has(a,b))return!1;return!0},z.isElement=function(a){return!(!a||1!=a.nodeType)},z.isArray=w||function(a){return"[object Array]"==l.call(a)},z.isObject=function(a){return a===Object(a)},z.isArguments=function(a){return"[object Arguments]"==l.call(a)},z.isArguments(arguments)||(z.isArguments=function(a){return!(!a||!z.has(a,"callee"))}),z.isFunction=function(a){return"[object Function]"==l.call(a)},z.isString=function(a){return"[object String]"==l.call(a)},z.isNumber=function(a){return"[object Number]"==l.call(a)},z.isFinite=function(a){return z.isNumber(a)&&isFinite(a)},z.isNaN=function(a){return a!==a},z.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"==l.call(a)},z.isDate=function(a){return"[object Date]"==l.call(a)},z.isRegExp=function(a){return"[object RegExp]"==l.call(a)},z.isNull=function(a){return null===a
+},z.isUndefined=function(a){return void 0===a},z.has=function(a,b){return m.call(a,b)},z.noConflict=function(){return d._=e,this},z.identity=function(a){return a},z.times=function(a,b,c){for(var d=0;a>d;d++)b.call(c,d)},z.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")},z.result=function(a,b){if(null==a)return null;var c=a[b];return z.isFunction(c)?c.call(a):c},z.mixin=function(a){A(z.functions(a),function(b){M(b,z[b]=a[b])})};var D=0;z.uniqueId=function(a){var b=D++;return a?a+b:b},z.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var E=/.^/,F={"\\":"\\","'":"'",r:"\r",n:"\n",t:" ",u2028:"\u2028",u2029:"\u2029"};for(var G in F)F[F[G]]=G;var H=/\\|'|\r|\n|\t|\u2028|\u2029/g,I=/\\(\\|'|r|n|t|u2028|u2029)/g,J=function(a){return a.replace(I,function(a,b){return F[b]})};z.template=function(a,b,c){c=z.defaults(c||{},z.templateSettings);var d="__p+='"+a.replace(H,function(a){return"\\"+F[a]}).replace(c.escape||E,function(a,b){return"'+\n_.escape("+J(b)+")+\n'"}).replace(c.interpolate||E,function(a,b){return"'+\n("+J(b)+")+\n'"}).replace(c.evaluate||E,function(a,b){return"';\n"+J(b)+"\n;__p+='"})+"';\n";c.variable||(d="with(obj||{}){\n"+d+"}\n"),d="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+d+"return __p;\n";var e=new Function(c.variable||"obj","_",d);if(b)return e(b,z);var f=function(a){return e.call(this,a,z)};return f.source="function("+(c.variable||"obj")+"){\n"+d+"}",f},z.chain=function(a){return z(a).chain()};var K=function(a){this._wrapped=a};z.prototype=K.prototype;var L=function(a,b){return b?z(a).chain():a},M=function(a,b){K.prototype[a]=function(){var a=j.call(arguments);return k.call(a,this._wrapped),L(b.apply(z,a),this._chain)}};z.mixin(z),A(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=g[a];K.prototype[a]=function(){var c=this._wrapped;b.apply(c,arguments);var d=c.length;return"shift"!=a&&"splice"!=a||0!==d||delete c[0],L(c,this._chain)}}),A(["concat","join","slice"],function(a){var b=g[a];K.prototype[a]=function(){return L(b.apply(this._wrapped,arguments),this._chain)}}),K.prototype.chain=function(){return this._chain=!0,this},K.prototype.value=function(){return this._wrapped}}).call(this)},{}],12:[function(require,module,exports){var Object_keys=function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)b.push(c);return b},forEach=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c++)b(a[c],c,a)},Script=exports.Script=function(a){return this instanceof Script?(this.code=a,void 0):new Script(a)};Script.prototype.runInNewContext=function(a){a||(a={});var b=document.createElement("iframe");b.style||(b.style={}),b.style.display="none",document.body.appendChild(b);var c=b.contentWindow;forEach(Object_keys(a),function(b){c[b]=a[b]}),!c.eval&&c.execScript&&c.execScript("null");var d=c.eval(this.code);return forEach(Object_keys(c),function(b){a[b]=c[b]}),document.body.removeChild(b),d},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInContext=function(a){return this.runInNewContext(a)},forEach(Object_keys(Script.prototype),function(a){exports[a]=Script[a]=function(b){var c=Script(b);return c[a].apply(c,[].slice.call(arguments,1))}}),exports.createScript=function(a){return exports.Script(a)},exports.createContext=Script.createContext=function(a){var b={};return"object"==typeof a&&forEach(Object_keys(a),function(c){b[c]=a[c]}),b}},{}],13:[function(){},{}],14:[function(a,b){b.exports={parser:a("./src/parser"),Resource:a("./src/resource")}},{"./src/parser":18,"./src/resource":19}],15:[function(a,b,c){var d="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};(function(){function a(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d<e;)if(a[d]===b)return d;return-1}function e(b,c){var d=typeof c;if(b=b.cache,"boolean"==d||null==c)return b[c]?0:-1;"number"!=d&&"string"!=d&&(d="object");var e="number"==d?c:v+c;return b=(b=b[d])&&b[e],"object"==d?b&&a(b,c)>-1?0:-1:b?0:-1}function f(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:v+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function g(a){return a.charCodeAt(0)}function h(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||"undefined"==typeof c)return 1;if(d>c||"undefined"==typeof d)return-1}return a.index-b.index}function i(a){var b=-1,c=a.length,d=a[0],e=a[c/2|0],g=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&g&&"object"==typeof g)return!1;var h=l();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=l();for(i.array=a,i.cache=h,i.push=f;++b<c;)i.push(a[b]);return i}function j(a){return"\\"+Z[a]}function k(){return s.pop()||[]}function l(){return t.pop()||{array:null,cache:null,criteria:null,"false":!1,index:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,value:null}}function m(){}function n(a){a.length=0,s.length<x&&s.push(a)}function o(a){var b=a.cache;b&&o(b),a.array=a.cache=a.criteria=a.object=a.number=a.string=a.value=null,t.length<x&&t.push(a)}function p(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);for(var d=-1,e=c-b||0,f=Array(0>e?0:e);++d<e;)f[d]=a[b+d];return f}function q(b){function c(a){return a&&"object"==typeof a&&!Xd(a)&&yd.call(a,"__wrapped__")?a:new d(a)}function d(a,b){this.__chain__=!!b,this.__wrapped__=a}function f(a,b,c,d,e){if(c){var g=c(a);if("undefined"!=typeof g)return g}var h=Ab(a);if(!h)return a;var i=Ed.call(a);if(!V[i])return a;var j=Ud[i];switch(i){case O:case P:return new j(+a);case R:case U:return new j(a);case T:return g=j(a.source,D.exec(a)),g.lastIndex=a.lastIndex,g}var l=Xd(a);if(b){var m=!d;d||(d=k()),e||(e=k());for(var o=d.length;o--;)if(d[o]==a)return e[o];g=l?j(a.length):{}}else g=l?p(a):ce({},a);return l&&(yd.call(a,"index")&&(g.index=a.index),yd.call(a,"input")&&(g.input=a.input)),b?(d.push(a),e.push(g),(l?Tb:fe)(a,function(a,h){g[h]=f(a,b,c,d,e)}),m&&(n(d),n(e)),g):g}function s(a,b,c){if("function"!=typeof a)return Tc;if("undefined"==typeof b)return a;var d=a.__bindData__||Vd.funcNames&&!a.name;if("undefined"==typeof d){var e=I&&wd.call(a);Vd.funcNames||!e||E.test(e)||(d=!0),(Vd.funcNames||!d)&&(d=!Vd.funcDecomp||I.test(e),Wd(a,d))}if(d!==!0&&d&&1&d[1])return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return Dc(a,b)}function t(a,b,c,d){for(var e=(d||0)-1,f=a?a.length:0,g=[];++e<f;){var h=a[e];if(h&&"object"==typeof h&&"number"==typeof h.length&&(Xd(h)||jb(h))){b||(h=t(h,b,c));var i=-1,j=h.length,k=g.length;for(g.length+=j;++i<j;)g[k++]=h[i]}else c||g.push(h)}return g}function x(a,b,c,d,e,f){if(c){var g=c(a,b);if("undefined"!=typeof g)return!!g}if(a===b)return 0!==a||1/a==1/b;var h=typeof a,i=typeof b;if(!(a!==a||a&&Y[h]||b&&Y[i]))return!1;if(null==a||null==b)return a===b;var j=Ed.call(a),l=Ed.call(b);if(j==M&&(j=S),l==M&&(l=S),j!=l)return!1;switch(j){case O:case P:return+a==+b;case R:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case T:case U:return a==nd(b)}var m=j==N;if(!m){if(yd.call(a,"__wrapped__ ")||yd.call(b,"__wrapped__"))return x(a.__wrapped__||a,b.__wrapped__||b,c,d,e,f);if(j!=S)return!1;var o=a.constructor,p=b.constructor;if(o!=p&&!(zb(o)&&o instanceof o&&zb(p)&&p instanceof p))return!1}var q=!e;e||(e=k()),f||(f=k());for(var r=e.length;r--;)if(e[r]==a)return f[r]==b;var s=0;if(g=!0,e.push(a),f.push(b),m){if(r=a.length,s=b.length,g=s==a.length,!g&&!d)return g;for(;s--;){var t=r,u=b[s];if(d)for(;t--&&!(g=x(a[t],u,c,d,e,f)););else if(!(g=x(a[s],u,c,d,e,f)))break}return g}return ee(b,function(b,h,i){return yd.call(i,h)?(s++,g=yd.call(a,h)&&x(a[h],b,c,d,e,f)):void 0}),g&&!d&&ee(a,function(a,b,c){return yd.call(c,b)?g=--s>-1:void 0}),q&&(n(e),n(f)),g}function Z(a,b,c,d,e){(Xd(b)?Tb:fe)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Xd(b))||ge(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Xd(j)?j:[]:ge(j)?j:{}),d.push(b),e.push(j),l||Z(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function _(b,c,d){var f=-1,g=gb(),h=b?b.length:0,j=[],l=!c&&h>=w&&g===a,m=d||l?k():j;if(l){var p=i(m);p?(g=e,m=p):(l=!1,m=d?m:(n(m),j))}for(;++f<h;){var q=b[f],r=d?d(q,f,b):q;(c?!f||m[m.length-1]!==r:g(m,r)<0)&&((d||l)&&m.push(r),j.push(q))}return l?(n(m.array),o(m)):d&&n(m),j}function ab(a){return function(b,d,e){var f={};d=c.createCallback(d,e,3);var g=-1,h=b?b.length:0;if("number"==typeof h)for(;++g<h;){var i=b[g];a(f,i,d(i,g,b),b)}else fe(b,function(b,c,e){a(f,b,d(b,c,e),e)});return f}}function cb(a,b,c,d,e,f){var g=1&b,h=2&b,i=4&b,j=8&b,k=16&b,l=32&b,m=a;if(!h&&!zb(a))throw new od;k&&!c.length&&(b&=-17,k=c=!1),l&&!d.length&&(b&=-33,l=d=!1);var n=a&&a.__bindData__;if(n)return!g||1&n[1]||(n[4]=e),!g&&1&n[1]&&(b|=8),!i||4&n[1]||(n[5]=f),k&&Ad.apply(n[2]||(n[2]=[]),c),l&&Ad.apply(n[3]||(n[3]=[]),d),n[1]|=b,cb.apply(null,n);if(g&&!(h||i||l)&&(Vd.fastBind||Hd&&k)){if(k){var o=[e];Ad.apply(o,c)}var p=k?Hd.apply(a,o):Hd.call(a,e)}else p=function(){var n=arguments,o=g?e:this;if((i||k||l)&&(n=Rd.call(n),k&&Fd.apply(n,c),l&&Ad.apply(n,d),i&&n.length<f))return b|=16,cb(a,j?b:-4&b,n,null,e,f);if(h&&(a=o[m]),this instanceof p){o=eb(a.prototype);var q=a.apply(o,n);return Ab(q)?q:o}return a.apply(o,n)};return Wd(p,Rd.call(arguments)),p}function eb(a){return Ab(a)?Id(a):{}}function fb(a){return $d[a]}function gb(){var b=(b=c.indexOf)===nc?a:b;return b}function hb(a){var b,c;return a&&Ed.call(a)==S&&(b=a.constructor,!zb(b)||b instanceof b)?(ee(a,function(a,b){c=b}),"undefined"==typeof c||yd.call(a,c)):!1}function ib(a){return _d[a]}function jb(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ed.call(a)==M||!1}function kb(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=b,b=!1),f(a,b,"function"==typeof c&&s(c,d,1))}function lb(a,b,c){return f(a,!0,"function"==typeof b&&s(b,c,1))}function mb(a,b,d){var e;return b=c.createCallback(b,d,3),fe(a,function(a,c,d){return b(a,c,d)?(e=c,!1):void 0}),e}function nb(a,b,d){var e;return b=c.createCallback(b,d,3),pb(a,function(a,c,d){return b(a,c,d)?(e=c,!1):void 0}),e}function ob(a,b,c){var d=[];ee(a,function(a,b){d.push(b,a)});var e=d.length;for(b=s(b,c,3);e--&&b(d[e--],d[e],a)!==!1;);return a}function pb(a,b,c){var d=Zd(a),e=d.length;for(b=s(b,c,3);e--;){var f=d[e];if(b(a[f],f,a)===!1)break}return a}function qb(a){var b=[];return ee(a,function(a,c){zb(a)&&b.push(c)}),b.sort()}function rb(a,b){return a?yd.call(a,b):!1}function sb(a){for(var b=-1,c=Zd(a),d=c.length,e={};++b<d;){var f=c[b];e[a[f]]=f}return e}function tb(a){return a===!0||a===!1||Ed.call(a)==O}function ub(a){return a?"object"==typeof a&&Ed.call(a)==P:!1}function vb(a){return a?1===a.nodeType:!1}function wb(a){var b=!0;if(!a)return b;var c=Ed.call(a),d=a.length;return c==N||c==U||c==M||c==S&&"number"==typeof d&&zb(a.splice)?!d:(fe(a,function(){return b=!1}),b)}function xb(a,b,c,d){return x(a,b,"function"==typeof c&&s(c,d,2))}function yb(a){return Kd(a)&&!Ld(parseFloat(a))}function zb(a){return"function"==typeof a}function Ab(a){return!(!a||!Y[typeof a])}function Bb(a){return Db(a)&&a!=+a}function Cb(a){return null===a}function Db(a){return"number"==typeof a||Ed.call(a)==R}function Eb(a){return a?"object"==typeof a&&Ed.call(a)==T:!1}function Fb(a){return"string"==typeof a||Ed.call(a)==U}function Gb(a){return"undefined"==typeof a}function Hb(a){var b=arguments,c=2;if(!Ab(a))return a;if("number"!=typeof b[2]&&(c=b.length),c>3&&"function"==typeof b[c-2])var d=s(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=Rd.call(arguments,1,c),f=-1,g=k(),h=k();++f<c;)Z(a,e[f],d,g,h);return n(g),n(h),a}function Ib(a,b,d){var e=gb(),f="function"==typeof b,g={};if(f)b=c.createCallback(b,d,3);else var h=t(arguments,!0,!1,1);return ee(a,function(a,c,d){(f?!b(a,c,d):e(h,c)<0)&&(g[c]=a)}),g}function Jb(a){for(var b=-1,c=Zd(a),d=c.length,e=fd(d);++b<d;){var f=c[b];e[b]=[f,a[f]]}return e}function Kb(a,b,d){var e={};if("function"!=typeof b)for(var f=-1,g=t(arguments,!0,!1,1),h=Ab(a)?g.length:0;++f<h;){var i=g[f];i in a&&(e[i]=a[i])}else b=c.createCallback(b,d,3),ee(a,function(a,c,d){b(a,c,d)&&(e[c]=a)});return e}function Lb(a,b,c,d){var e=Xd(a);if(b=s(b,d,4),null==c)if(e)c=[];else{var f=a&&a.constructor,g=f&&f.prototype;c=eb(g)}return(e?Tb:fe)(a,function(a,d,e){return b(c,a,d,e)}),c}function Mb(a){for(var b=-1,c=Zd(a),d=c.length,e=fd(d);++b<d;)e[b]=a[c[b]];return e}function Nb(a){for(var b=arguments,c=-1,d=t(b,!0,!1,1),e=b[2]&&b[2][b[1]]===a?1:d.length,f=fd(e);++c<e;)f[c]=a[d[c]];return f}function Ob(a,b,c){var d=-1,e=gb(),f=a?a.length:0,g=!1;return c=(0>c?Nd(0,f+c):c)||0,Xd(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Fb(a)?a.indexOf(b,c):e(a,b,c))>-1:fe(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Pb(a,b,d){var e=!0;b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&(e=!!b(a[f],f,a)););else fe(a,function(a,c,d){return e=!!b(a,c,d)});return e}function Qb(a,b,d){var e=[];b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g;){var h=a[f];b(h,f,a)&&e.push(h)}else fe(a,function(a,c,d){b(a,c,d)&&e.push(a)});return e}function Rb(a,b,d){b=c.createCallback(b,d,3);var e=-1,f=a?a.length:0;if("number"!=typeof f){var g;return fe(a,function(a,c,d){return b(a,c,d)?(g=a,!1):void 0}),g}for(;++e<f;){var h=a[e];if(b(h,e,a))return h}}function Sb(a,b,d){var e;return b=c.createCallback(b,d,3),Ub(a,function(a,c,d){return b(a,c,d)?(e=a,!1):void 0}),e}function Tb(a,b,c){var d=-1,e=a?a.length:0;if(b=b&&"undefined"==typeof c?b:s(b,c,3),"number"==typeof e)for(;++d<e&&b(a[d],d,a)!==!1;);else fe(a,b);return a}function Ub(a,b,c){var d=a?a.length:0;if(b=b&&"undefined"==typeof c?b:s(b,c,3),"number"==typeof d)for(;d--&&b(a[d],d,a)!==!1;);else{var e=Zd(a);d=e.length,fe(a,function(a,c,f){return c=e?e[--d]:--d,b(f[c],c,f)})}return a}function Vb(a,b){var c=Rd.call(arguments,2),d=-1,e="function"==typeof b,f=a?a.length:0,g=fd("number"==typeof f?f:0);return Tb(a,function(a){g[++d]=(e?b:a[b]).apply(a,c)}),g}function Wb(a,b,d){var e=-1,f=a?a.length:0;if(b=c.createCallback(b,d,3),"number"==typeof f)for(var g=fd(f);++e<f;)g[e]=b(a[e],e,a);else g=[],fe(a,function(a,c,d){g[++e]=b(a,c,d)});return g}function Xb(a,b,d){var e=-1/0,f=e;if(!b&&Xd(a))for(var h=-1,i=a.length;++h<i;){var j=a[h];j>f&&(f=j)}else b=!b&&Fb(a)?g:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);g>e&&(e=g,f=a)});return f}function Yb(a,b,d){var e=1/0,f=e;if(!b&&Xd(a))for(var h=-1,i=a.length;++h<i;){var j=a[h];f>j&&(f=j)}else b=!b&&Fb(a)?g:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);e>g&&(e=g,f=a)});return f}function Zb(a,b){var c=-1,d=a?a.length:0;if("number"==typeof d)for(var e=fd(d);++c<d;)e[c]=a[c][b];return e||Wb(a,b)}function $b(a,b,c,d){if(!a)return c;var e=arguments.length<3;b=s(b,d,4);var f=-1,g=a.length;if("number"==typeof g)for(e&&(c=a[++f]);++f<g;)c=b(c,a[f],f,a);else fe(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)});return c}function _b(a,b,c,d){var e=arguments.length<3;return b=s(b,d,4),Ub(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)}),c}function ac(a,b,d){return b=c.createCallback(b,d,3),Qb(a,function(a,c,d){return!b(a,c,d)})}function bc(a,b,c){var d=a?a.length:0;if("number"!=typeof d&&(a=Mb(a)),null==b||c)return a?a[Wc(d-1)]:r;var e=cc(a);return e.length=Od(Nd(0,b),e.length),e}function cc(a){var b=-1,c=a?a.length:0,d=fd("number"==typeof c?c:0);return Tb(a,function(a){var c=Wc(++b);d[b]=d[c],d[c]=a}),d}function dc(a){var b=a?a.length:0;return"number"==typeof b?b:Zd(a).length}function ec(a,b,d){var e;b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&!(e=b(a[f],f,a)););else fe(a,function(a,c,d){return!(e=b(a,c,d))});return!!e}function fc(a,b,d){var e=-1,f=a?a.length:0,g=fd("number"==typeof f?f:0);for(b=c.createCallback(b,d,3),Tb(a,function(a,c,d){var f=g[++e]=l();f.criteria=b(a,c,d),f.index=e,f.value=a}),f=g.length,g.sort(h);f--;){var i=g[f];g[f]=i.value,o(i)}return g}function gc(a){return a&&"number"==typeof a.length?p(a):Mb(a)}function hc(a){for(var b=-1,c=a?a.length:0,d=[];++b<c;){var e=a[b];e&&d.push(e)}return d}function ic(b){var c=-1,d=gb(),f=b?b.length:0,g=t(arguments,!0,!0,1),h=[],j=f>=w&&d===a;if(j){var k=i(g);k?(d=e,g=k):j=!1}for(;++c<f;){var l=b[c];d(g,l)<0&&h.push(l)}return j&&o(g),h}function jc(a,b,d){var e=-1,f=a?a.length:0;for(b=c.createCallback(b,d,3);++e<f;)if(b(a[e],e,a))return e;return-1}function kc(a,b,d){var e=a?a.length:0;for(b=c.createCallback(b,d,3);e--;)if(b(a[e],e,a))return e;return-1}function lc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=-1;for(b=c.createCallback(b,d,3);++g<f&&b(a[g],g,a);)e++}else if(e=b,null==e||d)return a?a[0]:r;return p(a,0,Od(Nd(0,e),f))}function mc(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=d&&d[b]===a?null:b,b=!1),null!=c&&(a=Wb(a,c,d)),t(a,b)}function nc(b,c,d){if("number"==typeof d){var e=b?b.length:0;d=0>d?Nd(0,e+d):d||0}else if(d){var f=wc(b,c);return b[f]===c?f:-1}return a(b,c,d)}function oc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=f;for(b=c.createCallback(b,d,3);g--&&b(a[g],g,a);)e++}else e=null==b||d?1:b||e;return p(a,0,Od(Nd(0,f-e),f))}function pc(b){for(var c=arguments,d=c.length,f=-1,g=k(),h=-1,j=gb(),l=b?b.length:0,m=[],p=k();++f<d;){var q=c[f];g[f]=j===a&&(q?q.length:0)>=w&&i(f?c[f]:p)}a:for(;++h<l;){var r=g[0];if(q=b[h],(r?e(r,q):j(p,q))<0){for(f=d,(r||p).push(q);--f;)if(r=g[f],(r?e(r,q):j(c[f],q))<0)continue a;m.push(q)}}for(;d--;)r=g[d],r&&o(r);return n(g),n(p),m}function qc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=f;for(b=c.createCallback(b,d,3);g--&&b(a[g],g,a);)e++}else if(e=b,null==e||d)return a?a[f-1]:r;return p(a,Nd(0,f-e))}function rc(a,b,c){var d=a?a.length:0;for("number"==typeof c&&(d=(0>c?Nd(0,d+c):Od(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function sc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++c<d;)for(var f=-1,g=b[c];++f<e;)a[f]===g&&(Dd.call(a,f--,1),e--);return a}function tc(a,b,c){a=+a||0,c="number"==typeof c?c:+c||1,null==b&&(b=a,a=0);for(var d=-1,e=Nd(0,td((b-a)/(c||1))),f=fd(e);++d<e;)f[d]=a,a+=c;return f}function uc(a,b,d){var e=-1,f=a?a.length:0,g=[];for(b=c.createCallback(b,d,3);++e<f;){var h=a[e];b(h,e,a)&&(g.push(h),Dd.call(a,e--,1),f--)}return g}function vc(a,b,d){if("number"!=typeof b&&null!=b){var e=0,f=-1,g=a?a.length:0;for(b=c.createCallback(b,d,3);++f<g&&b(a[f],f,a);)e++}else e=null==b||d?1:Nd(0,b);return p(a,e)}function wc(a,b,d,e){var f=0,g=a?a.length:f;for(d=d?c.createCallback(d,e,1):Tc,b=d(b);g>f;){var h=f+g>>>1;d(a[h])<b?f=h+1:g=h}return f}function xc(){return _(t(arguments,!0,!0))}function yc(a,b,d,e){return"boolean"!=typeof b&&null!=b&&(e=d,d=e&&e[b]===a?null:b,b=!1),null!=d&&(d=c.createCallback(d,e,3)),_(a,b,d)}function zc(a){return ic(a,Rd.call(arguments,1))}function Ac(){for(var a=arguments.length>1?arguments:arguments[0],b=-1,c=a?Xb(Zb(a,"length")):0,d=fd(0>c?0:c);++b<c;)d[b]=Zb(a,b);return d}function Bc(a,b){for(var c=-1,d=a?a.length:0,e={};++c<d;){var f=a[c];b?e[f]=b[c]:f&&(e[f[0]]=f[1])}return e}function Cc(a,b){if(!zb(b))throw new od;return function(){return--a<1?b.apply(this,arguments):void 0}}function Dc(a,b){return arguments.length>2?cb(a,17,Rd.call(arguments,2),null,b):cb(a,1,null,null,b)}function Ec(a){for(var b=arguments.length>1?t(arguments,!0,!1,1):qb(a),c=-1,d=b.length;++c<d;){var e=b[c];a[e]=cb(a[e],1,null,null,a)}return a}function Fc(a,b){return arguments.length>2?cb(b,19,Rd.call(arguments,2),null,a):cb(b,3,null,null,a)}function Gc(){for(var a=arguments,b=a.length;b--;)if(!zb(a[b]))throw new od;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Hc(a,b,c){var d=typeof a;if(null==a||"function"==d)return s(a,b,c);if("object"!=d)return function(b){return b[a]};var e=Zd(a),f=e[0],g=a[f];return 1!=e.length||g!==g||Ab(g)?function(b){for(var c=e.length,d=!1;c--&&(d=x(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return g===b&&(0!==g||1/g==1/b)}}function Ic(a,b){return b="number"==typeof b?b:+b||a.length,cb(a,4,null,null,null,b)}function Jc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!zb(a))throw new od;if(b=Nd(0,b)||0,c===!0){var n=!0;m=!1}else Ab(c)&&(n=c.leading,l="maxWait"in c&&(Nd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(zd()-g);if(0>=c){e&&ud(e);var l=j;e=i=j=r,l&&(k=zd(),f=a.apply(h,d))}else i=Cd(o,c)},p=function(){i&&ud(i),e=i=j=r,(m||l!==b)&&(k=zd(),f=a.apply(h,d))};return function(){if(d=arguments,g=zd(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k);0>=q?(e&&(e=ud(e)),k=g,f=a.apply(h,d)):e||(e=Cd(p,q))}return i||b===l||(i=Cd(o,b)),c&&(f=a.apply(h,d)),f}}function Kc(a){if(!zb(a))throw new od;var b=Rd.call(arguments,1);return Cd(function(){a.apply(r,b)},1)}function Lc(a,b){if(!zb(a))throw new od;var c=Rd.call(arguments,2);return Cd(function(){a.apply(r,c)},b)}function Mc(a,b){if(!zb(a))throw new od;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):v+arguments[0];return yd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Nc(a){var b,c;if(!zb(a))throw new od;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Oc(a){return cb(a,16,Rd.call(arguments,1))}function Pc(a){return cb(a,32,null,Rd.call(arguments,1))}function Qc(a,b,c){var d=!0,e=!0;if(!zb(a))throw new od;c===!1?d=!1:Ab(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),W.leading=d,W.maxWait=b,W.trailing=e;var f=Jc(a,b,W);return f}function Rc(a,b){if(!zb(b))throw new od;return function(){var c=[a];return Ad.apply(c,arguments),b.apply(this,c)}}function Sc(a){return null==a?"":nd(a).replace(be,fb)}function Tc(a){return a}function Uc(a,b){var e=a,f=!b||zb(e);b||(e=d,b=a,a=c),Tb(qb(b),function(c){var d=a[c]=b[c];f&&(e.prototype[c]=function(){var b=this.__wrapped__,c=[b];Ad.apply(c,arguments);var f=d.apply(a,c);return b&&"object"==typeof b&&b===f?this:(f=new e(f),f.__chain__=this.__chain__,f)})})}function Vc(){return b._=rd,this}function Wc(a,b,c){var d=null==a,e=null==b;null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0;var f=Qd();return c||a%1||b%1?Od(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b):a+vd(f*(b-a+1))}function Xc(a,b){if(a){var c=a[b];return zb(c)?a[b]():c}}function Yc(a,b,d){var e=c.templateSettings;a||(a=""),d=de({},d,e);var f,g=de({},d.imports,e.imports),h=Zd(g),i=Mb(g),k=0,l=d.interpolate||H,m="__p += '",n=md((d.escape||H).source+"|"+l.source+"|"+(l===F?C:H).source+"|"+(d.evaluate||H).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(k,h).replace(J,j),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),k=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(z,""):m).replace(A,"$1").replace(B,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+L++ +"]")+"\n*/";try{var s=id(h,"return "+m+q).apply(r,i)}catch(t){throw t.source=m,t}return b?s(b):(s.source=m,s)}function Zc(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=fd(a);for(b=s(b,c,1);++d<a;)e[d]=b(d);return e}function $c(a){return null==a?"":nd(a).replace(ae,ib)}function _c(a){var b=++u;return nd(null==a?"":a)+b}function ad(a){return a=new d(a),a.__chain__=!0,a}function bd(a,b){return b(a),a}function cd(){return this.__chain__=!0,this}function dd(){return nd(this.__wrapped__)}function ed(){return this.__wrapped__}b=b?db.defaults($.Object(),b,db.pick($,K)):$;var fd=b.Array,gd=b.Boolean,hd=b.Date,id=b.Function,jd=b.Math,kd=b.Number,ld=b.Object,md=b.RegExp,nd=b.String,od=b.TypeError,pd=[],qd=ld.prototype,rd=b._,sd=md("^"+nd(qd.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),td=jd.ceil,ud=b.clearTimeout,vd=jd.floor,wd=id.prototype.toString,xd=sd.test(xd=ld.getPrototypeOf)&&xd,yd=qd.hasOwnProperty,zd=sd.test(zd=hd.now)&&zd||function(){return+new hd},Ad=pd.push,Bd=b.setImmediate,Cd=b.setTimeout,Dd=pd.splice,Ed=qd.toString,Fd=pd.unshift,Gd=function(){try{var a={},b=sd.test(b=ld.defineProperty)&&b,c=b(a,a,a)&&b}catch(d){}return c}(),Hd=sd.test(Hd=Ed.bind)&&Hd,Id=sd.test(Id=ld.create)&&Id,Jd=sd.test(Jd=fd.isArray)&&Jd,Kd=b.isFinite,Ld=b.isNaN,Md=sd.test(Md=ld.keys)&&Md,Nd=jd.max,Od=jd.min,Pd=b.parseInt,Qd=jd.random,Rd=pd.slice,Sd=sd.test(b.attachEvent),Td=Hd&&!/\n|true/.test(Hd+Sd),Ud={};Ud[N]=fd,Ud[O]=gd,Ud[P]=hd,Ud[Q]=id,Ud[S]=ld,Ud[R]=kd,Ud[T]=md,Ud[U]=nd,d.prototype=c.prototype;var Vd=c.support={};Vd.fastBind=Hd&&!Td,Vd.funcDecomp=!sd.test(b.WinRTError)&&I.test(q),Vd.funcNames="string"==typeof id.name,c.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:c}},Id||(eb=function(a){if(Ab(a)){m.prototype=a;var b=new m;m.prototype=null}return b||{}});var Wd=Gd?function(a,b){X.value=b,Gd(a,"__bindData__",X)}:m,Xd=Jd||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ed.call(a)==N||!1},Yd=function(a){var b,c=a,d=[];if(!c)return d;if(!Y[typeof a])return d;for(b in c)yd.call(c,b)&&d.push(b);return d},Zd=Md?function(a){return Ab(a)?Md(a):[]}:Yd,$d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_d=sb($d),ae=md("("+Zd(_d).join("|")+")","g"),be=md("["+Zd($d).join("")+"]","g"),ce=function(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=s(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h<i;)if(e=g[h],e&&Y[typeof e])for(var k=-1,l=Y[typeof e]&&Zd(e),m=l?l.length:0;++k<m;)d=l[k],f[d]=j?j(f[d],e[d]):e[d];return f},de=function(a,b,c){var d,e=a,f=e;if(!e)return f;for(var g=arguments,h=0,i="number"==typeof c?2:g.length;++h<i;)if(e=g[h],e&&Y[typeof e])for(var j=-1,k=Y[typeof e]&&Zd(e),l=k?k.length:0;++j<l;)d=k[j],"undefined"==typeof f[d]&&(f[d]=e[d]);return f},ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:s(b,c,3);for(d in e)if(b(e[d],d,a)===!1)return f;return f},fe=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:s(b,c,3);for(var g=-1,h=Y[typeof e]&&Zd(e),i=h?h.length:0;++g<i;)if(d=h[g],b(e[d],d,a)===!1)return f;return f},ge=function(a){if(!a||Ed.call(a)!=S)return!1;var b=a.valueOf,c="function"==typeof b&&(c=xd(b))&&xd(c);return c?a==c||xd(a)==c:hb(a)},he=ab(function(a,b,c){yd.call(a,c)?a[c]++:a[c]=1}),ie=ab(function(a,b,c){(yd.call(a,c)?a[c]:a[c]=[]).push(b)}),je=ab(function(a,b,c){a[c]=b}),ke=Qb;Td&&bb&&"function"==typeof Bd&&(Kc=function(a){if(!zb(a))throw new od;return Bd.apply(b,arguments)});var le=8==Pd(y+"08")?Pd:function(a,b){return Pd(Fb(a)?a.replace(G,""):a,b||0)};return c.after=Cc,c.assign=ce,c.at=Nb,c.bind=Dc,c.bindAll=Ec,c.bindKey=Fc,c.chain=ad,c.compact=hc,c.compose=Gc,c.countBy=he,c.createCallback=Hc,c.curry=Ic,c.debounce=Jc,c.defaults=de,c.defer=Kc,c.delay=Lc,c.difference=ic,c.filter=Qb,c.flatten=mc,c.forEach=Tb,c.forEachRight=Ub,c.forIn=ee,c.forInRight=ob,c.forOwn=fe,c.forOwnRight=pb,c.functions=qb,c.groupBy=ie,c.indexBy=je,c.initial=oc,c.intersection=pc,c.invert=sb,c.invoke=Vb,c.keys=Zd,c.map=Wb,c.max=Xb,c.memoize=Mc,c.merge=Hb,c.min=Yb,c.omit=Ib,c.once=Nc,c.pairs=Jb,c.partial=Oc,c.partialRight=Pc,c.pick=Kb,c.pluck=Zb,c.pull=sc,c.range=tc,c.reject=ac,c.remove=uc,c.rest=vc,c.shuffle=cc,c.sortBy=fc,c.tap=bd,c.throttle=Qc,c.times=Zc,c.toArray=gc,c.transform=Lb,c.union=xc,c.uniq=yc,c.values=Mb,c.where=ke,c.without=zc,c.wrap=Rc,c.zip=Ac,c.zipObject=Bc,c.collect=Wb,c.drop=vc,c.each=Tb,c.eachRight=Ub,c.extend=ce,c.methods=qb,c.object=Bc,c.select=Qb,c.tail=vc,c.unique=yc,c.unzip=Ac,Uc(c),c.clone=kb,c.cloneDeep=lb,c.contains=Ob,c.escape=Sc,c.every=Pb,c.find=Rb,c.findIndex=jc,c.findKey=mb,c.findLast=Sb,c.findLastIndex=kc,c.findLastKey=nb,c.has=rb,c.identity=Tc,c.indexOf=nc,c.isArguments=jb,c.isArray=Xd,c.isBoolean=tb,c.isDate=ub,c.isElement=vb,c.isEmpty=wb,c.isEqual=xb,c.isFinite=yb,c.isFunction=zb,c.isNaN=Bb,c.isNull=Cb,c.isNumber=Db,c.isObject=Ab,c.isPlainObject=ge,c.isRegExp=Eb,c.isString=Fb,c.isUndefined=Gb,c.lastIndexOf=rc,c.mixin=Uc,c.noConflict=Vc,c.parseInt=le,c.random=Wc,c.reduce=$b,c.reduceRight=_b,c.result=Xc,c.runInContext=q,c.size=dc,c.some=ec,c.sortedIndex=wc,c.template=Yc,c.unescape=$c,c.uniqueId=_c,c.all=Pb,c.any=ec,c.detect=Rb,c.findWhere=Rb,c.foldl=$b,c.foldr=_b,c.include=Ob,c.inject=$b,fe(c,function(a,b){c.prototype[b]||(c.prototype[b]=function(){var b=[this.__wrapped__],e=this.__chain__;Ad.apply(b,arguments);var f=a.apply(c,b);return e?new d(f,e):f})}),c.first=lc,c.last=qc,c.sample=bc,c.take=lc,c.head=lc,fe(c,function(a,b){var e="sample"!==b;c.prototype[b]||(c.prototype[b]=function(b,c){var f=this.__chain__,g=a(this.__wrapped__,b,c);return f||null!=b&&(!c||e&&"function"==typeof b)?new d(g,f):g})}),c.VERSION="2.2.1",c.prototype.chain=cd,c.prototype.toString=dd,c.prototype.value=ed,c.prototype.valueOf=ed,Tb(["join","pop","shift"],function(a){var b=pd[a];c.prototype[a]=function(){var a=this.__chain__,c=b.apply(this.__wrapped__,arguments);return a?new d(c,a):c}}),Tb(["push","reverse","sort","unshift"],function(a){var b=pd[a];c.prototype[a]=function(){return b.apply(this.__wrapped__,arguments),this}}),Tb(["concat","slice","splice"],function(a){var b=pd[a];c.prototype[a]=function(){return new d(b.apply(this.__wrapped__,arguments),this.__chain__)}}),c}var r,s=[],t=[],u=0,v=+new Date+"",w=75,x=40,y=" \f \n\r\u2028\u2029 ᠎              ",z=/\b__p \+= '';/g,A=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,E=/^function[ \n\r\t]+\w/,F=/<%=([\s\S]+?)%>/g,G=RegExp("^["+y+"]*0+(?=.$)"),H=/($^)/,I=/\bthis\b/,J=/['\n\r\t\u2028\u2029\\]/g,K=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setImmediate","setTimeout"],L=0,M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Function]",R="[object Number]",S="[object Object]",T="[object RegExp]",U="[object String]",V={};V[Q]=!1,V[M]=V[N]=V[O]=V[P]=V[R]=V[S]=V[T]=V[U]=!0;var W={leading:!1,maxWait:0,trailing:!1},X={configurable:!1,enumerable:!1,value:null,writable:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=Y[typeof window]&&window||this,_=Y[typeof c]&&c&&!c.nodeType&&c,ab=Y[typeof b]&&b&&!b.nodeType&&b,bb=ab&&ab.exports===_&&_,cb=Y[typeof d]&&d;!cb||cb.global!==cb&&cb.window!==cb||($=cb);var db=q();"function"==typeof define&&"object"==typeof define.amd&&define.amd?($._=db,define(function(){return db})):_&&ab?bb?(ab.exports=db)._=db:_._=db:$._=db}).call(this)},{}],16:[function(a,b){function c(a,b){"use strict";function c(b){return b in a}function e(c,e){return b?d["is"+e].call(void 0,a[c]):!0}if(b=null==b?!0:b,!d.isPlainObject(a))throw new TypeError("Invalid parameter passed to Link constructor");if(!c("href")){if(!b)return;throw new ReferenceError('Missing "href" property to link description')}if(this.templated=a.templated===!0,c("deprecation")&&!e("deprecation","Boolean")&&!e("deprecation","String"))throw new TypeError("Invalid Link deprecation provided");this.deprecated=!!a.deprecation,this.deprecationInfo=!a.deprecation||d.isBoolean(a.deprecation)?null:a.deprecation,["type","name","profile","title","href","hreflang"].forEach(function(b){if(c(b)&&null!=a[b]&&!e(b,"String"))throw new Error('Invalid link property "'+b+'" provided.');
+this[b]=a[b]}.bind(this))}var d=a("lodash");b.exports=c},{lodash:15}],17:[function(a,b){function c(a,b){"use strict";b=null==b?!0:b;var c={};if(this.get=function(a){return a?c[a]:c},a){if(!e.isPlainObject(a))throw new TypeError("The provided object is not an object literal.");Object.keys(a).forEach(function(f){var g=a[f];e.isArray(g)||(g=[g]);var h=g.map(function(a){return new d(a,b)});c[f]=h})}}var d=a("./link"),e=a("lodash");b.exports=c},{"./link":16,lodash:15}],18:[function(a,b){function c(a,b){"use strict";b=null==b?!0:b;var f=e.cloneDeep(a),g=f._links;delete f._links;var h=f._embedded;return delete f._embedded,new d(f,g,h,c,b)}var d=a("./resource"),e=a("lodash");b.exports=c},{"./resource":19,lodash:15}],19:[function(a,b){function c(a,b,c){"use strict";var d={},e=f.partialRight(b,c);return Object.keys(a).forEach(function(b){var c=a[b];d[b]=c.map?c.map(e):c}),d}function d(a,b,d,g,h){"use strict";var i=this;if(!f.isPlainObject(a))throw new Error("No object provided");var j=c(d||{},g,h),k=new e(b,h);this.toJSON=function(){return a},this.embedded=function(a){return a?j[a]:j},this.links=function(a){return a?k.get(a):k},Object.keys(a).forEach(function(b){i[b]=a[b]})}var e=a("./links"),f=a("lodash");b.exports=d},{"./links":17,lodash:15}],20:[function(a,b,c){!function(a,d){"use strict";function e(a,b){var c,d,e=a.toLowerCase();for(b=[].concat(b),c=0;c<b.length;c+=1)if(d=b[c]){if(d.test&&d.test(a))return!0;if(d.toLowerCase()===e)return!0}}var f=d.prototype.trim,g=d.prototype.trimRight,h=d.prototype.trimLeft,i=function(a){return 1*a||0},j=function(a,b){if(1>b)return"";for(var c="";b>0;)1&b&&(c+=a),b>>=1,a+=a;return c},k=[].slice,l=function(a){return null==a?"\\s":a.source?a.source:"["+q.escapeRegExp(a)+"]"},m={lt:"<",gt:">",quot:'"',amp:"&",apos:"'"},n={};for(var o in m)n[m[o]]=o;n["'"]="#39";var p=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}var b=j,c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,e){var f,g,h,i,j,k,l,m=1,n=c.length,o="",q=[];for(g=0;n>g;g++)if(o=a(c[g]),"string"===o)q.push(c[g]);else if("array"===o){if(i=c[g],i[2])for(f=e[m],h=0;h<i[2].length;h++){if(!f.hasOwnProperty(i[2][h]))throw new Error(p('[_.sprintf] property "%s" does not exist',i[2][h]));f=f[i[2][h]]}else f=i[1]?e[i[1]]:e[m++];if(/[^s]/.test(i[8])&&"number"!=a(f))throw new Error(p("[_.sprintf] expecting number but found %s",a(f)));switch(i[8]){case"b":f=f.toString(2);break;case"c":f=d.fromCharCode(f);break;case"d":f=parseInt(f,10);break;case"e":f=i[7]?f.toExponential(i[7]):f.toExponential();break;case"f":f=i[7]?parseFloat(f).toFixed(i[7]):parseFloat(f);break;case"o":f=f.toString(8);break;case"s":f=(f=d(f))&&i[7]?f.substring(0,i[7]):f;break;case"u":f=Math.abs(f);break;case"x":f=f.toString(16);break;case"X":f=f.toString(16).toUpperCase()}f=/[def]/.test(i[8])&&i[3]&&f>=0?"+"+f:f,k=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",l=i[6]-d(f).length,j=i[6]?b(k,l):"",q.push(i[5]?f+j:j+f)}return q.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw new Error("[_.sprintf] huh?");if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw new Error("[_.sprintf] huh?");for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw new Error("[_.sprintf] huh?");f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw new Error("[_.sprintf] mixing positional and named placeholders is not (yet) supported");d.push(c)}b=b.substring(c[0].length)}return d},c}(),q={VERSION:"2.3.0",isBlank:function(a){return null==a&&(a=""),/^\s*$/.test(a)},stripTags:function(a){return null==a?"":d(a).replace(/<\/?[^>]+>/g,"")},capitalize:function(a){return a=null==a?"":d(a),a.charAt(0).toUpperCase()+a.slice(1)},chop:function(a,b){return null==a?[]:(a=d(a),b=~~b,b>0?a.match(new RegExp(".{1,"+b+"}","g")):[a])},clean:function(a){return q.strip(a).replace(/\s+/g," ")},count:function(a,b){if(null==a||null==b)return 0;a=d(a),b=d(b);for(var c=0,e=0,f=b.length;;){if(e=a.indexOf(b,e),-1===e)break;c++,e+=f}return c},chars:function(a){return null==a?[]:d(a).split("")},swapCase:function(a){return null==a?"":d(a).replace(/\S/g,function(a){return a===a.toUpperCase()?a.toLowerCase():a.toUpperCase()})},escapeHTML:function(a){return null==a?"":d(a).replace(/[&<>"']/g,function(a){return"&"+n[a]+";"})},unescapeHTML:function(a){return null==a?"":d(a).replace(/\&([^;]+);/g,function(a,b){var c;return b in m?m[b]:(c=b.match(/^#x([\da-fA-F]+)$/))?d.fromCharCode(parseInt(c[1],16)):(c=b.match(/^#(\d+)$/))?d.fromCharCode(~~c[1]):a})},escapeRegExp:function(a){return null==a?"":d(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")},splice:function(a,b,c,d){var e=q.chars(a);return e.splice(~~b,~~c,d),e.join("")},insert:function(a,b,c){return q.splice(a,b,0,c)},include:function(a,b){return""===b?!0:null==a?!1:-1!==d(a).indexOf(b)},join:function(){var a=k.call(arguments),b=a.shift();return null==b&&(b=""),a.join(b)},lines:function(a){return null==a?[]:d(a).split("\n")},reverse:function(a){return q.chars(a).reverse().join("")},startsWith:function(a,b){return""===b?!0:null==a||null==b?!1:(a=d(a),b=d(b),a.length>=b.length&&a.slice(0,b.length)===b)},endsWith:function(a,b){return""===b?!0:null==a||null==b?!1:(a=d(a),b=d(b),a.length>=b.length&&a.slice(a.length-b.length)===b)},succ:function(a){return null==a?"":(a=d(a),a.slice(0,-1)+d.fromCharCode(a.charCodeAt(a.length-1)+1))},titleize:function(a){return null==a?"":(a=d(a).toLowerCase(),a.replace(/(?:^|\s|-)\S/g,function(a){return a.toUpperCase()}))},camelize:function(a){return q.trim(a).replace(/[-_\s]+(.)?/g,function(a,b){return b?b.toUpperCase():""})},underscored:function(a){return q.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()},dasherize:function(a){return q.trim(a).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},classify:function(a){return q.titleize(d(a).replace(/[\W_]/g," ")).replace(/\s/g,"")},humanize:function(a){return q.capitalize(q.underscored(a).replace(/_id$/,"").replace(/_/g," "))},trim:function(a,b){return null==a?"":!b&&f?f.call(a):(b=l(b),d(a).replace(new RegExp("^"+b+"+|"+b+"+$","g"),""))},ltrim:function(a,b){return null==a?"":!b&&h?h.call(a):(b=l(b),d(a).replace(new RegExp("^"+b+"+"),""))},rtrim:function(a,b){return null==a?"":!b&&g?g.call(a):(b=l(b),d(a).replace(new RegExp(b+"+$"),""))},truncate:function(a,b,c){return null==a?"":(a=d(a),c=c||"...",b=~~b,a.length>b?a.slice(0,b)+c:a)},prune:function(a,b,c){if(null==a)return"";if(a=d(a),b=~~b,c=null!=c?d(c):"...",a.length<=b)return a;var e=function(a){return a.toUpperCase()!==a.toLowerCase()?"A":" "},f=a.slice(0,b+1).replace(/.(?=\W*\w*$)/g,e);return f=f.slice(f.length-2).match(/\w\w/)?f.replace(/\s*\S+$/,""):q.rtrim(f.slice(0,f.length-1)),(f+c).length>a.length?a:a.slice(0,f.length)+c},words:function(a,b){return q.isBlank(a)?[]:q.trim(a,b).split(b||/\s+/)},pad:function(a,b,c,e){a=null==a?"":d(a),b=~~b;var f=0;switch(c?c.length>1&&(c=c.charAt(0)):c=" ",e){case"right":return f=b-a.length,a+j(c,f);case"both":return f=b-a.length,j(c,Math.ceil(f/2))+a+j(c,Math.floor(f/2));default:return f=b-a.length,j(c,f)+a}},lpad:function(a,b,c){return q.pad(a,b,c)},rpad:function(a,b,c){return q.pad(a,b,c,"right")},lrpad:function(a,b,c){return q.pad(a,b,c,"both")},sprintf:p,vsprintf:function(a,b){return b.unshift(a),p.apply(null,b)},toNumber:function(a,b){return a?(a=q.trim(a),a.match(/^-?\d+(?:\.\d+)?$/)?i(i(a).toFixed(~~b)):0/0):0},numberFormat:function(a,b,c,d){if(isNaN(a)||null==a)return"";a=a.toFixed(~~b),d="string"==typeof d?d:",";var e=a.split("."),f=e[0],g=e[1]?(c||".")+e[1]:"";return f.replace(/(\d)(?=(?:\d{3})+$)/g,"$1"+d)+g},strRight:function(a,b){if(null==a)return"";a=d(a),b=null!=b?d(b):b;var c=b?a.indexOf(b):-1;return~c?a.slice(c+b.length,a.length):a},strRightBack:function(a,b){if(null==a)return"";a=d(a),b=null!=b?d(b):b;var c=b?a.lastIndexOf(b):-1;return~c?a.slice(c+b.length,a.length):a},strLeft:function(a,b){if(null==a)return"";a=d(a),b=null!=b?d(b):b;var c=b?a.indexOf(b):-1;return~c?a.slice(0,c):a},strLeftBack:function(a,b){if(null==a)return"";a+="",b=null!=b?""+b:b;var c=a.lastIndexOf(b);return~c?a.slice(0,c):a},toSentence:function(a,b,c,d){b=b||", ",c=c||" and ";var e=a.slice(),f=e.pop();return a.length>2&&d&&(c=q.rtrim(b)+c),e.length?e.join(b)+c+f:f},toSentenceSerial:function(){var a=k.call(arguments);return a[3]=!0,q.toSentence.apply(q,a)},slugify:function(a){if(null==a)return"";var b="ąàáäâãåæăćęèéëêìíïîłńòóöôõøśșțùúüûñçżź",c="aaaaaaaaaceeeeeiiiilnoooooosstuuuunczz",e=new RegExp(l(b),"g");return a=d(a).toLowerCase().replace(e,function(a){var d=b.indexOf(a);return c.charAt(d)||"-"}),q.dasherize(a.replace(/[^\w\s-]/g,""))},surround:function(a,b){return[b,a,b].join("")},quote:function(a,b){return q.surround(a,b||'"')},unquote:function(a,b){return b=b||'"',a[0]===b&&a[a.length-1]===b?a.slice(1,a.length-1):a},exports:function(){var a={};for(var b in this)this.hasOwnProperty(b)&&!b.match(/^(?:include|contains|reverse)$/)&&(a[b]=this[b]);return a},repeat:function(a,b,c){if(null==a)return"";if(b=~~b,null==c)return j(d(a),b);for(var e=[];b>0;e[--b]=a);return e.join(c)},naturalCmp:function(a,b){if(a==b)return 0;if(!a)return-1;if(!b)return 1;for(var c=/(\.\d+)|(\d+)|(\D+)/g,e=d(a).toLowerCase().match(c),f=d(b).toLowerCase().match(c),g=Math.min(e.length,f.length),h=0;g>h;h++){var i=e[h],j=f[h];if(i!==j){var k=parseInt(i,10);if(!isNaN(k)){var l=parseInt(j,10);if(!isNaN(l)&&k-l)return k-l}return j>i?-1:1}}return e.length===f.length?e.length-f.length:b>a?-1:1},levenshtein:function(a,b){if(null==a&&null==b)return 0;if(null==a)return d(b).length;if(null==b)return d(a).length;a=d(a),b=d(b);for(var c,e,f=[],g=0;g<=b.length;g++)for(var h=0;h<=a.length;h++)e=g&&h?a.charAt(h-1)===b.charAt(g-1)?c:Math.min(f[h],f[h-1],c)+1:g+h,c=f[h],f[h]=e;return f.pop()},toBoolean:function(a,b,c){return"number"==typeof a&&(a=""+a),"string"!=typeof a?!!a:(a=q.trim(a),e(a,b||["true","1"])?!0:e(a,c||["false","0"])?!1:void 0)}};q.strip=q.trim,q.lstrip=q.ltrim,q.rstrip=q.rtrim,q.center=q.lrpad,q.rjust=q.lpad,q.ljust=q.rpad,q.contains=q.include,q.q=q.quote,q.toBool=q.toBoolean,"undefined"!=typeof c&&("undefined"!=typeof b&&b.exports&&(b.exports=q),c._s=q),"function"==typeof define&&define.amd&&define("underscore.string",[],function(){return q}),a._=a._||{},a._.string=a._.str=q}(this,String)},{}],21:[function(a,b){b.exports=function(){function b(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var c={parse:function(c,d){function e(a){v>t||(t>v&&(v=t,w=[]),w.push(a))}function f(){var a,b,c;for(c=t,a=[],b=o(),null===b&&(b=g());null!==b;)a.push(b),b=o(),null===b&&(b=g());return null!==a&&(a=function(a,b){return new y(b)}(c,a)),null===a&&(t=c),a}function g(){var a,b,d,f,g,i;return g=t,i=t,123===c.charCodeAt(t)?(a="{",t++):(a=null,0===u&&e('"{"')),null!==a?(b=h(),null!==b?(d=j(),null!==d?(125===c.charCodeAt(t)?(f="}",t++):(f=null,0===u&&e('"}"')),null!==f?a=[a,b,d,f]:(a=null,t=i)):(a=null,t=i)):(a=null,t=i)):(a=null,t=i),null!==a&&(a=function(a,b,c){return z(b,c)}(g,a[1],a[2])),null===a&&(t=g),a}function h(){var a;return/^[\/;:.?&+#]/.test(c.charAt(t))?(a=c.charAt(t),t++):(a=null,0===u&&e("[\\/;:.?&+#]")),null===a&&(a=""),a}function i(){var a;return"{/"===c.substr(t,2)?(a="{/",t+=2):(a=null,0===u&&e('"{/"')),a}function j(){var a,b,d,f,g,h,i,j;if(g=t,h=t,a=k(),null!==a){for(b=[],i=t,j=t,44===c.charCodeAt(t)?(d=",",t++):(d=null,0===u&&e('","')),null!==d?(f=k(),null!==f?d=[d,f]:(d=null,t=j)):(d=null,t=j),null!==d&&(d=function(a,b){return b}(i,d[1])),null===d&&(t=i);null!==d;)b.push(d),i=t,j=t,44===c.charCodeAt(t)?(d=",",t++):(d=null,0===u&&e('","')),null!==d?(f=k(),null!==f?d=[d,f]:(d=null,t=j)):(d=null,t=j),null!==d&&(d=function(a,b){return b}(i,d[1])),null===d&&(t=i);null!==b?a=[a,b]:(a=null,t=h)}else a=null,t=h;return null!==a&&(a=function(a,b,c){return c.unshift(b),c}(g,a[0],a[1])),null===a&&(t=g),a}function k(){var a,b,d,f,g;for(f=t,g=t,a=[],/^[a-zA-Z0-9_.%]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[a-zA-Z0-9_.%]"));null!==b;)a.push(b),/^[a-zA-Z0-9_.%]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[a-zA-Z0-9_.%]"));return null!==a?(b=l(),null===b&&(b=m()),b=null!==b?b:"",null!==b?(d=p(),d=null!==d?d:"",null!==d?a=[a,b,d]:(a=null,t=g)):(a=null,t=g)):(a=null,t=g),null!==a&&(a=function(a,b,c,d){return c=c||{},{name:b.join(""),explode:c.listMarker,cut:c.cut,extended:d}}(f,a[0],a[1],a[2])),null===a&&(t=f),a}function l(){var a,b;return b=t,a=n(),null!==a&&(a=function(a,b){return{cut:b}}(b,a)),null===a&&(t=b),a}function m(){var a,b;return b=t,42===c.charCodeAt(t)?(a="*",t++):(a=null,0===u&&e('"*"')),null!==a&&(a=function(a,b){return{listMarker:b}}(b,a)),null===a&&(t=b),a}function n(){var a,b,d,f,g;if(f=t,g=t,58===c.charCodeAt(t)?(a=":",t++):(a=null,0===u&&e('":"')),null!==a){if(/^[0-9]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[0-9]")),null!==d)for(b=[];null!==d;)b.push(d),/^[0-9]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[0-9]"));else b=null;null!==b?a=[a,b]:(a=null,t=g)}else a=null,t=g;return null!==a&&(a=function(a,b){return parseInt(b.join(""))}(f,a[1])),null===a&&(t=f),a}function o(){var a,b,d;if(d=t,/^[^{]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[^{]")),null!==b)for(a=[];null!==b;)a.push(b),/^[^{]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[^{]"));else a=null;return null!==a&&(a=function(a,b){return b.join("")}(d,a)),null===a&&(t=d),a}function p(){var a,b,d,f,g;if(f=t,g=t,40===c.charCodeAt(t)?(a="(",t++):(a=null,0===u&&e('"("')),null!==a){if(/^[^)]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[^)]")),null!==d)for(b=[];null!==d;)b.push(d),/^[^)]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[^)]"));else b=null;null!==b?(41===c.charCodeAt(t)?(d=")",t++):(d=null,0===u&&e('")"')),null!==d?a=[a,b,d]:(a=null,t=g)):(a=null,t=g)}else a=null,t=g;return null!==a&&(a=function(a,b){return b.join("")}(f,a[1])),null===a&&(t=f),a}function q(a){a.sort();for(var b=null,c=[],d=0;d<a.length;d++)a[d]!==b&&(c.push(a[d]),b=a[d]);return c}function r(){for(var a=1,b=1,d=!1,e=0;e<Math.max(t,v);e++){var f=c.charAt(e);"\n"===f?(d||a++,b=1,d=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(a++,b=1,d=!0):(b++,d=!1)}return{line:a,column:b}}var s={uriTemplate:f,expression:g,op:h,pathExpression:i,paramList:j,param:k,cut:l,listMarker:m,substr:n,nonexpression:o,extension:p};if(void 0!==d){if(void 0===s[d])throw new Error("Invalid rule name: "+b(d)+".")}else d="uriTemplate";var t=0,u=0,v=0,w=[],x=a("./lib/classes"),y=x.Template,z=x.expression,A=s[d]();if(null===A||t!==c.length){var B=Math.max(t,v),C=B<c.length?c.charAt(B):null,D=r();throw new this.SyntaxError(q(w),C,B,D.line,D.column)}return A},toSource:function(){return this._source}};return c.SyntaxError=function(a,c,d,e,f){function g(a,c){var d,e;switch(a.length){case 0:d="end of input";break;case 1:d=a[0];break;default:d=a.slice(0,a.length-1).join(", ")+" or "+a[a.length-1]}return e=c?b(c):"end of input","Expected "+d+" but "+e+" found."}this.name="SyntaxError",this.expected=a,this.found=c,this.message=g(a,c),this.offset=d,this.line=e,this.column=f},c.SyntaxError.prototype=Error.prototype,c}()},{"./lib/classes":22}],22:[function(a,b){(function(){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=function(a,b){return function(){return a.apply(b,arguments)}},w={}.hasOwnProperty,x=function(a,b){function c(){this.constructor=a}for(var d in b)w.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};m=a("./encoders"),l=l=function(){function a(a){var b,c=this;this.expressions=[],this.prefix="string"==typeof a[0]?a.shift():"",b=0,a.forEach(function(a){switch(typeof a){case"object":return c.expressions[b++]=a;case"string":return c.expressions[b-1].suffix=a}})}return a.prototype.expand=function(a){return this.prefix+this.expressions.map(function(b){return b.expand(a)}).join("")},a.prototype.toString=function(){return this.prefix+this.expressions.join("")},a.prototype.toJSON=function(){return this.toString()},a}(),k=function(){function a(a){var b;this.params=a,this.explodeObject=v(this.explodeObject,this),this.explodeArray=v(this.explodeArray,this),this._expandPair=v(this._expandPair,this),this.stringifySingle=v(this.stringifySingle,this),this.encode=v(this.encode,this),null==(b=this.params)&&(this.params=[]),this.suffix=""}var b;return a.prototype.first="",a.prototype.sep=",",a.prototype.named=!1,a.prototype.empty="",a.prototype.allow="U",a.prototype.encode=function(a){return m[this.allow](a)},a.prototype.stringifySingle=function(a,b){var c,d,e;if(d=typeof b,"string"===d||"boolean"===d||"number"===d)return b=b.toString(),this.encode(b.substring(0,a.cut||b.length));if(Array.isArray(b)){if(a.cut)throw new Error("Prefixed Values do not support lists. Check "+a.name);return b.map(this.encode).join(",")}if(a.cut)throw new Error("Prefixed Values do not support maps. Check "+a.name);return function(){var a;a=[];for(c in b)e=b[c],a.push([c,e].map(this.encode).join(","));return a}.call(this).join(",")},a.prototype.expand=function(a){var c,d,e=this;return c=b(this.params,a),d=c.map(function(a){return e._expandPair.apply(e,a)}).join(this.sep),d?this.first+d+this.suffix:this.empty&&c.length?this.empty+this.suffix:this.suffix},b=function(a,b){return a.map(function(a){return[a,b[a.name]]}).filter(function(a){var b,c,d;switch(c=a[1],typeof c){case"undefined":return!1;case"object":Array.isArray(c)&&c.length>0;for(b in c)if(d=c[b])return!0;return!1;default:return!0}})},a.prototype._expandPair=function(a,b){var c;return c=a.name,a.explode?Array.isArray(b)?this.explodeArray(a,b):"string"==typeof b?this.stringifySingle(a,b):this.explodeObject(b):this.stringifySingle(a,b)},a.prototype.explodeArray=function(a,b){return b.map(this.encode).join(this.sep)},a.prototype.explodeObject=function(a){var b,c,d,e,f,g;c=[];for(b in a)if(d=a[b],b=this.encode(b),Array.isArray(d))for(f=0,g=d.length;g>f;f++)e=d[f],c.push([b,this.encode(e)]);else c.push([b,this.encode(d)]);return c.map(function(a){return a.join("=")}).join(this.sep)},a.prototype.toString=function(){var a;return a=this.params.map(function(a){return a.name+a.explode}).join(","),"{"+this.first+a+"}"+this.suffix},a.prototype.toJSON=function(){return this.toString()},a}(),g=function(a){function b(){return this.explodeArray=v(this.explodeArray,this),this.stringifySingle=v(this.stringifySingle,this),n=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.stringifySingle=function(a,c){return c=(c=b.__super__.stringifySingle.apply(this,arguments))?"="+c:this.empty,""+a.name+c},b.prototype.explodeArray=function(a,b){var c=this;return b.map(function(b){return""+a.name+"="+c.encode(b)}).join(this.sep)},b}(k),j=function(a){function b(){return o=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.encode=function(a){return m["U+R"](a)},b.prototype.toString=function(){return"{+"+b.__super__.toString.apply(this,arguments).substring(1)},b}(k),e=function(a){function b(){return p=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="#",b.prototype.empty="#",b.prototype.encode=function(a){return m["U+R"](a)},b}(k),f=function(a){function b(){return q=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first=".",b.prototype.sep=".",b.prototype.empty=".",b}(k),i=function(a){function b(){return r=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="/",b.prototype.sep="/",b}(k),h=function(a){function b(){return s=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first=";",b.prototype.sep=";",b}(g),d=function(a){function b(){return t=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="?",b.prototype.sep="&",b.prototype.empty="=",b}(g),c=function(a){function b(){return u=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="&",b}(d),b.exports={Template:l,SimpleExpression:k,NamedExpression:g,ReservedExpression:j,FragmentExpression:e,LabelExpression:f,PathSegmentExpression:i,PathParamExpression:h,FormStartExpression:d,FormContinuationExpression:c,expression:function(a,b){var g;return g=function(){switch(a){case"":return k;case"+":return j;case"#":return e;case".":return f;case"/":return i;case";":return h;case"?":return d;case"&":return c}}(),new g(b)}}}).call(this)},{"./encoders":23}],23:[function(a,b,c){(function(){var b;b=a("pct-encode"),c.U=b(/[^\w~.-]/g),c["U+R"]=b(/[^\w.~:\/\?#\[\]@!\$&'()*+,;=-]/g)}).call(this)},{"pct-encode":24}],24:[function(a,b){b.exports=function(a){return function(b){return b=String(b),b.replace(a,function(a){var b=a[0].charCodeAt(0),c=[];return 128>b?c.push(b):b>=128&&2048>b?(c.push(b>>6|192),c.push(63&b|128)):(c.push(b>>12|224),c.push(b>>6&63|128),c.push(63&b|128)),c.map(function(a){return"%"+a.toString(16).toUpperCase()}).join("")})}}},{}],"/home/bastian/projekte/traverson/traverson.js":[function(a,b){b.exports=a("5u5bvt")},{}],"5u5bvt":[function(a,b){"use strict";var c=(a("minilog"),a("./lib/media_types")),d=a("./lib/walker_builder");b.exports={json:{from:function(a){return{newRequest:function(){return new d(c.JSON,a)}}}},jsonHal:{from:function(a){return{newRequest:function(){return new d(c.JSON_HAL,a)}}}}}},{"./lib/media_types":7,"./lib/walker_builder":9,minilog:1}]},{},["5u5bvt"]);
View
18,046 browser/dist/traverson.js
9,653 additions, 8,393 deletions not shown
View
3  browser/dist/traverson.min.js
@@ -0,0 +1,3 @@
+!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.traverson=a():"undefined"!=typeof global?global.traverson=a():"undefined"!=typeof self&&(self.traverson=a())}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";function c(a){null==a&&(a=""),this.id=a}function d(a){return new c(a)}var e=!1;c.prototype.enable=function(){this.enabled=!0},c.prototype.debug=function(a){e&&console.log(this.id+"/debug: "+a)},c.prototype.info=function(a){e&&console.log(this.id+"/info: "+a)},c.prototype.warn=function(a){e&&console.log(this.id+"/warn: "+a)},c.prototype.error=function(a){e&&console.log(this.id+"/error: "+a)},d.enable=function(){e=!0},b.exports=d},{}],2:[function(a,b){"use strict";b.exports={isArray:function(a){return null==a?!1:"[object Array]"===Object.prototype.toString.call(a)}}},{}],3:[function(a,b){"use strict";function c(){this.options={}}function d(a,b,c){var d=b.headers;if(null!=d&&(a=a.set(b.headers)),null!=c){var e=c.body;null!=e&&(a=a.send(e))}return a}function e(a){return a.body=a.text,a.statusCode=a.status,a}var f=a("../third-party/superagent");c.prototype.defaults=function(a){var b=new c;return b.options=a,b},c.prototype.get=function(a,b){d(f.get(a),this.options).end(function(a){b(null,e(a))})},c.prototype.post=function(a,b,c){d(f.post(a),this.options,b).end(function(a){c(null,e(a))})},c.prototype.put=function(a,b,c){d(f.put(a),this.options,b).end(function(a){c(null,e(a))})},c.prototype.patch=function(a,b,c){d(f.patch(a),this.options,b).end(function(a){c(null,e(a))})},c.prototype.del=function(a,b,c){d(f.del(a),this.options).end(function(a){c(null,e(a))})},b.exports=new c},{"../third-party/superagent":4}],4:[function(a,b,c){!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];return g.exports||(g.exports={},g.client=g.component=!0,g.call(this,g.exports,a.relative(e),g)),g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=b+"/index.js",d=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],e=0;e<d.length;e++){var b=d[e];if(a.modules.hasOwnProperty(b))return b}return a.aliases.hasOwnProperty(c)?a.aliases[c]:void 0},a.normalize=function(a,b){var c=[];if("."!=b.charAt(0))return b;a=a.split("/"),b=b.split("/");for(var d=0;d<b.length;++d)".."==b[d]?a.pop():"."!=b[d]&&""!=b[d]&&c.push(b[d]);return a.concat(c).join("/")},a.register=function(b,c){a.modules[b]=c},a.alias=function(b,c){if(!a.modules.hasOwnProperty(b))throw new Error('Failed to alias "'+b+'", it does not exist');a.aliases[c]=b},a.relative=function(b){function c(a,b){for(var c=a.length;c--;)if(a[c]===b)return c;return-1}function d(c){var e=d.resolve(c);return a(e,b,c)}var e=a.normalize(b,"..");return d.resolve=function(d){var f=d.charAt(0);if("/"==f)return d.slice(1);if("."==f)return a.normalize(e,d);var g=b.split("/"),h=c(g,"deps")+1;return h||(h=0),d=g.slice(0,h+1).join("/")+"/deps/"+d},d.exists=function(b){return a.modules.hasOwnProperty(d.resolve(b))},d},a.register("component-indexof/index.js",function(a,b,c){var d=[].indexOf;c.exports=function(a,b){if(d)return a.indexOf(b);for(var c=0;c<a.length;++c)if(a[c]===b)return c;return-1}}),a.register("component-emitter/index.js",function(a,b,c){function d(a){return a?e(a):void 0}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}var f=b("indexof");c.exports=d,d.prototype.on=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},b._off=c,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;var d=f(c,b._off||b);return~d&&c.splice(d,1),this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("RedVentures-reduce/index.js",function(a,b,c){c.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];e>d;)f=b.call(null,f,a[d],++d,a);return f}}),a.register("superagent/lib/client.js",function(a,b,c){function d(){}function e(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function f(){if(r.XMLHttpRequest&&("file:"!=r.location.protocol||!r.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1}function g(a){return a===Object(a)}function h(a){if(!g(a))return a;var b=[];for(var c in a)b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")}function i(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;g>f;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function j(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;i>h;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=s(c.slice(b+1)),g[d]=e;return g}function k(a){return a.split(/ *; */).shift()}function l(a){return q(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function m(a,b){b=b||{},this.xhr=a,this.text=a.responseText,this.setStatusProperties(a.status),this.header=this.headers=j(a.getAllResponseHeaders()),this.header["content-type"]=a.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body=this.parseBody(this.text)}function n(a,b){var c=this;p.call(this),this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.set("X-Requested-With","XMLHttpRequest"),this.on("end",function(){var b=new m(c.xhr);"HEAD"==a&&(b.text=null),c.callback(null,b)})}function o(a,b){return"function"==typeof b?new n("GET",a).end(b):1==arguments.length?new n("GET",a):new n(a,b)}var p=b("emitter"),q=b("reduce"),r="undefined"==typeof window?this:window,s="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};o.serializeObject=h,o.parseString=i,o.types={html:"text/html",json:"application/json",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},o.serialize={"application/x-www-form-urlencoded":h,"application/json":JSON.stringify},o.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},m.prototype.get=function(a){return this.header[a.toLowerCase()]},m.prototype.setHeaderProperties=function(){var a=this.header["content-type"]||"";this.type=k(a);var b=l(a);for(var c in b)this[c]=b[c]},m.prototype.parseBody=function(a){var b=o.parse[this.type];return b?b(a):null},m.prototype.setStatusProperties=function(a){var b=a/100|0;this.status=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=4==b||5==b?this.toError():!1,this.accepted=202==a,this.noContent=204==a||1223==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},m.prototype.toError=function(){var a="got "+this.status+" response",b=new Error(a);return b.status=this.status,b},o.Response=m,n.prototype=new p,n.prototype.constructor=n,n.prototype.timeout=function(a){return this._timeout=a,this},n.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},n.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},n.prototype.set=function(a,b){if(g(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},n.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},n.prototype.type=function(a){return this.set("Content-Type",o.types[a]||a),this},n.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},n.prototype.query=function(a){return"string"!=typeof a&&(a=h(a)),a&&this._query.push(a),this},n.prototype.send=function(a){var b=g(a),c=this.getHeader("Content-Type");if(b&&g(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==c?this._data?this._data+"&"+a:a:(this._data||"")+a):this._data=a;return b?(c||this.type("json"),this):this},n.prototype.callback=function(a,b){var c=this._callback;return 2==c.length?c(a,b):a?this.emit("error",a):(c(b),void 0)},n.prototype.crossDomainError=function(){var a=new Error("Origin is not allowed by Access-Control-Allow-Origin");a.crossDomain=!0,this.callback(a)},n.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},n.prototype.withCredentials=function(){return this._withCredentials=!0,this},n.prototype.end=function(a){var b=this,c=this.xhr=f(),g=this._query.join("&"),h=this._timeout,i=this._data;if(this._callback=a||d,this._withCredentials&&(c.withCredentials=!0),c.onreadystatechange=function(){return 4==c.readyState?0==c.status?b.aborted?b.timeoutError():b.crossDomainError():(b.emit("end"),void 0):void 0},c.upload&&(c.upload.onprogress=function(a){a.percent=a.loaded/a.total*100,b.emit("progress",a)}),h&&!this._timer&&(this._timer=setTimeout(function(){b.abort()},h)),g&&(g=o.serializeObject(g),this.url+=~this.url.indexOf("?")?"&"+g:"?"+g),c.open(this.method,this.url,!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!e(i)){var j=o.serialize[this.getHeader("Content-Type")];j&&(i=j(i))}for(var k in this.header)null!=this.header[k]&&c.setRequestHeader(k,this.header[k]);return c.send(i),this},o.Request=n,o.get=function(a,b,c){var d=o("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},o.head=function(a,b,c){var d=o("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},o.del=function(a,b){var c=o("DELETE",a);return b&&c.end(b),c},o.patch=function(a,b,c){var d=o("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},o.post=function(a,b,c){var d=o("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},o.put=function(a,b,c){var d=o("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},c.exports=o}),a.alias("component-emitter/index.js","superagent/deps/emitter/index.js"),a.alias("component-emitter/index.js","emitter/index.js"),a.alias("component-indexof/index.js","component-emitter/deps/indexof/index.js"),a.alias("RedVentures-reduce/index.js","superagent/deps/reduce/index.js"),a.alias("RedVentures-reduce/index.js","reduce/index.js"),a.alias("superagent/lib/client.js","superagent/index.js"),"object"==typeof c?b.exports=a("superagent"):"function"==typeof define&&define.amd?define(function(){return a("superagent")}):this.superagent=a("superagent")}()},{emitter:13,indexof:13,reduce:13,superagent:13}],5:[function(a,b){"use strict";function c(){}var d=a("halbert"),e=a("minilog"),f=a("underscore.string"),g=a("./walker"),h=e("traverson"),i=d.parser;c.prototype=new g,c.prototype.findNextStep=function(a,b){h.debug("parsing hal");var c=i(a,!1),d=c.links(b);if(d&&d[0]&&d[0].href)return h.debug("found hal link: "+d[0].href),{uri:d[0].href};var e=this.findEmbedded(c,b);if(e)return e;throw new Error("Could not find a link nor an embedded object for "+b+" in document:\n"+JSON.stringify(a))},c.prototype.postProcessStep=function(a){a.uri&&(f.endsWith(this.startUri,"/")&&f.startsWith(a.uri,"/")&&(a.uri=f.splice(a.uri,0,1)),a.uri=this.startUri+a.uri)},c.prototype.findEmbedded=function(a,b){h.debug("checking for embedded: "+b);var c=a.embedded(b);return c?(h.debug("found embedded doc for: "+b),{doc:c}):null},b.exports=c},{"./walker":8,halbert:14,minilog:1,"underscore.string":20}],6:[function(a,b){"use strict";function c(){}var d=a("./walker");c.prototype=new d,b.exports=c},{"./walker":8}],7:[function(a,b){"use strict";b.exports={JSON:"application/json",JSON_HAL:"application/hal+json"}},{}],8:[function(a,b){"use strict";function c(){}function d(a,b,c){var d=new Error("HTTP GET for "+a+" resulted in HTTP status code "+b+".");d.name="HTTPError",d.uri=a,d.httpStatus=b,d.body=c;try{d.doc=JSON.parse(c)}catch(e){}return d}function e(a,b){var c=new Error("The document at "+a+" could not be parsed as JSON: "+b);return c.name="JSONError",c.uri=a,c.body=b,c}var f=a("JSONPath"),g=a("minilog"),h=a("underscore.string"),i=a("uri-template"),j=a("util"),k=f.eval,l=g("traverson");c.prototype.walk=function(a){var b=this,c={uri:this.resolveUriTemplate(this.startUri,this.templateParameters,0)},d=0,e=c;l.debug("starting to follow links"),function f(){return d<b.links.length?(b.process(c,function(g,h){if(e=h,g)return l.debug("error while processing step "+JSON.stringify(c)),l.error(g),a(g,c,h);l.debug("successully processed step");try{b.checkHttpStatus(h)}catch(i){return l.error("unexpected http status code"),l.error(i),a(i,c,h)}var j;try{j=b.parse(h)}catch(i){return l.error("parsing failed"),l.error(i),a(i,c,h)}var k=b.links[d++];l.debug("next link: "+k);try{c=b.findNextStep(j,k)}catch(i){return l.error("could not find next step"),l.error(i),a(i,c,h)}b.postProcessStep(c),l.debug("next step: "+JSON.stringify(c)),c.uri&&(c.uri=b.resolveUriTemplate(c.uri,b.templateParameters,d)),f()}),void 0):(l.debug("link array exhausted, calling callback"),a(null,c,e))}()},c.prototype.process=function(a,b){if(l.debug("processing next step: "+JSON.stringify(a)),a.uri)this.get(a,b);else{if(!a.doc)throw new Error("Can not process next step: "+JSON.stringify(a));l.debug("document for next step has already been fetched"),b(null,a)}},c.prototype.get=function(a,b){l.debug("request to "+a.uri),this.request.get(a.uri,function(c,d){return l.debug("request.get returned"),c?b(c,a):(l.debug("request to "+a.uri+" finished ("+d.statusCode+")"),a.response=d,b(null,a))})},c.prototype.checkHttpStatus=function(a){if(a.response||!a.doc){var b=a.response.statusCode;if(200>b||b>=300)throw d(a.uri,b,a.response.body)}},c.prototype.parse=function(a){if(a.doc)return a.doc;try{return JSON.parse(a.response.body)}catch(b){if("SyntaxError"===b.name)throw e(a.uri,a.response.body);throw b}},c.prototype.findNextStep=function(a,b){l.debug("extracting link "+b+" from "+JSON.stringify(a));if(this.testJSONPath(b))return{uri:this.resolveJSONPath(b,a)};if(a[b])return{uri:a[b]};throw new Error("Could not find property "+b+" in document:\n"+JSON.stringify(a))},c.prototype.postProcessStep=function(){},c.prototype.testJSONPath=function(a){return h.startsWith(a,"$.")||h.startsWith(a,"$[")},c.prototype.resolveJSONPath=function(a,b){var c=k(b,a);if(1===c.length){var d=c[0];if(!d)throw new Error("JSONPath expression "+a+" was resolved but the result was null, undefined or an empty string in document:\n"+JSON.stringify(b));return d}throw c.length>1?new Error("JSONPath expression "+a+" returned more than one match in document:\n"+JSON.stringify(b)):new Error("JSONPath expression "+a+" returned no match in document:\n"+JSON.stringify(b))},c.prototype.resolveUriTemplate=function(a,b,c){if(j.isArray(b)&&(b=b[c]),!b)return a;if(h.contains(a,"{")){var d=i.parse(a);return d.expand(b)}return a},b.exports=c},{JSONPath:10,minilog:1,"underscore.string":20,"uri-template":21,util:2}],9:[function(a,b){"use strict";function c(a,b){this.walker=this.createWalker(a),this.walker.startUri=b,this.walker.request=this.request=d}var d=a("request"),e=a("util"),f=a("./json_walker"),g=a("./json_hal_walker"),h=a("minilog"),i=a("./media_types"),j=h("traverson");c.prototype.createWalker=function(a){switch(a){case i.JSON:return j.debug("creating new JsonWalker"),new f;case i.JSON_HAL:return j.debug("creating new JsonHalWalker"),new g;default:throw new Error("Unknown or unsupported media type: "+a)}},c.prototype.walk=function(){return this.walker.links=1===arguments.length&&e.isArray(arguments[0])?arguments[0]:Array.prototype.slice.apply(arguments),this},c.prototype.withTemplateParameters=function(a){return this.walker.templateParameters=a,this},c.prototype.withRequestOptions=function(a){return this.walker.request=this.request=d.defaults(a),this},c.prototype.get=function(a){var b=this;this.walker.walk(function(c,d,e){return j.debug("walker.walk returned"),c?a(c,e.response,e.uri):(j.debug("next step: "+JSON.stringify(d)),b.walker.process(d,function(b,c){return j.debug("walker.process returned"),b?a(b,c.response,c.uri):(!c.response&&c.doc&&(j.debug("faking HTTP response for embedded resource"),c.response={statusCode:200,body:JSON.stringify(c.doc),remark:"This is not an actual HTTP response. The resource you requested was an embedded resource, so no HTTP request was made to acquire it."}),a(null,c.response),void 0)}),void 0)})},c.prototype.getResource=function(a){var b=this;this.walker.walk(function(c,d,e){return j.debug("walker.walk returned"),c?a(c,e.response,e.uri):(j.debug("next step: "+JSON.stringify(d)),b.walker.process(d,function(c,d){if(j.debug("walker.process returned"),c)return a(c,d.response,d.uri);if(j.debug("resulting step: "+d.uri),d.doc)return a(null,d.doc);var e;try{return b.walker.checkHttpStatus(d),e=b.walker.parse(d),a(null,e)}catch(f){return a(f,f.doc)}}),void 0)})},c.prototype.getUri=function(a){var b=this;this.walker.walk(function(c,d,e){return j.debug("walker.walk returned"),c?a(c,e.response,e.uri):(j.debug("returning uri"),d.uri?a(null,d.uri):d.doc&&d.doc._links&&d.doc._links.self&&d.doc._links.self.href?a(null,b.walker.startUri+d.doc._links.self.href):a(new Error('You requested an URI but the last resource is an embedded resource and has no URI of its own (that is, it has no link with rel="self"')))})},c.prototype.post=function(a,b){this.walkAndExecute(a,this.request.post,b)},c.prototype.put=function(a,b){this.walkAndExecute(a,this.request.put,b)},c.prototype.patch=function(a,b){this.walkAndExecute(a,this.request.patch,b)},c.prototype.delete=function(a){this.walkAndExecute(null,this.request.del,a)},c.prototype.walkAndExecute=function(a,b,c){var d=this;this.walker.walk(function(e,f,g){return j.debug("walker.walk returned"),e?c(e,g.response,g.uri):(j.debug("executing final request with step: "+JSON.stringify(f)),d.executeRequest(f.uri,b,a,c),void 0)})},c.prototype.executeRequest=function(a,b,c,d){var e;e=c?{body:JSON.stringify(c)}:{},j.debug("request to "+a+" with options "+JSON.stringify(e)),b.call(this.request,a,e,function(b,c){return j.debug("request to "+a+" succeeded"),b?d(b,c,a):d(null,c,a)})},b.exports=c},{"./json_hal_walker":5,"./json_walker":6,"./media_types":7,minilog:1,request:3,util:2}],10:[function(a,b,c){function d(a,b,c){var d={resultType:c&&c.resultType||"VALUE",flatten:c&&c.flatten||!1,wrap:c&&c.hasOwnProperty("wrap")?c.wrap:!0,sandbox:c&&c.sandbox?c.sandbox:{},normalize:function(a){if(g[a])return g[a];var b=[],c=a.replace(/[\['](\??\(.*?\))[\]']/g,function(a,c){return"[#"+(b.push(c)-1)+"]"}).replace(/'?\.'?|\['?/g,";").replace(/;;;|;;/g,";..;").replace(/;$|'?\]|'$/g,"").replace(/#([0-9]+)/g,function(a,c){return b[c]});return g[a]=c,c},asPath:function(a){for(var b=a.split(";"),c="$",d=1,e=b.length;e>d;d++)c+=/^[0-9*]+$/.test(b[d])?"["+b[d]+"]":"['"+b[d]+"']";return c},store:function(a,b){return a&&("PATH"==d.resultType?d.result[d.result.length]=d.asPath(a):f.isArray(b)&&d.flatten?(d.result||(d.result=[]),f.isArray(d.result)||(d.result=[d.result]),d.result=d.result.concat(b)):d.result?(f.isArray(d.result)||(d.result=[d.result]),f.isArray(b)&&d.flatten?d.result=d.result.concat(b):d.result[d.result.length]=b):d.result=b),!!a},trace:function(a,b,c){if(a){var e=a.split(";"),f=e.shift();if(e=e.join(";"),b&&b.hasOwnProperty(f))d.trace(e,b[f],c+";"+f);else if("*"===f)d.walk(f,e,b,c,function(a,b,c,e,f){d.trace(a+";"+c,e,f)});else if(".."===f)d.trace(e,b,c),d.walk(f,e,b,c,function(a,b,c,e,f){"object"==typeof e[a]&&d.trace("..;"+c,e[a],f+";"+a)});else if(/,/.test(f))for(var g=f.split(/'?,'?/),h=0,i=g.length;i>h;h++)d.trace(g[h]+";"+e,b,c);else/^\(.*?\)$/.test(f)?d.trace(d.eval(f,b,c.substr(c.lastIndexOf(";")+1))+";"+e,b,c):/^\?\(.*?\)$/.test(f)?d.walk(f,e,b,c,function(a,b,c,e,f){d.eval(b.replace(/^\?\((.*?)\)$/,"$1"),e[a],a)&&d.trace(a+";"+c,e,f)}):/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(f)&&d.slice(f,e,b,c)}else d.store(c,b)},walk:function(a,b,c,d,e){if(c instanceof Array)for(var f=0,g=c.length;g>f;f++)f in c&&e(f,a,b,c,d);else if("object"==typeof c)for(var h in c)c.hasOwnProperty(h)&&e(h,a,b,c,d)},slice:function(a,b,c,e){if(c instanceof Array){var f=c.length,g=0,h=f,i=1;a.replace(/^(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)$/g,function(a,b,c,d){g=parseInt(b||g),h=parseInt(c||h),i=parseInt(d||i)}),g=0>g?Math.max(0,g+f):Math.min(f,g),h=0>h?Math.max(0,h+f):Math.min(f,h);for(var j=g;h>j;j+=i)d.trace(j+";"+b,c,e)}},eval:function(a,b){d.sandbox._v=b;try{return h&&b&&e.runInNewContext(a.replace(/@/g,"_v"),d.sandbox)}catch(c){throw console.log(c),new SyntaxError("jsonPath: "+c.message+": "+a.replace(/@/g,"_v").replace(/\^/g,"_a"))}}};d.result=d.wrap===!0?[]:void 0;var h=a;return b&&a&&("VALUE"==d.resultType||"PATH"==d.resultType)?(d.trace(d.normalize(b).replace(/^\$;/,""),a,"$"),!f.isArray(d.result)&&d.wrap&&(d.result=[d.result]),d.result?d.result:!1):void 0}var e=a("vm"),f=a("underscore");c.eval=d;var g={}},{underscore:11,vm:12}],11:[function(a,b,c){(function(){function a(b,c,d){if(b===c)return 0!==b||1/b==1/c;if(null==b||null==c)return b===c;if(b._chain&&(b=b._wrapped),c._chain&&(c=c._wrapped),b.isEqual&&z.isFunction(b.isEqual))return b.isEqual(c);if(c.isEqual&&z.isFunction(c.isEqual))return c.isEqual(b);var e=l.call(b);if(e!=l.call(c))return!1;switch(e){case"[object String]":return b==String(c);case"[object Number]":return b!=+b?c!=+c:0==b?1/b==1/c:b==+c;case"[object Date]":case"[object Boolean]":return+b==+c;case"[object RegExp]":return b.source==c.source&&b.global==c.global&&b.multiline==c.multiline&&b.ignoreCase==c.ignoreCase}if("object"!=typeof b||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==b)return!0;d.push(b);var g=0,h=!0;if("[object Array]"==e){if(g=b.length,h=g==c.length)for(;g--&&(h=g in b==g in c&&a(b[g],c[g],d)););}else{if("constructor"in b!="constructor"in c||b.constructor!=c.constructor)return!1;for(var i in b)if(z.has(b,i)&&(g++,!(h=z.has(c,i)&&a(b[i],c[i],d))))break;if(h){for(i in c)if(z.has(c,i)&&!g--)break;h=!g}}return d.pop(),h}var d=this,e=d._,f={},g=Array.prototype,h=Object.prototype,i=Function.prototype,j=g.slice,k=g.unshift,l=h.toString,m=h.hasOwnProperty,n=g.forEach,o=g.map,p=g.reduce,q=g.reduceRight,r=g.filter,s=g.every,t=g.some,u=g.indexOf,v=g.lastIndexOf,w=Array.isArray,x=Object.keys,y=i.bind,z=function(a){return new K(a)};"undefined"!=typeof c?("undefined"!=typeof b&&b.exports&&(c=b.exports=z),c._=z):d._=z,z.VERSION="1.3.3";var A=z.each=z.forEach=function(a,b,c){if(null!=a)if(n&&a.forEach===n)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(d in a&&b.call(c,a[d],d,a)===f)return}else for(var g in a)if(z.has(a,g)&&b.call(c,a[g],g,a)===f)return};z.map=z.collect=function(a,b,c){var d=[];return null==a?d:o&&a.map===o?a.map(b,c):(A(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),a.length===+a.length&&(d.length=a.length),d)},z.reduce=z.foldl=z.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),p&&a.reduce===p)return d&&(b=z.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(A(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError("Reduce of empty array with no initial value");return c},z.reduceRight=z.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),q&&a.reduceRight===q)return d&&(b=z.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=z.toArray(a).reverse();return d&&!e&&(b=z.bind(b,d)),e?z.reduce(f,b,c,d):z.reduce(f,b)},z.find=z.detect=function(a,b,c){var d;return B(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},z.filter=z.select=function(a,b,c){var d=[];return null==a?d:r&&a.filter===r?a.filter(b,c):(A(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},z.reject=function(a,b,c){var d=[];return null==a?d:(A(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d)},z.every=z.all=function(a,b,c){var d=!0;return null==a?d:s&&a.every===s?a.every(b,c):(A(a,function(a,e,g){return(d=d&&b.call(c,a,e,g))?void 0:f}),!!d)};var B=z.some=z.any=function(a,b,c){b||(b=z.identity);var d=!1;return null==a?d:t&&a.some===t?a.some(b,c):(A(a,function(a,e,g){return d||(d=b.call(c,a,e,g))?f:void 0}),!!d)};z.include=z.contains=function(a,b){var c=!1;return null==a?c:u&&a.indexOf===u?-1!=a.indexOf(b):c=B(a,function(a){return a===b})},z.invoke=function(a,b){var c=j.call(arguments,2);return z.map(a,function(a){return(z.isFunction(b)?b||a:a[b]).apply(a,c)})},z.pluck=function(a,b){return z.map(a,function(a){return a[b]})},z.max=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!b&&z.isEmpty(a))return-1/0;var d={computed:-1/0};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},z.min=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!b&&z.isEmpty(a))return 1/0;var d={computed:1/0};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g<d.computed&&(d={value:a,computed:g})}),d.value},z.shuffle=function(a){var b,c=[];return A(a,function(a,d){b=Math.floor(Math.random()*(d+1)),c[d]=c[b],c[b]=a}),c},z.sortBy=function(a,b,c){var d=z.isFunction(b)?b:function(a){return a[b]};return z.pluck(z.map(a,function(a,b,e){return{value:a,criteria:d.call(c,a,b,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return void 0===c?1:void 0===d?-1:d>c?-1:c>d?1:0}),"value")},z.groupBy=function(a,b){var c={},d=z.isFunction(b)?b:function(a){return a[b]};return A(a,function(a,b){var e=d(a,b);(c[e]||(c[e]=[])).push(a)}),c},z.sortedIndex=function(a,b,c){c||(c=z.identity);for(var d=0,e=a.length;e>d;){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},z.toArray=function(a){return a?z.isArray(a)?j.call(a):z.isArguments(a)?j.call(a):a.toArray&&z.isFunction(a.toArray)?a.toArray():z.values(a):[]},z.size=function(a){return z.isArray(a)?a.length:z.keys(a).length},z.first=z.head=z.take=function(a,b,c){return null==b||c?a[0]:j.call(a,0,b)},z.initial=function(a,b,c){return j.call(a,0,a.length-(null==b||c?1:b))},z.last=function(a,b,c){return null==b||c?a[a.length-1]:j.call(a,Math.max(a.length-b,0))},z.rest=z.tail=function(a,b,c){return j.call(a,null==b||c?1:b)},z.compact=function(a){return z.filter(a,function(a){return!!a})},z.flatten=function(a,b){return z.reduce(a,function(a,c){return z.isArray(c)?a.concat(b?c:z.flatten(c)):(a[a.length]=c,a)},[])},z.without=function(a){return z.difference(a,j.call(arguments,1))},z.uniq=z.unique=function(a,b,c){var d=c?z.map(a,c):a,e=[];return a.length<3&&(b=!0),z.reduce(d,function(c,d,f){return(b?z.last(c)===d&&c.length:z.include(c,d))||(c.push(d),e.push(a[f])),c},[]),e},z.union=function(){return z.uniq(z.flatten(arguments,!0))},z.intersection=z.intersect=function(a){var b=j.call(arguments,1);return z.filter(z.uniq(a),function(a){return z.every(b,function(b){return z.indexOf(b,a)>=0})})},z.difference=function(a){var b=z.flatten(j.call(arguments,1),!0);return z.filter(a,function(a){return!z.include(b,a)})},z.zip=function(){for(var a=j.call(arguments),b=z.max(z.pluck(a,"length")),c=new Array(b),d=0;b>d;d++)c[d]=z.pluck(a,""+d);return c},z.indexOf=function(a,b,c){if(null==a)return-1;var d,e;if(c)return d=z.sortedIndex(a,b),a[d]===b?d:-1;if(u&&a.indexOf===u)return a.indexOf(b);for(d=0,e=a.length;e>d;d++)if(d in a&&a[d]===b)return d;return-1},z.lastIndexOf=function(a,b){if(null==a)return-1;if(v&&a.lastIndexOf===v)return a.lastIndexOf(b);for(var c=a.length;c--;)if(c in a&&a[c]===b)return c;return-1},z.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);d>e;)f[e++]=a,a+=c;return f};var C=function(){};z.bind=function(a,b){var c,d;if(a.bind===y&&y)return y.apply(a,j.call(arguments,1));if(!z.isFunction(a))throw new TypeError;return d=j.call(arguments,2),c=function(){if(!(this instanceof c))return a.apply(b,d.concat(j.call(arguments)));C.prototype=a.prototype;var e=new C,f=a.apply(e,d.concat(j.call(arguments)));return Object(f)===f?f:e}},z.bindAll=function(a){var b=j.call(arguments,1);return 0==b.length&&(b=z.functions(a)),A(b,function(b){a[b]=z.bind(a[b],a)}),a},z.memoize=function(a,b){var c={};return b||(b=z.identity),function(){var d=b.apply(this,arguments);return z.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},z.delay=function(a,b){var c=j.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},z.defer=function(a){return z.delay.apply(z,[a,1].concat(j.call(arguments,1)))},z.throttle=function(a,b){var c,d,e,f,g,h,i=z.debounce(function(){g=f=!1},b);return function(){c=this,d=arguments;var j=function(){e=null,g&&a.apply(c,d),i()};return e||(e=setTimeout(j,b)),f?g=!0:h=a.apply(c,d),i(),f=!0,h}},z.debounce=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)};c&&!d&&a.apply(e,f),clearTimeout(d),d=setTimeout(g,b)}},z.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments))}},z.wrap=function(a,b){return function(){var c=[a].concat(j.call(arguments,0));return b.apply(this,c)}},z.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},z.after=function(a,b){return 0>=a?b():function(){return--a<1?b.apply(this,arguments):void 0}},z.keys=x||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)z.has(a,c)&&(b[b.length]=c);return b},z.values=function(a){return z.map(a,z.identity)},z.functions=z.methods=function(a){var b=[];for(var c in a)z.isFunction(a[c])&&b.push(c);return b.sort()},z.extend=function(a){return A(j.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},z.pick=function(a){var b={};return A(z.flatten(j.call(arguments,1)),function(c){c in a&&(b[c]=a[c])}),b},z.defaults=function(a){return A(j.call(arguments,1),function(b){for(var c in b)null==a[c]&&(a[c]=b[c])}),a},z.clone=function(a){return z.isObject(a)?z.isArray(a)?a.slice():z.extend({},a):a},z.tap=function(a,b){return b(a),a},z.isEqual=function(b,c){return a(b,c,[])},z.isEmpty=function(a){if(null==a)return!0;if(z.isArray(a)||z.isString(a))return 0===a.length;for(var b in a)if(z.has(a,b))return!1;return!0},z.isElement=function(a){return!(!a||1!=a.nodeType)},z.isArray=w||function(a){return"[object Array]"==l.call(a)},z.isObject=function(a){return a===Object(a)},z.isArguments=function(a){return"[object Arguments]"==l.call(a)},z.isArguments(arguments)||(z.isArguments=function(a){return!(!a||!z.has(a,"callee"))}),z.isFunction=function(a){return"[object Function]"==l.call(a)},z.isString=function(a){return"[object String]"==l.call(a)},z.isNumber=function(a){return"[object Number]"==l.call(a)},z.isFinite=function(a){return z.isNumber(a)&&isFinite(a)
+},z.isNaN=function(a){return a!==a},z.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"==l.call(a)},z.isDate=function(a){return"[object Date]"==l.call(a)},z.isRegExp=function(a){return"[object RegExp]"==l.call(a)},z.isNull=function(a){return null===a},z.isUndefined=function(a){return void 0===a},z.has=function(a,b){return m.call(a,b)},z.noConflict=function(){return d._=e,this},z.identity=function(a){return a},z.times=function(a,b,c){for(var d=0;a>d;d++)b.call(c,d)},z.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")},z.result=function(a,b){if(null==a)return null;var c=a[b];return z.isFunction(c)?c.call(a):c},z.mixin=function(a){A(z.functions(a),function(b){M(b,z[b]=a[b])})};var D=0;z.uniqueId=function(a){var b=D++;return a?a+b:b},z.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var E=/.^/,F={"\\":"\\","'":"'",r:"\r",n:"\n",t:" ",u2028:"\u2028",u2029:"\u2029"};for(var G in F)F[F[G]]=G;var H=/\\|'|\r|\n|\t|\u2028|\u2029/g,I=/\\(\\|'|r|n|t|u2028|u2029)/g,J=function(a){return a.replace(I,function(a,b){return F[b]})};z.template=function(a,b,c){c=z.defaults(c||{},z.templateSettings);var d="__p+='"+a.replace(H,function(a){return"\\"+F[a]}).replace(c.escape||E,function(a,b){return"'+\n_.escape("+J(b)+")+\n'"}).replace(c.interpolate||E,function(a,b){return"'+\n("+J(b)+")+\n'"}).replace(c.evaluate||E,function(a,b){return"';\n"+J(b)+"\n;__p+='"})+"';\n";c.variable||(d="with(obj||{}){\n"+d+"}\n"),d="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+d+"return __p;\n";var e=new Function(c.variable||"obj","_",d);if(b)return e(b,z);var f=function(a){return e.call(this,a,z)};return f.source="function("+(c.variable||"obj")+"){\n"+d+"}",f},z.chain=function(a){return z(a).chain()};var K=function(a){this._wrapped=a};z.prototype=K.prototype;var L=function(a,b){return b?z(a).chain():a},M=function(a,b){K.prototype[a]=function(){var a=j.call(arguments);return k.call(a,this._wrapped),L(b.apply(z,a),this._chain)}};z.mixin(z),A(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=g[a];K.prototype[a]=function(){var c=this._wrapped;b.apply(c,arguments);var d=c.length;return"shift"!=a&&"splice"!=a||0!==d||delete c[0],L(c,this._chain)}}),A(["concat","join","slice"],function(a){var b=g[a];K.prototype[a]=function(){return L(b.apply(this._wrapped,arguments),this._chain)}}),K.prototype.chain=function(){return this._chain=!0,this},K.prototype.value=function(){return this._wrapped}}).call(this)},{}],12:[function(require,module,exports){var Object_keys=function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)b.push(c);return b},forEach=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c++)b(a[c],c,a)},Script=exports.Script=function(a){return this instanceof Script?(this.code=a,void 0):new Script(a)};Script.prototype.runInNewContext=function(a){a||(a={});var b=document.createElement("iframe");b.style||(b.style={}),b.style.display="none",document.body.appendChild(b);var c=b.contentWindow;forEach(Object_keys(a),function(b){c[b]=a[b]}),!c.eval&&c.execScript&&c.execScript("null");var d=c.eval(this.code);return forEach(Object_keys(c),function(b){a[b]=c[b]}),document.body.removeChild(b),d},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInContext=function(a){return this.runInNewContext(a)},forEach(Object_keys(Script.prototype),function(a){exports[a]=Script[a]=function(b){var c=Script(b);return c[a].apply(c,[].slice.call(arguments,1))}}),exports.createScript=function(a){return exports.Script(a)},exports.createContext=Script.createContext=function(a){var b={};return"object"==typeof a&&forEach(Object_keys(a),function(c){b[c]=a[c]}),b}},{}],13:[function(){},{}],14:[function(a,b){b.exports={parser:a("./src/parser"),Resource:a("./src/resource")}},{"./src/parser":18,"./src/resource":19}],15:[function(a,b,c){var d="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};(function(){function a(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d<e;)if(a[d]===b)return d;return-1}function e(b,c){var d=typeof c;if(b=b.cache,"boolean"==d||null==c)return b[c]?0:-1;"number"!=d&&"string"!=d&&(d="object");var e="number"==d?c:v+c;return b=(b=b[d])&&b[e],"object"==d?b&&a(b,c)>-1?0:-1:b?0:-1}function f(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:v+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function g(a){return a.charCodeAt(0)}function h(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||"undefined"==typeof c)return 1;if(d>c||"undefined"==typeof d)return-1}return a.index-b.index}function i(a){var b=-1,c=a.length,d=a[0],e=a[c/2|0],g=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&g&&"object"==typeof g)return!1;var h=l();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=l();for(i.array=a,i.cache=h,i.push=f;++b<c;)i.push(a[b]);return i}function j(a){return"\\"+Z[a]}function k(){return s.pop()||[]}function l(){return t.pop()||{array:null,cache:null,criteria:null,"false":!1,index:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,value:null}}function m(){}function n(a){a.length=0,s.length<x&&s.push(a)}function o(a){var b=a.cache;b&&o(b),a.array=a.cache=a.criteria=a.object=a.number=a.string=a.value=null,t.length<x&&t.push(a)}function p(a,b,c){b||(b=0),"undefined"==typeof c&&(c=a?a.length:0);for(var d=-1,e=c-b||0,f=Array(0>e?0:e);++d<e;)f[d]=a[b+d];return f}function q(b){function c(a){return a&&"object"==typeof a&&!Xd(a)&&yd.call(a,"__wrapped__")?a:new d(a)}function d(a,b){this.__chain__=!!b,this.__wrapped__=a}function f(a,b,c,d,e){if(c){var g=c(a);if("undefined"!=typeof g)return g}var h=Ab(a);if(!h)return a;var i=Ed.call(a);if(!V[i])return a;var j=Ud[i];switch(i){case O:case P:return new j(+a);case R:case U:return new j(a);case T:return g=j(a.source,D.exec(a)),g.lastIndex=a.lastIndex,g}var l=Xd(a);if(b){var m=!d;d||(d=k()),e||(e=k());for(var o=d.length;o--;)if(d[o]==a)return e[o];g=l?j(a.length):{}}else g=l?p(a):ce({},a);return l&&(yd.call(a,"index")&&(g.index=a.index),yd.call(a,"input")&&(g.input=a.input)),b?(d.push(a),e.push(g),(l?Tb:fe)(a,function(a,h){g[h]=f(a,b,c,d,e)}),m&&(n(d),n(e)),g):g}function s(a,b,c){if("function"!=typeof a)return Tc;if("undefined"==typeof b)return a;var d=a.__bindData__||Vd.funcNames&&!a.name;if("undefined"==typeof d){var e=I&&wd.call(a);Vd.funcNames||!e||E.test(e)||(d=!0),(Vd.funcNames||!d)&&(d=!Vd.funcDecomp||I.test(e),Wd(a,d))}if(d!==!0&&d&&1&d[1])return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return Dc(a,b)}function t(a,b,c,d){for(var e=(d||0)-1,f=a?a.length:0,g=[];++e<f;){var h=a[e];if(h&&"object"==typeof h&&"number"==typeof h.length&&(Xd(h)||jb(h))){b||(h=t(h,b,c));var i=-1,j=h.length,k=g.length;for(g.length+=j;++i<j;)g[k++]=h[i]}else c||g.push(h)}return g}function x(a,b,c,d,e,f){if(c){var g=c(a,b);if("undefined"!=typeof g)return!!g}if(a===b)return 0!==a||1/a==1/b;var h=typeof a,i=typeof b;if(!(a!==a||a&&Y[h]||b&&Y[i]))return!1;if(null==a||null==b)return a===b;var j=Ed.call(a),l=Ed.call(b);if(j==M&&(j=S),l==M&&(l=S),j!=l)return!1;switch(j){case O:case P:return+a==+b;case R:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case T:case U:return a==nd(b)}var m=j==N;if(!m){if(yd.call(a,"__wrapped__ ")||yd.call(b,"__wrapped__"))return x(a.__wrapped__||a,b.__wrapped__||b,c,d,e,f);if(j!=S)return!1;var o=a.constructor,p=b.constructor;if(o!=p&&!(zb(o)&&o instanceof o&&zb(p)&&p instanceof p))return!1}var q=!e;e||(e=k()),f||(f=k());for(var r=e.length;r--;)if(e[r]==a)return f[r]==b;var s=0;if(g=!0,e.push(a),f.push(b),m){if(r=a.length,s=b.length,g=s==a.length,!g&&!d)return g;for(;s--;){var t=r,u=b[s];if(d)for(;t--&&!(g=x(a[t],u,c,d,e,f)););else if(!(g=x(a[s],u,c,d,e,f)))break}return g}return ee(b,function(b,h,i){return yd.call(i,h)?(s++,g=yd.call(a,h)&&x(a[h],b,c,d,e,f)):void 0}),g&&!d&&ee(a,function(a,b,c){return yd.call(c,b)?g=--s>-1:void 0}),q&&(n(e),n(f)),g}function Z(a,b,c,d,e){(Xd(b)?Tb:fe)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Xd(b))||ge(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Xd(j)?j:[]:ge(j)?j:{}),d.push(b),e.push(j),l||Z(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function _(b,c,d){var f=-1,g=gb(),h=b?b.length:0,j=[],l=!c&&h>=w&&g===a,m=d||l?k():j;if(l){var p=i(m);p?(g=e,m=p):(l=!1,m=d?m:(n(m),j))}for(;++f<h;){var q=b[f],r=d?d(q,f,b):q;(c?!f||m[m.length-1]!==r:g(m,r)<0)&&((d||l)&&m.push(r),j.push(q))}return l?(n(m.array),o(m)):d&&n(m),j}function ab(a){return function(b,d,e){var f={};d=c.createCallback(d,e,3);var g=-1,h=b?b.length:0;if("number"==typeof h)for(;++g<h;){var i=b[g];a(f,i,d(i,g,b),b)}else fe(b,function(b,c,e){a(f,b,d(b,c,e),e)});return f}}function cb(a,b,c,d,e,f){var g=1&b,h=2&b,i=4&b,j=8&b,k=16&b,l=32&b,m=a;if(!h&&!zb(a))throw new od;k&&!c.length&&(b&=-17,k=c=!1),l&&!d.length&&(b&=-33,l=d=!1);var n=a&&a.__bindData__;if(n)return!g||1&n[1]||(n[4]=e),!g&&1&n[1]&&(b|=8),!i||4&n[1]||(n[5]=f),k&&Ad.apply(n[2]||(n[2]=[]),c),l&&Ad.apply(n[3]||(n[3]=[]),d),n[1]|=b,cb.apply(null,n);if(g&&!(h||i||l)&&(Vd.fastBind||Hd&&k)){if(k){var o=[e];Ad.apply(o,c)}var p=k?Hd.apply(a,o):Hd.call(a,e)}else p=function(){var n=arguments,o=g?e:this;if((i||k||l)&&(n=Rd.call(n),k&&Fd.apply(n,c),l&&Ad.apply(n,d),i&&n.length<f))return b|=16,cb(a,j?b:-4&b,n,null,e,f);if(h&&(a=o[m]),this instanceof p){o=eb(a.prototype);var q=a.apply(o,n);return Ab(q)?q:o}return a.apply(o,n)};return Wd(p,Rd.call(arguments)),p}function eb(a){return Ab(a)?Id(a):{}}function fb(a){return $d[a]}function gb(){var b=(b=c.indexOf)===nc?a:b;return b}function hb(a){var b,c;return a&&Ed.call(a)==S&&(b=a.constructor,!zb(b)||b instanceof b)?(ee(a,function(a,b){c=b}),"undefined"==typeof c||yd.call(a,c)):!1}function ib(a){return _d[a]}function jb(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ed.call(a)==M||!1}function kb(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=b,b=!1),f(a,b,"function"==typeof c&&s(c,d,1))}function lb(a,b,c){return f(a,!0,"function"==typeof b&&s(b,c,1))}function mb(a,b,d){var e;return b=c.createCallback(b,d,3),fe(a,function(a,c,d){return b(a,c,d)?(e=c,!1):void 0}),e}function nb(a,b,d){var e;return b=c.createCallback(b,d,3),pb(a,function(a,c,d){return b(a,c,d)?(e=c,!1):void 0}),e}function ob(a,b,c){var d=[];ee(a,function(a,b){d.push(b,a)});var e=d.length;for(b=s(b,c,3);e--&&b(d[e--],d[e],a)!==!1;);return a}function pb(a,b,c){var d=Zd(a),e=d.length;for(b=s(b,c,3);e--;){var f=d[e];if(b(a[f],f,a)===!1)break}return a}function qb(a){var b=[];return ee(a,function(a,c){zb(a)&&b.push(c)}),b.sort()}function rb(a,b){return a?yd.call(a,b):!1}function sb(a){for(var b=-1,c=Zd(a),d=c.length,e={};++b<d;){var f=c[b];e[a[f]]=f}return e}function tb(a){return a===!0||a===!1||Ed.call(a)==O}function ub(a){return a?"object"==typeof a&&Ed.call(a)==P:!1}function vb(a){return a?1===a.nodeType:!1}function wb(a){var b=!0;if(!a)return b;var c=Ed.call(a),d=a.length;return c==N||c==U||c==M||c==S&&"number"==typeof d&&zb(a.splice)?!d:(fe(a,function(){return b=!1}),b)}function xb(a,b,c,d){return x(a,b,"function"==typeof c&&s(c,d,2))}function yb(a){return Kd(a)&&!Ld(parseFloat(a))}function zb(a){return"function"==typeof a}function Ab(a){return!(!a||!Y[typeof a])}function Bb(a){return Db(a)&&a!=+a}function Cb(a){return null===a}function Db(a){return"number"==typeof a||Ed.call(a)==R}function Eb(a){return a?"object"==typeof a&&Ed.call(a)==T:!1}function Fb(a){return"string"==typeof a||Ed.call(a)==U}function Gb(a){return"undefined"==typeof a}function Hb(a){var b=arguments,c=2;if(!Ab(a))return a;if("number"!=typeof b[2]&&(c=b.length),c>3&&"function"==typeof b[c-2])var d=s(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=Rd.call(arguments,1,c),f=-1,g=k(),h=k();++f<c;)Z(a,e[f],d,g,h);return n(g),n(h),a}function Ib(a,b,d){var e=gb(),f="function"==typeof b,g={};if(f)b=c.createCallback(b,d,3);else var h=t(arguments,!0,!1,1);return ee(a,function(a,c,d){(f?!b(a,c,d):e(h,c)<0)&&(g[c]=a)}),g}function Jb(a){for(var b=-1,c=Zd(a),d=c.length,e=fd(d);++b<d;){var f=c[b];e[b]=[f,a[f]]}return e}function Kb(a,b,d){var e={};if("function"!=typeof b)for(var f=-1,g=t(arguments,!0,!1,1),h=Ab(a)?g.length:0;++f<h;){var i=g[f];i in a&&(e[i]=a[i])}else b=c.createCallback(b,d,3),ee(a,function(a,c,d){b(a,c,d)&&(e[c]=a)});return e}function Lb(a,b,c,d){var e=Xd(a);if(b=s(b,d,4),null==c)if(e)c=[];else{var f=a&&a.constructor,g=f&&f.prototype;c=eb(g)}return(e?Tb:fe)(a,function(a,d,e){return b(c,a,d,e)}),c}function Mb(a){for(var b=-1,c=Zd(a),d=c.length,e=fd(d);++b<d;)e[b]=a[c[b]];return e}function Nb(a){for(var b=arguments,c=-1,d=t(b,!0,!1,1),e=b[2]&&b[2][b[1]]===a?1:d.length,f=fd(e);++c<e;)f[c]=a[d[c]];return f}function Ob(a,b,c){var d=-1,e=gb(),f=a?a.length:0,g=!1;return c=(0>c?Nd(0,f+c):c)||0,Xd(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Fb(a)?a.indexOf(b,c):e(a,b,c))>-1:fe(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Pb(a,b,d){var e=!0;b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&(e=!!b(a[f],f,a)););else fe(a,function(a,c,d){return e=!!b(a,c,d)});return e}function Qb(a,b,d){var e=[];b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g;){var h=a[f];b(h,f,a)&&e.push(h)}else fe(a,function(a,c,d){b(a,c,d)&&e.push(a)});return e}function Rb(a,b,d){b=c.createCallback(b,d,3);var e=-1,f=a?a.length:0;if("number"!=typeof f){var g;return fe(a,function(a,c,d){return b(a,c,d)?(g=a,!1):void 0}),g}for(;++e<f;){var h=a[e];if(b(h,e,a))return h}}function Sb(a,b,d){var e;return b=c.createCallback(b,d,3),Ub(a,function(a,c,d){return b(a,c,d)?(e=a,!1):void 0}),e}function Tb(a,b,c){var d=-1,e=a?a.length:0;if(b=b&&"undefined"==typeof c?b:s(b,c,3),"number"==typeof e)for(;++d<e&&b(a[d],d,a)!==!1;);else fe(a,b);return a}function Ub(a,b,c){var d=a?a.length:0;if(b=b&&"undefined"==typeof c?b:s(b,c,3),"number"==typeof d)for(;d--&&b(a[d],d,a)!==!1;);else{var e=Zd(a);d=e.length,fe(a,function(a,c,f){return c=e?e[--d]:--d,b(f[c],c,f)})}return a}function Vb(a,b){var c=Rd.call(arguments,2),d=-1,e="function"==typeof b,f=a?a.length:0,g=fd("number"==typeof f?f:0);return Tb(a,function(a){g[++d]=(e?b:a[b]).apply(a,c)}),g}function Wb(a,b,d){var e=-1,f=a?a.length:0;if(b=c.createCallback(b,d,3),"number"==typeof f)for(var g=fd(f);++e<f;)g[e]=b(a[e],e,a);else g=[],fe(a,function(a,c,d){g[++e]=b(a,c,d)});return g}function Xb(a,b,d){var e=-1/0,f=e;if(!b&&Xd(a))for(var h=-1,i=a.length;++h<i;){var j=a[h];j>f&&(f=j)}else b=!b&&Fb(a)?g:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);g>e&&(e=g,f=a)});return f}function Yb(a,b,d){var e=1/0,f=e;if(!b&&Xd(a))for(var h=-1,i=a.length;++h<i;){var j=a[h];f>j&&(f=j)}else b=!b&&Fb(a)?g:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);e>g&&(e=g,f=a)});return f}function Zb(a,b){var c=-1,d=a?a.length:0;if("number"==typeof d)for(var e=fd(d);++c<d;)e[c]=a[c][b];return e||Wb(a,b)}function $b(a,b,c,d){if(!a)return c;var e=arguments.length<3;b=s(b,d,4);var f=-1,g=a.length;if("number"==typeof g)for(e&&(c=a[++f]);++f<g;)c=b(c,a[f],f,a);else fe(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)});return c}function _b(a,b,c,d){var e=arguments.length<3;return b=s(b,d,4),Ub(a,function(a,d,f){c=e?(e=!1,a):b(c,a,d,f)}),c}function ac(a,b,d){return b=c.createCallback(b,d,3),Qb(a,function(a,c,d){return!b(a,c,d)})}function bc(a,b,c){var d=a?a.length:0;if("number"!=typeof d&&(a=Mb(a)),null==b||c)return a?a[Wc(d-1)]:r;var e=cc(a);return e.length=Od(Nd(0,b),e.length),e}function cc(a){var b=-1,c=a?a.length:0,d=fd("number"==typeof c?c:0);return Tb(a,function(a){var c=Wc(++b);d[b]=d[c],d[c]=a}),d}function dc(a){var b=a?a.length:0;return"number"==typeof b?b:Zd(a).length}function ec(a,b,d){var e;b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++f<g&&!(e=b(a[f],f,a)););else fe(a,function(a,c,d){return!(e=b(a,c,d))});return!!e}function fc(a,b,d){var e=-1,f=a?a.length:0,g=fd("number"==typeof f?f:0);for(b=c.createCallback(b,d,3),Tb(a,function(a,c,d){var f=g[++e]=l();f.criteria=b(a,c,d),f.index=e,f.value=a}),f=g.length,g.sort(h);f--;){var i=g[f];g[f]=i.value,o(i)}return g}function gc(a){return a&&"number"==typeof a.length?p(a):Mb(a)}function hc(a){for(var b=-1,c=a?a.length:0,d=[];++b<c;){var e=a[b];e&&d.push(e)}return d}function ic(b){var c=-1,d=gb(),f=b?b.length:0,g=t(arguments,!0,!0,1),h=[],j=f>=w&&d===a;if(j){var k=i(g);k?(d=e,g=k):j=!1}for(;++c<f;){var l=b[c];d(g,l)<0&&h.push(l)}return j&&o(g),h}function jc(a,b,d){var e=-1,f=a?a.length:0;for(b=c.createCallback(b,d,3);++e<f;)if(b(a[e],e,a))return e;return-1}function kc(a,b,d){var e=a?a.length:0;for(b=c.createCallback(b,d,3);e--;)if(b(a[e],e,a))return e;return-1}function lc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=-1;for(b=c.createCallback(b,d,3);++g<f&&b(a[g],g,a);)e++}else if(e=b,null==e||d)return a?a[0]:r;return p(a,0,Od(Nd(0,e),f))}function mc(a,b,c,d){return"boolean"!=typeof b&&null!=b&&(d=c,c=d&&d[b]===a?null:b,b=!1),null!=c&&(a=Wb(a,c,d)),t(a,b)}function nc(b,c,d){if("number"==typeof d){var e=b?b.length:0;d=0>d?Nd(0,e+d):d||0}else if(d){var f=wc(b,c);return b[f]===c?f:-1}return a(b,c,d)}function oc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=f;for(b=c.createCallback(b,d,3);g--&&b(a[g],g,a);)e++}else e=null==b||d?1:b||e;return p(a,0,Od(Nd(0,f-e),f))}function pc(b){for(var c=arguments,d=c.length,f=-1,g=k(),h=-1,j=gb(),l=b?b.length:0,m=[],p=k();++f<d;){var q=c[f];g[f]=j===a&&(q?q.length:0)>=w&&i(f?c[f]:p)}a:for(;++h<l;){var r=g[0];if(q=b[h],(r?e(r,q):j(p,q))<0){for(f=d,(r||p).push(q);--f;)if(r=g[f],(r?e(r,q):j(c[f],q))<0)continue a;m.push(q)}}for(;d--;)r=g[d],r&&o(r);return n(g),n(p),m}function qc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=f;for(b=c.createCallback(b,d,3);g--&&b(a[g],g,a);)e++}else if(e=b,null==e||d)return a?a[f-1]:r;return p(a,Nd(0,f-e))}function rc(a,b,c){var d=a?a.length:0;for("number"==typeof c&&(d=(0>c?Nd(0,d+c):Od(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function sc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++c<d;)for(var f=-1,g=b[c];++f<e;)a[f]===g&&(Dd.call(a,f--,1),e--);return a}function tc(a,b,c){a=+a||0,c="number"==typeof c?c:+c||1,null==b&&(b=a,a=0);for(var d=-1,e=Nd(0,td((b-a)/(c||1))),f=fd(e);++d<e;)f[d]=a,a+=c;return f}function uc(a,b,d){var e=-1,f=a?a.length:0,g=[];for(b=c.createCallback(b,d,3);++e<f;){var h=a[e];b(h,e,a)&&(g.push(h),Dd.call(a,e--,1),f--)}return g}function vc(a,b,d){if("number"!=typeof b&&null!=b){var e=0,f=-1,g=a?a.length:0;for(b=c.createCallback(b,d,3);++f<g&&b(a[f],f,a);)e++}else e=null==b||d?1:Nd(0,b);return p(a,e)}function wc(a,b,d,e){var f=0,g=a?a.length:f;for(d=d?c.createCallback(d,e,1):Tc,b=d(b);g>f;){var h=f+g>>>1;d(a[h])<b?f=h+1:g=h}return f}function xc(){return _(t(arguments,!0,!0))}function yc(a,b,d,e){return"boolean"!=typeof b&&null!=b&&(e=d,d=e&&e[b]===a?null:b,b=!1),null!=d&&(d=c.createCallback(d,e,3)),_(a,b,d)}function zc(a){return ic(a,Rd.call(arguments,1))}function Ac(){for(var a=arguments.length>1?arguments:arguments[0],b=-1,c=a?Xb(Zb(a,"length")):0,d=fd(0>c?0:c);++b<c;)d[b]=Zb(a,b);return d}function Bc(a,b){for(var c=-1,d=a?a.length:0,e={};++c<d;){var f=a[c];b?e[f]=b[c]:f&&(e[f[0]]=f[1])}return e}function Cc(a,b){if(!zb(b))throw new od;return function(){return--a<1?b.apply(this,arguments):void 0}}function Dc(a,b){return arguments.length>2?cb(a,17,Rd.call(arguments,2),null,b):cb(a,1,null,null,b)}function Ec(a){for(var b=arguments.length>1?t(arguments,!0,!1,1):qb(a),c=-1,d=b.length;++c<d;){var e=b[c];a[e]=cb(a[e],1,null,null,a)}return a}function Fc(a,b){return arguments.length>2?cb(b,19,Rd.call(arguments,2),null,a):cb(b,3,null,null,a)}function Gc(){for(var a=arguments,b=a.length;b--;)if(!zb(a[b]))throw new od;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Hc(a,b,c){var d=typeof a;if(null==a||"function"==d)return s(a,b,c);if("object"!=d)return function(b){return b[a]};var e=Zd(a),f=e[0],g=a[f];return 1!=e.length||g!==g||Ab(g)?function(b){for(var c=e.length,d=!1;c--&&(d=x(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return g===b&&(0!==g||1/g==1/b)}}function Ic(a,b){return b="number"==typeof b?b:+b||a.length,cb(a,4,null,null,null,b)}function Jc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!zb(a))throw new od;if(b=Nd(0,b)||0,c===!0){var n=!0;m=!1}else Ab(c)&&(n=c.leading,l="maxWait"in c&&(Nd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(zd()-g);if(0>=c){e&&ud(e);var l=j;e=i=j=r,l&&(k=zd(),f=a.apply(h,d))}else i=Cd(o,c)},p=function(){i&&ud(i),e=i=j=r,(m||l!==b)&&(k=zd(),f=a.apply(h,d))};return function(){if(d=arguments,g=zd(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k);0>=q?(e&&(e=ud(e)),k=g,f=a.apply(h,d)):e||(e=Cd(p,q))}return i||b===l||(i=Cd(o,b)),c&&(f=a.apply(h,d)),f}}function Kc(a){if(!zb(a))throw new od;var b=Rd.call(arguments,1);return Cd(function(){a.apply(r,b)},1)}function Lc(a,b){if(!zb(a))throw new od;var c=Rd.call(arguments,2);return Cd(function(){a.apply(r,c)},b)}function Mc(a,b){if(!zb(a))throw new od;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):v+arguments[0];return yd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Nc(a){var b,c;if(!zb(a))throw new od;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Oc(a){return cb(a,16,Rd.call(arguments,1))}function Pc(a){return cb(a,32,null,Rd.call(arguments,1))}function Qc(a,b,c){var d=!0,e=!0;if(!zb(a))throw new od;c===!1?d=!1:Ab(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),W.leading=d,W.maxWait=b,W.trailing=e;var f=Jc(a,b,W);return f}function Rc(a,b){if(!zb(b))throw new od;return function(){var c=[a];return Ad.apply(c,arguments),b.apply(this,c)}}function Sc(a){return null==a?"":nd(a).replace(be,fb)}function Tc(a){return a}function Uc(a,b){var e=a,f=!b||zb(e);b||(e=d,b=a,a=c),Tb(qb(b),function(c){var d=a[c]=b[c];f&&(e.prototype[c]=function(){var b=this.__wrapped__,c=[b];Ad.apply(c,arguments);var f=d.apply(a,c);return b&&"object"==typeof b&&b===f?this:(f=new e(f),f.__chain__=this.__chain__,f)})})}function Vc(){return b._=rd,this}function Wc(a,b,c){var d=null==a,e=null==b;null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0;var f=Qd();return c||a%1||b%1?Od(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b):a+vd(f*(b-a+1))}function Xc(a,b){if(a){var c=a[b];return zb(c)?a[b]():c}}function Yc(a,b,d){var e=c.templateSettings;a||(a=""),d=de({},d,e);var f,g=de({},d.imports,e.imports),h=Zd(g),i=Mb(g),k=0,l=d.interpolate||H,m="__p += '",n=md((d.escape||H).source+"|"+l.source+"|"+(l===F?C:H).source+"|"+(d.evaluate||H).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(k,h).replace(J,j),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),k=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(z,""):m).replace(A,"$1").replace(B,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+L++ +"]")+"\n*/";try{var s=id(h,"return "+m+q).apply(r,i)}catch(t){throw t.source=m,t}return b?s(b):(s.source=m,s)}function Zc(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=fd(a);for(b=s(b,c,1);++d<a;)e[d]=b(d);return e}function $c(a){return null==a?"":nd(a).replace(ae,ib)}function _c(a){var b=++u;return nd(null==a?"":a)+b}function ad(a){return a=new d(a),a.__chain__=!0,a}function bd(a,b){return b(a),a}function cd(){return this.__chain__=!0,this}function dd(){return nd(this.__wrapped__)}function ed(){return this.__wrapped__}b=b?db.defaults($.Object(),b,db.pick($,K)):$;var fd=b.Array,gd=b.Boolean,hd=b.Date,id=b.Function,jd=b.Math,kd=b.Number,ld=b.Object,md=b.RegExp,nd=b.String,od=b.TypeError,pd=[],qd=ld.prototype,rd=b._,sd=md("^"+nd(qd.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),td=jd.ceil,ud=b.clearTimeout,vd=jd.floor,wd=id.prototype.toString,xd=sd.test(xd=ld.getPrototypeOf)&&xd,yd=qd.hasOwnProperty,zd=sd.test(zd=hd.now)&&zd||function(){return+new hd},Ad=pd.push,Bd=b.setImmediate,Cd=b.setTimeout,Dd=pd.splice,Ed=qd.toString,Fd=pd.unshift,Gd=function(){try{var a={},b=sd.test(b=ld.defineProperty)&&b,c=b(a,a,a)&&b}catch(d){}return c}(),Hd=sd.test(Hd=Ed.bind)&&Hd,Id=sd.test(Id=ld.create)&&Id,Jd=sd.test(Jd=fd.isArray)&&Jd,Kd=b.isFinite,Ld=b.isNaN,Md=sd.test(Md=ld.keys)&&Md,Nd=jd.max,Od=jd.min,Pd=b.parseInt,Qd=jd.random,Rd=pd.slice,Sd=sd.test(b.attachEvent),Td=Hd&&!/\n|true/.test(Hd+Sd),Ud={};Ud[N]=fd,Ud[O]=gd,Ud[P]=hd,Ud[Q]=id,Ud[S]=ld,Ud[R]=kd,Ud[T]=md,Ud[U]=nd,d.prototype=c.prototype;var Vd=c.support={};Vd.fastBind=Hd&&!Td,Vd.funcDecomp=!sd.test(b.WinRTError)&&I.test(q),Vd.funcNames="string"==typeof id.name,c.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:c}},Id||(eb=function(a){if(Ab(a)){m.prototype=a;var b=new m;m.prototype=null}return b||{}});var Wd=Gd?function(a,b){X.value=b,Gd(a,"__bindData__",X)}:m,Xd=Jd||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ed.call(a)==N||!1},Yd=function(a){var b,c=a,d=[];if(!c)return d;if(!Y[typeof a])return d;for(b in c)yd.call(c,b)&&d.push(b);return d},Zd=Md?function(a){return Ab(a)?Md(a):[]}:Yd,$d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_d=sb($d),ae=md("("+Zd(_d).join("|")+")","g"),be=md("["+Zd($d).join("")+"]","g"),ce=function(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=s(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h<i;)if(e=g[h],e&&Y[typeof e])for(var k=-1,l=Y[typeof e]&&Zd(e),m=l?l.length:0;++k<m;)d=l[k],f[d]=j?j(f[d],e[d]):e[d];return f},de=function(a,b,c){var d,e=a,f=e;if(!e)return f;for(var g=arguments,h=0,i="number"==typeof c?2:g.length;++h<i;)if(e=g[h],e&&Y[typeof e])for(var j=-1,k=Y[typeof e]&&Zd(e),l=k?k.length:0;++j<l;)d=k[j],"undefined"==typeof f[d]&&(f[d]=e[d]);return f},ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:s(b,c,3);for(d in e)if(b(e[d],d,a)===!1)return f;return f},fe=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Y[typeof e])return f;b=b&&"undefined"==typeof c?b:s(b,c,3);for(var g=-1,h=Y[typeof e]&&Zd(e),i=h?h.length:0;++g<i;)if(d=h[g],b(e[d],d,a)===!1)return f;return f},ge=function(a){if(!a||Ed.call(a)!=S)return!1;var b=a.valueOf,c="function"==typeof b&&(c=xd(b))&&xd(c);return c?a==c||xd(a)==c:hb(a)},he=ab(function(a,b,c){yd.call(a,c)?a[c]++:a[c]=1}),ie=ab(function(a,b,c){(yd.call(a,c)?a[c]:a[c]=[]).push(b)}),je=ab(function(a,b,c){a[c]=b}),ke=Qb;Td&&bb&&"function"==typeof Bd&&(Kc=function(a){if(!zb(a))throw new od;return Bd.apply(b,arguments)});var le=8==Pd(y+"08")?Pd:function(a,b){return Pd(Fb(a)?a.replace(G,""):a,b||0)};return c.after=Cc,c.assign=ce,c.at=Nb,c.bind=Dc,c.bindAll=Ec,c.bindKey=Fc,c.chain=ad,c.compact=hc,c.compose=Gc,c.countBy=he,c.createCallback=Hc,c.curry=Ic,c.debounce=Jc,c.defaults=de,c.defer=Kc,c.delay=Lc,c.difference=ic,c.filter=Qb,c.flatten=mc,c.forEach=Tb,c.forEachRight=Ub,c.forIn=ee,c.forInRight=ob,c.forOwn=fe,c.forOwnRight=pb,c.functions=qb,c.groupBy=ie,c.indexBy=je,c.initial=oc,c.intersection=pc,c.invert=sb,c.invoke=Vb,c.keys=Zd,c.map=Wb,c.max=Xb,c.memoize=Mc,c.merge=Hb,c.min=Yb,c.omit=Ib,c.once=Nc,c.pairs=Jb,c.partial=Oc,c.partialRight=Pc,c.pick=Kb,c.pluck=Zb,c.pull=sc,c.range=tc,c.reject=ac,c.remove=uc,c.rest=vc,c.shuffle=cc,c.sortBy=fc,c.tap=bd,c.throttle=Qc,c.times=Zc,c.toArray=gc,c.transform=Lb,c.union=xc,c.uniq=yc,c.values=Mb,c.where=ke,c.without=zc,c.wrap=Rc,c.zip=Ac,c.zipObject=Bc,c.collect=Wb,c.drop=vc,c.each=Tb,c.eachRight=Ub,c.extend=ce,c.methods=qb,c.object=Bc,c.select=Qb,c.tail=vc,c.unique=yc,c.unzip=Ac,Uc(c),c.clone=kb,c.cloneDeep=lb,c.contains=Ob,c.escape=Sc,c.every=Pb,c.find=Rb,c.findIndex=jc,c.findKey=mb,c.findLast=Sb,c.findLastIndex=kc,c.findLastKey=nb,c.has=rb,c.identity=Tc,c.indexOf=nc,c.isArguments=jb,c.isArray=Xd,c.isBoolean=tb,c.isDate=ub,c.isElement=vb,c.isEmpty=wb,c.isEqual=xb,c.isFinite=yb,c.isFunction=zb,c.isNaN=Bb,c.isNull=Cb,c.isNumber=Db,c.isObject=Ab,c.isPlainObject=ge,c.isRegExp=Eb,c.isString=Fb,c.isUndefined=Gb,c.lastIndexOf=rc,c.mixin=Uc,c.noConflict=Vc,c.parseInt=le,c.random=Wc,c.reduce=$b,c.reduceRight=_b,c.result=Xc,c.runInContext=q,c.size=dc,c.some=ec,c.sortedIndex=wc,c.template=Yc,c.unescape=$c,c.uniqueId=_c,c.all=Pb,c.any=ec,c.detect=Rb,c.findWhere=Rb,c.foldl=$b,c.foldr=_b,c.include=Ob,c.inject=$b,fe(c,function(a,b){c.prototype[b]||(c.prototype[b]=function(){var b=[this.__wrapped__],e=this.__chain__;Ad.apply(b,arguments);var f=a.apply(c,b);return e?new d(f,e):f})}),c.first=lc,c.last=qc,c.sample=bc,c.take=lc,c.head=lc,fe(c,function(a,b){var e="sample"!==b;c.prototype[b]||(c.prototype[b]=function(b,c){var f=this.__chain__,g=a(this.__wrapped__,b,c);return f||null!=b&&(!c||e&&"function"==typeof b)?new d(g,f):g})}),c.VERSION="2.2.1",c.prototype.chain=cd,c.prototype.toString=dd,c.prototype.value=ed,c.prototype.valueOf=ed,Tb(["join","pop","shift"],function(a){var b=pd[a];c.prototype[a]=function(){var a=this.__chain__,c=b.apply(this.__wrapped__,arguments);return a?new d(c,a):c}}),Tb(["push","reverse","sort","unshift"],function(a){var b=pd[a];c.prototype[a]=function(){return b.apply(this.__wrapped__,arguments),this}}),Tb(["concat","slice","splice"],function(a){var b=pd[a];c.prototype[a]=function(){return new d(b.apply(this.__wrapped__,arguments),this.__chain__)}}),c}var r,s=[],t=[],u=0,v=+new Date+"",w=75,x=40,y=" \f \n\r\u2028\u2029 ᠎              ",z=/\b__p \+= '';/g,A=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,E=/^function[ \n\r\t]+\w/,F=/<%=([\s\S]+?)%>/g,G=RegExp("^["+y+"]*0+(?=.$)"),H=/($^)/,I=/\bthis\b/,J=/['\n\r\t\u2028\u2029\\]/g,K=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setImmediate","setTimeout"],L=0,M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Function]",R="[object Number]",S="[object Object]",T="[object RegExp]",U="[object String]",V={};V[Q]=!1,V[M]=V[N]=V[O]=V[P]=V[R]=V[S]=V[T]=V[U]=!0;var W={leading:!1,maxWait:0,trailing:!1},X={configurable:!1,enumerable:!1,value:null,writable:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=Y[typeof window]&&window||this,_=Y[typeof c]&&c&&!c.nodeType&&c,ab=Y[typeof b]&&b&&!b.nodeType&&b,bb=ab&&ab.exports===_&&_,cb=Y[typeof d]&&d;!cb||cb.global!==cb&&cb.window!==cb||($=cb);var db=q();"function"==typeof define&&"object"==typeof define.amd&&define.amd?($._=db,define(function(){return db})):_&&ab?bb?(ab.exports=db)._=db:_._=db:$._=db}).call(this)},{}],16:[function(a,b){function c(a,b){"use strict";function c(b){return b in a}function e(c,e){return b?d["is"+e].call(void 0,a[c]):!0}if(b=null==b?!0:b,!d.isPlainObject(a))throw new TypeError("Invalid parameter passed to Link constructor");if(!c("href")){if(!b)return;throw new ReferenceError('Missing "href" property to link description')}if(this.templated=a.templated===!0,c("deprecation")&&!e("deprecation","Boolean")&&!e("deprecation","String"))throw new TypeError("Invalid Link deprecation provided");
+this.deprecated=!!a.deprecation,this.deprecationInfo=!a.deprecation||d.isBoolean(a.deprecation)?null:a.deprecation,["type","name","profile","title","href","hreflang"].forEach(function(b){if(c(b)&&null!=a[b]&&!e(b,"String"))throw new Error('Invalid link property "'+b+'" provided.');this[b]=a[b]}.bind(this))}var d=a("lodash");b.exports=c},{lodash:15}],17:[function(a,b){function c(a,b){"use strict";b=null==b?!0:b;var c={};if(this.get=function(a){return a?c[a]:c},a){if(!e.isPlainObject(a))throw new TypeError("The provided object is not an object literal.");Object.keys(a).forEach(function(f){var g=a[f];e.isArray(g)||(g=[g]);var h=g.map(function(a){return new d(a,b)});c[f]=h})}}var d=a("./link"),e=a("lodash");b.exports=c},{"./link":16,lodash:15}],18:[function(a,b){function c(a,b){"use strict";b=null==b?!0:b;var f=e.cloneDeep(a),g=f._links;delete f._links;var h=f._embedded;return delete f._embedded,new d(f,g,h,c,b)}var d=a("./resource"),e=a("lodash");b.exports=c},{"./resource":19,lodash:15}],19:[function(a,b){function c(a,b,c){"use strict";var d={},e=f.partialRight(b,c);return Object.keys(a).forEach(function(b){var c=a[b];d[b]=c.map?c.map(e):c}),d}function d(a,b,d,g,h){"use strict";var i=this;if(!f.isPlainObject(a))throw new Error("No object provided");var j=c(d||{},g,h),k=new e(b,h);this.toJSON=function(){return a},this.embedded=function(a){return a?j[a]:j},this.links=function(a){return a?k.get(a):k},Object.keys(a).forEach(function(b){i[b]=a[b]})}var e=a("./links"),f=a("lodash");b.exports=d},{"./links":17,lodash:15}],20:[function(a,b,c){!function(a,d){"use strict";function e(a,b){var c,d,e=a.toLowerCase();for(b=[].concat(b),c=0;c<b.length;c+=1)if(d=b[c]){if(d.test&&d.test(a))return!0;if(d.toLowerCase()===e)return!0}}var f=d.prototype.trim,g=d.prototype.trimRight,h=d.prototype.trimLeft,i=function(a){return 1*a||0},j=function(a,b){if(1>b)return"";for(var c="";b>0;)1&b&&(c+=a),b>>=1,a+=a;return c},k=[].slice,l=function(a){return null==a?"\\s":a.source?a.source:"["+q.escapeRegExp(a)+"]"},m={lt:"<",gt:">",quot:'"',amp:"&",apos:"'"},n={};for(var o in m)n[m[o]]=o;n["'"]="#39";var p=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}var b=j,c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,e){var f,g,h,i,j,k,l,m=1,n=c.length,o="",q=[];for(g=0;n>g;g++)if(o=a(c[g]),"string"===o)q.push(c[g]);else if("array"===o){if(i=c[g],i[2])for(f=e[m],h=0;h<i[2].length;h++){if(!f.hasOwnProperty(i[2][h]))throw new Error(p('[_.sprintf] property "%s" does not exist',i[2][h]));f=f[i[2][h]]}else f=i[1]?e[i[1]]:e[m++];if(/[^s]/.test(i[8])&&"number"!=a(f))throw new Error(p("[_.sprintf] expecting number but found %s",a(f)));switch(i[8]){case"b":f=f.toString(2);break;case"c":f=d.fromCharCode(f);break;case"d":f=parseInt(f,10);break;case"e":f=i[7]?f.toExponential(i[7]):f.toExponential();break;case"f":f=i[7]?parseFloat(f).toFixed(i[7]):parseFloat(f);break;case"o":f=f.toString(8);break;case"s":f=(f=d(f))&&i[7]?f.substring(0,i[7]):f;break;case"u":f=Math.abs(f);break;case"x":f=f.toString(16);break;case"X":f=f.toString(16).toUpperCase()}f=/[def]/.test(i[8])&&i[3]&&f>=0?"+"+f:f,k=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",l=i[6]-d(f).length,j=i[6]?b(k,l):"",q.push(i[5]?f+j:j+f)}return q.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw new Error("[_.sprintf] huh?");if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw new Error("[_.sprintf] huh?");for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw new Error("[_.sprintf] huh?");f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw new Error("[_.sprintf] mixing positional and named placeholders is not (yet) supported");d.push(c)}b=b.substring(c[0].length)}return d},c}(),q={VERSION:"2.3.0",isBlank:function(a){return null==a&&(a=""),/^\s*$/.test(a)},stripTags:function(a){return null==a?"":d(a).replace(/<\/?[^>]+>/g,"")},capitalize:function(a){return a=null==a?"":d(a),a.charAt(0).toUpperCase()+a.slice(1)},chop:function(a,b){return null==a?[]:(a=d(a),b=~~b,b>0?a.match(new RegExp(".{1,"+b+"}","g")):[a])},clean:function(a){return q.strip(a).replace(/\s+/g," ")},count:function(a,b){if(null==a||null==b)return 0;a=d(a),b=d(b);for(var c=0,e=0,f=b.length;;){if(e=a.indexOf(b,e),-1===e)break;c++,e+=f}return c},chars:function(a){return null==a?[]:d(a).split("")},swapCase:function(a){return null==a?"":d(a).replace(/\S/g,function(a){return a===a.toUpperCase()?a.toLowerCase():a.toUpperCase()})},escapeHTML:function(a){return null==a?"":d(a).replace(/[&<>"']/g,function(a){return"&"+n[a]+";"})},unescapeHTML:function(a){return null==a?"":d(a).replace(/\&([^;]+);/g,function(a,b){var c;return b in m?m[b]:(c=b.match(/^#x([\da-fA-F]+)$/))?d.fromCharCode(parseInt(c[1],16)):(c=b.match(/^#(\d+)$/))?d.fromCharCode(~~c[1]):a})},escapeRegExp:function(a){return null==a?"":d(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")},splice:function(a,b,c,d){var e=q.chars(a);return e.splice(~~b,~~c,d),e.join("")},insert:function(a,b,c){return q.splice(a,b,0,c)},include:function(a,b){return""===b?!0:null==a?!1:-1!==d(a).indexOf(b)},join:function(){var a=k.call(arguments),b=a.shift();return null==b&&(b=""),a.join(b)},lines:function(a){return null==a?[]:d(a).split("\n")},reverse:function(a){return q.chars(a).reverse().join("")},startsWith:function(a,b){return""===b?!0:null==a||null==b?!1:(a=d(a),b=d(b),a.length>=b.length&&a.slice(0,b.length)===b)},endsWith:function(a,b){return""===b?!0:null==a||null==b?!1:(a=d(a),b=d(b),a.length>=b.length&&a.slice(a.length-b.length)===b)},succ:function(a){return null==a?"":(a=d(a),a.slice(0,-1)+d.fromCharCode(a.charCodeAt(a.length-1)+1))},titleize:function(a){return null==a?"":(a=d(a).toLowerCase(),a.replace(/(?:^|\s|-)\S/g,function(a){return a.toUpperCase()}))},camelize:function(a){return q.trim(a).replace(/[-_\s]+(.)?/g,function(a,b){return b?b.toUpperCase():""})},underscored:function(a){return q.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()},dasherize:function(a){return q.trim(a).replace(/([A-Z])/g,"-$1").replace(/[-_\s]+/g,"-").toLowerCase()},classify:function(a){return q.titleize(d(a).replace(/[\W_]/g," ")).replace(/\s/g,"")},humanize:function(a){return q.capitalize(q.underscored(a).replace(/_id$/,"").replace(/_/g," "))},trim:function(a,b){return null==a?"":!b&&f?f.call(a):(b=l(b),d(a).replace(new RegExp("^"+b+"+|"+b+"+$","g"),""))},ltrim:function(a,b){return null==a?"":!b&&h?h.call(a):(b=l(b),d(a).replace(new RegExp("^"+b+"+"),""))},rtrim:function(a,b){return null==a?"":!b&&g?g.call(a):(b=l(b),d(a).replace(new RegExp(b+"+$"),""))},truncate:function(a,b,c){return null==a?"":(a=d(a),c=c||"...",b=~~b,a.length>b?a.slice(0,b)+c:a)},prune:function(a,b,c){if(null==a)return"";if(a=d(a),b=~~b,c=null!=c?d(c):"...",a.length<=b)return a;var e=function(a){return a.toUpperCase()!==a.toLowerCase()?"A":" "},f=a.slice(0,b+1).replace(/.(?=\W*\w*$)/g,e);return f=f.slice(f.length-2).match(/\w\w/)?f.replace(/\s*\S+$/,""):q.rtrim(f.slice(0,f.length-1)),(f+c).length>a.length?a:a.slice(0,f.length)+c},words:function(a,b){return q.isBlank(a)?[]:q.trim(a,b).split(b||/\s+/)},pad:function(a,b,c,e){a=null==a?"":d(a),b=~~b;var f=0;switch(c?c.length>1&&(c=c.charAt(0)):c=" ",e){case"right":return f=b-a.length,a+j(c,f);case"both":return f=b-a.length,j(c,Math.ceil(f/2))+a+j(c,Math.floor(f/2));default:return f=b-a.length,j(c,f)+a}},lpad:function(a,b,c){return q.pad(a,b,c)},rpad:function(a,b,c){return q.pad(a,b,c,"right")},lrpad:function(a,b,c){return q.pad(a,b,c,"both")},sprintf:p,vsprintf:function(a,b){return b.unshift(a),p.apply(null,b)},toNumber:function(a,b){return a?(a=q.trim(a),a.match(/^-?\d+(?:\.\d+)?$/)?i(i(a).toFixed(~~b)):0/0):0},numberFormat:function(a,b,c,d){if(isNaN(a)||null==a)return"";a=a.toFixed(~~b),d="string"==typeof d?d:",";var e=a.split("."),f=e[0],g=e[1]?(c||".")+e[1]:"";return f.replace(/(\d)(?=(?:\d{3})+$)/g,"$1"+d)+g},strRight:function(a,b){if(null==a)return"";a=d(a),b=null!=b?d(b):b;var c=b?a.indexOf(b):-1;return~c?a.slice(c+b.length,a.length):a},strRightBack:function(a,b){if(null==a)return"";a=d(a),b=null!=b?d(b):b;var c=b?a.lastIndexOf(b):-1;return~c?a.slice(c+b.length,a.length):a},strLeft:function(a,b){if(null==a)return"";a=d(a),b=null!=b?d(b):b;var c=b?a.indexOf(b):-1;return~c?a.slice(0,c):a},strLeftBack:function(a,b){if(null==a)return"";a+="",b=null!=b?""+b:b;var c=a.lastIndexOf(b);return~c?a.slice(0,c):a},toSentence:function(a,b,c,d){b=b||", ",c=c||" and ";var e=a.slice(),f=e.pop();return a.length>2&&d&&(c=q.rtrim(b)+c),e.length?e.join(b)+c+f:f},toSentenceSerial:function(){var a=k.call(arguments);return a[3]=!0,q.toSentence.apply(q,a)},slugify:function(a){if(null==a)return"";var b="ąàáäâãåæăćęèéëêìíïîłńòóöôõøśșțùúüûñçżź",c="aaaaaaaaaceeeeeiiiilnoooooosstuuuunczz",e=new RegExp(l(b),"g");return a=d(a).toLowerCase().replace(e,function(a){var d=b.indexOf(a);return c.charAt(d)||"-"}),q.dasherize(a.replace(/[^\w\s-]/g,""))},surround:function(a,b){return[b,a,b].join("")},quote:function(a,b){return q.surround(a,b||'"')},unquote:function(a,b){return b=b||'"',a[0]===b&&a[a.length-1]===b?a.slice(1,a.length-1):a},exports:function(){var a={};for(var b in this)this.hasOwnProperty(b)&&!b.match(/^(?:include|contains|reverse)$/)&&(a[b]=this[b]);return a},repeat:function(a,b,c){if(null==a)return"";if(b=~~b,null==c)return j(d(a),b);for(var e=[];b>0;e[--b]=a);return e.join(c)},naturalCmp:function(a,b){if(a==b)return 0;if(!a)return-1;if(!b)return 1;for(var c=/(\.\d+)|(\d+)|(\D+)/g,e=d(a).toLowerCase().match(c),f=d(b).toLowerCase().match(c),g=Math.min(e.length,f.length),h=0;g>h;h++){var i=e[h],j=f[h];if(i!==j){var k=parseInt(i,10);if(!isNaN(k)){var l=parseInt(j,10);if(!isNaN(l)&&k-l)return k-l}return j>i?-1:1}}return e.length===f.length?e.length-f.length:b>a?-1:1},levenshtein:function(a,b){if(null==a&&null==b)return 0;if(null==a)return d(b).length;if(null==b)return d(a).length;a=d(a),b=d(b);for(var c,e,f=[],g=0;g<=b.length;g++)for(var h=0;h<=a.length;h++)e=g&&h?a.charAt(h-1)===b.charAt(g-1)?c:Math.min(f[h],f[h-1],c)+1:g+h,c=f[h],f[h]=e;return f.pop()},toBoolean:function(a,b,c){return"number"==typeof a&&(a=""+a),"string"!=typeof a?!!a:(a=q.trim(a),e(a,b||["true","1"])?!0:e(a,c||["false","0"])?!1:void 0)}};q.strip=q.trim,q.lstrip=q.ltrim,q.rstrip=q.rtrim,q.center=q.lrpad,q.rjust=q.lpad,q.ljust=q.rpad,q.contains=q.include,q.q=q.quote,q.toBool=q.toBoolean,"undefined"!=typeof c&&("undefined"!=typeof b&&b.exports&&(b.exports=q),c._s=q),"function"==typeof define&&define.amd&&define("underscore.string",[],function(){return q}),a._=a._||{},a._.string=a._.str=q}(this,String)},{}],21:[function(a,b){b.exports=function(){function b(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var c={parse:function(c,d){function e(a){v>t||(t>v&&(v=t,w=[]),w.push(a))}function f(){var a,b,c;for(c=t,a=[],b=o(),null===b&&(b=g());null!==b;)a.push(b),b=o(),null===b&&(b=g());return null!==a&&(a=function(a,b){return new y(b)}(c,a)),null===a&&(t=c),a}function g(){var a,b,d,f,g,i;return g=t,i=t,123===c.charCodeAt(t)?(a="{",t++):(a=null,0===u&&e('"{"')),null!==a?(b=h(),null!==b?(d=j(),null!==d?(125===c.charCodeAt(t)?(f="}",t++):(f=null,0===u&&e('"}"')),null!==f?a=[a,b,d,f]:(a=null,t=i)):(a=null,t=i)):(a=null,t=i)):(a=null,t=i),null!==a&&(a=function(a,b,c){return z(b,c)}(g,a[1],a[2])),null===a&&(t=g),a}function h(){var a;return/^[\/;:.?&+#]/.test(c.charAt(t))?(a=c.charAt(t),t++):(a=null,0===u&&e("[\\/;:.?&+#]")),null===a&&(a=""),a}function i(){var a;return"{/"===c.substr(t,2)?(a="{/",t+=2):(a=null,0===u&&e('"{/"')),a}function j(){var a,b,d,f,g,h,i,j;if(g=t,h=t,a=k(),null!==a){for(b=[],i=t,j=t,44===c.charCodeAt(t)?(d=",",t++):(d=null,0===u&&e('","')),null!==d?(f=k(),null!==f?d=[d,f]:(d=null,t=j)):(d=null,t=j),null!==d&&(d=function(a,b){return b}(i,d[1])),null===d&&(t=i);null!==d;)b.push(d),i=t,j=t,44===c.charCodeAt(t)?(d=",",t++):(d=null,0===u&&e('","')),null!==d?(f=k(),null!==f?d=[d,f]:(d=null,t=j)):(d=null,t=j),null!==d&&(d=function(a,b){return b}(i,d[1])),null===d&&(t=i);null!==b?a=[a,b]:(a=null,t=h)}else a=null,t=h;return null!==a&&(a=function(a,b,c){return c.unshift(b),c}(g,a[0],a[1])),null===a&&(t=g),a}function k(){var a,b,d,f,g;for(f=t,g=t,a=[],/^[a-zA-Z0-9_.%]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[a-zA-Z0-9_.%]"));null!==b;)a.push(b),/^[a-zA-Z0-9_.%]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[a-zA-Z0-9_.%]"));return null!==a?(b=l(),null===b&&(b=m()),b=null!==b?b:"",null!==b?(d=p(),d=null!==d?d:"",null!==d?a=[a,b,d]:(a=null,t=g)):(a=null,t=g)):(a=null,t=g),null!==a&&(a=function(a,b,c,d){return c=c||{},{name:b.join(""),explode:c.listMarker,cut:c.cut,extended:d}}(f,a[0],a[1],a[2])),null===a&&(t=f),a}function l(){var a,b;return b=t,a=n(),null!==a&&(a=function(a,b){return{cut:b}}(b,a)),null===a&&(t=b),a}function m(){var a,b;return b=t,42===c.charCodeAt(t)?(a="*",t++):(a=null,0===u&&e('"*"')),null!==a&&(a=function(a,b){return{listMarker:b}}(b,a)),null===a&&(t=b),a}function n(){var a,b,d,f,g;if(f=t,g=t,58===c.charCodeAt(t)?(a=":",t++):(a=null,0===u&&e('":"')),null!==a){if(/^[0-9]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[0-9]")),null!==d)for(b=[];null!==d;)b.push(d),/^[0-9]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[0-9]"));else b=null;null!==b?a=[a,b]:(a=null,t=g)}else a=null,t=g;return null!==a&&(a=function(a,b){return parseInt(b.join(""))}(f,a[1])),null===a&&(t=f),a}function o(){var a,b,d;if(d=t,/^[^{]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[^{]")),null!==b)for(a=[];null!==b;)a.push(b),/^[^{]/.test(c.charAt(t))?(b=c.charAt(t),t++):(b=null,0===u&&e("[^{]"));else a=null;return null!==a&&(a=function(a,b){return b.join("")}(d,a)),null===a&&(t=d),a}function p(){var a,b,d,f,g;if(f=t,g=t,40===c.charCodeAt(t)?(a="(",t++):(a=null,0===u&&e('"("')),null!==a){if(/^[^)]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[^)]")),null!==d)for(b=[];null!==d;)b.push(d),/^[^)]/.test(c.charAt(t))?(d=c.charAt(t),t++):(d=null,0===u&&e("[^)]"));else b=null;null!==b?(41===c.charCodeAt(t)?(d=")",t++):(d=null,0===u&&e('")"')),null!==d?a=[a,b,d]:(a=null,t=g)):(a=null,t=g)}else a=null,t=g;return null!==a&&(a=function(a,b){return b.join("")}(f,a[1])),null===a&&(t=f),a}function q(a){a.sort();for(var b=null,c=[],d=0;d<a.length;d++)a[d]!==b&&(c.push(a[d]),b=a[d]);return c}function r(){for(var a=1,b=1,d=!1,e=0;e<Math.max(t,v);e++){var f=c.charAt(e);"\n"===f?(d||a++,b=1,d=!1):"\r"===f||"\u2028"===f||"\u2029"===f?(a++,b=1,d=!0):(b++,d=!1)}return{line:a,column:b}}var s={uriTemplate:f,expression:g,op:h,pathExpression:i,paramList:j,param:k,cut:l,listMarker:m,substr:n,nonexpression:o,extension:p};if(void 0!==d){if(void 0===s[d])throw new Error("Invalid rule name: "+b(d)+".")}else d="uriTemplate";var t=0,u=0,v=0,w=[],x=a("./lib/classes"),y=x.Template,z=x.expression,A=s[d]();if(null===A||t!==c.length){var B=Math.max(t,v),C=B<c.length?c.charAt(B):null,D=r();throw new this.SyntaxError(q(w),C,B,D.line,D.column)}return A},toSource:function(){return this._source}};return c.SyntaxError=function(a,c,d,e,f){function g(a,c){var d,e;switch(a.length){case 0:d="end of input";break;case 1:d=a[0];break;default:d=a.slice(0,a.length-1).join(", ")+" or "+a[a.length-1]}return e=c?b(c):"end of input","Expected "+d+" but "+e+" found."}this.name="SyntaxError",this.expected=a,this.found=c,this.message=g(a,c),this.offset=d,this.line=e,this.column=f},c.SyntaxError.prototype=Error.prototype,c}()},{"./lib/classes":22}],22:[function(a,b){(function(){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=function(a,b){return function(){return a.apply(b,arguments)}},w={}.hasOwnProperty,x=function(a,b){function c(){this.constructor=a}for(var d in b)w.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};m=a("./encoders"),l=l=function(){function a(a){var b,c=this;this.expressions=[],this.prefix="string"==typeof a[0]?a.shift():"",b=0,a.forEach(function(a){switch(typeof a){case"object":return c.expressions[b++]=a;case"string":return c.expressions[b-1].suffix=a}})}return a.prototype.expand=function(a){return this.prefix+this.expressions.map(function(b){return b.expand(a)}).join("")},a.prototype.toString=function(){return this.prefix+this.expressions.join("")},a.prototype.toJSON=function(){return this.toString()},a}(),k=function(){function a(a){var b;this.params=a,this.explodeObject=v(this.explodeObject,this),this.explodeArray=v(this.explodeArray,this),this._expandPair=v(this._expandPair,this),this.stringifySingle=v(this.stringifySingle,this),this.encode=v(this.encode,this),null==(b=this.params)&&(this.params=[]),this.suffix=""}var b;return a.prototype.first="",a.prototype.sep=",",a.prototype.named=!1,a.prototype.empty="",a.prototype.allow="U",a.prototype.encode=function(a){return m[this.allow](a)},a.prototype.stringifySingle=function(a,b){var c,d,e;if(d=typeof b,"string"===d||"boolean"===d||"number"===d)return b=b.toString(),this.encode(b.substring(0,a.cut||b.length));if(Array.isArray(b)){if(a.cut)throw new Error("Prefixed Values do not support lists. Check "+a.name);return b.map(this.encode).join(",")}if(a.cut)throw new Error("Prefixed Values do not support maps. Check "+a.name);return function(){var a;a=[];for(c in b)e=b[c],a.push([c,e].map(this.encode).join(","));return a}.call(this).join(",")},a.prototype.expand=function(a){var c,d,e=this;return c=b(this.params,a),d=c.map(function(a){return e._expandPair.apply(e,a)}).join(this.sep),d?this.first+d+this.suffix:this.empty&&c.length?this.empty+this.suffix:this.suffix},b=function(a,b){return a.map(function(a){return[a,b[a.name]]}).filter(function(a){var b,c,d;switch(c=a[1],typeof c){case"undefined":return!1;case"object":Array.isArray(c)&&c.length>0;for(b in c)if(d=c[b])return!0;return!1;default:return!0}})},a.prototype._expandPair=function(a,b){var c;return c=a.name,a.explode?Array.isArray(b)?this.explodeArray(a,b):"string"==typeof b?this.stringifySingle(a,b):this.explodeObject(b):this.stringifySingle(a,b)},a.prototype.explodeArray=function(a,b){return b.map(this.encode).join(this.sep)},a.prototype.explodeObject=function(a){var b,c,d,e,f,g;c=[];for(b in a)if(d=a[b],b=this.encode(b),Array.isArray(d))for(f=0,g=d.length;g>f;f++)e=d[f],c.push([b,this.encode(e)]);else c.push([b,this.encode(d)]);return c.map(function(a){return a.join("=")}).join(this.sep)},a.prototype.toString=function(){var a;return a=this.params.map(function(a){return a.name+a.explode}).join(","),"{"+this.first+a+"}"+this.suffix},a.prototype.toJSON=function(){return this.toString()},a}(),g=function(a){function b(){return this.explodeArray=v(this.explodeArray,this),this.stringifySingle=v(this.stringifySingle,this),n=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.stringifySingle=function(a,c){return c=(c=b.__super__.stringifySingle.apply(this,arguments))?"="+c:this.empty,""+a.name+c},b.prototype.explodeArray=function(a,b){var c=this;return b.map(function(b){return""+a.name+"="+c.encode(b)}).join(this.sep)},b}(k),j=function(a){function b(){return o=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.encode=function(a){return m["U+R"](a)},b.prototype.toString=function(){return"{+"+b.__super__.toString.apply(this,arguments).substring(1)},b}(k),e=function(a){function b(){return p=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="#",b.prototype.empty="#",b.prototype.encode=function(a){return m["U+R"](a)},b}(k),f=function(a){function b(){return q=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first=".",b.prototype.sep=".",b.prototype.empty=".",b}(k),i=function(a){function b(){return r=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="/",b.prototype.sep="/",b}(k),h=function(a){function b(){return s=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first=";",b.prototype.sep=";",b}(g),d=function(a){function b(){return t=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="?",b.prototype.sep="&",b.prototype.empty="=",b}(g),c=function(a){function b(){return u=b.__super__.constructor.apply(this,arguments)}return x(b,a),b.prototype.first="&",b}(d),b.exports={Template:l,SimpleExpression:k,NamedExpression:g,ReservedExpression:j,FragmentExpression:e,LabelExpression:f,PathSegmentExpression:i,PathParamExpression:h,FormStartExpression:d,FormContinuationExpression:c,expression:function(a,b){var g;return g=function(){switch(a){case"":return k;case"+":return j;case"#":return e;case".":return f;case"/":return i;case";":return h;case"?":return d;case"&":return c}}(),new g(b)}}}).call(this)},{"./encoders":23}],23:[function(a,b,c){(function(){var b;b=a("pct-encode"),c.U=b(/[^\w~.-]/g),c["U+R"]=b(/[^\w.~:\/\?#\[\]@!\$&'()*+,;=-]/g)}).call(this)},{"pct-encode":24}],24:[function(a,b){b.exports=function(a){return function(b){return b=String(b),b.replace(a,function(a){var b=a[0].charCodeAt(0),c=[];return 128>b?c.push(b):b>=128&&2048>b?(c.push(b>>6|192),c.push(63&b|128)):(c.push(b>>12|224),c.push(b>>6&63|128),c.push(63&b|128)),c.map(function(a){return"%"+a.toString(16).toUpperCase()}).join("")})}}},{}],25:[function(a,b){"use strict";var c=(a("minilog"),a("./lib/media_types")),d=a("./lib/walker_builder");b.exports={json:{from:function(a){return{newRequest:function(){return new d(c.JSON,a)}}}},jsonHal:{from:function(a){return{newRequest:function(){return new d(c.JSON_HAL,a)}}}}}},{"./lib/media_types":7,"./lib/walker_builder":9,minilog:1}]},{},[25])(25)});
View
2  browser/example/README.md
@@ -1 +1 @@
-This folder contains an example html page and accompanying assets that shows how Traverson works in the browser. You need to start the test server with `node bin/start-test-server.js`, which serves index.html and the static assets as well as the REST API that is used in the example. Then open the URL `http://localhost:2808/static/browser/example` in your browser and click on "Start All Requests At Once" to get Traverson going.
+This folder contains an example html page that shows how Traverson works in the browser. You need to start the test server with `node bin/start-test-server.js`, which serves index.html and the static assets as well as the REST API that is used in the example. Then open the URL `http://localhost:2808/static/browser/example/index.html` or `http://localhost:2808/static/browser/example/index.amd.html` in your browser and click on "Start All Requests At Once" to get Traverson going.
View
0  browser/example/bootstrap.min.css → browser/example/assets/bootstrap.min.css
File renamed without changes
View
0  browser/example/jquery-2.0.2.min.js → browser/example/assets/jquery-2.0.2.min.js
File renamed without changes
View
2,054 browser/example/assets/require.js
@@ -0,0 +1,2054 @@
+/** vim: et:ts=4:sw=4:sts=4
+ * @license RequireJS 2.1.9 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+//Not using strict: uneven strict support in browsers, #392, and causes
+//problems with requirejs.exec()/transpiler plugins that may not be strict.
+/*jslint regexp: true, nomen: true, sloppy: true */
+/*global window, navigator, document, importScripts, setTimeout, opera */
+
+var requirejs, require, define;
+(function (global) {
+ var req, s, head, baseElement, dataMain, src,
+ interactiveScript, currentlyAddingScript, mainScript, subPath,
+ version = '2.1.9',
+ commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
+ cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
+ jsSuffixRegExp = /\.js$/,
+ currDirRegExp = /^\.\//,
+ op = Object.prototype,
+ ostring = op.toString,
+ hasOwn = op.hasOwnProperty,
+ ap = Array.prototype,
+ apsp = ap.splice,
+ isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
+ isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
+ //PS3 indicates loaded and complete, but need to wait for complete
+ //specifically. Sequence is 'loading', 'loaded', execution,
+ // then 'complete'. The UA check is unfortunate, but not sure how
+ //to feature test w/o causing perf issues.
+ readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
+ /^complete$/ : /^(complete|loaded)$/,
+ defContextName = '_',
+ //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
+ isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
+ contexts = {},
+ cfg = {},
+ globalDefQueue = [],
+ useInteractive = false;
+
+ function isFunction(it) {
+ return ostring.call(it) === '[object Function]';
+ }
+
+ function isArray(it) {
+ return ostring.call(it) === '[object Array]';
+ }
+
+ /**
+ * Helper function for iterating over an array. If the func returns
+ * a true value, it will break out of the loop.
+ */
+ function each(ary, func) {
+ if (ary) {
+ var i;
+ for (i = 0; i < ary.length; i += 1) {
+ if (ary[i] && func(ary[i], i, ary)) {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Helper function for iterating over an array backwards. If the func
+ * returns a true value, it will break out of the loop.
+ */
+ function eachReverse(ary, func) {
+ if (ary) {
+ var i;
+ for (i = ary.length - 1; i > -1; i -= 1) {
+ if (ary[i] && func(ary[i], i, ary)) {
+ break;
+ }
+ }
+ }
+ }
+
+ function hasProp(obj, prop) {
+ return hasOwn.call(obj, prop);
+ }
+
+ function getOwn(obj, prop) {
+ return hasProp(obj, prop) && obj[prop];
+ }
+
+ /**
+ * Cycles over properties in an object and calls a function for each
+ * property value. If the function returns a truthy value, then the
+ * iteration is stopped.
+ */
+ function eachProp(obj, func) {
+ var prop;
+ for (prop in obj) {
+ if (hasProp(obj, prop)) {
+ if (func(obj[prop], prop)) {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Simple function to mix in properties from source into target,
+ * but only if target does not already have a property of the same name.
+ */
+ function mixin(target, source, force, deepStringMixin) {
+ if (source) {
+ eachProp(source, function (value, prop) {
+ if (force || !hasProp(target, prop)) {
+ if (deepStringMixin && typeof value !== 'string') {
+ if (!target[prop]) {
+ target[prop] = {};
+ }
+ mixin(target[prop], value, force, deepStringMixin);
+ } else {
+ target[prop] = value;
+ }
+ }
+ });
+ }
+ return target;
+ }
+
+ //Similar to Function.prototype.bind, but the 'this' object is specified
+ //first, since it is easier to read/figure out what 'this' will be.
+ function bind(obj, fn) {
+ return function () {
+ return fn.apply(obj, arguments);
+ };
+ }
+
+ function scripts() {
+ return document.getElementsByTagName('script');
+ }
+
+ function defaultOnError(err) {
+ throw err;
+ }
+
+ //Allow getting a global that expressed in
+ //dot notation, like 'a.b.c'.
+ function getGlobal(value) {
+ if (!value) {
+ return value;
+ }
+ var g = global;
+ each(value.split('.'), function (part) {
+ g = g[part];
+ });
+ return g;
+ }
+
+ /**
+ * Constructs an error with a pointer to an URL with more information.
+ * @param {String} id the error ID that maps to an ID on a web page.
+ * @param {String} message human readable error.
+ * @param {Error} [err] the original error, if there is one.
+ *
+ * @returns {Error}
+ */
+ function makeError(id, msg, err, requireModules) {
+ var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
+ e.requireType = id;
+ e.requireModules = requireModules;
+ if (err) {
+ e.originalError = err;
+ }
+ return e;
+ }
+
+ if (typeof define !== 'undefined') {
+ //If a define is already in play via another AMD loader,
+ //do not overwrite.
+ return;
+ }
+
+ if (typeof requirejs !== 'undefined') {
+ if (isFunction(requirejs)) {
+ //Do not overwrite and existing requirejs instance.
+ return;
+ }
+ cfg = requirejs;
+ requirejs = undefined;
+ }
+
+ //Allow for a require config object
+ if (typeof require !== 'undefined' && !isFunction(require)) {
+ //assume it is a config object.
+ cfg = require;
+ require = undefined;
+ }
+
+ function newContext(contextName) {
+ var inCheckLoaded, Module, context, handlers,
+ checkLoadedTimeoutId,
+ config = {
+ //Defaults. Do not set a default for map
+ //config to speed up normalize(), which
+ //will run faster if there is no default.
+ waitSeconds: 7,
+ baseUrl: './',
+ paths: {},
+ pkgs: {},
+ shim: {},
+ config: {}
+ },
+ registry = {},
+ //registry of just enabled modules, to speed
+ //cycle breaking code when lots of modules
+ //are registered, but not activated.
+ enabledRegistry = {},
+ undefEvents = {},
+ defQueue = [],
+ defined = {},
+ urlFetched = {},
+ requireCounter = 1,
+ unnormalizedCounter = 1;
+
+ /**
+ * Trims the . and .. from an array of path segments.
+ * It will keep a leading path segment if a .. will become
+ * the first path segment, to help with module name lookups,
+ * which act like paths, but can be remapped. But the end result,
+ * all paths that use this function should look normalized.
+ * NOTE: this method MODIFIES the input array.
+ * @param {Array} ary the array of path segments.
+ */
+ function trimDots(ary) {
+ var i, part;
+ for (i = 0; ary[i]; i += 1) {
+ part = ary[i];
+ if (part === '.') {
+ ary.splice(i, 1);
+ i -= 1;
+ } else if (part === '..') {
+ if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
+ //End of the line. Keep at least one non-dot
+ //path segment at the front so it can be mapped
+ //correctly to disk. Otherwise, there is likely
+ //no path mapping for a path starting with '..'.
+ //This can still fail, but catches the most reasonable
+ //uses of ..
+ break;
+ } else if (i > 0) {
+ ary.splice(i - 1, 2);
+ i -= 2;
+ }
+ }
+ }
+ }
+
+ /**
+ * Given a relative module name, like ./something, normalize it to
+ * a real name that can be mapped to a path.
+ * @param {String} name the relative name
+ * @param {String} baseName a real name that the name arg is relative
+ * to.
+ * @param {Boolean} applyMap apply the map config to the value. Should
+ * only be done if this normalization is for a dependency ID.
+ * @returns {String} normalized name
+ */
+ function normalize(name, baseName, applyMap) {
+ var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
+ foundMap, foundI, foundStarMap, starI,
+ baseParts = baseName && baseName.split('/'),
+ normalizedBaseParts = baseParts,
+ map = config.map,
+ starMap = map && map['*'];
+
+ //Adjust any relative paths.
+ if (name && name.charAt(0) === '.') {
+ //If have a base name, try to normalize against it,
+ //otherwise, assume it is a top-level require that will
+ //be relative to baseUrl in the end.
+ if (baseName) {
+ if (getOwn(config.pkgs, baseName)) {
+ //If the baseName is a package name, then just treat it as one
+ //name to concat the name with.
+ normalizedBaseParts = baseParts = [baseName];
+ } else {
+ //Convert baseName to array, and lop off the last part,
+ //so that . matches that 'directory' and not name of the baseName's
+ //module. For instance, baseName of 'one/two/three', maps to
+ //'one/two/three.js', but we want the directory, 'one/two' for
+ //this normalization.
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
+ }
+
+ name = normalizedBaseParts.concat(name.split('/'));
+ trimDots(name);
+
+ //Some use of packages may use a . path to reference the
+ //'main' module name, so normalize for that.
+ pkgConfig = getOwn(config.pkgs, (pkgName = name[0]));
+ name = name.join('/');
+ if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
+ name = pkgName;
+ }
+ } else if (name.indexOf('./') === 0) {
+ // No baseName, so this is ID is resolved relative
+ // to baseUrl, pull off the leading dot.
+ name = name.substring(2);
+ }
+ }
+
+ //Apply map config if available.
+ if (applyMap && map && (baseParts || starMap)) {
+ nameParts = name.split('/');
+
+ for (i = nameParts.length; i > 0; i -= 1) {
+ nameSegment = nameParts.slice(0, i).join('/');
+
+ if (baseParts) {
+ //Find the longest baseName segment match in the config.
+ //So, do joins on the biggest to smallest lengths of baseParts.
+ for (j = baseParts.length; j > 0; j -= 1) {
+ mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
+
+ //baseName segment has config, find if it has one for
+ //this name.
+ if (mapValue) {
+ mapValue = getOwn(mapValue, nameSegment);
+ if (mapValue) {
+ //Match, update name to the new value.
+ foundMap = mapValue;
+ foundI = i;
+ break;
+ }
+ }
+ }
+ }
+
+ if (foundMap) {
+ break;
+ }
+
+ //Check for a star map match, but just hold on to it,
+ //if there is a shorter segment match later in a matching
+ //config, then favor over this star map.
+ if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
+ foundStarMap = getOwn(starMap, nameSegment);
+ starI = i;
+ }
+ }
+
+ if (!foundMap && foundStarMap) {
+ foundMap = foundStarMap;
+ foundI = starI;
+ }
+
+ if (foundMap) {
+ nameParts.splice(0, foundI, foundMap);
+ name = nameParts.join('/');
+ }
+ }
+
+ return name;
+ }
+
+ function removeScript(name) {
+ if (isBrowser) {
+ each(scripts(), function (scriptNode) {
+ if (scriptNode.getAttribute('data-requiremodule') === name &&
+ scriptNode.getAttribute('data-requirecontext') === context.contextName) {
+ scriptNode.parentNode.removeChild(scriptNode);
+ return true;
+ }
+ });
+ }
+ }
+
+ function hasPathFallback(id) {
+ var pathConfig = getOwn(config.paths, id);
+ if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
+ //Pop off the first array value, since it failed, and
+ //retry
+ pathConfig.shift();
+ context.require.undef(id);
+ context.require([id]);
+ return true;
+ }
+ }
+
+ //Turns a plugin!resource to [plugin, resource]
+ //with the plugin being undefined if the name
+ //did not have a plugin prefix.
+ function splitPrefix(name) {
+ var prefix,
+ index = name ? name.indexOf('!') : -1;
+ if (index > -1) {
+ prefix = name.substring(0, index);
+ name = name.substring(index + 1, name.length);
+ }
+ return [prefix, name];
+ }
+
+ /**
+ * Creates a module mapping that includes plugin prefix, module
+ * name, and path. If parentModuleMap is provided it will
+ * also normalize the name via require.normalize()
+ *
+ * @param {String} name the module name
+ * @param {String} [parentModuleMap] parent module map
+ * for the module name, used to resolve relative names.
+ * @param {Boolean} isNormalized: is the ID already normalized.
+ * This is true if this call is done for a define() module ID.
+ * @param {Boolean} applyMap: apply the map config to the ID.
+ * Should only be true if this map is for a dependency.
+ *
+ * @returns {Object}
+ */
+ function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
+ var url, pluginModule, suffix, nameParts,
+ prefix = null,
+ parentName = parentModuleMap ? parentModuleMap.name : null,
+ originalName = name,
+ isDefine = true,
+ normalizedName = '';
+
+ //If no name, then it means it is a require call, generate an
+ //internal name.
+ if (!name) {
+ isDefine = false;
+ name = '_@r' + (requireCounter += 1);
+ }
+
+ nameParts = splitPrefix(name);
+ prefix = nameParts[0];
+ name = nameParts[1];
+
+ if (prefix) {
+ prefix = normalize(prefix, parentName, applyMap);
+ pluginModule = getOwn(defined, prefix);
+ }
+
+ //Account for relative paths if there is a base name.
+ if (name) {
+ if (prefix) {
+ if (pluginModule && pluginModule.normalize) {
+ //Plugin is loaded, use its normalize method.
+ normalizedName = pluginModule.normalize(name, function (name) {
+ return normalize(name, parentName, applyMap);
+ });
+ } else {
+ normalizedName = normalize(name, parentName, applyMap);
+ }
+ } else {
+ //A regular module.
+ normalizedName = normalize(name, parentName, applyMap);
+
+ //Normalized name may be a plugin ID due to map config
+ //application in normalize. The map config values must
+ //already be normalized, so do not need to redo that part.
+ nameParts = splitPrefix(normalizedName);
+ prefix = nameParts[0];
+ normalizedName = nameParts[1];
+ isNormalized = true;
+
+ url = context.nameToUrl(normalizedName);
+ }
+ }
+
+ //If the id is a plugin id that cannot be determined if it needs
+ //normalization, stamp it with a unique ID so two matching relative
+ //ids that may conflict can be separate.
+ suffix = prefix && !pluginModule && !isNormalized ?
+ '_unnormalized' + (unnormalizedCounter += 1) :
+ '';
+
+ return {
+ prefix: prefix,
+ name: normalizedName,
+ parentMap: parentModuleMap,
+ unnormalized: !!suffix,
+ url: url,
+ originalName: originalName,
+ isDefine: isDefine,
+ id: (prefix ?
+ prefix + '!' + normalizedName :
+ normalizedName) + suffix
+ };
+ }
+
+ function getModule(depMap) {
+ var id = depMap.id,
+ mod = getOwn(registry, id);
+
+ if (!mod) {
+ mod = registry[id] = new context.Module(depMap);
+ }
+
+ return mod;
+ }
+
+ function on(depMap, name, fn) {
+ var id = depMap.id,
+ mod = getOwn(registry, id);
+
+ if (hasProp(defined, id) &&
+ (!mod || mod.defineEmitComplete)) {
+ if (name === 'defined') {
+ fn(defined[id]);
+ }
+ } else {
+ mod = getModule(depMap);
+ if (mod.error && name === 'error') {
+ fn(mod.error);
+ } else {
+ mod.on(name, fn);
+ }
+ }
+ }
+
+ function onError(err, errback) {
+ var ids = err.requireModules,
+ notified = false;
+
+ if (errback) {
+ errback(err);
+ } else {
+ each(ids, function (id) {
+ var mod = getOwn(registry, id);
+ if (mod) {
+ //Set error on module, so it skips timeout checks.
+ mod.error = err;
+ if (mod.events.error) {
+ notified = true;
+ mod.emit('error', err);
+ }
+ }
+ });
+
+ if (!notified) {
+ req.onError(err);
+ }
+ }
+ }
+
+ /**
+ * Internal method to transfer globalQueue items to this context's
+ * defQueue.
+ */
+ function takeGlobalQueue() {
+ //Push all the globalDefQueue items into the context's defQueue
+ if (globalDefQueue.length) {
+ //Array splice in the values since the context code has a
+ //local var ref to defQueue, so cannot just reassign the one
+ //on context.
+ apsp.apply(defQueue,
+ [defQueue.length - 1, 0].concat(globalDefQueue));
+ globalDefQueue = [];
+ }
+ }
+
+ handlers = {
+ 'require': function (mod) {
+ if (mod.require) {
+ return mod.require;
+ } else {
+ return (mod.require = context.makeRequire(mod.map));
+ }
+ },
+ 'exports': function (mod) {
+ mod.usingExports = true;
+ if (mod.map.isDefine) {
+ if (mod.exports) {
+ return mod.exports;
+ } else {
+ return (mod.exports = defined[mod.map.id] = {});
+ }
+ }
+ },
+ 'module': function (mod) {
+ if (mod.module) {
+ return mod.module;
+ } else {
+ return (mod.module = {
+ id: mod.map.id,
+ uri: mod.map.url,
+ config: function () {
+ var c,
+ pkg = getOwn(config.pkgs, mod.map.id);
+ // For packages, only support config targeted
+ // at the main module.
+ c = pkg ? getOwn(config.config, mod.map.id + '/' + pkg.main) :
+ getOwn(config.config, mod.map.id);
+ return c || {};
+ },
+ exports: defined[mod.map.id]
+ });
+ }
+ }
+ };
+
+ function cleanRegistry(id) {
+ //Clean up machinery used for waiting modules.
+ delete registry[id];
+ delete enabledRegistry[id];
+ }
+
+ function breakCycle(mod, traced, processed) {
+ var id = mod.map.id;
+
+ if (mod.error) {
+ mod.emit('error', mod.error);
+ } else {
+ traced[id] = true;
+ each(mod.depMaps, function (depMap, i) {
+ var depId = depMap.id,
+ dep = getOwn(registry, depId);
+
+ //Only force things that have not completed
+ //being defined, so still in the registry,
+ //and only if it has not been matched up
+ //in the module already.
+ if (dep && !mod.depMatched[i] && !processed[depId]) {
+ if (getOwn(traced, depId)) {
+ mod.defineDep(i, defined[depId]);
+ mod.check(); //pass false?
+ } else {
+ breakCycle(dep, traced, processed);
+ }
+ }
+ });
+ processed[id] = true;
+ }
+ }
+
+ function checkLoaded() {
+ var map, modId, err, usingPathFallback,
+ waitInterval = config.waitSeconds * 1000,
+ //It is possible to disable the wait interval by using waitSeconds of 0.
+ expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
+ noLoads = [],
+ reqCalls = [],
+ stillLoading = false,
+ needCycleCheck = true;
+
+ //Do not bother if this call was a result of a cycle break.
+ if (inCheckLoaded) {
+ return;
+ }
+
+ inCheckLoaded = true;
+
+ //Figure out the state of all the modules.
+ eachProp(enabledRegistry, function (mod) {
+ map = mod.map;
+ modId = map.id;
+
+ //Skip things that are not enabled or in error state.
+ if (!mod.enabled) {
+ return;
+ }
+
+ if (!map.isDefine) {
+ reqCalls.push(mod);
+ }
+
+ if (!mod.error) {
+ //If the module should be executed, and it has not
+ //been inited and time is up, remember it.
+ if (!mod.inited && expired) {
+ if (hasPathFallback(modId)) {
+ usingPathFallback = true;
+ stillLoading = true;
+ } else {
+ noLoads.push(modId);
+ removeScript(modId);
+ }
+ } else if (!mod.inited && mod.fetched && map.isDefine) {
+ stillLoading = true;
+ if (!map.prefix) {
+ //No reason to keep looking for unfinished
+ //loading. If the only stillLoading is a
+ //plugin resource though, keep going,
+ //because it may be that a plugin resource
+ //is waiting on a non-plugin cycle.
+ return (needCycleCheck = false);
+ }
+ }
+ }
+ });
+
+ if (expired && noLoads.length) {
+ //If wait time expired, throw error of unloaded modules.
+ err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
+ err.contextName = context.contextName;
+ return onError(err);
+ }
+
+ //Not expired, check for a cycle.
+ if (needCycleCheck) {
+ each(reqCalls, function (mod) {
+ breakCycle(mod, {}, {});
+ });
+ }
+
+ //If still waiting on loads, and the waiting load is something
+ //other than a plugin resource, or there are still outstanding
+ //scripts, then just try back later.
+ if ((!expired || usingPathFallback) && stillLoading) {
+ //Something is still waiting to load. Wait for it, but only
+ //if a timeout is not already in effect.
+ if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
+ checkLoadedTimeoutId = setTimeout(function () {
+ checkLoadedTimeoutId = 0;
+ checkLoaded();
+ }, 50);
+ }
+ }
+
+ inCheckLoaded = false;
+ }
+
+ Module = function (map) {
+ this.events = getOwn(undefEvents, map.id) || {};
+ this.map = map;
+ this.shim = getOwn(config.shim, map.id);
+ this.depExports = [];
+ this.depMaps = [];
+ this.depMatched = [];
+ this.pluginMaps = {};
+ this.depCount = 0;
+
+ /* this.exports this.factory
+ this.depMaps = [],
+ this.enabled, this.fetched
+ */
+ };
+
+ Module.prototype = {
+ init: function (depMaps, factory, errback, options) {
+ options = options || {};
+
+ //Do not do more inits if already done. Can happen if there
+ //are multiple define calls for the same module. That is not
+ //a normal, common case, but it is also not unexpected.
+ if (this.inited) {
+ return;
+ }
+
+ this.factory = factory;
+
+ if (errback) {
+ //Register for errors on this module.
+ this.on('error', errback);
+ } else if (this.events.error) {
+ //If no errback already, but there are error listeners
+ //on this module, set up an errback to pass to the deps.
+ errback = bind(this, function (err) {
+ this.emit('error', err);
+ });
+ }
+
+ //Do a copy of the dependency array, so that
+ //source inputs are not modified. For example
+ //"shim" deps are passed in here directly, and
+ //doing a direct modification of the depMaps array
+ //would affect that config.
+ this.depMaps = depMaps && depMaps.slice(0);
+
+ this.errback = errback;
+
+ //Indicate this module has be initialized
+ this.inited = true;
+
+ this.ignore = options.ignore;
+
+ //Could have option to init this module in enabled mode,
+ //or could have been previously marked as enabled. However,
+ //the dependencies are not known until init is called. So
+ //if enabled previously, now trigger dependencies as enabled.
+ if (options.enabled || this.enabled) {
+ //Enable this module and dependencies.
+ //Will call this.check()
+ this.enable();
+ } else {
+ this.check();
+ }
+ },
+
+ defineDep: function (i, depExports) {
+ //Because of cycles, defined callback for a given
+ //export can be called more than once.
+ if (!this.depMatched[i]) {
+ this.depMatched[i] = true;
+ this.depCount -= 1;
+ this.depExports[i] = depExports;
+ }
+ },
+
+ fetch: function () {
+ if (this.fetched) {
+ return;
+ }
+ this.fetched = true;
+
+ context.startTime = (new Date()).getTime();
+
+ var map = this.map;
+
+ //If the manager is for a plugin managed resource,
+ //ask the plugin to load it now.
+ if (this.shim) {
+ context.makeRequire(this.map, {
+ enableBuildCallback: true
+ })(this.shim.deps || [], bind(this, function () {
+ return map.prefix ? this.callPlugin() : this.load();
+ }));
+ } else {
+ //Regular dependency.
+ return map.prefix ? this.callPlugin() : this.load();
+ }
+ },
+
+ load: function () {
+ var url = this.map.url;
+
+ //Regular dependency.
+ if (!urlFetched[url]) {
+ urlFetched[url] = true;
+ context.load(this.map.id, url);
+ }
+ },
+
+ /**
+ * Checks if the module is ready to define itself, and if so,
+ * define it.
+ */
+ check: function () {
+ if (!this.enabled || this.enabling) {
+ return;
+ }
+
+ var err, cjsModule,
+ id = this.map.id,
+ depExports = this.depExports,
+ exports = this.exports,
+ factory = this.factory;
+
+ if (!this.inited) {
+ this.fetch();
+ } else if (this.error) {
+ this.emit('error', this.error);
+ } else if (!this.defining) {
+ //The factory could trigger another require call
+ //that would result in checking this module to
+ //define itself again. If already in the process
+ //of doing that, skip this work.
+ this.defining = true;
+
+ if (this.depCount < 1 && !this.defined) {
+ if (isFunction(factory)) {
+ //If there is an error listener, favor passing
+ //to that instead of throwing an error. However,
+ //only do it for define()'d modules. require
+ //errbacks should not be called for failures in
+ //their callbacks (#699). However if a global
+ //onError is set, use that.
+ if ((this.events.error && this.map.isDefine) ||
+ req.onError !== defaultOnError) {
+ try {
+ exports = context.execCb(id, factory, depExports, exports);
+ } catch (e) {
+ err = e;
+ }
+ } else {
+ exports = context.execCb(id, factory, depExports, exports);
+ }
+
+ if (this.map.isDefine) {
+ //If setting exports via 'module' is in play,
+ //favor that over return value and exports. After that,
+ //favor a non-undefined return value over exports use.
+ cjsModule = this.module;
+ if (cjsModule &&
+ cjsModule.exports !== undefined &&
+ //Make sure it is not already the exports value
+ cjsModule.exports !== this.exports) {
+ exports = cjsModule.exports;
+ } else if (exports === undefined && this.usingExports) {
+ //exports already set the defined value.
+ exports = this.exports;
+ }
+ }
+
+ if (err) {
+ err.requireMap = this.map;
+ err.requireModules = this.map.isDefine ? [this.map.id] : null;
+ err.requireType = this.map.isDefine ? 'define' : 'require';
+ return onError((this.error = err));
+ }
+
+ } else {
+ //Just a literal value
+ exports = factory;
+ }
+
+ this.exports = exports;
+
+ if (this.map.isDefine && !this.ignore) {
+ defined[id] = exports;
+
+ if (req.onResourceLoad) {
+ req.onResourceLoad(context, this.map, this.depMaps);
+ }
+ }
+
+ //Clean up
+ cleanRegistry(id);
+
+ this.defined = true;
+ }
+
+ //Finished the define stage. Allow calling check again
+ //to allow define notifications below in the case of a
+ //cycle.
+ this.defining = false;
+
+ if (this.defined && !this.defineEmitted) {
+ this.defineEmitted = true;
+ this.emit('defined', this.exports);
+ this.defineEmitComplete = true;
+ }
+
+ }
+ },
+
+ callPlugin: function () {
+ var map = this.map,
+ id = map.id,
+ //Map already normalized the prefix.
+ pluginMap = makeModuleMap(map.prefix);
+
+ //Mark this as a dependency for this plugin, so it
+ //can be traced for cycles.
+ this.depMaps.push(pluginMap);
+
+ on(pluginMap, 'defined', bind(this, function (plugin) {
+ var load, normalizedMap, normalizedMod,
+ name = this.map.name,
+ parentName = this.map.parentMap ? this.map.parentMap.name : null,
+ localRequire = context.makeRequire(map.parentMap, {
+ enableBuildCallback: true
+ });
+
+ //If current map is not normalized, wait for that
+ //normalized name to load instead of continuing.
+ if (this.map.unnormalized) {
+ //Normalize the ID if the plugin allows it.
+ if (plugin.normalize) {
+ name = plugin.normalize(name, function (name) {
+ return normalize(name, parentName, true);
+ }) || '';
+ }
+
+ //prefix and name should already be normalized, no need
+ //for applying map config again either.
+ normalizedMap = makeModuleMap(map.prefix + '!' + name,
+ this.map.parentMap);
+ on(normalizedMap,
+ 'defined', bind(this, function (value) {
+ this.init([], function () { return value; }, null, {
+ enabled: true,
+ ignore: true
+ });
+ }));
+
+ normalizedMod = getOwn(registry, normalizedMap.id);
+ if (normalizedMod) {
+ //Mark this as a dependency for this plugin, so it
+ //can be traced for cycles.
+ this.depMaps.push(normalizedMap);
+
+ if (this.events.error) {
+ normalizedMod.on('error', bind(this, function (err) {
+ this.emit('error', err);
+ }));
+ }
+ normalizedMod.enable();
+ }
+
+ return;
+ }
+
+ load = bind(this, function (value) {
+ this.init([], function () { return value; }, null, {
+ enabled: true
+ });
+ });
+
+ load.error = bind(this, function (err) {
+ this.inited = true;
+ this.error = err;
+ err.requireModules = [id];
+
+ //Remove temp unnormalized modules for this module,
+ //since they will never be resolved otherwise now.
+ eachProp(registry, function (mod) {
+ if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
+ cleanRegistry(mod.map.id);
+ }
+ });
+
+ onError(err);
+ });
+
+ //Allow plugins to load other code without having to know the
+ //context or how to 'complete' the load.
+ load.fromText = bind(this, function (text, textAlt) {
+ /*jslint evil: true */
+ var moduleName = map.name,
+ moduleMap = makeModuleMap(moduleName),
+ hasInteractive = useInteractive;
+
+ //As of 2.1.0, support just passing the text, to reinforce
+ //fromText only being called once per resource. Still
+ //support old style of passing moduleName but discard
+ //that moduleName in favor of the internal ref.
+ if (textAlt) {
+ text = textAlt;
+ }
+
+ //Turn off interactive script matching for IE for any define
+ //calls in the text, then turn it back on at the end.
+ if (hasInteractive) {
+ useInteractive = false;
+ }
+
+ //Prime the system by creating a module instance for
+ //it.
+ getModule(moduleMap);
+
+ //Transfer any config to this other module.
+ if (hasProp(config.config, id)) {
+ config.config[moduleName] = config.config[id];
+ }
+
+ try {
+ req.exec(text);
+ } catch (e) {
+ return onError(makeError('fromtexteval',
+ 'fromText eval for ' + id +
+ ' failed: ' + e,
+ e,
+ [id]));
+ }
+
+ if (hasInteractive) {
+ useInteractive = true;
+ }
+
+ //Mark this as a dependency for the plugin
+ //resource
+ this.depMaps.push(moduleMap);
+
+ //Support anonymous modules.
+ context.completeLoad(moduleName);
+
+ //Bind the value of that module to the value for this
+ //resource ID.
+ localRequire([moduleName], load);
+ });
+
+ //Use parentName here since the plugin's name is not reliable,
+ //could be some weird string with no path that actually wants to
+ //reference the parentName's path.
+ plugin.load(map.name, localRequire, load, config);
+ }));
+
+ context.enable(pluginMap, this);
+ this.pluginMaps[pluginMap.id] = pluginMap;
+ },
+
+ enable: function () {
+ enabledRegistry[this.map.id] = this;
+ this.enabled = true;
+
+ //Set flag mentioning that the module is enabling,
+ //so that immediate calls to the defined callbacks
+ //for dependencies do not trigger inadvertent load
+ //with the depCount still being zero.
+ this.enabling = true;
+
+ //Enable each dependency
+ each(this.depMaps, bind(this, function (depMap, i) {
+ var id, mod, handler;
+
+ if (typeof depMap === 'string') {
+ //Dependency needs to be converted to a depMap
+ //and wired up to this module.
+ depMap = makeModuleMap(depMap,
+ (this.map.isDefine ? this.map : this.map.parentMap),
+ false,
+ !this.skipMap);
+ this.depMaps[i] = depMap;
+
+ handler = getOwn(handlers, depMap.id);
+
+ if (handler) {
+ this.depExports[i] = handler(this);
+ return;
+ }
+
+ this.depCount += 1;
+
+ on(depMap, 'defined', bind(this, function (depExports) {
+ this.defineDep(i, depExports);
+ this.check();
+ }));
+
+ if (this.errback) {
+ on(depMap, 'error', bind(this, this.errback));
+ }
+ }
+
+ id = depMap.id;
+ mod = registry[id];
+
+ //Skip special modules like 'require', 'exports', 'module'
+ //Also, don't call enable if it is already enabled,
+ //important in circular dependency cases.
+ if (!hasProp(handlers, id) && mod && !mod.enabled) {
+ context.enable(depMap, this);
+ }
+ }));
+
+ //Enable each plugin that is used in
+ //a dependency
+ eachProp(this.pluginMaps, bind(this, function (pluginMap) {
+ var mod = getOwn(registry, pluginMap.id);
+ if (mod && !mod.enabled) {
+ context.enable(pluginMap, this);
+ }
+ }));
+
+ this.enabling = false;
+
+ this.check();
+ },
+
+ on: function (name, cb) {
+ var cbs = this.events[name];
+ if (!cbs) {
+ cbs = this.events[name] = [];
+ }
+ cbs.push(cb);
+ },
+
+ emit: function (name, evt) {
+ each(this.events[name], function (cb) {
+ cb(evt);
+ });
+ if (name === 'error') {
+ //Now that the error handler was triggered, remove
+ //the listeners, since this broken Module instance
+ //can stay around for a while in the registry.
+ delete this.events[name];
+ }
+ }
+ };
+
+ function callGetModule(args) {
+ //Skip modules already defined.
+ if (!hasProp(defined, args[0])) {
+ getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
+ }
+ }
+
+ function removeListener(node, func, name, ieName) {
+ //Favor detachEvent because of IE9
+ //issue, see attachEvent/addEventListener comment elsewhere
+ //in this file.
+ if (node.detachEvent && !isOpera) {
+ //Probably IE. If not it will throw an error, which will be
+ //useful to know.
+ if (ieName) {
+ node.detachEvent(ieName, func);
+ }
+ } else {
+ node.removeEventListener(name, func, false);
+ }
+ }
+
+ /**
+ * Given an event from a script node, get the requirejs info from it,
+ * and then removes the event listeners on the node.
+ * @param {Event} evt
+ * @returns {Object}
+ */
+ function getScriptData(evt) {
+ //Using currentTarget instead of target for Firefox 2.0's sake. Not
+ //all old browsers will be supported, but this one was easy enough
+ //to support and still makes sense.
+ var node = evt.currentTarget || evt.srcElement;
+
+ //Remove the listeners once here.
+ removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
+ removeListener(node, context.onScriptError, 'error');
+
+ return {
+ node: node,
+ id: node && node.getAttribute('data-requiremodule')
+ };
+ }
+
+ function intakeDefines() {
+ var args;
+
+ //Any defined modules in the global queue, intake them now.
+ takeGlobalQueue();
+
+ //Make sure any remaining defQueue items get properly processed.
+ while (defQueue.length) {
+ args = defQueue.shift();
+ if (args[0] === null) {
+ return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
+ } else {
+ //args are id, deps, factory. Should be normalized by the
+ //define() function.
+ callGetModule(args);
+ }
+ }
+ }
+
+ context = {
+ config: config,
+ contextName: contextName,
+ registry: registry,
+ defined: defined,
+ urlFetched: urlFetched,
+ defQueue: defQueue,
+ Module: Module,
+ makeModuleMap: makeModuleMap,
+ nextTick: req.nextTick,
+ onError: onError,
+
+ /**
+ * Set a configuration for the context.
+ * @param {Object} cfg config object to integrate.
+ */
+ configure: function (cfg) {
+ //Make sure the baseUrl ends in a slash.
+ if (cfg.baseUrl) {
+ if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
+ cfg.baseUrl += '/';
+ }
+ }
+
+ //Save off the paths and packages since they require special processing,
+ //they are additive.
+ var pkgs = config.pkgs,
+ shim = config.shim,
+ objs = {
+ paths: true,
+ config: true,
+ map: true
+ };
+
+ eachProp(cfg, function (value, prop) {
+ if (objs[prop]) {
+ if (prop === 'map') {
+ if (!config.map) {
+ config.map = {};
+ }
+ mixin(config[prop], value, true, true);
+ } else {
+ mixin(config[prop], value, true);
+ }
+ } else {
+ config[prop] = value;
+ }
+ });
+
+ //Merge shim
+ if (cfg.shim) {
+ eachProp(cfg.shim, function (value, id) {
+ //Normalize the structure
+ if (isArray(value)) {
+ value = {
+ deps: value
+ };
+ }
+ if ((value.exports || value.init) && !value.exportsFn) {
+ value.exportsFn = context.makeShimExports(value);
+ }
+ shim[id] = value;
+ });
+ config.shim = shim;
+ }
+
+ //Adjust packages if necessary.
+ if (cfg.packages) {
+ each(cfg.packages, function (pkgObj) {
+ var location;
+
+ pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
+ location = pkgObj.location;
+
+ //Create a brand new object on pkgs, since currentPackages can
+ //be passed in again, and config.pkgs is the internal transformed
+ //state for all package configs.
+ pkgs[pkgObj.name] = {
+ name: pkgObj.name,
+ location: location || pkgObj.name,
+ //Remove leading dot in main, so main paths are normalized,
+ //and remove any trailing .js, since different package
+ //envs have different conventions: some use a module name,
+ //some use a file name.
+ main: (pkgObj.main || 'main')
+ .replace(currDirRegExp, '')
+ .replace(jsSuffixRegExp, '')
+ };
+ });
+
+ //Done with modifications, assing packages back to context config
+ config.pkgs = pkgs;
+ }
+
+ //If there are any "waiting to execute" modules in the registry,
+ //update the maps for them, since their info, like URLs to load,
+ //may have changed.
+ eachProp(registry, function (mod, id) {
+ //If module already has init called, since it is too
+ //late to modify them, and ignore unnormalized ones
+ //since they are transient.
+ if (!mod.inited && !mod.map.unnormalized) {
+ mod.map = makeModuleMap(id);
+ }
+ });
+
+ //If a deps array or a config callback is specified, then call
+ //require with those args. This is useful when require is defined as a
+ //config object before require.js is loaded.
+ if (cfg.deps || cfg.callback) {
+ context.require(cfg.deps || [], cfg.callback);
+ }
+ },
+
+ makeShimExports: function (value) {
+ function fn() {
+ var ret;
+ if (value.init) {
+ ret = value.init.apply(global, arguments);
+ }
+ return ret || (value.exports && getGlobal(value.exports));
+ }
+ return fn;
+ },
+
+ makeRequire: function (relMap, options) {
+ options = options || {};
+
+ function localRequire(deps, callback, errback) {
+ var id, map, requireMod;
+
+ if (options.enableBuildCallback && callback && isFunction(callback)) {
+ callback.__requireJsBuild = true;
+ }
+
+ if (typeof deps === 'string') {
+ if (isFunction(callback)) {
+ //Invalid call
+ return onError(makeError('requireargs', 'Invalid require call'), errback);
+ }
+
+ //If require|exports|module are requested, get the
+ //value for them from the special handlers. Caveat:
+ //this only works while module is being defined.
+ if (relMap && hasProp(handlers, deps)) {
+ return handlers[deps](registry[relMap.id]);
+ }
+
+ //Synchronous access to one module. If require.get is
+ //available (as in the Node adapter), prefer that.
+ if (req.get) {
+ return req.get(context, deps, relMap, localRequire);
+ }
+
+ //Normalize module name, if it contains . or ..
+ map = makeModuleMap(deps, relMap, false, true);
+ id = map.id;
+
+ if (!hasProp(defined, id)) {
+ return onError(makeError('notloaded', 'Module name "' +
+ id +
+ '" has not been loaded yet for context: ' +
+ contextName +
+ (relMap ? '' : '. Use require([])')));
+ }
+ return defined[id];
+ }
+
+ //Grab defines waiting in the global queue.
+ intakeDefines();
+
+ //Mark all the dependencies as needing to be loaded.
+ context.nextTick(function () {
+ //Some defines could have been added since the
+ //require call, collect them.
+ intakeDefines();
+
+ requireMod = getModule(makeModuleMap(null, relMap));
+
+ //Store if map config should be applied to this require
+ //call for dependencies.
+ requireMod.skipMap = options.skipMap;
+
+ requireMod.init(deps, callback, errback, {
+ enabled: true
+ });
+
+ checkLoaded();
+ });
+
+ return localRequire;
+ }
+
+ mixin(localRequire, {
+ isBrowser: isBrowser,
+
+ /**
+ * Converts a module name + .extension into an URL path.
+ * *Requires* the use of a module name. It does not support using
+ * plain URLs like nameToUrl.
+ */
+ toUrl: function (moduleNamePlusExt) {
+ var ext,
+ index = moduleNamePlusExt.lastIndexOf('.'),
+ segment = moduleNamePlusExt.split('/')[0],
+ isRelative = segment === '.' || segment === '..';
+
+ //Have a file extension alias, and it is not the
+ //dots from a relative path.
+ if (index !== -1 && (!isRelative || index > 1)) {
+ ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
+ moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
+ }
+
+ return context.nameToUrl(normalize(moduleNamePlusExt,
+ relMap && relMap.id, true), ext, true);
+ },
+
+ defined: function (id) {
+ return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
+ },
+
+ specified: function (id) {
+ id = makeModuleMap(id, relMap, false, true).id;
+ return hasProp(defined, id) || hasProp(registry, id);
+ }
+ });
+
+ //Only allow undef on top level require calls
+ if (!relMap) {
+ localRequire.undef = function (id) {
+ //Bind any waiting define() calls to this context,
+ //fix for #408
+ takeGlobalQueue();
+
+ var map = makeModuleMap(id, relMap, true),
+ mod = getOwn(registry, id);
+
+ removeScript(id);
+
+ delete defined[id];
+ delete urlFetched[map.url];
+ delete undefEvents[id];
+
+ if (mod) {
+ //Hold on to listeners in case the
+ //module will be attempted to be reloaded
+ //using a different config.
+ if (mod.events.defined) {
+ undefEvents[id] = mod.events;
+ }
+
+ cleanRegistry(id);
+ }
+ };
+ }
+
+ return localRequire;
+ },
+
+ /**
+ * Called to enable a module if it is still in the registry
+ * awaiting enablement. A second arg, parent, the parent module,
+ * is passed in for context, when this method is overriden by
+ * the optimizer. Not shown here to keep code compact.
+ */
+ enable: function (depMap) {
+ var mod = getOwn(registry, depMap.id);
+ if (mod) {
+ getModule(depMap).enable();
+ }
+ },
+
+ /**
+ * Internal method used by environment adapters to complete a load event.
+ * A load event could be a script load or just a load pass from a synchronous
+ * load call.
+ * @param {String} moduleName the name of the module to potentially complete.
+ */
+ completeLoad: function (moduleName) {
+ var found, args, mod,
+ shim = getOwn(config.shim, moduleName) || {},
+ shExports = shim.exports;
+
+ takeGlobalQueue();
+
+ while (defQueue.length) {
+ args = defQueue.shift();
+ if (args[0] === null) {
+ args[0] = moduleName;
+ //If already found an anonymous module and bound it
+ //to this name, then this is some other anon module
+ //waiting for its completeLoad to fire.
+ if (found) {
+ break;
+ }
+ found = true;
+ } else if (args[0] === moduleName) {
+ //Found matching define call for this script!
+ found = true;
+ }
+
+ callGetModule(args);
+ }
+
+ //Do this after the cycle of callGetModule in case the result
+ //of those calls/init calls changes the registry.
+ mod = getOwn(registry, moduleName);
+
+ if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
+ if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
+ if (hasPathFallback(moduleName)) {
+ return;
+ } else {
+ return onError(makeError('nodefine',
+ 'No define call for ' + moduleName,
+ null,
+ [moduleName]));
+ }
+ } else {
+ //A script that does not call define(), so just simulate
+ //the call for it.
+ callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
+ }
+ }
+
+ checkLoaded();
+ },
+
+ /**
+ * Converts a module name to a file path. Supports cases where
+ * moduleName may actually be just an URL.
+ * Note that it **does not** call normalize on the moduleName,
+ * it is assumed to have already been normalized. This is an
+ * internal API, not a public one. Use toUrl for the public API.
+ */
+ nameToUrl: function (moduleName, ext, skipExt) {
+ var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
+ parentPath;
+
+ //If a colon is in the URL, it indicates a protocol is used and it is just
+ //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
+ //or ends with .js, then assume the user meant to use an url and not a module id.
+ //The slash is important for protocol-less URLs as well as full paths.
+ if (req.jsExtRegExp.test(moduleName)) {
+ //Just a plain path, not module name lookup, so just return it.
+ //Add extension if it is included. This is a bit wonky, only non-.js things pass
+ //an extension, this method probably needs to be reworked.
+ url = moduleName + (ext || '');
+ } else {
+ //A module that needs to be converted to a path.
+ paths = config.paths;
+ pkgs = config.pkgs;
+
+ syms = moduleName.split('/');
+ //For each module name segment, see if there is a path
+ //registered for it. Start with most specific name
+ //and work up from it.
+ for (i = syms.length; i > 0; i -= 1) {
+ parentModule = syms.slice(0, i).join('/');
+ pkg = getOwn(pkgs, parentModule);
+ parentPath = getOwn(paths, parentModule);
+ if (parentPath) {
+ //If an array, it means there are a few choices,
+ //Choose the one that is desired
+ if (isArray(parentPath)) {
+ parentPath = parentPath[0];
+ }
+ syms.splice(0, i, parentPath);
+ break;
+ } else if (pkg) {
+ //If module name is just the package name, then looking
+ //for the main module.
+ if (moduleName === pkg.name) {
+ pkgPath = pkg.location + '/' + pkg.main;
+ } else {
+ pkgPath = pkg.location;
+ }
+ syms.splice(0, i, pkgPath);
+ break;
+ }
+ }
+
+ //Join the path parts together, then figure out if baseUrl is needed.
+ url = syms.join('/');
+ url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
+ url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
+ }
+
+ return config.urlArgs ? url +
+ ((url.indexOf('?') === -1 ? '?' : '&') +
+ config.urlArgs) : url;
+ },
+