├── .npmignore ├── .gitignore ├── test └── fixtures │ ├── input │ ├── assets │ │ └── vendor │ │ │ ├── s_code.js │ │ │ ├── hammer.js │ │ │ ├── jquery.hammer.js │ │ │ └── jquery.js │ └── app │ │ ├── helper.js │ │ ├── router.js │ │ ├── views │ │ ├── maps │ │ │ └── maps.js │ │ └── user │ │ │ └── user.js │ │ ├── models │ │ ├── user │ │ │ └── user.js │ │ └── maps │ │ │ └── maps.js │ │ ├── lib │ │ └── tracking │ │ │ ├── pixel.js │ │ │ ├── custom.js │ │ │ └── omniture.js │ │ └── main.js │ └── expected │ ├── user.2a25559b93ae406914f97d940e98aa3d.js │ ├── maps.b371bd03bd498257ded2aae300de5d13.js │ ├── optional.f242c6ec7db101d485e624c441061180.js │ └── common.8c4a46cef59ebdd05e6cc94e41d7e574.js ├── .bithoundrc ├── .editorconfig ├── .travis.yml ├── LICENSE-MIT ├── .eslintrc ├── package.json ├── tasks └── multibundle-requirejs.js ├── README.md └── Gruntfile.js /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | test/ 3 | *.log 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | test/tmp 3 | *.log 4 | -------------------------------------------------------------------------------- /test/fixtures/input/assets/vendor/s_code.js: -------------------------------------------------------------------------------- 1 | var s_code='',s_objectID;function s_gi(un,pg,ss){var c='some omniture code';}; 2 | -------------------------------------------------------------------------------- /test/fixtures/input/app/helper.js: -------------------------------------------------------------------------------- 1 | define(['underscore', 'async'], function(_, async) 2 | { 3 | /* Some helper code */ 4 | }); 5 | -------------------------------------------------------------------------------- /test/fixtures/input/app/router.js: -------------------------------------------------------------------------------- 1 | define(['rendr/client/router'], function(BaseClientRouter) { 2 | 3 | // more router code 4 | 5 | }); 6 | -------------------------------------------------------------------------------- /test/fixtures/input/app/views/maps/maps.js: -------------------------------------------------------------------------------- 1 | define(['app/models/maps/maps'], function(Model) 2 | { 3 | /* Some maps view code */ 4 | }); 5 | -------------------------------------------------------------------------------- /test/fixtures/input/app/views/user/user.js: -------------------------------------------------------------------------------- 1 | define(['app/models/user/user'], function(Model) 2 | { 3 | /* Some user view code */ 4 | }); 5 | -------------------------------------------------------------------------------- /test/fixtures/input/app/models/user/user.js: -------------------------------------------------------------------------------- 1 | define(['app/lib/tracking/custom'], function(TrackingCustom) 2 | { 3 | /* Some user model code */ 4 | }); 5 | -------------------------------------------------------------------------------- /test/fixtures/input/app/models/maps/maps.js: -------------------------------------------------------------------------------- 1 | define(['app/lib/tracking/omniture'], function(TrackingOmniture) 2 | { 3 | /* Some maps model code */ 4 | }); 5 | -------------------------------------------------------------------------------- /.bithoundrc: -------------------------------------------------------------------------------- 1 | { 2 | "ignore": [ 3 | "**/node_modules/**", 4 | "**/test/fixtures/**" 5 | ], 6 | "test": [ 7 | "**/Gruntfile.js", 8 | "**/test/**" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /test/fixtures/expected/user.2a25559b93ae406914f97d940e98aa3d.js: -------------------------------------------------------------------------------- 1 | define("app/models/user/user",["app/lib/tracking/custom"],function(e){}),define("app/views/user/user",["app/models/user/user"],function(e){}),define("user",function(){}),require([""]); -------------------------------------------------------------------------------- /test/fixtures/expected/maps.b371bd03bd498257ded2aae300de5d13.js: -------------------------------------------------------------------------------- 1 | define("app/models/maps/maps",["app/lib/tracking/omniture"],function(e){}),define("app/views/maps/maps",["app/models/maps/maps"],function(e){}),define("maps",function(){}),require([""]); -------------------------------------------------------------------------------- /test/fixtures/input/app/lib/tracking/pixel.js: -------------------------------------------------------------------------------- 1 | define(['underscore'], function(_) 2 | { 3 | var pixel = { 4 | track: function() 5 | { 6 | /* some pixel tracking code */ 7 | } 8 | }; 9 | 10 | return pixel; 11 | }); 12 | -------------------------------------------------------------------------------- /test/fixtures/input/app/lib/tracking/custom.js: -------------------------------------------------------------------------------- 1 | define(['underscore'], function(_) 2 | { 3 | 4 | var custom = { 5 | track: function() 6 | { 7 | return 'some custom tracking code'; 8 | } 9 | }; 10 | 11 | return custom; 12 | }); 13 | -------------------------------------------------------------------------------- /test/fixtures/input/app/lib/tracking/omniture.js: -------------------------------------------------------------------------------- 1 | define(['underscore', 'omniture'], function(_) 2 | { 3 | 4 | var omniture = { 5 | track: function() 6 | { 7 | return 'some tracking code'; 8 | } 9 | }; 10 | 11 | return omniture; 12 | }); 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - "0.10" 5 | - "0.12" 6 | - "iojs" 7 | - "4.2" 8 | - "stable" 9 | notifications: 10 | webhooks: 11 | urls: 12 | - "https://webhooks.gitter.im/e/7c1a69342b5a192a3670" 13 | on_success: change 14 | on_failure: always 15 | on_start: false 16 | -------------------------------------------------------------------------------- /test/fixtures/input/app/main.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'require', 3 | 'underscore', 4 | 'backbone', 5 | 'rendr/shared/app', 6 | 'app/helper', 7 | 'app/models/user/user', 8 | 'app/lib/tracking/pixel' 9 | ], function (require, _, Backbone, BaseApp, Helper, UserModel, TrackingPixel) 10 | { 11 | /* Some main app code */ 12 | }); 13 | -------------------------------------------------------------------------------- /test/fixtures/expected/optional.f242c6ec7db101d485e624c441061180.js: -------------------------------------------------------------------------------- 1 | function s_gi(e,t,n){var r="some omniture code"}var s_code="",s_objectID;define("omniture",function(){}),define("app/lib/tracking/pixel",["underscore"],function(e){var t={track:function(){}};return t}),define("app/lib/tracking/omniture",["underscore","omniture"],function(e){var t={track:function(){return"some tracking code"}};return t}),define("optional",function(){}),require([""]); -------------------------------------------------------------------------------- /test/fixtures/input/assets/vendor/hammer.js: -------------------------------------------------------------------------------- 1 | /*! Hammer.JS - v1.0.6dev - 2013-11-05 2 | * http://eightmedia.github.com/hammer.js 3 | * 4 | * Copyright (c) 2013 Jorik Tangelder ; 5 | * Licensed under the MIT license */ 6 | 7 | (function(window, undefined) { 8 | 'use strict'; 9 | 10 | /** 11 | * Hammer 12 | * use this to create instances 13 | * @param {HTMLElement} element 14 | * @param {Object} options 15 | * @returns {Hammer.Instance} 16 | * @constructor 17 | */ 18 | var Hammer = function(element, options) { 19 | return new Hammer.Instance(element, options || {}); 20 | }; 21 | 22 | window.Hammer = Hammer; 23 | 24 | })(this); 25 | -------------------------------------------------------------------------------- /test/fixtures/input/assets/vendor/jquery.hammer.js: -------------------------------------------------------------------------------- 1 | /*! jQuery plugin for Hammer.JS - v1.0.0 - 2013-11-03 2 | * http://eightmedia.github.com/hammer.js 3 | * 4 | * Copyright (c) 2013 Jorik Tangelder ; 5 | * Licensed under the MIT license */ 6 | 7 | (function(window, undefined) { 8 | 'use strict'; 9 | 10 | function setup(Hammer, $) { 11 | /** 12 | * jQuery plugin 13 | * create instance of Hammer and watch for gestures, 14 | * and when called again you can change the options 15 | * @param {Object} [options={}] 16 | * @return {jQuery} 17 | */ 18 | $.fn.hammer = function(options) { 19 | return this.each(function() { 20 | var el = $(this); 21 | var inst = el.data('hammer'); 22 | // start new hammer instance 23 | if(!inst) { 24 | el.data('hammer', new Hammer(this, options || {})); 25 | } 26 | // change the options 27 | else if(inst && options) { 28 | Hammer.utils.extend(inst.options, options); 29 | } 30 | }); 31 | }; 32 | } 33 | 34 | })(this); 35 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Trulia Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /test/fixtures/input/assets/vendor/jquery.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v2.0.3 3 | * http://jquery.com/ 4 | * 5 | * Includes Sizzle.js 6 | * http://sizzlejs.com/ 7 | * 8 | * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors 9 | * Released under the MIT license 10 | * http://jquery.org/license 11 | * 12 | * Date: 2013-07-03T13:30Z 13 | */ 14 | (function( window, undefined ) { 15 | 16 | // Can't do this because several apps including ASP.NET trace 17 | // the stack via arguments.caller.callee and Firefox dies if 18 | // you try to trace through "use strict" call chains. (#13335) 19 | // Support: Firefox 18+ 20 | //"use strict"; 21 | var 22 | // A central reference to the root jQuery(document) 23 | rootjQuery, 24 | 25 | // Define a local copy of jQuery 26 | jQuery = function( selector, context ) { 27 | // The jQuery object is actually just the init constructor 'enhanced' 28 | return new jQuery.fn.init( selector, context, rootjQuery ); 29 | }; 30 | 31 | jQuery.fn = jQuery.prototype = { 32 | // The current version of jQuery being used 33 | jquery: core_version, 34 | }; 35 | 36 | window.jQuery = window.$ = jQuery; 37 | 38 | })( window ); 39 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "indent": [2, 2, {"SwitchCase": 1}], 4 | "quotes": [2, "single"], 5 | "linebreak-style": [2, "unix"], 6 | "semi": [2, "always"], 7 | "curly": [2, "multi-line"], 8 | "handle-callback-err": [2, "^err"], 9 | "valid-jsdoc": [2, { 10 | "requireReturn": false, 11 | "requireReturnDescription": false, 12 | "prefer": { 13 | "return": "returns" 14 | } 15 | }], 16 | "require-jsdoc": [2, { 17 | "require": { 18 | "FunctionDeclaration": true 19 | } 20 | }], 21 | "no-redeclare": [2, { "builtinGlobals": true }], 22 | "no-shadow": [2, { "builtinGlobals": true, "hoist": "all" }], 23 | "no-use-before-define": [2, "nofunc"], 24 | "no-shadow-restricted-names": 2, 25 | "no-extra-semi": 2, 26 | "no-unused-vars": 2, 27 | "no-undef": 2, 28 | "no-irregular-whitespace": 2, 29 | "key-spacing": 0, 30 | "strict": 0, 31 | "dot-notation": 0, 32 | "eol-last": 0, 33 | "no-new": 0, 34 | "semi-spacing": 0, 35 | "no-multi-spaces": 0, 36 | "eqeqeq": 0, 37 | "no-mixed-requires": 0, 38 | "no-console": 0 39 | }, 40 | "env": { 41 | "node": true 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-multibundle-requirejs", 3 | "version": "4.0.0", 4 | "description": "Grunt task for handling multi-bundle requirejs setup", 5 | "main": "tasks/multibundle-requirejs.js", 6 | "scripts": { 7 | "test": "grunt test", 8 | "lint": "grunt lint" 9 | }, 10 | "pre-commit": [ 11 | "lint", 12 | "test" 13 | ], 14 | "repository": { 15 | "type": "git", 16 | "url": "git@github.com:trulia/grunt-multibundle-requirejs.git" 17 | }, 18 | "dependencies": { 19 | "multibundle": "^2.0.0" 20 | }, 21 | "devDependencies": { 22 | "async": "^1.5.2", 23 | "backbone": "1.2.3", 24 | "deeply": "^1.0.0", 25 | "eslint": "^1.10.3", 26 | "grunt-cli": "^0.1.13", 27 | "grunt-contrib-clean": "^0.7.0", 28 | "grunt-eslint": "^17.3.1", 29 | "grunt-file-compare": "^1.0.5", 30 | "lodash": "^4.2.0", 31 | "pre-commit": "^1.1.2", 32 | "rendr": "1.1.3", 33 | "requirejs": "^2.1.22" 34 | }, 35 | "keywords": [ 36 | "gruntplugin", 37 | "bundle", 38 | "bundles", 39 | "multiple", 40 | "multi-bundle", 41 | "requirejs" 42 | ], 43 | "author": { 44 | "name": "Alex Ivashchenko", 45 | "email": "alexi@trulia.com" 46 | }, 47 | "license": "MIT" 48 | } 49 | -------------------------------------------------------------------------------- /tasks/multibundle-requirejs.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-multibundle-requirejs 3 | * Grunt task for handling multi-bundle requirejs setup. 4 | * 5 | * Copyright (c) 2015 Trulia Inc. 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | var path = require('path') 10 | , multibundle = require('multibundle') 11 | ; 12 | 13 | // Public API 14 | module.exports = function(grunt) 15 | { 16 | grunt.registerTask( 17 | 'multibundle-requirejs', 18 | 'Grunt task for handling multibundle requirejs setup', 19 | function() 20 | { 21 | var done = this.async() 22 | , options = this.options() 23 | , config = options['_config'] 24 | , bundler 25 | , mapper 26 | ; 27 | 28 | // keep in options components only 29 | delete options['_config']; 30 | 31 | // make sure destination dir exists 32 | grunt.file.mkdir(path.join(config.baseUrl, config.destination)); 33 | 34 | // build (+ optimize) 35 | bundler = multibundle(config, options); 36 | 37 | // should be a function that returns 38 | // mapper instance (receiving function or writable stream) 39 | // Note: it needs to be wrapper into a function 40 | // to prevent grunt messing up with the object's state 41 | if (typeof config.handleMapping == 'function') 42 | { 43 | // options and grunt instance being passed to allow 44 | // for more flexible configuration in the options 45 | // last passed callback to invoke when mapping finished 46 | mapper = config.handleMapping.call(this, options, grunt, done); 47 | 48 | if (typeof mapper == 'function') 49 | { 50 | bundler.on('data', mapper); 51 | bundler.on('end', mapper); 52 | } 53 | else 54 | { 55 | bundler.pipe(mapper); 56 | } 57 | } 58 | // no mapping handler finish 59 | // after all files built 60 | else 61 | { 62 | bundler.on('end', function() 63 | { 64 | done(true); 65 | }); 66 | } 67 | 68 | bundler.on('error', function(error) 69 | { 70 | if (error) grunt.log.error('Could not process some bundles', error); 71 | done(false); 72 | }); 73 | } 74 | ); 75 | }; 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grunt-multibundle-requirejs 2 | 3 | > Grunt task for handling multi-bundle requirejs setup 4 | 5 | [![Build Status](https://img.shields.io/travis/trulia/grunt-multibundle-requirejs.svg)](https://travis-ci.org/trulia/grunt-multibundle-requirejs) 6 | [![bitHound Overall Score](https://www.bithound.io/github/trulia/grunt-multibundle-requirejs/badges/score.svg)](https://www.bithound.io/github/trulia/grunt-multibundle-requirejs) 7 | [![Join the chat at https://gitter.im/trulia/grunt-multibundle-requirejs](http://form-data.github.io/images/gitterbadge.svg)](https://gitter.im/trulia/grunt-multibundle-requirejs) 8 | 9 | ## Getting Started 10 | This plugin requires Grunt `^0.4.5` 11 | 12 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: 13 | 14 | ```shell 15 | npm install grunt-multibundle-requirejs --save-dev 16 | ``` 17 | 18 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 19 | 20 | ```js 21 | grunt.loadNpmTasks('grunt-multibundle-requirejs'); 22 | ``` 23 | 24 | ## The "multibundle_requirejs" task 25 | 26 | ### Overview 27 | In your project's Gruntfile, add a section named `multibundle_requirejs` to the data object passed into `grunt.initConfig()`. 28 | 29 | ```js 30 | grunt.initConfig({ 31 | 'multibundle-requirejs': { 32 | options: { 33 | _config: { 34 | // task "global" options 35 | }, 36 | 37 | bundle_one: [ 38 | // bundle specific config go here 39 | ], 40 | 41 | bundle_two: [ 42 | // bundle specific config go here 43 | ] 44 | } 45 | }, 46 | }); 47 | ``` 48 | 49 | ### Options 50 | 51 | Example file with all the options could be found here [Gruntfile.js](Gruntfile.js). 52 | 53 | #### options._config 54 | Type: `Object` 55 | 56 | "Global" config object for the task 57 | 58 | #### options.[bundle_name] 59 | Type: `Array` 60 | 61 | List of modules to bundle into [bundle_name]. 62 | 63 | ### _config object 64 | 65 | #### _config.logLevel 66 | Type: `Number` 67 | Default value: `1` 68 | 69 | Controls log level of the task and requirejs bundler, `4` being silent. 70 | 71 | #### _config.destination 72 | Type: `String` 73 | Default value: `undefined` 74 | 75 | Output folder for the bundles. 76 | 77 | #### _config.sharedBundles 78 | Type: `Array` 79 | Default value: `undefined` 80 | 81 | Defines list of the shared bundles (order matters), all the modules included in the shared bundles, 82 | will be excluded from other modules. 83 | 84 | #### _config.hashFiles 85 | Type: `Boolean|Function` 86 | Default value: `undefined` 87 | 88 | If enabled adds md5 hash (over bundle's content) to the bundle's filename. 89 | Could be a function (`hashFiles(output, componentOptions)`), then it will be responsible for producing content hash. 90 | 91 | #### _config.handleMapping 92 | Type: `Function` 93 | 94 | Accepts two arguments `options` - options object passed to the grunt task, 95 | and `grunt` - grunt instance itself. 96 | 97 | Expected to return mapper instance, either `WriteStream` or a function, 98 | that will be called after each bundle creation with respective `buildObject`, 99 | to allow modules-bundle mapping. Will be called one extra time with no arguments 100 | after all the bundles processed. In case of WriteStream, bundler's ReadStream will piped into it. 101 | For example of the mapping write stream, see [multibundle-mapper](https://www.npmjs.com/package/multibundle-mapper). 102 | 103 | #### _config.baseUrl 104 | Type: `String` 105 | Default value: `undefined` 106 | 107 | The root path to use for all module lookups. Passed to r.js. Also used as destination if `_config.destination` is omitted. 108 | 109 | #### _config.optimize 110 | Type: `String` 111 | Default value: `none` 112 | 113 | Minifier option, passed to r.js. 114 | 115 | #### _config.paths 116 | Type: `Object` 117 | Default value: `undefined` 118 | 119 | Path mappings for module names not found directly under baseUrl. Passed to r.js. 120 | 121 | #### _config.preserveLicenseComments 122 | Type: `Boolean` 123 | Default value: `false` 124 | 125 | Controls preseces of the license comments in the minified files. Passed to r.js. 126 | 127 | ### [bundle] list 128 | 129 | #### [bundle].[filepath] 130 | Type: `String` 131 | Example: `'app/lib/my_module.js'` 132 | 133 | Adds specified file to the parent bundle. 134 | 135 | #### [bundle].[glob_mask] 136 | Type: `String` 137 | Example: `'app/lib/**/*.js'` 138 | 139 | Adds all the files matched the pattern to the parent bundle. 140 | 141 | #### [bundle].[simple_object] 142 | Type: `Object` 143 | Example: `{'main': 'assets/js/public/main'}` 144 | 145 | Adds named module from specified filepath to the parent bundle. 146 | 147 | #### [bundle].[feature_object] 148 | Type: `Object` 149 | Example: `{'backbone': {src: 'node_modules/backbone/backbone.js', deps: ['jquery', 'underscore'], exports: 'Backbone', insertRequire: true}}` 150 | 151 | Adds named module from specified source to the parent bundle, with explicitly set dependencies. 152 | and creates shim to make it AMD-compatible by exporting global object. Also adds require call to execute module in-place. 153 | 154 | ## Contributing 155 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code before committing. 156 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var expectedBundles = 4; 3 | 4 | /** 5 | * Tests provided build object 6 | * against list of expected bundles 7 | * 8 | * @param {object} options - config object for the task 9 | * @param {function} cb - callback function 10 | * @param {object} buildObject - generated options object for r.js 11 | * @returns {void} 12 | */ 13 | function testBuild(options, cb, buildObject) 14 | { 15 | // pretending writing to a file 16 | setTimeout(function() 17 | { 18 | // it will be invoked for each bundle with respective buildObject 19 | if (buildObject) 20 | { 21 | assert(buildObject.name in options); 22 | expectedBundles--; 23 | } 24 | // and without arguments after all bundles have been processed 25 | else 26 | { 27 | assert.strictEqual(0, expectedBundles); 28 | cb(); 29 | } 30 | }, 10); 31 | } 32 | 33 | module.exports = function(grunt) 34 | { 35 | // Project configuration. 36 | grunt.initConfig({ 37 | 38 | 'eslint': 39 | { 40 | options: 41 | { 42 | configFile: '.eslintrc' 43 | }, 44 | target: ['tasks/multibundle-requirejs.js', 'Gruntfile.js'] 45 | }, 46 | 47 | 'clean': 48 | { 49 | tests: ['test/tmp'] 50 | }, 51 | 52 | 'file_compare': 53 | { 54 | check_common : ['test/fixtures/expected/common.8c4a46cef59ebdd05e6cc94e41d7e574.js', 'test/tmp/common.8c4a46cef59ebdd05e6cc94e41d7e574.js'], 55 | check_maps : ['test/fixtures/expected/maps.b371bd03bd498257ded2aae300de5d13.js', 'test/tmp/maps.b371bd03bd498257ded2aae300de5d13.js'], 56 | check_optional: ['test/fixtures/expected/optional.f242c6ec7db101d485e624c441061180.js', 'test/tmp/optional.f242c6ec7db101d485e624c441061180.js'], 57 | check_user : ['test/fixtures/expected/user.2a25559b93ae406914f97d940e98aa3d.js', 'test/tmp/user.2a25559b93ae406914f97d940e98aa3d.js'] 58 | }, 59 | 60 | // Configuration to be run (and then tested). 61 | 'multibundle-requirejs': 62 | { 63 | options: 64 | { 65 | '_config': 66 | { 67 | // 4 is silent in r.js world 68 | logLevel: process.env.quiet ? 4 : 1, 69 | destination: 'test/tmp', 70 | sharedBundles: ['optional', 'common'], 71 | // or custom function `hashFiles(output, componentOptions)` 72 | hashFiles: true, 73 | // should be a function that returns 74 | // mapper instance (receiving function or writable stream) 75 | // Note: it needs to be wrapper into a function 76 | // to prevent grunt messing up with the object's state 77 | handleMapping: function(options, gruntInstance, done) 78 | { 79 | // will be called one extra time with no arguments after all the bundles processed 80 | // also accepts writable streams in object mode, (e.g. `multibundle-mapper`) 81 | return testBuild.bind(null, options, function() 82 | { 83 | console.log('Finished all bundles.'); 84 | // grunt style callback 85 | done(true); 86 | }); 87 | }, 88 | // pass options to r.js 89 | baseUrl: '.', 90 | optimize: 'uglify', 91 | sharedPaths: 92 | { 93 | // test location namespacing 94 | 'app' : 'test/fixtures/input/app', 95 | 'assets': 'test/fixtures/input/assets', 96 | // needed for rendr modules 97 | 'rendr' : 'node_modules/rendr' 98 | }, 99 | preserveLicenseComments: false 100 | }, 101 | 102 | // optional modules 103 | 'optional': 104 | [ 105 | {'omniture' : 'assets/vendor/s_code.js'}, 106 | 107 | 'app/lib/tracking/pixel.js', 108 | 'app/lib/tracking/omniture.js' 109 | ], 110 | 111 | // Creates `/common..js` file that includes all the modules specified in the bundle, 112 | // shared modules between all the pages. 113 | 'common': 114 | [ 115 | // node modules 116 | {'requirejs' : 'node_modules/requirejs/require.js'}, 117 | 118 | // multiple entry points module 119 | {'rendr/shared' : 'node_modules/rendr/shared/app.js'}, 120 | {'rendr/client' : 'node_modules/rendr/client/router.js'}, 121 | 122 | // module that requires files directly 123 | // it needs `nodeIdCompat:true` 124 | {'deeply' : 'node_modules/deeply/index.js'}, 125 | 126 | // modules needed to be shimmed 127 | {'async' : {src: 'node_modules/async/lib/async.js', exports: 'async'}}, 128 | // module with implicit dependencies 129 | {'backbone' : {src: 'node_modules/backbone/backbone.js', deps: ['jquery', 'underscore', 'jqueryHammer'], exports: 'Backbone'}}, 130 | 131 | // replace underscore with lodash 132 | {'underscore' : {src: 'node_modules/lodash/index.js', exports: '_'}}, 133 | 134 | // checked in assets 135 | {'hammer' : 'assets/vendor/hammer.js'}, 136 | 137 | // assets needed to be shimmed 138 | {'jquery' : {src: 'assets/vendor/jquery.js', exports: 'jQuery'}}, 139 | 140 | // execute plugin to add methods to jQuery 141 | {'jqueryHammer' : {src: 'assets/vendor/jquery.hammer.js', deps: ['jquery', 'hammer'] , insertRequire: true}}, 142 | 143 | // main script 144 | {'main' : 'app/main.js'}, 145 | 146 | // app helper files 147 | 'app/helper*.js', 148 | 149 | // lib 150 | 'app/lib/**/*.js' 151 | ], 152 | 153 | // Creates separate bundle for user page components – `/user..js` 154 | 'user': 155 | [ 156 | 'app/models/user/**/*.js', 157 | 'app/views/user/**/*.js' 158 | ], 159 | 160 | // Creates separate bundle for map page components – `/maps..js` 161 | 'maps': 162 | [ 163 | 'app/models/maps/**/*.js', 164 | 'app/views/maps/**/*.js' 165 | ] 166 | } 167 | } 168 | }); 169 | 170 | // Actually load this plugin's task(s). 171 | grunt.loadTasks('tasks'); 172 | 173 | // These plugins provide necessary tasks. 174 | grunt.loadNpmTasks('grunt-eslint'); 175 | grunt.loadNpmTasks('grunt-contrib-clean'); 176 | grunt.loadNpmTasks('grunt-file-compare'); 177 | 178 | // Whenever the "test" task is run, run this plugin's task(s), 179 | // then test the result. 180 | grunt.registerTask('test', ['clean', 'multibundle-requirejs', 'file_compare']); 181 | 182 | // use eslint for linting 183 | grunt.registerTask('lint', ['eslint']); 184 | 185 | // By default, lint and run all tests. 186 | grunt.registerTask('default', ['lint', 'test']); 187 | 188 | }; 189 | -------------------------------------------------------------------------------- /test/fixtures/expected/common.8c4a46cef59ebdd05e6cc94e41d7e574.js: -------------------------------------------------------------------------------- 1 | var requirejs,require,define;(function(global){function isFunction(e){return ostring.call(e)==="[object Function]"}function isArray(e){return ostring.call(e)==="[object Array]"}function each(e,t){if(e){var n;for(n=0;n-1;n-=1)if(e[n]&&t(e[n],n,e))break}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var n;for(n in e)if(hasProp(e,n)&&t(e[n],n))break}function mixin(e,t,n,r){return t&&eachProp(t,function(t,i){if(n||!hasProp(e,i))r&&typeof t=="object"&&t&&!isArray(t)&&!isFunction(t)&&!(t instanceof RegExp)?(e[i]||(e[i]={}),mixin(e[i],t,n,r)):e[i]=t}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,n,r){var i=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return i.requireType=e,i.requireModules=r,n&&(i.originalError=n),i}function newContext(e){function m(e){var t,n;for(t=0;t0&&(e.splice(t-1,2),t-=2)}}}function g(e,t,n){var r,i,s,u,a,f,l,c,h,p,d,v,g=t&&t.split("/"),y=o.map,b=y&&y["*"];e&&(e=e.split("/"),l=e.length-1,o.nodeIdCompat&&jsSuffixRegExp.test(e[l])&&(e[l]=e[l].replace(jsSuffixRegExp,"")),e[0].charAt(0)==="."&&g&&(v=g.slice(0,g.length-1),e=v.concat(e)),m(e),e=e.join("/"));if(n&&y&&(g||b)){s=e.split("/");e:for(u=s.length;u>0;u-=1){f=s.slice(0,u).join("/");if(g)for(a=g.length;a>0;a-=1){i=getOwn(y,g.slice(0,a).join("/"));if(i){i=getOwn(i,f);if(i){c=i,h=u;break e}}}!p&&b&&getOwn(b,f)&&(p=getOwn(b,f),d=u)}!c&&p&&(c=p,h=d),c&&(s.splice(0,h,c),e=s.join("/"))}return r=getOwn(o.pkgs,e),r?r:e}function y(e){isBrowser&&each(scripts(),function(t){if(t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===r.contextName)return t.parentNode.removeChild(t),!0})}function b(e){var t=getOwn(o.paths,e);if(t&&isArray(t)&&t.length>1)return t.shift(),r.require.undef(e),r.makeRequire(null,{skipMap:!0})([e]),!0}function w(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function E(e,t,n,i){var s,o,u,a,f=null,l=t?t.name:null,h=e,p=!0,m="";return e||(p=!1,e="_@r"+(d+=1)),a=w(e),f=a[0],e=a[1],f&&(f=g(f,l,i),o=getOwn(c,f)),e&&(f?o&&o.normalize?m=o.normalize(e,function(e){return g(e,l,i)}):m=e.indexOf("!")===-1?g(e,l,i):e:(m=g(e,l,i),a=w(m),f=a[0],m=a[1],n=!0,s=r.nameToUrl(m))),u=f&&!o&&!n?"_unnormalized"+(v+=1):"",{prefix:f,name:m,parentMap:t,unnormalized:!!u,url:s,originalName:h,isDefine:p,id:(f?f+"!"+m:m)+u}}function S(e){var t=e.id,n=getOwn(u,t);return n||(n=u[t]=new r.Module(e)),n}function x(e,t,n){var r=e.id,i=getOwn(u,r);hasProp(c,r)&&(!i||i.defineEmitComplete)?t==="defined"&&n(c[r]):(i=S(e),i.error&&t==="error"?n(i.error):i.on(t,n))}function T(e,t){var n=e.requireModules,r=!1;t?t(e):(each(n,function(t){var n=getOwn(u,t);n&&(n.error=e,n.events.error&&(r=!0,n.emit("error",e)))}),r||req.onError(e))}function N(){globalDefQueue.length&&(each(globalDefQueue,function(e){var t=e[0];typeof t=="string"&&(r.defQueueMap[t]=!0),l.push(e)}),globalDefQueue=[])}function C(e){delete u[e],delete a[e]}function k(e,t,n){var r=e.map.id;e.error?e.emit("error",e.error):(t[r]=!0,each(e.depMaps,function(r,i){var s=r.id,o=getOwn(u,s);o&&!e.depMatched[i]&&!n[s]&&(getOwn(t,s)?(e.defineDep(i,c[s]),e.check()):k(o,t,n))}),n[r]=!0)}function L(){var e,n,i=o.waitSeconds*1e3,u=i&&r.startTime+i<(new Date).getTime(),f=[],l=[],c=!1,h=!0;if(t)return;t=!0,eachProp(a,function(e){var t=e.map,r=t.id;if(!e.enabled)return;t.isDefine||l.push(e);if(!e.error)if(!e.inited&&u)b(r)?(n=!0,c=!0):(f.push(r),y(r));else if(!e.inited&&e.fetched&&t.isDefine){c=!0;if(!t.prefix)return h=!1}});if(u&&f.length)return e=makeError("timeout","Load timeout for modules: "+f,null,f),e.contextName=r.contextName,T(e);h&&each(l,function(e){k(e,{},{})}),(!u||n)&&c&&(isBrowser||isWebWorker)&&!s&&(s=setTimeout(function(){s=0,L()},50)),t=!1}function A(e){hasProp(c,e[0])||S(E(e[0],null,!0)).init(e[1],e[2])}function O(e,t,n,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(n,t,!1)}function M(e){var t=e.currentTarget||e.srcElement;return O(t,r.onScriptLoad,"load","onreadystatechange"),O(t,r.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function _(){var e;N();while(l.length){e=l.shift();if(e[0]===null)return T(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));A(e)}r.defQueueMap={}}var t,n,r,i,s,o={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},u={},a={},f={},l=[],c={},h={},p={},d=1,v=1;return i={require:function(e){return e.require?e.require:e.require=r.makeRequire(e.map)},exports:function(e){e.usingExports=!0;if(e.map.isDefine)return e.exports?c[e.map.id]=e.exports:e.exports=c[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return getOwn(o.config,e.map.id)||{}},exports:e.exports||(e.exports={})}}},n=function(e){this.events=getOwn(f,e.id)||{},this.map=e,this.shim=getOwn(o.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},n.prototype={init:function(e,t,n,r){r=r||{};if(this.inited)return;this.factory=t,n?this.on("error",n):this.events.error&&(n=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=n,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check()},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(this.fetched)return;this.fetched=!0,r.startTime=(new Date).getTime();var e=this.map;if(!this.shim)return e.prefix?this.callPlugin():this.load();r.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()}))},load:function(){var e=this.map.url;h[e]||(h[e]=!0,r.load(this.map.id,e))},check:function(){if(!this.enabled||this.enabling)return;var e,t,n=this.map.id,i=this.depExports,s=this.exports,o=this.factory;if(!this.inited)hasProp(r.defQueueMap,n)||this.fetch();else if(this.error)this.emit("error",this.error);else if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(isFunction(o)){try{s=r.execCb(n,o,i,s)}catch(u){e=u}this.map.isDefine&&s===undefined&&(t=this.module,t?s=t.exports:this.usingExports&&(s=this.exports));if(e){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)return e.requireMap=this.map,e.requireModules=this.map.isDefine?[this.map.id]:null,e.requireType=this.map.isDefine?"define":"require",T(this.error=e);typeof console!="undefined"&&console.error?console.error(e):req.onError(e)}}else s=o;this.exports=s;if(this.map.isDefine&&!this.ignore){c[n]=s;if(req.onResourceLoad){var a=[];each(this.depMaps,function(e){a.push(e.normalizedMap||e)}),req.onResourceLoad(r,this.map,a)}}C(n),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}},callPlugin:function(){var e=this.map,t=e.id,n=E(e.prefix);this.depMaps.push(n),x(n,"defined",bind(this,function(n){var i,s,a,f=getOwn(p,this.map.id),l=this.map.name,c=this.map.parentMap?this.map.parentMap.name:null,h=r.makeRequire(e.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){n.normalize&&(l=n.normalize(l,function(e){return g(e,c,!0)})||""),s=E(e.prefix+"!"+l,this.map.parentMap),x(s,"defined",bind(this,function(e){this.map.normalizedMap=s,this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),a=getOwn(u,s.id),a&&(this.depMaps.push(s),this.events.error&&a.on("error",bind(this,function(e){this.emit("error",e)})),a.enable());return}if(f){this.map.url=r.nameToUrl(f),this.load();return}i=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})}),i.error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(u,function(e){e.map.id.indexOf(t+"_unnormalized")===0&&C(e.map.id)}),T(e)}),i.fromText=bind(this,function(n,s){var u=e.name,a=E(u),f=useInteractive;s&&(n=s),f&&(useInteractive=!1),S(a),hasProp(o.config,t)&&(o.config[u]=o.config[t]);try{req.exec(n)}catch(l){return T(makeError("fromtexteval","fromText eval for "+t+" failed: "+l,l,[t]))}f&&(useInteractive=!0),this.depMaps.push(a),r.completeLoad(u),h([u],i)}),n.load(e.name,h,i,o)})),r.enable(n,this),this.pluginMaps[n.id]=n},enable:function(){a[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var n,s,o;if(typeof e=="string"){e=E(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,o=getOwn(i,e.id);if(o){this.depExports[t]=o(this);return}this.depCount+=1,x(e,"defined",bind(this,function(e){if(this.undefed)return;this.defineDep(t,e),this.check()})),this.errback?x(e,"error",bind(this,this.errback)):this.events.error&&x(e,"error",bind(this,function(e){this.emit("error",e)}))}n=e.id,s=u[n],!hasProp(i,n)&&s&&!s.enabled&&r.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(u,e.id);t&&!t.enabled&&r.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var n=this.events[e];n||(n=this.events[e]=[]),n.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),e==="error"&&delete this.events[e]}},r={config:o,contextName:e,registry:u,defined:c,urlFetched:h,defQueue:l,defQueueMap:{},Module:n,makeModuleMap:E,nextTick:req.nextTick,onError:T,configure:function(e){e.baseUrl&&e.baseUrl.charAt(e.baseUrl.length-1)!=="/"&&(e.baseUrl+="/");var t=o.shim,n={paths:!0,bundles:!0,config:!0,map:!0};eachProp(e,function(e,t){n[t]?(o[t]||(o[t]={}),mixin(o[t],e,!0,!0)):o[t]=e}),e.bundles&&eachProp(e.bundles,function(e,t){each(e,function(e){e!==t&&(p[e]=t)})}),e.shim&&(eachProp(e.shim,function(e,n){isArray(e)&&(e={deps:e}),(e.exports||e.init)&&!e.exportsFn&&(e.exportsFn=r.makeShimExports(e)),t[n]=e}),o.shim=t),e.packages&&each(e.packages,function(e){var t,n;e=typeof e=="string"?{name:e}:e,n=e.name,t=e.location,t&&(o.paths[n]=e.location),o.pkgs[n]=e.name+"/"+(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(u,function(e,t){!e.inited&&!e.map.unnormalized&&(e.map=E(t,null,!0))}),(e.deps||e.callback)&&r.require(e.deps||[],e.callback)},makeShimExports:function(e){function t(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}return t},makeRequire:function(t,n){function s(o,a,f){var l,h,p;return n.enableBuildCallback&&a&&isFunction(a)&&(a.__requireJsBuild=!0),typeof o=="string"?isFunction(a)?T(makeError("requireargs","Invalid require call"),f):t&&hasProp(i,o)?i[o](u[t.id]):req.get?req.get(r,o,t,s):(h=E(o,t,!1,!0),l=h.id,hasProp(c,l)?c[l]:T(makeError("notloaded",'Module name "'+l+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(_(),r.nextTick(function(){_(),p=S(E(null,t)),p.skipMap=n.skipMap,p.init(o,a,f,{enabled:!0}),L()}),s)}return n=n||{},mixin(s,{isBrowser:isBrowser,toUrl:function(e){var n,i=e.lastIndexOf("."),s=e.split("/")[0],o=s==="."||s==="..";return i!==-1&&(!o||i>1)&&(n=e.substring(i,e.length),e=e.substring(0,i)),r.nameToUrl(g(e,t&&t.id,!0),n,!0)},defined:function(e){return hasProp(c,E(e,t,!1,!0).id)},specified:function(e){return e=E(e,t,!1,!0).id,hasProp(c,e)||hasProp(u,e)}}),t||(s.undef=function(e){N();var n=E(e,t,!0),i=getOwn(u,e);i.undefed=!0,y(e),delete c[e],delete h[n.url],delete f[e],eachReverse(l,function(t,n){t[0]===e&&l.splice(n,1)}),delete r.defQueueMap[e],i&&(i.events.defined&&(f[e]=i.events),C(e))}),s},enable:function(e){var t=getOwn(u,e.id);t&&S(e).enable()},completeLoad:function(e){var t,n,i,s=getOwn(o.shim,e)||{},a=s.exports;N();while(l.length){n=l.shift();if(n[0]===null){n[0]=e;if(t)break;t=!0}else n[0]===e&&(t=!0);A(n)}r.defQueueMap={},i=getOwn(u,e);if(!t&&!hasProp(c,e)&&i&&!i.inited){if(o.enforceDefine&&(!a||!getGlobal(a))){if(b(e))return;return T(makeError("nodefine","No define call for "+e,null,[e]))}A([e,s.deps||[],s.exportsFn])}L()},nameToUrl:function(e,t,n){var i,s,u,a,f,l,c,h=getOwn(o.pkgs,e);h&&(e=h),c=getOwn(p,e);if(c)return r.nameToUrl(c,t,n);if(req.jsExtRegExp.test(e))f=e+(t||"");else{i=o.paths,s=e.split("/");for(u=s.length;u>0;u-=1){a=s.slice(0,u).join("/"),l=getOwn(i,a);if(l){isArray(l)&&(l=l[0]),s.splice(0,u,l);break}}f=s.join("/"),f+=t||(/^data\:|\?/.test(f)||n?"":".js"),f=(f.charAt(0)==="/"||f.match(/^[\w\+\.\-]+:/)?"":o.baseUrl)+f}return o.urlArgs?f+((f.indexOf("?")===-1?"?":"&")+o.urlArgs):f},load:function(e,t){req.load(r,e,t)},execCb:function(e,t,n,r){return t.apply(r,n)},onScriptLoad:function(e){if(e.type==="load"||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=M(e);r.completeLoad(t.id)}},onScriptError:function(e){var t=M(e);if(!b(t.id)){var n=[];return eachProp(u,function(e,r){r.indexOf("_@r")!==0&&each(e.depMaps,function(e){return e.id===t.id&&n.push(r),!0})}),T(makeError("scripterror",'Script error for "'+t.id+(n.length?'", needed by: '+n.join(", "):'"'),e,[t.id]))}}},r.require=r.makeRequire(),r}function getInteractiveScript(){return interactiveScript&&interactiveScript.readyState==="interactive"?interactiveScript:(eachReverse(scripts(),function(e){if(e.readyState==="interactive")return interactiveScript=e}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.1.22",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,isBrowser=typeof window!="undefined"&&typeof navigator!="undefined"&&!!window.document,isWebWorker=!isBrowser&&typeof importScripts!="undefined",readyRegExp=isBrowser&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera=typeof opera!="undefined"&&opera.toString()==="[object Opera]",contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if(typeof define!="undefined")return;if(typeof requirejs!="undefined"){if(isFunction(requirejs))return;cfg=requirejs,requirejs=undefined}typeof require!="undefined"&&!isFunction(require)&&(cfg=require,require=undefined),req=requirejs=function(e,t,n,r){var i,s,o=defContextName;return!isArray(e)&&typeof e!="string"&&(s=e,isArray(t)?(e=t,t=n,n=r):e=[]),s&&s.context&&(o=s.context),i=getOwn(contexts,o),i||(i=contexts[o]=req.s.newContext(o)),s&&i.configure(s),i.require(e,t,n)},req.config=function(e){return req(e)},req.nextTick=typeof setTimeout!="undefined"?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,n){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,n){var r=e&&e.config||{},i;if(isBrowser)return i=req.createNode(r,t,n),r.onNodeCreated&&r.onNodeCreated(i,r,t,n),i.setAttribute("data-requirecontext",e.contextName),i.setAttribute("data-requiremodule",t),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!isOpera?(useInteractive=!0,i.attachEvent("onreadystatechange",e.onScriptLoad)):(i.addEventListener("load",e.onScriptLoad,!1),i.addEventListener("error",e.onScriptError,!1)),i.src=n,currentlyAddingScript=i,baseElement?head.insertBefore(i,baseElement):head.appendChild(i),currentlyAddingScript=null,i;if(isWebWorker)try{importScripts(n),e.completeLoad(t)}catch(s){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+n,s,[t]))}},isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){head||(head=e.parentNode),dataMain=e.getAttribute("data-main");if(dataMain)return mainScript=dataMain,cfg.baseUrl||(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,n){var r,i;typeof e!="string"&&(n=t,t=e,e=null),isArray(t)||(n=t,t=null),!t&&isFunction(n)&&(t=[],n.length&&(n.toString().replace(commentRegExp,"").replace(cjsRequireRegExp,function(e,n){t.push(n)}),t=(n.length===1?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),i=contexts[r.getAttribute("data-requirecontext")])),i?(i.defQueue.push([e,t,n]),i.defQueueMap[e]=!0):globalDefQueue.push([e,t,n])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)})(this),define("requirejs",["requirejs/require"],function(e){return e}),define("requirejs/require",function(){}),function(){function In(e,t){return e.set(t[0],t[1]),e}function qn(e,t){return e.add(t),e}function Rn(e,t,n){var r=n.length;switch(r){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Un(e,t,n,r){var i=-1,s=e.length;while(++i-1}function Kn(e,t,n){var r=-1,i=e.length;while(++r-1);return n}function pr(e,t){var n=e.length;while(n--&&ir(t,e[n],0)>-1);return n}function dr(e){return e&&e.Object===Object?e:null}function vr(t,n){if(t!==n){var r=t===null,i=t===e,s=t===t,o=n===null,u=n===e,a=n===n;if(t>n&&!o||!s||r&&!u&&a||i&&a)return 1;if(t=u)return a;var f=n[r];return a*(f=="desc"?-1:1)}}return e.index-t.index}function gr(e){return Tn[e]}function yr(e){return Nn[e]}function br(e){return"\\"+Ln[e]}function wr(e,t,n){var r=e.length,i=t+(n?0:-1);while(n?i--:++i-1&&e%1==0&&e-1}function si(e,t){var n=e.length;while(n--)if(Ja(e[n][0],t))return n;return-1}function oi(e,t,n){var r=si(e,t);r<0?e.push([t,n]):e[r][1]=n}function ui(t,n,r,i){return t===e||Ja(t,Ft[r])&&!qt.call(i,r)?n:t}function ai(t,n,r){if(r!==e&&!Ja(t[n],r)||typeof n=="number"&&r===e&&!(n in t))t[n]=r}function fi(t,n,r){var i=t[n];if(!Ja(i,r)||Ja(i,Ft[n])&&!qt.call(t,n)||r===e&&!(n in t))t[n]=r}function li(e,t,n,r){return bi(e,function(e,i,s){t(r,e,n(e),s)}),r}function ci(e,t){return e&&As(t,ol(t),e)}function hi(t,n){var r=-1,i=t==null,s=n.length,o=Array(s);while(++r=n?t:n)),t}function di(t,n,r,i,s,o){var u;r&&(u=s?r(t,i,s,o):r(t));if(u!==e)return u;if(!pf(t))return t;var a=Ya(t);if(a){u=co(t);if(!n)return Ls(t,u)}else{var f=ao(t),l=f==j||f==F;if(!(f==R||f==_||l&&!s))return xn[f]?po(t,f,n):s?t:{};if(Er(t))return s?t:{};u=ho(l?{}:t);if(!n)return Ms(t,ci(u,t))}o||(o=new Qr);var c=o.get(t);return c?c:(o.set(t,u),(a?Wn:Li)(t,function(e,i){fi(u,i,di(e,n,r,i,t,o))}),a?u:Ms(t,u))}function vi(t){var n=ol(t),r=n.length;return function(i){if(i==null)return!r;var s=r;while(s--){var o=n[s],u=t[o],a=i[o];if(a===e&&!(o in Object(i))||!u(a))return!1}return!0}}function gi(t,n,r){if(typeof t!="function")throw new Bt(S);return tn(function(){t.apply(e,r)},n)}function yi(e,t,n,r){var i=-1,s=Jn,o=!0,u=e.length,a=[],f=t.length;if(!u)return a;n&&(t=Qn(t,lr(n))),r?(s=Kn,o=!1):t.length>=y&&(s=Jr,o=!1,t=new $r(t));e:while(++is?0:s+r),i=i===e||i>s?s:_f(i),i<0&&(i+=s),i=r>i?0:Df(i);while(r=ln(t,n)&&e=120)?new $r(o&&f):e}f=t[0];var l=-1,c=f.length,h=u[0];e:while(++l-1)s!==e&&nn.call(s,o,1),nn.call(e,o,1)}return e}function ns(e,t){var n=e?t.length:0,r=n-1;while(n--){var i=t[n];if(r==n||i!=s){var s=i;if(Sr(i))nn.call(e,i,1);else if(!go(i,e)){var o=ps(i),u=To(e,o);u!=null&&delete u[eu(o)]}else delete e[i]}}return e}function rs(e,t){return e+sn(hn()*(t-e+1))}function is(e,t,n,r){var i=-1,s=fn(rn((t-e)/(n||1)),0),o=Array(s);while(s--)o[r?s:++i]=e,e+=n;return o}function ss(t,n,r,i){n=go(n,t)?[n+""]:ps(n);var s=-1,o=n.length,u=o-1,a=t;while(a!=null&&++si?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;var s=Array(i);while(++r>>1,o=e[s];(n?o<=t:o=y){var f=t?null:Qs(e);if(f)return Cr(f);o=!1,i=Jr,a=new $r}else a=t?[]:u;e:while(++r1?r[s-1]:e,u=s>2?r[2]:e;o=typeof o=="function"?(s--,o):e,u&&mo(r[0],r[1],u)&&(o=s<3?e:o,s=1),n=Object(n);while(++i=y)return c.plant(t).value();var i=0,s=r?n[i].apply(this,e):t;while(++i1&&r.reverse(),g&&v=n)return"";var s=n-i;r=r===e?" ":r+"";var o=Ul(r,rn(s/kr(r)));return mn.test(r)?Lr(o).slice(0,s).join(""):o.slice(0,s)}function Vs(e,t,r,i){function u(){var t=-1,n=arguments.length,a=-1,f=i.length,l=Array(f+n),c=this&&this!==Fn&&this instanceof u?o:e;while(++al))return!1;var d=o.get(t);if(d)return d==n;var v=!0;o.set(t,n);while(++u=this.__values__.length,n=t?e:this.__values__[this.__index__++];return{done:t,value:n}}function Vu(){return this}function $u(t){var n,r=this;while(r instanceof jn){var i=Oo(r);i.__index__=0,i.__values__=e,n?s.__wrapped__=i:n=i;var s=i;r=r.__wrapped__}return s.__wrapped__=t,n}function Ju(){var t=this.__wrapped__;if(t instanceof _r){var n=t;return this.__actions__.length&&(n=new _r(this)),n=n.reverse(),n.__actions__.push({func:qu,args:[uu],thisArg:e}),new dr(n,this.__chain__)}return this.thru(uu)}function Ku(){return gs(this.__wrapped__,this.__actions__)}function Gu(t,n,r){var i=Ya(t)?Vn:Ei;return r&&mo(t,n,r)&&(n=e),i(t,ro(n,3))}function Yu(e,t){var n=Ya(e)?$n:xi;return n(e,ro(t,3))}function Zu(t,n){n=ro(n,3);if(Ya(t)){var r=rr(t,n);return r>-1?t[r]:e}return nr(t,n,bi)}function ea(t,n){n=ro(n,3);if(Ya(t)){var r=rr(t,n,!0);return r>-1?t[r]:e}return nr(t,n,wi)}function ta(e,t){return Ti(aa(e,t))}function na(e,t){return typeof t=="function"&&Ya(e)?Wn(e,t):bi(e,Ao(t))}function ra(e,t){return typeof t=="function"&&Ya(e)?Xn(e,t):wi(e,Ao(t))}function sa(e,t,n,r){e=Za(e)?e:xl(e),n=n&&!r?_f(n):0;var i=e.length;return n<0&&(n=fn(i+n,0)),Nf(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&ir(e,t,n)>-1}function aa(e,t){var n=Ya(e)?Qn:Wi;return n(e,ro(t,3))}function fa(t,n,r,i){return t==null?[]:(Ya(n)||(n=n==null?[]:[n]),r=i?e:r,Ya(r)||(r=r==null?[]:[r]),Ki(t,n,r))}function ca(e,t,n){var r=Ya(e)?Yn:sr,i=arguments.length<3;return r(e,ro(t,4),n,i,bi)}function ha(e,t,n){var r=Ya(e)?Zn:sr,i=arguments.length<3;return r(e,ro(t,4),n,i,wi)}function pa(e,t){var n=Ya(e)?$n:xi;return t=ro(t,3),n(e,function(e,n,r){return!t(e,n,r)})}function da(t){var n=Za(t)?t:xl(t),r=n.length;return r>0?n[rs(0,r-1)]:e}function va(e,t){var n=-1,r=Mf(e),i=r.length,s=i-1;t=pi(_f(t),0,i);while(++n0&&(r=n.apply(this,arguments)),t<=1&&(n=e),r}}function Ca(t,n,r){n=r?e:n;var i=Gs(t,s,e,e,e,e,e,n);return i.placeholder=Ca.placeholder,i}function ka(t,n,r){n=r?e:n;var i=Gs(t,o,e,e,e,e,e,n);return i.placeholder=ka.placeholder,i}function La(t,n,r){function v(){f&&Kt(f),s&&Kt(s),c=0,i=s=a=f=l=e}function m(n,r){r&&Kt(r),s=f=l=e,n&&(c=wa(),o=t.apply(a,i),!f&&!s&&(i=a=e))}function g(){var e=n-(wa()-u);e<=0||e>n?m(l,s):f=tn(g,e)}function y(){if(f&&l||s&&d)o=t.apply(a,i);return v(),o}function b(){m(d,f)}function w(){i=arguments,u=wa(),a=this,l=d&&(f||!h);if(p===!1)var r=h&&!f;else{!s&&!h&&(c=u);var v=p-(u-c),m=v<=0||v>p;m?(s&&(s=Kt(s)),c=u,o=t.apply(a,i)):s||(s=tn(b,v))}return m&&f?f=Kt(f):!f&&n!==p&&(f=tn(g,n)),r&&(m=!0,o=t.apply(a,i)),m&&!f&&!s&&(i=a=e),o}var i,s,o,u,a,f,l,c=0,h=!1,p=!1,d=!0;if(typeof t!="function")throw new Bt(S);return n=Pf(n)||0,pf(r)&&(h=!!r.leading,p="maxWait"in r&&fn(Pf(r.maxWait)||0,n),d="trailing"in r?!!r.trailing:d),w.cancel=v,w.flush=y,w}function Ma(e){return Gs(e,c)}function _a(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new Bt(S);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var o=e.apply(this,r);return n.cache=s.set(i,o),o};return n.cache=new _a.Cache,n}function Da(e){if(typeof e!="function")throw new Bt(S);return function(){return!e.apply(this,arguments)}}function Pa(e){return xa(2,e)}function Ia(t,n){if(typeof t!="function")throw new Bt(S);return n=fn(n===e?t.length-1:_f(n),0),function(){var e=arguments,r=-1,i=fn(e.length-n,0),s=Array(i);while(++rt}function Qa(e,t){return e>=t}function Ga(e){return ef(e)&&qt.call(e,"callee")&&(!en.call(e,"callee")||zt.call(e)==_)}function Za(e){return e!=null&&(typeof e!="function"||!lf(e))&&hf(io(e))}function ef(e){return df(e)&&Za(e)}function tf(e){return e===!0||e===!1||df(e)&&zt.call(e)==P}function nf(e){return df(e)&&zt.call(e)==H}function rf(e){return!!e&&e.nodeType===1&&df(e)&&!Sf(e)}function sf(e){if(Za(e)&&(Ya(e)||Nf(e)||lf(e.splice)||Ga(e)))return!e.length;for(var t in e)if(qt.call(e,t))return!1;return!0}function of(e,t){return Fi(e,t)}function uf(t,n,r){r=typeof r=="function"?r:e;var i=r?r(t,n):e;return i===e?Fi(t,n,r):!!i}function af(e){return df(e)&&typeof e.message=="string"&&zt.call(e)==B}function ff(e){return typeof e=="number"&&on(e)}function lf(e){var t=pf(e)?zt.call(e):"";return t==j||t==F}function cf(e){return typeof e=="number"&&e==_f(e)}function hf(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=N}function pf(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function df(e){return!!e&&typeof e=="object"}function vf(e,t){return e===t||qi(e,t,so(t))}function mf(t,n,r){return r=typeof r=="function"?r:e,qi(t,n,so(n),r)}function gf(e){return Ef(e)&&e!=+e}function yf(e){return e==null?!1:lf(e)?Xt.test(It.call(e)):df(e)&&(Er(e)?Xt:kt).test(e)}function bf(e){return e===null}function wf(e){return e==null}function Ef(e){return typeof e=="number"||df(e)&&zt.call(e)==q}function Sf(e){if(!df(e)||zt.call(e)!=R||Er(e))return!1;var t=Ft;typeof e.constructor=="function"&&(t=Gt(e));if(t===null)return!0;var n=t.constructor;return typeof n=="function"&&n instanceof n&&It.call(n)==Ut}function xf(e){return pf(e)&&zt.call(e)==U}function Tf(e){return cf(e)&&e>=-N&&e<=N}function Nf(e){return typeof e=="string"||!Ya(e)&&df(e)&&zt.call(e)==W}function Cf(e){return typeof e=="symbol"||df(e)&&zt.call(e)==X}function kf(e){return df(e)&&hf(e.length)&&!!Sn[zt.call(e)]}function Lf(t){return t===e}function Af(e,t){return en){var i=t;t=n,n=i}if(r||t%1||n%1){var s=hn();return ln(t+s*(n-t+An("1e-"+((s+"").length-1))),n)}return rs(t,n)}function Al(e){return jl(jf(e).toLowerCase())}function Ol(e){return e=jf(e),e&&e.replace(Ot,gr).replace(dn,"")}function Ml(t,n,r){t=jf(t),n=typeof n=="string"?n:n+"";var i=t.length;return r=r===e?i:pi(_f(r),0,i),r-=n.length,r>=0&&t.indexOf(n,r)==r}function _l(e){return e=jf(e),e&&ft.test(e)?e.replace(ut,yr):e}function Dl(e){return e=jf(e),e&>.test(e)?e.replace(mt,"\\$&"):e}function Fl(e,t,n){e=jf(e),t=_f(t);var r=kr(e);if(!t||r>=t)return e;var i=(t-r)/2,s=sn(i),o=rn(i);return Xs("",s,n)+e+Xs("",o,n)}function Il(e,t,n){return e=jf(e),e+Xs(e,t,n)}function ql(e,t,n){return e=jf(e),Xs(e,t,n)+e}function Rl(e,t,n){return n||t==null?t=0:t&&(t=+t),e=jf(e).replace(yt,""),cn(e,t||(Tt.test(e)?16:10))}function Ul(e,t){e=jf(e),t=_f(t);var n="";if(!e||t<1||t>N)return n;do t%2&&(n+=e),t=sn(t/2),e+=e;while(t);return n}function zl(){var e=arguments,t=jf(e[0]);return e.length<3?t:t.replace(e[1],e[2])}function Xl(e,t,n){return jf(e).split(t,n)}function $l(e,t,n){return e=jf(e),n=pi(_f(n),0,e.length),e.lastIndexOf(t,n)==n}function Jl(t,n,r){var i=Bn.templateSettings;r&&mo(t,n,r)&&(n=e),t=jf(t),n=qf({},n,i,ui);var s=qf({},n.imports,i.imports,ui),o=ol(s),u=cr(s,o),a,f,l=0,c=n.interpolate||Mt,h="__p += '",p=Ht((n.escape||Mt).source+"|"+c.source+"|"+(c===ht?St:Mt).source+"|"+(n.evaluate||Mt).source+"|$","g"),d="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++En+"]")+"\n";t.replace(p,function(e,n,r,i,s,o){return r||(r=i),h+=t.slice(l,o).replace(_t,br),n&&(a=!0,h+="' +\n__e("+n+") +\n'"),s&&(f=!0,h+="';\n"+s+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),l=o+e.length,e}),h+="';\n";var v=n.variable;v||(h="with (obj) {\n"+h+"\n}\n"),h=(f?h.replace(rt,""):h).replace(it,"$1").replace(st,"$1;"),h="function("+(v||"obj")+") {\n"+(v?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var m=ic(function(){return Function(o,d+"return "+h).apply(e,u)});m.source=h;if(af(m))throw m;return m}function Kl(e){return jf(e).toLowerCase()}function Ql(e){return jf(e).toUpperCase()}function Gl(t,n,r){t=jf(t);if(!t)return t;if(r||n===e)return t.replace(yt,"");n+="";if(!n)return t;var i=Lr(t),s=Lr(n);return i.slice(hr(i,s),pr(i,s)+1).join("")}function Yl(t,n,r){t=jf(t);if(!t)return t;if(r||n===e)return t.replace(wt,"");n+="";if(!n)return t;var i=Lr(t);return i.slice(0,pr(i,Lr(n))+1).join("")}function Zl(t,n,r){t=jf(t);if(!t)return t;if(r||n===e)return t.replace(bt,"");n+="";if(!n)return t;var i=Lr(t);return i.slice(hr(i,Lr(n))).join("")}function ec(t,n){var r=d,i=v;if(pf(n)){var s="separator"in n?n.separator:s;r="length"in n?_f(n.length):r,i="omission"in n?jf(n.omission):i}t=jf(t);var o=t.length;if(mn.test(t)){var u=Lr(t);o=u.length}if(r>=o)return t;var a=r-kr(i);if(a<1)return i;var f=u?u.slice(0,a).join(""):t.slice(0,a);if(s===e)return f+i;u&&(a+=f.length-a);if(xf(s)){if(t.slice(a).search(s)){var l,c=f;s.global||(s=Ht(s.source,jf(xt.exec(s))+"g")),s.lastIndex=0;while(l=s.exec(c))var h=l.index;f=f.slice(0,h===e?a:h)}}else if(t.indexOf(s,a)!=a){var p=f.lastIndexOf(s);p>-1&&(f=f.slice(0,p))}return f+i}function tc(e){return e=jf(e),e&&at.test(e)?e.replace(ot,Ar):e}function rc(t,n,r){return t=jf(t),n=r?e:n,n===e&&(n=bn.test(t)?yn:gn),t.match(n)||[]}function oc(e){var t=e?e.length:0,n=ro();return e=t?Qn(e,function(e){if(typeof e[1]!="function")throw new Bt(S);return[n(e[0]),e[1]]}):[],Ia(function(n){var r=-1;while(++rN)return[];var n=L,r=ln(e,L);t=Ao(t),e-=L;var i=ar(r,t);while(++n0){if(++e>=m)return n}else e=0;return os(n,r)}}(),Do=Ia(function(e,t){return Ya(e)||(e=e==null?[]:[Object(e)]),t=Ti(t),zn(e,t)}),Po=Ia(function(e,t){return ef(e)?yi(e,Ti(t,!1,!0)):[]}),Ho=Ia(function(t,n){var r=eu(n);return ef(r)&&(r=e),ef(t)?yi(t,Ti(n,!1,!0),ro(r)):[]}),Bo=Ia(function(t,n){var r=eu(n);return ef(r)&&(r=e),ef(t)?yi(t,Ti(n,!1,!0),e,r):[]}),Qo=Ia(function(e){var t=Qn(e,Lo);return t.length&&t[0]===e[0]?Hi(t):[]}),Go=Ia(function(t){var n=eu(t),r=Qn(t,Lo);return n===eu(r)?n=e:r.pop(),r.length&&r[0]===t[0]?Hi(r,ro(n)):[]}),Yo=Ia(function(t){var n=eu(t),r=Qn(t,Lo);return n===eu(r)?n=e:r.pop(),r.length&&r[0]===t[0]?Hi(r,e,n):[]}),nu=Ia(ru),su=Ia(function(e,t){t=Qn(Ti(t),String);var n=hi(e,t);return ns(e,t.sort(vr)),n}),Su=Ia(function(e){return ds(Ti(e,!1,!0))}),xu=Ia(function(t){var n=eu(t);return ef(n)&&(n=e),ds(Ti(t,!1,!0),ro(n))}),Tu=Ia(function(t){var n=eu(t);return ef(n)&&(n=e),ds(Ti(t,!1,!0),e,n)}),Ou=Ia(function(e,t){return ef(e)?yi(e,t):[]}),Mu=Ia(function(e){return ys($n(e,ef))}),_u=Ia(function(t){var n=eu(t);return ef(n)&&(n=e),ys($n(t,ef),ro(n))}),Du=Ia(function(t){var n=eu(t);return ef(n)&&(n=e),ys($n(t,ef),e,n)}),Pu=Ia(Lu),ju=Ia(function(t){var n=t.length,r=n>1?t[n-1]:e;return r=typeof r=="function"?(t.pop(),r):e,Au(t,r)}),Ru=Ia(function(t){t=Ti(t);var n=t.length,r=n?t[0]:0,i=this.__wrapped__,s=function(e){return hi(e,t)};return n>1||this.__actions__.length||!(i instanceof _r)||!Sr(r)?this.thru(s):(i=i.slice(r,+r+(n?1:0)),i.__actions__.push({func:qu,args:[s],thisArg:e}),(new dr(i,this.__chain__)).thru(function(t){return n&&!t.length&&t.push(e),t}))}),Qu=_s(function(e,t,n){qt.call(e,n)?++e[n]:e[n]=1}),ia=_s(function(e,t,n){qt.call(e,n)?e[n].push(t):e[n]=[t]}),oa=Ia(function(t,n,r){var i=-1,s=typeof n=="function",o=go(n),u=Za(t)?Array(t.length):[];return bi(t,function(t){var a=s?n:o&&t!=null?t[n]:e;u[++i]=a?Rn(a,t,r):ji(t,n,r)}),u}),ua=_s(function(e,t,n){e[n]=t}),la=_s(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),ba=Ia(function(e,t){if(e==null)return[];var n=t.length;return n>1&&mo(e,t[0],t[1])?t=[]:n>2&&mo(t[0],t[1],t[2])&&(t.length=1),Ki(e,Ti(t),[])}),wa=At.now,Ta=Ia(function(e,t,r){var i=n;if(r.length){var s=Nr(r,Ta.placeholder);i|=u}return Gs(e,i,t,r,s)}),Na=Ia(function(e,t,i){var s=n|r;if(i.length){var o=Nr(i,Na.placeholder);s|=u}return Gs(t,s,e,i,o)}),Aa=Ia(function(e,t){return gi(e,1,t)}),Oa=Ia(function(e,t,n){return gi(e,Pf(t)||0,n)}),Ha=Ia(function(e,t){t=Qn(Ti(t),ro());var n=t.length;return Ia(function(r){var i=-1,s=ln(r.length,n);while(++i0||n<0)?new _r(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==e&&(n=_f(n),r=n<0?r.dropRight(-n):r.take(n-t)),r)},_r.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},_r.prototype.toArray=function(){return this.take(L)},Li(_r.prototype,function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),i=/^(?:head|last)$/.test(n),s=Bn[i?"take"+(n=="last"?"Right":""):n],o=i||/^find/.test(n);if(!s)return;Bn.prototype[n]=function(){var n=this.__wrapped__,u=i?[1]:arguments,a=n instanceof _r,f=u[0],l=a||Ya(n),c=function(e){var t=s.apply(Bn,Gn([e],u));return i&&h?t[0]:t};l&&r&&typeof f=="function"&&f.length!=1&&(a=l=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,v=a&&!p;if(!o&&l){n=v?n:new _r(this);var m=t.apply(n,u);return m.__actions__.push({func:qu,args:[c],thisArg:e}),new dr(m,h)}return d&&v?t.apply(this,u):(m=this.thru(c),d?i?m.value()[0]:m.value():m)}}),Wn(["pop","push","shift","sort","splice","unshift"],function(e){var t=jt[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Bn.prototype[e]=function(){var e=arguments;return r&&!this.__chain__?t.apply(this.value(),e):this[n](function(n){return t.apply(n,e)})}}),Li(_r.prototype,function(e,t){var n=Bn[t];if(n){var r=n.name+"",i=Hn[r]||(Hn[r]=[]);i.push({name:t,func:n})}}),Hn[Us(e,r).name]=[{name:"wrapper",func:e}],_r.prototype.clone=Dr,_r.prototype.reverse=Pr,_r.prototype.value=Hr,Bn.prototype.at=Ru,Bn.prototype.chain=Uu,Bn.prototype.commit=zu,Bn.prototype.flatMap=Wu,Bn.prototype.next=Xu,Bn.prototype.plant=$u,Bn.prototype.reverse=Ju,Bn.prototype.toJSON=Bn.prototype.valueOf=Bn.prototype.value=Ku,Zt&&(Bn.prototype[Zt]=Vu),Bn}var e,t="4.2.0",n=1,r=2,i=4,s=8,o=16,u=32,a=64,f=128,l=256,c=512,h=1,p=2,d=30,v="...",m=150,g=16,y=200,b=1,w=2,E=3,S="Expected a function",x="__lodash_hash_undefined__",T=1/0,N=9007199254740991,C=1.7976931348623157e308,k=0/0,L=4294967295,A=L-1,O=L>>>1,M="__lodash_placeholder__",_="[object Arguments]",D="[object Array]",P="[object Boolean]",H="[object Date]",B="[object Error]",j="[object Function]",F="[object GeneratorFunction]",I="[object Map]",q="[object Number]",R="[object Object]",U="[object RegExp]",z="[object Set]",W="[object String]",X="[object Symbol]",V="[object WeakMap]",$="[object ArrayBuffer]",J="[object Float32Array]",K="[object Float64Array]",Q="[object Int8Array]",G="[object Int16Array]",Y="[object Int32Array]",Z="[object Uint8Array]",et="[object Uint8ClampedArray]",tt="[object Uint16Array]",nt="[object Uint32Array]",rt=/\b__p \+= '';/g,it=/\b(__p \+=) '' \+/g,st=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ot=/&(?:amp|lt|gt|quot|#39|#96);/g,ut=/[&<>"'`]/g,at=RegExp(ot.source),ft=RegExp(ut.source),lt=/<%-([\s\S]+?)%>/g,ct=/<%([\s\S]+?)%>/g,ht=/<%=([\s\S]+?)%>/g,pt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dt=/^\w*$/,vt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,mt=/[\\^$.*+?()[\]{}|]/g,gt=RegExp(mt.source),yt=/^\s+|\s+$/g,bt=/^\s+/,wt=/\s+$/,Et=/\\(\\)?/g,St=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,xt=/\w*$/,Tt=/^0x/i,Nt=/^[-+]0x[0-9a-f]+$/i,Ct=/^0b[01]+$/i,kt=/^\[object .+?Constructor\]$/,Lt=/^0o[0-7]+$/i,At=/^(?:0|[1-9]\d*)$/,Ot=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Mt=/($^)/,_t=/['\n\r\u2028\u2029\\]/g,Dt="\\ud800-\\udfff",Pt="\\u0300-\\u036f\\ufe20-\\ufe23",Ht="\\u20d0-\\u20f0",Bt="\\u2700-\\u27bf",jt="a-z\\xdf-\\xf6\\xf8-\\xff",Ft="\\xac\\xb1\\xd7\\xf7",It="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",qt="\\u2018\\u2019\\u201c\\u201d",Rt=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ut="A-Z\\xc0-\\xd6\\xd8-\\xde",zt="\\ufe0e\\ufe0f",Wt=Ft+It+qt+Rt,Xt="["+Dt+"]",Vt="["+Wt+"]",$t="["+Pt+Ht+"]",Jt="\\d+",Kt="["+Bt+"]",Qt="["+jt+"]",Gt="[^"+Dt+Wt+Jt+Bt+jt+Ut+"]",Yt="\\ud83c[\\udffb-\\udfff]",Zt="(?:"+$t+"|"+Yt+")",en="[^"+Dt+"]",tn="(?:\\ud83c[\\udde6-\\uddff]){2}",nn="[\\ud800-\\udbff][\\udc00-\\udfff]",rn="["+Ut+"]",sn="\\u200d",on="(?:"+Qt+"|"+Gt+")",un="(?:"+rn+"|"+Gt+")",an=Zt+"?",fn="["+zt+"]?",ln="(?:"+sn+"(?:"+[en,tn,nn].join("|")+")"+fn+an+")*",cn=fn+an+ln,hn="(?:"+[Kt,tn,nn].join("|")+")"+cn,pn="(?:"+[en+$t+"?",$t,tn,nn,Xt].join("|")+")",dn=RegExp($t,"g"),vn=RegExp(Yt+"(?="+Yt+")|"+pn+cn,"g"),mn=RegExp("["+sn+Dt+Pt+Ht+zt+"]"),gn=/[a-zA-Z0-9]+/g,yn=RegExp([rn+"?"+Qt+"+(?="+[Vt,rn,"$"].join("|")+")",un+"+(?="+[Vt,rn+on,"$"].join("|")+")",rn+"?"+on+"+",rn+"+",Jt,hn].join("|"),"g"),bn=/[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,wn=["Array","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Reflect","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],En=-1,Sn={};Sn[J]=Sn[K]=Sn[Q]=Sn[G]=Sn[Y]=Sn[Z]=Sn[et]=Sn[tt]=Sn[nt]=!0,Sn[_]=Sn[D]=Sn[$]=Sn[P]=Sn[H]=Sn[B]=Sn[j]=Sn[I]=Sn[q]=Sn[R]=Sn[U]=Sn[z]=Sn[W]=Sn[V]=!1;var xn={};xn[_]=xn[D]=xn[$]=xn[P]=xn[H]=xn[J]=xn[K]=xn[Q]=xn[G]=xn[Y]=xn[I]=xn[q]=xn[R]=xn[U]=xn[z]=xn[W]=xn[X]=xn[Z]=xn[et]=xn[tt]=xn[nt]=!0,xn[B]=xn[j]=xn[V]=!1;var Tn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Nn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Cn={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},kn={"function":!0,object:!0},Ln={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},An=parseFloat,On=parseInt,Mn=kn[typeof exports]&&exports&&!exports.nodeType?exports:null,_n=kn[typeof module]&&module&&!module.nodeType?module:null,Dn=dr(Mn&&_n&&typeof global=="object"&&global),Pn=dr(kn[typeof self]&&self),Hn=dr(kn[typeof window]&&window),Bn=_n&&_n.exports===Mn?Mn:null,jn=dr(kn[typeof this]&&this),Fn=Dn||Hn!==(jn&&jn.window)&&Hn||Pn||jn||Function("return this")(),Mr=Or();(Hn||Pn||{})._=Mr,typeof define=="function"&&typeof define.amd=="object"&&define.amd?define("underscore/lodash",[],function(){return Mr}):Mn&&_n?(Bn&&((_n.exports=Mr)._=Mr),Mn._=Mr):Fn._=Mr}.call(this),define("underscore/index",["require","exports","module","./lodash"],function(e,t,n){n.exports=e("./lodash")}),define("underscore",["underscore/index"],function(e){return e}),function(e,t){var n,r=function(e,t){return new r.fn.init(e,t,n)};r.fn=r.prototype={jquery:core_version},e.jQuery=e.$=r}(window),define("jquery",function(e){return function(){var t,n;return t||e.jQuery}}(this)),function(e){var t=typeof self=="object"&&self.self==self&&self||typeof global=="object"&&global.global==global&&global;if(typeof define=="function"&&define.amd)define("backbone/backbone",["underscore","jquery","exports"],function(n,r,i){t.Backbone=e(t,i,n,r)});else if(typeof exports!="undefined"){var n=require("underscore"),r;try{r=require("jquery")}catch(i){}e(t,exports,n,r)}else t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}(function(e,t,n,r){var i=e.Backbone,s=Array.prototype.slice;t.VERSION="1.2.3",t.$=r,t.noConflict=function(){return e.Backbone=i,this},t.emulateHTTP=!1,t.emulateJSON=!1;var o=function(e,t,r){switch(e){case 1:return function(){return n[t](this[r])};case 2:return function(e){return n[t](this[r],e)};case 3:return function(e,i){return n[t](this[r],a(e,this),i)};case 4:return function(e,i,s){return n[t](this[r],a(e,this),i,s)};default:return function(){var e=s.call(arguments);return e.unshift(this[r]),n[t].apply(n,e)}}},u=function(e,t,r){n.each(t,function(t,i){n[i]&&(e.prototype[i]=o(t,i,r))})},a=function(e,t){return n.isFunction(e)?e:n.isObject(e)&&!t._isModel(e)?f(e):n.isString(e)?function(t){return t.get(e)}:e},f=function(e){var t=n.matches(e);return function(e){return t(e.attributes)}},l=t.Events={},c=/\s+/,h=function(e,t,r,i,s){var o=0,u;if(r&&typeof r=="object"){i!==void 0&&"context"in s&&s.context===void 0&&(s.context=i);for(u=n.keys(r);o7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!this.history&&!!this.history.pushState,this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(j,"/");if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var t=this.root.slice(0,-1)||"/";return this.location.replace(t+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var r=document.body,i=r.insertBefore(this.iframe,r.firstChild).contentWindow;i.document.open(),i.document.close(),i.location.hash="#"+this.fragment}var s=window.addEventListener||function(e,t){return attachEvent("on"+e,t)};this._usePushState?s("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?s("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval));if(!this.options.silent)return this.loadUrl()},stop:function(){var e=window.removeEventListener||function(e,t){return detachEvent("on"+e,t)};this._usePushState?e("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&e("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),H.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(e){var t=this.getFragment();t===this.fragment&&this.iframe&&(t=this.getHash(this.iframe.contentWindow));if(t===this.fragment)return!1;this.iframe&&this.navigate(t),this.loadUrl()},loadUrl:function(e){return this.matchRoot()?(e=this.fragment=this.getFragment(e),n.some(this.handlers,function(t){if(t.route.test(e))return t.callback(e),!0})):!1},navigate:function(e,t){if(!H.started)return!1;if(!t||t===!0)t={trigger:!!t};e=this.getFragment(e||"");var n=this.root;if(e===""||e.charAt(0)==="?")n=n.slice(0,-1)||"/";var r=n+e;e=this.decodeFragment(e.replace(F,""));if(this.fragment===e)return;this.fragment=e;if(this._usePushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,r);else{if(!this._wantsHashChange)return this.location.assign(r);this._updateHash(this.location,e,t.replace);if(this.iframe&&e!==this.getHash(this.iframe.contentWindow)){var i=this.iframe.contentWindow;t.replace||(i.document.open(),i.document.close()),this._updateHash(i.location,e,t.replace)}}if(t.trigger)return this.loadUrl(e)},_updateHash:function(e,t,n){if(n){var r=e.href.replace(/(javascript:|#).*$/,"");e.replace(r+"#"+t)}else e.hash="#"+t}}),t.history=new H;var I=function(e,t){var r=this,i;e&&n.has(e,"constructor")?i=e.constructor:i=function(){return r.apply(this,arguments)},n.extend(i,r,t);var s=function(){this.constructor=i};return s.prototype=r.prototype,i.prototype=new s,e&&n.extend(i.prototype,e),i.__super__=r.prototype,i};b.extend=E.extend=O.extend=C.extend=H.extend=I;var q=function(){throw new Error('A "url" property or function must be specified')},R=function(e,t){var n=t.error;t.error=function(r){n&&n.call(t.context,e,r,t),e.trigger("error",e,r,t)}};return t}),define("backbone",["backbone/backbone"],function(e){return e}),function(){function t(){}function n(e){return e}function r(e){return!!e}function i(e){return!e}function u(e){return function(){if(e===null)throw new Error("Callback was already called.");e.apply(this,arguments),e=null}}function a(e){return function(){if(e===null)return;e.apply(this,arguments),e=null}}function h(e){return l(e)||typeof e.length=="number"&&e.length>=0&&e.length%1===0}function p(e,t){var n=-1,r=e.length;while(++n3?e(r,i,a,u):(o=s,s=i,e(r,a,u))}}function D(e,t){return t}function P(e,n,r){r=r||t;var i=h(n)?[]:{};e(n,function(e,t,n){e(E(function(e,r){r.length<=1&&(r=r[0]),i[t]=r,n(e)}))},function(e){r(e,i)})}function H(e,t,n,r){var i=[];e(t,function(e,t,r){n(e,function(e,t){i=i.concat(t||[]),r(e)})},function(e){r(e,i)})}function B(n,r,i){function s(n,r,i,s){if(s!=null&&typeof s!="function")throw new Error("task callback must be a function");n.started=!0,l(r)||(r=[r]);if(r.length===0&&n.idle())return e.setImmediate(function(){n.drain()});p(r,function(e){var r={data:e,callback:s||t};i?n.tasks.unshift(r):n.tasks.push(r),n.tasks.length===n.concurrency&&n.saturated()}),e.setImmediate(n.process)}function o(e,t){return function(){a-=1;var n=!1,r=arguments;p(t,function(e){p(f,function(t,r){t===e&&!n&&(f.splice(r,1),n=!0)}),e.callback.apply(e,r)}),e.tasks.length+a===0&&e.drain(),e.process()}}if(r==null)r=1;else if(r===0)throw new Error("Concurrency must not be zero");var a=0,f=[],c={tasks:[],concurrency:r,payload:i,saturated:t,empty:t,drain:t,started:!1,paused:!1,push:function(e,t){s(c,e,!1,t)},kill:function(){c.drain=t,c.tasks=[]},unshift:function(e,t){s(c,e,!0,t)},process:function(){while(!c.paused&&ar?1:0}e.map(t,function(e,t){n(e,function(n,r){n?t(n):t(null,{value:e,criteria:r})})},function(e,t){if(e)return r(e);r(null,d(t.sort(i),function(e){return e.value}))})},e.auto=function(n,r,i){function d(e){h.unshift(e)}function v(e){var t=y(h,e);t>=0&&h.splice(t,1)}function w(){o--,p(h.slice(0),function(e){e()})}typeof arguments[1]=="function"&&(i=r,r=null),i=a(i||t);var s=b(n),o=s.length;if(!o)return i(null);r||(r=o);var u={},f=0,c=!1,h=[];d(function(){o||i(null,u)}),p(s,function(t){function b(){return f=0)throw new Error("Has cyclic dependencies")}b()?(f++,s[s.length-1](o,u)):d(S)})},e.retry=function(t,n,r){function a(e,t){if(typeof t=="number")e.times=parseInt(t,10)||i;else{if(typeof t!="object")throw new Error("Unsupported argument type for 'times': "+typeof t);e.times=parseInt(t.times,10)||i,e.interval=parseInt(t.interval,10)||s}}function l(t,n){function r(e,t){return function(r){e(function(e,n){r(!e||t,{err:e,result:n})},n)}}function i(e){return function(t){setTimeout(function(){t(null)},e)}}while(u.times){var s=!(u.times-=1);o.push(r(u.task,s)),!s&&u.interval>0&&o.push(i(u.interval))}e.series(o,function(e,n){n=n[n.length-1],(t||u.callback)(n.err,n.result)})}var i=5,s=0,o=[],u={times:i,interval:s},f=arguments.length;if(f<1||f>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return f<=2&&typeof t=="function"&&(r=n,n=t),typeof t!="function"&&a(u,t),u.callback=r,u.task=n,u.callback?l():l},e.waterfall=function(n,r){function s(e){return E(function(t,n){if(t)r.apply(null,[t].concat(n));else{var i=e.next();i?n.push(s(i)):n.push(r),q(e).apply(null,n)}})}r=a(r||t);if(!l(n)){var i=new Error("First argument to waterfall must be an array of functions");return r(i)}if(!n.length)return r();s(e.iterator(n))()},e.parallel=function(t,n){P(e.eachOf,t,n)},e.parallelLimit=function(e,t,n){P(N(t),e,n)},e.series=function(t,n){P(e.eachOfSeries,t,n)},e.iterator=function(e){function t(n){function r(){return e.length&&e[n].apply(null,arguments),r.next()}return r.next=function(){return n>>1);n(t,e[s])>=0?r=s:i=s-1}return r}function o(n,r,o,u){if(u!=null&&typeof u!="function")throw new Error("task callback must be a function");n.started=!0,l(r)||(r=[r]);if(r.length===0)return e.setImmediate(function(){n.drain()});p(r,function(r){var a={data:r,priority:o,callback:typeof u=="function"?u:t};n.tasks.splice(s(n.tasks,a,i)+1,0,a),n.tasks.length===n.concurrency&&n.saturated(),e.setImmediate(n.process)})}var u=e.queue(n,r);return u.push=function(e,t,n){o(u,e,t,n)},delete u.unshift,u},e.cargo=function(e,t){return B(e,1,t)},e.log=j("log"),e.dir=j("dir"),e.memoize=function(t,r){var i={},s={},o=Object.prototype.hasOwnProperty;r=r||n;var u=E(function(u){var a=u.pop(),f=r.apply(null,u);o.call(i,f)?e.setImmediate(function(){a.apply(null,i[f])}):o.call(s,f)?s[f].push(a):(s[f]=[a],t.apply(null,u.concat([E(function(e){i[f]=e;var t=s[f];delete s[f];for(var n=0,r=t.length;nt.expires?(typeof console!="undefined"&&console.log('MemoryStore: Expiring key "'+e+'".'),this.clear(e),t=undefined):t&&t.value&&(t=t.value),t},r.prototype.set=function(e,t,n){var r;return!e||t===undefined?!1:(r=n?Date.now()+n*1e3:null,this._set(e,{value:t,expires:r}),!0)},r.prototype._get=function(e){return this.cache[this._formatKey(e)]},r.prototype._set=function(e,t){this.cache[this._formatKey(e)]=t},r.prototype._clear=function(e){delete this.cache[this._formatKey(e)]},r.prototype._clearAll=function(){this.cache={}},r.prototype.clear=function(e){return e!=null?this._clear(e):this._clearAll()},r.prototype._versionKey=function(e){return e+":"+this.cacheVersion},r.prototype._formatKey=function(e){return this._versionKey(e)}}),define("rendr/shared/store/model_store",["require","exports","module","underscore","./memory_store"],function(e,t,n){function s(){i.apply(this,arguments)}function o(e){return function(t){return u(t,e)}}function u(e,t){return e.slice(0,t.length)==t}function a(e,t){return r.all(e,function(e,n){return t[n]==e})}var r=e("underscore"),i=e("./memory_store");n.exports=s,r.extend(s.prototype,i.prototype,{expireSeconds:null,set:function(e){var t,n;n=this.modelUtils.modelName(e.constructor);if(n==null)throw new Error("Undefined modelName for model");return t=this._getModelStoreKey(n,e.id),e.parse(e.attributes),i.prototype.set.call(this,t,e,this.expireSeconds)},get:function(e,t){var n,r;return n=this._getModelStoreKey(e,t),i.prototype.get.call(this,n)},clear:function(e,t){if(e&&t){var n=this._getModelStoreKey(e,t);return i.prototype.clear.call(this,n)}if(!e||!!t)return i.prototype.clear.call(this,null);var s=this._getCachedItemsByModel(e),o=this,u;r.each(s,function(t){u=o._getModelStoreKey(e,t.value.id),i.prototype.clear.call(o,u)})},find:function(e,t){var n=this._formatKey(this._keyPrefix(e)),s=Object.keys(this.cache),u=s.filter(o(n)),f=this,l;l=r.find(u,function(n){var r=f.cache[n].value,s=f._getModelStoreKey(e,r.id),o=i.prototype.get.call(f,s);return o&&a(t,o.toJSON())});if(l)return this.cache[l].value},_getCachedItemsByModel:function(e){var t=this._formatKey(this._keyPrefix(e));return r.filter(this.cache,function(e,n){return u(n,t)})},_formatKey:function(e){return i.prototype._formatKey.call(this,"_ms:"+e)},_keyPrefix:function(e){return this.modelUtils.underscorize(e)},_getModelStoreKey:function(e,t){return this._keyPrefix(e)+":"+t}})}),define("rendr/shared/store/collection_store",["require","exports","module","underscore","./memory_store"],function(e,t,n){function s(){i.apply(this,arguments)}function o(e){var t={};return r.chain(e).keys().sort().forEach(function(n){t[n]=e[n]}),t}function u(e,t){return e.slice(0,t.length)==t}var r=e("underscore"),i=e("./memory_store");n.exports=s,r.extend(s.prototype,i.prototype,{expireSeconds:null,set:function(e,t){var n=this._getStoreKeyForCollection(e,t);return i.prototype.set.call(this,n,e,this.expireSeconds)},get:function(e,t,n){var s=this,o;return this.mergeParams(e,t,function(t){var u=s._getStoreKey(e,t);o=i.prototype.get.call(s,u),r.isFunction(n)&&n(o)}),o},clear:function(e,t){if(!r.isUndefined(e)&&t){var n=this._getStoreKey(e,t);return i.prototype.clear.call(this,n)}if(!!r.isUndefined(e)||!!t)return i.prototype.clear.call(this,null);var s=this._getCachedItemsByCollection(e),o=this,u;r.each(s,function(t){u=o._getStoreKey(e,t.value.params),i.prototype.clear.call(o,u)})},mergeParams:function(e,t,n){this.modelUtils.getCollectionConstructor(e,function(e){var i=r.extend({},e.prototype.defaultParams,t);n(i)})},_getCachedItemsByCollection:function(e){var t=this._formatKey(this.modelUtils.underscorize(e));return r.filter(this.cache,function(e,n){return u(n,t)})},_getStoreKeyForCollection:function(e,t){var n=this.modelUtils.modelName(e.constructor);return t=t||e.params,this._getStoreKey(n,t)},_getStoreKey:function(e,t){var n=this.modelUtils.underscorize(e);return n+":"+JSON.stringify(o(t))}})}),define("rendr/shared/fetcher",["require","exports","module","underscore","backbone","async","./store/model_store","./store/collection_store","jquery"],function(e,t,n){function f(e){this.options=e,this.app=this.options.app,this.modelUtils=this.app.modelUtils,this.modelStore=new o({app:this.app,modelUtils:this.modelUtils}),this.collectionStore=new u({app:this.app,modelUtils:this.modelUtils})}var r=e("underscore"),i=e("backbone"),s=e("async"),o=e("./store/model_store"),u=e("./store/collection_store"),a=typeof window=="undefined";a||(i.$=window.$||e("jquery")),n.exports=f,f.prototype.buildOptions=function(e,t){var n={app:this.app,parse:!0};return r.defaults(n,e),r.defaults(n,t),n},f.prototype.getModelOrCollectionForSpec=function(e,t,n,r){return e.model?this.getModelForSpec(e,t,n,r):this.getCollectionForSpec(e,t,n,r)},f.prototype.getCollectionForSpec=function(e,t,n,i){var s=this.buildOptions(n,r.extend({params:e.params},e.params));return t=t||[],this.modelUtils.getCollection(e.collection,t,s,i)},f.prototype.getModelForSpec=function(e,t,n,i){var s=this.buildOptions(n);return t=t||{},r.defaults(t,e.params),this.modelUtils.getModel(e.model,t,s,i)},f.prototype._retrieve=function(e,t,n){var i={};r.each(e,function(e,n){i[n]=function(n){var i,s=t.readFromCache;!r.isUndefined(e.readFromCache)&&!r.isNull(e.readFromCache)&&(s=e.readFromCache),s?(i=null,e.model!=null?this._retrieveModel(e,function(r,i){this._refreshData(e,i,t,n)}.bind(this)):e.collection!=null&&this.collectionStore.get(e.collection,e.params,function(r){this._refreshData(e,r,t,n)}.bind(this))):this.fetchFromApi(e,t,n)}.bind(this)},this),s.parallel(i,n)},f.prototype._refreshData=function(e,t,n,r){this.needsFetch(t,e)?this.fetchFromApi(e,n,r):r(null,t)},f.prototype._retrieveModel=function(e,t){var n=this;this.modelUtils.modelIdAttribute(e.model,function(i){var s=n.modelStore.get(e.model,e.params[i]);return s?t(null,s):r.isEmpty(r.omit(e.params,i))?t(null,null):t(null,n.modelStore.find(e.model,e.params))})},f.prototype.needsFetch=function(e,t){return e==null?!0:this.modelUtils.isModel(e)&&this.isMissingKeys(e.attributes,t.ensureKeys)?!0:t.needsFetch===!0?!0:typeof t.needsFetch=="function"&&t.needsFetch(e)?!0:!1},f.prototype.isMissingKeys=function(e,t){var n;if(t==null)return!1;r.isArray(t)||(t=[t]);for(var i=0,s=t.length;i"+e+""},render:function(){var e=this.getInnerHtml();return this.$el.html(e),this.$el.attr(this.getAttributes()),this._postRender(),this},fetchLazy:function(){var e={},t,n;if(this.options.fetch_params){if(!i.isObject(this.options.fetch_params))throw new Error("fetch_params must be an object for lazy loaded views");e=this.options.fetch_params}else this.options.param_name&&(e[this.options.param_name]=this.options.param_value);if(this.options.fetch_options){if(!i.isObject(this.options.fetch_options))throw new Error("fetch_options must be an object for lazy loaded views");t=this.options.fetch_options}this.options.model_id!=null&&(e.id=this.options.model_id),this.options.model_name!=null?n={model:{model:this.options.model_name,params:e}}:this.options.collection_name!=null&&(n={collection:{collection:this.options.collection_name,params:e}});if(this.options.fetch_spec){if(!i.isObject(this.options.fetch_spec))throw new Error("fetch_spec must be an object for lazy loaded views");n=this.options.fetch_spec}this.setLoading(!0),this._preRender(),this.app.fetch(n,t,this._fetchLazyCallback.bind(this))},_fetchLazyCallback:function(e,t){this.setLoading(!1),e?this.lazyErrorCallback(e):this.viewing&&(this.parseOptions(t),this.lazyCallback(t))},lazyErrorCallback:function(e){console.log("FETCH ERR: "+e)},lazyCallback:function(e){this.render()},_preRender:function(){this.preRender(),this.trigger("preRender")},_postRender:function(){this.attachChildViews(function(){this.postRender(),this.trigger("postRender")})},preRender:i.noop,postRender:i.noop,setLoading:function(e){this.$el.toggleClass("loading",e),this.trigger("loading",e)},attachOrRender:function(e,t){var n=s.$(e);this.parentView=t,this.viewing=!0;if(this.options.lazy===!0&&this.options.collection==null&&this.options.model==null)return n.attr("data-view-attached",!0),this.setElement(n),this.fetchLazy();n.data("render")?(n.replaceWith(this.$el),this.render()):(n.attr("data-view-attached",!0),this.setElement(n),this.attach())},attach:function(){this._preRender(),this._postRender(),this.trigger("attach")},attachChildViews:function(e){var t=this;this.removeChildViews(),a.getChildViews(this.app,this,function(n){t.childViews=n,e.call(t)})},removeChildViews:function(){(this.childViews||[]).forEach(function(e){e.remove()})},remove:function(){this.parentView&&this.parentView.childViews&&(this.parentView.childViews=i.without(this.parentView.childViews,this)),this.removeChildViews(),this.childViews=null,this.parentView=null,this.viewing=!1;var e=this.model||this.collection;e&&e.off(null,null,this),a.__super__.remove.apply(this,arguments),this.trigger("remove")}}),a.getView=function(t,n,i){var s;n||(n=""),s=n+"app/views/"+t;if(typeof i!="function")return e(s);typeof define!="undefined"?r([s],i):i(e(s))},a.createChildView=function(e,t,n,r,i){if(!n.data("view-attached")){var s=a.attachNewChildView(e,t,n,r);i(null,s)}else i(null,null)},a.getViewOptions=function(e){var t,n=e.data();return i.each(n,function(e,r){if(i.isString(e)){t=i.unescape(e);try{t=JSON.parse(t)}catch(s){}n[r]=t}}),n},a.attachNewChildView=function(e,t,n,r){var i=new e(t);return i.attachOrRender(n,r),i},a.getChildViews=function(e,t,n){var r=t?t.$el:null,u=s.$("[data-view]",r).toArray();o.map(u,function(n,r){var o,u,f,l;o=s.$(n),o.data("view-attached")?r(null,null):(u=a.getViewOptions(o),u.app=e,f=u.view,l=u.fetch_summary||{},e.fetcher.hydrate(l,{app:e},function(n,s){u=i.extend(u,s),a.getView(f,e.options.entryPath,function(e){a.createChildView(e,u,o,t,r)})}))},function(e,t){n(i.compact(t))})},a.parseModelAndCollection=function(e,t){return t.model!=null&&(!(t.model instanceof s.Model)&&t.model_name&&(t.model=e.getModel(t.model_name,t.model,{parse:!!t.parse,app:t.app})),t.model_name=t.model_name||e.modelName(t.model.constructor),t.model_id=t.model.id),t.collection!=null&&(!(t.collection instanceof s.Collection)&&t.collection_name&&(t.collection=e.getCollection(t.collection_name,t.collection,{parse:!!t.parse,app:t.app,params:t.collection_params})),t.collection_name=t.collection_name||e.modelName(t.collection.constructor),t.collection_params=t.collection_params||t.collection.params),t},a.extractFetchSummary=function(e,t){var n={};return i.each(t,function(t,r){var s,o;if(t!=null&&i.isFunction(t.constructor)&&t.constructor.id!=null){o=t.constructor.id;if(e.isModel(t)){s=t.get(t.idAttribute);if(s==null)return;t=s.toString(),n[r]={model:o,id:t};return}if(e.isCollection(t)&&t.params!=null){n[r]={collection:o,params:t.params};return}}}),n},typeof window=="undefined"&&(a.prototype._ensureElement=i.noop,a.prototype.delegateEvents=i.noop)}),define("rendr/client/router",["require","exports","module","underscore","backbone","../shared/base/router","../shared/base/view","jquery"],function(e,t,n){function h(e){this._router=new i.Router,s.apply(this,arguments),this.app=e.app;var t=this.options.appViewClass;this.app.router=this,this.on("route:add",this.addBackboneRoute,this),this.on("action:start",this.trackAction,this),this.app.on("reload",this.renderView,this),this.appView=new t({app:this.app}),this.appView.render(),this.buildRoutes(),this.initialize(e)}var r=e("underscore"),i=e("backbone"),s=e("../shared/base/router"),o=e("../shared/base/view"),u=typeof window=="undefined",a=/:(\w+)/g,f=/\+/g,l=!0,c="";u||(i.$=window.$||e("jquery")),n.exports=h,h.prototype=Object.create(s.prototype),h.prototype.constructor=h,h.prototype.currentFragment=null,h.prototype.previousFragment=null,h.prototype.currentRoute=null,h.prototype._router=null,h.prototype.reverseRoutes=!0,h.prototype.initialize=r.noop,h.prototype.addBackboneRoute=function(e){var t,n,r,i;r=e[0]instanceof RegExp?e[0]:e[0].slice(1),i=e[1],t=e[2],n=i.controller+":"+i.action,this._router.route(r,n,t)},h.prototype.getHandler=function(e,t,n){function s(e,t){e.call(i,t,i.getRenderCallback(n))}var i=this;return function(){var u,a,f;i.trigger("action:start",n,l),i.currentRoute=n;if(l)l=!1,o.getChildViews(i.app,null,function(e){i.currentView=i.getMainView(e),i.trigger("action:end",n,!0)});else{a=r.toArray(arguments),u=i.getParamsHash(t,a,window.location.search),f=i.getRedirect(n,u);if(f!=null)i.redirectTo(f,{replace:!0});else{if(!e)throw new Error('Missing action "'+n.action+'" for controller "'+n.controller+'"');s(e,u)}}}},h.prototype.getMainView=function(e){var t=this.appView.$content;return r.find(e,function(e){return e.$el.parent().is(t)})},h.prototype.navigate=function(e,t){var n=i.history.getFragment(e);this.matchesAnyRoute(n)?this._router.navigate.apply(this._router,arguments):this.redirectTo(n,{pushState:!1})},h.prototype.getParamsHash=function(e,t,n){var i,s,o;return e instanceof RegExp?i=t.map(function(e,t){return String(t)}):i=(e.match(a)||[]).map(function(e){return e.slice(1)}),s=(i||[]).reduce(function(e,n,r){return e[n]=decodeURIComponent(t[r]),e},{}),o=n.slice(1).split("&").reduce(function(e,t){var n=t.split("=");return n.length>1&&(e[n[0]]=decodeURIComponent(n[1].replace(f," "))),e},{}),r.extend(o,s)},h.prototype.matchingRoute=function(e){return r.find(i.history.handlers,function(t){return t.route.test(e)})},h.prototype.matchesAnyRoute=function(e){return this.matchingRoute(e)!=null},h.prototype.redirectTo=function(e,t){var n;t==null&&(t={}),r.defaults(t,{trigger:!0,pushState:!0,replace:!1}),t.pushState===!1?this.exitApp(e):(n=e.split("#"),e=n[0],n.length>1&&this.once("action:end",function(){window.location.hash=n[1]}),this.navigate(e,t))},h.prototype.exitApp=function(e){var t=this.noRelativePath(e);window.location.href=t},h.prototype.noRelativePath=function(e){return/^[a-z]+:/i.test(e)===!1&&e.charAt(0)!=="/"&&(e="/"+e),e},h.prototype.handleErr=function(e,t){this.trigger("action:error",e,t)},h.prototype.getRenderCallback=function(e){return function(t,n,i){if(t)return this.handleErr(t,e);var s,u=this;this.currentView&&this.currentView.remove();var a=this.defaultHandlerParams(n,i,e);n=a[0],i=a[1],i=i||{},r.extend(i,{fetch_summary:o.extractFetchSummary(this.app.modelUtils,i)}),i.app=this.app,this.getView(n,this.options.entryPath,function(t){u.currentView=new t(i),u.renderView(),u.trigger("action:end",e,l)})}.bind(this)},h.prototype.renderView=function(){this.appView.setCurrentView(this.currentView)},h.prototype.start=function(){i.history.start({pushState:!0,hashChange:!1,root:this.options.rootPath||c})},h.prototype.trackAction=function(){this.previousFragment=this.currentFragment,this.currentFragment=i.history.getFragment()},h.prototype.getView=function(e,t,n){var i=o.getView(e,t,function(t){if(!r.isFunction(t))throw new Error("View '"+e+"' not found.");n(t)})}}),define("rendr/client",["rendr/client/router"],function(e){return e}),define("app/router",["rendr/client/router"],function(e){}),define("rendr/client/app_view",["require","exports","module","underscore","backbone","../shared/base/view","jquery"],function(e,t,n){var r=e("underscore"),i=e("backbone"),s=e("../shared/base/view"),o=typeof window=="undefined";o||(i.$=window.$||e("jquery")),n.exports=s.extend({el:"body",constructor:function(){s.apply(this,arguments),r.defaults(this.options,{contentEl:"#content"}),this.$content=i.$(this.options.contentEl),this._bindInterceptClick()},hasPushState:typeof window!="undefined"&&window.history.pushState!=null,render:function(){},setCurrentView:function(e){this.$content.html(e.el),e.render()},_bindInterceptClick:function(){this.$el.on("click","a:not([data-pass-thru])",this._interceptClick.bind(this))},_interceptClick:function(e){var t=i.$(e.currentTarget).attr("href");this.shouldInterceptClick(t,e.currentTarget,e)&&(e.preventDefault(),this.app.router.redirectTo(t))},shouldInterceptClick:function(e,t,n){var r,i;return!e||!this.hasPushState||n.metaKey||n.shiftKey?!1:(r=e.split("#"),i=r.length>1&&r[0]===window.location.pathname,!i&&e.slice(0,1)==="/"&&e.slice(0,2)!=="//")}})}),define("rendr/shared/app",["require","exports","module","backbone","underscore","./fetcher","./modelUtils","app/router","jquery","../client/app_view"],function(e,t,n){var r=e("backbone"),i=e("underscore"),s=e("./fetcher"),o=e("./modelUtils"),u=typeof window=="undefined",a;u||(a=e("app/router"),r.$=window.$||e("jquery")),n.exports=r.Model.extend({defaults:{loading:!1,templateEngine:"handlebars",templateAdapter:"rendr-handlebars"},templateAdapter:undefined,req:undefined,modelUtils:undefined,fetcher:undefined,constructor:function(e,t){e=e||{},this.options=t||{};var n=this.options.entryPath||"";u||(n=""),this.modelUtils=this.options.modelUtils||new o(n),this.options.req&&(this.req=this.options.req),this.initializeTemplateAdapter(n,e),this.fetcher=new s({app:this}),u||(this.options.ClientRouter&&(a=this.options.ClientRouter),new a({app:this,entryPath:n,appViewClass:this.getAppViewClass(),rootPath:e.rootPath})),r.Model.apply(this,arguments)},initializeTemplateAdapter:function(t,n){if(this.options.templateAdapterInstance)this.templateAdapter=this.options.templateAdapterInstance;else{var r=n.templateAdapter||this.defaults.templateAdapter,i={entryPath:t},s=e(n.templateEngine||this.defaults.templateEngine);i=this.setTemplateFinder(i),this.templateAdapter=e(r)(i,s)}},getTemplateFinder:i.noop,setTemplateFinder:function(e){return i.isFunction(this.getTemplateFinder)&&this.getTemplateFinder!==i.noop&&(e.templateFinder=this.getTemplateFinder()),e},fetch:function(){this.fetcher.fetch.apply(this.fetcher,arguments)},getAppViewClass:function(){return e("../client/app_view")},bootstrapData:function(e,t){this.fetcher.bootstrapData(e,t)},start:function(){this.router.start(),this.trigger("start")}})}),define("rendr/shared",["rendr/shared/app"],function(e){return e}),define("deeply/mutable",["require","exports","module"],function(e,t,n){function r(){var e,t,n=Array.prototype.slice.call(arguments),s=n.shift(),o=typeof n[n.length-1]=="function"?n.pop():undefined;while(e=n.shift())for(t in e){if(!e.hasOwnProperty(t))continue;typeof e[t]=="object"&&i(e[t])=="object"?s[t]=r(s[t]||{},e[t],o):o&&Array.isArray(e[t])?s[t]=o(s[t]||[],Array.prototype.slice.call(e[t])):s[t]=e[t]}return s}function i(e){return Object.prototype.toString.call(e).match(/\[object\s*([^\]]+)\]/)[1].toLowerCase()}n.exports=r}),define("deeply/immutable",["require","exports","module","./mutable.js"],function(e,t,n){function i(){var e=Array.prototype.slice.call(arguments,0);return r.apply(this,[{}].concat(e))}var r=e("./mutable.js");n.exports=i}),define("deeply/index",["require","exports","module","./mutable.js","./immutable.js"],function(e,t,n){var r=e("./mutable.js"),i=e("./immutable.js");n.exports=i,n.exports.mutable=r,n.exports.immutable=i}),define("deeply",["deeply/index"],function(e){return e}),function(e,t){"use strict";var n=function(e,t){return new n.Instance(e,t||{})};e.Hammer=n}(this),define("hammer",function(){}),function(e,t){"use strict";function n(e,t){t.fn.hammer=function(n){return this.each(function(){var r=t(this),i=r.data("hammer");i?i&&n&&e.utils.extend(i.options,n):r.data("hammer",new e(this,n||{}))})}}}(this),define("jqueryHammer",function(){}),define("app/helper",["underscore","async"],function(e,t){}),define("app/lib/tracking/custom",["underscore"],function(e){var t={track:function(){return"some custom tracking code"}};return t}),define("app/models/user/user",["app/lib/tracking/custom"],function(e){}),define("main",["require","underscore","backbone","rendr/shared/app","app/helper","app/models/user/user","app/lib/tracking/pixel"],function(e,t,n,r,i,s,o){}),define("common",function(){}),require(["jqueryHammer"]); --------------------------------------------------------------------------------