Commit 7afe6c73 authored by Kevin Stover's avatar Kevin Stover

gulping.

parent e7281cbf
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v3.3.1
// v3.2.0
//
// Copyright (c)2017 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
//
// http://marionettejs.com
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("backbone"),require("underscore"),require("backbone.radio")):"function"==typeof define&&define.amd?define(["backbone","underscore","backbone.radio"],t):e.Marionette=e.Mn=t(e.Backbone,e._,e.Backbone.Radio)}(this,function(e,t,i){"use strict";function n(e,t,i){return i.toUpperCase()}function r(e){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];var s=W(e),o=N.call(this,s),h=void 0;return t.isFunction(o)&&(h=o.apply(this,n)),this.trigger.apply(this,arguments),h}function s(e){for(var i=arguments.length,n=Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return t.isFunction(e.triggerMethod)?e.triggerMethod.apply(e,n):r.apply(e,n)}function o(e,i,n){e._getImmediateChildren&&t.each(e._getImmediateChildren(),function(e){n(e)&&s(e,i,e)})}function h(e){return!e._isAttached}function d(e){return!!h(e)&&(e._isAttached=!0,!0)}function l(e){return e._isAttached}function a(e){return!!l(e)&&(e._isAttached=!1,!0)}function c(e){e._isAttached&&e._isRendered&&s(e,"dom:refresh",e)}function u(e){e._isAttached&&e._isRendered&&s(e,"dom:remove",e)}function f(){o(this,"before:attach",h)}function _(){o(this,"attach",d),c(this)}function p(){o(this,"before:detach",l),u(this)}function g(){o(this,"detach",a)}function v(){u(this)}function m(){c(this)}function w(e){e._areViewEventsMonitored||(e._areViewEventsMonitored=!0,e.on({"before:attach":f,attach:_,"before:detach":p,detach:g,"before:render":v,render:m}))}function y(e,i,n,r,s){var o=r.split(/\s+/);t.each(o,function(t){var r=e[t];if(!r)throw new Z('Method "'+t+'" was configured as an event handler, but does not exist.');e[s](i,n,r)})}function C(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new Z({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindevents"});t.each(n,function(n,s){return t.isString(n)?void y(e,i,s,n,r):void e[r](i,s,n)})}}function V(e,t){return C(this,e,t,"listenTo"),this}function E(e,t){return C(this,e,t,"stopListening"),this}function b(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new Z({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindrequests"});var s=q.call(e,n);i[r](s,e)}}function M(e,t){return b(this,e,t,"reply"),this}function R(e,t){return b(this,e,t,"stopReplying"),this}function B(e,i){return e.behaviorClass?e.behaviorClass:t.isFunction(e)?e:t.isFunction(ke.Behaviors.behaviorsLookup)?ke.Behaviors.behaviorsLookup(e,i)[i]:ke.Behaviors.behaviorsLookup[i]}function x(e,i){return t.chain(i).map(function(i,n){var r=B(i,n),s=i===r?{}:i,o=new r(s,e),h=x(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()}function A(e,i){return[e+t.uniqueId(".evt"),i].join(" ")}function O(e){return!!de[e]}function I(e,t){return de[e]=t}function T(e,i){t.isString(i)&&(i={event:i});var n=i.event,r=!!i.preventDefault;O("triggersPreventDefault")&&(r=i.preventDefault!==!1);var s=!!i.stopPropagation;return O("triggersStopPropagation")&&(s=i.stopPropagation!==!1),function(t){r&&t.preventDefault(),s&&t.stopPropagation(),e.triggerMethod(n,e,t)}}function D(e){e.supportsDestroyLifecycle||s(e,"before:destroy",e);var t=!!e._isAttached;t&&s(e,"before:detach",e),e.remove(),t&&(e._isAttached=!1,s(e,"detach",e)),e._isDestroyed=!0,e.supportsDestroyLifecycle||s(e,"destroy",e)}function U(e,i){var n=t.extend({},i);if(t.isString(e))return t.extend(n,{el:e}),F(n);if(t.isFunction(e))return t.extend(n,{regionClass:e}),F(n);if(t.isObject(e))return e.selector&&P("The selector option on a Region definition object is deprecated. Use el to pass a selector string"),t.extend(n,{el:e.selector},e),F(n);throw new Z({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})}function F(e){var i=e.regionClass,n=t.omit(e,"regionClass");return new i(n)}function S(e,t){return t.model&&t.model.get(e)}function L(){throw new Z({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.md#behaviorslookup"})}e="default"in e?e.default:e,t="default"in t?t.default:t,i="default"in i?i.default:i;var $="3.3.1",z=function(e){return function(t){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return e.apply(t,n)}},k=e.Model.extend,P=function e(i,n){t.isObject(i)&&(i=i.prev+" is going to be removed in the future. Please use "+i.next+" instead."+(i.url?" See: "+i.url:"")),ke.DEV_MODE&&(void 0!==n&&n||e._cache[i]||(e._warn("Deprecation warning: "+i),e._cache[i]=!0))};P._console="undefined"!=typeof console?console:{},P._warn=function(){var e=P._console.warn||P._console.log||t.noop;return e.apply(P._console,arguments)},P._cache={};var j=function(e){return document.documentElement.contains(e&&e.parentNode)},H=function(e,i){var n=this;e&&t.each(i,function(t){var i=e[t];void 0!==i&&(n[t]=i)})},N=function(e){if(e)return this.options&&void 0!==this.options[e]?this.options[e]:this[e]},q=function(e){var i=this;return t.reduce(e,function(e,n,r){return t.isFunction(n)||(n=i[n]),n&&(e[r]=n),e},{})},K=/(^|:)(\w)/gi,W=t.memoize(function(e){return"on"+e.replace(K,n)}),Y=["description","fileName","lineNumber","name","message","number"],Z=k.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+$+"/",constructor:function(e,i){t.isObject(e)?(i=e,e=i.message):i||(i={});var n=Error.call(this,e);t.extend(this,t.pick(n,Y),t.pick(i,Y)),this.captureStackTrace(),i.url&&(this.url=this.urlRoot+i.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,Z)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}});Z.extend=k;var G=function(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];this.options=t.extend.apply(t,[{},t.result(this,"options")].concat(i))},J={normalizeMethods:q,_setOptions:G,mergeOptions:H,getOption:N,bindEvents:V,unbindEvents:E},Q={_initRadio:function(){var e=t.result(this,"channelName");if(e){if(!i)throw new Z({name:"BackboneRadioMissing",message:'The dependency "backbone.radio" is missing.'});var n=this._channel=i.channel(e),r=t.result(this,"radioEvents");this.bindEvents(n,r);var s=t.result(this,"radioRequests");this.bindRequests(n,s),this.on("destroy",this._destroyRadio)}},_destroyRadio:function(){this._channel.stopReplying(null,null,this)},getChannel:function(){return this._channel},bindEvents:V,unbindEvents:E,bindRequests:M,unbindRequests:R},X=["channelName","radioEvents","radioRequests"],ee=function(e){this._setOptions(e),this.mergeOptions(e,X),this.cid=t.uniqueId(this.cidPrefix),this._initRadio(),this.initialize.apply(this,arguments)};ee.extend=k,t.extend(ee.prototype,e.Events,J,Q,{cidPrefix:"mno",_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},initialize:function(){},destroy:function(){if(this._isDestroyed)return this;for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.triggerMethod.apply(this,["before:destroy",this].concat(t)),this._isDestroyed=!0,this.triggerMethod.apply(this,["destroy",this].concat(t)),this.stopListening(),this},triggerMethod:r});var te={createBuffer:function(){return document.createDocumentFragment()},appendChildren:function(t,i){e.$(t).append(i)},beforeEl:function(t,i){e.$(t).before(i)},replaceEl:function(e,t){if(e!==t){var i=t.parentNode;i&&i.replaceChild(e,t)}},detachContents:function(t){e.$(t).contents().detach()},setInnerContent:function(t,i){e.$(t).html(i)},detachEl:function(t){e.$(t).detach()},removeEl:function(t){e.$(t).remove()},findEls:function(t,i){return e.$(t,i)}},ie=function(e){this.templateId=e};t.extend(ie,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new ie(e),this.templateCaches[e]=i),i.load(t)},clear:function(){for(var e=void 0,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];var r=i.length;if(r>0)for(e=0;e<r;e++)delete this.templateCaches[i[e]];else this.templateCaches={}}}),t.extend(ie.prototype,te,{load:function(e){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,e);return this.compiledTemplate=this.compileTemplate(t,e),this.compiledTemplate},loadTemplate:function(e,t){var i=this.findEls(e);if(!i.length)throw new Z({name:"NoTemplateError",message:'Could not find template: "'+e+'"'});return i.html()},compileTemplate:function(e,i){return t.template(e,i)}});var ne=t.invokeMap||t.invoke,re={_initBehaviors:function(){this._behaviors=this._getBehaviors()},_getBehaviors:function(){var e=t.result(this,"behaviors");return t.isObject(e)?x(this,e):{}},_getBehaviorTriggers:function(){var e=ne(this._behaviors,"getTriggers");return t.reduce(e,function(e,i){return t.extend(e,i)},{})},_getBehaviorEvents:function(){var e=ne(this._behaviors,"getEvents");return t.reduce(e,function(e,i){return t.extend(e,i)},{})},_proxyBehaviorViewProperties:function(){ne(this._behaviors,"proxyViewProperties")},_delegateBehaviorEntityEvents:function(){ne(this._behaviors,"delegateEntityEvents")},_undelegateBehaviorEntityEvents:function(){ne(this._behaviors,"undelegateEntityEvents")},_destroyBehaviors:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];ne.apply(void 0,[this._behaviors,"destroy"].concat(t))},_removeBehavior:function(e){this._isDestroyed||(this._behaviors=t.without(this._behaviors,e))},_bindBehaviorUIElements:function(){ne(this._behaviors,"bindUIElements")},_unbindBehaviorUIElements:function(){ne(this._behaviors,"unbindUIElements")},_triggerEventOnBehaviors:function(){for(var e=this._behaviors,t=0,i=e&&e.length;t<i;t++)r.apply(e[t],arguments)}},se={_delegateEntityEvents:function(e,i){this._undelegateEntityEvents(e,i);var n=t.result(this,"modelEvents");V.call(this,e,n);var r=t.result(this,"collectionEvents");V.call(this,i,r)},_undelegateEntityEvents:function(e,i){var n=t.result(this,"modelEvents");E.call(this,e,n);var r=t.result(this,"collectionEvents");E.call(this,i,r)}},oe=/^(\S+)\s*(.*)$/,he=function(e){var t=e.match(oe);return A(t[1],t[2])},de={childViewEventPrefix:!0,triggersStopPropagation:!0,triggersPreventDefault:!0},le={_getViewTriggers:function(e,i){return t.reduce(i,function(t,i,n){return n=he(n),t[n]=T(e,i),t},{})}},ae=function(e,i){return t.reduce(e,function(e,t,n){var r=ce(n,i);return e[r]=t,e},{})},ce=function(e,t){return e.replace(/@ui\.[a-zA-Z-_$0-9]*/g,function(e){return t[e.slice(4)]})},ue=function e(i,n,r){return t.each(i,function(s,o){t.isString(s)?i[o]=ce(s,n):t.isObject(s)&&t.isArray(r)&&(t.extend(s,e(t.pick(s,r),n)),t.each(r,function(e){var i=s[e];t.isString(i)&&(s[e]=ce(i,n))}))}),i},fe={normalizeUIKeys:function(e){var t=this._getUIBindings();return ae(e,t)},normalizeUIString:function(e){var t=this._getUIBindings();return ce(e,t)},normalizeUIValues:function(e,t){var i=this._getUIBindings();return ue(e,i,t)},_getUIBindings:function(){var e=t.result(this,"_uiBindings"),i=t.result(this,"ui");return e||i},_bindUIElements:function(){var e=this;if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var i=t.result(this,"_uiBindings");this._ui={},t.each(i,function(t,i){e._ui[i]=e.$(t)}),this.ui=this._ui}},_unbindUIElements:function(){var e=this;this.ui&&this._uiBindings&&(t.each(this.ui,function(t,i){delete e.ui[i]}),this.ui=this._uiBindings,delete this._uiBindings,delete this._ui)},_getUI:function(e){return this._ui[e]}},_e={supportsRenderLifecycle:!0,supportsDestroyLifecycle:!0,_isDestroyed:!1,isDestroyed:function(){return!!this._isDestroyed},_isRendered:!1,isRendered:function(){return!!this._isRendered},_isAttached:!1,isAttached:function(){return!!this._isAttached},delegateEvents:function(i){this._proxyBehaviorViewProperties(),this._buildEventProxies();var n=this._getEvents(i);"undefined"==typeof i&&(this.events=n);var r=t.extend({},this._getBehaviorEvents(),n,this._getBehaviorTriggers(),this.getTriggers());return e.View.prototype.delegateEvents.call(this,r),this},_getEvents:function(e){var i=e||this.events;return t.isFunction(i)?this.normalizeUIKeys(i.call(this)):this.normalizeUIKeys(i)},getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(t.result(this,"triggers"));return this._getViewTriggers(this,e)}},delegateEntityEvents:function(){return this._delegateEntityEvents(this.model,this.collection),this._delegateBehaviorEntityEvents(),this},undelegateEntityEvents:function(){return this._undelegateEntityEvents(this.model,this.collection),this._undelegateBehaviorEntityEvents(),this},destroy:function(){if(this._isDestroyed)return this;for(var e=!!this._isAttached,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];return this.triggerMethod.apply(this,["before:destroy",this].concat(i)),e&&this.triggerMethod("before:detach",this),this.unbindUIElements(),this.removeEl(this.el),e&&(this._isAttached=!1,this.triggerMethod("detach",this)),this._removeChildren(),this._isDestroyed=!0,this._isRendered=!1,this._destroyBehaviors.apply(this,i),this.triggerMethod.apply(this,["destroy",this].concat(i)),this.stopListening(),this},bindUIElements:function(){return this._bindUIElements(),this._bindBehaviorUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this._unbindBehaviorUIElements(),this},getUI:function(e){return this._getUI(e)},childViewEventPrefix:function(){return!!O("childViewEventPrefix")&&"childview"},triggerMethod:function(){var e=r.apply(this,arguments);return this._triggerEventOnBehaviors.apply(this,arguments),e},_buildEventProxies:function(){this._childViewEvents=t.result(this,"childViewEvents"),this._childViewTriggers=t.result(this,"childViewTriggers")},_proxyChildViewEvents:function(e){this.listenTo(e,"all",this._childViewEventHandler)},_childViewEventHandler:function(e){for(var i=this.normalizeMethods(this._childViewEvents),n=arguments.length,r=Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];"undefined"!=typeof i&&t.isFunction(i[e])&&i[e].apply(this,r);var o=this._childViewTriggers;o&&t.isString(o[e])&&this.triggerMethod.apply(this,[o[e]].concat(r));var h=t.result(this,"childViewEventPrefix");if(h!==!1){var d=h+":"+e;this.triggerMethod.apply(this,[d].concat(r))}}};t.extend(_e,te,re,J,se,le,fe);var pe=["allowMissingEl","parentEl","replaceElement"],ge=ee.extend({cidPrefix:"mnr",replaceElement:!1,_isReplaced:!1,_isSwappingView:!1,constructor:function(t){if(this._setOptions(t),this.mergeOptions(t,pe),this._initEl=this.el=this.getOption("el"),this.el=this.el instanceof e.$?this.el[0]:this.el,!this.el)throw new Z({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),ee.call(this,t)},show:function(e,t){if(this._ensureElement(t))return e=this._getView(e,t),e===this.currentView?this:(this._isSwappingView=!!this.currentView,this.triggerMethod("before:show",this,e,t),e._isAttached||this.empty(t),this._setupChildView(e),this._renderView(e),this._attachView(e,t),this.currentView=e,this.triggerMethod("show",this,e,t),this._isSwappingView=!1,this)},_setupChildView:function(e){w(e),this._proxyChildViewEvents(e),e.on("destroy",this._empty,this)},_proxyChildViewEvents:function(e){var t=this._parentView;t&&t._proxyChildViewEvents(e)},_renderView:function(e){e._isRendered||(e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)))},_attachView:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!e._isAttached&&j(this.el),r="undefined"==typeof i.replaceElement?!!t.result(this,"replaceElement"):!!i.replaceElement;n&&s(e,"before:attach",e),r?this._replaceEl(e):this.attachHtml(e),n&&(e._isAttached=!0,s(e,"attach",e))},_ensureElement:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.isObject(this.el)||(this.$el=this.getEl(this.el),this.el=this.$el[0]),!this.$el||0===this.$el.length){var i="undefined"==typeof e.allowMissingEl?!!t.result(this,"allowMissingEl"):!!e.allowMissingEl;if(i)return!1;throw new Z('An "el" must exist in DOM for this region '+this.cid)}return!0},_getView:function(t){if(!t)throw new Z({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(t._isDestroyed)throw new Z({name:"ViewDestroyedError",message:'View (cid: "'+t.cid+'") has already been destroyed and cannot be used.'});if(t instanceof e.View)return t;var i=this._getViewOptions(t);return new Ce(i)},_getViewOptions:function(e){if(t.isFunction(e))return{template:e};if(t.isObject(e))return e;var i=function(){return e};return{template:i}},getEl:function(e){return this.findEls(e,t.result(this,"parentEl"))},_replaceEl:function(e){this._restoreEl(),e.on("before:destroy",this._restoreEl,this),this.replaceEl(e.el,this.el),this._isReplaced=!0},_restoreEl:function(){if(this._isReplaced){var e=this.currentView;e&&(this._detachView(e),this._isReplaced=!1)}},isReplaced:function(){return!!this._isReplaced},isSwappingView:function(){return!!this._isSwappingView},attachHtml:function(e){this.appendChildren(this.el,e.el)},empty:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{allowMissingEl:!0},t=this.currentView;if(!t)return this._ensureElement(e)&&this.detachHtml(),this;var i=!e.preventDestroy;return i||P("The preventDestroy option is deprecated. Use Region#detachView"),this._empty(t,i),this},_empty:function(e,t){e.off("destroy",this._empty,this),this.triggerMethod("before:empty",this,e),this._restoreEl(),delete this.currentView,e._isDestroyed||(t?this.removeView(e):this._detachView(e),this._stopChildViewEvents(e)),this.triggerMethod("empty",this,e)},_stopChildViewEvents:function(e){var t=this._parentView;t&&this._parentView.stopListening(e)},destroyView:function(e){return e._isDestroyed?e:(e.destroy?e.destroy():D(e),e)},removeView:function(e){this.destroyView(e)},detachView:function(){var e=this.currentView;if(e)return this._empty(e),e},_detachView:function(e){var t=!!e._isAttached,i=this._isReplaced;t&&s(e,"before:detach",e),i?this.replaceEl(this.el,e.el):this.detachHtml(),t&&(e._isAttached=!1,s(e,"detach",e))},detachHtml:function(){this.detachContents(this.el)},hasView:function(){return!!this.currentView},reset:function(e){return this.empty(e),this.$el&&(this.el=this._initEl),delete this.$el,this},destroy:function(e){return this._isDestroyed?this:(this.reset(e),this._name&&this._parentView._removeReferences(this._name),delete this._parentView,delete this._name,ee.prototype.destroy.apply(this,arguments))}});t.extend(ge.prototype,te);var ve=function(e,t){return e instanceof ge?e:U(e,t)},me={regionClass:ge,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(t.result(this,"regions"))},_reInitRegions:function(){ne(this._regions,"reset")},addRegion:function(e,t){var i={};return i[e]=t,this.addRegions(i)[e]},addRegions:function(e){if(!t.isEmpty(e))return e=this.normalizeUIValues(e,["selector","el"]),this.regions=t.extend({},this.regions,e),this._addRegions(e)},_addRegions:function(e){var i=this,n={regionClass:this.regionClass,parentEl:t.partial(t.result,this,"el")};return t.reduce(e,function(e,t,r){return e[r]=ve(t,n),i._addRegion(e[r],r),e},{})},_addRegion:function(e,t){this.triggerMethod("before:add:region",this,t,e),e._parentView=this,e._name=t,this._regions[t]=e,this.triggerMethod("add:region",this,t,e)},removeRegion:function(e){var t=this._regions[e];return this._removeRegion(t,e),t},removeRegions:function(){var e=this._getRegions();return t.each(this._regions,t.bind(this._removeRegion,this)),e},_removeRegion:function(e,t){this.triggerMethod("before:remove:region",this,t,e),e.destroy(),this.triggerMethod("remove:region",this,t,e)},_removeReferences:function(e){delete this.regions[e],delete this._regions[e]},emptyRegions:function(){var e=this.getRegions();return ne(e,"empty"),e},hasRegion:function(e){return!!this.getRegion(e)},getRegion:function(e){return this._isRendered||this.render(),this._regions[e]},_getRegions:function(){return t.clone(this._regions)},getRegions:function(){return this._isRendered||this.render(),this._getRegions()},showChildView:function(e,t){for(var i=this.getRegion(e),n=arguments.length,r=Array(n>2?n-2:0),s=2;s<n;s++)r[s-2]=arguments[s];return i.show.apply(i,[t].concat(r))},detachChildView:function(e){return this.getRegion(e).detachView()},getChildView:function(e){return this.getRegion(e).currentView}},we={render:function(e,i){if(!e)throw new Z({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});var n=t.isFunction(e)?e:ie.get(e);return n(i)}},ye=["behaviors","childViewEventPrefix","childViewEvents","childViewTriggers","collectionEvents","events","modelEvents","regionClass","regions","template","templateContext","triggers","ui"],Ce=e.View.extend({constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,ye),w(this),this._initBehaviors(),this._initRegions();var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this)},serializeData:function(){return this.model||this.collection?this.model?this.serializeModel():{items:this.serializeCollection()}:{}},serializeModel:function(){return this.model?t.clone(this.model.attributes):{}},serializeCollection:function(){return this.collection?this.collection.map(function(e){return t.clone(e.attributes)}):{}},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isRendered=!!this.$el.length,this._isAttached=j(this.el)),this._isRendered&&this.bindUIElements(),this},render:function(){return this._isDestroyed?this:(this.triggerMethod("before:render",this),this._isRendered&&this._reInitRegions(),this._renderTemplate(),this.bindUIElements(),this._isRendered=!0,this.triggerMethod("render",this),this)},_renderTemplate:function(){var e=this.getTemplate();if(e===!1)return void P("template:false is deprecated. Use _.noop.");var t=this.mixinTemplateContext(this.serializeData()),i=this._renderHtml(e,t);this.attachElContent(i)},_renderHtml:function(e,t){return we.render(e,t,this)},getTemplate:function(){return this.template},mixinTemplateContext:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.result(this,"templateContext");return t.extend(e,i)},attachElContent:function(e){return this.setInnerContent(this.el,e),this},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return t.chain(this._getRegions()).map("currentView").compact().value()}},{setRenderer:function(e){this.prototype._renderHtml=e}});t.extend(Ce.prototype,_e,me);var Ve=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck","reduce","partition"],Ee=function(e,i){t.each(Ve,function(n){e[n]=function(){var e=t.values(t.result(this,i)),r=[e].concat(t.toArray(arguments));return t[n].apply(t,r)}})},be=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,t.bind(this.add,this))};Ee(be.prototype,"_views"),t.extend(be.prototype,{add:function(e,t){return this._add(e,t)._updateLength()},_add:function(e,t){var i=e.cid;return this._views[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),t&&(this._indexByCustom[t]=i),this},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByCustom:function(e){var t=this._indexByCustom[e];return this.findByCid(t)},findByIndex:function(e){return t.values(this._views)[e]},findByCid:function(e){return this._views[e]},remove:function(e){return this._remove(e)._updateLength()},_remove:function(e){var i=e.cid;return e.model&&delete this._indexByModel[e.model.cid],t.some(this._indexByCustom,t.bind(function(e,t){if(e===i)return delete this._indexByCustom[t],!0},this)),delete this._views[i],this},_updateLength:function(){return this.length=t.size(this._views),this}});var Me=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","events","filter","emptyView","emptyViewOptions","modelEvents","reorderOnSort","sort","triggers","ui","viewComparator"],Re=e.View.extend({sort:!0,constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,Me),w(this),this._initBehaviors(),this.once("render",this._initialEvents),this._initChildViewStorage(),this._bufferedChildren=[];var n=Array.prototype.slice.call(arguments);n[0]=this.options,e.View.prototype.constructor.apply(this,n),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this)},_startBuffering:function(){this._isBuffering=!0},_endBuffering:function(){var e=!!this._isAttached,i=e?this._getImmediateChildren():[];this._isBuffering=!1,t.each(i,function(e){s(e,"before:attach",e)}),this.attachBuffer(this,this._createBuffer()),t.each(i,function(e){e._isAttached=!0,s(e,"attach",e)}),this._bufferedChildren=[]},_getImmediateChildren:function(){return t.values(this.children._views)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"update",this._onCollectionUpdate),this.listenTo(this.collection,"reset",this.render),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_onCollectionAdd:function(e,i,n){var r=void 0!==n.at&&(n.index||i.indexOf(e));(this.filter||r===!1)&&(r=t.indexOf(this._filteredSortedModels(r),e)),this._shouldAddChild(e,r)&&(this._destroyEmptyView(),this._addChild(e,r))},_onCollectionUpdate:function(e,t){var i=t.changes;this._removeChildModels(i.removed)},_removeChildModels:function(e){var t=this._getRemovedViews(e);t.length&&(this.children._updateLength(),this._updateIndices(t,!1),this.isEmpty()&&this._showEmptyView())},_getRemovedViews:function(e){var i=this;return t.reduce(e,function(e,t){var n=t&&i.children.findByModel(t);return!n||n._isDestroyed?e:(i._removeChildView(n),e.push(n),e)},[])},_removeChildView:function(e){this.triggerMethod("before:remove:child",this,e),this.children._remove(e),e.destroy?e.destroy():D(e),this.stopListening(e),this.triggerMethod("remove:child",this,e)},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isAttached=j(this.el)),this},render:function(){return this._isDestroyed?this:(this.triggerMethod("before:render",this),this._renderChildren(),this._isRendered=!0,this.triggerMethod("render",this),this)},setFilter:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.preventRender,n=this._isRendered&&!this._isDestroyed,r=this.filter!==e,s=n&&r&&!i;if(s){var o=this._filteredSortedModels();this.filter=e;var h=this._filteredSortedModels();this._applyModelDeltas(h,o)}else this.filter=e;return this},removeFilter:function(e){return this.setFilter(null,e)},_applyModelDeltas:function(e,i){var n=this,r={};t.each(e,function(e,t){var i=!n.children.findByModel(e);i&&n._onCollectionAdd(e,n.collection,{at:t}),r[e.cid]=!0});var s=t.filter(i,function(e){return!r[e.cid]&&n.children.findByModel(e)});this._removeChildModels(s)},reorder:function(){var e=this.children,i=this._filteredSortedModels();if(!i.length&&this._showingEmptyView)return this;var n=t.some(i,function(t){return!e.findByModel(t)});if(n)this.render();else{var r=[],s=e.reduce(function(e,n){var s=t.indexOf(i,n.model);return s===-1?(r.push(n.model),e):(n._index=s,e[s]=n.el,e)},new Array(i.length));this.triggerMethod("before:reorder",this),this._appendReorderedChildren(s),this._removeChildModels(r),this.triggerMethod("reorder",this)}return this},resortView:function(){return this.reorderOnSort?this.reorder():this._renderChildren(),this},_sortViews:function(){var e=this,i=this._filteredSortedModels(),n=t.find(i,function(t,i){var n=e.children.findByModel(t);return!n||n._index!==i});n&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(e){this.appendChildren(this.el,e)},_renderChildren:function(){this._isRendered&&(this._destroyEmptyView(),this._destroyChildren());var e=this._filteredSortedModels();this.isEmpty({processedModels:e})?this._showEmptyView():(this.triggerMethod("before:render:children",this),this._startBuffering(),this._showCollection(e),this._endBuffering(),this.triggerMethod("render:children",this))},_createView:function(e,t){var i=this._getChildView(e),n=this._getChildViewOptions(e,t),r=this.buildChildView(e,i,n);return r},_setupChildView:function(e,t){w(e),this._proxyChildViewEvents(e),this.sort&&(e._index=t)},_showCollection:function(e){t.each(e,t.bind(this._addChild,this)),this.children._updateLength()},_filteredSortedModels:function(e){if(!this.collection||!this.collection.length)return[];var t=this.getViewComparator(),i=this.collection.models;if(e=Math.min(Math.max(e,0),i.length-1),t){var n=void 0;e&&(n=i[e],i=i.slice(0,e).concat(i.slice(e+1))),i=this._sortModelsBy(i,t),n&&i.splice(e,0,n)}return i=this._filterModels(i)},getViewComparator:function(){return this.viewComparator},_filterModels:function(e){var i=this;return this.filter&&(e=t.filter(e,function(e,t){return i._shouldAddChild(e,t)})),e},_sortModelsBy:function(e,i){return"string"==typeof i?t.sortBy(e,function(e){return e.get(i)}):1===i.length?t.sortBy(e,t.bind(i,this)):t.clone(e).sort(t.bind(i,this))},_showEmptyView:function(){var i=this._getEmptyView();if(i&&!this._showingEmptyView){this._showingEmptyView=!0;var n=new e.Model,r=this.emptyViewOptions||this.childViewOptions;t.isFunction(r)&&(r=r.call(this,n,this._emptyViewIndex));var s=this.buildChildView(n,i,r);this.triggerMethod("before:render:empty",this,s),this.addChildView(s,0),this.triggerMethod("render:empty",this,s)}},_destroyEmptyView:function(){this._showingEmptyView&&(this.triggerMethod("before:remove:empty",this),this._destroyChildren(),delete this._showingEmptyView,this.triggerMethod("remove:empty",this))},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_getChildView:function(e){var t=this.childView;if(!t)throw new Z({name:"NoChildViewError",message:'A "childView" must be specified'});if(t=this._getView(t,e),!t)throw new Z({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},_getView:function(i,n){return i.prototype instanceof e.View||i===e.View?i:t.isFunction(i)?i.call(this,n):void 0},_addChild:function(e,t){var i=this._createView(e,t);return this.addChildView(i,t),i},_getChildViewOptions:function(e,i){return t.isFunction(this.childViewOptions)?this.childViewOptions(e,i):this.childViewOptions},addChildView:function(e,t){return this.triggerMethod("before:add:child",this,e),this._setupChildView(e,t),this._isBuffering?this.children._add(e):(this._updateIndices(e,!0),this.children.add(e)),this._renderView(e),this._attachView(e,t),this.triggerMethod("add:child",this,e),e},_updateIndices:function(e,i){if(this.sort){if(!i)return void t.each(t.sortBy(this.children._views,"_index"),function(e,t){e._index=t});var n=t.isArray(e)?t.max(e,"_index"):e;t.isObject(n)&&this.children.each(function(e){e._index>=n._index&&(e._index+=1)})}},_renderView:function(e){e._isRendered||(e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)))},_attachView:function(e,t){var i=!e._isAttached&&!this._isBuffering&&this._isAttached;i&&s(e,"before:attach",e),this.attachHtml(this,e,t),i&&(e._isAttached=!0,s(e,"attach",e))},buildChildView:function(e,i,n){var r=t.extend({model:e},n);return new i(r)},removeChildView:function(e){return!e||e._isDestroyed?e:(this._removeChildView(e),this.children._updateLength(),this._updateIndices(e,!1),e)},isEmpty:function(e){var i=void 0;return t.result(e,"processedModels")?i=e.processedModels:(i=this.collection?this.collection.models:[],i=this._filterModels(i)),0===i.length},attachBuffer:function(e,t){this.appendChildren(e.el,t)},_createBuffer:function(){var e=this,i=this.createBuffer();return t.each(this._bufferedChildren,function(t){e.appendChildren(i,t.el);
}),i},attachHtml:function(e,t,i){e._isBuffering?e._bufferedChildren.splice(i,0,t):e._insertBefore(t,i)||e._insertAfter(t)},_insertBefore:function(e,t){var i=void 0,n=this.sort&&t<this.children.length-1;return n&&(i=this.children.find(function(e){return e._index===t+1})),!!i&&(this.beforeEl(i.el,e.el),!0)},_insertAfter:function(e){this.appendChildren(this.el,e.el)},_initChildViewStorage:function(){this.children=new be},_removeChildren:function(){this._destroyChildren()},_destroyChildren:function(e){this.children.length&&(this.triggerMethod("before:destroy:children",this),this.children.each(t.bind(this._removeChildView,this)),this.children._updateLength(),this.triggerMethod("destroy:children",this))},_shouldAddChild:function(e,i){var n=this.filter;return!t.isFunction(n)||n.call(this,e,i,this.collection)}});t.extend(Re.prototype,_e);var Be=function(){this._init()};Ee(Be.prototype,"_views"),t.extend(Be.prototype,{_init:function(){this._views=[],this._viewsByCid={},this._indexByModel={},this._updateLength()},_add:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._views.length,i=e.cid;this._viewsByCid[i]=e,e.model&&(this._indexByModel[e.model.cid]=i),this._views.splice(t,0,e),this._updateLength()},_sort:function(e){return"string"==typeof e?(e=t.partial(S,e),this._sortBy(e)):1===e.length?this._sortBy(e):this._views.sort(e)},_sortBy:function(e){var i=t.sortBy(this._views,e);return this._set(i),i},_set:function(e){this._views.length=0,this._views.push.apply(this._views,e.slice(0)),this._updateLength()},findByModel:function(e){return this.findByModelCid(e.cid)},findByModelCid:function(e){var t=this._indexByModel[e];return this.findByCid(t)},findByIndex:function(e){return this._views[e]},findIndexByView:function(e){return this._views.indexOf(e)},findByCid:function(e){return this._viewsByCid[e]},_remove:function(e){if(this._viewsByCid[e.cid]){e.model&&delete this._indexByModel[e.model.cid],delete this._viewsByCid[e.cid];var t=this.findIndexByView(e);this._views.splice(t,1),this._updateLength()}},_updateLength:function(){this.length=this._views.length}});var xe=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","emptyView","emptyViewOptions","events","modelEvents","sortWithCollection","triggers","ui","viewComparator","viewFilter"],Ae=e.View.extend({sortWithCollection:!0,constructor:function(t){this._setOptions(t),this.mergeOptions(t,xe),w(this),this.once("render",this._initialEvents),this._initChildViewStorage(),this._initBehaviors();var i=Array.prototype.slice.call(arguments);i[0]=this.options,e.View.prototype.constructor.apply(this,i),this._initEmptyRegion(),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this)},_initChildViewStorage:function(){this.children=new Be},_initEmptyRegion:function(){this.emptyRegion=new ge({el:this.el}),this.emptyRegion._parentView=this},_initialEvents:function(){this.listenTo(this.collection,{sort:this._onCollectionSort,reset:this._onCollectionReset,update:this._onCollectionUpdate})},_onCollectionSort:function(){var e=this;if(this.sortWithCollection&&this.collection.length===this.children.length){var t=this.collection.some(function(t){return!e.children.findByModel(t)});t||this.sort()}},_onCollectionReset:function(){this.render()},_onCollectionUpdate:function(e,t){var i=t.changes,n=this._removeChildModels(i.removed);this._addChildModels(i.added),this._detachChildren(n),this._showChildren(),this._removeChildViews(n)},_removeChildModels:function(e){return t.map(e,t.bind(this._removeChildModel,this))},_removeChildModel:function(e){var t=this.children.findByModel(e);return this._removeChild(t),t},_removeChild:function(e){this.triggerMethod("before:remove:child",this,e),this.children._remove(e),this.triggerMethod("remove:child",this,e)},_addChildModels:function(e){return t.map(e,t.bind(this._addChildModel,this))},_addChildModel:function(e){var t=this._createChildView(e);return this._addChild(t),t},_createChildView:function(e){var t=this._getChildView(e),i=this._getChildViewOptions(e),n=this.buildChildView(e,t,i);return n},_addChild:function(e,t){this.triggerMethod("before:add:child",this,e),this._setupChildView(e),this.children._add(e,t),this.triggerMethod("add:child",this,e)},_getChildView:function(e){var t=this.childView;if(!t)throw new Z({name:"NoChildViewError",message:'A "childView" must be specified'});if(t=this._getView(t,e),!t)throw new Z({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},_getView:function(i,n){return i.prototype instanceof e.View||i===e.View?i:t.isFunction(i)?i.call(this,n):void 0},_getChildViewOptions:function(e){return t.isFunction(this.childViewOptions)?this.childViewOptions(e):this.childViewOptions},buildChildView:function(e,i,n){var r=t.extend({model:e},n);return new i(r)},_setupChildView:function(e){w(e),e.on("destroy",this.removeChildView,this),this._proxyChildViewEvents(e)},_getImmediateChildren:function(){return this.children._views},setElement:function(){var t=!!this.el;return e.View.prototype.setElement.apply(this,arguments),t&&(this._isAttached=j(this.el)),this},render:function(){return this._isDestroyed?this:(this.triggerMethod("before:render",this),this._destroyChildren(),this.children._init(),this.collection&&this._addChildModels(this.collection.models),this._showChildren(),this._isRendered=!0,this.triggerMethod("render",this),this)},sort:function(){return this._isDestroyed?this:this.children.length?(this._showChildren(),this):this},_showChildren:function(){return this.isEmpty()?void this._showEmptyView():(this._sortChildren(),void this.filter())},isEmpty:function(e){return e||!this.children.length},_showEmptyView:function(){var e=this._getEmptyView();if(e){var t=this._getEmptyViewOptions();this.emptyRegion.show(new e(t))}},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_destroyEmptyView:function(){this.emptyRegion.hasView()&&this.emptyRegion.empty()},_getEmptyViewOptions:function(){var e=this.emptyViewOptions||this.childViewOptions;return t.isFunction(e)?e.call(this):e},_sortChildren:function(){this.triggerMethod("before:sort",this);var e=this.getComparator();t.isFunction(e)&&(e=e.bind(this)),this.children._sort(e),this.triggerMethod("sort",this)},setComparator:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.preventRender,n=this.viewComparator!==e,r=n&&!i;return this.viewComparator=e,r&&this.sort(),this},removeComparator:function(e){return this.setComparator(null,e)},getComparator:function(){return this.viewComparator||this._viewComparator},_viewComparator:function(e){if(this.collection)return this.collection.indexOf(e.model)},filter:function(){if(this._isDestroyed)return this;if(!this.children.length)return this;var e=this._filterChildren();return this._renderChildren(e),this},_filterChildren:function(){var e=this._getFilter();if(!e)return this.children._views;this.triggerMethod("before:filter",this);var i=this.children.partition(t.bind(e,this));return this._detachChildren(i[1]),this.triggerMethod("filter",this),i[0]},_getFilter:function(){var e=this.getFilter();if(!e)return!1;if(t.isFunction(e))return e;if(t.isObject(e)){var i=t.matches(e);return function(e){return i(e.model&&e.model.attributes)}}if(t.isString(e))return function(t){return t.model&&t.model.get(e)};throw new Z({name:"InvalidViewFilterError",message:'"viewFilter" must be a function, predicate object literal, a string indicating a model attribute, or falsy'})},getFilter:function(){return this.viewFilter},setFilter:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.preventRender,n=this.viewFilter!==e,r=n&&!i;return this.viewFilter=e,r&&this.filter(),this},removeFilter:function(e){return this.setFilter(null,e)},_detachChildren:function(e){t.each(e,t.bind(this._detachChildView,this))},_detachChildView:function(e){var t=!!e._isAttached;t&&s(e,"before:detach",e),this.detachHtml(e),t&&(e._isAttached=!1,s(e,"detach",e))},detachHtml:function(e){this.detachEl(e.el)},_renderChildren:function(e){if(this.isEmpty(!e.length))return void this._showEmptyView();this._destroyEmptyView(),this.triggerMethod("before:render:children",this,e);var t=this._getBuffer(e);this._attachChildren(t,e),this.triggerMethod("render:children",this,e)},_attachChildren:function(e,i){var n=!!this._isAttached;i=n?i:[],t.each(i,function(e){e._isAttached||s(e,"before:attach",e)}),this.attachHtml(this,e),t.each(i,function(e){e._isAttached||(e._isAttached=!0,s(e,"attach",e))})},_getBuffer:function(e){var i=this,n=this.createBuffer();return t.each(e,function(e){i._renderChildView(e),i.appendChildren(n,e.el)}),n},_renderChildView:function(e){e._isRendered||(e.supportsRenderLifecycle||s(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,s(e,"render",e)))},attachHtml:function(e,t){this.appendChildren(e.el,t)},addChildView:function(e,t){return!e||e._isDestroyed?e:(this._addChild(e,t),this._showChildren(),e)},detachChildView:function(e){return this.removeChildView(e,{shouldDetach:!0}),e},removeChildView:function(e,t){return e?(this._removeChildView(e,t),this._removeChild(e),this.isEmpty()&&this._showEmptyView(),e):e},_removeChildViews:function(e){t.each(e,t.bind(this._removeChildView,this))},_removeChildView:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.shouldDetach;e.off("destroy",this.removeChildView,this),i?this._detachChildView(e):this._destroyChildView(e),this.stopListening(e)},_destroyChildView:function(e){e._isDestroyed||(e.destroy?e.destroy():D(e))},_removeChildren:function(){this._destroyChildren(),this.emptyRegion.destroy()},_destroyChildren:function(){this.children&&this.children.length&&(this.triggerMethod("before:destroy:children",this),this.children.each(t.bind(this._removeChildView,this)),this.triggerMethod("destroy:children",this))}});t.extend(Ae.prototype,_e);var Oe=["childViewContainer","template","templateContext"],Ie=Re.extend({constructor:function(e){P("CompositeView is deprecated. Convert to View at your earliest convenience"),this.mergeOptions(e,Oe),Re.prototype.constructor.apply(this,arguments)},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this._onCollectionAdd),this.listenTo(this.collection,"update",this._onCollectionUpdate),this.listenTo(this.collection,"reset",this.renderChildren),this.sort&&this.listenTo(this.collection,"sort",this._sortViews))},_getChildView:function(e){var t=this.childView;if(!t)return this.constructor;if(t=this._getView(t,e),!t)throw new Z({name:"InvalidChildViewError",message:'"childView" must be a view class or a function that returns a view class'});return t},serializeData:function(){return this.serializeModel()},render:function(){return this._isDestroyed?this:(this._isRendering=!0,this.resetChildViewContainer(),this.triggerMethod("before:render",this),this._renderTemplate(),this.bindUIElements(),this.renderChildren(),this._isRendering=!1,this._isRendered=!0,this.triggerMethod("render",this),this)},renderChildren:function(){(this._isRendered||this._isRendering)&&Re.prototype._renderChildren.call(this)},attachBuffer:function(e,t){var i=this.getChildViewContainer(e);this.appendChildren(i,t)},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);this.appendChildren(t,e.el)},_appendReorderedChildren:function(e){var t=this.getChildViewContainer(this);this.appendChildren(t,e)},getChildViewContainer:function(e,i){if(e.$childViewContainer)return e.$childViewContainer;var n=void 0,r=e.childViewContainer;if(r){var s=t.result(e,"childViewContainer");if(n="@"===s.charAt(0)&&e.ui?e.ui[s.substr(4)]:this.findEls(s,e.$el),n.length<=0)throw new Z({name:"ChildViewContainerMissingError",message:'The specified "childViewContainer" was not found: '+e.childViewContainer})}else n=e.$el;return e.$childViewContainer=n,n},resetChildViewContainer:function(){this.$childViewContainer&&(this.$childViewContainer=void 0)}}),Te=t.pick(Ce.prototype,"serializeModel","getTemplate","_renderTemplate","_renderHtml","mixinTemplateContext","attachElContent");t.extend(Ie.prototype,Te);var De=["collectionEvents","events","modelEvents","triggers","ui"],Ue=ee.extend({cidPrefix:"mnb",constructor:function(e,i){this.view=i,this.defaults&&P("Behavior defaults are deprecated. For similar functionality set options on the Behavior class."),this.defaults=t.clone(t.result(this,"defaults",{})),this._setOptions(this.defaults,e),this.mergeOptions(this.options,De),this.ui=t.extend({},t.result(this,"ui"),t.result(i,"ui")),ee.apply(this,arguments)},$:function(){return this.view.$.apply(this.view,arguments)},destroy:function(){return this.stopListening(),this.view._removeBehavior(this),this},proxyViewProperties:function(){return this.$el=this.view.$el,this.el=this.view.el,this},bindUIElements:function(){return this._bindUIElements(),this},unbindUIElements:function(){return this._unbindUIElements(),this},getUI:function(e){return this._getUI(e)},delegateEntityEvents:function(){return this._delegateEntityEvents(this.view.model,this.view.collection),this},undelegateEntityEvents:function(){return this._undelegateEntityEvents(this.view.model,this.view.collection),this},getEvents:function(){var e=this,i=this.normalizeUIKeys(t.result(this,"events"));return t.reduce(i,function(i,n,r){if(t.isFunction(n)||(n=e[n]),n)return r=he(r),i[r]=t.bind(n,e),i},{})},getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(t.result(this,"triggers"));return this._getViewTriggers(this.view,e)}}});t.extend(Ue.prototype,se,le,fe);var Fe=["region","regionClass"],Se=ee.extend({cidPrefix:"mna",constructor:function(e){this._setOptions(e),this.mergeOptions(e,Fe),this._initRegion(),ee.prototype.constructor.apply(this,arguments)},regionClass:ge,_initRegion:function(){var e=this.region;if(e){var t={regionClass:this.regionClass};this._region=ve(e,t)}},getRegion:function(){return this._region},showView:function(e){for(var t=this.getRegion(),i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return t.show.apply(t,[e].concat(n))},getView:function(){return this.getRegion().currentView},start:function(e){return this.triggerMethod("before:start",this,e),this.triggerMethod("start",this,e),this}}),Le=["appRoutes","controller"],$e=e.Router.extend({constructor:function(t){this._setOptions(t),this.mergeOptions(t,Le),e.Router.apply(this,arguments);var i=this.appRoutes,n=this._getController();this.processAppRoutes(n,i),this.on("route",this._processOnRoute,this)},appRoute:function(e,t){var i=this._getController();return this._addAppRoute(i,e,t),this},_processOnRoute:function(e,i){if(t.isFunction(this.onRoute)){var n=t.invert(this.appRoutes)[e];this.onRoute(e,n,i)}},processAppRoutes:function(e,i){var n=this;if(!i)return this;var r=t.keys(i).reverse();return t.each(r,function(t){n._addAppRoute(e,t,i[t])}),this},_getController:function(){return this.controller},_addAppRoute:function(e,i,n){var r=e[n];if(!r)throw new Z('Method "'+n+'" was not found on the controller');this.route(i,n,t.bind(r,e))},triggerMethod:r});t.extend($e.prototype,J);var ze=e.Marionette,ke=e.Marionette={};return ke.noConflict=function(){return e.Marionette=ze,this},ke.bindEvents=z(V),ke.unbindEvents=z(E),ke.bindRequests=z(M),ke.unbindRequests=z(R),ke.mergeOptions=z(H),ke.getOption=z(N),ke.normalizeMethods=z(q),ke.extend=k,ke.isNodeAttached=j,ke.deprecate=P,ke.triggerMethod=z(r),ke.triggerMethodOn=s,ke.isEnabled=O,ke.setEnabled=I,ke.monitorViewEvents=w,ke.Behaviors={},ke.Behaviors.behaviorsLookup=L,ke.Application=Se,ke.AppRouter=$e,ke.Renderer=we,ke.TemplateCache=ie,ke.View=Ce,ke.CollectionView=Re,ke.NextCollectionView=Ae,ke.CompositeView=Ie,ke.Behavior=Ue,ke.Region=ge,ke.Error=Z,ke.Object=ee,ke.DEV_MODE=!1,ke.FEATURES=de,ke.VERSION=$,ke});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("backbone"),require("underscore"),require("backbone.radio")):"function"==typeof define&&define.amd?define(["backbone","underscore","backbone.radio"],t):e.Marionette=e.Mn=t(e.Backbone,e._,e.Backbone.Radio)}(this,function(e,t,i){"use strict";function n(e,t,i){return i.toUpperCase()}function r(e){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];var s=H(e),o=j.call(this,s),h=void 0;return t.isFunction(o)&&(h=o.apply(this,n)),this.trigger.apply(this,arguments),h}function s(e){for(var i=arguments.length,n=Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return t.isFunction(e.triggerMethod)?e.triggerMethod.apply(e,n):r.apply(e,n)}function o(e,i,n){e._getImmediateChildren&&t.each(e._getImmediateChildren(),function(e){n(e)&&s(e,i,e)})}function h(e){return!e._isAttached}function d(e){return!!h(e)&&(e._isAttached=!0,!0)}function l(e){return e._isAttached}function a(e){return!!l(e)&&(e._isAttached=!1,!0)}function c(e){e._isAttached&&e._isRendered&&s(e,"dom:refresh",e)}function u(){o(this,"before:attach",h)}function f(){o(this,"attach",d),c(this)}function p(){o(this,"before:detach",l)}function g(){o(this,"detach",a)}function _(){c(this)}function v(e){e._areViewEventsMonitored||(e._areViewEventsMonitored=!0,e.on({"before:attach":u,attach:f,"before:detach":p,detach:g,render:_}))}function m(e,i,n,r,s){var o=r.split(/\s+/);t.each(o,function(t){var r=e[t];if(!r)throw new Y('Method "'+t+'" was configured as an event handler, but does not exist.');e[s](i,n,r)})}function w(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new Y({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindevents"});t.each(n,function(n,s){return t.isString(n)?void m(e,i,s,n,r):void e[r](i,s,n)})}}function y(e,t){return w(this,e,t,"listenTo"),this}function E(e,t){return w(this,e,t,"stopListening"),this}function V(e,i,n,r){if(i&&n){if(!t.isObject(n))throw new Y({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindrequests"});var s=q.call(e,n);i[r](s,e)}}function C(e,t){return V(this,e,t,"reply"),this}function b(e,t){return V(this,e,t,"stopReplying"),this}function R(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}function M(e,i){return e.behaviorClass?e.behaviorClass:t.isFunction(e)?e:t.isFunction(Se.Behaviors.behaviorsLookup)?Se.Behaviors.behaviorsLookup(e,i)[i]:Se.Behaviors.behaviorsLookup[i]}function x(e,i){return t.chain(i).map(function(i,n){var r=M(i,n),s=i===r?{}:i,o=new r(s,e),h=x(e,t.result(o,"behaviors"));return[o].concat(h)}).flatten().value()}function B(e,i){return[e+t.uniqueId(".evt"),i].join(" ")}function A(e){return!!oe[e]}function I(e,t){return oe[e]=t}function O(e,i){t.isString(i)&&(i={event:i});var n=i.event,r=!!i.preventDefault;A("triggersPreventDefault")&&(r=i.preventDefault!==!1);var s=!!i.stopPropagation;return A("triggersStopPropagation")&&(s=i.stopPropagation!==!1),function(t){r&&t.preventDefault(),s&&t.stopPropagation(),e.triggerMethod(n,e,t)}}function T(e){e.supportsDestroyLifecycle||s(e,"before:destroy",e);var t=!!e._isAttached;t&&s(e,"before:detach",e),e.remove(),t&&(e._isAttached=!1,s(e,"detach",e)),e._isDestroyed=!0,e.supportsDestroyLifecycle||s(e,"destroy",e)}function U(e,i){var n=t.extend({},i);if(t.isString(e))return t.extend(n,{el:e}),D(n);if(t.isFunction(e))return t.extend(n,{regionClass:e}),D(n);if(t.isObject(e))return e.selector&&L("The selector option on a Region definition object is deprecated. Use el to pass a selector string"),t.extend(n,{el:e.selector},e),D(n);throw new Y({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})}function D(e){var i=e.regionClass,n=t.omit(e,"regionClass");return new i(n)}function S(){throw new Y({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.md#behaviorslookup"})}e="default"in e?e.default:e,t="default"in t?t.default:t,i="default"in i?i.default:i;var $="3.2.0",k=function(e){return function(t){for(var i=arguments.length,n=Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return e.apply(t,n)}},z=e.Model.extend,L=function e(i,n){t.isObject(i)&&(i=i.prev+" is going to be removed in the future. Please use "+i.next+" instead."+(i.url?" See: "+i.url:"")),Se.DEV_MODE&&(void 0!==n&&n||e._cache[i]||(e._warn("Deprecation warning: "+i),e._cache[i]=!0))};L._console="undefined"!=typeof console?console:{},L._warn=function(){var e=L._console.warn||L._console.log||t.noop;return e.apply(L._console,arguments)},L._cache={};var P=function(e){return document.documentElement.contains(e&&e.parentNode)},F=function(e,i){var n=this;e&&t.each(i,function(t){var i=e[t];void 0!==i&&(n[t]=i)})},j=function(e){if(e)return this.options&&void 0!==this.options[e]?this.options[e]:this[e]},q=function(e){var i=this;return t.reduce(e,function(e,n,r){return t.isFunction(n)||(n=i[n]),n&&(e[r]=n),e},{})},N=/(^|:)(\w)/gi,H=t.memoize(function(e){return"on"+e.replace(N,n)}),K=["description","fileName","lineNumber","name","message","number"],Y=z.call(Error,{urlRoot:"http://marionettejs.com/docs/v"+$+"/",constructor:function(e,i){t.isObject(e)?(i=e,e=i.message):i||(i={});var n=Error.call(this,e);t.extend(this,t.pick(n,K),t.pick(i,K)),this.captureStackTrace(),i.url&&(this.url=this.urlRoot+i.url)},captureStackTrace:function(){Error.captureStackTrace&&Error.captureStackTrace(this,Y)},toString:function(){return this.name+": "+this.message+(this.url?" See: "+this.url:"")}});Y.extend=z;var Z=function(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];this.options=t.extend.apply(t,[{},t.result(this,"options")].concat(i))},G={normalizeMethods:q,_setOptions:Z,mergeOptions:F,getOption:j,bindEvents:y,unbindEvents:E},J={_initRadio:function(){var e=t.result(this,"channelName");if(e){if(!i)throw new Y({name:"BackboneRadioMissing",message:'The dependency "backbone.radio" is missing.'});var n=this._channel=i.channel(e),r=t.result(this,"radioEvents");this.bindEvents(n,r);var s=t.result(this,"radioRequests");this.bindRequests(n,s),this.on("destroy",this._destroyRadio)}},_destroyRadio:function(){this._channel.stopReplying(null,null,this)},getChannel:function(){return this._channel},bindEvents:y,unbindEvents:E,bindRequests:C,unbindRequests:b},Q=["channelName","radioEvents","radioRequests"],W=function(e){this._setOptions(e),this.mergeOptions(e,Q),this.cid=t.uniqueId(this.cidPrefix),this._initRadio(),this.initialize.apply(this,arguments)};W.extend=z,t.extend(W.prototype,e.Events,G,J,{cidPrefix:"mno",_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},initialize:function(){},destroy:function(){if(this._isDestroyed)return this;for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.triggerMethod.apply(this,["before:destroy",this].concat(t)),this._isDestroyed=!0,this.triggerMethod.apply(this,["destroy",this].concat(t)),this.stopListening(),this},triggerMethod:r});var X={createBuffer:function(){return document.createDocumentFragment()},appendChildren:function(t,i){e.$(t).append(i)},beforeEl:function(t,i){e.$(t).before(i)},replaceEl:function(e,t){if(e!==t){var i=t.parentNode;i&&i.replaceChild(e,t)}},detachContents:function(t){e.$(t).contents().detach()},setInnerContent:function(t,i){e.$(t).html(i)},removeEl:function(t){e.$(t).remove()},findEls:function(t,i){return e.$(t,i)}},ee=function(e){this.templateId=e};t.extend(ee,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new ee(e),this.templateCaches[e]=i),i.load(t)},clear:function(){for(var e=void 0,t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];var r=i.length;if(r>0)for(e=0;e<r;e++)delete this.templateCaches[i[e]];else this.templateCaches={}}}),t.extend(ee.prototype,X,{load:function(e){if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId,e);return this.compiledTemplate=this.compileTemplate(t,e),this.compiledTemplate},loadTemplate:function(e,t){var i=this.findEls(e);if(!i.length)throw new Y({name:"NoTemplateError",message:'Could not find template: "'+e+'"'});return i.html()},compileTemplate:function(e,i){return t.template(e,i)}});var te=t.invokeMap||t.invoke,ie={_initBehaviors:function(){this._behaviors=this._getBehaviors()},_getBehaviors:function(){var e=t.result(this,"behaviors");return t.isObject(e)?x(this,e):{}},_getBehaviorTriggers:function(){var e=te(this._behaviors,"getTriggers");return t.extend.apply(t,[{}].concat(R(e)))},_getBehaviorEvents:function(){var e=te(this._behaviors,"getEvents");return t.extend.apply(t,[{}].concat(R(e)))},_proxyBehaviorViewProperties:function(){te(this._behaviors,"proxyViewProperties")},_delegateBehaviorEntityEvents:function(){te(this._behaviors,"delegateEntityEvents")},_undelegateBehaviorEntityEvents:function(){te(this._behaviors,"undelegateEntityEvents")},_destroyBehaviors:function(e){te.apply(void 0,[this._behaviors,"destroy"].concat(R(e)))},_bindBehaviorUIElements:function(){te(this._behaviors,"bindUIElements")},_unbindBehaviorUIElements:function(){te(this._behaviors,"unbindUIElements")},_triggerEventOnBehaviors:function(){for(var e=this._behaviors,t=0,i=e&&e.length;t<i;t++)r.apply(e[t],arguments)}},ne={_delegateEntityEvents:function(e,i){this._undelegateEntityEvents(e,i);var n=t.result(this,"modelEvents");y.call(this,e,n);var r=t.result(this,"collectionEvents");y.call(this,i,r)},_undelegateEntityEvents:function(e,i){var n=t.result(this,"modelEvents");E.call(this,e,n);var r=t.result(this,"collectionEvents");E.call(this,i,r)}},re=/^(\S+)\s*(.*)$/,se=function(e){var t=e.match(re);return B(t[1],t[2])},oe={triggersStopPropagation:!0,triggersPreventDefault:!0},he={_getViewTriggers:function(e,i){return t.reduce(i,function(t,i,n){return n=se(n),t[n]=O(e,i),t},{})}},de=function(e,i){return t.reduce(e,function(e,t,n){var r=le(n,i);return e[r]=t,e},{})},le=function(e,t){return e.replace(/@ui\.[a-zA-Z-_$0-9]*/g,function(e){return t[e.slice(4)]})},ae=function e(i,n,r){return t.each(i,function(s,o){t.isString(s)?i[o]=le(s,n):t.isObject(s)&&t.isArray(r)&&(t.extend(s,e(t.pick(s,r),n)),t.each(r,function(e){var i=s[e];t.isString(i)&&(s[e]=le(i,n))}))}),i},ce={normalizeUIKeys:function(e){var t=this._getUIBindings();return de(e,t)},normalizeUIString:function(e){var t=this._getUIBindings();return le(e,t)},normalizeUIValues:function(e,t){var i=this._getUIBindings();return ae(e,i,t)},_getUIBindings:function(){var e=t.result(this,"_uiBindings"),i=t.result(this,"ui");return e||i},_bindUIElements:function(){var e=this;if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var i=t.result(this,"_uiBindings");this._ui={},t.each(i