!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=t(e.Backbone,e._,e.Backbone.Radio)}(this,function(e,t,i){"use strict";function n(e,t,i){return i.toUpperCase()}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];var r=K(e),o=N.call(this,r),h=void 0;return t.isFunction(o)&&(h=o.apply(this,n)),this.trigger.apply(this,arguments),h}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];return t.isFunction(e.triggerMethod)?e.triggerMethod.apply(e,n):s.apply(e,n)}function o(e,i,n){e._getImmediateChildren&&t.each(e._getImmediateChildren(),function(e){n(e)&&r(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&&r(e,"dom:refresh",e)}function u(e){e._isAttached&&e._isRendered&&r(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||!1===e.monitorViewEvents||(e._areViewEventsMonitored=!0,e.on({"before:attach":f,attach:_,"before:detach":p,detach:g,"before:render":v,render:m}))}function y(e,i,n,s,r){var o=s.split(/\s+/);o.length>1&&z("Multiple handlers for a single event are deprecated. If needed, use a single handler to call multiple methods."),t.each(o,function(t){var s=e[t];if(!s)throw new Y('Method "'+t+'" was configured as an event handler, but does not exist.');e[r](i,n,s)})}function C(e,i,n,s){if(!t.isObject(n))throw new Y({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindevents"});t.each(n,function(n,r){t.isString(n)?y(e,i,r,n,s):e[s](i,r,n)})}function V(e,t){return e&&t?(C(this,e,t,"listenTo"),this):this}function E(e,t){return e?t?(C(this,e,t,"stopListening"),this):(this.stopListening(e),this):this}function b(e,i,n,s){if(!t.isObject(n))throw new Y({message:"Bindings must be an object.",url:"marionette.functions.html#marionettebindrequests"});var r=H.call(e,n);i[s](r,e)}function M(e,t){return e&&t?(b(this,e,t,"reply"),this):this}function R(e,t){return e?t?(b(this,e,t,"stopReplying"),this):(e.stopReplying(null,null,this),this):this}function B(e,i){return e.behaviorClass?e.behaviorClass:t.isFunction(e)?e:t.isFunction(Le.Behaviors.behaviorsLookup)?Le.Behaviors.behaviorsLookup(e,i)[i]:Le.Behaviors.behaviorsLookup[i]}function x(e,i){return t.chain(i).map(function(i,n){var s=B(i,n),r=new s(i===s?{}:i,e),o=x(e,t.result(r,"behaviors"));return[r].concat(o)}).flatten().value()}function D(e){return!!re[e]}function A(e,i){t.isString(i)&&(i={event:i});var n=i.event,s=!!i.preventDefault;D("triggersPreventDefault")&&(s=!1!==i.preventDefault);var r=!!i.stopPropagation;return D("triggersStopPropagation")&&(r=!1!==i.stopPropagation),function(t){s&&t.preventDefault(),r&&t.stopPropagation(),e.triggerMethod(n,e,t)}}function O(t){return t instanceof e.$?t:e.$(t)}function I(e){return this.prototype.Dom=t.extend({},this.prototype.Dom,e),this}function $(e){e._isRendered||(e.supportsRenderLifecycle||r(e,"before:render",e),e.render(),e.supportsRenderLifecycle||(e._isRendered=!0,r(e,"render",e)))}function T(e){if(e.destroy)e.destroy();else{e.supportsDestroyLifecycle||r(e,"before:destroy",e);var t=e._isAttached&&!e._shouldDisableEvents;t&&r(e,"before:detach",e),e.remove(),t&&(e._isAttached=!1,r(e,"detach",e)),e._isDestroyed=!0,e.supportsDestroyLifecycle||r(e,"destroy",e)}}function U(e,i){var n=t.extend({},i);if(t.isString(e))return t.extend(n,{el:e}),S(n);if(t.isFunction(e))return t.extend(n,{regionClass:e}),S(n);if(t.isObject(e))return e.selector&&z("The selector option on a Region definition object is deprecated. Use el to pass a selector string"),t.extend(n,{el:e.selector},e),S(n);throw new Y({message:"Improper region configuration type.",url:"marionette.region.html#region-configuration-types"})}function S(e){return new(0,e.regionClass)(t.omit(e,"regionClass"))}function F(e,t){return t.model&&t.model.get(e)}e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i;var L=function(e){return function(t){for(var i=arguments.length,n=Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return e.apply(t,n)}},P=e.Model.extend,z=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:"")),Le.DEV_MODE&&(void 0!==n&&n||e._cache[i]||(e._warn("Deprecation warning: "+i),e._cache[i]=!0))};z._console="undefined"!=typeof console?console:{},z._warn=function(){return(z._console.warn||z._console.log||t.noop).apply(z._console,arguments)},z._cache={};var k=function(e){return document.documentElement.contains(e&&e.parentNode)},j=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]},H=function(e){var i=this;return t.reduce(e,function(e,n,s){return t.isFunction(n)||(n=i[n]),n&&(e[s]=n),e},{})},q=/(^|:)(\w)/gi,K=t.memoize(function(e){return"on"+e.replace(q,n)}),W=["description","fileName","lineNumber","name","message","number"],Y=P.call(Error,{urlRoot:"http://marionettejs.com/docs/v3.5.1/",constructor:function(e,i){t.isObject(e)?e=(i=e).message:i||(i={});var n=Error.call(this,e);t.extend(this,t.pick(n,W),t.pick(i,W)),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=P;var Z={normalizeMethods:H,_setOptions:function(e){this.options=t.extend({},t.result(this,"options"),e)},mergeOptions:j,getOption:N,bindEvents:V,unbindEvents:E},G={_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),s=t.result(this,"radioEvents");this.bindEvents(n,s);var r=t.result(this,"radioRequests");this.bindRequests(n,r),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},J=["channelName","radioEvents","radioRequests"],Q=function(e){this.hasOwnProperty("options")||this._setOptions(e),this.mergeOptions(e,J),this._setCid(),this._initRadio(),this.initialize.apply(this,arguments)};Q.extend=P,t.extend(Q.prototype,e.Events,Z,G,{cidPrefix:"mno",_isDestroyed:!1,isDestroyed:function(){return this._isDestroyed},initialize:function(){},_setCid:function(){this.cid||(this.cid=t.uniqueId(this.cidPrefix))},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:s});var X=function(e){this.templateId=e};t.extend(X,{templateCaches:{},get:function(e,t){var i=this.templateCaches[e];return i||(i=new X(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 s=i.length;if(s>0)for(e=0;e<s;e++)delete this.templateCaches[i[e]];else this.templateCaches={}}}),t.extend(X.prototype,{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(t,i){var n=e.$(t);if(!n.length)throw new Y({name:"NoTemplateError",message:'Could not find template: "'+t+'"'});return n.html()},compileTemplate:function(e,i){return t.template(e,i)}});var ee=t.invokeMap||t.invoke,te={_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=ee(this._behaviors,"getTriggers");return t.reduce(e,function(e,i){return t.extend(e,i)},{})},_getBehaviorEvents:function(){var e=ee(this._behaviors,"getEvents");return t.reduce(e,function(e,i){return t.extend(e,i)},{})},_proxyBehaviorViewProperties:function(){ee(this._behaviors,"proxyViewProperties")},_delegateBehaviorEntityEvents:function(){ee(this._behaviors,"delegateEntityEvents")},_undelegateBehaviorEntityEvents:function(){ee(this._behaviors,"undelegateEntityEvents")},_destroyBehaviors:function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];ee.apply(void 0,[this._behaviors,"destroy"].concat(t))},_removeBehavior:function(e){this._isDestroyed||(this.undelegate(".trig"+e.cid+" ."+e.cid),this._behaviors=t.without(this._behaviors,e))},_bindBehaviorUIElements:function(){ee(this._behaviors,"bindUIElements")},_unbindBehaviorUIElements:function(){ee(this._behaviors,"unbindUIElements")},_triggerEventOnBehaviors:function(){for(var e=this._behaviors,t=0,i=e&&e.length;t<i;t++)s.apply(e[t],arguments)}},ie={_delegateEntityEvents:function(e,i){var n=t.result(this,"modelEvents");n&&(E.call(this,e,n),V.call(this,e,n));var s=t.result(this,"collectionEvents");s&&(E.call(this,i,s),V.call(this,i,s))},_undelegateEntityEvents:function(e,i){var n=t.result(this,"modelEvents");E.call(this,e,n);var s=t.result(this,"collectionEvents");E.call(this,i,s)}},ne=/^(\S+)\s*(.*)$/,se=function(e,t){var i=e.match(ne);return i[1]+"."+t+" "+i[2]},re={childViewEventPrefix:!0,triggersStopPropagation:!0,triggersPreventDefault:!0},oe={_getViewTriggers:function(e,i){var n=this;return t.reduce(i,function(t,i,s){return s=se(s,"trig"+n.cid),t[s]=A(e,i),t},{})}},he=function(e,i){return t.reduce(e,function(e,t,n){return e[de(n,i)]=t,e},{})},de=function(e,t){return e.replace(/@ui\.[a-zA-Z-_$0-9]*/g,function(e){return t[e.slice(4)]})},le=function e(i,n,s){return t.each(i,function(r,o){t.isString(r)?i[o]=de(r,n):t.isObject(r)&&t.isArray(s)&&(t.extend(r,e(t.pick(r,s),n)),t.each(s,function(e){var i=r[e];t.isString(i)&&(r[e]=de(i,n))}))}),i},ae={normalizeUIKeys:function(e){var t=this._getUIBindings();return he(e,t)},normalizeUIString:function(e){var t=this._getUIBindings();return de(e,t)},normalizeUIValues:function(e,t){var i=this._getUIBindings();return le(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]}},ce={createBuffer:function(){return document.createDocumentFragment()},getEl:function(e){return O(e)},findEl:function(e,t){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:O(e)).find(t)},hasEl:function(e,t){return e.contains(t&&t.parentNode)},detachEl:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:O(e)).detach()},replaceEl:function(e,t){if(e!==t){var i=t.parentNode;i&&i.replaceChild(e,t)}},swapEl:function(e,t){if(e!==t){var i=e.parentNode,n=t.parentNode;if(i&&n){var s=e.nextSibling,r=t.nextSibling;i.insertBefore(t,s),n.insertBefore(e,r)}}},setContents:function(e,t){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:O(e)).html(t)},appendContents:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=i._$el,s=void 0===n?O(e):n,r=i._$contents,o=void 0===r?O(t):r;s.append(o)},hasContents:function(e){return!!e&&e.hasChildNodes()},detachContents:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:O(e)).contents().detach()}},ue={Dom:ce,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);void 0===i&&(this.events=n);var s=t.extend({},this._getBehaviorEvents(),n,this._getBehaviorTriggers(),this.getTriggers());return e.View.prototype.delegateEvents.call(this,s),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&&!this._shouldDisableEvents,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._removeElement(),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},_removeElement:function(){this.$el.off().removeData(),this.Dom.detachEl(this.el,this.$el)},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!!D("childViewEventPrefix")&&"childview"},triggerMethod:function(){var e=s.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,s=Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];void 0!==i&&t.isFunction(i[e])&&i[e].apply(this,s);var o=this._childViewTriggers;o&&t.isString(o[e])&&this.triggerMethod.apply(this,[o[e]].concat(s));var h=t.result(this,"childViewEventPrefix");if(!1!==h){var d=h+":"+e;this.triggerMethod.apply(this,[d].concat(s))}}};t.extend(ue,te,Z,ie,oe,ae);var fe=["allowMissingEl","parentEl","replaceElement"],_e=Q.extend({Dom:ce,cidPrefix:"mnr",replaceElement:!1,_isReplaced:!1,_isSwappingView:!1,constructor:function(t){if(this._setOptions(t),this.mergeOptions(t,fe),this._initEl=this.el=this.getOption("el"),this.el=this.el instanceof e.$?this.el[0]:this.el,!this.el)throw new Y({name:"NoElError",message:'An "el" must be specified for a region.'});this.$el=this.getEl(this.el),Q.call(this,t)},show:function(e,t){if(this._ensureElement(t))return(e=this._getView(e,t))===this.currentView?this:(this._isSwappingView=!!this.currentView,this.triggerMethod("before:show",this,e,t),e._isAttached||this.empty(t),this._setupChildView(e),this.currentView=e,$(e),this._attachView(e,t),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)},_shouldDisableMonitoring:function(){return this._parentView&&!1===this._parentView.monitorViewEvents},_attachView:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!e._isAttached&&k(this.el)&&!this._shouldDisableMonitoring(),s=void 0===i.replaceElement?!!t.result(this,"replaceElement"):!!i.replaceElement;n&&r(e,"before:attach",e),s?this._replaceEl(e):this.attachHtml(e),n&&(e._isAttached=!0,r(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=this.Dom.getEl(this.el)),!this.$el||0===this.$el.length){if(void 0===e.allowMissingEl?!!t.result(this,"allowMissingEl"):!!e.allowMissingEl)return!1;throw new Y('An "el" must exist in DOM for this region '+this.cid)}return!0},_getView:function(t){if(!t)throw new Y({name:"ViewNotValid",message:"The view passed is undefined and therefore invalid. You must pass a view instance to show."});if(t._isDestroyed)throw new Y({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 we(i)},_getViewOptions:function(e){if(t.isFunction(e))return{template:e};if(t.isObject(e))return e;return{template:function(){return e}}},getEl:function(e){var i=t.result(this,"parentEl");return i&&t.isString(e)?this.Dom.findEl(i,e):this.Dom.getEl(e)},_replaceEl:function(e){this._restoreEl(),e.on("before:destroy",this._restoreEl,this),this.Dom.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.Dom.appendContents(this.el,e.el,{_$el:this.$el,_$contents: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||z("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){this._parentView&&this._parentView.stopListening(e)},destroyView:function(e){return e._isDestroyed?e:(e._shouldDisableEvents=this._shouldDisableMonitoring(),T(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&&!this._shouldDisableMonitoring(),i=this._isReplaced;t&&r(e,"before:detach",e),i?this.Dom.replaceEl(this.el,e.el):this.detachHtml(),t&&(e._isAttached=!1,r(e,"detach",e))},detachHtml:function(){this.Dom.detachContents(this.el,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,Q.prototype.destroy.apply(this,arguments))}},{setDomApi:I}),pe=function(e,t){return e instanceof _e?e:U(e,t)},ge={regionClass:_e,_initRegions:function(){this.regions=this.regions||{},this._regions={},this.addRegions(t.result(this,"regions"))},_reInitRegions:function(){ee(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,s){return e[s]=pe(t,n),i._addRegion(e[s],s),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 ee(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,s=Array(n>2?n-2:0),r=2;r<n;r++)s[r-2]=arguments[r];return i.show.apply(i,[t].concat(s))},detachChildView:function(e){return this.getRegion(e).detachView()},getChildView:function(e){return this.getRegion(e).currentView}},ve={render:function(e,i){if(!e)throw new Y({name:"TemplateNotFoundError",message:"Cannot render the template since its false, null or undefined."});return(t.isFunction(e)?e:X.get(e))(i)}},me=["behaviors","childViewEventPrefix","childViewEvents","childViewTriggers","collectionEvents","events","modelEvents","regionClass","regions","template","templateContext","triggers","ui"],we=e.View.extend({constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,me),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(){return e.View.prototype.setElement.apply(this,arguments),this._isRendered=this.Dom.hasContents(this.el),this._isAttached=k(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(!1!==e){var t=this.mixinTemplateContext(this.serializeData()),i=this._renderHtml(e,t);this.attachElContent(i)}else z("template:false is deprecated. Use _.noop.")},_renderHtml:function(e,t){return ve.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.Dom.setContents(this.el,e,this.$el),this},_removeChildren:function(){this.removeRegions()},_getImmediateChildren:function(){return t.chain(this._getRegions()).map("currentView").compact().value()}},{setRenderer:function(e){return this.prototype._renderHtml=e,this},setDomApi:I});t.extend(we.prototype,ue,ge);var ye=["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"],Ce=function(e,i){t.each(ye,function(n){e[n]=function(){var e=t.result(this,i),s=Array.prototype.slice.call(arguments);return t[n].apply(t,[e].concat(s))}})},Ve=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,t.bind(this.add,this))};Ce(Ve.prototype,"_getViews"),t.extend(Ve.prototype,{_getViews:function(){return t.values(this._views)},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 Ee=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","events","filter","emptyView","emptyViewOptions","modelEvents","reorderOnSort","sort","triggers","ui","viewComparator"],be=e.View.extend({sort:!0,constructor:function(i){this.render=t.bind(this.render,this),this._setOptions(i),this.mergeOptions(i,Ee),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&&!1!==this.monitorViewEvents?this._getImmediateChildren():[];this._isBuffering=!1,t.each(e,function(e){r(e,"before:attach",e)}),this.attachBuffer(this,this._createBuffer()),t.each(e,function(e){e._isAttached=!0,r(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 s=void 0!==n.at&&(n.index||i.indexOf(e));(this.filter||!1===s)&&(s=t.indexOf(this._filteredSortedModels(s),e)),this._shouldAddChild(e,s)&&(this._destroyEmptyView(),this._addChild(e,s))},_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._shouldDisableEvents=!1===this.monitorViewEvents,T(e),this.stopListening(e),this.triggerMethod("remove:child",this,e)},setElement:function(){return e.View.prototype.setElement.apply(this,arguments),this._isAttached=k(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]:{}).preventRender,i=this._isRendered&&!this._isDestroyed,n=this.filter!==e;if(i&&n&&!t){var s=this._filteredSortedModels();this.filter=e;var r=this._filteredSortedModels();this._applyModelDeltas(r,s)}else this.filter=e;return this},removeFilter:function(e){return this.setFilter(null,e)},_applyModelDeltas:function(e,i){var n=this,s={};t.each(e,function(e,t){!n.children.findByModel(e)&&n._onCollectionAdd(e,n.collection,{at:t}),s[e.cid]=!0});var r=t.filter(i,function(e){return!s[e.cid]&&n.children.findByModel(e)});this._removeChildModels(r)},reorder:function(){var e=this,i=this.children,n=this._filteredSortedModels();if(!n.length&&this._showingEmptyView)return this;if(t.some(n,function(e){return!i.findByModel(e)}))this.render();else{var s=[],r=t.reduce(this.children._views,function(e,i){var r=t.indexOf(n,i.model);return-1===r?(s.push(i.model),e):(i._index=r,e[r]=i.el,e)},new Array(n.length));this.triggerMethod("before:reorder",this);var o=this.Dom.createBuffer();t.each(r,function(t){e.Dom.appendContents(o,t)}),this._appendReorderedChildren(o),this._removeChildModels(s),this.triggerMethod("reorder",this)}return this},resortView:function(){return this.reorderOnSort?this.reorder():this._renderChildren(),this},_sortViews:function(){var e=this,i=this._filteredSortedModels();t.find(i,function(t,i){var n=e.children.findByModel(t);return!n||n._index!==i})&&this.resortView()},_emptyViewIndex:-1,_appendReorderedChildren:function(e){this.Dom.appendContents(this.el,e,{_$el:this.$el})},_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);return this.buildChildView(e,i,n)},_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,s=this.emptyViewOptions||this.childViewOptions;t.isFunction(s)&&(s=s.call(this,n,this._emptyViewIndex));var r=this.buildChildView(n,i,s);this.triggerMethod("before:render:empty",this,r),this.addChildView(r,0),this.triggerMethod("render:empty",this,r)}},_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 Y({name:"NoChildViewError",message:'A "childView" must be specified'});if(!(t=this._getView(t,e)))throw new Y({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)),$(e),this._attachView(e,t),this.triggerMethod("add:child",this,e),e},_updateIndices:function(e,i){if(this.sort)if(i){var n=t.isArray(e)?t.max(e,"_index"):e;t.isObject(n)&&t.each(this.children._views,function(e){e._index>=n._index&&(e._index+=1)})}else t.each(t.sortBy(this.children._views,"_index"),function(e,t){e._index=t})},_attachView:function(e,t){var i=!e._isAttached&&!this._isBuffering&&this._isAttached&&!1!==this.monitorViewEvents;i&&r(e,"before:attach",e),this.attachHtml(this,e,t),i&&(e._isAttached=!0,r(e,"attach",e))},buildChildView:function(e,i,n){return new i(t.extend({model:e},n))},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.Dom.appendContents(e.el,t,{_$el:e.$el})},_createBuffer:function(){var e=this,i=this.Dom.createBuffer();return t.each(this._bufferedChildren,function(t){e.Dom.appendContents(i,t.el,{_$contents: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,i){var n=void 0;return this.sort&&i<this.children.length-1&&(n=t.find(this.children._views,function(e){return e._index===i+1})),!!n&&(this.beforeEl(n.el,e.el),!0)},beforeEl:function(e,t){this.$(e).before(t)},_insertAfter:function(e){this.Dom.appendContents(this.el,e.el,{_$el:this.$el,_$contents:e.$el})},_initChildViewStorage:function(){this.children=new Ve},_removeChildren:function(){this._destroyChildren()},_destroyChildren:function(e){this.children.length&&(this.triggerMethod("before:destroy:children",this),t.each(this.children._views,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)}},{setDomApi:I});t.extend(be.prototype,ue);var Me=function(){this._init()};Ce(Me.prototype,"_views"),t.extend(Me.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,i){return"string"==typeof e?(e=t.partial(F,e),this._sortBy(e)):1===e.length?this._sortBy(t.bind(e,i)):this._views.sort(t.bind(e,i))},_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()},_swap:function(e,t){var i=this.findIndexByView(e),n=this.findIndexByView(t);if(-1!==i&&-1!==n){var s=this._views[i];this._views[i]=this._views[n],this._views[n]=s}},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]},hasView:function(e){return!!this.findByCid(e.cid)},_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 Re=["behaviors","childView","childViewEventPrefix","childViewEvents","childViewOptions","childViewTriggers","collectionEvents","emptyView","emptyViewOptions","events","modelEvents","sortWithCollection","triggers","ui","viewComparator","viewFilter"],Be=e.View.extend({sortWithCollection:!0,constructor:function(t){this._setOptions(t),this.mergeOptions(t,Re),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.getEmptyRegion(),this.delegateEntityEvents(),this._triggerEventOnBehaviors("initialize",this)},_initChildViewStorage:function(){this.children=new Me},getEmptyRegion:function(){return this._emptyRegion&&!this._emptyRegion.isDestroyed()?this._emptyRegion:(this._emptyRegion=new _e({el:this.el,replaceElement:!1}),this._emptyRegion._parentView=this,this._emptyRegion)},_initialEvents:function(){this.listenTo(this.collection,{sort:this._onCollectionSort,reset:this._onCollectionReset,update:this._onCollectionUpdate})},_onCollectionSort:function(e,t){var i=t.add,n=t.merge,s=t.remove;this.sortWithCollection&&!1!==this.viewComparator&&(i||s||n||this.sort())},_onCollectionReset:function(){this.render()},_onCollectionUpdate:function(e,t){var i=t.changes,n=i.removed.length&&this._removeChildModels(i.removed);this._addedViews=i.added.length&&this._addChildModels(i.added),this._detachChildren(n),this._showChildren(),this._removeChildViews(n)},_removeChildModels:function(e){var i=this;return t.reduce(e,function(e,t){var n=i._removeChildModel(t);return n&&e.push(n),e},[])},_removeChildModel:function(e){var t=this.children.findByModel(e);return t&&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);return this.buildChildView(e,t,i)},_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 Y({name:"NoChildViewError",message:'A "childView" must be specified'});if(!(t=this._getView(t,e)))throw new Y({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){return new i(t.extend({model:e},n))},_setupChildView:function(e){w(e),e.on("destroy",this.removeChildView,this),this._proxyChildViewEvents(e)},_getImmediateChildren:function(){return this.children._views},setElement:function(){return e.View.prototype.setElement.apply(this,arguments),this._isAttached=k(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(){this.isEmpty()?this._showEmptyView():(this._sortChildren(),this.filter())},isEmpty:function(e){return e||!this.children.length},_showEmptyView:function(){var e=this._getEmptyView();if(e){var t=this._getEmptyViewOptions();this.getEmptyRegion().show(new e(t))}},_getEmptyView:function(){var e=this.emptyView;if(e)return this._getView(e)},_destroyEmptyView:function(){var e=this.getEmptyRegion();e.hasView()&&e.empty()},_getEmptyViewOptions:function(){var e=this.emptyViewOptions||this.childViewOptions;return t.isFunction(e)?e.call(this):e},_sortChildren:function(){var e=this.getComparator();e&&(delete this._addedViews,this.triggerMethod("before:sort",this),this.children._sort(e,this),this.triggerMethod("sort",this))},setComparator:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).preventRender,i=this.viewComparator!==e&&!t;return this.viewComparator=e,i&&this.sort(),this},removeComparator:function(e){return this.setComparator(null,e)},getComparator:function(){return this.viewComparator?this.viewComparator:!(!this.sortWithCollection||!1===this.viewComparator||!this.collection)&&this._viewComparator},_viewComparator:function(e){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,i=this._getFilter(),n=this._addedViews;if(delete this._addedViews,!i)return n||this.children._views;this.triggerMethod("before:filter",this);var s=[],r=[];return t.each(this.children._views,function(t,n,o){(i.call(e,t,n,o)?s:r).push(t)}),this._detachChildren(r),this.triggerMethod("filter",this,s,r),s},_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 Y({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]:{}).preventRender,i=this.viewFilter!==e&&!t;return this.viewFilter=e,i&&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&&!1!==this.monitorViewEvents;t&&r(e,"before:detach",e),this.detachHtml(e),t&&(e._isAttached=!1,r(e,"detach",e))},detachHtml:function(e){this.Dom.detachEl(e.el,e.$el)},_renderChildren:function(e){if(this.isEmpty(!e.length))this._showEmptyView();else{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){i=this._isAttached&&!1!==this.monitorViewEvents?i:[],t.each(i,function(e){e._isAttached||r(e,"before:attach",e)}),this.attachHtml(e),t.each(i,function(e){e._isAttached||(e._isAttached=!0,r(e,"attach",e))})},_getBuffer:function(e){var i=this,n=this.Dom.createBuffer();return t.each(e,function(e){$(e),i.Dom.appendContents(n,e.el,{_$contents:e.$el})}),n},attachHtml:function(e){this.Dom.appendContents(this.el,e,{_$el:this.$el})},swapChildViews:function(e,t){if(!this.children.hasView(e)||!this.children.hasView(t))throw new Y({name:"ChildSwapError",message:"Both views must be children of the collection view"});return this.children._swap(e,t),this.Dom.swapEl(e.el,t.el),this.Dom.hasEl(this.el,e.el)!==this.Dom.hasEl(this.el,t.el)&&this.filter(),this},addChildView:function(e,t){return!e||e._isDestroyed?e:((!t||t>=this.children.length)&&(this._addedViews=[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]:{}).shouldDetach;e.off("destroy",this.removeChildView,this),t?this._detachChildView(e):this._destroyChildView(e),this.stopListening(e)},_destroyChildView:function(e){e._isDestroyed||(e._shouldDisableEvents=!1===this.monitorViewEvents,T(e))},_removeChildren:function(){this._destroyChildren(),this.getEmptyRegion().destroy(),delete this._addedViews},_destroyChildren:function(){this.children&&this.children.length&&(this.triggerMethod("before:destroy:children",this),!1===this.monitorViewEvents&&this.Dom.detachContents(this.el,this.$el),t.each(this.children._views,t.bind(this._removeChildView,this)),this.triggerMethod("destroy:children",this))}},{setDomApi:I});t.extend(Be.prototype,ue);var xe=["childViewContainer","template","templateContext"],De=be.extend({constructor:function(e){z("CompositeView is deprecated. Convert to View at your earliest convenience"),this.mergeOptions(e,xe),be.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)))throw new Y({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)&&be.prototype._renderChildren.call(this)},attachBuffer:function(e,t){var i=this.getChildViewContainer(e);this.Dom.appendContents(i[0],t,{_$el:i})},_insertAfter:function(e){var t=this.getChildViewContainer(this,e);this.Dom.appendContents(t[0],e.el,{_$el:t,_$contents:e.$el})},_appendReorderedChildren:function(e){var t=this.getChildViewContainer(this);this.Dom.appendContents(t[0],e,{_$el:t})},getChildViewContainer:function(e,i){if(e.$childViewContainer)return e.$childViewContainer;var n=void 0;if(e.childViewContainer){var s=t.result(e,"childViewContainer");if((n="@"===s.charAt(0)&&e.ui?e.ui[s.substr(4)]:this.$(s)).length<=0)throw new Y({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)}}),Ae=t.pick(we.prototype,"serializeModel","getTemplate","_renderTemplate","_renderHtml","mixinTemplateContext","attachElContent");t.extend(De.prototype,Ae);var Oe=["collectionEvents","events","modelEvents","triggers","ui"],Ie=Q.extend({cidPrefix:"mnb",constructor:function(e,i){this.view=i,this.defaults&&z("Behavior defaults are deprecated. For similar functionality set options on the Behavior class."),this.defaults=t.clone(t.result(this,"defaults",{})),this._setOptions(t.extend({},this.defaults,e)),this.mergeOptions(this.options,Oe),this.ui=t.extend({},t.result(this,"ui"),t.result(i,"ui")),Q.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,s){return t.isFunction(n)||(n=e[n]),n?(s=se(s,e.cid),i[s]=t.bind(n,e),i):i},{})},getTriggers:function(){if(this.triggers){var e=this.normalizeUIKeys(t.result(this,"triggers"));return this._getViewTriggers(this.view,e)}}});t.extend(Ie.prototype,ie,oe,ae);var $e=["region","regionClass"],Te=Q.extend({cidPrefix:"mna",constructor:function(e){this._setOptions(e),this.mergeOptions(e,$e),this._initRegion(),Q.prototype.constructor.apply(this,arguments)},regionClass:_e,_initRegion:function(){var e=this.region;if(e){var t={regionClass:this.regionClass};this._region=pe(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),s=1;s<i;s++)n[s-1]=arguments[s];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}}),Ue=["appRoutes","controller"],Se=e.Router.extend({constructor:function(t){this._setOptions(t),this.mergeOptions(t,Ue),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 s=t.keys(i).reverse();return t.each(s,function(t){n._addAppRoute(e,t,i[t])}),this},_getController:function(){return this.controller},_addAppRoute:function(e,i,n){var s=e[n];if(!s)throw new Y('Method "'+n+'" was not found on the controller');this.route(i,n,t.bind(s,e))},triggerMethod:s});t.extend(Se.prototype,Z);var Fe=e.Marionette,Le=e.Marionette={};return Le.noConflict=function(){return e.Marionette=Fe,this},Le.bindEvents=L(V),Le.unbindEvents=L(E),Le.bindRequests=L(M),Le.unbindRequests=L(R),Le.mergeOptions=L(j),Le.getOption=L(N),Le.normalizeMethods=L(H),Le.extend=P,Le.isNodeAttached=k,Le.deprecate=z,Le.triggerMethod=L(s),Le.triggerMethodOn=r,Le.isEnabled=D,Le.setEnabled=function(e,t){return re[e]=t},Le.monitorViewEvents=w,Le.Behaviors={},Le.Behaviors.behaviorsLookup=function(){throw new Y({message:"You must define where your behaviors are stored.",url:"marionette.behaviors.md#behaviorslookup"})},Le.Application=Te,Le.AppRouter=Se,Le.Renderer=ve,Le.TemplateCache=X,Le.View=we,Le.CollectionView=be,Le.NextCollectionView=Be,Le.CompositeView=De,Le.Behavior=Ie,Le.Region=_e,Le.Error=Y,Le.Object=Q,Le.DEV_MODE=!1,Le.FEATURES=re,Le.VERSION="3.5.1",Le.DomApi=ce,Le.setDomApi=function(e){be.setDomApi(e),De.setDomApi(e),Be.setDomApi(e),_e.setDomApi(e),we.setDomApi(e)},Le}),this&&this.Marionette&&(this.Mn=this.Marionette);