diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..a2f4c549 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,29 @@ +{ + "parserOptions": { + "ecmaVersion": 6 + }, + "rules": { + "keyword-spacing": 1, + "space-before-function-paren": [1, "never"], + "eqeqeq": 1, + "space-infix-ops": 1, + "comma-spacing": 1, + "brace-style": 1, + "no-multiple-empty-lines": 1, + "camelcase": 1, + "func-call-spacing": 1, + "key-spacing": 1, + "semi": 1, + "no-floating-decimal": 1, + "no-multi-spaces": 1, + "object-property-newline": 1, + "padded-blocks": [1, "never"], + "space-before-blocks": 1, + "space-in-parens": 1, + "spaced-comment": 1, + "quotes": [1, "single"], + "id-length": [1, { "exceptions": ["i", "j", "x"] }], + "indent": [1, 2], + "no-array-constructor": 1 + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d6b426ce --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode +debug.log \ No newline at end of file diff --git a/README.md b/README.md index cc501c00..992616aa 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,7 @@ -# E-commerce +# eCommerce +SPA de ecommerce -* **Track:** _Especialización Front-end_ -* **Curso:** _CONSTRUYE UNA SINGLE PAGE APP (SPA) MULTI-USUARIO CONSUMIENDO DATA REMOTA_ -* **Unidad:** _Producto final_ -*** - -## Flujo de trabajo - -1. Debes realizar un [**fork**](https://gist.github.com/ivandevp/1de47ae69a5e139a6622d78c882e1f74) - de este repositorio. - -2. Luego deberás **clonar** tu fork en tu máquina. Recuerda que el comando a usar - es `git clone` y su estructura normalmente se ve así: - - ```bash - git clone https://github.com//freelancer.git - ``` - -3. Cuando hayas terminado tu producto, envía un Pull Request a este repositorio - (puedes solicitar apoyo de tus profes para este paso). - -> Nota: No olvides que es una buena práctica describir tu proyecto en este -> archivo `README.md` y también desplegar tu web a Github Pages :smiley:. +![eCommerce Site](https://kdangelo.github.io/ecommerce) +## Autoras +Katherine Dangelo, Makarena Fernández, Viviana Marcelo \ No newline at end of file diff --git a/assets/css/styles.css b/assets/css/styles.css new file mode 100644 index 00000000..09543daf --- /dev/null +++ b/assets/css/styles.css @@ -0,0 +1,402 @@ +body { + font-family: 'Montserrat', sans-serif; + font-size: 16px; +} + +main { + padding-top: 165px; +} + +ul { + list-style-type: none; + padding: 0; +} + +a { + color: #000; +} + +a:hover { + /*color: #9B9B9B;*/ + /*color: #4A4A4A;*/ + color: #B8B8B8; +} + +nav { + background-color: #fff!important; +} + +input { + border-radius: 0!important; + border: 1px solid #000 !important; + color: #000 !important; +} + +button { + border-radius: 0!important; +} + +/*----------------- + Header +------------------*/ +#info-bar { + font-size: 0.8rem; + background-color: #000; +} + +#main-nav { + background-color: #fff!important; +} + +.navbar-brand { + font-size: 3rem!important; + font-weight: 700; +} + +.navbar-nav { + font-size: 0.9rem; + align-items: baseline; +} + +#shoppingCart { + font-size: 1.1rem; +} + +.navbar-nav a { + color: #B8B8B8 !important; +} + +#searchForm { + border: 1px solid #000 !important; +} + +#searchBox input { + border: 1px solid transparent !important; + padding: 0 0 0 36px !important; + color: #000 !important; + width: 400px !important; + font-size: 0.8rem !important; +} + +#searchIcon { + background-color: #fff !important; + border-radius: 0 !important; + border: 1px solid transparent !important; +} + +#searchBtn { + border: 1px solid transparent !important; + border-left: 1px solid #000 !important; + font-size: 0.8rem !important; +} + +#searchBtn:hover { + background-color: #000; +} + +#shopping:hover { + color: #000; +} + +#category-bar { + font-size: 0.9rem; + font-weight: 700; +} + +/*----------------- + Footer +------------------*/ +#footer-nav { + border-top: 1px solid #E5E5E5; + border-bottom: 1px solid #E5E5E5; + font-size: 0.8rem; + text-align: right; +} + +.footerTitle { + font-size: 1rem; + font-weight: 700; +} + +#footerLinks { + font-size: 0.8rem; + border-bottom: 1px solid #E5E5E5; +} + +.footerText { + font-size: 0.9rem; +} + +.social { + font-size: 2rem; +} + +/*----------------- + Home +------------------*/ +h6 { + font-weight: 700; + font-size: 0.95rem; +} + +.thumb { + display: inline-block; + text-align: left; + font-size: 0.8rem; + font-weight: 500; +} + +.thumb img { + width: 100%; +} + +/*------------------- + All Products Page +--------------------*/ + +/* Filter Form */ + +.filters { + box-sizing: border-box; + padding: 5px 30px 30px; + width: 190px; + background-color: #FFF; + border: 1px solid #DBE3E7; + border-radius: 3px; + box-shadow: 1px 3px 1px rgba(0, 0, 0, 0.08); + position: fixed; + text-align: left; + color: #2B2E31; + opacity: 0; + pointer-events: none; +} + +.filters .filter-criteria{ + display: block; + margin: 10px 0 10px; +} + +.filters span{ + font-size:14px; + display: block; + margin-bottom: 12px; + font-weight: bold; + margin-top: 20px; +} + +.filters label{ + display: block; + line-height: 1.4; + font-size: 15px; +} + +.filters label input{ + margin-right: 10px; +} + +.filters button{ + border-radius: 2px; + background-color: #4BC34B; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12); + border: 0; + color: #ffffff; + font-weight: bold; + font-size: 13px; + cursor: pointer; + + width: 95px; + height: 32px; + margin-top: 10px; +} + + +/* Products List */ + +.all-products h3{ + opacity: 0; +} + +.products-list{ + list-style:none; + margin-left:225px; + max-width: 1500px; + text-align: center; + padding: 0; + opacity: 0; + font-size: 0; +} + +.all-products.visible .products-list, +.all-products.visible .filters, +.all-products.visible h3{ + opacity: 1; + transition: 1s; + pointer-events: auto; +} + +.products-list > li{ + box-sizing:border-box; + display: inline-block; + cursor: pointer; + position: relative; + transition: 0.2s; + + text-align:left; + font:normal 12px sans-serif; + + background-color:#ffffff; + border:1px solid #dbe3e7; + border-radius: 3px; + box-shadow: 1px 3px 1px rgba(0, 0, 0, 0.08); + + margin: 0 12px 14px 0; + padding: 25px; +} + +.products-list > li.hidden{ + opacity: 0.2; + pointer-events: none; +} + +/* The product image */ + +.products-list .product-photo{ + display: block; + text-align: center; + box-shadow : 0 0 20px 8px #f3f3f3 inset; + + width: 275px; + margin-bottom: 25px; + padding: 20px 0; + box-sizing: border-box; +} + +/* The product name */ + +.products-list h2{ + display: block; + font-size: 18px; + white-space: nowrap; + overflow: hidden; + text-overflow:ellipsis; + max-width: 200px; + margin:0; +} + +.products-list h2 a{ + text-decoration: none; + color: #2B2E31; +} + +/* Product description */ + +.products-list .product-description{ + margin-top: 20px; + + color: #5d5d5d; + font-size: 14px; + line-height: 1.45; + white-space: normal; + + max-width: 260px; + margin-bottom: 20px; + + list-style: none; +} + +.products-list .product-description li{ + display: inline-block; + margin-right: 5px; +} + +.products-list .product-description li:first-child{ + display: block; +} + +.products-list .product-description li span{ + font-weight: bold; +} + +/* Price and order button */ + +.products-list button{ + border-radius: 2px; + background-color: #87bae1; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12); + border: 0; + color: #ffffff; + font-weight: bold; + font-size: 13px; + cursor: pointer; + + width: 95px; + height: 32px; +} + +.products-list .product-price{ + float: right; + + color: #4e4e4e; + font-weight: bold; + font-size: 20px; + + padding-top: 6px; + margin: 0; +} + +.products-list .highlight{ + position: absolute; + top:0; + left:0; + width:100%; + height:100%; + background-color: rgba(0,0,0,0.1); + opacity: 0; + transition: 0.4s; +} + +.products-list > li:hover .highlight{ + opacity: 1; +} + +/* Making the list responsive */ + +@media (max-width: 800px){ + + .products-list .product-photo{ + width: 225px; + } + + .products-list .product-description{ + max-width: 225px; + } +} + + +/*--------------------------- + Single Product Page +----------------------------*/ + + + +/*--------------------------- + Error Page +----------------------------*/ + +.error{ + opacity: 0; + transition: 0.6s; + pointer-events: none; + position: absolute; + left: 0; + top: 100px; + width: 100%; +} + +.error.visible{ + opacity: 1; +} + +.error h3{ + font-size: 40px; +} \ No newline at end of file diff --git a/assets/img/app-store.svg b/assets/img/app-store.svg new file mode 100644 index 00000000..3c069030 --- /dev/null +++ b/assets/img/app-store.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/img/cam.png b/assets/img/cam.png new file mode 100644 index 00000000..195efa30 Binary files /dev/null and b/assets/img/cam.png differ diff --git a/assets/js/ML-Search.js b/assets/js/ML-Search.js new file mode 100644 index 00000000..1e364f68 --- /dev/null +++ b/assets/js/ML-Search.js @@ -0,0 +1,51 @@ +function getMLProducts(productSearch) { + // https://api.mercadolibre.com/sites/MLC/search?q=guitarra + $.get('https://api.mercadolibre.com/sites/MLC/search?q=' + productSearch, function(data) { + console.log(data); + $('#divProductsList').empty(); + $.each(data.results, function(i, products) { + var html = '
'; + html += '
'; + html += 'Responsive image'; + html += '
'; + html += '

' + products.title + '
$' + products.price + '

'; + html += '
'; + html += '
'; + html += ''; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + $('#divProductsList').append(html); + // html += ''; + // console.log(categoria.name); + }); + }); +} + +function getProductDetail(productId) { + $.get('https://api.mercadolibre.com/items/' + productId, function(data) { + console.log(data); + // $('#divProductsList').empty(); + // $.each(data, function(i, product) { + // var html=''; + // //$('#divProductsList').append(html); + // //html += ''; + // // console.log(categoria.name); + // }); + }); +} + +$(document).ready(() => { + $('.carousel').carousel(); + $('#searchForm').submit(function(event) { + if ($('#searchText').val() === '') { + alert('Debe escribir un producto a buscar'); + } else { + getMLProducts($('#searchText').val()); + $('#searchText').val(''); + } + event.preventDefault(); + }); +}); \ No newline at end of file diff --git a/assets/js/handlebars-v4.0.11.js b/assets/js/handlebars-v4.0.11.js new file mode 100644 index 00000000..81f32ee3 --- /dev/null +++ b/assets/js/handlebars-v4.0.11.js @@ -0,0 +1,6013 @@ +/** ! + + @license + handlebars v4.0.11 + +Copyright (C) 2011-2017 by Yehuda Katz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ +(function webpackUniversalModuleDefinition(root, factory) { + if (typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if (typeof define === 'function' && define.amd) + define([], factory); + else if (typeof exports === 'object') + exports['Handlebars'] = factory(); + else + root['Handlebars'] = factory(); +})(this, function() { + return /** ****/ (function(modules) { // webpackBootstrap + /** ****/ // The module cache + /** ****/ var installedModules = {}; + + /** ****/ // The require function + /** ****/ function __webpack_require__(moduleId) { + /** ****/ // Check if module is in cache + /** ****/ if (installedModules[moduleId]) + /** ****/ return installedModules[moduleId].exports; + + /** ****/ // Create a new module (and put it into the cache) + /** ****/ var module = installedModules[moduleId] = { + /** ****/ exports: {}, + /** ****/ id: moduleId, + /** ****/ loaded: false + /** ****/ }; + + /** ****/ // Execute the module function + /** ****/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + + /** ****/ // Flag the module as loaded + /** ****/ module.loaded = true; + + /** ****/ // Return the exports of the module + /** ****/ return module.exports; + /** ****/ } + + + /** ****/ // expose the modules object (__webpack_modules__) + /** ****/ __webpack_require__.m = modules; + + /** ****/ // expose the module cache + /** ****/ __webpack_require__.c = installedModules; + + /** ****/ // __webpack_public_path__ + /** ****/ __webpack_require__.p = ''; + + /** ****/ // Load entry module and return exports + /** ****/ return __webpack_require__(0); + /** ****/ }) + /** **********************************************************************/ + /** ****/ ([ + /* 0 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _handlebarsRuntime = __webpack_require__(2); + + var _handlebarsRuntime2 = _interopRequireDefault(_handlebarsRuntime); + + // Compiler imports + + var _handlebarsCompilerAst = __webpack_require__(35); + + var _handlebarsCompilerAst2 = _interopRequireDefault(_handlebarsCompilerAst); + + var _handlebarsCompilerBase = __webpack_require__(36); + + var _handlebarsCompilerCompiler = __webpack_require__(41); + + var _handlebarsCompilerJavascriptCompiler = __webpack_require__(42); + + var _handlebarsCompilerJavascriptCompiler2 = _interopRequireDefault(_handlebarsCompilerJavascriptCompiler); + + var _handlebarsCompilerVisitor = __webpack_require__(39); + + var _handlebarsCompilerVisitor2 = _interopRequireDefault(_handlebarsCompilerVisitor); + + var _handlebarsNoConflict = __webpack_require__(34); + + var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict); + + var _create = _handlebarsRuntime2['default'].create; + function create() { + var hb = _create(); + + hb.compile = function(input, options) { + return _handlebarsCompilerCompiler.compile(input, options, hb); + }; + hb.precompile = function(input, options) { + return _handlebarsCompilerCompiler.precompile(input, options, hb); + }; + + hb.AST = _handlebarsCompilerAst2['default']; + hb.Compiler = _handlebarsCompilerCompiler.Compiler; + hb.JavaScriptCompiler = _handlebarsCompilerJavascriptCompiler2['default']; + hb.Parser = _handlebarsCompilerBase.parser; + hb.parse = _handlebarsCompilerBase.parse; + + return hb; + } + + var inst = create(); + inst.create = create; + + _handlebarsNoConflict2['default'](inst); + + inst.Visitor = _handlebarsCompilerVisitor2['default']; + + inst['default'] = inst; + + exports['default'] = inst; + module.exports = exports['default']; + /** */ }), + /* 1 */ + /** */ (function(module, exports) { + 'use strict'; + + exports['default'] = function(obj) { + return obj && obj.__esModule ? obj : { + 'default': obj + }; + }; + + exports.__esModule = true; + /** */ }), + /* 2 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireWildcard = __webpack_require__(3)['default']; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _handlebarsBase = __webpack_require__(4); + + var base = _interopRequireWildcard(_handlebarsBase); + + // Each of these augment the Handlebars object. No need to setup here. + // (This is done to easily share code between commonjs and browse envs) + + var _handlebarsSafeString = __webpack_require__(21); + + var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString); + + var _handlebarsException = __webpack_require__(6); + + var _handlebarsException2 = _interopRequireDefault(_handlebarsException); + + var _handlebarsUtils = __webpack_require__(5); + + var Utils = _interopRequireWildcard(_handlebarsUtils); + + var _handlebarsRuntime = __webpack_require__(22); + + var runtime = _interopRequireWildcard(_handlebarsRuntime); + + var _handlebarsNoConflict = __webpack_require__(34); + + var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict); + + // For compatibility and usage outside of module systems, make the Handlebars object a namespace + function create() { + var hb = new base.HandlebarsEnvironment(); + + Utils.extend(hb, base); + hb.SafeString = _handlebarsSafeString2['default']; + hb.Exception = _handlebarsException2['default']; + hb.Utils = Utils; + hb.escapeExpression = Utils.escapeExpression; + + hb.VM = runtime; + hb.template = function(spec) { + return runtime.template(spec, hb); + }; + + return hb; + } + + var inst = create(); + inst.create = create; + + _handlebarsNoConflict2['default'](inst); + + inst['default'] = inst; + + exports['default'] = inst; + module.exports = exports['default']; + /** */ }), + /* 3 */ + /** */ (function(module, exports) { + 'use strict'; + + exports['default'] = function(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + + newObj['default'] = obj; + return newObj; + } + }; + + exports.__esModule = true; + /** */ }), + /* 4 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + exports.HandlebarsEnvironment = HandlebarsEnvironment; + + var _utils = __webpack_require__(5); + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + var _helpers = __webpack_require__(10); + + var _decorators = __webpack_require__(18); + + var _logger = __webpack_require__(20); + + var _logger2 = _interopRequireDefault(_logger); + + var VERSION = '4.0.11'; + exports.VERSION = VERSION; + var COMPILER_REVISION = 7; + + exports.COMPILER_REVISION = COMPILER_REVISION; + var REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '== 1.0.0-rc.4', + 4: '== 1.x.x', + 5: '== 2.0.0-alpha.x', + 6: '>= 2.0.0-beta.1', + 7: '>= 4.0.0' + }; + + exports.REVISION_CHANGES = REVISION_CHANGES; + var objectType = '[object Object]'; + + function HandlebarsEnvironment(helpers, partials, decorators) { + this.helpers = helpers || {}; + this.partials = partials || {}; + this.decorators = decorators || {}; + + _helpers.registerDefaultHelpers(this); + _decorators.registerDefaultDecorators(this); + } + + HandlebarsEnvironment.prototype = { + constructor: HandlebarsEnvironment, + + logger: _logger2['default'], + log: _logger2['default'].log, + + registerHelper: function registerHelper(name, fn) { + if (_utils.toString.call(name) === objectType) { + if (fn) { + throw new _exception2['default']('Arg not supported with multiple helpers'); + } + _utils.extend(this.helpers, name); + } else { + this.helpers[name] = fn; + } + }, + unregisterHelper: function unregisterHelper(name) { + delete this.helpers[name]; + }, + + registerPartial: function registerPartial(name, partial) { + if (_utils.toString.call(name) === objectType) { + _utils.extend(this.partials, name); + } else { + if (typeof partial === 'undefined') { + throw new _exception2['default']('Attempting to register a partial called "' + name + '" as undefined'); + } + this.partials[name] = partial; + } + }, + unregisterPartial: function unregisterPartial(name) { + delete this.partials[name]; + }, + + registerDecorator: function registerDecorator(name, fn) { + if (_utils.toString.call(name) === objectType) { + if (fn) { + throw new _exception2['default']('Arg not supported with multiple decorators'); + } + _utils.extend(this.decorators, name); + } else { + this.decorators[name] = fn; + } + }, + unregisterDecorator: function unregisterDecorator(name) { + delete this.decorators[name]; + } + }; + + var log = _logger2['default'].log; + + exports.log = log; + exports.createFrame = _utils.createFrame; + exports.logger = _logger2['default']; + /** */ }), + /* 5 */ + /** */ (function(module, exports) { + 'use strict'; + + exports.__esModule = true; + exports.extend = extend; + exports.indexOf = indexOf; + exports.escapeExpression = escapeExpression; + exports.isEmpty = isEmpty; + exports.createFrame = createFrame; + exports.blockParams = blockParams; + exports.appendContextPath = appendContextPath; + var escape = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''', + '`': '`', + '=': '=' + }; + + var badChars = /[&<>"'`=]/g, + possible = /[&<>"'`=]/; + + function escapeChar(chr) { + return escape[chr]; + } + + function extend(obj /* , ...source */) { + for (var i = 1; i < arguments.length; i++) { + for (var key in arguments[i]) { + if (Object.prototype.hasOwnProperty.call(arguments[i], key)) { + obj[key] = arguments[i][key]; + } + } + } + + return obj; + } + + var toString = Object.prototype.toString; + + exports.toString = toString; + // Sourced from lodash + // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt + /* eslint-disable func-style */ + var isFunction = function isFunction(value) { + return typeof value === 'function'; + }; + // fallback for older versions of Chrome and Safari + /* istanbul ignore next */ + if (isFunction(/x/)) { + exports.isFunction = isFunction = function(value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; + } + exports.isFunction = isFunction; + + /* eslint-enable func-style */ + + /* istanbul ignore next */ + var isArray = Array.isArray || function(value) { + return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false; + }; + + exports.isArray = isArray; + // Older IE versions do not directly support indexOf so we must implement our own, sadly. + + function indexOf(array, value) { + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + return -1; + } + + function escapeExpression(string) { + if (typeof string !== 'string') { + // don't escape SafeStrings, since they're already safe + if (string && string.toHTML) { + return string.toHTML(); + } else if (string == null) { + return ''; + } else if (!string) { + return string + ''; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = '' + string; + } + + if (!possible.test(string)) { + return string; + } + return string.replace(badChars, escapeChar); + } + + function isEmpty(value) { + if (!value && value !== 0) { + return true; + } else if (isArray(value) && value.length === 0) { + return true; + } else { + return false; + } + } + + function createFrame(object) { + var frame = extend({}, object); + frame._parent = object; + return frame; + } + + function blockParams(params, ids) { + params.path = ids; + return params; + } + + function appendContextPath(contextPath, id) { + return (contextPath ? contextPath + '.' : '') + id; + } + /** */ }), + /* 6 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _Object$defineProperty = __webpack_require__(7)['default']; + + exports.__esModule = true; + + var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + + function Exception(message, node) { + var loc = node && node.loc, + line = undefined, + column = undefined; + if (loc) { + line = loc.start.line; + column = loc.start.column; + + message += ' - ' + line + ':' + column; + } + + var tmp = Error.prototype.constructor.call(this, message); + + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; + } + + /* istanbul ignore else */ + if (Error.captureStackTrace) { + Error.captureStackTrace(this, Exception); + } + + try { + if (loc) { + this.lineNumber = line; + + // Work around issue under safari where we can't directly set the column value + /* istanbul ignore next */ + if (_Object$defineProperty) { + Object.defineProperty(this, 'column', { + value: column, + enumerable: true + }); + } else { + this.column = column; + } + } + } catch (nop) { + /* Ignore if the browser is very particular */ + } + } + + Exception.prototype = new Error(); + + exports['default'] = Exception; + module.exports = exports['default']; + /** */ }), + /* 7 */ + /** */ (function(module, exports, __webpack_require__) { + module.exports = { 'default': __webpack_require__(8), +__esModule: true }; + /** */ }), + /* 8 */ + /** */ (function(module, exports, __webpack_require__) { + var $ = __webpack_require__(9); + module.exports = function defineProperty(it, key, desc) { + return $.setDesc(it, key, desc); + }; + /** */ }), + /* 9 */ + /** */ (function(module, exports) { + var $Object = Object; + module.exports = { + create: $Object.create, + getProto: $Object.getPrototypeOf, + isEnum: {}.propertyIsEnumerable, + getDesc: $Object.getOwnPropertyDescriptor, + setDesc: $Object.defineProperty, + setDescs: $Object.defineProperties, + getKeys: $Object.keys, + getNames: $Object.getOwnPropertyNames, + getSymbols: $Object.getOwnPropertySymbols, + each: [].forEach + }; + /** */ }), + /* 10 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + exports.registerDefaultHelpers = registerDefaultHelpers; + + var _helpersBlockHelperMissing = __webpack_require__(11); + + var _helpersBlockHelperMissing2 = _interopRequireDefault(_helpersBlockHelperMissing); + + var _helpersEach = __webpack_require__(12); + + var _helpersEach2 = _interopRequireDefault(_helpersEach); + + var _helpersHelperMissing = __webpack_require__(13); + + var _helpersHelperMissing2 = _interopRequireDefault(_helpersHelperMissing); + + var _helpersIf = __webpack_require__(14); + + var _helpersIf2 = _interopRequireDefault(_helpersIf); + + var _helpersLog = __webpack_require__(15); + + var _helpersLog2 = _interopRequireDefault(_helpersLog); + + var _helpersLookup = __webpack_require__(16); + + var _helpersLookup2 = _interopRequireDefault(_helpersLookup); + + var _helpersWith = __webpack_require__(17); + + var _helpersWith2 = _interopRequireDefault(_helpersWith); + + function registerDefaultHelpers(instance) { + _helpersBlockHelperMissing2['default'](instance); + _helpersEach2['default'](instance); + _helpersHelperMissing2['default'](instance); + _helpersIf2['default'](instance); + _helpersLog2['default'](instance); + _helpersLookup2['default'](instance); + _helpersWith2['default'](instance); + } + /** */ }), + /* 11 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + exports['default'] = function(instance) { + instance.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse, + fn = options.fn; + + if (context === true) { + return fn(this); + } else if (context === false || context == null) { + return inverse(this); + } else if (_utils.isArray(context)) { + if (context.length > 0) { + if (options.ids) { + options.ids = [options.name]; + } + + return instance.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + if (options.data && options.ids) { + var data = _utils.createFrame(options.data); + data.contextPath = _utils.appendContextPath(options.data.contextPath, options.name); + options = { data: data }; + } + + return fn(context, options); + } + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 12 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + exports['default'] = function(instance) { + instance.registerHelper('each', function(context, options) { + if (!options) { + throw new _exception2['default']('Must pass iterator to #each'); + } + + var fn = options.fn, + inverse = options.inverse, + i = 0, + ret = '', + data = undefined, + contextPath = undefined; + + if (options.data && options.ids) { + contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.'; + } + + if (_utils.isFunction(context)) { + context = context.call(this); + } + + if (options.data) { + data = _utils.createFrame(options.data); + } + + function execIteration(field, index, last) { + if (data) { + data.key = field; + data.index = index; + data.first = index === 0; + data.last = !!last; + + if (contextPath) { + data.contextPath = contextPath + field; + } + } + + ret = ret + fn(context[field], { + data: data, + blockParams: _utils.blockParams([context[field], field], [contextPath + field, null]) + }); + } + + if (context && typeof context === 'object') { + if (_utils.isArray(context)) { + for (var j = context.length; i < j; i++) { + if (i in context) { + execIteration(i, i, i === context.length - 1); + } + } + } else { + var priorKey = undefined; + + for (var key in context) { + if (context.hasOwnProperty(key)) { + // We're running the iterations one step out of sync so we can detect + // the last iteration without have to scan the object twice and create + // an itermediate keys array. + if (priorKey !== undefined) { + execIteration(priorKey, i - 1); + } + priorKey = key; + i++; + } + } + if (priorKey !== undefined) { + execIteration(priorKey, i - 1, true); + } + } + } + + if (i === 0) { + ret = inverse(this); + } + + return ret; + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 13 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + exports['default'] = function(instance) { + instance.registerHelper('helperMissing', function() /* [args, ]options */{ + if (arguments.length === 1) { + // A missing field in a {{foo}} construct. + return undefined; + } else { + // Someone is actually trying to call something, blow up. + throw new _exception2['default']('Missing helper: "' + arguments[arguments.length - 1].name + '"'); + } + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 14 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + exports['default'] = function(instance) { + instance.registerHelper('if', function(conditional, options) { + if (_utils.isFunction(conditional)) { + conditional = conditional.call(this); + } + + // Default behavior is to render the positive path if the value is truthy and not empty. + // The `includeZero` option may be set to treat the condtional as purely not empty based on the + // behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative. + if (!options.hash.includeZero && !conditional || _utils.isEmpty(conditional)) { + return options.inverse(this); + } else { + return options.fn(this); + } + }); + + instance.registerHelper('unless', function(conditional, options) { + return instance.helpers['if'].call(this, conditional, { fn: options.inverse, +inverse: options.fn, +hash: options.hash }); + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 15 */ + /** */ (function(module, exports) { + 'use strict'; + + exports.__esModule = true; + + exports['default'] = function(instance) { + instance.registerHelper('log', function() /* message, options */{ + var args = [undefined], + options = arguments[arguments.length - 1]; + for (var i = 0; i < arguments.length - 1; i++) { + args.push(arguments[i]); + } + + var level = 1; + if (options.hash.level != null) { + level = options.hash.level; + } else if (options.data && options.data.level != null) { + level = options.data.level; + } + args[0] = level; + + instance.log.apply(instance, args); + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 16 */ + /** */ (function(module, exports) { + 'use strict'; + + exports.__esModule = true; + + exports['default'] = function(instance) { + instance.registerHelper('lookup', function(obj, field) { + return obj && obj[field]; + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 17 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + exports['default'] = function(instance) { + instance.registerHelper('with', function(context, options) { + if (_utils.isFunction(context)) { + context = context.call(this); + } + + var fn = options.fn; + + if (!_utils.isEmpty(context)) { + var data = options.data; + if (options.data && options.ids) { + data = _utils.createFrame(options.data); + data.contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]); + } + + return fn(context, { + data: data, + blockParams: _utils.blockParams([context], [data && data.contextPath]) + }); + } else { + return options.inverse(this); + } + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 18 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + exports.registerDefaultDecorators = registerDefaultDecorators; + + var _decoratorsInline = __webpack_require__(19); + + var _decoratorsInline2 = _interopRequireDefault(_decoratorsInline); + + function registerDefaultDecorators(instance) { + _decoratorsInline2['default'](instance); + } + /** */ }), + /* 19 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + exports['default'] = function(instance) { + instance.registerDecorator('inline', function(fn, props, container, options) { + var ret = fn; + if (!props.partials) { + props.partials = {}; + ret = function(context, options) { + // Create a new partials stack frame prior to exec. + var original = container.partials; + container.partials = _utils.extend({}, original, props.partials); + var ret = fn(context, options); + container.partials = original; + return ret; + }; + } + + props.partials[options.args[0]] = options.fn; + + return ret; + }); + }; + + module.exports = exports['default']; + /** */ }), + /* 20 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + var logger = { + methodMap: ['debug', 'info', 'warn', 'error'], + level: 'info', + + // Maps a given level value to the `methodMap` indexes above. + lookupLevel: function lookupLevel(level) { + if (typeof level === 'string') { + var levelMap = _utils.indexOf(logger.methodMap, level.toLowerCase()); + if (levelMap >= 0) { + level = levelMap; + } else { + level = parseInt(level, 10); + } + } + + return level; + }, + + // Can be overridden in the host environment + log: function log(level) { + level = logger.lookupLevel(level); + + if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) { + var method = logger.methodMap[level]; + if (!console[method]) { + // eslint-disable-line no-console + method = 'log'; + } + + for (var _len = arguments.length, message = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + message[_key - 1] = arguments[_key]; + } + + console[method].apply(console, message); // eslint-disable-line no-console + } + } + }; + + exports['default'] = logger; + module.exports = exports['default']; + /** */ }), + /* 21 */ + /** */ (function(module, exports) { + // Build out our basic SafeString type + 'use strict'; + + exports.__esModule = true; + function SafeString(string) { + this.string = string; + } + + SafeString.prototype.toString = SafeString.prototype.toHTML = function() { + return '' + this.string; + }; + + exports['default'] = SafeString; + module.exports = exports['default']; + /** */ }), + /* 22 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _Object$seal = __webpack_require__(23)['default']; + + var _interopRequireWildcard = __webpack_require__(3)['default']; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + exports.checkRevision = checkRevision; + exports.template = template; + exports.wrapProgram = wrapProgram; + exports.resolvePartial = resolvePartial; + exports.invokePartial = invokePartial; + exports.noop = noop; + + var _utils = __webpack_require__(5); + + var Utils = _interopRequireWildcard(_utils); + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + var _base = __webpack_require__(4); + + function checkRevision(compilerInfo) { + var compilerRevision = compilerInfo && compilerInfo[0] || 1, + currentRevision = _base.COMPILER_REVISION; + + if (compilerRevision !== currentRevision) { + if (compilerRevision < currentRevision) { + var runtimeVersions = _base.REVISION_CHANGES[currentRevision], + compilerVersions = _base.REVISION_CHANGES[compilerRevision]; + throw new _exception2['default']('Template was precompiled with an older version of Handlebars than the current runtime. ' + 'Please update your precompiler to a newer version (' + runtimeVersions + ') or downgrade your runtime to an older version (' + compilerVersions + ').'); + } else { + // Use the embedded version info since the runtime doesn't know about this revision yet + throw new _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').'); + } + } + } + + function template(templateSpec, env) { + /* istanbul ignore next */ + if (!env) { + throw new _exception2['default']('No environment passed to template'); + } + if (!templateSpec || !templateSpec.main) { + throw new _exception2['default']('Unknown template object: ' + typeof templateSpec); + } + + templateSpec.main.decorator = templateSpec.main_d; + + // Note: Using env.VM references rather than local var references throughout this section to allow + // for external users to override these as psuedo-supported APIs. + env.VM.checkRevision(templateSpec.compiler); + + function invokePartialWrapper(partial, context, options) { + if (options.hash) { + context = Utils.extend({}, context, options.hash); + if (options.ids) { + options.ids[0] = true; + } + } + + partial = env.VM.resolvePartial.call(this, partial, context, options); + var result = env.VM.invokePartial.call(this, partial, context, options); + + if (result == null && env.compile) { + options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env); + result = options.partials[options.name](context, options); + } + if (result != null) { + if (options.indent) { + var lines = result.split('\n'); + for (var i = 0, l = lines.length; i < l; i++) { + if (!lines[i] && i + 1 === l) { + break; + } + + lines[i] = options.indent + lines[i]; + } + result = lines.join('\n'); + } + return result; + } else { + throw new _exception2['default']('The partial ' + options.name + ' could not be compiled when running in runtime-only mode'); + } + } + + // Just add water + var container = { + strict: function strict(obj, name) { + if (!(name in obj)) { + throw new _exception2['default']('"' + name + '" not defined in ' + obj); + } + return obj[name]; + }, + lookup: function lookup(depths, name) { + var len = depths.length; + for (var i = 0; i < len; i++) { + if (depths[i] && depths[i][name] != null) { + return depths[i][name]; + } + } + }, + lambda: function lambda(current, context) { + return typeof current === 'function' ? current.call(context) : current; + }, + + escapeExpression: Utils.escapeExpression, + invokePartial: invokePartialWrapper, + + fn: function fn(i) { + var ret = templateSpec[i]; + ret.decorator = templateSpec[i + '_d']; + return ret; + }, + + programs: [], + program: function program(i, data, declaredBlockParams, blockParams, depths) { + var programWrapper = this.programs[i], + fn = this.fn(i); + if (data || depths || blockParams || declaredBlockParams) { + programWrapper = wrapProgram(this, i, fn, data, declaredBlockParams, blockParams, depths); + } else if (!programWrapper) { + programWrapper = this.programs[i] = wrapProgram(this, i, fn); + } + return programWrapper; + }, + + data: function data(value, depth) { + while (value && depth--) { + value = value._parent; + } + return value; + }, + merge: function merge(param, common) { + var obj = param || common; + + if (param && common && param !== common) { + obj = Utils.extend({}, common, param); + } + + return obj; + }, + // An empty object to use as replacement for null-contexts + nullContext: _Object$seal({}), + + noop: env.VM.noop, + compilerInfo: templateSpec.compiler + }; + + function ret(context) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var data = options.data; + + ret._setup(options); + if (!options.partial && templateSpec.useData) { + data = initData(context, data); + } + var depths = undefined, + blockParams = templateSpec.useBlockParams ? [] : undefined; + if (templateSpec.useDepths) { + if (options.depths) { + depths = context != options.depths[0] ? [context].concat(options.depths) : options.depths; + } else { + depths = [context]; + } + } + + function main(context /* , options*/) { + return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths); + } + main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); + return main(context, options); + } + ret.isTop = true; + + ret._setup = function(options) { + if (!options.partial) { + container.helpers = container.merge(options.helpers, env.helpers); + + if (templateSpec.usePartial) { + container.partials = container.merge(options.partials, env.partials); + } + if (templateSpec.usePartial || templateSpec.useDecorators) { + container.decorators = container.merge(options.decorators, env.decorators); + } + } else { + container.helpers = options.helpers; + container.partials = options.partials; + container.decorators = options.decorators; + } + }; + + ret._child = function(i, data, blockParams, depths) { + if (templateSpec.useBlockParams && !blockParams) { + throw new _exception2['default']('must pass block params'); + } + if (templateSpec.useDepths && !depths) { + throw new _exception2['default']('must pass parent depths'); + } + + return wrapProgram(container, i, templateSpec[i], data, 0, blockParams, depths); + }; + return ret; + } + + function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) { + function prog(context) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var currentDepths = depths; + if (depths && context != depths[0] && !(context === container.nullContext && depths[0] === null)) { + currentDepths = [context].concat(depths); + } + + return fn(container, context, container.helpers, container.partials, options.data || data, blockParams && [options.blockParams].concat(blockParams), currentDepths); + } + + prog = executeDecorators(fn, prog, container, depths, data, blockParams); + + prog.program = i; + prog.depth = depths ? depths.length : 0; + prog.blockParams = declaredBlockParams || 0; + return prog; + } + + function resolvePartial(partial, context, options) { + if (!partial) { + if (options.name === '@partial-block') { + partial = options.data['partial-block']; + } else { + partial = options.partials[options.name]; + } + } else if (!partial.call && !options.name) { + // This is a dynamic partial that returned a string + options.name = partial; + partial = options.partials[partial]; + } + return partial; + } + + function invokePartial(partial, context, options) { + // Use the current closure context to save the partial-block if this partial + var currentPartialBlock = options.data && options.data['partial-block']; + options.partial = true; + if (options.ids) { + options.data.contextPath = options.ids[0] || options.data.contextPath; + } + + var partialBlock = undefined; + if (options.fn && options.fn !== noop) { + (function() { + options.data = _base.createFrame(options.data); + // Wrapper function to get access to currentPartialBlock from the closure + var fn = options.fn; + partialBlock = options.data['partial-block'] = function partialBlockWrapper(context) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + // Restore the partial-block from the closure for the execution of the block + // i.e. the part inside the block of the partial call. + options.data = _base.createFrame(options.data); + options.data['partial-block'] = currentPartialBlock; + return fn(context, options); + }; + if (fn.partials) { + options.partials = Utils.extend({}, options.partials, fn.partials); + } + })(); + } + + if (partial === undefined && partialBlock) { + partial = partialBlock; + } + + if (partial === undefined) { + throw new _exception2['default']('The partial ' + options.name + ' could not be found'); + } else if (partial instanceof Function) { + return partial(context, options); + } + } + + function noop() { + return ''; + } + + function initData(context, data) { + if (!data || !('root' in data)) { + data = data ? _base.createFrame(data) : {}; + data.root = context; + } + return data; + } + + function executeDecorators(fn, prog, container, depths, data, blockParams) { + if (fn.decorator) { + var props = {}; + prog = fn.decorator(prog, props, container, depths && depths[0], data, blockParams, depths); + Utils.extend(prog, props); + } + return prog; + } + /** */ }), + /* 23 */ + /** */ (function(module, exports, __webpack_require__) { + module.exports = { 'default': __webpack_require__(24), +__esModule: true }; + /** */ }), + /* 24 */ + /** */ (function(module, exports, __webpack_require__) { + __webpack_require__(25); + module.exports = __webpack_require__(30).Object.seal; + /** */ }), + /* 25 */ + /** */ (function(module, exports, __webpack_require__) { + // 19.1.2.17 Object.seal(O) + var isObject = __webpack_require__(26); + + __webpack_require__(27)('seal', function($seal) { + return function seal(it) { + return $seal && isObject(it) ? $seal(it) : it; + }; + }); + /** */ }), + /* 26 */ + /** */ (function(module, exports) { + module.exports = function(it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + /** */ }), + /* 27 */ + /** */ (function(module, exports, __webpack_require__) { + // most Object methods by ES6 should accept primitives + var $export = __webpack_require__(28) + , core = __webpack_require__(30) + , fails = __webpack_require__(33); + module.exports = function(KEY, exec) { + var fn = (core.Object || {})[KEY] || Object[KEY] + , exp = {}; + exp[KEY] = exec(fn); + $export($export.S + $export.F * fails(function() { + fn(1); +}), 'Object', exp); + }; + /** */ }), + /* 28 */ + /** */ (function(module, exports, __webpack_require__) { + var global = __webpack_require__(29) + , core = __webpack_require__(30) + , ctx = __webpack_require__(31) + , PROTOTYPE = 'prototype'; + + var $export = function(type, name, source) { + var IS_FORCED = type & $export.F + , IS_GLOBAL = type & $export.G + , IS_STATIC = type & $export.S + , IS_PROTO = type & $export.P + , IS_BIND = type & $export.B + , IS_WRAP = type & $export.W + , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] + , key, own, out; + if (IS_GLOBAL)source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && key in target; + if (own && key in exports) continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] !== 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? ctx(out, global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function(C) { + var F = function(param) { + return this instanceof C ? new C(param) : C(param); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out === 'function' ? ctx(Function.call, out) : out; + if (IS_PROTO)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; + } + }; + // type bitmap + $export.F = 1; // forced + $export.G = 2; // global + $export.S = 4; // static + $export.P = 8; // proto + $export.B = 16; // bind + $export.W = 32; // wrap + module.exports = $export; + /** */ }), + /* 29 */ + /** */ (function(module, exports) { + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window !== 'undefined' && window.Math == Math + ? window : typeof self !== 'undefined' && self.Math == Math ? self : Function('return this')(); + if (typeof __g === 'number')__g = global; // eslint-disable-line no-undef + /** */ }), + /* 30 */ + /** */ (function(module, exports) { + var core = module.exports = {version: '1.2.6'}; + if (typeof __e === 'number')__e = core; // eslint-disable-line no-undef + /** */ }), + /* 31 */ + /** */ (function(module, exports, __webpack_require__) { + // optional / simple context binding + var aFunction = __webpack_require__(32); + module.exports = function(fn, that, length) { + aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function(a) { + return fn.call(that, a); + }; + case 2: return function(a, b) { + return fn.call(that, a, b); + }; + case 3: return function(a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function(/* ...args */) { + return fn.apply(that, arguments); + }; + }; + /** */ }), + /* 32 */ + /** */ (function(module, exports) { + module.exports = function(it) { + if (typeof it !== 'function') throw TypeError(it + ' is not a function!'); + return it; + }; + /** */ }), + /* 33 */ + /** */ (function(module, exports) { + module.exports = function(exec) { + try { + return !!exec(); + } catch (e) { + return true; + } + }; + /** */ }), + /* 34 */ + /** */ (function(module, exports) { + /* WEBPACK VAR INJECTION */(function(global) {/* global window */ + 'use strict'; + + exports.__esModule = true; + + exports['default'] = function(Handlebars) { + /* istanbul ignore next */ + var root = typeof global !== 'undefined' ? global : window, + $Handlebars = root.Handlebars; + /* istanbul ignore next */ + Handlebars.noConflict = function() { + if (root.Handlebars === Handlebars) { + root.Handlebars = $Handlebars; + } + return Handlebars; + }; + }; + + module.exports = exports['default']; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { + return this; +}()))); + /** */ }), + /* 35 */ + /** */ (function(module, exports) { + 'use strict'; + + exports.__esModule = true; + var AST = { + // Public API used to evaluate derived attributes regarding AST nodes + helpers: { + // a mustache is definitely a helper if: + // * it is an eligible helper, and + // * it has at least one parameter or hash segment + helperExpression: function helperExpression(node) { + return node.type === 'SubExpression' || (node.type === 'MustacheStatement' || node.type === 'BlockStatement') && !!(node.params && node.params.length || node.hash); + }, + + scopedId: function scopedId(path) { + return (/^\.|this\b/.test(path.original) + ); + }, + + // an ID is simple if it only has one part, and that part is not + // `..` or `this`. + simpleId: function simpleId(path) { + return path.parts.length === 1 && !AST.helpers.scopedId(path) && !path.depth; + } + } + }; + + // Must be exported as an object rather than the root of the module as the jison lexer + // must modify the object to operate properly. + exports['default'] = AST; + module.exports = exports['default']; + /** */ }), + /* 36 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + var _interopRequireWildcard = __webpack_require__(3)['default']; + + exports.__esModule = true; + exports.parse = parse; + + var _parser = __webpack_require__(37); + + var _parser2 = _interopRequireDefault(_parser); + + var _whitespaceControl = __webpack_require__(38); + + var _whitespaceControl2 = _interopRequireDefault(_whitespaceControl); + + var _helpers = __webpack_require__(40); + + var Helpers = _interopRequireWildcard(_helpers); + + var _utils = __webpack_require__(5); + + exports.parser = _parser2['default']; + + var yy = {}; + _utils.extend(yy, Helpers); + + function parse(input, options) { + // Just return if an already-compiled AST was passed in. + if (input.type === 'Program') { + return input; + } + + _parser2['default'].yy = yy; + + // Altering the shared object here, but this is ok as parser is a sync operation + yy.locInfo = function(locInfo) { + return new yy.SourceLocation(options && options.srcName, locInfo); + }; + + var strip = new _whitespaceControl2['default'](options); + return strip.accept(_parser2['default'].parse(input)); + } + /** */ }), + /* 37 */ + /** */ (function(module, exports) { + // File ignored in coverage tests via setting in .istanbul.yml + /* Jison generated parser */ + 'use strict'; + + exports.__esModule = true; + var handlebars = (function() { + var parser = { trace: function trace() {}, + yy: {}, + symbols_: { 'error': 2, +'root': 3, +'program': 4, +'EOF': 5, +'program_repetition0': 6, +'statement': 7, +'mustache': 8, +'block': 9, +'rawBlock': 10, +'partial': 11, +'partialBlock': 12, +'content': 13, +'COMMENT': 14, +'CONTENT': 15, +'openRawBlock': 16, +'rawBlock_repetition_plus0': 17, +'END_RAW_BLOCK': 18, +'OPEN_RAW_BLOCK': 19, +'helperName': 20, +'openRawBlock_repetition0': 21, +'openRawBlock_option0': 22, +'CLOSE_RAW_BLOCK': 23, +'openBlock': 24, +'block_option0': 25, +'closeBlock': 26, +'openInverse': 27, +'block_option1': 28, +'OPEN_BLOCK': 29, +'openBlock_repetition0': 30, +'openBlock_option0': 31, +'openBlock_option1': 32, +'CLOSE': 33, +'OPEN_INVERSE': 34, +'openInverse_repetition0': 35, +'openInverse_option0': 36, +'openInverse_option1': 37, +'openInverseChain': 38, +'OPEN_INVERSE_CHAIN': 39, +'openInverseChain_repetition0': 40, +'openInverseChain_option0': 41, +'openInverseChain_option1': 42, +'inverseAndProgram': 43, +'INVERSE': 44, +'inverseChain': 45, +'inverseChain_option0': 46, +'OPEN_ENDBLOCK': 47, +'OPEN': 48, +'mustache_repetition0': 49, +'mustache_option0': 50, +'OPEN_UNESCAPED': 51, +'mustache_repetition1': 52, +'mustache_option1': 53, +'CLOSE_UNESCAPED': 54, +'OPEN_PARTIAL': 55, +'partialName': 56, +'partial_repetition0': 57, +'partial_option0': 58, +'openPartialBlock': 59, +'OPEN_PARTIAL_BLOCK': 60, +'openPartialBlock_repetition0': 61, +'openPartialBlock_option0': 62, +'param': 63, +'sexpr': 64, +'OPEN_SEXPR': 65, +'sexpr_repetition0': 66, +'sexpr_option0': 67, +'CLOSE_SEXPR': 68, +'hash': 69, +'hash_repetition_plus0': 70, +'hashSegment': 71, +'ID': 72, +'EQUALS': 73, +'blockParams': 74, +'OPEN_BLOCK_PARAMS': 75, +'blockParams_repetition_plus0': 76, +'CLOSE_BLOCK_PARAMS': 77, +'path': 78, +'dataName': 79, +'STRING': 80, +'NUMBER': 81, +'BOOLEAN': 82, +'UNDEFINED': 83, +'NULL': 84, +'DATA': 85, +'pathSegments': 86, +'SEP': 87, +'$accept': 0, +'$end': 1 }, + terminals_: { 2: 'error', +5: 'EOF', +14: 'COMMENT', +15: 'CONTENT', +18: 'END_RAW_BLOCK', +19: 'OPEN_RAW_BLOCK', +23: 'CLOSE_RAW_BLOCK', +29: 'OPEN_BLOCK', +33: 'CLOSE', +34: 'OPEN_INVERSE', +39: 'OPEN_INVERSE_CHAIN', +44: 'INVERSE', +47: 'OPEN_ENDBLOCK', +48: 'OPEN', +51: 'OPEN_UNESCAPED', +54: 'CLOSE_UNESCAPED', +55: 'OPEN_PARTIAL', +60: 'OPEN_PARTIAL_BLOCK', +65: 'OPEN_SEXPR', +68: 'CLOSE_SEXPR', +72: 'ID', +73: 'EQUALS', +75: 'OPEN_BLOCK_PARAMS', +77: 'CLOSE_BLOCK_PARAMS', +80: 'STRING', +81: 'NUMBER', +82: 'BOOLEAN', +83: 'UNDEFINED', +84: 'NULL', +85: 'DATA', +87: 'SEP' }, + productions_: [0, [3, 2], [4, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [13, 1], [10, 3], [16, 5], [9, 4], [9, 4], [24, 6], [27, 6], [38, 6], [43, 2], [45, 3], [45, 1], [26, 3], [8, 5], [8, 5], [11, 5], [12, 3], [59, 5], [63, 1], [63, 1], [64, 5], [69, 1], [71, 3], [74, 3], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [56, 1], [56, 1], [79, 2], [78, 1], [86, 3], [86, 1], [6, 0], [6, 2], [17, 1], [17, 2], [21, 0], [21, 2], [22, 0], [22, 1], [25, 0], [25, 1], [28, 0], [28, 1], [30, 0], [30, 2], [31, 0], [31, 1], [32, 0], [32, 1], [35, 0], [35, 2], [36, 0], [36, 1], [37, 0], [37, 1], [40, 0], [40, 2], [41, 0], [41, 1], [42, 0], [42, 1], [46, 0], [46, 1], [49, 0], [49, 2], [50, 0], [50, 1], [52, 0], [52, 2], [53, 0], [53, 1], [57, 0], [57, 2], [58, 0], [58, 1], [61, 0], [61, 2], [62, 0], [62, 1], [66, 0], [66, 2], [67, 0], [67, 1], [70, 1], [70, 2], [76, 1], [76, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$ + /**/) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + break; + case 2: + this.$ = yy.prepareProgram($$[$0]); + break; + case 3: + this.$ = $$[$0]; + break; + case 4: + this.$ = $$[$0]; + break; + case 5: + this.$ = $$[$0]; + break; + case 6: + this.$ = $$[$0]; + break; + case 7: + this.$ = $$[$0]; + break; + case 8: + this.$ = $$[$0]; + break; + case 9: + this.$ = { + type: 'CommentStatement', + value: yy.stripComment($$[$0]), + strip: yy.stripFlags($$[$0], $$[$0]), + loc: yy.locInfo(this._$) + }; + + break; + case 10: + this.$ = { + type: 'ContentStatement', + original: $$[$0], + value: $$[$0], + loc: yy.locInfo(this._$) + }; + + break; + case 11: + this.$ = yy.prepareRawBlock($$[$0 - 2], $$[$0 - 1], $$[$0], this._$); + break; + case 12: + this.$ = { path: $$[$0 - 3], +params: $$[$0 - 2], +hash: $$[$0 - 1] }; + break; + case 13: + this.$ = yy.prepareBlock($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0], false, this._$); + break; + case 14: + this.$ = yy.prepareBlock($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0], true, this._$); + break; + case 15: + this.$ = { open: $$[$0 - 5], +path: $$[$0 - 4], +params: $$[$0 - 3], +hash: $$[$0 - 2], +blockParams: $$[$0 - 1], +strip: yy.stripFlags($$[$0 - 5], $$[$0]) }; + break; + case 16: + this.$ = { path: $$[$0 - 4], +params: $$[$0 - 3], +hash: $$[$0 - 2], +blockParams: $$[$0 - 1], +strip: yy.stripFlags($$[$0 - 5], $$[$0]) }; + break; + case 17: + this.$ = { path: $$[$0 - 4], +params: $$[$0 - 3], +hash: $$[$0 - 2], +blockParams: $$[$0 - 1], +strip: yy.stripFlags($$[$0 - 5], $$[$0]) }; + break; + case 18: + this.$ = { strip: yy.stripFlags($$[$0 - 1], $$[$0 - 1]), +program: $$[$0] }; + break; + case 19: + var inverse = yy.prepareBlock($$[$0 - 2], $$[$0 - 1], $$[$0], $$[$0], false, this._$), + program = yy.prepareProgram([inverse], $$[$0 - 1].loc); + program.chained = true; + + this.$ = { strip: $$[$0 - 2].strip, +program: program, +chain: true }; + + break; + case 20: + this.$ = $$[$0]; + break; + case 21: + this.$ = { path: $$[$0 - 1], +strip: yy.stripFlags($$[$0 - 2], $$[$0]) }; + break; + case 22: + this.$ = yy.prepareMustache($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0 - 4], yy.stripFlags($$[$0 - 4], $$[$0]), this._$); + break; + case 23: + this.$ = yy.prepareMustache($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0 - 4], yy.stripFlags($$[$0 - 4], $$[$0]), this._$); + break; + case 24: + this.$ = { + type: 'PartialStatement', + name: $$[$0 - 3], + params: $$[$0 - 2], + hash: $$[$0 - 1], + indent: '', + strip: yy.stripFlags($$[$0 - 4], $$[$0]), + loc: yy.locInfo(this._$) + }; + + break; + case 25: + this.$ = yy.preparePartialBlock($$[$0 - 2], $$[$0 - 1], $$[$0], this._$); + break; + case 26: + this.$ = { path: $$[$0 - 3], +params: $$[$0 - 2], +hash: $$[$0 - 1], +strip: yy.stripFlags($$[$0 - 4], $$[$0]) }; + break; + case 27: + this.$ = $$[$0]; + break; + case 28: + this.$ = $$[$0]; + break; + case 29: + this.$ = { + type: 'SubExpression', + path: $$[$0 - 3], + params: $$[$0 - 2], + hash: $$[$0 - 1], + loc: yy.locInfo(this._$) + }; + + break; + case 30: + this.$ = { type: 'Hash', +pairs: $$[$0], +loc: yy.locInfo(this._$) }; + break; + case 31: + this.$ = { type: 'HashPair', +key: yy.id($$[$0 - 2]), +value: $$[$0], +loc: yy.locInfo(this._$) }; + break; + case 32: + this.$ = yy.id($$[$0 - 1]); + break; + case 33: + this.$ = $$[$0]; + break; + case 34: + this.$ = $$[$0]; + break; + case 35: + this.$ = { type: 'StringLiteral', +value: $$[$0], +original: $$[$0], +loc: yy.locInfo(this._$) }; + break; + case 36: + this.$ = { type: 'NumberLiteral', +value: Number($$[$0]), +original: Number($$[$0]), +loc: yy.locInfo(this._$) }; + break; + case 37: + this.$ = { type: 'BooleanLiteral', +value: $$[$0] === 'true', +original: $$[$0] === 'true', +loc: yy.locInfo(this._$) }; + break; + case 38: + this.$ = { type: 'UndefinedLiteral', +original: undefined, +value: undefined, +loc: yy.locInfo(this._$) }; + break; + case 39: + this.$ = { type: 'NullLiteral', +original: null, +value: null, +loc: yy.locInfo(this._$) }; + break; + case 40: + this.$ = $$[$0]; + break; + case 41: + this.$ = $$[$0]; + break; + case 42: + this.$ = yy.preparePath(true, $$[$0], this._$); + break; + case 43: + this.$ = yy.preparePath(false, $$[$0], this._$); + break; + case 44: + $$[$0 - 2].push({ part: yy.id($$[$0]), +original: $$[$0], +separator: $$[$0 - 1] });this.$ = $$[$0 - 2]; + break; + case 45: + this.$ = [{ part: yy.id($$[$0]), +original: $$[$0] }]; + break; + case 46: + this.$ = []; + break; + case 47: + $$[$0 - 1].push($$[$0]); + break; + case 48: + this.$ = [$$[$0]]; + break; + case 49: + $$[$0 - 1].push($$[$0]); + break; + case 50: + this.$ = []; + break; + case 51: + $$[$0 - 1].push($$[$0]); + break; + case 58: + this.$ = []; + break; + case 59: + $$[$0 - 1].push($$[$0]); + break; + case 64: + this.$ = []; + break; + case 65: + $$[$0 - 1].push($$[$0]); + break; + case 70: + this.$ = []; + break; + case 71: + $$[$0 - 1].push($$[$0]); + break; + case 78: + this.$ = []; + break; + case 79: + $$[$0 - 1].push($$[$0]); + break; + case 82: + this.$ = []; + break; + case 83: + $$[$0 - 1].push($$[$0]); + break; + case 86: + this.$ = []; + break; + case 87: + $$[$0 - 1].push($$[$0]); + break; + case 90: + this.$ = []; + break; + case 91: + $$[$0 - 1].push($$[$0]); + break; + case 94: + this.$ = []; + break; + case 95: + $$[$0 - 1].push($$[$0]); + break; + case 98: + this.$ = [$$[$0]]; + break; + case 99: + $$[$0 - 1].push($$[$0]); + break; + case 100: + this.$ = [$$[$0]]; + break; + case 101: + $$[$0 - 1].push($$[$0]); + break; + } + }, + table: [{ 3: 1, +4: 2, +5: [2, 46], +6: 3, +14: [2, 46], +15: [2, 46], +19: [2, 46], +29: [2, 46], +34: [2, 46], +48: [2, 46], +51: [2, 46], +55: [2, 46], +60: [2, 46] }, { 1: [3] }, { 5: [1, 4] }, { 5: [2, 2], +7: 5, +8: 6, +9: 7, +10: 8, +11: 9, +12: 10, +13: 11, +14: [1, 12], +15: [1, 20], +16: 17, +19: [1, 23], +24: 15, +27: 16, +29: [1, 21], +34: [1, 22], +39: [2, 2], +44: [2, 2], +47: [2, 2], +48: [1, 13], +51: [1, 14], +55: [1, 18], +59: 19, +60: [1, 24] }, { 1: [2, 1] }, { 5: [2, 47], +14: [2, 47], +15: [2, 47], +19: [2, 47], +29: [2, 47], +34: [2, 47], +39: [2, 47], +44: [2, 47], +47: [2, 47], +48: [2, 47], +51: [2, 47], +55: [2, 47], +60: [2, 47] }, { 5: [2, 3], +14: [2, 3], +15: [2, 3], +19: [2, 3], +29: [2, 3], +34: [2, 3], +39: [2, 3], +44: [2, 3], +47: [2, 3], +48: [2, 3], +51: [2, 3], +55: [2, 3], +60: [2, 3] }, { 5: [2, 4], +14: [2, 4], +15: [2, 4], +19: [2, 4], +29: [2, 4], +34: [2, 4], +39: [2, 4], +44: [2, 4], +47: [2, 4], +48: [2, 4], +51: [2, 4], +55: [2, 4], +60: [2, 4] }, { 5: [2, 5], +14: [2, 5], +15: [2, 5], +19: [2, 5], +29: [2, 5], +34: [2, 5], +39: [2, 5], +44: [2, 5], +47: [2, 5], +48: [2, 5], +51: [2, 5], +55: [2, 5], +60: [2, 5] }, { 5: [2, 6], +14: [2, 6], +15: [2, 6], +19: [2, 6], +29: [2, 6], +34: [2, 6], +39: [2, 6], +44: [2, 6], +47: [2, 6], +48: [2, 6], +51: [2, 6], +55: [2, 6], +60: [2, 6] }, { 5: [2, 7], +14: [2, 7], +15: [2, 7], +19: [2, 7], +29: [2, 7], +34: [2, 7], +39: [2, 7], +44: [2, 7], +47: [2, 7], +48: [2, 7], +51: [2, 7], +55: [2, 7], +60: [2, 7] }, { 5: [2, 8], +14: [2, 8], +15: [2, 8], +19: [2, 8], +29: [2, 8], +34: [2, 8], +39: [2, 8], +44: [2, 8], +47: [2, 8], +48: [2, 8], +51: [2, 8], +55: [2, 8], +60: [2, 8] }, { 5: [2, 9], +14: [2, 9], +15: [2, 9], +19: [2, 9], +29: [2, 9], +34: [2, 9], +39: [2, 9], +44: [2, 9], +47: [2, 9], +48: [2, 9], +51: [2, 9], +55: [2, 9], +60: [2, 9] }, { 20: 25, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 36, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 4: 37, +6: 3, +14: [2, 46], +15: [2, 46], +19: [2, 46], +29: [2, 46], +34: [2, 46], +39: [2, 46], +44: [2, 46], +47: [2, 46], +48: [2, 46], +51: [2, 46], +55: [2, 46], +60: [2, 46] }, { 4: 38, +6: 3, +14: [2, 46], +15: [2, 46], +19: [2, 46], +29: [2, 46], +34: [2, 46], +44: [2, 46], +47: [2, 46], +48: [2, 46], +51: [2, 46], +55: [2, 46], +60: [2, 46] }, { 13: 40, +15: [1, 20], +17: 39 }, { 20: 42, +56: 41, +64: 43, +65: [1, 44], +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 4: 45, +6: 3, +14: [2, 46], +15: [2, 46], +19: [2, 46], +29: [2, 46], +34: [2, 46], +47: [2, 46], +48: [2, 46], +51: [2, 46], +55: [2, 46], +60: [2, 46] }, { 5: [2, 10], +14: [2, 10], +15: [2, 10], +18: [2, 10], +19: [2, 10], +29: [2, 10], +34: [2, 10], +39: [2, 10], +44: [2, 10], +47: [2, 10], +48: [2, 10], +51: [2, 10], +55: [2, 10], +60: [2, 10] }, { 20: 46, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 47, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 48, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 42, +56: 49, +64: 43, +65: [1, 44], +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 33: [2, 78], +49: 50, +65: [2, 78], +72: [2, 78], +80: [2, 78], +81: [2, 78], +82: [2, 78], +83: [2, 78], +84: [2, 78], +85: [2, 78] }, { 23: [2, 33], +33: [2, 33], +54: [2, 33], +65: [2, 33], +68: [2, 33], +72: [2, 33], +75: [2, 33], +80: [2, 33], +81: [2, 33], +82: [2, 33], +83: [2, 33], +84: [2, 33], +85: [2, 33] }, { 23: [2, 34], +33: [2, 34], +54: [2, 34], +65: [2, 34], +68: [2, 34], +72: [2, 34], +75: [2, 34], +80: [2, 34], +81: [2, 34], +82: [2, 34], +83: [2, 34], +84: [2, 34], +85: [2, 34] }, { 23: [2, 35], +33: [2, 35], +54: [2, 35], +65: [2, 35], +68: [2, 35], +72: [2, 35], +75: [2, 35], +80: [2, 35], +81: [2, 35], +82: [2, 35], +83: [2, 35], +84: [2, 35], +85: [2, 35] }, { 23: [2, 36], +33: [2, 36], +54: [2, 36], +65: [2, 36], +68: [2, 36], +72: [2, 36], +75: [2, 36], +80: [2, 36], +81: [2, 36], +82: [2, 36], +83: [2, 36], +84: [2, 36], +85: [2, 36] }, { 23: [2, 37], +33: [2, 37], +54: [2, 37], +65: [2, 37], +68: [2, 37], +72: [2, 37], +75: [2, 37], +80: [2, 37], +81: [2, 37], +82: [2, 37], +83: [2, 37], +84: [2, 37], +85: [2, 37] }, { 23: [2, 38], +33: [2, 38], +54: [2, 38], +65: [2, 38], +68: [2, 38], +72: [2, 38], +75: [2, 38], +80: [2, 38], +81: [2, 38], +82: [2, 38], +83: [2, 38], +84: [2, 38], +85: [2, 38] }, { 23: [2, 39], +33: [2, 39], +54: [2, 39], +65: [2, 39], +68: [2, 39], +72: [2, 39], +75: [2, 39], +80: [2, 39], +81: [2, 39], +82: [2, 39], +83: [2, 39], +84: [2, 39], +85: [2, 39] }, { 23: [2, 43], +33: [2, 43], +54: [2, 43], +65: [2, 43], +68: [2, 43], +72: [2, 43], +75: [2, 43], +80: [2, 43], +81: [2, 43], +82: [2, 43], +83: [2, 43], +84: [2, 43], +85: [2, 43], +87: [1, 51] }, { 72: [1, 35], +86: 52 }, { 23: [2, 45], +33: [2, 45], +54: [2, 45], +65: [2, 45], +68: [2, 45], +72: [2, 45], +75: [2, 45], +80: [2, 45], +81: [2, 45], +82: [2, 45], +83: [2, 45], +84: [2, 45], +85: [2, 45], +87: [2, 45] }, { 52: 53, +54: [2, 82], +65: [2, 82], +72: [2, 82], +80: [2, 82], +81: [2, 82], +82: [2, 82], +83: [2, 82], +84: [2, 82], +85: [2, 82] }, { 25: 54, +38: 56, +39: [1, 58], +43: 57, +44: [1, 59], +45: 55, +47: [2, 54] }, { 28: 60, +43: 61, +44: [1, 59], +47: [2, 56] }, { 13: 63, +15: [1, 20], +18: [1, 62] }, { 15: [2, 48], +18: [2, 48] }, { 33: [2, 86], +57: 64, +65: [2, 86], +72: [2, 86], +80: [2, 86], +81: [2, 86], +82: [2, 86], +83: [2, 86], +84: [2, 86], +85: [2, 86] }, { 33: [2, 40], +65: [2, 40], +72: [2, 40], +80: [2, 40], +81: [2, 40], +82: [2, 40], +83: [2, 40], +84: [2, 40], +85: [2, 40] }, { 33: [2, 41], +65: [2, 41], +72: [2, 41], +80: [2, 41], +81: [2, 41], +82: [2, 41], +83: [2, 41], +84: [2, 41], +85: [2, 41] }, { 20: 65, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 26: 66, +47: [1, 67] }, { 30: 68, +33: [2, 58], +65: [2, 58], +72: [2, 58], +75: [2, 58], +80: [2, 58], +81: [2, 58], +82: [2, 58], +83: [2, 58], +84: [2, 58], +85: [2, 58] }, { 33: [2, 64], +35: 69, +65: [2, 64], +72: [2, 64], +75: [2, 64], +80: [2, 64], +81: [2, 64], +82: [2, 64], +83: [2, 64], +84: [2, 64], +85: [2, 64] }, { 21: 70, +23: [2, 50], +65: [2, 50], +72: [2, 50], +80: [2, 50], +81: [2, 50], +82: [2, 50], +83: [2, 50], +84: [2, 50], +85: [2, 50] }, { 33: [2, 90], +61: 71, +65: [2, 90], +72: [2, 90], +80: [2, 90], +81: [2, 90], +82: [2, 90], +83: [2, 90], +84: [2, 90], +85: [2, 90] }, { 20: 75, +33: [2, 80], +50: 72, +63: 73, +64: 76, +65: [1, 44], +69: 74, +70: 77, +71: 78, +72: [1, 79], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 72: [1, 80] }, { 23: [2, 42], +33: [2, 42], +54: [2, 42], +65: [2, 42], +68: [2, 42], +72: [2, 42], +75: [2, 42], +80: [2, 42], +81: [2, 42], +82: [2, 42], +83: [2, 42], +84: [2, 42], +85: [2, 42], +87: [1, 51] }, { 20: 75, +53: 81, +54: [2, 84], +63: 82, +64: 76, +65: [1, 44], +69: 83, +70: 77, +71: 78, +72: [1, 79], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 26: 84, +47: [1, 67] }, { 47: [2, 55] }, { 4: 85, +6: 3, +14: [2, 46], +15: [2, 46], +19: [2, 46], +29: [2, 46], +34: [2, 46], +39: [2, 46], +44: [2, 46], +47: [2, 46], +48: [2, 46], +51: [2, 46], +55: [2, 46], +60: [2, 46] }, { 47: [2, 20] }, { 20: 86, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 4: 87, +6: 3, +14: [2, 46], +15: [2, 46], +19: [2, 46], +29: [2, 46], +34: [2, 46], +47: [2, 46], +48: [2, 46], +51: [2, 46], +55: [2, 46], +60: [2, 46] }, { 26: 88, +47: [1, 67] }, { 47: [2, 57] }, { 5: [2, 11], +14: [2, 11], +15: [2, 11], +19: [2, 11], +29: [2, 11], +34: [2, 11], +39: [2, 11], +44: [2, 11], +47: [2, 11], +48: [2, 11], +51: [2, 11], +55: [2, 11], +60: [2, 11] }, { 15: [2, 49], +18: [2, 49] }, { 20: 75, +33: [2, 88], +58: 89, +63: 90, +64: 76, +65: [1, 44], +69: 91, +70: 77, +71: 78, +72: [1, 79], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 65: [2, 94], +66: 92, +68: [2, 94], +72: [2, 94], +80: [2, 94], +81: [2, 94], +82: [2, 94], +83: [2, 94], +84: [2, 94], +85: [2, 94] }, { 5: [2, 25], +14: [2, 25], +15: [2, 25], +19: [2, 25], +29: [2, 25], +34: [2, 25], +39: [2, 25], +44: [2, 25], +47: [2, 25], +48: [2, 25], +51: [2, 25], +55: [2, 25], +60: [2, 25] }, { 20: 93, +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 75, +31: 94, +33: [2, 60], +63: 95, +64: 76, +65: [1, 44], +69: 96, +70: 77, +71: 78, +72: [1, 79], +75: [2, 60], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 75, +33: [2, 66], +36: 97, +63: 98, +64: 76, +65: [1, 44], +69: 99, +70: 77, +71: 78, +72: [1, 79], +75: [2, 66], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 75, +22: 100, +23: [2, 52], +63: 101, +64: 76, +65: [1, 44], +69: 102, +70: 77, +71: 78, +72: [1, 79], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 20: 75, +33: [2, 92], +62: 103, +63: 104, +64: 76, +65: [1, 44], +69: 105, +70: 77, +71: 78, +72: [1, 79], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 33: [1, 106] }, { 33: [2, 79], +65: [2, 79], +72: [2, 79], +80: [2, 79], +81: [2, 79], +82: [2, 79], +83: [2, 79], +84: [2, 79], +85: [2, 79] }, { 33: [2, 81] }, { 23: [2, 27], +33: [2, 27], +54: [2, 27], +65: [2, 27], +68: [2, 27], +72: [2, 27], +75: [2, 27], +80: [2, 27], +81: [2, 27], +82: [2, 27], +83: [2, 27], +84: [2, 27], +85: [2, 27] }, { 23: [2, 28], +33: [2, 28], +54: [2, 28], +65: [2, 28], +68: [2, 28], +72: [2, 28], +75: [2, 28], +80: [2, 28], +81: [2, 28], +82: [2, 28], +83: [2, 28], +84: [2, 28], +85: [2, 28] }, { 23: [2, 30], +33: [2, 30], +54: [2, 30], +68: [2, 30], +71: 107, +72: [1, 108], +75: [2, 30] }, { 23: [2, 98], +33: [2, 98], +54: [2, 98], +68: [2, 98], +72: [2, 98], +75: [2, 98] }, { 23: [2, 45], +33: [2, 45], +54: [2, 45], +65: [2, 45], +68: [2, 45], +72: [2, 45], +73: [1, 109], +75: [2, 45], +80: [2, 45], +81: [2, 45], +82: [2, 45], +83: [2, 45], +84: [2, 45], +85: [2, 45], +87: [2, 45] }, { 23: [2, 44], +33: [2, 44], +54: [2, 44], +65: [2, 44], +68: [2, 44], +72: [2, 44], +75: [2, 44], +80: [2, 44], +81: [2, 44], +82: [2, 44], +83: [2, 44], +84: [2, 44], +85: [2, 44], +87: [2, 44] }, { 54: [1, 110] }, { 54: [2, 83], +65: [2, 83], +72: [2, 83], +80: [2, 83], +81: [2, 83], +82: [2, 83], +83: [2, 83], +84: [2, 83], +85: [2, 83] }, { 54: [2, 85] }, { 5: [2, 13], +14: [2, 13], +15: [2, 13], +19: [2, 13], +29: [2, 13], +34: [2, 13], +39: [2, 13], +44: [2, 13], +47: [2, 13], +48: [2, 13], +51: [2, 13], +55: [2, 13], +60: [2, 13] }, { 38: 56, +39: [1, 58], +43: 57, +44: [1, 59], +45: 112, +46: 111, +47: [2, 76] }, { 33: [2, 70], +40: 113, +65: [2, 70], +72: [2, 70], +75: [2, 70], +80: [2, 70], +81: [2, 70], +82: [2, 70], +83: [2, 70], +84: [2, 70], +85: [2, 70] }, { 47: [2, 18] }, { 5: [2, 14], +14: [2, 14], +15: [2, 14], +19: [2, 14], +29: [2, 14], +34: [2, 14], +39: [2, 14], +44: [2, 14], +47: [2, 14], +48: [2, 14], +51: [2, 14], +55: [2, 14], +60: [2, 14] }, { 33: [1, 114] }, { 33: [2, 87], +65: [2, 87], +72: [2, 87], +80: [2, 87], +81: [2, 87], +82: [2, 87], +83: [2, 87], +84: [2, 87], +85: [2, 87] }, { 33: [2, 89] }, { 20: 75, +63: 116, +64: 76, +65: [1, 44], +67: 115, +68: [2, 96], +69: 117, +70: 77, +71: 78, +72: [1, 79], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 33: [1, 118] }, { 32: 119, +33: [2, 62], +74: 120, +75: [1, 121] }, { 33: [2, 59], +65: [2, 59], +72: [2, 59], +75: [2, 59], +80: [2, 59], +81: [2, 59], +82: [2, 59], +83: [2, 59], +84: [2, 59], +85: [2, 59] }, { 33: [2, 61], +75: [2, 61] }, { 33: [2, 68], +37: 122, +74: 123, +75: [1, 121] }, { 33: [2, 65], +65: [2, 65], +72: [2, 65], +75: [2, 65], +80: [2, 65], +81: [2, 65], +82: [2, 65], +83: [2, 65], +84: [2, 65], +85: [2, 65] }, { 33: [2, 67], +75: [2, 67] }, { 23: [1, 124] }, { 23: [2, 51], +65: [2, 51], +72: [2, 51], +80: [2, 51], +81: [2, 51], +82: [2, 51], +83: [2, 51], +84: [2, 51], +85: [2, 51] }, { 23: [2, 53] }, { 33: [1, 125] }, { 33: [2, 91], +65: [2, 91], +72: [2, 91], +80: [2, 91], +81: [2, 91], +82: [2, 91], +83: [2, 91], +84: [2, 91], +85: [2, 91] }, { 33: [2, 93] }, { 5: [2, 22], +14: [2, 22], +15: [2, 22], +19: [2, 22], +29: [2, 22], +34: [2, 22], +39: [2, 22], +44: [2, 22], +47: [2, 22], +48: [2, 22], +51: [2, 22], +55: [2, 22], +60: [2, 22] }, { 23: [2, 99], +33: [2, 99], +54: [2, 99], +68: [2, 99], +72: [2, 99], +75: [2, 99] }, { 73: [1, 109] }, { 20: 75, +63: 126, +64: 76, +65: [1, 44], +72: [1, 35], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 5: [2, 23], +14: [2, 23], +15: [2, 23], +19: [2, 23], +29: [2, 23], +34: [2, 23], +39: [2, 23], +44: [2, 23], +47: [2, 23], +48: [2, 23], +51: [2, 23], +55: [2, 23], +60: [2, 23] }, { 47: [2, 19] }, { 47: [2, 77] }, { 20: 75, +33: [2, 72], +41: 127, +63: 128, +64: 76, +65: [1, 44], +69: 129, +70: 77, +71: 78, +72: [1, 79], +75: [2, 72], +78: 26, +79: 27, +80: [1, 28], +81: [1, 29], +82: [1, 30], +83: [1, 31], +84: [1, 32], +85: [1, 34], +86: 33 }, { 5: [2, 24], +14: [2, 24], +15: [2, 24], +19: [2, 24], +29: [2, 24], +34: [2, 24], +39: [2, 24], +44: [2, 24], +47: [2, 24], +48: [2, 24], +51: [2, 24], +55: [2, 24], +60: [2, 24] }, { 68: [1, 130] }, { 65: [2, 95], +68: [2, 95], +72: [2, 95], +80: [2, 95], +81: [2, 95], +82: [2, 95], +83: [2, 95], +84: [2, 95], +85: [2, 95] }, { 68: [2, 97] }, { 5: [2, 21], +14: [2, 21], +15: [2, 21], +19: [2, 21], +29: [2, 21], +34: [2, 21], +39: [2, 21], +44: [2, 21], +47: [2, 21], +48: [2, 21], +51: [2, 21], +55: [2, 21], +60: [2, 21] }, { 33: [1, 131] }, { 33: [2, 63] }, { 72: [1, 133], +76: 132 }, { 33: [1, 134] }, { 33: [2, 69] }, { 15: [2, 12] }, { 14: [2, 26], +15: [2, 26], +19: [2, 26], +29: [2, 26], +34: [2, 26], +47: [2, 26], +48: [2, 26], +51: [2, 26], +55: [2, 26], +60: [2, 26] }, { 23: [2, 31], +33: [2, 31], +54: [2, 31], +68: [2, 31], +72: [2, 31], +75: [2, 31] }, { 33: [2, 74], +42: 135, +74: 136, +75: [1, 121] }, { 33: [2, 71], +65: [2, 71], +72: [2, 71], +75: [2, 71], +80: [2, 71], +81: [2, 71], +82: [2, 71], +83: [2, 71], +84: [2, 71], +85: [2, 71] }, { 33: [2, 73], +75: [2, 73] }, { 23: [2, 29], +33: [2, 29], +54: [2, 29], +65: [2, 29], +68: [2, 29], +72: [2, 29], +75: [2, 29], +80: [2, 29], +81: [2, 29], +82: [2, 29], +83: [2, 29], +84: [2, 29], +85: [2, 29] }, { 14: [2, 15], +15: [2, 15], +19: [2, 15], +29: [2, 15], +34: [2, 15], +39: [2, 15], +44: [2, 15], +47: [2, 15], +48: [2, 15], +51: [2, 15], +55: [2, 15], +60: [2, 15] }, { 72: [1, 138], +77: [1, 137] }, { 72: [2, 100], +77: [2, 100] }, { 14: [2, 16], +15: [2, 16], +19: [2, 16], +29: [2, 16], +34: [2, 16], +44: [2, 16], +47: [2, 16], +48: [2, 16], +51: [2, 16], +55: [2, 16], +60: [2, 16] }, { 33: [1, 139] }, { 33: [2, 75] }, { 33: [2, 32] }, { 72: [2, 101], +77: [2, 101] }, { 14: [2, 17], +15: [2, 17], +19: [2, 17], +29: [2, 17], +34: [2, 17], +39: [2, 17], +44: [2, 17], +47: [2, 17], +48: [2, 17], +51: [2, 17], +55: [2, 17], +60: [2, 17] }], + defaultActions: { 4: [2, 1], +55: [2, 55], +57: [2, 20], +61: [2, 57], +74: [2, 81], +83: [2, 85], +87: [2, 18], +91: [2, 89], +102: [2, 53], +105: [2, 93], +111: [2, 19], +112: [2, 77], +117: [2, 97], +120: [2, 63], +123: [2, 69], +124: [2, 12], +136: [2, 75], +137: [2, 32] }, + parseError: function parseError(str, hash) { + throw new Error(str); + }, + parse: function parse(input) { + var self = this, + stack = [0], + vstack = [null], + lstack = [], + table = this.table, + yytext = '', + yylineno = 0, + yyleng = 0, + recovering = 0, + TERROR = 2, + EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc === 'undefined') this.lexer.yylloc = {}; + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === 'function') this.parseError = this.yy.parseError; + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || 1; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, + preErrorSymbol, + state, + action, + a, + r, + yyval = {}, + p, + len, + newState, + expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol === 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + if (!recovering) { + expected = []; + for (p in table[state]) if (this.terminals_[p] && p > 2) { + expected.push('\'' + this.terminals_[p] + '\''); + } + if (this.lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + this.lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == 1 ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + this.parseError(errStr, { text: this.lexer.match, +token: this.terminals_[symbol] || symbol, +line: this.lexer.yylineno, +loc: yyloc, +expected: expected }); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { first_line: lstack[lstack.length - (len || 1)].first_line, +last_line: lstack[lstack.length - 1].last_line, +first_column: lstack[lstack.length - (len || 1)].first_column, +last_column: lstack[lstack.length - 1].last_column }; + if (ranges) { + yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + /* Jison generated lexer */ + var lexer = (function() { + var lexer = { EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + setInput: function setInput(input) { + this._input = input; + this._more = this._less = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = { first_line: 1, +first_column: 0, +last_line: 1, +last_column: 0 }; + if (this.options.ranges) this.yylloc.range = [0, 0]; + this.offset = 0; + return this; + }, + input: function input() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) this.yylloc.range[1]++; + + this._input = this._input.slice(1); + return ch; + }, + unput: function unput(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len - 1); + // this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + + if (lines.length - 1) this.yylineno -= lines.length - 1; + var r = this.yylloc.range; + + this.yylloc = { first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + return this; + }, + more: function more() { + this._more = true; + return this; + }, + less: function less(n) { + this.unput(this.match.slice(n)); + }, + pastInput: function pastInput() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, ''); + }, + upcomingInput: function upcomingInput() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ''); + }, + showPosition: function showPosition() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join('-'); + return pre + this.upcomingInput() + '\n' + c + '^'; + }, + next: function next() { + if (this.done) { + return this.EOF; + } + if (!this._input) this.done = true; + + var token, match, tempMatch, index, col, lines; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (!this.options.flex) break; + } + } + if (match) { + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) this.yylineno += lines.length; + this.yylloc = { first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, rules[index], this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) this.done = false; + if (token) return token;else return; + } + if (this._input === '') { + return this.EOF; + } else { + return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { text: '', +token: null, +line: this.yylineno }); + } + }, + lex: function lex() { + var r = this.next(); + if (typeof r !== 'undefined') { + return r; + } else { + return this.lex(); + } + }, + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + popState: function popState() { + return this.conditionStack.pop(); + }, + _currentRules: function _currentRules() { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + }, + topState: function topState() { + return this.conditionStack[this.conditionStack.length - 2]; + }, + pushState: function begin(condition) { + this.begin(condition); + } }; + lexer.options = {}; + lexer.performAction = function anonymous(yy, yy_, $avoiding_name_collisions, YY_START + /**/) { + function strip(start, end) { + return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng - end); + } + + var YYSTATE = YY_START; + switch ($avoiding_name_collisions) { + case 0: + if (yy_.yytext.slice(-2) === '\\\\') { + strip(0, 1); + this.begin('mu'); + } else if (yy_.yytext.slice(-1) === '\\') { + strip(0, 1); + this.begin('emu'); + } else { + this.begin('mu'); + } + if (yy_.yytext) return 15; + + break; + case 1: + return 15; + break; + case 2: + this.popState(); + return 15; + + break; + case 3: + this.begin('raw');return 15; + break; + case 4: + this.popState(); + // Should be using `this.topState()` below, but it currently + // returns the second top instead of the first top. Opened an + // issue about it at https://github.com/zaach/jison/issues/291 + if (this.conditionStack[this.conditionStack.length - 1] === 'raw') { + return 15; + } else { + yy_.yytext = yy_.yytext.substr(5, yy_.yyleng - 9); + return 'END_RAW_BLOCK'; + } + + break; + case 5: + return 15; + break; + case 6: + this.popState(); + return 14; + + break; + case 7: + return 65; + break; + case 8: + return 68; + break; + case 9: + return 19; + break; + case 10: + this.popState(); + this.begin('raw'); + return 23; + + break; + case 11: + return 55; + break; + case 12: + return 60; + break; + case 13: + return 29; + break; + case 14: + return 47; + break; + case 15: + this.popState();return 44; + break; + case 16: + this.popState();return 44; + break; + case 17: + return 34; + break; + case 18: + return 39; + break; + case 19: + return 51; + break; + case 20: + return 48; + break; + case 21: + this.unput(yy_.yytext); + this.popState(); + this.begin('com'); + + break; + case 22: + this.popState(); + return 14; + + break; + case 23: + return 48; + break; + case 24: + return 73; + break; + case 25: + return 72; + break; + case 26: + return 72; + break; + case 27: + return 87; + break; + case 28: + // ignore whitespace + break; + case 29: + this.popState();return 54; + break; + case 30: + this.popState();return 33; + break; + case 31: + yy_.yytext = strip(1, 2).replace(/\\"/g, '"');return 80; + break; + case 32: + yy_.yytext = strip(1, 2).replace(/\\'/g, '\'');return 80; + break; + case 33: + return 85; + break; + case 34: + return 82; + break; + case 35: + return 82; + break; + case 36: + return 83; + break; + case 37: + return 84; + break; + case 38: + return 81; + break; + case 39: + return 75; + break; + case 40: + return 77; + break; + case 41: + return 72; + break; + case 42: + yy_.yytext = yy_.yytext.replace(/\\([\\\]])/g, '$1');return 72; + break; + case 43: + return 'INVALID'; + break; + case 44: + return 5; + break; + } + }; + lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^\/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]*?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^(?:\{\{(~)?\s*else\b)/, /^(?:\{\{(~)?\{)/, /^(?:\{\{(~)?&)/, /^(?:\{\{(~)?!--)/, /^(?:\{\{(~)?![\s\S]*?\}\})/, /^(?:\{\{(~)?\*?)/, /^(?:=)/, /^(?:\.\.)/, /^(?:\.(?=([=~}\s\/.)|])))/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:\}(~)?\}\})/, /^(?:(~)?\}\})/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@)/, /^(?:true(?=([~}\s)])))/, /^(?:false(?=([~}\s)])))/, /^(?:undefined(?=([~}\s)])))/, /^(?:null(?=([~}\s)])))/, /^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/, /^(?:as\s+\|)/, /^(?:\|)/, /^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/, /^(?:\[(\\\]|[^\]])*\])/, /^(?:.)/, /^(?:$)/]; + lexer.conditions = { 'mu': { 'rules': [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], +'inclusive': false }, +'emu': { 'rules': [2], +'inclusive': false }, +'com': { 'rules': [6], +'inclusive': false }, +'raw': { 'rules': [3, 4, 5], +'inclusive': false }, +'INITIAL': { 'rules': [0, 1, 44], +'inclusive': true } }; + return lexer; + })(); + parser.lexer = lexer; + function Parser() { + this.yy = {}; + }Parser.prototype = parser;parser.Parser = Parser; + return new Parser(); + })();exports['default'] = handlebars; + module.exports = exports['default']; + /** */ }), + /* 38 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _visitor = __webpack_require__(39); + + var _visitor2 = _interopRequireDefault(_visitor); + + function WhitespaceControl() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + this.options = options; + } + WhitespaceControl.prototype = new _visitor2['default'](); + + WhitespaceControl.prototype.Program = function(program) { + var doStandalone = !this.options.ignoreStandalone; + + var isRoot = !this.isRootSeen; + this.isRootSeen = true; + + var body = program.body; + for (var i = 0, l = body.length; i < l; i++) { + var current = body[i], + strip = this.accept(current); + + if (!strip) { + continue; + } + + var _isPrevWhitespace = isPrevWhitespace(body, i, isRoot), + _isNextWhitespace = isNextWhitespace(body, i, isRoot), + openStandalone = strip.openStandalone && _isPrevWhitespace, + closeStandalone = strip.closeStandalone && _isNextWhitespace, + inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace; + + if (strip.close) { + omitRight(body, i, true); + } + if (strip.open) { + omitLeft(body, i, true); + } + + if (doStandalone && inlineStandalone) { + omitRight(body, i); + + if (omitLeft(body, i)) { + // If we are on a standalone node, save the indent info for partials + if (current.type === 'PartialStatement') { + // Pull out the whitespace from the final line + current.indent = /([ \t]+$)/.exec(body[i - 1].original)[1]; + } + } + } + if (doStandalone && openStandalone) { + omitRight((current.program || current.inverse).body); + + // Strip out the previous content node if it's whitespace only + omitLeft(body, i); + } + if (doStandalone && closeStandalone) { + // Always strip the next node + omitRight(body, i); + + omitLeft((current.inverse || current.program).body); + } + } + + return program; + }; + + WhitespaceControl.prototype.BlockStatement = WhitespaceControl.prototype.DecoratorBlock = WhitespaceControl.prototype.PartialBlockStatement = function(block) { + this.accept(block.program); + this.accept(block.inverse); + + // Find the inverse program that is involed with whitespace stripping. + var program = block.program || block.inverse, + inverse = block.program && block.inverse, + firstInverse = inverse, + lastInverse = inverse; + + if (inverse && inverse.chained) { + firstInverse = inverse.body[0].program; + + // Walk the inverse chain to find the last inverse that is actually in the chain. + while (lastInverse.chained) { + lastInverse = lastInverse.body[lastInverse.body.length - 1].program; + } + } + + var strip = { + open: block.openStrip.open, + close: block.closeStrip.close, + + // Determine the standalone candiacy. Basically flag our content as being possibly standalone + // so our parent can determine if we actually are standalone + openStandalone: isNextWhitespace(program.body), + closeStandalone: isPrevWhitespace((firstInverse || program).body) + }; + + if (block.openStrip.close) { + omitRight(program.body, null, true); + } + + if (inverse) { + var inverseStrip = block.inverseStrip; + + if (inverseStrip.open) { + omitLeft(program.body, null, true); + } + + if (inverseStrip.close) { + omitRight(firstInverse.body, null, true); + } + if (block.closeStrip.open) { + omitLeft(lastInverse.body, null, true); + } + + // Find standalone else statments + if (!this.options.ignoreStandalone && isPrevWhitespace(program.body) && isNextWhitespace(firstInverse.body)) { + omitLeft(program.body); + omitRight(firstInverse.body); + } + } else if (block.closeStrip.open) { + omitLeft(program.body, null, true); + } + + return strip; + }; + + WhitespaceControl.prototype.Decorator = WhitespaceControl.prototype.MustacheStatement = function(mustache) { + return mustache.strip; + }; + + WhitespaceControl.prototype.PartialStatement = WhitespaceControl.prototype.CommentStatement = function(node) { + /* istanbul ignore next */ + var strip = node.strip || {}; + return { + inlineStandalone: true, + open: strip.open, + close: strip.close + }; + }; + + function isPrevWhitespace(body, i, isRoot) { + if (i === undefined) { + i = body.length; + } + + // Nodes that end with newlines are considered whitespace (but are special + // cased for strip operations) + var prev = body[i - 1], + sibling = body[i - 2]; + if (!prev) { + return isRoot; + } + + if (prev.type === 'ContentStatement') { + return (sibling || !isRoot ? /\r?\n\s*?$/ : /(^|\r?\n)\s*?$/).test(prev.original); + } + } + function isNextWhitespace(body, i, isRoot) { + if (i === undefined) { + i = -1; + } + + var next = body[i + 1], + sibling = body[i + 2]; + if (!next) { + return isRoot; + } + + if (next.type === 'ContentStatement') { + return (sibling || !isRoot ? /^\s*?\r?\n/ : /^\s*?(\r?\n|$)/).test(next.original); + } + } + + // Marks the node to the right of the position as omitted. + // I.e. {{foo}}' ' will mark the ' ' node as omitted. + // + // If i is undefined, then the first child will be marked as such. + // + // If mulitple is truthy then all whitespace will be stripped out until non-whitespace + // content is met. + function omitRight(body, i, multiple) { + var current = body[i == null ? 0 : i + 1]; + if (!current || current.type !== 'ContentStatement' || !multiple && current.rightStripped) { + return; + } + + var original = current.value; + current.value = current.value.replace(multiple ? /^\s+/ : /^[ \t]*\r?\n?/, ''); + current.rightStripped = current.value !== original; + } + + // Marks the node to the left of the position as omitted. + // I.e. ' '{{foo}} will mark the ' ' node as omitted. + // + // If i is undefined then the last child will be marked as such. + // + // If mulitple is truthy then all whitespace will be stripped out until non-whitespace + // content is met. + function omitLeft(body, i, multiple) { + var current = body[i == null ? body.length - 1 : i - 1]; + if (!current || current.type !== 'ContentStatement' || !multiple && current.leftStripped) { + return; + } + + // We omit the last node if it's whitespace only and not preceeded by a non-content node. + var original = current.value; + current.value = current.value.replace(multiple ? /\s+$/ : /[ \t]+$/, ''); + current.leftStripped = current.value !== original; + return current.leftStripped; + } + + exports['default'] = WhitespaceControl; + module.exports = exports['default']; + /** */ }), + /* 39 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + function Visitor() { + this.parents = []; + } + + Visitor.prototype = { + constructor: Visitor, + mutating: false, + + // Visits a given value. If mutating, will replace the value if necessary. + acceptKey: function acceptKey(node, name) { + var value = this.accept(node[name]); + if (this.mutating) { + // Hacky sanity check: This may have a few false positives for type for the helper + // methods but will generally do the right thing without a lot of overhead. + if (value && !Visitor.prototype[value.type]) { + throw new _exception2['default']('Unexpected node type "' + value.type + '" found when accepting ' + name + ' on ' + node.type); + } + node[name] = value; + } + }, + + // Performs an accept operation with added sanity check to ensure + // required keys are not removed. + acceptRequired: function acceptRequired(node, name) { + this.acceptKey(node, name); + + if (!node[name]) { + throw new _exception2['default'](node.type + ' requires ' + name); + } + }, + + // Traverses a given array. If mutating, empty respnses will be removed + // for child elements. + acceptArray: function acceptArray(array) { + for (var i = 0, l = array.length; i < l; i++) { + this.acceptKey(array, i); + + if (!array[i]) { + array.splice(i, 1); + i--; + l--; + } + } + }, + + accept: function accept(object) { + if (!object) { + return; + } + + /* istanbul ignore next: Sanity code */ + if (!this[object.type]) { + throw new _exception2['default']('Unknown type: ' + object.type, object); + } + + if (this.current) { + this.parents.unshift(this.current); + } + this.current = object; + + var ret = this[object.type](object); + + this.current = this.parents.shift(); + + if (!this.mutating || ret) { + return ret; + } else if (ret !== false) { + return object; + } + }, + + Program: function Program(program) { + this.acceptArray(program.body); + }, + + MustacheStatement: visitSubExpression, + Decorator: visitSubExpression, + + BlockStatement: visitBlock, + DecoratorBlock: visitBlock, + + PartialStatement: visitPartial, + PartialBlockStatement: function PartialBlockStatement(partial) { + visitPartial.call(this, partial); + + this.acceptKey(partial, 'program'); + }, + + ContentStatement: function ContentStatement() /* content */{}, + CommentStatement: function CommentStatement() /* comment */{}, + + SubExpression: visitSubExpression, + + PathExpression: function PathExpression() /* path */{}, + + StringLiteral: function StringLiteral() /* string */{}, + NumberLiteral: function NumberLiteral() /* number */{}, + BooleanLiteral: function BooleanLiteral() /* bool */{}, + UndefinedLiteral: function UndefinedLiteral() /* literal */{}, + NullLiteral: function NullLiteral() /* literal */{}, + + Hash: function Hash(hash) { + this.acceptArray(hash.pairs); + }, + HashPair: function HashPair(pair) { + this.acceptRequired(pair, 'value'); + } + }; + + function visitSubExpression(mustache) { + this.acceptRequired(mustache, 'path'); + this.acceptArray(mustache.params); + this.acceptKey(mustache, 'hash'); + } + function visitBlock(block) { + visitSubExpression.call(this, block); + + this.acceptKey(block, 'program'); + this.acceptKey(block, 'inverse'); + } + function visitPartial(partial) { + this.acceptRequired(partial, 'name'); + this.acceptArray(partial.params); + this.acceptKey(partial, 'hash'); + } + + exports['default'] = Visitor; + module.exports = exports['default']; + /** */ }), + /* 40 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + exports.SourceLocation = SourceLocation; + exports.id = id; + exports.stripFlags = stripFlags; + exports.stripComment = stripComment; + exports.preparePath = preparePath; + exports.prepareMustache = prepareMustache; + exports.prepareRawBlock = prepareRawBlock; + exports.prepareBlock = prepareBlock; + exports.prepareProgram = prepareProgram; + exports.preparePartialBlock = preparePartialBlock; + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + function validateClose(open, close) { + close = close.path ? close.path.original : close; + + if (open.path.original !== close) { + var errorNode = { loc: open.path.loc }; + + throw new _exception2['default'](open.path.original + ' doesn\'t match ' + close, errorNode); + } + } + + function SourceLocation(source, locInfo) { + this.source = source; + this.start = { + line: locInfo.first_line, + column: locInfo.first_column + }; + this.end = { + line: locInfo.last_line, + column: locInfo.last_column + }; + } + + function id(token) { + if (/^\[.*\]$/.test(token)) { + return token.substr(1, token.length - 2); + } else { + return token; + } + } + + function stripFlags(open, close) { + return { + open: open.charAt(2) === '~', + close: close.charAt(close.length - 3) === '~' + }; + } + + function stripComment(comment) { + return comment.replace(/^\{\{~?\!-?-?/, '').replace(/-?-?~?\}\}$/, ''); + } + + function preparePath(data, parts, loc) { + loc = this.locInfo(loc); + + var original = data ? '@' : '', + dig = [], + depth = 0, + depthString = ''; + + for (var i = 0, l = parts.length; i < l; i++) { + var part = parts[i].part, + + // If we have [] syntax then we do not treat path references as operators, + // i.e. foo.[this] resolves to approximately context.foo['this'] + isLiteral = parts[i].original !== part; + original += (parts[i].separator || '') + part; + + if (!isLiteral && (part === '..' || part === '.' || part === 'this')) { + if (dig.length > 0) { + throw new _exception2['default']('Invalid path: ' + original, { loc: loc }); + } else if (part === '..') { + depth++; + depthString += '../'; + } + } else { + dig.push(part); + } + } + + return { + type: 'PathExpression', + data: data, + depth: depth, + parts: dig, + original: original, + loc: loc + }; + } + + function prepareMustache(path, params, hash, open, strip, locInfo) { + // Must use charAt to support IE pre-10 + var escapeFlag = open.charAt(3) || open.charAt(2), + escaped = escapeFlag !== '{' && escapeFlag !== '&'; + + var decorator = /\*/.test(open); + return { + type: decorator ? 'Decorator' : 'MustacheStatement', + path: path, + params: params, + hash: hash, + escaped: escaped, + strip: strip, + loc: this.locInfo(locInfo) + }; + } + + function prepareRawBlock(openRawBlock, contents, close, locInfo) { + validateClose(openRawBlock, close); + + locInfo = this.locInfo(locInfo); + var program = { + type: 'Program', + body: contents, + strip: {}, + loc: locInfo + }; + + return { + type: 'BlockStatement', + path: openRawBlock.path, + params: openRawBlock.params, + hash: openRawBlock.hash, + program: program, + openStrip: {}, + inverseStrip: {}, + closeStrip: {}, + loc: locInfo + }; + } + + function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) { + if (close && close.path) { + validateClose(openBlock, close); + } + + var decorator = /\*/.test(openBlock.open); + + program.blockParams = openBlock.blockParams; + + var inverse = undefined, + inverseStrip = undefined; + + if (inverseAndProgram) { + if (decorator) { + throw new _exception2['default']('Unexpected inverse block on decorator', inverseAndProgram); + } + + if (inverseAndProgram.chain) { + inverseAndProgram.program.body[0].closeStrip = close.strip; + } + + inverseStrip = inverseAndProgram.strip; + inverse = inverseAndProgram.program; + } + + if (inverted) { + inverted = inverse; + inverse = program; + program = inverted; + } + + return { + type: decorator ? 'DecoratorBlock' : 'BlockStatement', + path: openBlock.path, + params: openBlock.params, + hash: openBlock.hash, + program: program, + inverse: inverse, + openStrip: openBlock.strip, + inverseStrip: inverseStrip, + closeStrip: close && close.strip, + loc: this.locInfo(locInfo) + }; + } + + function prepareProgram(statements, loc) { + if (!loc && statements.length) { + var firstLoc = statements[0].loc, + lastLoc = statements[statements.length - 1].loc; + + /* istanbul ignore else */ + if (firstLoc && lastLoc) { + loc = { + source: firstLoc.source, + start: { + line: firstLoc.start.line, + column: firstLoc.start.column + }, + end: { + line: lastLoc.end.line, + column: lastLoc.end.column + } + }; + } + } + + return { + type: 'Program', + body: statements, + strip: {}, + loc: loc + }; + } + + function preparePartialBlock(open, program, close, locInfo) { + validateClose(open, close); + + return { + type: 'PartialBlockStatement', + name: open.path, + params: open.params, + hash: open.hash, + program: program, + openStrip: open.strip, + closeStrip: close && close.strip, + loc: this.locInfo(locInfo) + }; + } + /** */ }), + /* 41 */ + /** */ (function(module, exports, __webpack_require__) { + /* eslint-disable new-cap */ + + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + exports.Compiler = Compiler; + exports.precompile = precompile; + exports.compile = compile; + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + var _utils = __webpack_require__(5); + + var _ast = __webpack_require__(35); + + var _ast2 = _interopRequireDefault(_ast); + + var slice = [].slice; + + function Compiler() {} + + // the foundHelper register will disambiguate helper lookup from finding a + // function in a context. This is necessary for mustache compatibility, which + // requires that context functions in blocks are evaluated by blockHelperMissing, + // and then proceed as if the resulting value was provided to blockHelperMissing. + + Compiler.prototype = { + compiler: Compiler, + + equals: function equals(other) { + var len = this.opcodes.length; + if (other.opcodes.length !== len) { + return false; + } + + for (var i = 0; i < len; i++) { + var opcode = this.opcodes[i], + otherOpcode = other.opcodes[i]; + if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) { + return false; + } + } + + // We know that length is the same between the two arrays because they are directly tied + // to the opcode behavior above. + len = this.children.length; + for (var i = 0; i < len; i++) { + if (!this.children[i].equals(other.children[i])) { + return false; + } + } + + return true; + }, + + guid: 0, + + compile: function compile(program, options) { + this.sourceNode = []; + this.opcodes = []; + this.children = []; + this.options = options; + this.stringParams = options.stringParams; + this.trackIds = options.trackIds; + + options.blockParams = options.blockParams || []; + + // These changes will propagate to the other compiler components + var knownHelpers = options.knownHelpers; + options.knownHelpers = { + 'helperMissing': true, + 'blockHelperMissing': true, + 'each': true, + 'if': true, + 'unless': true, + 'with': true, + 'log': true, + 'lookup': true + }; + if (knownHelpers) { + for (var _name in knownHelpers) { + /* istanbul ignore else */ + if (_name in knownHelpers) { + this.options.knownHelpers[_name] = knownHelpers[_name]; + } + } + } + + return this.accept(program); + }, + + compileProgram: function compileProgram(program) { + var childCompiler = new this.compiler(), + // eslint-disable-line new-cap + result = childCompiler.compile(program, this.options), + guid = this.guid++; + + this.usePartial = this.usePartial || result.usePartial; + + this.children[guid] = result; + this.useDepths = this.useDepths || result.useDepths; + + return guid; + }, + + accept: function accept(node) { + /* istanbul ignore next: Sanity code */ + if (!this[node.type]) { + throw new _exception2['default']('Unknown type: ' + node.type, node); + } + + this.sourceNode.unshift(node); + var ret = this[node.type](node); + this.sourceNode.shift(); + return ret; + }, + + Program: function Program(program) { + this.options.blockParams.unshift(program.blockParams); + + var body = program.body, + bodyLength = body.length; + for (var i = 0; i < bodyLength; i++) { + this.accept(body[i]); + } + + this.options.blockParams.shift(); + + this.isSimple = bodyLength === 1; + this.blockParams = program.blockParams ? program.blockParams.length : 0; + + return this; + }, + + BlockStatement: function BlockStatement(block) { + transformLiteralToPath(block); + + var program = block.program, + inverse = block.inverse; + + program = program && this.compileProgram(program); + inverse = inverse && this.compileProgram(inverse); + + var type = this.classifySexpr(block); + + if (type === 'helper') { + this.helperSexpr(block, program, inverse); + } else if (type === 'simple') { + this.simpleSexpr(block); + + // now that the simple mustache is resolved, we need to + // evaluate it by executing `blockHelperMissing` + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + this.opcode('emptyHash'); + this.opcode('blockValue', block.path.original); + } else { + this.ambiguousSexpr(block, program, inverse); + + // now that the simple mustache is resolved, we need to + // evaluate it by executing `blockHelperMissing` + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + this.opcode('emptyHash'); + this.opcode('ambiguousBlockValue'); + } + + this.opcode('append'); + }, + + DecoratorBlock: function DecoratorBlock(decorator) { + var program = decorator.program && this.compileProgram(decorator.program); + var params = this.setupFullMustacheParams(decorator, program, undefined), + path = decorator.path; + + this.useDecorators = true; + this.opcode('registerDecorator', params.length, path.original); + }, + + PartialStatement: function PartialStatement(partial) { + this.usePartial = true; + + var program = partial.program; + if (program) { + program = this.compileProgram(partial.program); + } + + var params = partial.params; + if (params.length > 1) { + throw new _exception2['default']('Unsupported number of partial arguments: ' + params.length, partial); + } else if (!params.length) { + if (this.options.explicitPartialContext) { + this.opcode('pushLiteral', 'undefined'); + } else { + params.push({ type: 'PathExpression', +parts: [], +depth: 0 }); + } + } + + var partialName = partial.name.original, + isDynamic = partial.name.type === 'SubExpression'; + if (isDynamic) { + this.accept(partial.name); + } + + this.setupFullMustacheParams(partial, program, undefined, true); + + var indent = partial.indent || ''; + if (this.options.preventIndent && indent) { + this.opcode('appendContent', indent); + indent = ''; + } + + this.opcode('invokePartial', isDynamic, partialName, indent); + this.opcode('append'); + }, + PartialBlockStatement: function PartialBlockStatement(partialBlock) { + this.PartialStatement(partialBlock); + }, + + MustacheStatement: function MustacheStatement(mustache) { + this.SubExpression(mustache); + + if (mustache.escaped && !this.options.noEscape) { + this.opcode('appendEscaped'); + } else { + this.opcode('append'); + } + }, + Decorator: function Decorator(decorator) { + this.DecoratorBlock(decorator); + }, + + ContentStatement: function ContentStatement(content) { + if (content.value) { + this.opcode('appendContent', content.value); + } + }, + + CommentStatement: function CommentStatement() {}, + + SubExpression: function SubExpression(sexpr) { + transformLiteralToPath(sexpr); + var type = this.classifySexpr(sexpr); + + if (type === 'simple') { + this.simpleSexpr(sexpr); + } else if (type === 'helper') { + this.helperSexpr(sexpr); + } else { + this.ambiguousSexpr(sexpr); + } + }, + ambiguousSexpr: function ambiguousSexpr(sexpr, program, inverse) { + var path = sexpr.path, + name = path.parts[0], + isBlock = program != null || inverse != null; + + this.opcode('getContext', path.depth); + + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + + path.strict = true; + this.accept(path); + + this.opcode('invokeAmbiguous', name, isBlock); + }, + + simpleSexpr: function simpleSexpr(sexpr) { + var path = sexpr.path; + path.strict = true; + this.accept(path); + this.opcode('resolvePossibleLambda'); + }, + + helperSexpr: function helperSexpr(sexpr, program, inverse) { + var params = this.setupFullMustacheParams(sexpr, program, inverse), + path = sexpr.path, + name = path.parts[0]; + + if (this.options.knownHelpers[name]) { + this.opcode('invokeKnownHelper', params.length, name); + } else if (this.options.knownHelpersOnly) { + throw new _exception2['default']('You specified knownHelpersOnly, but used the unknown helper ' + name, sexpr); + } else { + path.strict = true; + path.falsy = true; + + this.accept(path); + this.opcode('invokeHelper', params.length, path.original, _ast2['default'].helpers.simpleId(path)); + } + }, + + PathExpression: function PathExpression(path) { + this.addDepth(path.depth); + this.opcode('getContext', path.depth); + + var name = path.parts[0], + scoped = _ast2['default'].helpers.scopedId(path), + blockParamId = !path.depth && !scoped && this.blockParamIndex(name); + + if (blockParamId) { + this.opcode('lookupBlockParam', blockParamId, path.parts); + } else if (!name) { + // Context reference, i.e. `{{foo .}}` or `{{foo ..}}` + this.opcode('pushContext'); + } else if (path.data) { + this.options.data = true; + this.opcode('lookupData', path.depth, path.parts, path.strict); + } else { + this.opcode('lookupOnContext', path.parts, path.falsy, path.strict, scoped); + } + }, + + StringLiteral: function StringLiteral(string) { + this.opcode('pushString', string.value); + }, + + NumberLiteral: function NumberLiteral(number) { + this.opcode('pushLiteral', number.value); + }, + + BooleanLiteral: function BooleanLiteral(bool) { + this.opcode('pushLiteral', bool.value); + }, + + UndefinedLiteral: function UndefinedLiteral() { + this.opcode('pushLiteral', 'undefined'); + }, + + NullLiteral: function NullLiteral() { + this.opcode('pushLiteral', 'null'); + }, + + Hash: function Hash(hash) { + var pairs = hash.pairs, + i = 0, + l = pairs.length; + + this.opcode('pushHash'); + + for (; i < l; i++) { + this.pushParam(pairs[i].value); + } + while (i--) { + this.opcode('assignToHash', pairs[i].key); + } + this.opcode('popHash'); + }, + + // HELPERS + opcode: function opcode(name) { + this.opcodes.push({ opcode: name, +args: slice.call(arguments, 1), +loc: this.sourceNode[0].loc }); + }, + + addDepth: function addDepth(depth) { + if (!depth) { + return; + } + + this.useDepths = true; + }, + + classifySexpr: function classifySexpr(sexpr) { + var isSimple = _ast2['default'].helpers.simpleId(sexpr.path); + + var isBlockParam = isSimple && !!this.blockParamIndex(sexpr.path.parts[0]); + + // a mustache is an eligible helper if: + // * its id is simple (a single part, not `this` or `..`) + var isHelper = !isBlockParam && _ast2['default'].helpers.helperExpression(sexpr); + + // if a mustache is an eligible helper but not a definite + // helper, it is ambiguous, and will be resolved in a later + // pass or at runtime. + var isEligible = !isBlockParam && (isHelper || isSimple); + + // if ambiguous, we can possibly resolve the ambiguity now + // An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc. + if (isEligible && !isHelper) { + var _name2 = sexpr.path.parts[0], + options = this.options; + + if (options.knownHelpers[_name2]) { + isHelper = true; + } else if (options.knownHelpersOnly) { + isEligible = false; + } + } + + if (isHelper) { + return 'helper'; + } else if (isEligible) { + return 'ambiguous'; + } else { + return 'simple'; + } + }, + + pushParams: function pushParams(params) { + for (var i = 0, l = params.length; i < l; i++) { + this.pushParam(params[i]); + } + }, + + pushParam: function pushParam(val) { + var value = val.value != null ? val.value : val.original || ''; + + if (this.stringParams) { + if (value.replace) { + value = value.replace(/^(\.?\.\/)*/g, '').replace(/\//g, '.'); + } + + if (val.depth) { + this.addDepth(val.depth); + } + this.opcode('getContext', val.depth || 0); + this.opcode('pushStringParam', value, val.type); + + if (val.type === 'SubExpression') { + // SubExpressions get evaluated and passed in + // in string params mode. + this.accept(val); + } + } else { + if (this.trackIds) { + var blockParamIndex = undefined; + if (val.parts && !_ast2['default'].helpers.scopedId(val) && !val.depth) { + blockParamIndex = this.blockParamIndex(val.parts[0]); + } + if (blockParamIndex) { + var blockParamChild = val.parts.slice(1).join('.'); + this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild); + } else { + value = val.original || value; + if (value.replace) { + value = value.replace(/^this(?:\.|$)/, '').replace(/^\.\//, '').replace(/^\.$/, ''); + } + + this.opcode('pushId', val.type, value); + } + } + this.accept(val); + } + }, + + setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) { + var params = sexpr.params; + this.pushParams(params); + + this.opcode('pushProgram', program); + this.opcode('pushProgram', inverse); + + if (sexpr.hash) { + this.accept(sexpr.hash); + } else { + this.opcode('emptyHash', omitEmpty); + } + + return params; + }, + + blockParamIndex: function blockParamIndex(name) { + for (var depth = 0, len = this.options.blockParams.length; depth < len; depth++) { + var blockParams = this.options.blockParams[depth], + param = blockParams && _utils.indexOf(blockParams, name); + if (blockParams && param >= 0) { + return [depth, param]; + } + } + } + }; + + function precompile(input, options, env) { + if (input == null || typeof input !== 'string' && input.type !== 'Program') { + throw new _exception2['default']('You must pass a string or Handlebars AST to Handlebars.precompile. You passed ' + input); + } + + options = options || {}; + if (!('data' in options)) { + options.data = true; + } + if (options.compat) { + options.useDepths = true; + } + + var ast = env.parse(input, options), + environment = new env.Compiler().compile(ast, options); + return new env.JavaScriptCompiler().compile(environment, options); + } + + function compile(input, options, env) { + if (options === undefined) options = {}; + + if (input == null || typeof input !== 'string' && input.type !== 'Program') { + throw new _exception2['default']('You must pass a string or Handlebars AST to Handlebars.compile. You passed ' + input); + } + + options = _utils.extend({}, options); + if (!('data' in options)) { + options.data = true; + } + if (options.compat) { + options.useDepths = true; + } + + var compiled = undefined; + + function compileInput() { + var ast = env.parse(input, options), + environment = new env.Compiler().compile(ast, options), + templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); + return env.template(templateSpec); + } + + // Template is only compiled on first use and cached after that point. + function ret(context, execOptions) { + if (!compiled) { + compiled = compileInput(); + } + return compiled.call(this, context, execOptions); + } + ret._setup = function(setupOptions) { + if (!compiled) { + compiled = compileInput(); + } + return compiled._setup(setupOptions); + }; + ret._child = function(i, data, blockParams, depths) { + if (!compiled) { + compiled = compileInput(); + } + return compiled._child(i, data, blockParams, depths); + }; + return ret; + } + + function argEquals(a, b) { + if (a === b) { + return true; + } + + if (_utils.isArray(a) && _utils.isArray(b) && a.length === b.length) { + for (var i = 0; i < a.length; i++) { + if (!argEquals(a[i], b[i])) { + return false; + } + } + return true; + } + } + + function transformLiteralToPath(sexpr) { + if (!sexpr.path.parts) { + var literal = sexpr.path; + // Casting to string here to make false and 0 literal values play nicely with the rest + // of the system. + sexpr.path = { + type: 'PathExpression', + data: false, + depth: 0, + parts: [literal.original + ''], + original: literal.original + '', + loc: literal.loc + }; + } + } + /** */ }), + /* 42 */ + /** */ (function(module, exports, __webpack_require__) { + 'use strict'; + + var _interopRequireDefault = __webpack_require__(1)['default']; + + exports.__esModule = true; + + var _base = __webpack_require__(4); + + var _exception = __webpack_require__(6); + + var _exception2 = _interopRequireDefault(_exception); + + var _utils = __webpack_require__(5); + + var _codeGen = __webpack_require__(43); + + var _codeGen2 = _interopRequireDefault(_codeGen); + + function Literal(value) { + this.value = value; + } + + function JavaScriptCompiler() {} + + JavaScriptCompiler.prototype = { + // PUBLIC API: You can override these methods in a subclass to provide + // alternative compiled forms for name lookup and buffering semantics + nameLookup: function nameLookup(parent, name /* , type*/) { + if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) { + return [parent, '.', name]; + } else { + return [parent, '[', JSON.stringify(name), ']']; + } + }, + depthedLookup: function depthedLookup(name) { + return [this.aliasable('container.lookup'), '(depths, "', name, '")']; + }, + + compilerInfo: function compilerInfo() { + var revision = _base.COMPILER_REVISION, + versions = _base.REVISION_CHANGES[revision]; + return [revision, versions]; + }, + + appendToBuffer: function appendToBuffer(source, location, explicit) { + // Force a source as this simplifies the merge logic. + if (!_utils.isArray(source)) { + source = [source]; + } + source = this.source.wrap(source, location); + + if (this.environment.isSimple) { + return ['return ', source, ';']; + } else if (explicit) { + // This is a case where the buffer operation occurs as a child of another + // construct, generally braces. We have to explicitly output these buffer + // operations to ensure that the emitted code goes in the correct location. + return ['buffer += ', source, ';']; + } else { + source.appendToBuffer = true; + return source; + } + }, + + initializeBuffer: function initializeBuffer() { + return this.quotedString(''); + }, + // END PUBLIC API + + compile: function compile(environment, options, context, asObject) { + this.environment = environment; + this.options = options; + this.stringParams = this.options.stringParams; + this.trackIds = this.options.trackIds; + this.precompile = !asObject; + + this.name = this.environment.name; + this.isChild = !!context; + this.context = context || { + decorators: [], + programs: [], + environments: [] + }; + + this.preamble(); + + this.stackSlot = 0; + this.stackVars = []; + this.aliases = {}; + this.registers = { list: [] }; + this.hashes = []; + this.compileStack = []; + this.inlineStack = []; + this.blockParams = []; + + this.compileChildren(environment, options); + + this.useDepths = this.useDepths || environment.useDepths || environment.useDecorators || this.options.compat; + this.useBlockParams = this.useBlockParams || environment.useBlockParams; + + var opcodes = environment.opcodes, + opcode = undefined, + firstLoc = undefined, + i = undefined, + l = undefined; + + for (i = 0, l = opcodes.length; i < l; i++) { + opcode = opcodes[i]; + + this.source.currentLocation = opcode.loc; + firstLoc = firstLoc || opcode.loc; + this[opcode.opcode].apply(this, opcode.args); + } + + // Flush any trailing content that might be pending. + this.source.currentLocation = firstLoc; + this.pushSource(''); + + /* istanbul ignore next */ + if (this.stackSlot || this.inlineStack.length || this.compileStack.length) { + throw new _exception2['default']('Compile completed with content left on stack'); + } + + if (!this.decorators.isEmpty()) { + this.useDecorators = true; + + this.decorators.prepend('var decorators = container.decorators;\n'); + this.decorators.push('return fn;'); + + if (asObject) { + this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]); + } else { + this.decorators.prepend('function(fn, props, container, depth0, data, blockParams, depths) {\n'); + this.decorators.push('}\n'); + this.decorators = this.decorators.merge(); + } + } else { + this.decorators = undefined; + } + + var fn = this.createFunctionContext(asObject); + if (!this.isChild) { + var ret = { + compiler: this.compilerInfo(), + main: fn + }; + + if (this.decorators) { + ret.main_d = this.decorators; // eslint-disable-line camelcase + ret.useDecorators = true; + } + + var _context = this.context; + var programs = _context.programs; + var decorators = _context.decorators; + + for (i = 0, l = programs.length; i < l; i++) { + if (programs[i]) { + ret[i] = programs[i]; + if (decorators[i]) { + ret[i + '_d'] = decorators[i]; + ret.useDecorators = true; + } + } + } + + if (this.environment.usePartial) { + ret.usePartial = true; + } + if (this.options.data) { + ret.useData = true; + } + if (this.useDepths) { + ret.useDepths = true; + } + if (this.useBlockParams) { + ret.useBlockParams = true; + } + if (this.options.compat) { + ret.compat = true; + } + + if (!asObject) { + ret.compiler = JSON.stringify(ret.compiler); + + this.source.currentLocation = { start: { line: 1, +column: 0 } }; + ret = this.objectLiteral(ret); + + if (options.srcName) { + ret = ret.toStringWithSourceMap({ file: options.destName }); + ret.map = ret.map && ret.map.toString(); + } else { + ret = ret.toString(); + } + } else { + ret.compilerOptions = this.options; + } + + return ret; + } else { + return fn; + } + }, + + preamble: function preamble() { + // track the last context pushed into place to allow skipping the + // getContext opcode when it would be a noop + this.lastContext = 0; + this.source = new _codeGen2['default'](this.options.srcName); + this.decorators = new _codeGen2['default'](this.options.srcName); + }, + + createFunctionContext: function createFunctionContext(asObject) { + var varDeclarations = ''; + + var locals = this.stackVars.concat(this.registers.list); + if (locals.length > 0) { + varDeclarations += ', ' + locals.join(', '); + } + + // Generate minimizer alias mappings + // + // When using true SourceNodes, this will update all references to the given alias + // as the source nodes are reused in situ. For the non-source node compilation mode, + // aliases will not be used, but this case is already being run on the client and + // we aren't concern about minimizing the template size. + var aliasCount = 0; + for (var alias in this.aliases) { + // eslint-disable-line guard-for-in + var node = this.aliases[alias]; + + if (this.aliases.hasOwnProperty(alias) && node.children && node.referenceCount > 1) { + varDeclarations += ', alias' + ++aliasCount + '=' + alias; + node.children[0] = 'alias' + aliasCount; + } + } + + var params = ['container', 'depth0', 'helpers', 'partials', 'data']; + + if (this.useBlockParams || this.useDepths) { + params.push('blockParams'); + } + if (this.useDepths) { + params.push('depths'); + } + + // Perform a second pass over the output to merge content when possible + var source = this.mergeSource(varDeclarations); + + if (asObject) { + params.push(source); + + return Function.apply(this, params); + } else { + return this.source.wrap(['function(', params.join(','), ') {\n ', source, '}']); + } + }, + mergeSource: function mergeSource(varDeclarations) { + var isSimple = this.environment.isSimple, + appendOnly = !this.forceBuffer, + appendFirst = undefined, + sourceSeen = undefined, + bufferStart = undefined, + bufferEnd = undefined; + this.source.each(function(line) { + if (line.appendToBuffer) { + if (bufferStart) { + line.prepend(' + '); + } else { + bufferStart = line; + } + bufferEnd = line; + } else { + if (bufferStart) { + if (!sourceSeen) { + appendFirst = true; + } else { + bufferStart.prepend('buffer += '); + } + bufferEnd.add(';'); + bufferStart = bufferEnd = undefined; + } + + sourceSeen = true; + if (!isSimple) { + appendOnly = false; + } + } + }); + + if (appendOnly) { + if (bufferStart) { + bufferStart.prepend('return '); + bufferEnd.add(';'); + } else if (!sourceSeen) { + this.source.push('return "";'); + } + } else { + varDeclarations += ', buffer = ' + (appendFirst ? '' : this.initializeBuffer()); + + if (bufferStart) { + bufferStart.prepend('return buffer + '); + bufferEnd.add(';'); + } else { + this.source.push('return buffer;'); + } + } + + if (varDeclarations) { + this.source.prepend('var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n')); + } + + return this.source.merge(); + }, + + // [blockValue] + // + // On stack, before: hash, inverse, program, value + // On stack, after: return value of blockHelperMissing + // + // The purpose of this opcode is to take a block of the form + // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and + // replace it on the stack with the result of properly + // invoking blockHelperMissing. + blockValue: function blockValue(name) { + var blockHelperMissing = this.aliasable('helpers.blockHelperMissing'), + params = [this.contextName(0)]; + this.setupHelperArgs(name, 0, params); + + var blockName = this.popStack(); + params.splice(1, 0, blockName); + + this.push(this.source.functionCall(blockHelperMissing, 'call', params)); + }, + + // [ambiguousBlockValue] + // + // On stack, before: hash, inverse, program, value + // Compiler value, before: lastHelper=value of last found helper, if any + // On stack, after, if no lastHelper: same as [blockValue] + // On stack, after, if lastHelper: value + ambiguousBlockValue: function ambiguousBlockValue() { + // We're being a bit cheeky and reusing the options value from the prior exec + var blockHelperMissing = this.aliasable('helpers.blockHelperMissing'), + params = [this.contextName(0)]; + this.setupHelperArgs('', 0, params, true); + + this.flushInline(); + + var current = this.topStack(); + params.splice(1, 0, current); + + this.pushSource(['if (!', this.lastHelper, ') { ', current, ' = ', this.source.functionCall(blockHelperMissing, 'call', params), '}']); + }, + + // [appendContent] + // + // On stack, before: ... + // On stack, after: ... + // + // Appends the string value of `content` to the current buffer + appendContent: function appendContent(content) { + if (this.pendingContent) { + content = this.pendingContent + content; + } else { + this.pendingLocation = this.source.currentLocation; + } + + this.pendingContent = content; + }, + + // [append] + // + // On stack, before: value, ... + // On stack, after: ... + // + // Coerces `value` to a String and appends it to the current buffer. + // + // If `value` is truthy, or 0, it is coerced into a string and appended + // Otherwise, the empty string is appended + append: function append() { + if (this.isInline()) { + this.replaceStack(function(current) { + return [' != null ? ', current, ' : ""']; + }); + + this.pushSource(this.appendToBuffer(this.popStack())); + } else { + var local = this.popStack(); + this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']); + if (this.environment.isSimple) { + this.pushSource(['else { ', this.appendToBuffer('\'\'', undefined, true), ' }']); + } + } + }, + + // [appendEscaped] + // + // On stack, before: value, ... + // On stack, after: ... + // + // Escape `value` and append it to the buffer + appendEscaped: function appendEscaped() { + this.pushSource(this.appendToBuffer([this.aliasable('container.escapeExpression'), '(', this.popStack(), ')'])); + }, + + // [getContext] + // + // On stack, before: ... + // On stack, after: ... + // Compiler value, after: lastContext=depth + // + // Set the value of the `lastContext` compiler value to the depth + getContext: function getContext(depth) { + this.lastContext = depth; + }, + + // [pushContext] + // + // On stack, before: ... + // On stack, after: currentContext, ... + // + // Pushes the value of the current context onto the stack. + pushContext: function pushContext() { + this.pushStackLiteral(this.contextName(this.lastContext)); + }, + + // [lookupOnContext] + // + // On stack, before: ... + // On stack, after: currentContext[name], ... + // + // Looks up the value of `name` on the current context and pushes + // it onto the stack. + lookupOnContext: function lookupOnContext(parts, falsy, strict, scoped) { + var i = 0; + + if (!scoped && this.options.compat && !this.lastContext) { + // The depthed query is expected to handle the undefined logic for the root level that + // is implemented below, so we evaluate that directly in compat mode + this.push(this.depthedLookup(parts[i++])); + } else { + this.pushContext(); + } + + this.resolvePath('context', parts, i, falsy, strict); + }, + + // [lookupBlockParam] + // + // On stack, before: ... + // On stack, after: blockParam[name], ... + // + // Looks up the value of `parts` on the given block param and pushes + // it onto the stack. + lookupBlockParam: function lookupBlockParam(blockParamId, parts) { + this.useBlockParams = true; + + this.push(['blockParams[', blockParamId[0], '][', blockParamId[1], ']']); + this.resolvePath('context', parts, 1); + }, + + // [lookupData] + // + // On stack, before: ... + // On stack, after: data, ... + // + // Push the data lookup operator + lookupData: function lookupData(depth, parts, strict) { + if (!depth) { + this.pushStackLiteral('data'); + } else { + this.pushStackLiteral('container.data(data, ' + depth + ')'); + } + + this.resolvePath('data', parts, 0, true, strict); + }, + + resolvePath: function resolvePath(type, parts, i, falsy, strict) { + // istanbul ignore next + + var _this = this; + + if (this.options.strict || this.options.assumeObjects) { + this.push(strictLookup(this.options.strict && strict, this, parts, type)); + return; + } + + var len = parts.length; + for (; i < len; i++) { + /* eslint-disable no-loop-func */ + this.replaceStack(function(current) { + var lookup = _this.nameLookup(current, parts[i], type); + // We want to ensure that zero and false are handled properly if the context (falsy flag) + // needs to have the special handling for these values. + if (!falsy) { + return [' != null ? ', lookup, ' : ', current]; + } else { + // Otherwise we can use generic falsy handling + return [' && ', lookup]; + } + }); + /* eslint-enable no-loop-func */ + } + }, + + // [resolvePossibleLambda] + // + // On stack, before: value, ... + // On stack, after: resolved value, ... + // + // If the `value` is a lambda, replace it on the stack by + // the return value of the lambda + resolvePossibleLambda: function resolvePossibleLambda() { + this.push([this.aliasable('container.lambda'), '(', this.popStack(), ', ', this.contextName(0), ')']); + }, + + // [pushStringParam] + // + // On stack, before: ... + // On stack, after: string, currentContext, ... + // + // This opcode is designed for use in string mode, which + // provides the string value of a parameter along with its + // depth rather than resolving it immediately. + pushStringParam: function pushStringParam(string, type) { + this.pushContext(); + this.pushString(type); + + // If it's a subexpression, the string result + // will be pushed after this opcode. + if (type !== 'SubExpression') { + if (typeof string === 'string') { + this.pushString(string); + } else { + this.pushStackLiteral(string); + } + } + }, + + emptyHash: function emptyHash(omitEmpty) { + if (this.trackIds) { + this.push('{}'); // hashIds + } + if (this.stringParams) { + this.push('{}'); // hashContexts + this.push('{}'); // hashTypes + } + this.pushStackLiteral(omitEmpty ? 'undefined' : '{}'); + }, + pushHash: function pushHash() { + if (this.hash) { + this.hashes.push(this.hash); + } + this.hash = { values: [], +types: [], +contexts: [], +ids: [] }; + }, + popHash: function popHash() { + var hash = this.hash; + this.hash = this.hashes.pop(); + + if (this.trackIds) { + this.push(this.objectLiteral(hash.ids)); + } + if (this.stringParams) { + this.push(this.objectLiteral(hash.contexts)); + this.push(this.objectLiteral(hash.types)); + } + + this.push(this.objectLiteral(hash.values)); + }, + + // [pushString] + // + // On stack, before: ... + // On stack, after: quotedString(string), ... + // + // Push a quoted version of `string` onto the stack + pushString: function pushString(string) { + this.pushStackLiteral(this.quotedString(string)); + }, + + // [pushLiteral] + // + // On stack, before: ... + // On stack, after: value, ... + // + // Pushes a value onto the stack. This operation prevents + // the compiler from creating a temporary variable to hold + // it. + pushLiteral: function pushLiteral(value) { + this.pushStackLiteral(value); + }, + + // [pushProgram] + // + // On stack, before: ... + // On stack, after: program(guid), ... + // + // Push a program expression onto the stack. This takes + // a compile-time guid and converts it into a runtime-accessible + // expression. + pushProgram: function pushProgram(guid) { + if (guid != null) { + this.pushStackLiteral(this.programExpression(guid)); + } else { + this.pushStackLiteral(null); + } + }, + + // [registerDecorator] + // + // On stack, before: hash, program, params..., ... + // On stack, after: ... + // + // Pops off the decorator's parameters, invokes the decorator, + // and inserts the decorator into the decorators list. + registerDecorator: function registerDecorator(paramSize, name) { + var foundDecorator = this.nameLookup('decorators', name, 'decorator'), + options = this.setupHelperArgs(name, paramSize); + + this.decorators.push(['fn = ', this.decorators.functionCall(foundDecorator, '', ['fn', 'props', 'container', options]), ' || fn;']); + }, + + // [invokeHelper] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of helper invocation + // + // Pops off the helper's parameters, invokes the helper, + // and pushes the helper's return value onto the stack. + // + // If the helper is not found, `helperMissing` is called. + invokeHelper: function invokeHelper(paramSize, name, isSimple) { + var nonHelper = this.popStack(), + helper = this.setupHelper(paramSize, name), + simple = isSimple ? [helper.name, ' || '] : ''; + + var lookup = ['('].concat(simple, nonHelper); + if (!this.options.strict) { + lookup.push(' || ', this.aliasable('helpers.helperMissing')); + } + lookup.push(')'); + + this.push(this.source.functionCall(lookup, 'call', helper.callParams)); + }, + + // [invokeKnownHelper] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of helper invocation + // + // This operation is used when the helper is known to exist, + // so a `helperMissing` fallback is not required. + invokeKnownHelper: function invokeKnownHelper(paramSize, name) { + var helper = this.setupHelper(paramSize, name); + this.push(this.source.functionCall(helper.name, 'call', helper.callParams)); + }, + + // [invokeAmbiguous] + // + // On stack, before: hash, inverse, program, params..., ... + // On stack, after: result of disambiguation + // + // This operation is used when an expression like `{{foo}}` + // is provided, but we don't know at compile-time whether it + // is a helper or a path. + // + // This operation emits more code than the other options, + // and can be avoided by passing the `knownHelpers` and + // `knownHelpersOnly` flags at compile-time. + invokeAmbiguous: function invokeAmbiguous(name, helperCall) { + this.useRegister('helper'); + + var nonHelper = this.popStack(); + + this.emptyHash(); + var helper = this.setupHelper(0, name, helperCall); + + var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper'); + + var lookup = ['(', '(helper = ', helperName, ' || ', nonHelper, ')']; + if (!this.options.strict) { + lookup[0] = '(helper = '; + lookup.push(' != null ? helper : ', this.aliasable('helpers.helperMissing')); + } + + this.push(['(', lookup, helper.paramsInit ? ['),(', helper.paramsInit] : [], '),', '(typeof helper === ', this.aliasable('"function"'), ' ? ', this.source.functionCall('helper', 'call', helper.callParams), ' : helper))']); + }, + + // [invokePartial] + // + // On stack, before: context, ... + // On stack after: result of partial invocation + // + // This operation pops off a context, invokes a partial with that context, + // and pushes the result of the invocation back. + invokePartial: function invokePartial(isDynamic, name, indent) { + var params = [], + options = this.setupParams(name, 1, params); + + if (isDynamic) { + name = this.popStack(); + delete options.name; + } + + if (indent) { + options.indent = JSON.stringify(indent); + } + options.helpers = 'helpers'; + options.partials = 'partials'; + options.decorators = 'container.decorators'; + + if (!isDynamic) { + params.unshift(this.nameLookup('partials', name, 'partial')); + } else { + params.unshift(name); + } + + if (this.options.compat) { + options.depths = 'depths'; + } + options = this.objectLiteral(options); + params.push(options); + + this.push(this.source.functionCall('container.invokePartial', '', params)); + }, + + // [assignToHash] + // + // On stack, before: value, ..., hash, ... + // On stack, after: ..., hash, ... + // + // Pops a value off the stack and assigns it to the current hash + assignToHash: function assignToHash(key) { + var value = this.popStack(), + context = undefined, + type = undefined, + id = undefined; + + if (this.trackIds) { + id = this.popStack(); + } + if (this.stringParams) { + type = this.popStack(); + context = this.popStack(); + } + + var hash = this.hash; + if (context) { + hash.contexts[key] = context; + } + if (type) { + hash.types[key] = type; + } + if (id) { + hash.ids[key] = id; + } + hash.values[key] = value; + }, + + pushId: function pushId(type, name, child) { + if (type === 'BlockParam') { + this.pushStackLiteral('blockParams[' + name[0] + '].path[' + name[1] + ']' + (child ? ' + ' + JSON.stringify('.' + child) : '')); + } else if (type === 'PathExpression') { + this.pushString(name); + } else if (type === 'SubExpression') { + this.pushStackLiteral('true'); + } else { + this.pushStackLiteral('null'); + } + }, + + // HELPERS + + compiler: JavaScriptCompiler, + + compileChildren: function compileChildren(environment, options) { + var children = environment.children, + child = undefined, + compiler = undefined; + + for (var i = 0, l = children.length; i < l; i++) { + child = children[i]; + compiler = new this.compiler(); // eslint-disable-line new-cap + + var existing = this.matchExistingProgram(child); + + if (existing == null) { + this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children + var index = this.context.programs.length; + child.index = index; + child.name = 'program' + index; + this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile); + this.context.decorators[index] = compiler.decorators; + this.context.environments[index] = child; + + this.useDepths = this.useDepths || compiler.useDepths; + this.useBlockParams = this.useBlockParams || compiler.useBlockParams; + child.useDepths = this.useDepths; + child.useBlockParams = this.useBlockParams; + } else { + child.index = existing.index; + child.name = 'program' + existing.index; + + this.useDepths = this.useDepths || existing.useDepths; + this.useBlockParams = this.useBlockParams || existing.useBlockParams; + } + } + }, + matchExistingProgram: function matchExistingProgram(child) { + for (var i = 0, len = this.context.environments.length; i < len; i++) { + var environment = this.context.environments[i]; + if (environment && environment.equals(child)) { + return environment; + } + } + }, + + programExpression: function programExpression(guid) { + var child = this.environment.children[guid], + programParams = [child.index, 'data', child.blockParams]; + + if (this.useBlockParams || this.useDepths) { + programParams.push('blockParams'); + } + if (this.useDepths) { + programParams.push('depths'); + } + + return 'container.program(' + programParams.join(', ') + ')'; + }, + + useRegister: function useRegister(name) { + if (!this.registers[name]) { + this.registers[name] = true; + this.registers.list.push(name); + } + }, + + push: function push(expr) { + if (!(expr instanceof Literal)) { + expr = this.source.wrap(expr); + } + + this.inlineStack.push(expr); + return expr; + }, + + pushStackLiteral: function pushStackLiteral(item) { + this.push(new Literal(item)); + }, + + pushSource: function pushSource(source) { + if (this.pendingContent) { + this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent), this.pendingLocation)); + this.pendingContent = undefined; + } + + if (source) { + this.source.push(source); + } + }, + + replaceStack: function replaceStack(callback) { + var prefix = ['('], + stack = undefined, + createdStack = undefined, + usedLiteral = undefined; + + /* istanbul ignore next */ + if (!this.isInline()) { + throw new _exception2['default']('replaceStack on non-inline'); + } + + // We want to merge the inline statement into the replacement statement via ',' + var top = this.popStack(true); + + if (top instanceof Literal) { + // Literals do not need to be inlined + stack = [top.value]; + prefix = ['(', stack]; + usedLiteral = true; + } else { + // Get or create the current stack name for use by the inline + createdStack = true; + var _name = this.incrStack(); + + prefix = ['((', this.push(_name), ' = ', top, ')']; + stack = this.topStack(); + } + + var item = callback.call(this, stack); + + if (!usedLiteral) { + this.popStack(); + } + if (createdStack) { + this.stackSlot--; + } + this.push(prefix.concat(item, ')')); + }, + + incrStack: function incrStack() { + this.stackSlot++; + if (this.stackSlot > this.stackVars.length) { + this.stackVars.push('stack' + this.stackSlot); + } + return this.topStackName(); + }, + topStackName: function topStackName() { + return 'stack' + this.stackSlot; + }, + flushInline: function flushInline() { + var inlineStack = this.inlineStack; + this.inlineStack = []; + for (var i = 0, len = inlineStack.length; i < len; i++) { + var entry = inlineStack[i]; + /* istanbul ignore if */ + if (entry instanceof Literal) { + this.compileStack.push(entry); + } else { + var stack = this.incrStack(); + this.pushSource([stack, ' = ', entry, ';']); + this.compileStack.push(stack); + } + } + }, + isInline: function isInline() { + return this.inlineStack.length; + }, + + popStack: function popStack(wrapped) { + var inline = this.isInline(), + item = (inline ? this.inlineStack : this.compileStack).pop(); + + if (!wrapped && item instanceof Literal) { + return item.value; + } else { + if (!inline) { + /* istanbul ignore next */ + if (!this.stackSlot) { + throw new _exception2['default']('Invalid stack pop'); + } + this.stackSlot--; + } + return item; + } + }, + + topStack: function topStack() { + var stack = this.isInline() ? this.inlineStack : this.compileStack, + item = stack[stack.length - 1]; + + /* istanbul ignore if */ + if (item instanceof Literal) { + return item.value; + } else { + return item; + } + }, + + contextName: function contextName(context) { + if (this.useDepths && context) { + return 'depths[' + context + ']'; + } else { + return 'depth' + context; + } + }, + + quotedString: function quotedString(str) { + return this.source.quotedString(str); + }, + + objectLiteral: function objectLiteral(obj) { + return this.source.objectLiteral(obj); + }, + + aliasable: function aliasable(name) { + var ret = this.aliases[name]; + if (ret) { + ret.referenceCount++; + return ret; + } + + ret = this.aliases[name] = this.source.wrap(name); + ret.aliasable = true; + ret.referenceCount = 1; + + return ret; + }, + + setupHelper: function setupHelper(paramSize, name, blockHelper) { + var params = [], + paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper); + var foundHelper = this.nameLookup('helpers', name, 'helper'), + callContext = this.aliasable(this.contextName(0) + ' != null ? ' + this.contextName(0) + ' : (container.nullContext || {})'); + + return { + params: params, + paramsInit: paramsInit, + name: foundHelper, + callParams: [callContext].concat(params) + }; + }, + + setupParams: function setupParams(helper, paramSize, params) { + var options = {}, + contexts = [], + types = [], + ids = [], + objectArgs = !params, + param = undefined; + + if (objectArgs) { + params = []; + } + + options.name = this.quotedString(helper); + options.hash = this.popStack(); + + if (this.trackIds) { + options.hashIds = this.popStack(); + } + if (this.stringParams) { + options.hashTypes = this.popStack(); + options.hashContexts = this.popStack(); + } + + var inverse = this.popStack(), + program = this.popStack(); + + // Avoid setting fn and inverse if neither are set. This allows + // helpers to do a check for `if (options.fn)` + if (program || inverse) { + options.fn = program || 'container.noop'; + options.inverse = inverse || 'container.noop'; + } + + // The parameters go on to the stack in order (making sure that they are evaluated in order) + // so we need to pop them off the stack in reverse order + var i = paramSize; + while (i--) { + param = this.popStack(); + params[i] = param; + + if (this.trackIds) { + ids[i] = this.popStack(); + } + if (this.stringParams) { + types[i] = this.popStack(); + contexts[i] = this.popStack(); + } + } + + if (objectArgs) { + options.args = this.source.generateArray(params); + } + + if (this.trackIds) { + options.ids = this.source.generateArray(ids); + } + if (this.stringParams) { + options.types = this.source.generateArray(types); + options.contexts = this.source.generateArray(contexts); + } + + if (this.options.data) { + options.data = 'data'; + } + if (this.useBlockParams) { + options.blockParams = 'blockParams'; + } + return options; + }, + + setupHelperArgs: function setupHelperArgs(helper, paramSize, params, useRegister) { + var options = this.setupParams(helper, paramSize, params); + options = this.objectLiteral(options); + if (useRegister) { + this.useRegister('options'); + params.push('options'); + return ['options=', options]; + } else if (params) { + params.push(options); + return ''; + } else { + return options; + } + } + }; + + (function() { + var reservedWords = ('break else new var' + ' case finally return void' + ' catch for switch while' + ' continue function this with' + ' default if throw' + ' delete in try' + ' do instanceof typeof' + ' abstract enum int short' + ' boolean export interface static' + ' byte extends long super' + ' char final native synchronized' + ' class float package throws' + ' const goto private transient' + ' debugger implements protected volatile' + ' double import public let yield await' + ' null true false').split(' '); + + var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; + + for (var i = 0, l = reservedWords.length; i < l; i++) { + compilerWords[reservedWords[i]] = true; + } + })(); + + JavaScriptCompiler.isValidJavaScriptVariableName = function(name) { + return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name); + }; + + function strictLookup(requireTerminal, compiler, parts, type) { + var stack = compiler.popStack(), + i = 0, + len = parts.length; + if (requireTerminal) { + len--; + } + + for (; i < len; i++) { + stack = compiler.nameLookup(stack, parts[i], type); + } + + if (requireTerminal) { + return [compiler.aliasable('container.strict'), '(', stack, ', ', compiler.quotedString(parts[i]), ')']; + } else { + return stack; + } + } + + exports['default'] = JavaScriptCompiler; + module.exports = exports['default']; + /** */ }), + /* 43 */ + /** */ (function(module, exports, __webpack_require__) { + /* global define */ + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(5); + + var SourceNode = undefined; + + try { + /* istanbul ignore next */ + if (false) { + // We don't support this in AMD environments. For these environments, we asusme that + // they are running on the browser and thus have no need for the source-map library. + var SourceMap = require('source-map'); + SourceNode = SourceMap.SourceNode; + } + } catch (err) {} + /* NOP */ + + /* istanbul ignore if: tested but not covered in istanbul due to dist build */ + if (!SourceNode) { + SourceNode = function(line, column, srcFile, chunks) { + this.src = ''; + if (chunks) { + this.add(chunks); + } + }; + /* istanbul ignore next */ + SourceNode.prototype = { + add: function add(chunks) { + if (_utils.isArray(chunks)) { + chunks = chunks.join(''); + } + this.src += chunks; + }, + prepend: function prepend(chunks) { + if (_utils.isArray(chunks)) { + chunks = chunks.join(''); + } + this.src = chunks + this.src; + }, + toStringWithSourceMap: function toStringWithSourceMap() { + return { code: this.toString() }; + }, + toString: function toString() { + return this.src; + } + }; + } + + function castChunk(chunk, codeGen, loc) { + if (_utils.isArray(chunk)) { + var ret = []; + + for (var i = 0, len = chunk.length; i < len; i++) { + ret.push(codeGen.wrap(chunk[i], loc)); + } + return ret; + } else if (typeof chunk === 'boolean' || typeof chunk === 'number') { + // Handle primitives that the SourceNode will throw up on + return chunk + ''; + } + return chunk; + } + + function CodeGen(srcFile) { + this.srcFile = srcFile; + this.source = []; + } + + CodeGen.prototype = { + isEmpty: function isEmpty() { + return !this.source.length; + }, + prepend: function prepend(source, loc) { + this.source.unshift(this.wrap(source, loc)); + }, + push: function push(source, loc) { + this.source.push(this.wrap(source, loc)); + }, + + merge: function merge() { + var source = this.empty(); + this.each(function(line) { + source.add([' ', line, '\n']); + }); + return source; + }, + + each: function each(iter) { + for (var i = 0, len = this.source.length; i < len; i++) { + iter(this.source[i]); + } + }, + + empty: function empty() { + var loc = this.currentLocation || { start: {} }; + return new SourceNode(loc.start.line, loc.start.column, this.srcFile); + }, + wrap: function wrap(chunk) { + var loc = arguments.length <= 1 || arguments[1] === undefined ? this.currentLocation || { start: {} } : arguments[1]; + + if (chunk instanceof SourceNode) { + return chunk; + } + + chunk = castChunk(chunk, this, loc); + + return new SourceNode(loc.start.line, loc.start.column, this.srcFile, chunk); + }, + + functionCall: function functionCall(fn, type, params) { + params = this.generateList(params); + return this.wrap([fn, type ? '.' + type + '(' : '(', params, ')']); + }, + + quotedString: function quotedString(str) { + return '"' + (str + '').replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 + .replace(/\u2029/g, '\\u2029') + '"'; + }, + + objectLiteral: function objectLiteral(obj) { + var pairs = []; + + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + var value = castChunk(obj[key], this); + if (value !== 'undefined') { + pairs.push([this.quotedString(key), ':', value]); + } + } + } + + var ret = this.generateList(pairs); + ret.prepend('{'); + ret.add('}'); + return ret; + }, + + generateList: function generateList(entries) { + var ret = this.empty(); + + for (var i = 0, len = entries.length; i < len; i++) { + if (i) { + ret.add(','); + } + + ret.add(castChunk(entries[i], this)); + } + + return ret; + }, + + generateArray: function generateArray(entries) { + var ret = this.generateList(entries); + ret.prepend('['); + ret.add(']'); + + return ret; + } + }; + + exports['default'] = CodeGen; + module.exports = exports['default']; + /** */ }) + /** ****/ ]); +}); +; \ No newline at end of file diff --git a/assets/js/login.js b/assets/js/login.js new file mode 100644 index 00000000..e36839e1 --- /dev/null +++ b/assets/js/login.js @@ -0,0 +1,40 @@ +// Initialize Firebase +var config = { + apiKey: 'AIzaSyCmcnWQF8G_WUg0e9P4qyLFhLzkuB3YN_I', + authDomain: 'ecommerce2-6c1f4.firebaseapp.com', + databaseURL: 'https://ecommerce2-6c1f4.firebaseio.com', + projectId: 'ecommerce2-6c1f4', + storageBucket: 'ecommerce2-6c1f4.appspot.com', + messagingSenderId: '192229541944' +}; +firebase.initializeApp(config); + +var provider = new firebase.auth.GoogleAuthProvider(); +$('#btn-Google').click(function() { + firebase.auth().signInWithPopup(provider).then(function(data) { + var user = data.user; + console.log(user); + var name = user.displayName; + $('h3').text(user.displayName); + console.log(user.displayName); + }).catch(function(error) { + console.log(error); + }); +}); +firebase.auth().onAuthStateChanged(function(user) { + if (user) { + $('h3').text(user.displayName); + $('.inicio').hide; + $('.usuario').show; + } else { + $('.inicio').show; + $('.usuario').hide; + } +}); +// cerrar session +$('#cerrar').click(function() { + firebase.auth().signOut().then(function() { + $('.inicio').show; + $('.usuario').hide; + }); +}); \ No newline at end of file diff --git a/assets/js/sammy-latest.min.js b/assets/js/sammy-latest.min.js new file mode 100644 index 00000000..a08d509b --- /dev/null +++ b/assets/js/sammy-latest.min.js @@ -0,0 +1,5 @@ +// -- Sammy.js -- /sammy.js +// http://sammyjs.org +// Version: 0.7.6 +// Built: 2014-08-26 10:45:34 +0300 +(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{jQuery.sammy=window.Sammy=factory(jQuery)}})(function($){var Sammy,PATH_REPLACER="([^/]+)",PATH_NAME_MATCHER=/:([\w\d]+)/g,QUERY_STRING_MATCHER=/\?([^#]*)?$/,_makeArray=function(nonarray){return Array.prototype.slice.call(nonarray)},_isFunction=function(obj){return Object.prototype.toString.call(obj)==="[object Function]"},_isArray=function(obj){return Object.prototype.toString.call(obj)==="[object Array]"},_isRegExp=function(obj){return Object.prototype.toString.call(obj)==="[object RegExp]"},_decode=function(str){return decodeURIComponent((str||"").replace(/\+/g," "))},_encode=encodeURIComponent,_escapeHTML=function(s){return String(s).replace(/&(?!\w+;)/g,"&").replace(//g,">").replace(/"/g,""")},_routeWrapper=function(verb){return function(){return this.route.apply(this,[verb].concat(Array.prototype.slice.call(arguments)))}},_template_cache={},_has_history=!!(window.history&&history.pushState),loggers=[];Sammy=function(){var args=_makeArray(arguments),app,selector;Sammy.apps=Sammy.apps||{};if(args.length===0||args[0]&&_isFunction(args[0])){return Sammy.apply(Sammy,["body"].concat(args))}else if(typeof(selector=args.shift())=="string"){app=Sammy.apps[selector]||new Sammy.Application;app.element_selector=selector;if(args.length>0){$.each(args,function(i,plugin){app.use(plugin)})}if(app.element_selector!=selector){delete Sammy.apps[selector]}Sammy.apps[app.element_selector]=app;return app}};Sammy.VERSION="0.7.6";Sammy.addLogger=function(logger){loggers.push(logger)};Sammy.log=function(){var args=_makeArray(arguments);args.unshift("["+Date()+"]");$.each(loggers,function(i,logger){logger.apply(Sammy,args)})};if(typeof window.console!="undefined"){if(typeof window.console.log==="function"&&_isFunction(window.console.log.apply)){Sammy.addLogger(function(){window.console.log.apply(window.console,arguments)})}else{Sammy.addLogger(function(){window.console.log(arguments)})}}else if(typeof console!="undefined"){Sammy.addLogger(function(){console.log.apply(console,arguments)})}$.extend(Sammy,{makeArray:_makeArray,isFunction:_isFunction,isArray:_isArray});Sammy.Object=function(obj){return $.extend(this,obj||{})};$.extend(Sammy.Object.prototype,{escapeHTML:_escapeHTML,h:_escapeHTML,toHash:function(){var json={};$.each(this,function(k,v){if(!_isFunction(v)){json[k]=v}});return json},toHTML:function(){var display="";$.each(this,function(k,v){if(!_isFunction(v)){display+=""+k+" "+v+"
"}});return display},keys:function(attributes_only){var keys=[];for(var property in this){if(!_isFunction(this[property])||!attributes_only){keys.push(property)}}return keys},has:function(key){return this[key]&&$.trim(this[key].toString())!==""},join:function(){var args=_makeArray(arguments);var delimiter=args.shift();return args.join(delimiter)},log:function(){Sammy.log.apply(Sammy,arguments)},toString:function(include_functions){var s=[];$.each(this,function(k,v){if(!_isFunction(v)||include_functions){s.push('"'+k+'": '+v.toString())}});return"Sammy.Object: {"+s.join(",")+"}"}});Sammy.targetIsThisWindow=function targetIsThisWindow(event,tagName){var targetElement=$(event.target).closest(tagName);if(targetElement.length===0){return true}var targetWindow=targetElement.attr("target");if(!targetWindow||targetWindow===window.name||targetWindow==="_self"){return true}if(targetWindow==="_blank"){return false}if(targetWindow==="top"&&window===window.top){return true}return false};Sammy.DefaultLocationProxy=function(app,run_interval_every){this.app=app;this.is_native=false;this.has_history=_has_history;this._startPolling(run_interval_every)};Sammy.DefaultLocationProxy.fullPath=function(location_obj){var matches=location_obj.toString().match(/^[^#]*(#.+)$/);var hash=matches?matches[1]:"";return[location_obj.pathname,location_obj.search,hash].join("")};$.extend(Sammy.DefaultLocationProxy.prototype,{bind:function(){var proxy=this,app=this.app,lp=Sammy.DefaultLocationProxy;$(window).bind("hashchange."+this.app.eventNamespace(),function(e,non_native){if(proxy.is_native===false&&!non_native){proxy.is_native=true;window.clearInterval(lp._interval);lp._interval=null}app.trigger("location-changed")});if(_has_history&&!app.disable_push_state){$(window).bind("popstate."+this.app.eventNamespace(),function(e){app.trigger("location-changed")});$(document).delegate("a","click.history-"+this.app.eventNamespace(),function(e){if(e.isDefaultPrevented()||e.metaKey||e.ctrlKey){return}var full_path=lp.fullPath(this),hostname=this.hostname?this.hostname:function(a){var l=document.createElement("a");l.href=a.href;return l.hostname}(this);if(hostname==window.location.hostname&&app.lookupRoute("get",full_path)&&Sammy.targetIsThisWindow(e,"a")){e.preventDefault();proxy.setLocation(full_path);return false}})}if(!lp._bindings){lp._bindings=0}lp._bindings++},unbind:function(){$(window).unbind("hashchange."+this.app.eventNamespace());$(window).unbind("popstate."+this.app.eventNamespace());$(document).undelegate("a","click.history-"+this.app.eventNamespace());Sammy.DefaultLocationProxy._bindings--;if(Sammy.DefaultLocationProxy._bindings<=0){window.clearInterval(Sammy.DefaultLocationProxy._interval);Sammy.DefaultLocationProxy._interval=null}},getLocation:function(){return Sammy.DefaultLocationProxy.fullPath(window.location)},setLocation:function(new_location){if(/^([^#\/]|$)/.test(new_location)){if(_has_history&&!this.app.disable_push_state){new_location="/"+new_location}else{new_location="#!/"+new_location}}if(new_location!=this.getLocation()){if(_has_history&&!this.app.disable_push_state&&/^\//.test(new_location)){history.pushState({path:new_location},window.title,new_location);this.app.trigger("location-changed")}else{return window.location=new_location}}},_startPolling:function(every){var proxy=this;if(!Sammy.DefaultLocationProxy._interval){if(!every){every=10}var hashCheck=function(){var current_location=proxy.getLocation();if(typeof Sammy.DefaultLocationProxy._last_location=="undefined"||current_location!=Sammy.DefaultLocationProxy._last_location){window.setTimeout(function(){$(window).trigger("hashchange",[true])},0)}Sammy.DefaultLocationProxy._last_location=current_location};hashCheck();Sammy.DefaultLocationProxy._interval=window.setInterval(hashCheck,every)}}});Sammy.Application=function(app_function){var app=this;this.routes={};this.listeners=new Sammy.Object({});this.arounds=[];this.befores=[];this.namespace=(new Date).getTime()+"-"+parseInt(Math.random()*1e3,10);this.context_prototype=function(){Sammy.EventContext.apply(this,arguments)};this.context_prototype.prototype=new Sammy.EventContext;if(_isFunction(app_function)){app_function.apply(this,[this])}if(!this._location_proxy){this.setLocationProxy(new Sammy.DefaultLocationProxy(this,this.run_interval_every))}if(this.debug){this.bindToAllEvents(function(e,data){app.log(app.toString(),e.cleaned_type,data||{})})}};Sammy.Application.prototype=$.extend({},Sammy.Object.prototype,{ROUTE_VERBS:["get","post","put","delete"],APP_EVENTS:["run","unload","lookup-route","run-route","route-found","event-context-before","event-context-after","changed","error","check-form-submission","redirect","location-changed"],_last_route:null,_location_proxy:null,_running:false,element_selector:"body",debug:false,raise_errors:false,run_interval_every:50,disable_push_state:false,template_engine:null,toString:function(){return"Sammy.Application:"+this.element_selector},$element:function(selector){return selector?$(this.element_selector).find(selector):$(this.element_selector)},use:function(){var args=_makeArray(arguments),plugin=args.shift(),plugin_name=plugin||"";try{args.unshift(this);if(typeof plugin=="string"){plugin_name="Sammy."+plugin;plugin=Sammy[plugin]}plugin.apply(this,args)}catch(e){if(typeof plugin==="undefined"){this.error("Plugin Error: called use() but plugin ("+plugin_name.toString()+") is not defined",e)}else if(!_isFunction(plugin)){this.error("Plugin Error: called use() but '"+plugin_name.toString()+"' is not a function",e)}else{this.error("Plugin Error",e)}}return this},setLocationProxy:function(new_proxy){var original_proxy=this._location_proxy;this._location_proxy=new_proxy;if(this.isRunning()){if(original_proxy){original_proxy.unbind()}this._location_proxy.bind()}},log:function(){Sammy.log.apply(Sammy,Array.prototype.concat.apply([this.element_selector],arguments))},route:function(verb,path){var app=this,param_names=[],add_route,path_match,callback=Array.prototype.slice.call(arguments,2);if(callback.length===0&&_isFunction(path)){callback=[path];path=verb;verb="any"}verb=verb.toLowerCase();if(path.constructor==String){PATH_NAME_MATCHER.lastIndex=0;while((path_match=PATH_NAME_MATCHER.exec(path))!==null){param_names.push(path_match[1])}path=new RegExp(path.replace(PATH_NAME_MATCHER,PATH_REPLACER)+"$")}$.each(callback,function(i,cb){if(typeof cb==="string"){callback[i]=app[cb]}});add_route=function(with_verb){var r={verb:with_verb,path:path,callback:callback,param_names:param_names};app.routes[with_verb]=app.routes[with_verb]||[];app.routes[with_verb].push(r)};if(verb==="any"){$.each(this.ROUTE_VERBS,function(i,v){add_route(v)})}else{add_route(verb)}return this},get:_routeWrapper("get"),post:_routeWrapper("post"),put:_routeWrapper("put"),del:_routeWrapper("delete"),any:_routeWrapper("any"),mapRoutes:function(route_array){var app=this;$.each(route_array,function(i,route_args){app.route.apply(app,route_args)});return this},eventNamespace:function(){return["sammy-app",this.namespace].join("-")},bind:function(name,data,callback){var app=this;if(typeof callback=="undefined"){callback=data}var listener_callback=function(){var e,context,data;e=arguments[0];data=arguments[1];if(data&&data.context){context=data.context;delete data.context}else{context=new app.context_prototype(app,"bind",e.type,data,e.target)}e.cleaned_type=e.type.replace(app.eventNamespace(),"");callback.apply(context,[e,data])};if(!this.listeners[name]){this.listeners[name]=[]}this.listeners[name].push(listener_callback);if(this.isRunning()){this._listen(name,listener_callback)}return this},trigger:function(name,data){this.$element().trigger([name,this.eventNamespace()].join("."),[data]);return this},refresh:function(){this.last_location=null;this.trigger("location-changed");return this},before:function(options,callback){if(_isFunction(options)){callback=options;options={}}this.befores.push([options,callback]);return this},after:function(callback){return this.bind("event-context-after",callback)},around:function(callback){this.arounds.push(callback);return this},onComplete:function(callback){this._onComplete=callback;return this},isRunning:function(){return this._running},helpers:function(extensions){$.extend(this.context_prototype.prototype,extensions);return this},helper:function(name,method){this.context_prototype.prototype[name]=method;return this},run:function(start_url){if(this.isRunning()){return false}var app=this;$.each(this.listeners.toHash(),function(name,callbacks){$.each(callbacks,function(i,listener_callback){app._listen(name,listener_callback)})});this.trigger("run",{start_url:start_url});this._running=true;this.last_location=null;if(!/\#(.+)/.test(this.getLocation())&&typeof start_url!="undefined"){this.setLocation(start_url)}this._checkLocation();this._location_proxy.bind();this.bind("location-changed",function(){app._checkLocation()});this.bind("submit",function(e){if(!Sammy.targetIsThisWindow(e,"form")){return true}var returned=app._checkFormSubmission($(e.target).closest("form"));return returned===false?e.preventDefault():false});$(window).bind("unload",function(){app.unload()});return this.trigger("changed")},unload:function(){if(!this.isRunning()){return false}var app=this;this.trigger("unload");this._location_proxy.unbind();this.$element().unbind("submit").removeClass(app.eventNamespace());$.each(this.listeners.toHash(),function(name,listeners){$.each(listeners,function(i,listener_callback){app._unlisten(name,listener_callback)})});this._running=false;return this},destroy:function(){this.unload();delete Sammy.apps[this.element_selector];return this},bindToAllEvents:function(callback){var app=this;$.each(this.APP_EVENTS,function(i,e){app.bind(e,callback)});$.each(this.listeners.keys(true),function(i,name){if($.inArray(name,app.APP_EVENTS)==-1){app.bind(name,callback)}});return this},routablePath:function(path){return path.replace(QUERY_STRING_MATCHER,"")},lookupRoute:function(verb,path){var app=this,routed=false,i=0,l,route;if(typeof this.routes[verb]!="undefined"){l=this.routes[verb].length;for(;i0){before=befores.shift();if(app.contextMatchesOptions(context,before[0])){returned=before[1].apply(context,[context]);if(returned===false){return false}}}app.last_route=route;context.trigger("event-context-before",{context:context});if(typeof route.callback==="function"){route.callback=[route.callback]}if(route.callback&&route.callback.length){i=-1;nextRoute=function(){i++;if(route.callback[i]){returned=route.callback[i].apply(context,callback_args)}else if(app._onComplete&&typeof(app._onComplete==="function")){app._onComplete(context)}};callback_args.push(nextRoute);nextRoute()}context.trigger("event-context-after",{context:context});return returned};$.each(arounds.reverse(),function(i,around){var last_wrapped_route=wrapped_route;wrapped_route=function(){return around.apply(context,[last_wrapped_route])}});try{final_returned=wrapped_route()}catch(e){this.error(["500 Error",verb,path].join(" "),e)}return final_returned}else{return this.notFound(verb,path)}},contextMatchesOptions:function(context,match_options,positive){var options=match_options;if(typeof options==="string"||_isRegExp(options)){options={path:options}}if(typeof positive==="undefined"){positive=true}if($.isEmptyObject(options)){return true}if(_isArray(options.path)){var results,numopt,opts,len;results=[];for(numopt=0,len=options.path.length;numopt-1?true:false;return positive?matched:!matched}if(options.only){return this.contextMatchesOptions(context,options.only,true)}else if(options.except){return this.contextMatchesOptions(context,options.except,false)}var path_matched=true,verb_matched=true;if(options.path){if(!_isRegExp(options.path)){options.path=new RegExp(options.path.toString()+"$")}path_matched=options.path.test(context.path)}if(options.verb){if(typeof options.verb==="string"){verb_matched=options.verb===context.verb}else{verb_matched=options.verb.indexOf(context.verb)>-1}}return positive?verb_matched&&path_matched:!(verb_matched&&path_matched)},getLocation:function(){return this._location_proxy.getLocation()},setLocation:function(new_location){return this._location_proxy.setLocation(new_location)},swap:function(content,callback){var $el=this.$element().html(content);if(_isFunction(callback)){callback(content)}return $el},templateCache:function(key,value){if(typeof value!="undefined"){return _template_cache[key]=value}else{return _template_cache[key]}},clearTemplateCache:function(){return _template_cache={}},notFound:function(verb,path){var ret=this.error(["404 Not Found",verb,path].join(" "));return verb==="get"?ret:true},error:function(message,original_error){if(!original_error){original_error=new Error}original_error.message=[message,original_error.message].join(" ");this.trigger("error",{message:original_error.message,error:original_error});if(this.raise_errors){throw original_error}else{this.log(original_error.message,original_error)}},_checkLocation:function(){var location,returned;location=this.getLocation();if(!this.last_location||this.last_location[0]!="get"||this.last_location[1]!=location){this.last_location=["get",location];returned=this.runRoute("get",location)}return returned},_getFormVerb:function(form){var $form=$(form),verb,$_method;$_method=$form.find('input[name="_method"]');if($_method.length>0){verb=$_method.val()}if(!verb){verb=$form[0].getAttribute("method")}if(!verb||verb===""){verb="get"}return $.trim(verb.toString().toLowerCase())},_checkFormSubmission:function(form){var $form,path,verb,params,returned;this.trigger("check-form-submission",{form:form});$form=$(form);path=$form.attr("action")||"";verb=this._getFormVerb($form);if(this.debug){this.log("_checkFormSubmission",$form,path,verb)}if(verb==="get"){params=this._serializeFormParams($form);if(params!==""){path+="?"+params}this.setLocation(path);returned=false}else{params=$.extend({},this._parseFormParams($form));returned=this.runRoute(verb,path,params,form.get(0))}return typeof returned=="undefined"?false:returned},_serializeFormParams:function($form){var queryString="",fields=$form.serializeArray(),i;if(fields.length>0){queryString=this._encodeFormPair(fields[0].name,fields[0].value);for(i=1;i0){this.then(this.callbacks.shift())}},load:function(location,options,callback){var context=this;return this.then(function(){var should_cache,cached,is_json,location_array;if(_isFunction(options)){callback=options;options={}}else{options=$.extend({},options)}if(callback){this.then(callback)}if(typeof location==="string"){is_json=location.match(/\.json(\?|$)/)||options.json;should_cache=is_json?options.cache===true:options.cache!==false;context.next_engine=context.event_context.engineFor(location);delete options.cache;delete options.json;if(options.engine){context.next_engine=options.engine;delete options.engine}if(should_cache&&(cached=this.event_context.app.templateCache(location))){return cached}this.wait();$.ajax($.extend({url:location,data:{},dataType:is_json?"json":"text",type:"get",success:function(data){if(should_cache){context.event_context.app.templateCache(location,data)}context.next(data)}},options));return false}else{if(location.nodeType){return location.innerHTML}if(location.selector){context.next_engine=location.attr("data-engine");if(options.clone===false){return location.remove()[0].innerHTML.toString()}else{return location[0].innerHTML.toString()}}}})},loadPartials:function(partials){var name;if(partials){this.partials=this.partials||{};for(name in partials){(function(context,name){context.load(partials[name]).then(function(template){this.partials[name]=template})})(this,name)}}return this},render:function(location,data,callback,partials){if(_isFunction(location)&&!data){return this.then(location)}else{if(_isFunction(data)){partials=callback;callback=data;data=null}else if(callback&&!_isFunction(callback)){partials=callback;callback=null}return this.loadPartials(partials).load(location).interpolate(data,location).then(callback)}},partial:function(location,data,callback,partials){if(_isFunction(callback)){return this.render(location,data,partials).swap(callback)}else if(_isFunction(data)){return this.render(location,{},callback).swap(data)}else{return this.render(location,data,callback).swap()}},send:function(){var context=this,args=_makeArray(arguments),fun=args.shift();if(_isArray(args[0])){args=args[0]}return this.then(function(content){args.push(function(response){context.next(response)});context.wait();fun.apply(fun,args);return false})},collect:function(array,callback,now){var context=this;var coll=function(){if(_isFunction(array)){callback=array;array=this.content}var contents=[],doms=false;$.each(array,function(i,item){var returned=callback.apply(context,[i,item]);if(returned.jquery&&returned.length==1){returned=returned[0];doms=true}contents.push(returned);return returned});return doms?contents:contents.join("")};return now?coll():this.then(coll)},renderEach:function(location,name,data,callback){if(_isArray(name)){callback=data;data=name;name=null}return this.load(location).then(function(content){var rctx=this;if(!data){data=_isArray(this.previous_content)?this.previous_content:[]}if(callback){$.each(data,function(i,value){var idata={},engine=this.next_engine||location;if(name){idata[name]=value}else{idata=value}callback(value,rctx.event_context.interpolate(content,idata,engine))})}else{return this.collect(data,function(i,value){var idata={},engine=this.next_engine||location;if(name){idata[name]=value}else{idata=value}return this.event_context.interpolate(content,idata,engine)},true)}})},interpolate:function(data,engine,retain){var context=this;return this.then(function(content,prev){if(!data&&prev){data=prev}if(this.next_engine){engine=this.next_engine;this.next_engine=false}var rendered=context.event_context.interpolate(content,data,engine,this.partials);return retain?prev+rendered:rendered})},swap:function(callback){return this.then(function(content){this.event_context.swap(content,callback);return content}).trigger("changed",{})},appendTo:function(selector){return this.then(function(content){$(selector).append(content)}).trigger("changed",{})},prependTo:function(selector){return this.then(function(content){$(selector).prepend(content)}).trigger("changed",{})},replace:function(selector){return this.then(function(content){$(selector).html(content)}).trigger("changed",{})},trigger:function(name,data){return this.then(function(content){if(typeof data=="undefined"){data={content:content}}this.event_context.trigger(name,data);return content})}});Sammy.EventContext=function(app,verb,path,params,target){this.app=app;this.verb=verb;this.path=path;this.params=new Sammy.Object(params);this.target=target};Sammy.EventContext.prototype=$.extend({},Sammy.Object.prototype,{$element:function(){return this.app.$element(_makeArray(arguments).shift())},engineFor:function(engine){var context=this,engine_match;if(_isFunction(engine)){return engine}engine=(engine||context.app.template_engine).toString();if(engine_match=engine.match(/\.([^\.\?\#]+)(\?|$)/)){engine=engine_match[1]}if(engine&&_isFunction(context[engine])){return context[engine]}if(context.app.template_engine){return this.engineFor(context.app.template_engine)}return function(content,data){return content}},interpolate:function(content,data,engine,partials){return this.engineFor(engine).apply(this,[content,data,partials])},render:function(location,data,callback,partials){return new Sammy.RenderContext(this).render(location,data,callback,partials)},renderEach:function(location,name,data,callback){return new Sammy.RenderContext(this).renderEach(location,name,data,callback)},load:function(location,options,callback){return new Sammy.RenderContext(this).load(location,options,callback)},loadPartials:function(partials){return new Sammy.RenderContext(this).loadPartials(partials)},partial:function(location,data,callback,partials){return new Sammy.RenderContext(this).partial(location,data,callback,partials)},send:function(){var rctx=new Sammy.RenderContext(this);return rctx.send.apply(rctx,arguments)},redirect:function(){var to,args=_makeArray(arguments),current_location=this.app.getLocation(),l=args.length;if(l>1){var i=0,paths=[],pairs=[],params={},has_params=false;for(;i + * @url http://www.minicartjs.com/ + * @license MIT + */ + +;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o i; ++i) { + if (array.hasOwnProperty(i)) { + if (isValueSet) { + value = callback(value, array[i], i, array); + } + else { + value = array[i]; + isValueSet = true; + } + } + } + + return value; +}; + +// String.prototype.substr - negative index don't work in IE8 +if ('ab'.substr(-1) !== 'b') { + exports.substr = function (str, start, length) { + // did we get a negative start, calculate how much it is from the beginning of the string + if (start < 0) start = str.length + start; + + // call the original function + return str.substr(start, length); + }; +} else { + exports.substr = function (str, start, length) { + return str.substr(start, length); + }; +} + +// String.prototype.trim is supported in IE9 +exports.trim = function (str) { + if (str.trim) return str.trim(); + return str.replace(/^\s+|\s+$/g, ''); +}; + +// Function.prototype.bind is supported in IE9 +exports.bind = function () { + var args = Array.prototype.slice.call(arguments); + var fn = args.shift(); + if (fn.bind) return fn.bind.apply(fn, args); + var self = args.shift(); + return function () { + fn.apply(self, args.concat([Array.prototype.slice.call(arguments)])); + }; +}; + +// Object.create is supported in IE9 +function create(prototype, properties) { + var object; + if (prototype === null) { + object = { '__proto__' : null }; + } + else { + if (typeof prototype !== 'object') { + throw new TypeError( + 'typeof prototype[' + (typeof prototype) + '] != \'object\'' + ); + } + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + object.__proto__ = prototype; + } + if (typeof properties !== 'undefined' && Object.defineProperties) { + Object.defineProperties(object, properties); + } + return object; +} +exports.create = typeof Object.create === 'function' ? Object.create : create; + +// Object.keys and Object.getOwnPropertyNames is supported in IE9 however +// they do show a description and number property on Error objects +function notObject(object) { + return ((typeof object != "object" && typeof object != "function") || object === null); +} + +function keysShim(object) { + if (notObject(object)) { + throw new TypeError("Object.keys called on a non-object"); + } + + var result = []; + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + result.push(name); + } + } + return result; +} + +// getOwnPropertyNames is almost the same as Object.keys one key feature +// is that it returns hidden properties, since that can't be implemented, +// this feature gets reduced so it just shows the length property on arrays +function propertyShim(object) { + if (notObject(object)) { + throw new TypeError("Object.getOwnPropertyNames called on a non-object"); + } + + var result = keysShim(object); + if (exports.isArray(object) && exports.indexOf(object, 'length') === -1) { + result.push('length'); + } + return result; +} + +var keys = typeof Object.keys === 'function' ? Object.keys : keysShim; +var getOwnPropertyNames = typeof Object.getOwnPropertyNames === 'function' ? + Object.getOwnPropertyNames : propertyShim; + +if (new Error().hasOwnProperty('description')) { + var ERROR_PROPERTY_FILTER = function (obj, array) { + if (toString.call(obj) === '[object Error]') { + array = exports.filter(array, function (name) { + return name !== 'description' && name !== 'number' && name !== 'message'; + }); + } + return array; + }; + + exports.keys = function (object) { + return ERROR_PROPERTY_FILTER(object, keys(object)); + }; + exports.getOwnPropertyNames = function (object) { + return ERROR_PROPERTY_FILTER(object, getOwnPropertyNames(object)); + }; +} else { + exports.keys = keys; + exports.getOwnPropertyNames = getOwnPropertyNames; +} + +// Object.getOwnPropertyDescriptor - supported in IE8 but only on dom elements +function valueObject(value, key) { + return { value: value[key] }; +} + +if (typeof Object.getOwnPropertyDescriptor === 'function') { + try { + Object.getOwnPropertyDescriptor({'a': 1}, 'a'); + exports.getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + } catch (e) { + // IE8 dom element issue - use a try catch and default to valueObject + exports.getOwnPropertyDescriptor = function (value, key) { + try { + return Object.getOwnPropertyDescriptor(value, key); + } catch (e) { + return valueObject(value, key); + } + }; + } +} else { + exports.getOwnPropertyDescriptor = valueObject; +} + +},{}],2:[function(require,module,exports){ + +// not implemented +// The reason for having an empty file and not throwing is to allow +// untraditional implementation of this module. + +},{}],3:[function(require,module,exports){ +var process=require("__browserify_process");// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var util = require('util'); +var shims = require('_shims'); + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i]; + if (last === '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var splitPath = function(filename) { + return splitPathRe.exec(filename).slice(1); +}; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { + var resolvedPath = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : process.cwd(); + + // Skip empty and invalid entries + if (!util.isString(path)) { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(shims.filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { + var isAbsolute = exports.isAbsolute(path), + trailingSlash = shims.substr(path, -1) === '/'; + + // Normalize the path + path = normalizeArray(shims.filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +exports.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(shims.filter(paths, function(p, index) { + if (!util.isString(p)) { + throw new TypeError('Arguments to path.join must be strings'); + } + return p; + }).join('/')); +}; + + +// path.relative(from, to) +// posix version +exports.relative = function(from, to) { + from = exports.resolve(from).substr(1); + to = exports.resolve(to).substr(1); + + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + +exports.sep = '/'; +exports.delimiter = ':'; + +exports.dirname = function(path) { + var result = splitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +exports.basename = function(path, ext) { + var f = splitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPath(path)[3]; +}; + +},{"__browserify_process":5,"_shims":1,"util":4}],4:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var shims = require('_shims'); + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + shims.forEach(array, function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = shims.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = shims.getOwnPropertyNames(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + + shims.forEach(keys, function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = shims.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (shims.indexOf(ctx.seen, desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = shims.reduce(output, function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return shims.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && objectToString(e) === '[object Error]'; +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.binarySlice === 'function' + ; +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = function(ctor, superCtor) { + ctor.super_ = superCtor; + ctor.prototype = shims.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); +}; + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = shims.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +},{"_shims":1}],5:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; + +process.nextTick = (function () { + var canSetImmediate = typeof window !== 'undefined' + && window.setImmediate; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canSetImmediate) { + return function (f) { return window.setImmediate(f) }; + } + + if (canPost) { + var queue = []; + window.addEventListener('message', function (ev) { + var source = ev.source; + if ((source === window || source === null) && ev.data === 'process-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('process-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +} + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; + +},{}],6:[function(require,module,exports){ + +/*! + * EJS + * Copyright(c) 2012 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('./utils') + , path = require('path') + , dirname = path.dirname + , extname = path.extname + , join = path.join + , fs = require('fs') + , read = fs.readFileSync; + +/** + * Filters. + * + * @type Object + */ + +var filters = exports.filters = require('./filters'); + +/** + * Intermediate js cache. + * + * @type Object + */ + +var cache = {}; + +/** + * Clear intermediate js cache. + * + * @api public + */ + +exports.clearCache = function(){ + cache = {}; +}; + +/** + * Translate filtered code into function calls. + * + * @param {String} js + * @return {String} + * @api private + */ + +function filtered(js) { + return js.substr(1).split('|').reduce(function(js, filter){ + var parts = filter.split(':') + , name = parts.shift() + , args = parts.join(':') || ''; + if (args) args = ', ' + args; + return 'filters.' + name + '(' + js + args + ')'; + }); +}; + +/** + * Re-throw the given `err` in context to the + * `str` of ejs, `filename`, and `lineno`. + * + * @param {Error} err + * @param {String} str + * @param {String} filename + * @param {String} lineno + * @api private + */ + +function rethrow(err, str, filename, lineno){ + var lines = str.split('\n') + , start = Math.max(lineno - 3, 0) + , end = Math.min(lines.length, lineno + 3); + + // Error context + var context = lines.slice(start, end).map(function(line, i){ + var curr = i + start + 1; + return (curr == lineno ? ' >> ' : ' ') + + curr + + '| ' + + line; + }).join('\n'); + + // Alter exception message + err.path = filename; + err.message = (filename || 'ejs') + ':' + + lineno + '\n' + + context + '\n\n' + + err.message; + + throw err; +} + +/** + * Parse the given `str` of ejs, returning the function body. + * + * @param {String} str + * @return {String} + * @api public + */ + +var parse = exports.parse = function(str, options){ + var options = options || {} + , open = options.open || exports.open || '<%' + , close = options.close || exports.close || '%>' + , filename = options.filename + , compileDebug = options.compileDebug !== false + , buf = ""; + + buf += 'var buf = [];'; + if (false !== options._with) buf += '\nwith (locals || {}) { (function(){ '; + buf += '\n buf.push(\''; + + var lineno = 1; + + var consumeEOL = false; + for (var i = 0, len = str.length; i < len; ++i) { + var stri = str[i]; + if (str.slice(i, open.length + i) == open) { + i += open.length + + var prefix, postfix, line = (compileDebug ? '__stack.lineno=' : '') + lineno; + switch (str[i]) { + case '=': + prefix = "', escape((" + line + ', '; + postfix = ")), '"; + ++i; + break; + case '-': + prefix = "', (" + line + ', '; + postfix = "), '"; + ++i; + break; + default: + prefix = "');" + line + ';'; + postfix = "; buf.push('"; + } + + var end = str.indexOf(close, i) + , js = str.substring(i, end) + , start = i + , include = null + , n = 0; + + if ('-' == js[js.length-1]){ + js = js.substring(0, js.length - 2); + consumeEOL = true; + } + + if (0 == js.trim().indexOf('include')) { + var name = js.trim().slice(7).trim(); + if (!filename) throw new Error('filename option is required for includes'); + var path = resolveInclude(name, filename); + include = read(path, 'utf8'); + include = exports.parse(include, { filename: path, _with: false, open: open, close: close, compileDebug: compileDebug }); + buf += "' + (function(){" + include + "})() + '"; + js = ''; + } + + while (~(n = js.indexOf("\n", n))) n++, lineno++; + if (js.substr(0, 1) == ':') js = filtered(js); + if (js) { + if (js.lastIndexOf('//') > js.lastIndexOf('\n')) js += '\n'; + buf += prefix; + buf += js; + buf += postfix; + } + i += end - start + close.length - 1; + + } else if (stri == "\\") { + buf += "\\\\"; + } else if (stri == "'") { + buf += "\\'"; + } else if (stri == "\r") { + // ignore + } else if (stri == "\n") { + if (consumeEOL) { + consumeEOL = false; + } else { + buf += "\\n"; + lineno++; + } + } else { + buf += stri; + } + } + + if (false !== options._with) buf += "'); })();\n} \nreturn buf.join('');"; + else buf += "');\nreturn buf.join('');"; + return buf; +}; + +/** + * Compile the given `str` of ejs into a `Function`. + * + * @param {String} str + * @param {Object} options + * @return {Function} + * @api public + */ + +var compile = exports.compile = function(str, options){ + options = options || {}; + var escape = options.escape || utils.escape; + + var input = JSON.stringify(str) + , compileDebug = options.compileDebug !== false + , client = options.client + , filename = options.filename + ? JSON.stringify(options.filename) + : 'undefined'; + + if (compileDebug) { + // Adds the fancy stack trace meta info + str = [ + 'var __stack = { lineno: 1, input: ' + input + ', filename: ' + filename + ' };', + rethrow.toString(), + 'try {', + exports.parse(str, options), + '} catch (err) {', + ' rethrow(err, __stack.input, __stack.filename, __stack.lineno);', + '}' + ].join("\n"); + } else { + str = exports.parse(str, options); + } + + if (options.debug) console.log(str); + if (client) str = 'escape = escape || ' + escape.toString() + ';\n' + str; + + try { + var fn = new Function('locals, filters, escape, rethrow', str); + } catch (err) { + if ('SyntaxError' == err.name) { + err.message += options.filename + ? ' in ' + filename + : ' while compiling ejs'; + } + throw err; + } + + if (client) return fn; + + return function(locals){ + return fn.call(this, locals, filters, escape, rethrow); + } +}; + +/** + * Render the given `str` of ejs. + * + * Options: + * + * - `locals` Local variables object + * - `cache` Compiled functions are cached, requires `filename` + * - `filename` Used by `cache` to key caches + * - `scope` Function execution context + * - `debug` Output generated function body + * - `open` Open tag, defaulting to "<%" + * - `close` Closing tag, defaulting to "%>" + * + * @param {String} str + * @param {Object} options + * @return {String} + * @api public + */ + +exports.render = function(str, options){ + var fn + , options = options || {}; + + if (options.cache) { + if (options.filename) { + fn = cache[options.filename] || (cache[options.filename] = compile(str, options)); + } else { + throw new Error('"cache" option requires "filename".'); + } + } else { + fn = compile(str, options); + } + + options.__proto__ = options.locals; + return fn.call(options.scope, options); +}; + +/** + * Render an EJS file at the given `path` and callback `fn(err, str)`. + * + * @param {String} path + * @param {Object|Function} options or callback + * @param {Function} fn + * @api public + */ + +exports.renderFile = function(path, options, fn){ + var key = path + ':string'; + + if ('function' == typeof options) { + fn = options, options = {}; + } + + options.filename = path; + + var str; + try { + str = options.cache + ? cache[key] || (cache[key] = read(path, 'utf8')) + : read(path, 'utf8'); + } catch (err) { + fn(err); + return; + } + fn(null, exports.render(str, options)); +}; + +/** + * Resolve include `name` relative to `filename`. + * + * @param {String} name + * @param {String} filename + * @return {String} + * @api private + */ + +function resolveInclude(name, filename) { + var path = join(dirname(filename), name); + var ext = extname(name); + if (!ext) path += '.ejs'; + return path; +} + +// express support + +exports.__express = exports.renderFile; + +/** + * Expose to require(). + */ + +if (require.extensions) { + require.extensions['.ejs'] = function (module, filename) { + filename = filename || module.filename; + var options = { filename: filename, client: true } + , template = fs.readFileSync(filename).toString() + , fn = compile(template, options); + module._compile('module.exports = ' + fn.toString() + ';', filename); + }; +} else if (require.registerExtension) { + require.registerExtension('.ejs', function(src) { + return compile(src, {}); + }); +} + +},{"./filters":7,"./utils":8,"fs":2,"path":3}],7:[function(require,module,exports){ +/*! + * EJS - Filters + * Copyright(c) 2010 TJ Holowaychuk + * MIT Licensed + */ + +/** + * First element of the target `obj`. + */ + +exports.first = function(obj) { + return obj[0]; +}; + +/** + * Last element of the target `obj`. + */ + +exports.last = function(obj) { + return obj[obj.length - 1]; +}; + +/** + * Capitalize the first letter of the target `str`. + */ + +exports.capitalize = function(str){ + str = String(str); + return str[0].toUpperCase() + str.substr(1, str.length); +}; + +/** + * Downcase the target `str`. + */ + +exports.downcase = function(str){ + return String(str).toLowerCase(); +}; + +/** + * Uppercase the target `str`. + */ + +exports.upcase = function(str){ + return String(str).toUpperCase(); +}; + +/** + * Sort the target `obj`. + */ + +exports.sort = function(obj){ + return Object.create(obj).sort(); +}; + +/** + * Sort the target `obj` by the given `prop` ascending. + */ + +exports.sort_by = function(obj, prop){ + return Object.create(obj).sort(function(a, b){ + a = a[prop], b = b[prop]; + if (a > b) return 1; + if (a < b) return -1; + return 0; + }); +}; + +/** + * Size or length of the target `obj`. + */ + +exports.size = exports.length = function(obj) { + return obj.length; +}; + +/** + * Add `a` and `b`. + */ + +exports.plus = function(a, b){ + return Number(a) + Number(b); +}; + +/** + * Subtract `b` from `a`. + */ + +exports.minus = function(a, b){ + return Number(a) - Number(b); +}; + +/** + * Multiply `a` by `b`. + */ + +exports.times = function(a, b){ + return Number(a) * Number(b); +}; + +/** + * Divide `a` by `b`. + */ + +exports.divided_by = function(a, b){ + return Number(a) / Number(b); +}; + +/** + * Join `obj` with the given `str`. + */ + +exports.join = function(obj, str){ + return obj.join(str || ', '); +}; + +/** + * Truncate `str` to `len`. + */ + +exports.truncate = function(str, len, append){ + str = String(str); + if (str.length > len) { + str = str.slice(0, len); + if (append) str += append; + } + return str; +}; + +/** + * Truncate `str` to `n` words. + */ + +exports.truncate_words = function(str, n){ + var str = String(str) + , words = str.split(/ +/); + return words.slice(0, n).join(' '); +}; + +/** + * Replace `pattern` with `substitution` in `str`. + */ + +exports.replace = function(str, pattern, substitution){ + return String(str).replace(pattern, substitution || ''); +}; + +/** + * Prepend `val` to `obj`. + */ + +exports.prepend = function(obj, val){ + return Array.isArray(obj) + ? [val].concat(obj) + : val + obj; +}; + +/** + * Append `val` to `obj`. + */ + +exports.append = function(obj, val){ + return Array.isArray(obj) + ? obj.concat(val) + : obj + val; +}; + +/** + * Map the given `prop`. + */ + +exports.map = function(arr, prop){ + return arr.map(function(obj){ + return obj[prop]; + }); +}; + +/** + * Reverse the given `obj`. + */ + +exports.reverse = function(obj){ + return Array.isArray(obj) + ? obj.reverse() + : String(obj).split('').reverse().join(''); +}; + +/** + * Get `prop` of the given `obj`. + */ + +exports.get = function(obj, prop){ + return obj[prop]; +}; + +/** + * Packs the given `obj` into json string + */ +exports.json = function(obj){ + return JSON.stringify(obj); +}; + +},{}],8:[function(require,module,exports){ + +/*! + * EJS + * Copyright(c) 2010 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Escape the given string of `html`. + * + * @param {String} html + * @return {String} + * @api private + */ + +exports.escape = function(html){ + return String(html) + .replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') + .replace(//g, '>') + .replace(/'/g, ''') + .replace(/"/g, '"'); +}; + + +},{}],9:[function(require,module,exports){ +'use strict'; + + +var Product = require('./product'), + Pubsub = require('./util/pubsub'), + Storage = require('./util/storage'), + constants = require('./constants'), + currency = require('./util/currency'), + mixin = require('./util/mixin'); + + + +/** + * Renders the Mini Cart to the page's DOM. + * + * @constructor + * @param {string} name Name of the cart (used as a key for storage) + * @param {duration} number Time in milliseconds that the cart data should persist + */ +function Cart(name, duration) { + var data, items, settings, len, i; + + this._items = []; + this._settings = { bn: constants.BN }; + + Pubsub.call(this); + Storage.call(this, name, duration); + + if ((data = this.load())) { + items = data.items; + settings = data.settings; + + if (settings) { + this._settings = settings; + } + + if (items) { + for (i = 0, len = items.length; i < len; i++) { + this.add(items[i]); + } + } + } +} + + +mixin(Cart.prototype, Pubsub.prototype); +mixin(Cart.prototype, Storage.prototype); + + +/** + * Adds an item to the cart. This fires an "add" event. + * + * @param {object} data Item data + * @return {number} Item location in the cart + */ +Cart.prototype.add = function add(data) { + var that = this, + items = this.items(), + idx = false, + isExisting = false, + product, key, len, i; + + // Prune cart settings data from the product + for (key in data) { + if (constants.SETTINGS.test(key)) { + this._settings[key] = data[key]; + delete data[key]; + } + } + + // Look to see if the same product has already been added + for (i = 0, len = items.length; i < len; i++) { + if (items[i].isEqual(data)) { + product = items[i]; + product.set('quantity', product.get('quantity') + (parseInt(data.quantity, 10) || 1)); + idx = i; + isExisting = true; + break; + } + } + + // If not, then try to add it + if (!product) { + product = new Product(data); + + if (product.isValid()) { + idx = (this._items.push(product) - 1); + + product.on('change', function (key, value) { + that.save(); + that.fire('change', idx, key, value); + }); + + this.save(); + } + } + + if (product) { + this.fire('add', idx, product, isExisting); + } + + return idx; +}; + + +/** + * Returns the carts current items. + * + * @param {number} idx (Optional) Returns only that item. + * @return {array|object} + */ +Cart.prototype.items = function get(idx) { + return (typeof idx === 'number') ? this._items[idx] : this._items; +}; + + +/** + * Returns the carts current settings. + * + * @param {string} name (Optional) Returns only that setting. + * @return {array|string} + */ +Cart.prototype.settings = function settings(name) { + return (name) ? this._settings[name] : this._settings; +}; + + +/** + * Returns the cart discount. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Cart.prototype.discount = function discount(config) { + var result = parseFloat(this.settings('discount_amount_cart')) || 0; + + if (!result) { + result = (parseFloat(this.settings('discount_rate_cart')) || 0) * this.subtotal() / 100; + } + + config = config || {}; + config.currency = this.settings('currency_code'); + + return currency(result, config); +}; + + +/** + * Returns the cart total without discounts. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Cart.prototype.subtotal = function subtotal(config) { + var products = this.items(), + result = 0, + i, len; + + for (i = 0, len = products.length; i < len; i++) { + result += products[i].total(); + } + + config = config || {}; + config.currency = this.settings('currency_code'); + + return currency(result, config); +}; + + +/** + * Returns the cart total. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Cart.prototype.total = function total(config) { + var result = 0; + + result += this.subtotal(); + result -= this.discount(); + + config = config || {}; + config.currency = this.settings('currency_code'); + + return currency(result, config); +}; + + +/** + * Remove an item from the cart. This fires a "remove" event. + * + * @param {number} idx Item index to remove. + * @return {boolean} + */ +Cart.prototype.remove = function remove(idx) { + var item = this._items.splice(idx, 1); + + if (this._items.length === 0) { + this.destroy(); + } + + if (item) { + this.save(); + this.fire('remove', idx, item[0]); + } + + return !!item.length; +}; + + +/** + * Saves the cart data. + */ +Cart.prototype.save = function save() { + var items = this.items(), + settings = this.settings(), + data = [], + i, len; + + for (i = 0, len = items.length; i < len; i++) { + data.push(items[i].get()); + } + + Storage.prototype.save.call(this, { + items: data, + settings: settings + }); +}; + + +/** + * Proxies the checkout event + * The assumption is the view triggers this and consumers subscribe to it + * + * @param {object} The initiating event + */ +Cart.prototype.checkout = function checkout(evt) { + this.fire('checkout', evt); +}; + + +/** + * Destroy the cart data. This fires a "destroy" event. + */ +Cart.prototype.destroy = function destroy() { + Storage.prototype.destroy.call(this); + + this._items = []; + this._settings = { bn: constants.BN }; + + this.fire('destroy'); +}; + + + + +module.exports = Cart; + +},{"./constants":11,"./product":13,"./util/currency":15,"./util/mixin":18,"./util/pubsub":19,"./util/storage":20}],10:[function(require,module,exports){ +'use strict'; + + +var mixin = require('./util/mixin'); + + +var defaults = module.exports = { + + name: 'PPMiniCart', + + parent: (typeof document !== 'undefined') ? document.body : null, + + action: 'https://www.paypal.com/cgi-bin/webscr', + + target: '', + + duration: 30, + + template: '<%var items = cart.items();var settings = cart.settings();var hasItems = !!items.length;var priceFormat = { format: true, currency: cart.settings("currency_code") };var totalFormat = { format: true, showCode: true };%>
    <% for (var i= 0, idx = i + 1, len = items.length; i < len; i++, idx++) { %>
  • "><%= items[i].get("item_name") %>
      <% if (items[i].get("item_number")) { %>
    • <%= items[i].get("item_number") %> " />
    • <% } %> <% if (items[i].discount()) { %>
    • <%= config.strings.discount %> <%= items[i].discount(priceFormat) %>
    • <% } %> <% for (var options = items[i].options(), j = 0, len2 = options.length; j < len2; j++) { %>
    • <%= options[j].key %>: <%= options[j].value %>
    • <% } %>
    " autocomplete="off" />
    <%= items[i].total(priceFormat) %>
    " /> " /> " />
  • <% } %>
<% for (var key in settings) { %> <% } %>
', + + styles: '@keyframes pop-in { 0% { opacity: 0; transform: scale(0.1); } 60% { opacity: 1; transform: scale(1.2); } 100% { transform: scale(1); }}@-webkit-keyframes pop-in { 0% { opacity: 0; -webkit-transform: scale(0.1); } 60% { opacity: 1; -webkit-transform: scale(1.2); } 100% { -webkit-transform: scale(1); }}@-moz-keyframes pop-in { 0% { opacity: 0; -moz-transform: scale(0.1); } 60% { opacity: 1; -moz-transform: scale(1.2); } 100% { -moz-transform: scale(1); }}.minicart-showing #PPMiniCart { display: block; transform: translateZ(0); -webkit-transform: translateZ(0); -moz-transform: translateZ(0); animation: pop-in 0.25s; -webkit-animation: pop-in 0.25s; -moz-animation: pop-in 0.25s;}#PPMiniCart { display: none; position: fixed; left: 50%; top: 75px;}#PPMiniCart form { position: relative; width: 400px; max-height: 400px; margin-left: -200px; padding: 10px 10px 40px; background: #fbfbfb; border: 1px solid #d7d7d7; border-radius: 4px; box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5); font: 15px/normal arial, helvetica; color: #333;}#PPMiniCart form.minicart-empty { padding-bottom: 10px; font-size: 16px; font-weight: bold;}#PPMiniCart ul { clear: both; float: left; width: 380px; margin: 5px 0 20px; padding: 10px; list-style-type: none; background: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);}#PPMiniCart .minicart-empty ul { display: none;}#PPMiniCart .minicart-closer { float: right; margin: -12px -10px 0; padding: 10px; background: 0; border: 0; font-size: 18px; cursor: pointer; font-weight: bold;}#PPMiniCart .minicart-item { clear: left; padding: 6px 0; min-height: 25px;}#PPMiniCart .minicart-item + .minicart-item { border-top: 1px solid #f2f2f2;}#PPMiniCart .minicart-item a { color: #333; text-decoration: none;}#PPMiniCart .minicart-details-name { float: left; width: 62%;}#PPMiniCart .minicart-details-quantity { float: left; width: 15%;}#PPMiniCart .minicart-details-remove { float: left; width: 7%;}#PPMiniCart .minicart-details-price { float: left; width: 16%; text-align: right;}#PPMiniCart .minicart-attributes { margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; color: #999; font-size: 12px; line-height: 22px;}#PPMiniCart .minicart-attributes li { display: inline;}#PPMiniCart .minicart-attributes li:after { content: ",";}#PPMiniCart .minicart-attributes li:last-child:after { content: "";}#PPMiniCart .minicart-quantity { width: 30px; height: 18px; padding: 2px 4px; border: 1px solid #ccc; border-radius: 4px; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); font-size: 13px; text-align: right; transition: border linear 0.2s, box-shadow linear 0.2s; -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; -moz-transition: border linear 0.2s, box-shadow linear 0.2s;}#PPMiniCart .minicart-quantity:hover { border-color: #0078C1;}#PPMiniCart .minicart-quantity:focus { border-color: #0078C1; outline: 0; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 3px rgba(0, 120, 193, 0.4);}#PPMiniCart .minicart-remove { width: 18px; height: 19px; margin: 2px 0 0; padding: 0; background: #b7b7b7; border: 1px solid #a3a3a3; border-radius: 3px; color: #fff; font-size: 13px; opacity: 0.70; cursor: pointer;}#PPMiniCart .minicart-remove:hover { opacity: 1;}#PPMiniCart .minicart-footer { clear: left;}#PPMiniCart .minicart-subtotal { position: absolute; bottom: 17px; padding-left: 6px; left: 10px; font-size: 16px; font-weight: bold;}#PPMiniCart .minicart-submit { position: absolute; bottom: 10px; right: 10px; min-width: 153px; height: 33px; margin-right: 6px; padding: 0 9px; border: 1px solid #ffc727; border-radius: 5px; color: #000; text-shadow: 1px 1px 1px #fff6e9; cursor: pointer; background: #ffaa00; background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZjZlOSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmFhMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top, #fff6e9 0%, #ffaa00 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fff6e9), color-stop(100%,#ffaa00)); background: -webkit-linear-gradient(top, #fff6e9 0%,#ffaa00 100%); background: -o-linear-gradient(top, #fff6e9 0%,#ffaa00 100%); background: -ms-linear-gradient(top, #fff6e9 0%,#ffaa00 100%); background: linear-gradient(to bottom, #fff6e9 0%,#ffaa00 100%);}#PPMiniCart .minicart-submit img { vertical-align: middle; padding: 4px 0 0 2px;}', + + strings: { + button: 'Check Out with PayPal', + subtotal: 'Subtotal:', + discount: 'Discount:', + empty: 'Your shopping cart is empty' + } + +}; + + +/** + * Mixes in the user config with the default config. + * + * @param {object} userConfig Configuration overrides + * @return {object} + */ +module.exports.load = function load(userConfig) { + return mixin(defaults, userConfig); +}; + +},{"./util/mixin":18}],11:[function(require,module,exports){ +'use strict'; + + +module.exports = { + + COMMANDS: { _cart: true, _xclick: true, _donations: true }, + + SETTINGS: /^(?:business|currency_code|lc|paymentaction|no_shipping|cn|no_note|invoice|handling_cart|weight_cart|weight_unit|tax_cart|discount_amount_cart|discount_rate_cart|page_style|image_url|cpp_|cs|cbt|return|cancel_return|notify_url|rm|custom|charset)/, + + BN: 'MiniCart_AddToCart_WPS_US', + + KEYUP_TIMEOUT: 500, + + SHOWING_CLASS: 'minicart-showing', + + REMOVE_CLASS: 'minicart-remove', + + CLOSER_CLASS: 'minicart-closer', + + QUANTITY_CLASS: 'minicart-quantity', + + ITEM_CLASS: 'minicart-item', + + ITEM_CHANGED_CLASS: 'minicart-item-changed', + + SUBMIT_CLASS: 'minicart-submit', + + DATA_IDX: 'data-minicart-idx' + +}; + +},{}],12:[function(require,module,exports){ +'use strict'; + + +var Cart = require('./cart'), + View = require('./view'), + config = require('./config'), + minicart = {}, + cartModel, + confModel, + viewModel; + + +/** + * Renders the Mini Cart to the page's DOM. + * + * @param {object} userConfig Configuration overrides + */ +minicart.render = function (userConfig) { + confModel = minicart.config = config.load(userConfig); + cartModel = minicart.cart = new Cart(confModel.name, confModel.duration); + viewModel = minicart.view = new View({ + config: confModel, + cart: cartModel + }); + + cartModel.on('add', viewModel.addItem, viewModel); + cartModel.on('change', viewModel.changeItem, viewModel); + cartModel.on('remove', viewModel.removeItem, viewModel); + cartModel.on('destroy', viewModel.hide, viewModel); +}; + + +/** + * Resets the Mini Cart and its view model + */ +minicart.reset = function () { + cartModel.destroy(); + + viewModel.hide(); + viewModel.redraw(); +}; + + + + +// Export to either node or the brower window +if (typeof window === 'undefined') { + module.exports = minicart; +} else { + if (!window.paypal) { + window.paypal = {}; + } + + window.paypal.minicart = minicart; +} + +},{"./cart":9,"./config":10,"./view":22}],13:[function(require,module,exports){ +'use strict'; + + +var currency = require('./util/currency'), + Pubsub = require('./util/pubsub'), + mixin = require('./util/mixin'); + + +var parser = { + quantity: function (value) { + value = parseInt(value, 10); + + if (isNaN(value) || !value) { + value = 1; + } + + return value; + }, + amount: function (value) { + return parseFloat(value) || 0; + }, + href: function (value) { + if (value) { + return value; + } else { + return (typeof window !== 'undefined') ? window.location.href : null; + } + } +}; + + +/** + * Creates a new product. + * + * @constructor + * @param {object} data Item data + */ +function Product(data) { + data.quantity = parser.quantity(data.quantity); + data.amount = parser.amount(data.amount); + data.href = parser.href(data.href); + + this._data = data; + this._options = null; + this._discount = null; + this._amount = null; + this._total = null; + + Pubsub.call(this); +} + + +mixin(Product.prototype, Pubsub.prototype); + + +/** + * Gets the product data. + * + * @param {string} key (Optional) A key to restrict the returned data to. + * @return {array|string} + */ +Product.prototype.get = function get(key) { + return (key) ? this._data[key] : this._data; +}; + + +/** + * Sets a value on the product. This is used rather than manually setting the + * value so that we can fire a "change" event. + * + * @param {string} key + * @param {string} value + */ +Product.prototype.set = function set(key, value) { + var setter = parser[key]; + + this._data[key] = setter ? setter(value) : value; + this._options = null; + this._discount = null; + this._amount = null; + this._total = null; + + this.fire('change', key); +}; + + +/** + * Parse and return the options for this product. + * + * @return {object} + */ +Product.prototype.options = function options() { + var result, key, value, amount, i, j; + + if (!this._options) { + result = []; + i = 0; + + while ((key = this.get('on' + i))) { + value = this.get('os' + i); + amount = 0; + j = 0; + + while (typeof this.get('option_select' + j) !== 'undefined') { + if (this.get('option_select' + j) === value) { + amount = parser.amount(this.get('option_amount' + j)); + break; + } + + j++; + } + + result.push({ + key: key, + value: value, + amount: amount + }); + + i++; + } + + this._options = result; + } + + return this._options; +}; + + +/** + * Parse and return the discount for this product. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Product.prototype.discount = function discount(config) { + var flat, rate, num, limit, result, amount; + + if (!this._discount) { + result = 0; + num = parseInt(this.get('discount_num'), 10) || 0; + limit = Math.max(num, this.get('quantity') - 1); + + if (this.get('discount_amount') !== undefined) { + flat = parser.amount(this.get('discount_amount')); + result += flat; + result += parser.amount(this.get('discount_amount2') || flat) * limit; + } else if (this.get('discount_rate') !== undefined) { + rate = parser.amount(this.get('discount_rate')); + amount = this.amount(); + + result += rate * amount / 100; + result += parser.amount(this.get('discount_rate2') || rate) * amount * limit / 100; + } + + this._discount = result; + } + + return currency(this._discount, config); +}; + + +/** + * Parse and return the total without discounts for this product. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Product.prototype.amount = function amount(config) { + var result, options, len, i; + + if (!this._amount) { + result = this.get('amount'); + options = this.options(); + + for (i = 0, len = options.length; i < len; i++) { + result += options[i].amount; + } + + this._amount = result; + } + + return currency(this._amount, config); +}; + + +/** + * Parse and return the total for this product. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Product.prototype.total = function total(config) { + var result; + + if (!this._total) { + result = this.get('quantity') * this.amount(); + result -= this.discount(); + + this._total = parser.amount(result); + } + + return currency(this._total, config); +}; + + +/** + * Determine if this product has the same data as another. + * + * @param {object|Product} data Other product. + * @return {boolean} + */ +Product.prototype.isEqual = function isEqual(data) { + var match = false; + + if (data instanceof Product) { + data = data._data; + } + + if (this.get('item_name') === data.item_name) { + if (this.get('item_number') === data.item_number) { + if (this.get('amount') === parser.amount(data.amount)) { + var i = 0; + + match = true; + + while (typeof data['os' + i] !== 'undefined') { + if (this.get('os' + i) !== data['os' + i]) { + match = false; + break; + } + + i++; + } + } + } + } + + return match; +}; + + +/** + * Determine if this product is valid. + * + * @return {boolean} + */ +Product.prototype.isValid = function isValid() { + return (this.get('item_name') && this.amount() > 0); +}; + + +/** + * Destroys this product. Fires a "destroy" event. + */ +Product.prototype.destroy = function destroy() { + this._data = []; + this.fire('destroy', this); +}; + + + + +module.exports = Product; + +},{"./util/currency":15,"./util/mixin":18,"./util/pubsub":19}],14:[function(require,module,exports){ +/* jshint quotmark:double */ + + +"use strict"; + + + +module.exports.add = function add(el, str) { + var re; + + if (!el) { return false; } + + if (el && el.classList && el.classList.add) { + el.classList.add(str); + } else { + re = new RegExp("\\b" + str + "\\b"); + + if (!re.test(el.className)) { + el.className += " " + str; + } + } +}; + + +module.exports.remove = function remove(el, str) { + var re; + + if (!el) { return false; } + + if (el.classList && el.classList.add) { + el.classList.remove(str); + } else { + re = new RegExp("\\b" + str + "\\b"); + + if (re.test(el.className)) { + el.className = el.className.replace(re, ""); + } + } +}; + + +module.exports.inject = function inject(el, str) { + var style; + + if (!el) { return false; } + + if (str) { + style = document.createElement("style"); + style.type = "text/css"; + + if (style.styleSheet) { + style.styleSheet.cssText = str; + } else { + style.appendChild(document.createTextNode(str)); + } + + el.appendChild(style); + } +}; + +},{}],15:[function(require,module,exports){ +'use strict'; + + +var currencies = { + AED: { before: '\u062c' }, + ANG: { before: '\u0192' }, + ARS: { before: '$', code: true }, + AUD: { before: '$', code: true }, + AWG: { before: '\u0192' }, + BBD: { before: '$', code: true }, + BGN: { before: '\u043b\u0432' }, + BMD: { before: '$', code: true }, + BND: { before: '$', code: true }, + BRL: { before: 'R$' }, + BSD: { before: '$', code: true }, + CAD: { before: '$', code: true }, + CHF: { before: '', code: true }, + CLP: { before: '$', code: true }, + CNY: { before: '\u00A5' }, + COP: { before: '$', code: true }, + CRC: { before: '\u20A1' }, + CZK: { before: 'Kc' }, + DKK: { before: 'kr' }, + DOP: { before: '$', code: true }, + EEK: { before: 'kr' }, + EUR: { before: '\u20AC' }, + GBP: { before: '\u00A3' }, + GTQ: { before: 'Q' }, + HKD: { before: '$', code: true }, + HRK: { before: 'kn' }, + HUF: { before: 'Ft' }, + IDR: { before: 'Rp' }, + ILS: { before: '\u20AA' }, + INR: { before: 'Rs.' }, + ISK: { before: 'kr' }, + JMD: { before: 'J$' }, + JPY: { before: '\u00A5' }, + KRW: { before: '\u20A9' }, + KYD: { before: '$', code: true }, + LTL: { before: 'Lt' }, + LVL: { before: 'Ls' }, + MXN: { before: '$', code: true }, + MYR: { before: 'RM' }, + NOK: { before: 'kr' }, + NZD: { before: '$', code: true }, + PEN: { before: 'S/' }, + PHP: { before: 'Php' }, + PLN: { before: 'z' }, + QAR: { before: '\ufdfc' }, + RON: { before: 'lei' }, + RUB: { before: '\u0440\u0443\u0431' }, + SAR: { before: '\ufdfc' }, + SEK: { before: 'kr' }, + SGD: { before: '$', code: true }, + THB: { before: '\u0E3F' }, + TRY: { before: 'TL' }, + TTD: { before: 'TT$' }, + TWD: { before: 'NT$' }, + UAH: { before: '\u20b4' }, + USD: { before: '$', code: true }, + UYU: { before: '$U' }, + VEF: { before: 'Bs' }, + VND: { before: '\u20ab' }, + XCD: { before: '$', code: true }, + ZAR: { before: 'R' } +}; + + +module.exports = function currency(amount, config) { + var code = config && config.currency || 'USD', + value = currencies[code], + before = value.before || '', + after = value.after || '', + length = value.length || 2, + showCode = value.code && config && config.showCode, + result = amount; + + if (config && config.format) { + result = before + result.toFixed(length) + after; + } + + if (showCode) { + result += ' ' + code; + } + + return result; +}; + +},{}],16:[function(require,module,exports){ +'use strict'; + + +module.exports = (function (window, document) { + + /** + * Events are added here for easy reference + */ + var cache = []; + + // NOOP for Node + if (!document) { + return { + add: function () {}, + remove: function () {} + }; + // Non-IE events + } else if (document.addEventListener) { + return { + /** + * Add an event to an object and optionally adjust it's scope + * + * @param obj {HTMLElement} The object to attach the event to + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + * @param scope {object} Object to adjust the scope to (optional) + */ + add: function (obj, type, fn, scope) { + scope = scope || obj; + + var wrappedFn = function (e) { fn.call(scope, e); }; + + obj.addEventListener(type, wrappedFn, false); + cache.push([obj, type, fn, wrappedFn]); + }, + + + /** + * Remove an event from an object + * + * @param obj {HTMLElement} The object to remove the event from + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + */ + remove: function (obj, type, fn) { + var wrappedFn, item, len = cache.length, i; + + for (i = 0; i < len; i++) { + item = cache[i]; + + if (item[0] === obj && item[1] === type && item[2] === fn) { + wrappedFn = item[3]; + + if (wrappedFn) { + obj.removeEventListener(type, wrappedFn, false); + cache = cache.slice(i); + return true; + } + } + } + } + }; + + // IE events + } else if (document.attachEvent) { + return { + /** + * Add an event to an object and optionally adjust it's scope (IE) + * + * @param obj {HTMLElement} The object to attach the event to + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + * @param scope {object} Object to adjust the scope to (optional) + */ + add: function (obj, type, fn, scope) { + scope = scope || obj; + + var wrappedFn = function () { + var e = window.event; + e.target = e.target || e.srcElement; + + e.preventDefault = function () { + e.returnValue = false; + }; + + fn.call(scope, e); + }; + + obj.attachEvent('on' + type, wrappedFn); + cache.push([obj, type, fn, wrappedFn]); + }, + + + /** + * Remove an event from an object (IE) + * + * @param obj {HTMLElement} The object to remove the event from + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + */ + remove: function (obj, type, fn) { + var wrappedFn, item, len = cache.length, i; + + for (i = 0; i < len; i++) { + item = cache[i]; + + if (item[0] === obj && item[1] === type && item[2] === fn) { + wrappedFn = item[3]; + + if (wrappedFn) { + obj.detachEvent('on' + type, wrappedFn); + cache = cache.slice(i); + return true; + } + } + } + } + }; + } + +})(typeof window === 'undefined' ? null : window, typeof document === 'undefined' ? null : document); + +},{}],17:[function(require,module,exports){ +'use strict'; + + +var forms = module.exports = { + + parse: function parse(form) { + var raw = form.elements, + data = {}, + pair, value, i, len; + + for (i = 0, len = raw.length; i < len; i++) { + pair = raw[i]; + + if ((value = forms.getInputValue(pair))) { + data[pair.name] = value; + } + } + + return data; + }, + + + getInputValue: function getInputValue(input) { + var tag = input.tagName.toLowerCase(); + + if (tag === 'select') { + return input.options[input.selectedIndex].value; + } else if (tag === 'textarea') { + return input.innerText; + } else { + if (input.type === 'radio') { + return (input.checked) ? input.value : null; + } else if (input.type === 'checkbox') { + return (input.checked) ? input.value : null; + } else { + return input.value; + } + } + } + +}; +},{}],18:[function(require,module,exports){ +'use strict'; + + +var mixin = module.exports = function mixin(dest, source) { + var value; + + for (var key in source) { + value = source[key]; + + if (value && value.constructor === Object) { + if (!dest[key]) { + dest[key] = value; + } else { + mixin(dest[key] || {}, value); + } + } else { + dest[key] = value; + } + } + + return dest; +}; + +},{}],19:[function(require,module,exports){ +'use strict'; + + +function Pubsub() { + this._eventCache = {}; +} + + +Pubsub.prototype.on = function on(name, fn, scope) { + var cache = this._eventCache[name]; + + if (!cache) { + cache = this._eventCache[name] = []; + } + + cache.push([fn, scope]); +}; + + +Pubsub.prototype.off = function off(name, fn) { + var cache = this._eventCache[name], + i, len; + + if (cache) { + for (i = 0, len = cache.length; i < len; i++) { + if (cache[i] === fn) { + cache = cache.splice(i, 1); + } + } + } +}; + + +Pubsub.prototype.fire = function on(name) { + var cache = this._eventCache[name], i, len, fn, scope; + + if (cache) { + for (i = 0, len = cache.length; i < len; i++) { + fn = cache[i][0]; + scope = cache[i][1] || this; + + if (typeof fn === 'function') { + fn.apply(scope, Array.prototype.slice.call(arguments, 1)); + } + } + } +}; + + +module.exports = Pubsub; + +},{}],20:[function(require,module,exports){ +'use strict'; + + +var Storage = module.exports = function Storage(name, duration) { + this._name = name; + this._duration = duration || 30; +}; + + +var proto = Storage.prototype; + + +proto.load = function () { + if (typeof window === 'object' && window.localStorage) { + var data = window.localStorage.getItem(this._name), today, expires; + + if (data) { + data = JSON.parse(decodeURIComponent(data)); + } + + if (data && data.expires) { + today = new Date(); + expires = new Date(data.expires); + + if (today > expires) { + this.destroy(); + return; + } + } + + return data && data.value; + } +}; + + +proto.save = function (data) { + if (typeof window === 'object' && window.localStorage) { + var expires = new Date(), wrapped; + + expires.setTime(expires.getTime() + this._duration * 24 * 60 * 60 * 1000); + + wrapped = { + value: data, + expires: expires.toGMTString() + }; + + window.localStorage.setItem(this._name, encodeURIComponent(JSON.stringify(wrapped))); + } +}; + + +proto.destroy = function () { + if (typeof window === 'object' && window.localStorage) { + window.localStorage.removeItem(this._name); + } +}; + +},{}],21:[function(require,module,exports){ +'use strict'; + + +var ejs = require('ejs'); + + +module.exports = function template(str, data) { + return ejs.render(str, data); +}; + + +// Workaround for IE 8's lack of support +if (!String.prototype.trim) { + String.prototype.trim = function () { + return this.replace(/^\s+|\s+$/g, ''); + }; +} + +},{"ejs":6}],22:[function(require,module,exports){ +'use strict'; + + +var config = require('./config'), + events = require('./util/events'), + template = require('./util/template'), + forms = require('./util/forms'), + css = require('./util/css'), + viewevents = require('./viewevents'), + constants = require('./constants'); + + + +/** + * Creates a view model. + * + * @constructor + * @param {object} model + */ +function View(model) { + var wrapper; + + this.el = wrapper = document.createElement('div'); + this.model = model; + this.isShowing = false; + + // HTML + wrapper.id = config.name; + config.parent.appendChild(wrapper); + + // CSS + css.inject(document.getElementsByTagName('head')[0], config.styles); + + // JavaScript + events.add(document, ('ontouchstart' in window) ? 'touchstart' : 'click', viewevents.click, this); + events.add(document, 'keyup', viewevents.keyup, this); + events.add(document, 'readystatechange', viewevents.readystatechange, this); + events.add(window, 'pageshow', viewevents.pageshow, this); +} + + +/** + * Tells the view to redraw + */ +View.prototype.redraw = function redraw() { + events.remove(this.el.querySelector('form'), 'submit', this.model.cart.checkout, this.model.cart); + this.el.innerHTML = template(config.template, this.model); + events.add(this.el.querySelector('form'), 'submit', this.model.cart.checkout, this.model.cart); +}; + + +/** + * Tells the view to show + */ +View.prototype.show = function show() { + if (!this.isShowing) { + css.add(document.body, constants.SHOWING_CLASS); + this.isShowing = true; + } +}; + + +/** + * Tells the view to hide + */ +View.prototype.hide = function hide() { + if (this.isShowing) { + css.remove(document.body, constants.SHOWING_CLASS); + this.isShowing = false; + } +}; + + +/** + * Toggles the visibility of the view + */ +View.prototype.toggle = function toggle() { + this[this.isShowing ? 'hide' : 'show'](); +}; + + +/** + * Binds cart submit events to a form. + * + * @param {HTMLElement} form + * @return {boolean} + */ +View.prototype.bind = function bind(form) { + var that = this; + + // Don't bind forms without a cmd value + if (!constants.COMMANDS[form.cmd.value]) { + return false; + } + + // Prevent re-binding forms + if (form.hasMinicart) { + return false; + } else { + form.hasMinicart = true; + } + + if (form.display) { + events.add(form, 'submit', function (e) { + e.preventDefault(); + that.show(); + }); + } else { + events.add(form, 'submit', function (e) { + e.preventDefault(e); + that.model.cart.add(forms.parse(form)); + }); + } + + return true; +}; + + +/** + * Adds an item to the view. + * + * @param {number} idx + * @param {object} data + */ +View.prototype.addItem = function addItem(idx, data) { + this.redraw(); + this.show(); + + var els = this.el.querySelectorAll('.' + constants.ITEM_CLASS); + css.add(els[idx], constants.ITEM_CHANGED_CLASS); +}; + + +/** + * Changes an item in the view. + * + * @param {number} idx + * @param {object} data + */ +View.prototype.changeItem = function changeItem(idx, data) { + this.redraw(); + this.show(); + + var els = this.el.querySelectorAll('.' + constants.ITEM_CLASS); + css.add(els[idx], constants.ITEM_CHANGED_CLASS); +}; + + +/** + * Removes an item from the view. + * + * @param {number} idx + */ +View.prototype.removeItem = function removeItem(idx) { + this.redraw(); +}; + + + + +module.exports = View; + +},{"./config":10,"./constants":11,"./util/css":14,"./util/events":16,"./util/forms":17,"./util/template":21,"./viewevents":23}],23:[function(require,module,exports){ +'use strict'; + + +var constants = require('./constants'), + events = require('./util/events'), + viewevents; + + +module.exports = viewevents = { + + click: function (evt) { + var target = evt.target, + className = target.className; + + if (this.isShowing) { + // Cart close button + if (className === constants.CLOSER_CLASS) { + this.hide(); + // Product remove button + } else if (className === constants.REMOVE_CLASS) { + this.model.cart.remove(target.getAttribute(constants.DATA_IDX)); + // Product quantity input + } else if (className === constants.QUANTITY_CLASS) { + target[target.setSelectionRange ? 'setSelectionRange' : 'select'](0, 999); + // Outside the cart + } else if (!(/input|button|select|option/i.test(target.tagName))) { + while (target.nodeType === 1) { + if (target === this.el) { + return; + } + + target = target.parentNode; + } + + this.hide(); + } + } + }, + + + keyup: function (evt) { + var that = this, + target = evt.target, + timer; + + if (target.className === constants.QUANTITY_CLASS) { + timer = setTimeout(function () { + var idx = parseInt(target.getAttribute(constants.DATA_IDX), 10), + cart = that.model.cart, + product = cart.items(idx), + quantity = parseInt(target.value, 10); + + if (product) { + if (quantity > 0) { + product.set('quantity', quantity); + } else if (quantity === 0) { + cart.remove(idx); + } + } + }, constants.KEYUP_TIMEOUT); + } + }, + + + readystatechange: function () { + if (/interactive|complete/.test(document.readyState)) { + var forms, form, i, len; + + // Bind to page's forms + forms = document.getElementsByTagName('form'); + + for (i = 0, len = forms.length; i < len; i++) { + form = forms[i]; + + if (form.cmd && constants.COMMANDS[form.cmd.value]) { + this.bind(form); + } + } + + // Do the initial render when the buttons are ready + this.redraw(); + + // Only run this once + events.remove(document, 'readystatechange', viewevents.readystatechange); + } + }, + + + pageshow: function (evt) { + if (evt.persisted) { + this.redraw(); + this.hide(); + } + } + +}; + +},{"./constants":11,"./util/events":16}]},{},[9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]) +; \ No newline at end of file diff --git a/carrito-con-paypal/carrito.html b/carrito-con-paypal/carrito.html new file mode 100644 index 00000000..ffb8f9e9 --- /dev/null +++ b/carrito-con-paypal/carrito.html @@ -0,0 +1,78 @@ + + + + + + + + carrito + + +
+
+
+
+
+ 100%x200 +
+

Samsumg S7

+

El fabuloso samsung S7 es mas que un celular, es el futuro

+

Ver Carrito

+
+
+
+
+
+ 100%x200 +
+

Iphone S6

+

Iphone que tiene la VISAKA!

+

Ver carrito

+
+
+
+
+
+ 100%x200 +
+

Moto G5 Plus

+

EL Moto G5 plus que tengo yo :v

+

Ver carrito

+
+
+
+
+
+ 100%x200 +
+

Telcel Alcatel Ot 5012g Plata

+

EL padre de todos los celulares

+

Ver carrito

+
+
+
+
+
+
+ 100%x200 +
+

Samsung S8

+

El Galaxy S8 está diseñado para ser mucho más que un smartphone.

+

Ver carrito

+
+
+
+ +
+ Derechos Reservados © 2018-2020 +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/firebase/administracion.html b/firebase/administracion.html new file mode 100644 index 00000000..f983f37a --- /dev/null +++ b/firebase/administracion.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + Listado Productos + + + +
+

Edición de Productos

+
+ + \ No newline at end of file diff --git a/firebase/css/custom.css b/firebase/css/custom.css new file mode 100644 index 00000000..ddf4c982 --- /dev/null +++ b/firebase/css/custom.css @@ -0,0 +1,24 @@ +body{ + padding-top: 65px; +} + +img{ + height:140px; + width:140px; +} + +.cabeceraProducto{ + border-bottom-style: solid; + border-bottom-width: 1px; + border-bottom-color: grey; + background-color: black; + color:white; +} + +.imagenFix{ + min-height: 140px; +} + +.espaciador{ + min-height: 30px; +} \ No newline at end of file diff --git a/firebase/editarproducto.html b/firebase/editarproducto.html new file mode 100644 index 00000000..ec524769 --- /dev/null +++ b/firebase/editarproducto.html @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + Edición de Productos + + + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +

Elija una imagen para este artículo

+ +
+ +
+
+ + \ No newline at end of file diff --git a/firebase/index.html b/firebase/index.html new file mode 100644 index 00000000..cd4ef6aa --- /dev/null +++ b/firebase/index.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + Gestión de Productos con Firebase + + + + +
+

Listado de Productos

+ +
+
+ + \ No newline at end of file diff --git a/firebase/js/administracion.js b/firebase/js/administracion.js new file mode 100644 index 00000000..aa4da9a7 --- /dev/null +++ b/firebase/js/administracion.js @@ -0,0 +1,88 @@ +// Inicializar la base de datos +var config = { + apiKey: 'AIzaSyCA_qTHoFGTVKRvPSAMCajPblhVZJ73Zk0', + authDomain: 'demoapp-30f5d.firebaseapp.com', + databaseURL: 'https://demoapp-30f5d.firebaseio.com', + projectId: 'demoapp-30f5d', + storageBucket: 'demoapp-30f5d.appspot.com', + messagingSenderId: '992985819602' +}; + +firebase.initializeApp(config); +var database = firebase.database(); + +var referencia = database.ref('productos'); + +var productos = {}; + +/* +Evento: value + +The value event is used to read a static snapshot of the contents at a given database path, +as they existed at the time of the read event. It is triggered once with the initial data and again every time the data changes. +The event callback is passed a snapshot containing all data at that location, including child data. In our code example above, +value returned all of the blog posts in our app. Everytime a new blog post is added, the callback function will return all of the posts. +*/ + +referencia.on('value', function(datos) { + // Eliminamos el contenido del listado para actualizarlo. + $('#listado div.row').remove(); + + productos = datos.val(); + + // Recorremos los productos y los mostramos + $.each(productos, function(indice, valor) { + var prevProducto = '
'; + + prevProducto += '

' + valor.articulo + '

'; + + prevProducto += '
'; + prevProducto += '

' + valor.precio + '

'; + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += '
'; + if (valor.imagen == 'NONE') + prevProducto += 'Sin Fotografía'; + else + prevProducto += ''; + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += '

' + valor.descripcion + '

'; + prevProducto += '
'; + prevProducto += '
'; + + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += ''; + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += ''; + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += '
'; + prevProducto += '
'; + + $(prevProducto).appendTo('#listado'); + }); +}, function(objetoError) { + console.log('Error de lectura:' + objetoError.code); +}); + +function editarProducto(id) { + // Para pasar el ID a otro proceso lo hacemos a través de window.name + window.name = id; + + // Cargamos la página editarproducto.html + location.assign('editarproducto.html'); +}; + +function borrarProducto(id) { + if (confirm('¿Está seguro/a de que quiere borrar este artículo?') == true) { + referencia.child(id).remove(); + } +}; \ No newline at end of file diff --git a/firebase/js/editarproducto.js b/firebase/js/editarproducto.js new file mode 100644 index 00000000..da96e0e6 --- /dev/null +++ b/firebase/js/editarproducto.js @@ -0,0 +1,72 @@ +$(document).ready(function() { + // Inicializar la base de datos + var config = { + apiKey: 'AIzaSyCA_qTHoFGTVKRvPSAMCajPblhVZJ73Zk0', + authDomain: 'demoapp-30f5d.firebaseapp.com', + databaseURL: 'https://demoapp-30f5d.firebaseio.com', + projectId: 'demoapp-30f5d', + storageBucket: 'demoapp-30f5d.appspot.com', + messagingSenderId: '992985819602' + }; + + firebase.initializeApp(config); + var database = firebase.database(); + var referencia = database.ref('productos'); + + var productoId = window.name; + // console.log(productoId); + + var articulo, descripcion, precio, imagen; + var producto = {}; + + // Buscamos el artículo. + referencia.child(productoId).once('value', function(datos) { + producto = datos.val(); + + articulo = producto.articulo; + descripcion = producto.descripcion; + precio = producto.precio; + imagenEdicion = producto.imagen; + + $('#articulo').val(articulo); + $('#descripcion').val(descripcion); + $('#precio').val(precio); + $('#previsualizacion').attr('src', imagenEdicion); + }); + + + $('#imagen').change(function() { + var descriptor = new FileReader(); + descriptor.readAsDataURL(this.files[0]); + + descriptor.onloadend = function() { + imagenEdicion = descriptor.result; + $('#previsualizacion').attr('src', imagenEdicion); + }; + }); + + $('#botonActualizar').click(function() { + var articulo = $('#articulo').val(); + var descripcion = $('#descripcion').val(); + var precio = $('#precio').val(); + var imagen = imagenEdicion; + + // Guardamos los datos en referencia + referencia.child(productoId).update( + { + articulo: articulo, + descripcion: descripcion, + precio: precio, + imagen: imagen, + }, alFinalizar); + }); + + function alFinalizar(error) { + if (error) { + alert('Ha habido problemas al realizar la operación: ' + error.code); + } else { + alert('Operación realizada con éxito !'); + location.assign('administracion.html'); + } + } +}); \ No newline at end of file diff --git a/firebase/js/index.js b/firebase/js/index.js new file mode 100644 index 00000000..e64aee91 --- /dev/null +++ b/firebase/js/index.js @@ -0,0 +1,69 @@ +$(document).ready(function() { + // Inicializar la base de datos + var config = { + apiKey: 'AIzaSyCA_qTHoFGTVKRvPSAMCajPblhVZJ73Zk0', + authDomain: 'demoapp-30f5d.firebaseapp.com', + databaseURL: 'https://demoapp-30f5d.firebaseio.com', + projectId: 'demoapp-30f5d', + storageBucket: 'demoapp-30f5d.appspot.com', + messagingSenderId: '992985819602' + }; + + firebase.initializeApp(config); + + var database = firebase.database(); + + // Fijarse que la ruta de partida ahora es la colección productos: + var referencia = database.ref('productos'); + + var productos = {}; + + /* + Evento: value + + The value event is used to read a static snapshot of the contents at a given database path, + as they existed at the time of the read event. It is triggered once with the initial data and again every time the data changes. + The event callback is passed a snapshot containing all data at that location, including child data. In our code example above, + value returned all of the blog posts in our app. Everytime a new blog post is added, the callback function will return all of the posts. + */ + + referencia.on('value', function(datos) { + productos = datos.val(); + + // Recorremos los productos y los mostramos + $.each(productos, function(indice, valor) { + var prevProducto = '
'; + + prevProducto += '

' + valor.articulo + '

'; + + prevProducto += '
'; + prevProducto += '

' + valor.precio + '

'; + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += '
'; + if (valor.imagen == 'NONE') + prevProducto += 'Sin Fotografía'; + else + prevProducto += ''; + prevProducto += '
'; + + prevProducto += '
'; + prevProducto += '

' + valor.descripcion + '

'; + prevProducto += '
'; + prevProducto += '
'; + prevProducto += '
'; + prevProducto += '
'; + prevProducto += '
'; + + $(prevProducto).appendTo('#listado'); + }); + }, function(objetoError) { + console.log('Error de lectura:' + objetoError.code); + }); +}); \ No newline at end of file diff --git a/firebase/js/minicart.js b/firebase/js/minicart.js new file mode 100644 index 00000000..0ad4c3b3 --- /dev/null +++ b/firebase/js/minicart.js @@ -0,0 +1,3020 @@ +/*! + * minicart + * The Mini Cart is a great way to improve your PayPal shopping cart integration. + * + * @version 3.0.6 + * @author Jeff Harrell + * @url http://www.minicartjs.com/ + * @license MIT + */ + +;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o i; ++i) { + if (array.hasOwnProperty(i)) { + if (isValueSet) { + value = callback(value, array[i], i, array); + } + else { + value = array[i]; + isValueSet = true; + } + } + } + + return value; +}; + +// String.prototype.substr - negative index don't work in IE8 +if ('ab'.substr(-1) !== 'b') { + exports.substr = function (str, start, length) { + // did we get a negative start, calculate how much it is from the beginning of the string + if (start < 0) start = str.length + start; + + // call the original function + return str.substr(start, length); + }; +} else { + exports.substr = function (str, start, length) { + return str.substr(start, length); + }; +} + +// String.prototype.trim is supported in IE9 +exports.trim = function (str) { + if (str.trim) return str.trim(); + return str.replace(/^\s+|\s+$/g, ''); +}; + +// Function.prototype.bind is supported in IE9 +exports.bind = function () { + var args = Array.prototype.slice.call(arguments); + var fn = args.shift(); + if (fn.bind) return fn.bind.apply(fn, args); + var self = args.shift(); + return function () { + fn.apply(self, args.concat([Array.prototype.slice.call(arguments)])); + }; +}; + +// Object.create is supported in IE9 +function create(prototype, properties) { + var object; + if (prototype === null) { + object = { '__proto__' : null }; + } + else { + if (typeof prototype !== 'object') { + throw new TypeError( + 'typeof prototype[' + (typeof prototype) + '] != \'object\'' + ); + } + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + object.__proto__ = prototype; + } + if (typeof properties !== 'undefined' && Object.defineProperties) { + Object.defineProperties(object, properties); + } + return object; +} +exports.create = typeof Object.create === 'function' ? Object.create : create; + +// Object.keys and Object.getOwnPropertyNames is supported in IE9 however +// they do show a description and number property on Error objects +function notObject(object) { + return ((typeof object != "object" && typeof object != "function") || object === null); +} + +function keysShim(object) { + if (notObject(object)) { + throw new TypeError("Object.keys called on a non-object"); + } + + var result = []; + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + result.push(name); + } + } + return result; +} + +// getOwnPropertyNames is almost the same as Object.keys one key feature +// is that it returns hidden properties, since that can't be implemented, +// this feature gets reduced so it just shows the length property on arrays +function propertyShim(object) { + if (notObject(object)) { + throw new TypeError("Object.getOwnPropertyNames called on a non-object"); + } + + var result = keysShim(object); + if (exports.isArray(object) && exports.indexOf(object, 'length') === -1) { + result.push('length'); + } + return result; +} + +var keys = typeof Object.keys === 'function' ? Object.keys : keysShim; +var getOwnPropertyNames = typeof Object.getOwnPropertyNames === 'function' ? + Object.getOwnPropertyNames : propertyShim; + +if (new Error().hasOwnProperty('description')) { + var ERROR_PROPERTY_FILTER = function (obj, array) { + if (toString.call(obj) === '[object Error]') { + array = exports.filter(array, function (name) { + return name !== 'description' && name !== 'number' && name !== 'message'; + }); + } + return array; + }; + + exports.keys = function (object) { + return ERROR_PROPERTY_FILTER(object, keys(object)); + }; + exports.getOwnPropertyNames = function (object) { + return ERROR_PROPERTY_FILTER(object, getOwnPropertyNames(object)); + }; +} else { + exports.keys = keys; + exports.getOwnPropertyNames = getOwnPropertyNames; +} + +// Object.getOwnPropertyDescriptor - supported in IE8 but only on dom elements +function valueObject(value, key) { + return { value: value[key] }; +} + +if (typeof Object.getOwnPropertyDescriptor === 'function') { + try { + Object.getOwnPropertyDescriptor({'a': 1}, 'a'); + exports.getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + } catch (e) { + // IE8 dom element issue - use a try catch and default to valueObject + exports.getOwnPropertyDescriptor = function (value, key) { + try { + return Object.getOwnPropertyDescriptor(value, key); + } catch (e) { + return valueObject(value, key); + } + }; + } +} else { + exports.getOwnPropertyDescriptor = valueObject; +} + +},{}],2:[function(require,module,exports){ + +// not implemented +// The reason for having an empty file and not throwing is to allow +// untraditional implementation of this module. + +},{}],3:[function(require,module,exports){ +var process=require("__browserify_process");// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var util = require('util'); +var shims = require('_shims'); + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i]; + if (last === '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var splitPath = function(filename) { + return splitPathRe.exec(filename).slice(1); +}; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { + var resolvedPath = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : process.cwd(); + + // Skip empty and invalid entries + if (!util.isString(path)) { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(shims.filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { + var isAbsolute = exports.isAbsolute(path), + trailingSlash = shims.substr(path, -1) === '/'; + + // Normalize the path + path = normalizeArray(shims.filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +exports.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(shims.filter(paths, function(p, index) { + if (!util.isString(p)) { + throw new TypeError('Arguments to path.join must be strings'); + } + return p; + }).join('/')); +}; + + +// path.relative(from, to) +// posix version +exports.relative = function(from, to) { + from = exports.resolve(from).substr(1); + to = exports.resolve(to).substr(1); + + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + +exports.sep = '/'; +exports.delimiter = ':'; + +exports.dirname = function(path) { + var result = splitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +exports.basename = function(path, ext) { + var f = splitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPath(path)[3]; +}; + +},{"__browserify_process":5,"_shims":1,"util":4}],4:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var shims = require('_shims'); + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + shims.forEach(array, function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = shims.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = shims.getOwnPropertyNames(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + + shims.forEach(keys, function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = shims.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (shims.indexOf(ctx.seen, desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = shims.reduce(output, function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return shims.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && objectToString(e) === '[object Error]'; +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.binarySlice === 'function' + ; +} +exports.isBuffer = isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = function(ctor, superCtor) { + ctor.super_ = superCtor; + ctor.prototype = shims.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); +}; + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = shims.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +},{"_shims":1}],5:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; + +process.nextTick = (function () { + var canSetImmediate = typeof window !== 'undefined' + && window.setImmediate; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canSetImmediate) { + return function (f) { return window.setImmediate(f) }; + } + + if (canPost) { + var queue = []; + window.addEventListener('message', function (ev) { + var source = ev.source; + if ((source === window || source === null) && ev.data === 'process-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('process-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +} + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; + +},{}],6:[function(require,module,exports){ + +/*! + * EJS + * Copyright(c) 2012 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var utils = require('./utils') + , path = require('path') + , dirname = path.dirname + , extname = path.extname + , join = path.join + , fs = require('fs') + , read = fs.readFileSync; + +/** + * Filters. + * + * @type Object + */ + +var filters = exports.filters = require('./filters'); + +/** + * Intermediate js cache. + * + * @type Object + */ + +var cache = {}; + +/** + * Clear intermediate js cache. + * + * @api public + */ + +exports.clearCache = function(){ + cache = {}; +}; + +/** + * Translate filtered code into function calls. + * + * @param {String} js + * @return {String} + * @api private + */ + +function filtered(js) { + return js.substr(1).split('|').reduce(function(js, filter){ + var parts = filter.split(':') + , name = parts.shift() + , args = parts.join(':') || ''; + if (args) args = ', ' + args; + return 'filters.' + name + '(' + js + args + ')'; + }); +}; + +/** + * Re-throw the given `err` in context to the + * `str` of ejs, `filename`, and `lineno`. + * + * @param {Error} err + * @param {String} str + * @param {String} filename + * @param {String} lineno + * @api private + */ + +function rethrow(err, str, filename, lineno){ + var lines = str.split('\n') + , start = Math.max(lineno - 3, 0) + , end = Math.min(lines.length, lineno + 3); + + // Error context + var context = lines.slice(start, end).map(function(line, i){ + var curr = i + start + 1; + return (curr == lineno ? ' >> ' : ' ') + + curr + + '| ' + + line; + }).join('\n'); + + // Alter exception message + err.path = filename; + err.message = (filename || 'ejs') + ':' + + lineno + '\n' + + context + '\n\n' + + err.message; + + throw err; +} + +/** + * Parse the given `str` of ejs, returning the function body. + * + * @param {String} str + * @return {String} + * @api public + */ + +var parse = exports.parse = function(str, options){ + var options = options || {} + , open = options.open || exports.open || '<%' + , close = options.close || exports.close || '%>' + , filename = options.filename + , compileDebug = options.compileDebug !== false + , buf = ""; + + buf += 'var buf = [];'; + if (false !== options._with) buf += '\nwith (locals || {}) { (function(){ '; + buf += '\n buf.push(\''; + + var lineno = 1; + + var consumeEOL = false; + for (var i = 0, len = str.length; i < len; ++i) { + var stri = str[i]; + if (str.slice(i, open.length + i) == open) { + i += open.length + + var prefix, postfix, line = (compileDebug ? '__stack.lineno=' : '') + lineno; + switch (str[i]) { + case '=': + prefix = "', escape((" + line + ', '; + postfix = ")), '"; + ++i; + break; + case '-': + prefix = "', (" + line + ', '; + postfix = "), '"; + ++i; + break; + default: + prefix = "');" + line + ';'; + postfix = "; buf.push('"; + } + + var end = str.indexOf(close, i) + , js = str.substring(i, end) + , start = i + , include = null + , n = 0; + + if ('-' == js[js.length-1]){ + js = js.substring(0, js.length - 2); + consumeEOL = true; + } + + if (0 == js.trim().indexOf('include')) { + var name = js.trim().slice(7).trim(); + if (!filename) throw new Error('filename option is required for includes'); + var path = resolveInclude(name, filename); + include = read(path, 'utf8'); + include = exports.parse(include, { filename: path, _with: false, open: open, close: close, compileDebug: compileDebug }); + buf += "' + (function(){" + include + "})() + '"; + js = ''; + } + + while (~(n = js.indexOf("\n", n))) n++, lineno++; + if (js.substr(0, 1) == ':') js = filtered(js); + if (js) { + if (js.lastIndexOf('//') > js.lastIndexOf('\n')) js += '\n'; + buf += prefix; + buf += js; + buf += postfix; + } + i += end - start + close.length - 1; + + } else if (stri == "\\") { + buf += "\\\\"; + } else if (stri == "'") { + buf += "\\'"; + } else if (stri == "\r") { + // ignore + } else if (stri == "\n") { + if (consumeEOL) { + consumeEOL = false; + } else { + buf += "\\n"; + lineno++; + } + } else { + buf += stri; + } + } + + if (false !== options._with) buf += "'); })();\n} \nreturn buf.join('');"; + else buf += "');\nreturn buf.join('');"; + return buf; +}; + +/** + * Compile the given `str` of ejs into a `Function`. + * + * @param {String} str + * @param {Object} options + * @return {Function} + * @api public + */ + +var compile = exports.compile = function(str, options){ + options = options || {}; + var escape = options.escape || utils.escape; + + var input = JSON.stringify(str) + , compileDebug = options.compileDebug !== false + , client = options.client + , filename = options.filename + ? JSON.stringify(options.filename) + : 'undefined'; + + if (compileDebug) { + // Adds the fancy stack trace meta info + str = [ + 'var __stack = { lineno: 1, input: ' + input + ', filename: ' + filename + ' };', + rethrow.toString(), + 'try {', + exports.parse(str, options), + '} catch (err) {', + ' rethrow(err, __stack.input, __stack.filename, __stack.lineno);', + '}' + ].join("\n"); + } else { + str = exports.parse(str, options); + } + + if (options.debug) console.log(str); + if (client) str = 'escape = escape || ' + escape.toString() + ';\n' + str; + + try { + var fn = new Function('locals, filters, escape, rethrow', str); + } catch (err) { + if ('SyntaxError' == err.name) { + err.message += options.filename + ? ' in ' + filename + : ' while compiling ejs'; + } + throw err; + } + + if (client) return fn; + + return function(locals){ + return fn.call(this, locals, filters, escape, rethrow); + } +}; + +/** + * Render the given `str` of ejs. + * + * Options: + * + * - `locals` Local variables object + * - `cache` Compiled functions are cached, requires `filename` + * - `filename` Used by `cache` to key caches + * - `scope` Function execution context + * - `debug` Output generated function body + * - `open` Open tag, defaulting to "<%" + * - `close` Closing tag, defaulting to "%>" + * + * @param {String} str + * @param {Object} options + * @return {String} + * @api public + */ + +exports.render = function(str, options){ + var fn + , options = options || {}; + + if (options.cache) { + if (options.filename) { + fn = cache[options.filename] || (cache[options.filename] = compile(str, options)); + } else { + throw new Error('"cache" option requires "filename".'); + } + } else { + fn = compile(str, options); + } + + options.__proto__ = options.locals; + return fn.call(options.scope, options); +}; + +/** + * Render an EJS file at the given `path` and callback `fn(err, str)`. + * + * @param {String} path + * @param {Object|Function} options or callback + * @param {Function} fn + * @api public + */ + +exports.renderFile = function(path, options, fn){ + var key = path + ':string'; + + if ('function' == typeof options) { + fn = options, options = {}; + } + + options.filename = path; + + var str; + try { + str = options.cache + ? cache[key] || (cache[key] = read(path, 'utf8')) + : read(path, 'utf8'); + } catch (err) { + fn(err); + return; + } + fn(null, exports.render(str, options)); +}; + +/** + * Resolve include `name` relative to `filename`. + * + * @param {String} name + * @param {String} filename + * @return {String} + * @api private + */ + +function resolveInclude(name, filename) { + var path = join(dirname(filename), name); + var ext = extname(name); + if (!ext) path += '.ejs'; + return path; +} + +// express support + +exports.__express = exports.renderFile; + +/** + * Expose to require(). + */ + +if (require.extensions) { + require.extensions['.ejs'] = function (module, filename) { + filename = filename || module.filename; + var options = { filename: filename, client: true } + , template = fs.readFileSync(filename).toString() + , fn = compile(template, options); + module._compile('module.exports = ' + fn.toString() + ';', filename); + }; +} else if (require.registerExtension) { + require.registerExtension('.ejs', function(src) { + return compile(src, {}); + }); +} + +},{"./filters":7,"./utils":8,"fs":2,"path":3}],7:[function(require,module,exports){ +/*! + * EJS - Filters + * Copyright(c) 2010 TJ Holowaychuk + * MIT Licensed + */ + +/** + * First element of the target `obj`. + */ + +exports.first = function(obj) { + return obj[0]; +}; + +/** + * Last element of the target `obj`. + */ + +exports.last = function(obj) { + return obj[obj.length - 1]; +}; + +/** + * Capitalize the first letter of the target `str`. + */ + +exports.capitalize = function(str){ + str = String(str); + return str[0].toUpperCase() + str.substr(1, str.length); +}; + +/** + * Downcase the target `str`. + */ + +exports.downcase = function(str){ + return String(str).toLowerCase(); +}; + +/** + * Uppercase the target `str`. + */ + +exports.upcase = function(str){ + return String(str).toUpperCase(); +}; + +/** + * Sort the target `obj`. + */ + +exports.sort = function(obj){ + return Object.create(obj).sort(); +}; + +/** + * Sort the target `obj` by the given `prop` ascending. + */ + +exports.sort_by = function(obj, prop){ + return Object.create(obj).sort(function(a, b){ + a = a[prop], b = b[prop]; + if (a > b) return 1; + if (a < b) return -1; + return 0; + }); +}; + +/** + * Size or length of the target `obj`. + */ + +exports.size = exports.length = function(obj) { + return obj.length; +}; + +/** + * Add `a` and `b`. + */ + +exports.plus = function(a, b){ + return Number(a) + Number(b); +}; + +/** + * Subtract `b` from `a`. + */ + +exports.minus = function(a, b){ + return Number(a) - Number(b); +}; + +/** + * Multiply `a` by `b`. + */ + +exports.times = function(a, b){ + return Number(a) * Number(b); +}; + +/** + * Divide `a` by `b`. + */ + +exports.divided_by = function(a, b){ + return Number(a) / Number(b); +}; + +/** + * Join `obj` with the given `str`. + */ + +exports.join = function(obj, str){ + return obj.join(str || ', '); +}; + +/** + * Truncate `str` to `len`. + */ + +exports.truncate = function(str, len, append){ + str = String(str); + if (str.length > len) { + str = str.slice(0, len); + if (append) str += append; + } + return str; +}; + +/** + * Truncate `str` to `n` words. + */ + +exports.truncate_words = function(str, n){ + var str = String(str) + , words = str.split(/ +/); + return words.slice(0, n).join(' '); +}; + +/** + * Replace `pattern` with `substitution` in `str`. + */ + +exports.replace = function(str, pattern, substitution){ + return String(str).replace(pattern, substitution || ''); +}; + +/** + * Prepend `val` to `obj`. + */ + +exports.prepend = function(obj, val){ + return Array.isArray(obj) + ? [val].concat(obj) + : val + obj; +}; + +/** + * Append `val` to `obj`. + */ + +exports.append = function(obj, val){ + return Array.isArray(obj) + ? obj.concat(val) + : obj + val; +}; + +/** + * Map the given `prop`. + */ + +exports.map = function(arr, prop){ + return arr.map(function(obj){ + return obj[prop]; + }); +}; + +/** + * Reverse the given `obj`. + */ + +exports.reverse = function(obj){ + return Array.isArray(obj) + ? obj.reverse() + : String(obj).split('').reverse().join(''); +}; + +/** + * Get `prop` of the given `obj`. + */ + +exports.get = function(obj, prop){ + return obj[prop]; +}; + +/** + * Packs the given `obj` into json string + */ +exports.json = function(obj){ + return JSON.stringify(obj); +}; + +},{}],8:[function(require,module,exports){ + +/*! + * EJS + * Copyright(c) 2010 TJ Holowaychuk + * MIT Licensed + */ + +/** + * Escape the given string of `html`. + * + * @param {String} html + * @return {String} + * @api private + */ + +exports.escape = function(html){ + return String(html) + .replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') + .replace(//g, '>') + .replace(/'/g, ''') + .replace(/"/g, '"'); +}; + + +},{}],9:[function(require,module,exports){ +'use strict'; + + +var Product = require('./product'), + Pubsub = require('./util/pubsub'), + Storage = require('./util/storage'), + constants = require('./constants'), + currency = require('./util/currency'), + mixin = require('./util/mixin'); + + + +/** + * Renders the Mini Cart to the page's DOM. + * + * @constructor + * @param {string} name Name of the cart (used as a key for storage) + * @param {duration} number Time in milliseconds that the cart data should persist + */ +function Cart(name, duration) { + var data, items, settings, len, i; + + this._items = []; + this._settings = { bn: constants.BN }; + + Pubsub.call(this); + Storage.call(this, name, duration); + + if ((data = this.load())) { + items = data.items; + settings = data.settings; + + if (settings) { + this._settings = settings; + } + + if (items) { + for (i = 0, len = items.length; i < len; i++) { + this.add(items[i]); + } + } + } +} + + +mixin(Cart.prototype, Pubsub.prototype); +mixin(Cart.prototype, Storage.prototype); + + +/** + * Adds an item to the cart. This fires an "add" event. + * + * @param {object} data Item data + * @return {number} Item location in the cart + */ +Cart.prototype.add = function add(data) { + var that = this, + items = this.items(), + idx = false, + isExisting = false, + product, key, len, i; + + // Prune cart settings data from the product + for (key in data) { + if (constants.SETTINGS.test(key)) { + this._settings[key] = data[key]; + delete data[key]; + } + } + + // Look to see if the same product has already been added + for (i = 0, len = items.length; i < len; i++) { + if (items[i].isEqual(data)) { + product = items[i]; + product.set('quantity', product.get('quantity') + (parseInt(data.quantity, 10) || 1)); + idx = i; + isExisting = true; + break; + } + } + + // If not, then try to add it + if (!product) { + product = new Product(data); + + if (product.isValid()) { + idx = (this._items.push(product) - 1); + + product.on('change', function (key, value) { + that.save(); + that.fire('change', idx, key, value); + }); + + this.save(); + } + } + + if (product) { + this.fire('add', idx, product, isExisting); + } + + return idx; +}; + + +/** + * Returns the carts current items. + * + * @param {number} idx (Optional) Returns only that item. + * @return {array|object} + */ +Cart.prototype.items = function get(idx) { + return (typeof idx === 'number') ? this._items[idx] : this._items; +}; + + +/** + * Returns the carts current settings. + * + * @param {string} name (Optional) Returns only that setting. + * @return {array|string} + */ +Cart.prototype.settings = function settings(name) { + return (name) ? this._settings[name] : this._settings; +}; + + +/** + * Returns the cart discount. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Cart.prototype.discount = function discount(config) { + var result = parseFloat(this.settings('discount_amount_cart')) || 0; + + if (!result) { + result = (parseFloat(this.settings('discount_rate_cart')) || 0) * this.subtotal() / 100; + } + + config = config || {}; + config.currency = this.settings('currency_code'); + + return currency(result, config); +}; + + +/** + * Returns the cart total without discounts. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Cart.prototype.subtotal = function subtotal(config) { + var products = this.items(), + result = 0, + i, len; + + for (i = 0, len = products.length; i < len; i++) { + result += products[i].total(); + } + + config = config || {}; + config.currency = this.settings('currency_code'); + + return currency(result, config); +}; + + +/** + * Returns the cart total. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Cart.prototype.total = function total(config) { + var result = 0; + + result += this.subtotal(); + result -= this.discount(); + + config = config || {}; + config.currency = this.settings('currency_code'); + + return currency(result, config); +}; + + +/** + * Remove an item from the cart. This fires a "remove" event. + * + * @param {number} idx Item index to remove. + * @return {boolean} + */ +Cart.prototype.remove = function remove(idx) { + var item = this._items.splice(idx, 1); + + if (this._items.length === 0) { + this.destroy(); + } + + if (item) { + this.save(); + this.fire('remove', idx, item[0]); + } + + return !!item.length; +}; + + +/** + * Saves the cart data. + */ +Cart.prototype.save = function save() { + var items = this.items(), + settings = this.settings(), + data = [], + i, len; + + for (i = 0, len = items.length; i < len; i++) { + data.push(items[i].get()); + } + + Storage.prototype.save.call(this, { + items: data, + settings: settings + }); +}; + + +/** + * Proxies the checkout event + * The assumption is the view triggers this and consumers subscribe to it + * + * @param {object} The initiating event + */ +Cart.prototype.checkout = function checkout(evt) { + this.fire('checkout', evt); +}; + + +/** + * Destroy the cart data. This fires a "destroy" event. + */ +Cart.prototype.destroy = function destroy() { + Storage.prototype.destroy.call(this); + + this._items = []; + this._settings = { bn: constants.BN }; + + this.fire('destroy'); +}; + + + + +module.exports = Cart; + +},{"./constants":11,"./product":13,"./util/currency":15,"./util/mixin":18,"./util/pubsub":19,"./util/storage":20}],10:[function(require,module,exports){ +'use strict'; + + +var mixin = require('./util/mixin'); + + +var defaults = module.exports = { + + name: 'PPMiniCart', + + parent: (typeof document !== 'undefined') ? document.body : null, + + action: 'https://www.paypal.com/cgi-bin/webscr', + + target: '', + + duration: 30, + + template: '<%var items = cart.items();var settings = cart.settings();var hasItems = !!items.length;var priceFormat = { format: true, currency: cart.settings("currency_code") };var totalFormat = { format: true, showCode: true };%>
    <% for (var i= 0, idx = i + 1, len = items.length; i < len; i++, idx++) { %>
  • "><%= items[i].get("item_name") %>
      <% if (items[i].get("item_number")) { %>
    • <%= items[i].get("item_number") %> " />
    • <% } %> <% if (items[i].discount()) { %>
    • <%= config.strings.discount %> <%= items[i].discount(priceFormat) %>
    • <% } %> <% for (var options = items[i].options(), j = 0, len2 = options.length; j < len2; j++) { %>
    • <%= options[j].key %>: <%= options[j].value %>
    • <% } %>
    " autocomplete="off" />
    <%= items[i].total(priceFormat) %>
    " /> " /> " />
  • <% } %>
<% for (var key in settings) { %> <% } %>
', + + styles: '@keyframes pop-in { 0% { opacity: 0; transform: scale(0.1); } 60% { opacity: 1; transform: scale(1.2); } 100% { transform: scale(1); }}@-webkit-keyframes pop-in { 0% { opacity: 0; -webkit-transform: scale(0.1); } 60% { opacity: 1; -webkit-transform: scale(1.2); } 100% { -webkit-transform: scale(1); }}@-moz-keyframes pop-in { 0% { opacity: 0; -moz-transform: scale(0.1); } 60% { opacity: 1; -moz-transform: scale(1.2); } 100% { -moz-transform: scale(1); }}.minicart-showing #PPMiniCart { display: block; transform: translateZ(0); -webkit-transform: translateZ(0); -moz-transform: translateZ(0); animation: pop-in 0.25s; -webkit-animation: pop-in 0.25s; -moz-animation: pop-in 0.25s;}#PPMiniCart { display: none; position: fixed; left: 50%; top: 75px;}#PPMiniCart form { position: relative; width: 400px; max-height: 400px; margin-left: -200px; padding: 10px 10px 40px; background: #fbfbfb; border: 1px solid #d7d7d7; border-radius: 4px; box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5); font: 15px/normal arial, helvetica; color: #333;}#PPMiniCart form.minicart-empty { padding-bottom: 10px; font-size: 16px; font-weight: bold;}#PPMiniCart ul { clear: both; float: left; width: 380px; margin: 5px 0 20px; padding: 10px; list-style-type: none; background: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);}#PPMiniCart .minicart-empty ul { display: none;}#PPMiniCart .minicart-closer { float: right; margin: -12px -10px 0; padding: 10px; background: 0; border: 0; font-size: 18px; cursor: pointer; font-weight: bold;}#PPMiniCart .minicart-item { clear: left; padding: 6px 0; min-height: 25px;}#PPMiniCart .minicart-item + .minicart-item { border-top: 1px solid #f2f2f2;}#PPMiniCart .minicart-item a { color: #333; text-decoration: none;}#PPMiniCart .minicart-details-name { float: left; width: 62%;}#PPMiniCart .minicart-details-quantity { float: left; width: 15%;}#PPMiniCart .minicart-details-remove { float: left; width: 7%;}#PPMiniCart .minicart-details-price { float: left; width: 16%; text-align: right;}#PPMiniCart .minicart-attributes { margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none; color: #999; font-size: 12px; line-height: 22px;}#PPMiniCart .minicart-attributes li { display: inline;}#PPMiniCart .minicart-attributes li:after { content: ",";}#PPMiniCart .minicart-attributes li:last-child:after { content: "";}#PPMiniCart .minicart-quantity { width: 30px; height: 18px; padding: 2px 4px; border: 1px solid #ccc; border-radius: 4px; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); font-size: 13px; text-align: right; transition: border linear 0.2s, box-shadow linear 0.2s; -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; -moz-transition: border linear 0.2s, box-shadow linear 0.2s;}#PPMiniCart .minicart-quantity:hover { border-color: #0078C1;}#PPMiniCart .minicart-quantity:focus { border-color: #0078C1; outline: 0; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 3px rgba(0, 120, 193, 0.4);}#PPMiniCart .minicart-remove { width: 18px; height: 19px; margin: 2px 0 0; padding: 0; background: #b7b7b7; border: 1px solid #a3a3a3; border-radius: 3px; color: #fff; font-size: 13px; opacity: 0.70; cursor: pointer;}#PPMiniCart .minicart-remove:hover { opacity: 1;}#PPMiniCart .minicart-footer { clear: left;}#PPMiniCart .minicart-subtotal { position: absolute; bottom: 17px; padding-left: 6px; left: 10px; font-size: 16px; font-weight: bold;}#PPMiniCart .minicart-submit { position: absolute; bottom: 10px; right: 10px; min-width: 153px; height: 33px; margin-right: 6px; padding: 0 9px; border: 1px solid #ffc727; border-radius: 5px; color: #000; text-shadow: 1px 1px 1px #fff6e9; cursor: pointer; background: #ffaa00; background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZjZlOSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmFhMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top, #fff6e9 0%, #ffaa00 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fff6e9), color-stop(100%,#ffaa00)); background: -webkit-linear-gradient(top, #fff6e9 0%,#ffaa00 100%); background: -o-linear-gradient(top, #fff6e9 0%,#ffaa00 100%); background: -ms-linear-gradient(top, #fff6e9 0%,#ffaa00 100%); background: linear-gradient(to bottom, #fff6e9 0%,#ffaa00 100%);}#PPMiniCart .minicart-submit img { vertical-align: middle; padding: 4px 0 0 2px;}', + + strings: { + button: 'Check Out with PayPal', + subtotal: 'Subtotal:', + discount: 'Discount:', + empty: 'Your shopping cart is empty' + } + +}; + + +/** + * Mixes in the user config with the default config. + * + * @param {object} userConfig Configuration overrides + * @return {object} + */ +module.exports.load = function load(userConfig) { + return mixin(defaults, userConfig); +}; + +},{"./util/mixin":18}],11:[function(require,module,exports){ +'use strict'; + + +module.exports = { + + COMMANDS: { _cart: true, _xclick: true, _donations: true }, + + SETTINGS: /^(?:business|currency_code|lc|paymentaction|no_shipping|cn|no_note|invoice|handling_cart|weight_cart|weight_unit|tax_cart|discount_amount_cart|discount_rate_cart|page_style|image_url|cpp_|cs|cbt|return|cancel_return|notify_url|rm|custom|charset)/, + + BN: 'MiniCart_AddToCart_WPS_US', + + KEYUP_TIMEOUT: 500, + + SHOWING_CLASS: 'minicart-showing', + + REMOVE_CLASS: 'minicart-remove', + + CLOSER_CLASS: 'minicart-closer', + + QUANTITY_CLASS: 'minicart-quantity', + + ITEM_CLASS: 'minicart-item', + + ITEM_CHANGED_CLASS: 'minicart-item-changed', + + SUBMIT_CLASS: 'minicart-submit', + + DATA_IDX: 'data-minicart-idx' + +}; + +},{}],12:[function(require,module,exports){ +'use strict'; + + +var Cart = require('./cart'), + View = require('./view'), + config = require('./config'), + minicart = {}, + cartModel, + confModel, + viewModel; + + +/** + * Renders the Mini Cart to the page's DOM. + * + * @param {object} userConfig Configuration overrides + */ +minicart.render = function (userConfig) { + confModel = minicart.config = config.load(userConfig); + cartModel = minicart.cart = new Cart(confModel.name, confModel.duration); + viewModel = minicart.view = new View({ + config: confModel, + cart: cartModel + }); + + cartModel.on('add', viewModel.addItem, viewModel); + cartModel.on('change', viewModel.changeItem, viewModel); + cartModel.on('remove', viewModel.removeItem, viewModel); + cartModel.on('destroy', viewModel.hide, viewModel); +}; + + +/** + * Resets the Mini Cart and its view model + */ +minicart.reset = function () { + cartModel.destroy(); + + viewModel.hide(); + viewModel.redraw(); +}; + + + + +// Export to either node or the brower window +if (typeof window === 'undefined') { + module.exports = minicart; +} else { + if (!window.paypal) { + window.paypal = {}; + } + + window.paypal.minicart = minicart; +} + +},{"./cart":9,"./config":10,"./view":22}],13:[function(require,module,exports){ +'use strict'; + + +var currency = require('./util/currency'), + Pubsub = require('./util/pubsub'), + mixin = require('./util/mixin'); + + +var parser = { + quantity: function (value) { + value = parseInt(value, 10); + + if (isNaN(value) || !value) { + value = 1; + } + + return value; + }, + amount: function (value) { + return parseFloat(value) || 0; + }, + href: function (value) { + if (value) { + return value; + } else { + return (typeof window !== 'undefined') ? window.location.href : null; + } + } +}; + + +/** + * Creates a new product. + * + * @constructor + * @param {object} data Item data + */ +function Product(data) { + data.quantity = parser.quantity(data.quantity); + data.amount = parser.amount(data.amount); + data.href = parser.href(data.href); + + this._data = data; + this._options = null; + this._discount = null; + this._amount = null; + this._total = null; + + Pubsub.call(this); +} + + +mixin(Product.prototype, Pubsub.prototype); + + +/** + * Gets the product data. + * + * @param {string} key (Optional) A key to restrict the returned data to. + * @return {array|string} + */ +Product.prototype.get = function get(key) { + return (key) ? this._data[key] : this._data; +}; + + +/** + * Sets a value on the product. This is used rather than manually setting the + * value so that we can fire a "change" event. + * + * @param {string} key + * @param {string} value + */ +Product.prototype.set = function set(key, value) { + var setter = parser[key]; + + this._data[key] = setter ? setter(value) : value; + this._options = null; + this._discount = null; + this._amount = null; + this._total = null; + + this.fire('change', key); +}; + + +/** + * Parse and return the options for this product. + * + * @return {object} + */ +Product.prototype.options = function options() { + var result, key, value, amount, i, j; + + if (!this._options) { + result = []; + i = 0; + + while ((key = this.get('on' + i))) { + value = this.get('os' + i); + amount = 0; + j = 0; + + while (typeof this.get('option_select' + j) !== 'undefined') { + if (this.get('option_select' + j) === value) { + amount = parser.amount(this.get('option_amount' + j)); + break; + } + + j++; + } + + result.push({ + key: key, + value: value, + amount: amount + }); + + i++; + } + + this._options = result; + } + + return this._options; +}; + + +/** + * Parse and return the discount for this product. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Product.prototype.discount = function discount(config) { + var flat, rate, num, limit, result, amount; + + if (!this._discount) { + result = 0; + num = parseInt(this.get('discount_num'), 10) || 0; + limit = Math.max(num, this.get('quantity') - 1); + + if (this.get('discount_amount') !== undefined) { + flat = parser.amount(this.get('discount_amount')); + result += flat; + result += parser.amount(this.get('discount_amount2') || flat) * limit; + } else if (this.get('discount_rate') !== undefined) { + rate = parser.amount(this.get('discount_rate')); + amount = this.amount(); + + result += rate * amount / 100; + result += parser.amount(this.get('discount_rate2') || rate) * amount * limit / 100; + } + + this._discount = result; + } + + return currency(this._discount, config); +}; + + +/** + * Parse and return the total without discounts for this product. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Product.prototype.amount = function amount(config) { + var result, options, len, i; + + if (!this._amount) { + result = this.get('amount'); + options = this.options(); + + for (i = 0, len = options.length; i < len; i++) { + result += options[i].amount; + } + + this._amount = result; + } + + return currency(this._amount, config); +}; + + +/** + * Parse and return the total for this product. + * + * @param {object} config (Optional) Currency formatting options. + * @return {number|string} + */ +Product.prototype.total = function total(config) { + var result; + + if (!this._total) { + result = this.get('quantity') * this.amount(); + result -= this.discount(); + + this._total = parser.amount(result); + } + + return currency(this._total, config); +}; + + +/** + * Determine if this product has the same data as another. + * + * @param {object|Product} data Other product. + * @return {boolean} + */ +Product.prototype.isEqual = function isEqual(data) { + var match = false; + + if (data instanceof Product) { + data = data._data; + } + + if (this.get('item_name') === data.item_name) { + if (this.get('item_number') === data.item_number) { + if (this.get('amount') === parser.amount(data.amount)) { + var i = 0; + + match = true; + + while (typeof data['os' + i] !== 'undefined') { + if (this.get('os' + i) !== data['os' + i]) { + match = false; + break; + } + + i++; + } + } + } + } + + return match; +}; + + +/** + * Determine if this product is valid. + * + * @return {boolean} + */ +Product.prototype.isValid = function isValid() { + return (this.get('item_name') && this.amount() > 0); +}; + + +/** + * Destroys this product. Fires a "destroy" event. + */ +Product.prototype.destroy = function destroy() { + this._data = []; + this.fire('destroy', this); +}; + + + + +module.exports = Product; + +},{"./util/currency":15,"./util/mixin":18,"./util/pubsub":19}],14:[function(require,module,exports){ +/* jshint quotmark:double */ + + +"use strict"; + + + +module.exports.add = function add(el, str) { + var re; + + if (!el) { return false; } + + if (el && el.classList && el.classList.add) { + el.classList.add(str); + } else { + re = new RegExp("\\b" + str + "\\b"); + + if (!re.test(el.className)) { + el.className += " " + str; + } + } +}; + + +module.exports.remove = function remove(el, str) { + var re; + + if (!el) { return false; } + + if (el.classList && el.classList.add) { + el.classList.remove(str); + } else { + re = new RegExp("\\b" + str + "\\b"); + + if (re.test(el.className)) { + el.className = el.className.replace(re, ""); + } + } +}; + + +module.exports.inject = function inject(el, str) { + var style; + + if (!el) { return false; } + + if (str) { + style = document.createElement("style"); + style.type = "text/css"; + + if (style.styleSheet) { + style.styleSheet.cssText = str; + } else { + style.appendChild(document.createTextNode(str)); + } + + el.appendChild(style); + } +}; + +},{}],15:[function(require,module,exports){ +'use strict'; + + +var currencies = { + AED: { before: '\u062c' }, + ANG: { before: '\u0192' }, + ARS: { before: '$', code: true }, + AUD: { before: '$', code: true }, + AWG: { before: '\u0192' }, + BBD: { before: '$', code: true }, + BGN: { before: '\u043b\u0432' }, + BMD: { before: '$', code: true }, + BND: { before: '$', code: true }, + BRL: { before: 'R$' }, + BSD: { before: '$', code: true }, + CAD: { before: '$', code: true }, + CHF: { before: '', code: true }, + CLP: { before: '$', code: true }, + CNY: { before: '\u00A5' }, + COP: { before: '$', code: true }, + CRC: { before: '\u20A1' }, + CZK: { before: 'Kc' }, + DKK: { before: 'kr' }, + DOP: { before: '$', code: true }, + EEK: { before: 'kr' }, + EUR: { before: '\u20AC' }, + GBP: { before: '\u00A3' }, + GTQ: { before: 'Q' }, + HKD: { before: '$', code: true }, + HRK: { before: 'kn' }, + HUF: { before: 'Ft' }, + IDR: { before: 'Rp' }, + ILS: { before: '\u20AA' }, + INR: { before: 'Rs.' }, + ISK: { before: 'kr' }, + JMD: { before: 'J$' }, + JPY: { before: '\u00A5' }, + KRW: { before: '\u20A9' }, + KYD: { before: '$', code: true }, + LTL: { before: 'Lt' }, + LVL: { before: 'Ls' }, + MXN: { before: '$', code: true }, + MYR: { before: 'RM' }, + NOK: { before: 'kr' }, + NZD: { before: '$', code: true }, + PEN: { before: 'S/' }, + PHP: { before: 'Php' }, + PLN: { before: 'z' }, + QAR: { before: '\ufdfc' }, + RON: { before: 'lei' }, + RUB: { before: '\u0440\u0443\u0431' }, + SAR: { before: '\ufdfc' }, + SEK: { before: 'kr' }, + SGD: { before: '$', code: true }, + THB: { before: '\u0E3F' }, + TRY: { before: 'TL' }, + TTD: { before: 'TT$' }, + TWD: { before: 'NT$' }, + UAH: { before: '\u20b4' }, + USD: { before: '$', code: true }, + UYU: { before: '$U' }, + VEF: { before: 'Bs' }, + VND: { before: '\u20ab' }, + XCD: { before: '$', code: true }, + ZAR: { before: 'R' } +}; + + +module.exports = function currency(amount, config) { + var code = config && config.currency || 'USD', + value = currencies[code], + before = value.before || '', + after = value.after || '', + length = value.length || 2, + showCode = value.code && config && config.showCode, + result = amount; + + if (config && config.format) { + result = before + result.toFixed(length) + after; + } + + if (showCode) { + result += ' ' + code; + } + + return result; +}; + +},{}],16:[function(require,module,exports){ +'use strict'; + + +module.exports = (function (window, document) { + + /** + * Events are added here for easy reference + */ + var cache = []; + + // NOOP for Node + if (!document) { + return { + add: function () {}, + remove: function () {} + }; + // Non-IE events + } else if (document.addEventListener) { + return { + /** + * Add an event to an object and optionally adjust it's scope + * + * @param obj {HTMLElement} The object to attach the event to + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + * @param scope {object} Object to adjust the scope to (optional) + */ + add: function (obj, type, fn, scope) { + scope = scope || obj; + + var wrappedFn = function (e) { fn.call(scope, e); }; + + obj.addEventListener(type, wrappedFn, false); + cache.push([obj, type, fn, wrappedFn]); + }, + + + /** + * Remove an event from an object + * + * @param obj {HTMLElement} The object to remove the event from + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + */ + remove: function (obj, type, fn) { + var wrappedFn, item, len = cache.length, i; + + for (i = 0; i < len; i++) { + item = cache[i]; + + if (item[0] === obj && item[1] === type && item[2] === fn) { + wrappedFn = item[3]; + + if (wrappedFn) { + obj.removeEventListener(type, wrappedFn, false); + cache = cache.slice(i); + return true; + } + } + } + } + }; + + // IE events + } else if (document.attachEvent) { + return { + /** + * Add an event to an object and optionally adjust it's scope (IE) + * + * @param obj {HTMLElement} The object to attach the event to + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + * @param scope {object} Object to adjust the scope to (optional) + */ + add: function (obj, type, fn, scope) { + scope = scope || obj; + + var wrappedFn = function () { + var e = window.event; + e.target = e.target || e.srcElement; + + e.preventDefault = function () { + e.returnValue = false; + }; + + fn.call(scope, e); + }; + + obj.attachEvent('on' + type, wrappedFn); + cache.push([obj, type, fn, wrappedFn]); + }, + + + /** + * Remove an event from an object (IE) + * + * @param obj {HTMLElement} The object to remove the event from + * @param type {string} The type of event excluding "on" + * @param fn {function} The function + */ + remove: function (obj, type, fn) { + var wrappedFn, item, len = cache.length, i; + + for (i = 0; i < len; i++) { + item = cache[i]; + + if (item[0] === obj && item[1] === type && item[2] === fn) { + wrappedFn = item[3]; + + if (wrappedFn) { + obj.detachEvent('on' + type, wrappedFn); + cache = cache.slice(i); + return true; + } + } + } + } + }; + } + +})(typeof window === 'undefined' ? null : window, typeof document === 'undefined' ? null : document); + +},{}],17:[function(require,module,exports){ +'use strict'; + + +var forms = module.exports = { + + parse: function parse(form) { + var raw = form.elements, + data = {}, + pair, value, i, len; + + for (i = 0, len = raw.length; i < len; i++) { + pair = raw[i]; + + if ((value = forms.getInputValue(pair))) { + data[pair.name] = value; + } + } + + return data; + }, + + + getInputValue: function getInputValue(input) { + var tag = input.tagName.toLowerCase(); + + if (tag === 'select') { + return input.options[input.selectedIndex].value; + } else if (tag === 'textarea') { + return input.innerText; + } else { + if (input.type === 'radio') { + return (input.checked) ? input.value : null; + } else if (input.type === 'checkbox') { + return (input.checked) ? input.value : null; + } else { + return input.value; + } + } + } + +}; +},{}],18:[function(require,module,exports){ +'use strict'; + + +var mixin = module.exports = function mixin(dest, source) { + var value; + + for (var key in source) { + value = source[key]; + + if (value && value.constructor === Object) { + if (!dest[key]) { + dest[key] = value; + } else { + mixin(dest[key] || {}, value); + } + } else { + dest[key] = value; + } + } + + return dest; +}; + +},{}],19:[function(require,module,exports){ +'use strict'; + + +function Pubsub() { + this._eventCache = {}; +} + + +Pubsub.prototype.on = function on(name, fn, scope) { + var cache = this._eventCache[name]; + + if (!cache) { + cache = this._eventCache[name] = []; + } + + cache.push([fn, scope]); +}; + + +Pubsub.prototype.off = function off(name, fn) { + var cache = this._eventCache[name], + i, len; + + if (cache) { + for (i = 0, len = cache.length; i < len; i++) { + if (cache[i] === fn) { + cache = cache.splice(i, 1); + } + } + } +}; + + +Pubsub.prototype.fire = function on(name) { + var cache = this._eventCache[name], i, len, fn, scope; + + if (cache) { + for (i = 0, len = cache.length; i < len; i++) { + fn = cache[i][0]; + scope = cache[i][1] || this; + + if (typeof fn === 'function') { + fn.apply(scope, Array.prototype.slice.call(arguments, 1)); + } + } + } +}; + + +module.exports = Pubsub; + +},{}],20:[function(require,module,exports){ +'use strict'; + + +var Storage = module.exports = function Storage(name, duration) { + this._name = name; + this._duration = duration || 30; +}; + + +var proto = Storage.prototype; + + +proto.load = function () { + if (typeof window === 'object' && window.localStorage) { + var data = window.localStorage.getItem(this._name), today, expires; + + if (data) { + data = JSON.parse(decodeURIComponent(data)); + } + + if (data && data.expires) { + today = new Date(); + expires = new Date(data.expires); + + if (today > expires) { + this.destroy(); + return; + } + } + + return data && data.value; + } +}; + + +proto.save = function (data) { + if (typeof window === 'object' && window.localStorage) { + var expires = new Date(), wrapped; + + expires.setTime(expires.getTime() + this._duration * 24 * 60 * 60 * 1000); + + wrapped = { + value: data, + expires: expires.toGMTString() + }; + + window.localStorage.setItem(this._name, encodeURIComponent(JSON.stringify(wrapped))); + } +}; + + +proto.destroy = function () { + if (typeof window === 'object' && window.localStorage) { + window.localStorage.removeItem(this._name); + } +}; + +},{}],21:[function(require,module,exports){ +'use strict'; + + +var ejs = require('ejs'); + + +module.exports = function template(str, data) { + return ejs.render(str, data); +}; + + +// Workaround for IE 8's lack of support +if (!String.prototype.trim) { + String.prototype.trim = function () { + return this.replace(/^\s+|\s+$/g, ''); + }; +} + +},{"ejs":6}],22:[function(require,module,exports){ +'use strict'; + + +var config = require('./config'), + events = require('./util/events'), + template = require('./util/template'), + forms = require('./util/forms'), + css = require('./util/css'), + viewevents = require('./viewevents'), + constants = require('./constants'); + + + +/** + * Creates a view model. + * + * @constructor + * @param {object} model + */ +function View(model) { + var wrapper; + + this.el = wrapper = document.createElement('div'); + this.model = model; + this.isShowing = false; + + // HTML + wrapper.id = config.name; + config.parent.appendChild(wrapper); + + // CSS + css.inject(document.getElementsByTagName('head')[0], config.styles); + + // JavaScript + events.add(document, ('ontouchstart' in window) ? 'touchstart' : 'click', viewevents.click, this); + events.add(document, 'keyup', viewevents.keyup, this); + events.add(document, 'readystatechange', viewevents.readystatechange, this); + events.add(window, 'pageshow', viewevents.pageshow, this); +} + + +/** + * Tells the view to redraw + */ +View.prototype.redraw = function redraw() { + events.remove(this.el.querySelector('form'), 'submit', this.model.cart.checkout, this.model.cart); + this.el.innerHTML = template(config.template, this.model); + events.add(this.el.querySelector('form'), 'submit', this.model.cart.checkout, this.model.cart); +}; + + +/** + * Tells the view to show + */ +View.prototype.show = function show() { + if (!this.isShowing) { + css.add(document.body, constants.SHOWING_CLASS); + this.isShowing = true; + } +}; + + +/** + * Tells the view to hide + */ +View.prototype.hide = function hide() { + if (this.isShowing) { + css.remove(document.body, constants.SHOWING_CLASS); + this.isShowing = false; + } +}; + + +/** + * Toggles the visibility of the view + */ +View.prototype.toggle = function toggle() { + this[this.isShowing ? 'hide' : 'show'](); +}; + + +/** + * Binds cart submit events to a form. + * + * @param {HTMLElement} form + * @return {boolean} + */ +View.prototype.bind = function bind(form) { + var that = this; + + // Don't bind forms without a cmd value + if (!constants.COMMANDS[form.cmd.value]) { + return false; + } + + // Prevent re-binding forms + if (form.hasMinicart) { + return false; + } else { + form.hasMinicart = true; + } + + if (form.display) { + events.add(form, 'submit', function (e) { + e.preventDefault(); + that.show(); + }); + } else { + events.add(form, 'submit', function (e) { + e.preventDefault(e); + that.model.cart.add(forms.parse(form)); + }); + } + + return true; +}; + + +/** + * Adds an item to the view. + * + * @param {number} idx + * @param {object} data + */ +View.prototype.addItem = function addItem(idx, data) { + this.redraw(); + this.show(); + + var els = this.el.querySelectorAll('.' + constants.ITEM_CLASS); + css.add(els[idx], constants.ITEM_CHANGED_CLASS); +}; + + +/** + * Changes an item in the view. + * + * @param {number} idx + * @param {object} data + */ +View.prototype.changeItem = function changeItem(idx, data) { + this.redraw(); + this.show(); + + var els = this.el.querySelectorAll('.' + constants.ITEM_CLASS); + css.add(els[idx], constants.ITEM_CHANGED_CLASS); +}; + + +/** + * Removes an item from the view. + * + * @param {number} idx + */ +View.prototype.removeItem = function removeItem(idx) { + this.redraw(); +}; + + + + +module.exports = View; + +},{"./config":10,"./constants":11,"./util/css":14,"./util/events":16,"./util/forms":17,"./util/template":21,"./viewevents":23}],23:[function(require,module,exports){ +'use strict'; + + +var constants = require('./constants'), + events = require('./util/events'), + viewevents; + + +module.exports = viewevents = { + + click: function (evt) { + var target = evt.target, + className = target.className; + + if (this.isShowing) { + // Cart close button + if (className === constants.CLOSER_CLASS) { + this.hide(); + // Product remove button + } else if (className === constants.REMOVE_CLASS) { + this.model.cart.remove(target.getAttribute(constants.DATA_IDX)); + // Product quantity input + } else if (className === constants.QUANTITY_CLASS) { + target[target.setSelectionRange ? 'setSelectionRange' : 'select'](0, 999); + // Outside the cart + } else if (!(/input|button|select|option/i.test(target.tagName))) { + while (target.nodeType === 1) { + if (target === this.el) { + return; + } + + target = target.parentNode; + } + + this.hide(); + } + } + }, + + + keyup: function (evt) { + var that = this, + target = evt.target, + timer; + + if (target.className === constants.QUANTITY_CLASS) { + timer = setTimeout(function () { + var idx = parseInt(target.getAttribute(constants.DATA_IDX), 10), + cart = that.model.cart, + product = cart.items(idx), + quantity = parseInt(target.value, 10); + + if (product) { + if (quantity > 0) { + product.set('quantity', quantity); + } else if (quantity === 0) { + cart.remove(idx); + } + } + }, constants.KEYUP_TIMEOUT); + } + }, + + + readystatechange: function () { + if (/interactive|complete/.test(document.readyState)) { + var forms, form, i, len; + + // Bind to page's forms + forms = document.getElementsByTagName('form'); + + for (i = 0, len = forms.length; i < len; i++) { + form = forms[i]; + + if (form.cmd && constants.COMMANDS[form.cmd.value]) { + this.bind(form); + } + } + + // Do the initial render when the buttons are ready + this.redraw(); + + // Only run this once + events.remove(document, 'readystatechange', viewevents.readystatechange); + } + }, + + + pageshow: function (evt) { + if (evt.persisted) { + this.redraw(); + this.hide(); + } + } + +}; + +},{"./constants":11,"./util/events":16}]},{},[9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]) +; \ No newline at end of file diff --git a/firebase/js/nuevoproducto.js b/firebase/js/nuevoproducto.js new file mode 100644 index 00000000..151add79 --- /dev/null +++ b/firebase/js/nuevoproducto.js @@ -0,0 +1,99 @@ +$(document).ready(function() { + // Inicializar la base de datos + var config = { + apiKey: 'AIzaSyCA_qTHoFGTVKRvPSAMCajPblhVZJ73Zk0', + authDomain: 'demoapp-30f5d.firebaseapp.com', + databaseURL: 'https://demoapp-30f5d.firebaseio.com', + projectId: 'demoapp-30f5d', + storageBucket: 'demoapp-30f5d.appspot.com', + messagingSenderId: '992985819602' + }; + firebase.initializeApp(config); + + var database = firebase.database(); + + var articulo; + var descripcion; + var precio; + var imagen; + + $('#imagen').change(function() { + var descriptor = new FileReader(); + descriptor.readAsDataURL(this.files[0]); + + descriptor.onloadend = function() { + imagen = descriptor.result; + $('#previsualizacion').attr('src', imagen); + }; + }); + + + $('#formularioAlta').change(function() { + articulo = $('#articulo').val(); + descripcion = $('#descripcion').val(); + precio = $('#precio').val(); + + if (articulo && descripcion && precio) { + $('#botonGuardar').prop('disabled', false); + } else { + $('#botonGuardar').prop('disabled', true); + } + }); + + + $('#botonGuardar').click(function() { + articulo = $('#articulo').val(); + descripcion = $('#descripcion').val(); + precio = $('#precio').val(); + + if (!imagen) { + imagen = 'NONE'; + } + + // Indicamos que la referencia base de nuestra base de datos es productos (algo así como el padre) + // del que colgarán el resto de nodos hijos. + /* + var usersRef = new Firebase('https://samplechat.firebaseio-demo.com/users'); + var fredRef = usersRef.child('fred'); + var fredFirstNameRef = fredRef.child('name/first'); + */ + var referencia = database.ref('productos'); + + + // De la siguiente forma el método sobreescribe los datos + /* + referencia.set( + { + articulo: articulo, + descripcion: descripcion, + precio: precio, + imagen: imagen + }); + */ + + // Ahora estamos poniendo el articulo como clave en la colección + // De esta manera podremos añadir nuevos articulos o actualizar uno ya existente. + + /* + referencia.child(articulo).set( + { + descripcion: descripcion, + precio: precio, + imagen: imagen + }); + */ + + // Si queremos permitir que hayas artículos con nombres duplicados entonces tendremos + // que decirle a Firebase que utilice otra clave en lugar del nombre del articulo. + // Usaremos el método push en lugar de set + referencia.push( + { + articulo: articulo, + descripcion: descripcion, + precio: precio, + imagen: imagen + }, function() { + alert('El alta se ha realizado correctamente'); + }); + }); +}); \ No newline at end of file diff --git a/firebase/js/paypale.js b/firebase/js/paypale.js new file mode 100644 index 00000000..79c7ad34 --- /dev/null +++ b/firebase/js/paypale.js @@ -0,0 +1,33 @@ +paypal.Button.render({ + + env: 'sandbox', // production Or 'sandbox' + + client: { + sandbox:'AY1QtzdFyi6YiSLpJFr9zIbVT9sXkc6QCEbpHEsiNjw_4H6yP-bpepmTp67jm-ktGyYyQZYk66jfxtX4', + production: 'AT4UP826uklOKEN54x4Q0SHukJklhDWNndFqpt6gRwGxpEEbiYB62pPdcE3npwUsFKd9aHrK5Gf4xV8M' + }, + + commit: true, // Show a 'Pay Now' button + + payment: function(data, actions) { + return actions.payment.create({ + payment: { + transactions: [ + { + amount: { total: '1.00', currency: 'USD' } + + } + ] + } + }); + }, + + onAuthorize: function(data, actions) { + return actions.payment.execute().then(function(payment) { + + // The payment is complete! + // You can now show a confirmation message to the customer + }); + } + +}, '#paypal-button'); \ No newline at end of file diff --git a/firebase/nuevoproducto.html b/firebase/nuevoproducto.html new file mode 100644 index 00000000..27af9556 --- /dev/null +++ b/firebase/nuevoproducto.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + Añadir un producto + + + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +

Elija una imagen para este artículo

+ +
+ +
+
+ + \ No newline at end of file diff --git a/firebase/nuevosproductos.html b/firebase/nuevosproductos.html new file mode 100644 index 00000000..1553e168 --- /dev/null +++ b/firebase/nuevosproductos.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + Gestión de Productos con Firebase + + + +
+

Listado de Productos

+
+ + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..0af67ee0 --- /dev/null +++ b/index.html @@ -0,0 +1,306 @@ + + + + + + eCommerce Site + + + + + + +
+
+
+
+
+ ENVÍO GRATIS en compras sobre $20.000 +
+
+ + Escríbenos + +
+
+
+
+ +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 00000000..e69de29b diff --git a/templates/categorias.html b/templates/categorias.html new file mode 100644 index 00000000..66910fab --- /dev/null +++ b/templates/categorias.html @@ -0,0 +1,68 @@ + + + + + + + Producto + + + +
+
+
+ +
+
+ +
+
+
+

Grumpy Fucker Pillow

+
+
+

$35.000

+
+
+ +
+
+

ENVIO GRATIS

+

sobre $30.000

+
+
+ +
+
+
+
+
+
+
+
+
+
+

Descripción

+
+

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Atque voluptate enim corporis eaque accusamus voluptatem aperiam non labore doloribus laborum? Minus necessitatibus sint temporibus aliquid animi cum, nisi labore voluptate.

+
+
+
+

Más Detalles

+
+

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Atque voluptate enim corporis eaque accusamus voluptatem aperiam.

+
+
+
+
+ + + + + + + + + + + + Home + + + + + + +
+
+
+
+
+
+
+ + +
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/templates/vistaproducto.html b/templates/vistaproducto.html new file mode 100644 index 00000000..df66788a --- /dev/null +++ b/templates/vistaproducto.html @@ -0,0 +1,68 @@ + + + + + + + Producto + + + +
+
+
+ +
+
+ +
+
+
+

Grumpy Fucker Pillow

+
+
+

$35.000

+
+
+ +
+
+

ENVIO GRATIS

+

sobre $30.000

+
+
+ +
+
+
+
+
+
+
+
+
+
+

Descripción

+
+

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Atque voluptate enim corporis eaque accusamus voluptatem aperiam non labore doloribus laborum? Minus necessitatibus sint temporibus aliquid animi cum, nisi labore voluptate.

+
+
+
+

Más Detalles

+
+

Lorem ipsum dolor, sit amet consectetur adipisicing elit. Atque voluptate enim corporis eaque accusamus voluptatem aperiam.

+
+
+
+
+ + + + + + \ No newline at end of file