/**
 * almond 0.2.6 Copyright (c) 2011-2012, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/jrburke/almond for details
 */

//     Underscore.js 1.6.0
//     http://underscorejs.org
//     (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
//     Underscore may be freely distributed under the MIT license.

/*!
 * jQuery JavaScript Library v1.10.2
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2013-07-03T13:48Z
 */

/*!
 * Sizzle CSS Selector Engine v1.10.2
 * http://sizzlejs.com/
 *
 * Copyright 2013 jQuery Foundation, Inc. and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2013-07-03
 */

//     (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
//     Backbone may be freely distributed under the MIT license.
//     For all details and documentation:
//     http://backbonejs.org

// Backbone.BabySitter
// -------------------
// v0.1.0
//
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
//
// http://github.com/marionettejs/backbone.babysitter

// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v1.6.4
//
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
//
// http://marionettejs.com

/*!
 * Includes BabySitter
 * https://github.com/marionettejs/backbone.babysitter/
 *
 * Includes Wreqr
 * https://github.com/marionettejs/backbone.wreqr/
 */

/*! Raven.js 1.1.16 (463f68f) | github.com/getsentry/raven-js */

/*
 * Includes TraceKit
 * https://github.com/getsentry/TraceKit
 *
 * Copyright 2014 Matt Robenolt and other contributors
 * Released under the BSD license
 * https://github.com/getsentry/raven-js/blob/master/LICENSE
 *
 */

/*
 TraceKit - Cross brower stack traces - github.com/occ/TraceKit
 MIT license
*/

/*
 Copyright 2011 Abdulla Abdurakhmanov
 Original sources are available at https://code.google.com/p/x2js/

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

//! moment.js
//! version : 2.4.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com

/*
 *  jssha256 version 0.1  -  Copyright 2006 B. Poettering
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307 USA
 */

/*!

 handlebars v1.1.2

Copyright (C) 2011 by Yehuda Katz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@license
*/

/**
 * @license RequireJS text 2.0.10 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
 * Available via the MIT or new BSD license.
 * see: http://github.com/requirejs/text for details
 */

/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

// Copyright 2013 Google Inc. All Rights Reserved.

/**
 * @fileoverview Manages the DRM license requests.
 */

// perform a single license call. This may be important if the server

// is tracking license requests, for example.

/**
 * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
 *
 * @version 0.6.11
 * @codingstandard ftlabs-jsv2
 * @copyright The Financial Times Limited [All Rights Reserved]
 * @license MIT License (see LICENSE.txt)
 */

/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Version: 3.1.11
 *
 * Requires: jQuery 1.2.2+
 */

/**
 * libjass
 *
 * https://github.com/Arnavion/libjass
 *
 * Copyright 2013 Arnav Singh
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**!
 * Sortable
 * @author	RubaXa   <trash@rubaxa.org>
 * @license MIT
 */

/**
 * sifter.js
 * Copyright (c) 2013 Brian Reavis & contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 *
 * @author Brian Reavis <brian@thirdroute.com>
 */

/**
 * microplugin.js
 * Copyright (c) 2013 Brian Reavis & contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 *
 * @author Brian Reavis <brian@thirdroute.com>
 */

/**
 * selectize.js (v0.12.1)
 * Copyright (c) 2013–2015 Brian Reavis & contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 *
 * @author Brian Reavis <brian@thirdroute.com>
 */

/**
 * Copyright 2013 Craig Campbell
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Mousetrap is a simple keyboard shortcut library for Javascript with
 * no external dependencies
 *
 * @version 1.4.6
 * @url craig.is/killing/mice
 */

/* ========================================================================
 * Bootstrap: transition.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#transitions
 * ========================================================================
 * Copyright 2013 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */

/* ========================================================================
 * Bootstrap: dropdown.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#dropdowns
 * ========================================================================
 * Copyright 2013 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */

/* ========================================================================
 * Bootstrap: tooltip.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#tooltip
 * Inspired by the original jQuery.tipsy by Jason Frame
 * ========================================================================
 * Copyright 2013 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */

/* ========================================================================
 * Bootstrap: button.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#buttons
 * ========================================================================
 * Copyright 2013 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */

/* ========================================================================
 * Bootstrap: modal.js v3.0.0
 * http://twbs.github.com/bootstrap/javascript.html#modals
 * ========================================================================
 * Copyright 2013 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ======================================================================== */

/** @license
 *
 * SoundManager 2: JavaScript Sound for the Web
 * ----------------------------------------------
 * http://schillmania.com/projects/soundmanager2/
 *
 * Copyright (c) 2007, Scott Schiller. All rights reserved.
 * Code provided under the BSD License:
 * http://schillmania.com/projects/soundmanager2/license.txt
 *
 * V2.97a.20140901
 */

function X2JS(e,t,i){"use strict";function n(e){var t=e.localName;return null==t&&(t=e.baseName),(null==t||""==t)&&(t=e.nodeName),t}function s(a){var r,o,l;if(a.nodeType==y.DOCUMENT_NODE){var c,d;for(o=a.firstChild,c=0,d=a.childNodes.length;d>c;c+=1)if(a.childNodes[c].nodeType!==y.COMMENT_NODE){o=a.childNodes[c];break}return i?r=s(o):(r={},l=n(o),r[l]=s(o)),r}if(a.nodeType==y.ELEMENT_NODE){var u=0,h=a.childNodes;r=new Object;for(var p=0;p<h.length;p++)if(o=h.item(p),l=n(o),u++,null==r[l])r[l]=s(o);
else{if(null!=r[l]&&!(r[l]instanceof Array)){var m=r[l];r[l]=[],r[l].push(m)}for(var f=0;null!=r[l][f];)f++;r[l][f]=s(o)}for(var g=0;g<a.attributes.length;g++){var v=a.attributes.item(g);u++;for(var b=v.value,w=0,x=e.length;x>w;w++){var k=e[w];k.test.call(this,v.value)&&(b=k.converter.call(this,v.value))}r[t+v.name]=b}if(null!=r["#text"]){var S=r["#text"];"string"==typeof S?(S=S.replace(/[\r\n]/g,""),r["#text"]=S,1==u&&(r=S)):delete r["#text"]}return r}return a.nodeType==y.TEXT_NODE||a.nodeType==y.CDATA_SECTION_NODE?a.nodeValue:a.nodeType==y.COMMENT_NODE?null:void 0
}function a(e){return"string"==typeof e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;"):e}function r(e){var t="";return null!=e.__cdata&&(t+="<![CDATA["+e.__cdata+"]]>"),null!=e.__text&&(t+=v?a(e.__text):e.__text),t}function o(e){var t="";return e instanceof Object?t+=r(e):null!=e&&(t+=v?a(e):e),t}function l(e,t){return-1!==e.indexOf(t,e.length-t.length)}function c(e,t){return l(t.toString(),"_asArray")||0==t.toString().indexOf("_")||e[t]instanceof Function?!0:!1
}function d(e){var t=0;if(e instanceof Object)for(var i in e)c(e,i)||t++;return t}function u(e){var t=[];if(e instanceof Object)for(var i in e){var n=i.toString(),s=n.charAt(0);-1==i.indexOf("__")&&("_"===s||s===s.toLowerCase()&&s!==s.toUpperCase())&&t.push(i)}return t}function h(e,t,i){var n="";if(0==e.length)n+=p(e,t,i,!0);else for(var s=0;s<e.length;s++)n+=p(e[s],t,u(e[s]),!1),n+=f(e[s]),n+=m(e[s],t);return n}function p(e,t,i,n){var s="<"+(null!=e&&null!=e.__prefix?e.__prefix+":":"")+t;if(null!=i)for(var a=0;a<i.length;a++){var r=i[a],o=e[r];
s+=" "+r.substr(1)+"='"+o+"'"}return s+=n?"/>":">"}function m(e,t){return"</"+(null!=e.__prefix?e.__prefix+":":"")+t+">"}function f(e){var t="",i=d(e);if(i>0)for(var n in e)if(!c(e,n)){var s=e[n],a=u(s);if(null==s||void 0==s)t+=p(s,n,a,!0);else if(s instanceof Object)if(s instanceof Array)t+=h(s,n,a);else{var r=d(s);r>0||null!=s.__text||null!=s.__cdata?(t+=p(s,n,a,!1),t+=f(s),t+=m(s,n)):t+=p(s,n,a,!0)}else t+=p(s,n,a,!1),t+=o(s),t+=m(s,n)}return t+=o(e)}(null===t||void 0===t)&&(t="_"),(null===i||void 0===i)&&(i=!1);
var g="1.0.11",v=!1,y={ELEMENT_NODE:1,TEXT_NODE:3,CDATA_SECTION_NODE:4,COMMENT_NODE:8,DOCUMENT_NODE:9};this.parseXmlString=function(e){var t;if(window.DOMParser){var i=new window.DOMParser;t=i.parseFromString(e,"text/xml")}else 0==e.indexOf("<?")&&(e=e.substr(e.indexOf("?>")+2)),t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e);return t},this.xml2json=function(e){return s(e)},this.xml_str2json=function(e){var t=this.parseXmlString(e);return this.xml2json(t)},this.getVersion=function(){return g
},this.escapeMode=function(e){v=e},this.json2xml_str=function(e){return f(e)}}function string_to_array(e){for(var t=e.length,i=new Array(t),n=0;t>n;n++)i[n]=e.charCodeAt(n);return i}function array_to_hex_string(e){for(var t="",i=0;i<e.length;i++)t+=SHA256_hexchars[e[i]>>4]+SHA256_hexchars[15&e[i]];return t}function array_to_string(e){for(var t="",i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t}function SHA256_init(){SHA256_H=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),SHA256_buf=new Array,SHA256_len=0
}function SHA256_write(e){SHA256_buf=SHA256_buf.concat("string"==typeof e?string_to_array(e):e);for(var t=0;t+64<=SHA256_buf.length;t+=64)SHA256_Hash_Byte_Block(SHA256_H,SHA256_buf.slice(t,t+64));SHA256_buf=SHA256_buf.slice(t),SHA256_len+=e.length}function SHA256_finalize(){if(SHA256_buf[SHA256_buf.length]=128,SHA256_buf.length>56){for(var e=SHA256_buf.length;64>e;e++)SHA256_buf[e]=0;SHA256_Hash_Byte_Block(SHA256_H,SHA256_buf),SHA256_buf.length=0}for(var e=SHA256_buf.length;59>e;e++)SHA256_buf[e]=0;
SHA256_buf[59]=SHA256_len>>>29&255,SHA256_buf[60]=SHA256_len>>>21&255,SHA256_buf[61]=SHA256_len>>>13&255,SHA256_buf[62]=SHA256_len>>>5&255,SHA256_buf[63]=SHA256_len<<3&255,SHA256_Hash_Byte_Block(SHA256_H,SHA256_buf);for(var t=new Array(32),e=0;8>e;e++)t[4*e+0]=SHA256_H[e]>>>24,t[4*e+1]=SHA256_H[e]>>16&255,t[4*e+2]=SHA256_H[e]>>8&255,t[4*e+3]=255&SHA256_H[e];return delete SHA256_H,delete SHA256_buf,delete SHA256_len,t}function SHA256_hash(e){var t;return SHA256_init(),SHA256_write(e),t=SHA256_finalize(),array_to_hex_string(t)
}function HMAC_SHA256_init(e){HMAC_SHA256_key="string"==typeof e?string_to_array(e):(new Array).concat(e),HMAC_SHA256_key.length>64&&(SHA256_init(),SHA256_write(HMAC_SHA256_key),HMAC_SHA256_key=SHA256_finalize());for(var t=HMAC_SHA256_key.length;64>t;t++)HMAC_SHA256_key[t]=0;for(var t=0;64>t;t++)HMAC_SHA256_key[t]^=54;SHA256_init(),SHA256_write(HMAC_SHA256_key)}function HMAC_SHA256_write(e){SHA256_write(e)}function HMAC_SHA256_finalize(){for(var e=SHA256_finalize(),t=0;64>t;t++)HMAC_SHA256_key[t]^=106;
SHA256_init(),SHA256_write(HMAC_SHA256_key),SHA256_write(e);for(var t=0;64>t;t++)HMAC_SHA256_key[t]=0;return delete HMAC_SHA256_key,SHA256_finalize()}function HMAC_SHA256_MAC(e,t){var i;return HMAC_SHA256_init(e),HMAC_SHA256_write(t),i=HMAC_SHA256_finalize(),array_to_hex_string(i)}function SHA256_sigma0(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function SHA256_sigma1(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}function SHA256_Sigma0(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function SHA256_Sigma1(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)
}function SHA256_Ch(e,t,i){return i^e&(t^i)}function SHA256_Maj(e,t,i){return e&t^i&(e^t)}function SHA256_Hash_Word_Block(e,t){for(var i=16;64>i;i++)t[i]=SHA256_sigma1(t[i-2])+t[i-7]+SHA256_sigma0(t[i-15])+t[i-16]&4294967295;for(var n=(new Array).concat(e),i=0;64>i;i++){var s=n[7]+SHA256_Sigma1(n[4])+SHA256_Ch(n[4],n[5],n[6])+SHA256_K[i]+t[i],a=SHA256_Sigma0(n[0])+SHA256_Maj(n[0],n[1],n[2]);n.pop(),n.unshift(s+a&4294967295),n[4]=n[4]+s&4294967295}for(var i=0;8>i;i++)e[i]=e[i]+n[i]&4294967295}function SHA256_Hash_Byte_Block(e,t){for(var i=new Array(16),n=0;16>n;n++)i[n]=t[4*n+0]<<24|t[4*n+1]<<16|t[4*n+2]<<8|t[4*n+3];
SHA256_Hash_Word_Block(e,i)}function FastClick(e){"use strict";var t,i=this;if(this.trackingClick=!1,this.trackingClickStart=0,this.targetElement=null,this.touchStartX=0,this.touchStartY=0,this.lastTouchIdentifier=0,this.touchBoundary=10,this.layer=e,!e||!e.nodeType)throw new TypeError("Layer must be a document node");this.onClick=function(){return FastClick.prototype.onClick.apply(i,arguments)},this.onMouse=function(){return FastClick.prototype.onMouse.apply(i,arguments)},this.onTouchStart=function(){return FastClick.prototype.onTouchStart.apply(i,arguments)
},this.onTouchMove=function(){return FastClick.prototype.onTouchMove.apply(i,arguments)},this.onTouchEnd=function(){return FastClick.prototype.onTouchEnd.apply(i,arguments)},this.onTouchCancel=function(){return FastClick.prototype.onTouchCancel.apply(i,arguments)},FastClick.notNeeded(e)||(this.deviceIsAndroid&&(e.addEventListener("mouseover",this.onMouse,!0),e.addEventListener("mousedown",this.onMouse,!0),e.addEventListener("mouseup",this.onMouse,!0)),e.addEventListener("click",this.onClick,!0),e.addEventListener("touchstart",this.onTouchStart,!1),e.addEventListener("touchmove",this.onTouchMove,!1),e.addEventListener("touchend",this.onTouchEnd,!1),e.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(e.removeEventListener=function(t,i,n){var s=Node.prototype.removeEventListener;
"click"===t?s.call(e,t,i.hijacked||i,n):s.call(e,t,i,n)},e.addEventListener=function(t,i,n){var s=Node.prototype.addEventListener;"click"===t?s.call(e,t,i.hijacked||(i.hijacked=function(e){e.propagationStopped||i(e)}),n):s.call(e,t,i,n)}),"function"==typeof e.onclick&&(t=e.onclick,e.addEventListener("click",function(e){t(e)},!1),e.onclick=null))}var requirejs,require,define;!function(e){function t(e,t){return v.call(e,t)}function i(e,t){var i,n,s,a,r,o,l,c,d,u,h=t&&t.split("/"),p=f.map,m=p&&p["*"]||{};
if(e&&"."===e.charAt(0))if(t){for(h=h.slice(0,h.length-1),e=h.concat(e.split("/")),c=0;c<e.length;c+=1)if(u=e[c],"."===u)e.splice(c,1),c-=1;else if(".."===u){if(1===c&&(".."===e[2]||".."===e[0]))break;c>0&&(e.splice(c-1,2),c-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((h||m)&&p){for(i=e.split("/"),c=i.length;c>0;c-=1){if(n=i.slice(0,c).join("/"),h)for(d=h.length;d>0;d-=1)if(s=p[h.slice(0,d).join("/")],s&&(s=s[n])){a=s,r=c;break}if(a)break;!o&&m&&m[n]&&(o=m[n],l=c)}!a&&o&&(a=o,r=l),a&&(i.splice(0,r,a),e=i.join("/"))
}return e}function n(t,i){return function(){return d.apply(e,y.call(arguments,0).concat([t,i]))}}function s(e){return function(t){return i(t,e)}}function a(e){return function(t){p[e]=t}}function r(i){if(t(m,i)){var n=m[i];delete m[i],g[i]=!0,c.apply(e,n)}if(!t(p,i)&&!t(g,i))throw new Error("No "+i);return p[i]}function o(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function l(e){return function(){return f&&f.config&&f.config[e]||{}}}var c,d,u,h,p={},m={},f={},g={},v=Object.prototype.hasOwnProperty,y=[].slice;
u=function(e,t){var n,a=o(e),l=a[0];return e=a[1],l&&(l=i(l,t),n=r(l)),l?e=n&&n.normalize?n.normalize(e,s(t)):i(e,t):(e=i(e,t),a=o(e),l=a[0],e=a[1],l&&(n=r(l))),{f:l?l+"!"+e:e,n:e,pr:l,p:n}},h={require:function(e){return n(e)},exports:function(e){var t=p[e];return"undefined"!=typeof t?t:p[e]={}},module:function(e){return{id:e,uri:"",exports:p[e],config:l(e)}}},c=function(i,s,o,l){var c,d,f,v,y,b,w=[];if(l=l||i,"function"==typeof o){for(s=!s.length&&o.length?["require","exports","module"]:s,y=0;y<s.length;y+=1)if(v=u(s[y],l),d=v.f,"require"===d)w[y]=h.require(i);
else if("exports"===d)w[y]=h.exports(i),b=!0;else if("module"===d)c=w[y]=h.module(i);else if(t(p,d)||t(m,d)||t(g,d))w[y]=r(d);else{if(!v.p)throw new Error(i+" missing "+d);v.p.load(v.n,n(l,!0),a(d),{}),w[y]=p[d]}f=o.apply(p[i],w),i&&(c&&c.exports!==e&&c.exports!==p[i]?p[i]=c.exports:f===e&&b||(p[i]=f))}else i&&(p[i]=o)},requirejs=require=d=function(t,i,n,s,a){return"string"==typeof t?h[t]?h[t](i):r(u(t,i).f):(t.splice||(f=t,i.splice?(t=i,i=n,n=null):t=e),i=i||function(){},"function"==typeof n&&(n=s,s=a),s?c(e,t,i,n):setTimeout(function(){c(e,t,i,n)
},4),d)},d.config=function(e){return f=e,f.deps&&d(f.deps,f.callback),d},requirejs._defined=p,define=function(e,i,n){i.splice||(n=i,i=[]),t(p,e)||t(m,e)||(m[e]=[e,i,n])},define.amd={jQuery:!0}}(),define("libs/require/almond-0.2.6",function(){}),require.config({templatePathPrefixs:["app/","app/js/"],paths:{templates:"../templates",text:"libs/require/text-2.0.10",hb:"libs/require/handlebars.precompile-0.1",tpl:"libs/require/underscore-tpl-0.1.0","jquery-lib":"libs/jquery-1.10.2",underscore:"libs/backbone/underscore-1.6.0","backbone-lib":"libs/backbone/backbone-1.1.2","marionette-lib":"libs/backbone/backbone.marionette-1.6.4","backbone.wreqr":"libs/backbone/backbone.wreqr-1.1.0","backbone.babysitter":"libs/backbone/backbone.babysitter-0.1.0","backbone.obscura":"libs/backbone/backbone.obscura-0.1.7","handlebars-lib":"libs/backbone/handlebars-1.1.2","soundmanager-lib":"libs/soundmanager/soundmanager2-custom",googledash:"libs/googledash",jwplayer:"libs/jwplayer/jwplayer-6.8",swfobject:"libs/jwplayer/swfobject-2.2",fastclick:"libs/fastclick-0.6.11",x2js:"libs/x2js-1.0.11",moment:"libs/moment-2.4.0","chrome-analytics":"libs/analytics/chrome-analytics","google-analytics":"libs/analytics/google-analytics",bugsense:"libs/analytics/bugsense-f0c8aa6e10",raven:"libs/analytics/raven-1.1.16",selectize:"libs/selectize-0.12.1-plex","jquery.freefocus":"libs/jquery.freefocus-0.8.7","jquery.translate":"libs/jquery.translate-0.1.0","jquery.mousewheel":"libs/jquery.mousewheel-3.1.11",sortable:"libs/sortable-0.3.0",mousetrap:"libs/mousetrap-1.4.6",jssha256:"libs/jssha256-0.1",requestanimframe:"libs/requestanimframe-0.1",libjass:"libs/libjass-0.10.0",modernizr:"libs/modernizr-custom",jquery:"plex/base/initializers/configs/JQueryConfig",backbone:"plex/base/initializers/configs/BackboneConfig",marionette:"plex/base/initializers/configs/MarionetteConfig",handlebars:"plex/base/initializers/configs/HandlebarsConfig",soundmanager:"plex/base/initializers/configs/SoundManagerConfig",affix:"libs/bootstrap/affix",alert:"libs/bootstrap/alert",button:"libs/bootstrap/button",carousel:"libs/bootstrap/carousel",collapse:"libs/bootstrap/collapse",dropdown:"libs/bootstrap/dropdown",modal:"libs/bootstrap/modal",popover:"libs/bootstrap/popover",scrollspy:"libs/bootstrap/scrollspy",tab:"libs/bootstrap/tab",tooltip:"libs/bootstrap/tooltip",transition:"libs/bootstrap/transition",qwebchannel:"libs/qwebchannel"},shim:{hb:["handlebars"],"handlebars-lib":{exports:"Handlebars"},googledash:{exports:"googledash"},jwplayer:{exports:"jwplayer"},swfobject:{exports:"swfobject"},x2js:{exports:"X2JS"},moment:{exports:"moment"},"chrome-analytics":{exports:"analytics"},"google-analytics":{exports:"ga"},bugsense:{exports:"Bugsense"},"jquery.freefocus":["jquery"],"jquery.translate":["jquery"],"jquery.mousewheel":["jquery"],sortable:{exports:"Sortable"},modernizr:{exports:"Modernizr"},qwebchannel:{exports:"QWebChannel"},affix:["jquery"],alert:["jquery"],button:["jquery"],carousel:["jquery"],collapse:["jquery"],dropdown:["jquery"],modal:["jquery"],scrollspy:["jquery"],tab:["jquery"],tooltip:["jquery"],popover:["jquery","tooltip"],transition:["jquery"]}}),define("config/require.conf",function(){}),function(){var e=this,t=e._,i={},n=Array.prototype,s=Object.prototype,a=Function.prototype,r=n.push,o=n.slice,l=n.concat,c=s.toString,d=s.hasOwnProperty,u=n.forEach,h=n.map,p=n.reduce,m=n.reduceRight,f=n.filter,g=n.every,v=n.some,y=n.indexOf,b=n.lastIndexOf,w=Array.isArray,x=Object.keys,k=a.bind,S=function(e){return e instanceof S?e:this instanceof S?void(this._wrapped=e):new S(e)
};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=S),exports._=S):e._=S,S.VERSION="1.6.0";var C=S.each=S.forEach=function(e,t,n){if(null==e)return e;if(u&&e.forEach===u)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,a=e.length;a>s;s++)if(t.call(n,e[s],s,e)===i)return}else for(var r=S.keys(e),s=0,a=r.length;a>s;s++)if(t.call(n,e[r[s]],r[s],e)===i)return;return e};S.map=S.collect=function(e,t,i){var n=[];return null==e?n:h&&e.map===h?e.map(t,i):(C(e,function(e,s,a){n.push(t.call(i,e,s,a))
}),n)};var P="Reduce of empty array with no initial value";S.reduce=S.foldl=S.inject=function(e,t,i,n){var s=arguments.length>2;if(null==e&&(e=[]),p&&e.reduce===p)return n&&(t=S.bind(t,n)),s?e.reduce(t,i):e.reduce(t);if(C(e,function(e,a,r){s?i=t.call(n,i,e,a,r):(i=e,s=!0)}),!s)throw new TypeError(P);return i},S.reduceRight=S.foldr=function(e,t,i,n){var s=arguments.length>2;if(null==e&&(e=[]),m&&e.reduceRight===m)return n&&(t=S.bind(t,n)),s?e.reduceRight(t,i):e.reduceRight(t);var a=e.length;if(a!==+a){var r=S.keys(e);
a=r.length}if(C(e,function(o,l,c){l=r?r[--a]:--a,s?i=t.call(n,i,e[l],l,c):(i=e[l],s=!0)}),!s)throw new TypeError(P);return i},S.find=S.detect=function(e,t,i){var n;return A(e,function(e,s,a){return t.call(i,e,s,a)?(n=e,!0):void 0}),n},S.filter=S.select=function(e,t,i){var n=[];return null==e?n:f&&e.filter===f?e.filter(t,i):(C(e,function(e,s,a){t.call(i,e,s,a)&&n.push(e)}),n)},S.reject=function(e,t,i){return S.filter(e,function(e,n,s){return!t.call(i,e,n,s)},i)},S.every=S.all=function(e,t,n){t||(t=S.identity);
var s=!0;return null==e?s:g&&e.every===g?e.every(t,n):(C(e,function(e,a,r){return(s=s&&t.call(n,e,a,r))?void 0:i}),!!s)};var A=S.some=S.any=function(e,t,n){t||(t=S.identity);var s=!1;return null==e?s:v&&e.some===v?e.some(t,n):(C(e,function(e,a,r){return s||(s=t.call(n,e,a,r))?i:void 0}),!!s)};S.contains=S.include=function(e,t){return null==e?!1:y&&e.indexOf===y?-1!=e.indexOf(t):A(e,function(e){return e===t})},S.invoke=function(e,t){var i=o.call(arguments,2),n=S.isFunction(t);return S.map(e,function(e){return(n?t:e[t]).apply(e,i)
})},S.pluck=function(e,t){return S.map(e,S.property(t))},S.where=function(e,t){return S.filter(e,S.matches(t))},S.findWhere=function(e,t){return S.find(e,S.matches(t))},S.max=function(e,t,i){if(!t&&S.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);var n=-1/0,s=-1/0;return C(e,function(e,a,r){var o=t?t.call(i,e,a,r):e;o>s&&(n=e,s=o)}),n},S.min=function(e,t,i){if(!t&&S.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);var n=1/0,s=1/0;return C(e,function(e,a,r){var o=t?t.call(i,e,a,r):e;
s>o&&(n=e,s=o)}),n},S.shuffle=function(e){var t,i=0,n=[];return C(e,function(e){t=S.random(i++),n[i-1]=n[t],n[t]=e}),n},S.sample=function(e,t,i){return null==t||i?(e.length!==+e.length&&(e=S.values(e)),e[S.random(e.length-1)]):S.shuffle(e).slice(0,Math.max(0,t))};var _=function(e){return null==e?S.identity:S.isFunction(e)?e:S.property(e)};S.sortBy=function(e,t,i){return t=_(t),S.pluck(S.map(e,function(e,n,s){return{value:e,index:n,criteria:t.call(i,e,n,s)}}).sort(function(e,t){var i=e.criteria,n=t.criteria;
if(i!==n){if(i>n||void 0===i)return 1;if(n>i||void 0===n)return-1}return e.index-t.index}),"value")};var I=function(e){return function(t,i,n){var s={};return i=_(i),C(t,function(a,r){var o=i.call(n,a,r,t);e(s,o,a)}),s}};S.groupBy=I(function(e,t,i){S.has(e,t)?e[t].push(i):e[t]=[i]}),S.indexBy=I(function(e,t,i){e[t]=i}),S.countBy=I(function(e,t){S.has(e,t)?e[t]++:e[t]=1}),S.sortedIndex=function(e,t,i,n){i=_(i);for(var s=i.call(n,t),a=0,r=e.length;r>a;){var o=a+r>>>1;i.call(n,e[o])<s?a=o+1:r=o}return a
},S.toArray=function(e){return e?S.isArray(e)?o.call(e):e.length===+e.length?S.map(e,S.identity):S.values(e):[]},S.size=function(e){return null==e?0:e.length===+e.length?e.length:S.keys(e).length},S.first=S.head=S.take=function(e,t,i){return null==e?void 0:null==t||i?e[0]:0>t?[]:o.call(e,0,t)},S.initial=function(e,t,i){return o.call(e,0,e.length-(null==t||i?1:t))},S.last=function(e,t,i){return null==e?void 0:null==t||i?e[e.length-1]:o.call(e,Math.max(e.length-t,0))},S.rest=S.tail=S.drop=function(e,t,i){return o.call(e,null==t||i?1:t)
},S.compact=function(e){return S.filter(e,S.identity)};var T=function(e,t,i){return t&&S.every(e,S.isArray)?l.apply(i,e):(C(e,function(e){S.isArray(e)||S.isArguments(e)?t?r.apply(i,e):T(e,t,i):i.push(e)}),i)};S.flatten=function(e,t){return T(e,t,[])},S.without=function(e){return S.difference(e,o.call(arguments,1))},S.partition=function(e,t,i){t=_(t);var n=[],s=[];return C(e,function(e){(t.call(i,e)?n:s).push(e)}),[n,s]},S.uniq=S.unique=function(e,t,i,n){S.isFunction(t)&&(n=i,i=t,t=!1);var s=i?S.map(e,i,n):e,a=[],r=[];
return C(s,function(i,n){(t?n&&r[r.length-1]===i:S.contains(r,i))||(r.push(i),a.push(e[n]))}),a},S.union=function(){return S.uniq(S.flatten(arguments,!0))},S.intersection=function(e){var t=o.call(arguments,1);return S.filter(S.uniq(e),function(e){return S.every(t,function(t){return S.contains(t,e)})})},S.difference=function(e){var t=l.apply(n,o.call(arguments,1));return S.filter(e,function(e){return!S.contains(t,e)})},S.zip=function(){for(var e=S.max(S.pluck(arguments,"length").concat(0)),t=new Array(e),i=0;e>i;i++)t[i]=S.pluck(arguments,""+i);
return t},S.object=function(e,t){if(null==e)return{};for(var i={},n=0,s=e.length;s>n;n++)t?i[e[n]]=t[n]:i[e[n][0]]=e[n][1];return i},S.indexOf=function(e,t,i){if(null==e)return-1;var n=0,s=e.length;if(i){if("number"!=typeof i)return n=S.sortedIndex(e,t),e[n]===t?n:-1;n=0>i?Math.max(0,s+i):i}if(y&&e.indexOf===y)return e.indexOf(t,i);for(;s>n;n++)if(e[n]===t)return n;return-1},S.lastIndexOf=function(e,t,i){if(null==e)return-1;var n=null!=i;if(b&&e.lastIndexOf===b)return n?e.lastIndexOf(t,i):e.lastIndexOf(t);
for(var s=n?i:e.length;s--;)if(e[s]===t)return s;return-1},S.range=function(e,t,i){arguments.length<=1&&(t=e||0,e=0),i=arguments[2]||1;for(var n=Math.max(Math.ceil((t-e)/i),0),s=0,a=new Array(n);n>s;)a[s++]=e,e+=i;return a};var M=function(){};S.bind=function(e,t){var i,n;if(k&&e.bind===k)return k.apply(e,o.call(arguments,1));if(!S.isFunction(e))throw new TypeError;return i=o.call(arguments,2),n=function(){if(!(this instanceof n))return e.apply(t,i.concat(o.call(arguments)));M.prototype=e.prototype;
var s=new M;M.prototype=null;var a=e.apply(s,i.concat(o.call(arguments)));return Object(a)===a?a:s}},S.partial=function(e){var t=o.call(arguments,1);return function(){for(var i=0,n=t.slice(),s=0,a=n.length;a>s;s++)n[s]===S&&(n[s]=arguments[i++]);for(;i<arguments.length;)n.push(arguments[i++]);return e.apply(this,n)}},S.bindAll=function(e){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return C(t,function(t){e[t]=S.bind(e[t],e)}),e},S.memoize=function(e,t){var i={};
return t||(t=S.identity),function(){var n=t.apply(this,arguments);return S.has(i,n)?i[n]:i[n]=e.apply(this,arguments)}},S.delay=function(e,t){var i=o.call(arguments,2);return setTimeout(function(){return e.apply(null,i)},t)},S.defer=function(e){return S.delay.apply(S,[e,1].concat(o.call(arguments,1)))},S.throttle=function(e,t,i){var n,s,a,r=null,o=0;i||(i={});var l=function(){o=i.leading===!1?0:S.now(),r=null,a=e.apply(n,s),n=s=null};return function(){var c=S.now();o||i.leading!==!1||(o=c);var d=t-(c-o);
return n=this,s=arguments,0>=d?(clearTimeout(r),r=null,o=c,a=e.apply(n,s),n=s=null):r||i.trailing===!1||(r=setTimeout(l,d)),a}},S.debounce=function(e,t,i){var n,s,a,r,o,l=function(){var c=S.now()-r;t>c?n=setTimeout(l,t-c):(n=null,i||(o=e.apply(a,s),a=s=null))};return function(){a=this,s=arguments,r=S.now();var c=i&&!n;return n||(n=setTimeout(l,t)),c&&(o=e.apply(a,s),a=s=null),o}},S.once=function(e){var t,i=!1;return function(){return i?t:(i=!0,t=e.apply(this,arguments),e=null,t)}},S.wrap=function(e,t){return S.partial(t,e)
},S.compose=function(){var e=arguments;return function(){for(var t=arguments,i=e.length-1;i>=0;i--)t=[e[i].apply(this,t)];return t[0]}},S.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},S.keys=function(e){if(!S.isObject(e))return[];if(x)return x(e);var t=[];for(var i in e)S.has(e,i)&&t.push(i);return t},S.values=function(e){for(var t=S.keys(e),i=t.length,n=new Array(i),s=0;i>s;s++)n[s]=e[t[s]];return n},S.pairs=function(e){for(var t=S.keys(e),i=t.length,n=new Array(i),s=0;i>s;s++)n[s]=[t[s],e[t[s]]];
return n},S.invert=function(e){for(var t={},i=S.keys(e),n=0,s=i.length;s>n;n++)t[e[i[n]]]=i[n];return t},S.functions=S.methods=function(e){var t=[];for(var i in e)S.isFunction(e[i])&&t.push(i);return t.sort()},S.extend=function(e){return C(o.call(arguments,1),function(t){if(t)for(var i in t)e[i]=t[i]}),e},S.pick=function(e){var t={},i=l.apply(n,o.call(arguments,1));return C(i,function(i){i in e&&(t[i]=e[i])}),t},S.omit=function(e){var t={},i=l.apply(n,o.call(arguments,1));for(var s in e)S.contains(i,s)||(t[s]=e[s]);
return t},S.defaults=function(e){return C(o.call(arguments,1),function(t){if(t)for(var i in t)void 0===e[i]&&(e[i]=t[i])}),e},S.clone=function(e){return S.isObject(e)?S.isArray(e)?e.slice():S.extend({},e):e},S.tap=function(e,t){return t(e),e};var D=function(e,t,i,n){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof S&&(e=e._wrapped),t instanceof S&&(t=t._wrapped);var s=c.call(e);if(s!=c.call(t))return!1;switch(s){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;
case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var a=i.length;a--;)if(i[a]==e)return n[a]==t;var r=e.constructor,o=t.constructor;if(r!==o&&!(S.isFunction(r)&&r instanceof r&&S.isFunction(o)&&o instanceof o)&&"constructor"in e&&"constructor"in t)return!1;i.push(e),n.push(t);var l=0,d=!0;if("[object Array]"==s){if(l=e.length,d=l==t.length)for(;l--&&(d=D(e[l],t[l],i,n)););}else{for(var u in e)if(S.has(e,u)&&(l++,!(d=S.has(t,u)&&D(e[u],t[u],i,n))))break;
if(d){for(u in t)if(S.has(t,u)&&!l--)break;d=!l}}return i.pop(),n.pop(),d};S.isEqual=function(e,t){return D(e,t,[],[])},S.isEmpty=function(e){if(null==e)return!0;if(S.isArray(e)||S.isString(e))return 0===e.length;for(var t in e)if(S.has(e,t))return!1;return!0},S.isElement=function(e){return!(!e||1!==e.nodeType)},S.isArray=w||function(e){return"[object Array]"==c.call(e)},S.isObject=function(e){return e===Object(e)},C(["Arguments","Function","String","Number","Date","RegExp"],function(e){S["is"+e]=function(t){return c.call(t)=="[object "+e+"]"
}}),S.isArguments(arguments)||(S.isArguments=function(e){return!(!e||!S.has(e,"callee"))}),"function"!=typeof/./&&(S.isFunction=function(e){return"function"==typeof e}),S.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},S.isNaN=function(e){return S.isNumber(e)&&e!=+e},S.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==c.call(e)},S.isNull=function(e){return null===e},S.isUndefined=function(e){return void 0===e},S.has=function(e,t){return d.call(e,t)},S.noConflict=function(){return e._=t,this
},S.identity=function(e){return e},S.constant=function(e){return function(){return e}},S.property=function(e){return function(t){return t[e]}},S.matches=function(e){return function(t){if(t===e)return!0;for(var i in e)if(e[i]!==t[i])return!1;return!0}},S.times=function(e,t,i){for(var n=Array(Math.max(0,e)),s=0;e>s;s++)n[s]=t.call(i,s);return n},S.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},S.now=Date.now||function(){return(new Date).getTime()};var E={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};
E.unescape=S.invert(E.escape);var L={escape:new RegExp("["+S.keys(E.escape).join("")+"]","g"),unescape:new RegExp("("+S.keys(E.unescape).join("|")+")","g")};S.each(["escape","unescape"],function(e){S[e]=function(t){return null==t?"":(""+t).replace(L[e],function(t){return E[e][t]})}}),S.result=function(e,t){if(null==e)return void 0;var i=e[t];return S.isFunction(i)?i.call(e):i},S.mixin=function(e){C(S.functions(e),function(t){var i=S[t]=e[t];S.prototype[t]=function(){var e=[this._wrapped];return r.apply(e,arguments),B.call(this,i.apply(S,e))
}})};var R=0;S.uniqueId=function(e){var t=++R+"";return e?e+t:t},S.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var O=/(.)^/,N={"'":"'","\\":"\\","\r":"r","\n":"n","	":"t","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\t|\u2028|\u2029/g;S.template=function(e,t,i){var n;i=S.defaults({},i,S.templateSettings);var s=new RegExp([(i.escape||O).source,(i.interpolate||O).source,(i.evaluate||O).source].join("|")+"|$","g"),a=0,r="__p+='";e.replace(s,function(t,i,n,s,o){return r+=e.slice(a,o).replace(F,function(e){return"\\"+N[e]
}),i&&(r+="'+\n((__t=("+i+"))==null?'':_.escape(__t))+\n'"),n&&(r+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),s&&(r+="';\n"+s+"\n__p+='"),a=o+t.length,t}),r+="';\n",i.variable||(r="with(obj||{}){\n"+r+"}\n"),r="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+r+"return __p;\n";try{n=new Function(i.variable||"obj","_",r)}catch(o){throw o.source=r,o}if(t)return n(t,S);var l=function(e){return n.call(this,e,S)};return l.source="function("+(i.variable||"obj")+"){\n"+r+"}",l
},S.chain=function(e){return S(e).chain()};var B=function(e){return this._chain?S(e).chain():e};S.mixin(S),C(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=n[e];S.prototype[e]=function(){var i=this._wrapped;return t.apply(i,arguments),"shift"!=e&&"splice"!=e||0!==i.length||delete i[0],B.call(this,i)}}),C(["concat","join","slice"],function(e){var t=n[e];S.prototype[e]=function(){return B.call(this,t.apply(this._wrapped,arguments))}}),S.extend(S.prototype,{chain:function(){return this._chain=!0,this
},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return S})}.call(this),function(e,t){function i(e){var t=e.length,i=dt.type(e);return dt.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===i||"function"!==i&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}function n(e){var t=Pt[e]={};return dt.each(e.match(ht)||[],function(e,i){t[i]=!0}),t}function s(e,i,n,s){if(dt.acceptData(e)){var a,r,o=dt.expando,l=e.nodeType,c=l?dt.cache:e,d=l?e[o]:e[o]&&o;
if(d&&c[d]&&(s||c[d].data)||n!==t||"string"!=typeof i)return d||(d=l?e[o]=tt.pop()||dt.guid++:o),c[d]||(c[d]=l?{}:{toJSON:dt.noop}),("object"==typeof i||"function"==typeof i)&&(s?c[d]=dt.extend(c[d],i):c[d].data=dt.extend(c[d].data,i)),r=c[d],s||(r.data||(r.data={}),r=r.data),n!==t&&(r[dt.camelCase(i)]=n),"string"==typeof i?(a=r[i],null==a&&(a=r[dt.camelCase(i)])):a=r,a}}function a(e,t,i){if(dt.acceptData(e)){var n,s,a=e.nodeType,r=a?dt.cache:e,l=a?e[dt.expando]:dt.expando;if(r[l]){if(t&&(n=i?r[l]:r[l].data)){dt.isArray(t)?t=t.concat(dt.map(t,dt.camelCase)):t in n?t=[t]:(t=dt.camelCase(t),t=t in n?[t]:t.split(" ")),s=t.length;
for(;s--;)delete n[t[s]];if(i?!o(n):!dt.isEmptyObject(n))return}(i||(delete r[l].data,o(r[l])))&&(a?dt.cleanData([e],!0):dt.support.deleteExpando||r!=r.window?delete r[l]:r[l]=null)}}}function r(e,i,n){if(n===t&&1===e.nodeType){var s="data-"+i.replace(_t,"-$1").toLowerCase();if(n=e.getAttribute(s),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:At.test(n)?dt.parseJSON(n):n}catch(a){}dt.data(e,i,n)}else n=t}return n}function o(e){var t;for(t in e)if(("data"!==t||!dt.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;
return!0}function l(){return!0}function c(){return!1}function d(){try{return X.activeElement}catch(e){}}function u(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function h(e,t,i){if(dt.isFunction(t))return dt.grep(e,function(e,n){return!!t.call(e,n,e)!==i});if(t.nodeType)return dt.grep(e,function(e){return e===t!==i});if("string"==typeof t){if(jt.test(t))return dt.filter(t,e,i);t=dt.filter(t,e)}return dt.grep(e,function(e){return dt.inArray(e,t)>=0!==i})}function p(e){var t=$t.split("|"),i=e.createDocumentFragment();
if(i.createElement)for(;t.length;)i.createElement(t.pop());return i}function m(e,t){return dt.nodeName(e,"table")&&dt.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function f(e){return e.type=(null!==dt.find.attr(e,"type"))+"/"+e.type,e}function g(e){var t=si.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function v(e,t){for(var i,n=0;null!=(i=e[n]);n++)dt._data(i,"globalEval",!t||dt._data(t[n],"globalEval"))
}function y(e,t){if(1===t.nodeType&&dt.hasData(e)){var i,n,s,a=dt._data(e),r=dt._data(t,a),o=a.events;if(o){delete r.handle,r.events={};for(i in o)for(n=0,s=o[i].length;s>n;n++)dt.event.add(t,i,o[i][n])}r.data&&(r.data=dt.extend({},r.data))}}function b(e,t){var i,n,s;if(1===t.nodeType){if(i=t.nodeName.toLowerCase(),!dt.support.noCloneEvent&&t[dt.expando]){s=dt._data(t);for(n in s.events)dt.removeEvent(t,n,s.handle);t.removeAttribute(dt.expando)}"script"===i&&t.text!==e.text?(f(t).text=e.text,g(t)):"object"===i?(t.parentNode&&(t.outerHTML=e.outerHTML),dt.support.html5Clone&&e.innerHTML&&!dt.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===i&&ti.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===i?t.defaultSelected=t.selected=e.defaultSelected:("input"===i||"textarea"===i)&&(t.defaultValue=e.defaultValue)
}}function w(e,i){var n,s,a=0,r=typeof e.getElementsByTagName!==Q?e.getElementsByTagName(i||"*"):typeof e.querySelectorAll!==Q?e.querySelectorAll(i||"*"):t;if(!r)for(r=[],n=e.childNodes||e;null!=(s=n[a]);a++)!i||dt.nodeName(s,i)?r.push(s):dt.merge(r,w(s,i));return i===t||i&&dt.nodeName(e,i)?dt.merge([e],r):r}function x(e){ti.test(e.type)&&(e.defaultChecked=e.checked)}function k(e,t){if(t in e)return t;for(var i=t.charAt(0).toUpperCase()+t.slice(1),n=t,s=Ci.length;s--;)if(t=Ci[s]+i,t in e)return t;
return n}function S(e,t){return e=t||e,"none"===dt.css(e,"display")||!dt.contains(e.ownerDocument,e)}function C(e,t){for(var i,n,s,a=[],r=0,o=e.length;o>r;r++)n=e[r],n.style&&(a[r]=dt._data(n,"olddisplay"),i=n.style.display,t?(a[r]||"none"!==i||(n.style.display=""),""===n.style.display&&S(n)&&(a[r]=dt._data(n,"olddisplay",I(n.nodeName)))):a[r]||(s=S(n),(i&&"none"!==i||!s)&&dt._data(n,"olddisplay",s?i:dt.css(n,"display"))));for(r=0;o>r;r++)n=e[r],n.style&&(t&&"none"!==n.style.display&&""!==n.style.display||(n.style.display=t?a[r]||"":"none"));
return e}function P(e,t,i){var n=vi.exec(t);return n?Math.max(0,n[1]-(i||0))+(n[2]||"px"):t}function A(e,t,i,n,s){for(var a=i===(n?"border":"content")?4:"width"===t?1:0,r=0;4>a;a+=2)"margin"===i&&(r+=dt.css(e,i+Si[a],!0,s)),n?("content"===i&&(r-=dt.css(e,"padding"+Si[a],!0,s)),"margin"!==i&&(r-=dt.css(e,"border"+Si[a]+"Width",!0,s))):(r+=dt.css(e,"padding"+Si[a],!0,s),"padding"!==i&&(r+=dt.css(e,"border"+Si[a]+"Width",!0,s)));return r}function _(e,t,i){var n=!0,s="width"===t?e.offsetWidth:e.offsetHeight,a=di(e),r=dt.support.boxSizing&&"border-box"===dt.css(e,"boxSizing",!1,a);
if(0>=s||null==s){if(s=ui(e,t,a),(0>s||null==s)&&(s=e.style[t]),yi.test(s))return s;n=r&&(dt.support.boxSizingReliable||s===e.style[t]),s=parseFloat(s)||0}return s+A(e,t,i||(r?"border":"content"),n,a)+"px"}function I(e){var t=X,i=wi[e];return i||(i=T(e,t),"none"!==i&&i||(ci=(ci||dt("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(ci[0].contentWindow||ci[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),i=T(e,t),ci.detach()),wi[e]=i),i
}function T(e,t){var i=dt(t.createElement(e)).appendTo(t.body),n=dt.css(i[0],"display");return i.remove(),n}function M(e,t,i,n){var s;if(dt.isArray(t))dt.each(t,function(t,s){i||Ai.test(e)?n(e,s):M(e+"["+("object"==typeof s?t:"")+"]",s,i,n)});else if(i||"object"!==dt.type(t))n(e,t);else for(s in t)M(e+"["+s+"]",t[s],i,n)}function D(e){return function(t,i){"string"!=typeof t&&(i=t,t="*");var n,s=0,a=t.toLowerCase().match(ht)||[];if(dt.isFunction(i))for(;n=a[s++];)"+"===n[0]?(n=n.slice(1)||"*",(e[n]=e[n]||[]).unshift(i)):(e[n]=e[n]||[]).push(i)
}}function E(e,t,i,n){function s(o){var l;return a[o]=!0,dt.each(e[o]||[],function(e,o){var c=o(t,i,n);return"string"!=typeof c||r||a[c]?r?!(l=c):void 0:(t.dataTypes.unshift(c),s(c),!1)}),l}var a={},r=e===qi;return s(t.dataTypes[0])||!a["*"]&&s("*")}function L(e,i){var n,s,a=dt.ajaxSettings.flatOptions||{};for(s in i)i[s]!==t&&((a[s]?e:n||(n={}))[s]=i[s]);return n&&dt.extend(!0,e,n),e}function R(e,i,n){for(var s,a,r,o,l=e.contents,c=e.dataTypes;"*"===c[0];)c.shift(),a===t&&(a=e.mimeType||i.getResponseHeader("Content-Type"));
if(a)for(o in l)if(l[o]&&l[o].test(a)){c.unshift(o);break}if(c[0]in n)r=c[0];else{for(o in n){if(!c[0]||e.converters[o+" "+c[0]]){r=o;break}s||(s=o)}r=r||s}return r?(r!==c[0]&&c.unshift(r),n[r]):void 0}function O(e,t,i,n){var s,a,r,o,l,c={},d=e.dataTypes.slice();if(d[1])for(r in e.converters)c[r.toLowerCase()]=e.converters[r];for(a=d.shift();a;)if(e.responseFields[a]&&(i[e.responseFields[a]]=t),!l&&n&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=a,a=d.shift())if("*"===a)a=l;else if("*"!==l&&l!==a){if(r=c[l+" "+a]||c["* "+a],!r)for(s in c)if(o=s.split(" "),o[1]===a&&(r=c[l+" "+o[0]]||c["* "+o[0]])){r===!0?r=c[s]:c[s]!==!0&&(a=o[0],d.unshift(o[1]));
break}if(r!==!0)if(r&&e["throws"])t=r(t);else try{t=r(t)}catch(u){return{state:"parsererror",error:r?u:"No conversion from "+l+" to "+a}}}return{state:"success",data:t}}function N(){try{return new e.XMLHttpRequest}catch(t){}}function F(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function B(){return setTimeout(function(){Ji=t}),Ji=dt.now()}function U(e,t,i){for(var n,s=(an[t]||[]).concat(an["*"]),a=0,r=s.length;r>a;a++)if(n=s[a].call(i,t,e))return n}function V(e,t,i){var n,s,a=0,r=sn.length,o=dt.Deferred().always(function(){delete l.elem
}),l=function(){if(s)return!1;for(var t=Ji||B(),i=Math.max(0,c.startTime+c.duration-t),n=i/c.duration||0,a=1-n,r=0,l=c.tweens.length;l>r;r++)c.tweens[r].run(a);return o.notifyWith(e,[c,a,i]),1>a&&l?i:(o.resolveWith(e,[c]),!1)},c=o.promise({elem:e,props:dt.extend({},t),opts:dt.extend(!0,{specialEasing:{}},i),originalProperties:t,originalOptions:i,startTime:Ji||B(),duration:i.duration,tweens:[],createTween:function(t,i){var n=dt.Tween(e,c.opts,t,i,c.opts.specialEasing[t]||c.opts.easing);return c.tweens.push(n),n
},stop:function(t){var i=0,n=t?c.tweens.length:0;if(s)return this;for(s=!0;n>i;i++)c.tweens[i].run(1);return t?o.resolveWith(e,[c,t]):o.rejectWith(e,[c,t]),this}}),d=c.props;for(z(d,c.opts.specialEasing);r>a;a++)if(n=sn[a].call(c,e,d,c.opts))return n;return dt.map(d,U,c),dt.isFunction(c.opts.start)&&c.opts.start.call(e,c),dt.fx.timer(dt.extend(l,{elem:e,anim:c,queue:c.opts.queue})),c.progress(c.opts.progress).done(c.opts.done,c.opts.complete).fail(c.opts.fail).always(c.opts.always)}function z(e,t){var i,n,s,a,r;
for(i in e)if(n=dt.camelCase(i),s=t[n],a=e[i],dt.isArray(a)&&(s=a[1],a=e[i]=a[0]),i!==n&&(e[n]=a,delete e[i]),r=dt.cssHooks[n],r&&"expand"in r){a=r.expand(a),delete e[n];for(i in a)i in e||(e[i]=a[i],t[i]=s)}else t[n]=s}function j(e,t,i){var n,s,a,r,o,l,c=this,d={},u=e.style,h=e.nodeType&&S(e),p=dt._data(e,"fxshow");i.queue||(o=dt._queueHooks(e,"fx"),null==o.unqueued&&(o.unqueued=0,l=o.empty.fire,o.empty.fire=function(){o.unqueued||l()}),o.unqueued++,c.always(function(){c.always(function(){o.unqueued--,dt.queue(e,"fx").length||o.empty.fire()
})})),1===e.nodeType&&("height"in t||"width"in t)&&(i.overflow=[u.overflow,u.overflowX,u.overflowY],"inline"===dt.css(e,"display")&&"none"===dt.css(e,"float")&&(dt.support.inlineBlockNeedsLayout&&"inline"!==I(e.nodeName)?u.zoom=1:u.display="inline-block")),i.overflow&&(u.overflow="hidden",dt.support.shrinkWrapBlocks||c.always(function(){u.overflow=i.overflow[0],u.overflowX=i.overflow[1],u.overflowY=i.overflow[2]}));for(n in t)if(s=t[n],en.exec(s)){if(delete t[n],a=a||"toggle"===s,s===(h?"hide":"show"))continue;
d[n]=p&&p[n]||dt.style(e,n)}if(!dt.isEmptyObject(d)){p?"hidden"in p&&(h=p.hidden):p=dt._data(e,"fxshow",{}),a&&(p.hidden=!h),h?dt(e).show():c.done(function(){dt(e).hide()}),c.done(function(){var t;dt._removeData(e,"fxshow");for(t in d)dt.style(e,t,d[t])});for(n in d)r=U(h?p[n]:0,n,c),n in p||(p[n]=r.start,h&&(r.end=r.start,r.start="width"===n||"height"===n?1:0))}}function q(e,t,i,n,s){return new q.prototype.init(e,t,i,n,s)}function H(e,t){var i,n={height:e},s=0;for(t=t?1:0;4>s;s+=2-t)i=Si[s],n["margin"+i]=n["padding"+i]=e;
return t&&(n.opacity=n.width=e),n}function W(e){return dt.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}var $,Y,Q=typeof t,K=e.location,X=e.document,G=X.documentElement,J=e.jQuery,Z=e.$,et={},tt=[],it="1.10.2",nt=tt.concat,st=tt.push,at=tt.slice,rt=tt.indexOf,ot=et.toString,lt=et.hasOwnProperty,ct=it.trim,dt=function(e,t){return new dt.fn.init(e,t,Y)},ut=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ht=/\S+/g,pt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,mt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,ft=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,gt=/^[\],:{}\s]*$/,vt=/(?:^|:|,)(?:\s*\[)+/g,yt=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,bt=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,wt=/^-ms-/,xt=/-([\da-z])/gi,kt=function(e,t){return t.toUpperCase()
},St=function(e){(X.addEventListener||"load"===e.type||"complete"===X.readyState)&&(Ct(),dt.ready())},Ct=function(){X.addEventListener?(X.removeEventListener("DOMContentLoaded",St,!1),e.removeEventListener("load",St,!1)):(X.detachEvent("onreadystatechange",St),e.detachEvent("onload",St))};dt.fn=dt.prototype={jquery:it,constructor:dt,init:function(e,i,n){var s,a;if(!e)return this;if("string"==typeof e){if(s="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:mt.exec(e),!s||!s[1]&&i)return!i||i.jquery?(i||n).find(e):this.constructor(i).find(e);
if(s[1]){if(i=i instanceof dt?i[0]:i,dt.merge(this,dt.parseHTML(s[1],i&&i.nodeType?i.ownerDocument||i:X,!0)),ft.test(s[1])&&dt.isPlainObject(i))for(s in i)dt.isFunction(this[s])?this[s](i[s]):this.attr(s,i[s]);return this}if(a=X.getElementById(s[2]),a&&a.parentNode){if(a.id!==s[2])return n.find(e);this.length=1,this[0]=a}return this.context=X,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):dt.isFunction(e)?n.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),dt.makeArray(e,this))
},selector:"",length:0,toArray:function(){return at.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=dt.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return dt.each(this,e,t)},ready:function(e){return dt.ready.promise().done(e),this},slice:function(){return this.pushStack(at.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,i=+e+(0>e?t:0);
return this.pushStack(i>=0&&t>i?[this[i]]:[])},map:function(e){return this.pushStack(dt.map(this,function(t,i){return e.call(t,i,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:st,sort:[].sort,splice:[].splice},dt.fn.init.prototype=dt.fn,dt.extend=dt.fn.extend=function(){var e,i,n,s,a,r,o=arguments[0]||{},l=1,c=arguments.length,d=!1;for("boolean"==typeof o&&(d=o,o=arguments[1]||{},l=2),"object"==typeof o||dt.isFunction(o)||(o={}),c===l&&(o=this,--l);c>l;l++)if(null!=(a=arguments[l]))for(s in a)e=o[s],n=a[s],o!==n&&(d&&n&&(dt.isPlainObject(n)||(i=dt.isArray(n)))?(i?(i=!1,r=e&&dt.isArray(e)?e:[]):r=e&&dt.isPlainObject(e)?e:{},o[s]=dt.extend(d,r,n)):n!==t&&(o[s]=n));
return o},dt.extend({expando:"jQuery"+(it+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===dt&&(e.$=Z),t&&e.jQuery===dt&&(e.jQuery=J),dt},isReady:!1,readyWait:1,holdReady:function(e){e?dt.readyWait++:dt.ready(!0)},ready:function(e){if(e===!0?!--dt.readyWait:!dt.isReady){if(!X.body)return setTimeout(dt.ready);dt.isReady=!0,e!==!0&&--dt.readyWait>0||($.resolveWith(X,[dt]),dt.fn.trigger&&dt(X).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===dt.type(e)},isArray:Array.isArray||function(e){return"array"===dt.type(e)
},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?String(e):"object"==typeof e||"function"==typeof e?et[ot.call(e)]||"object":typeof e},isPlainObject:function(e){var i;if(!e||"object"!==dt.type(e)||e.nodeType||dt.isWindow(e))return!1;try{if(e.constructor&&!lt.call(e,"constructor")&&!lt.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(dt.support.ownLast)for(i in e)return lt.call(e,i);
for(i in e);return i===t||lt.call(e,i)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,i){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(i=t,t=!1),t=t||X;var n=ft.exec(e),s=!i&&[];return n?[t.createElement(n[1])]:(n=dt.buildFragment([e],t,s),s&&dt(s).remove(),dt.merge([],n.childNodes))},parseJSON:function(t){return e.JSON&&e.JSON.parse?e.JSON.parse(t):null===t?t:"string"==typeof t&&(t=dt.trim(t),t&&gt.test(t.replace(yt,"@").replace(bt,"]").replace(vt,"")))?new Function("return "+t)():void dt.error("Invalid JSON: "+t)
},parseXML:function(i){var n,s;if(!i||"string"!=typeof i)return null;try{e.DOMParser?(s=new DOMParser,n=s.parseFromString(i,"text/xml")):(n=new ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(i))}catch(a){n=t}return n&&n.documentElement&&!n.getElementsByTagName("parsererror").length||dt.error("Invalid XML: "+i),n},noop:function(){},globalEval:function(t){t&&dt.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(wt,"ms-").replace(xt,kt)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()
},each:function(e,t,n){var s,a=0,r=e.length,o=i(e);if(n){if(o)for(;r>a&&(s=t.apply(e[a],n),s!==!1);a++);else for(a in e)if(s=t.apply(e[a],n),s===!1)break}else if(o)for(;r>a&&(s=t.call(e[a],a,e[a]),s!==!1);a++);else for(a in e)if(s=t.call(e[a],a,e[a]),s===!1)break;return e},trim:ct&&!ct.call("\ufeff\xa0")?function(e){return null==e?"":ct.call(e)}:function(e){return null==e?"":(e+"").replace(pt,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(i(Object(e))?dt.merge(n,"string"==typeof e?[e]:e):st.call(n,e)),n
},inArray:function(e,t,i){var n;if(t){if(rt)return rt.call(t,e,i);for(n=t.length,i=i?0>i?Math.max(0,n+i):i:0;n>i;i++)if(i in t&&t[i]===e)return i}return-1},merge:function(e,i){var n=i.length,s=e.length,a=0;if("number"==typeof n)for(;n>a;a++)e[s++]=i[a];else for(;i[a]!==t;)e[s++]=i[a++];return e.length=s,e},grep:function(e,t,i){var n,s=[],a=0,r=e.length;for(i=!!i;r>a;a++)n=!!t(e[a],a),i!==n&&s.push(e[a]);return s},map:function(e,t,n){var s,a=0,r=e.length,o=i(e),l=[];if(o)for(;r>a;a++)s=t(e[a],a,n),null!=s&&(l[l.length]=s);
else for(a in e)s=t(e[a],a,n),null!=s&&(l[l.length]=s);return nt.apply([],l)},guid:1,proxy:function(e,i){var n,s,a;return"string"==typeof i&&(a=e[i],i=e,e=a),dt.isFunction(e)?(n=at.call(arguments,2),s=function(){return e.apply(i||this,n.concat(at.call(arguments)))},s.guid=e.guid=e.guid||dt.guid++,s):t},access:function(e,i,n,s,a,r,o){var l=0,c=e.length,d=null==n;if("object"===dt.type(n)){a=!0;for(l in n)dt.access(e,i,l,n[l],!0,r,o)}else if(s!==t&&(a=!0,dt.isFunction(s)||(o=!0),d&&(o?(i.call(e,s),i=null):(d=i,i=function(e,t,i){return d.call(dt(e),i)
})),i))for(;c>l;l++)i(e[l],n,o?s:s.call(e[l],l,i(e[l],n)));return a?e:d?i.call(e):c?i(e[0],n):r},now:function(){return(new Date).getTime()},swap:function(e,t,i,n){var s,a,r={};for(a in t)r[a]=e.style[a],e.style[a]=t[a];s=i.apply(e,n||[]);for(a in t)e.style[a]=r[a];return s}}),dt.ready.promise=function(t){if(!$)if($=dt.Deferred(),"complete"===X.readyState)setTimeout(dt.ready);else if(X.addEventListener)X.addEventListener("DOMContentLoaded",St,!1),e.addEventListener("load",St,!1);else{X.attachEvent("onreadystatechange",St),e.attachEvent("onload",St);
var i=!1;try{i=null==e.frameElement&&X.documentElement}catch(n){}i&&i.doScroll&&!function s(){if(!dt.isReady){try{i.doScroll("left")}catch(e){return setTimeout(s,50)}Ct(),dt.ready()}}()}return $.promise(t)},dt.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){et["[object "+t+"]"]=t.toLowerCase()}),Y=dt(X),function(e,t){function i(e,t,i,n){var s,a,r,o,l,c,d,u,m,f;if((t?t.ownerDocument||t:V)!==E&&D(t),t=t||E,i=i||[],!e||"string"!=typeof e)return i;if(1!==(o=t.nodeType)&&9!==o)return[];
if(R&&!n){if(s=bt.exec(e))if(r=s[1]){if(9===o){if(a=t.getElementById(r),!a||!a.parentNode)return i;if(a.id===r)return i.push(a),i}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(r))&&B(t,a)&&a.id===r)return i.push(a),i}else{if(s[2])return et.apply(i,t.getElementsByTagName(e)),i;if((r=s[3])&&S.getElementsByClassName&&t.getElementsByClassName)return et.apply(i,t.getElementsByClassName(r)),i}if(S.qsa&&(!O||!O.test(e))){if(u=d=U,m=t,f=9===o&&e,1===o&&"object"!==t.nodeName.toLowerCase()){for(c=h(e),(d=t.getAttribute("id"))?u=d.replace(kt,"\\$&"):t.setAttribute("id",u),u="[id='"+u+"'] ",l=c.length;l--;)c[l]=u+p(c[l]);
m=pt.test(e)&&t.parentNode||t,f=c.join(",")}if(f)try{return et.apply(i,m.querySelectorAll(f)),i}catch(g){}finally{d||t.removeAttribute("id")}}}return x(e.replace(ct,"$1"),t,i,n)}function n(){function e(i,n){return t.push(i+=" ")>P.cacheLength&&delete e[t.shift()],e[i]=n}var t=[];return e}function s(e){return e[U]=!0,e}function a(e){var t=E.createElement("div");try{return!!e(t)}catch(i){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function r(e,t){for(var i=e.split("|"),n=e.length;n--;)P.attrHandle[i[n]]=t
}function o(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||K)-(~e.sourceIndex||K);if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function l(e){return function(t){var i=t.nodeName.toLowerCase();return"input"===i&&t.type===e}}function c(e){return function(t){var i=t.nodeName.toLowerCase();return("input"===i||"button"===i)&&t.type===e}}function d(e){return s(function(t){return t=+t,s(function(i,n){for(var s,a=e([],i.length,t),r=a.length;r--;)i[s=a[r]]&&(i[s]=!(n[s]=i[s]))
})})}function u(){}function h(e,t){var n,s,a,r,o,l,c,d=H[e+" "];if(d)return t?0:d.slice(0);for(o=e,l=[],c=P.preFilter;o;){(!n||(s=ut.exec(o)))&&(s&&(o=o.slice(s[0].length)||o),l.push(a=[])),n=!1,(s=ht.exec(o))&&(n=s.shift(),a.push({value:n,type:s[0].replace(ct," ")}),o=o.slice(n.length));for(r in P.filter)!(s=vt[r].exec(o))||c[r]&&!(s=c[r](s))||(n=s.shift(),a.push({value:n,type:r,matches:s}),o=o.slice(n.length));if(!n)break}return t?o.length:o?i.error(e):H(e,l).slice(0)}function p(e){for(var t=0,i=e.length,n="";i>t;t++)n+=e[t].value;
return n}function m(e,t,i){var n=t.dir,s=i&&"parentNode"===n,a=j++;return t.first?function(t,i,a){for(;t=t[n];)if(1===t.nodeType||s)return e(t,i,a)}:function(t,i,r){var o,l,c,d=z+" "+a;if(r){for(;t=t[n];)if((1===t.nodeType||s)&&e(t,i,r))return!0}else for(;t=t[n];)if(1===t.nodeType||s)if(c=t[U]||(t[U]={}),(l=c[n])&&l[0]===d){if((o=l[1])===!0||o===C)return o===!0}else if(l=c[n]=[d],l[1]=e(t,i,r)||C,l[1]===!0)return!0}}function f(e){return e.length>1?function(t,i,n){for(var s=e.length;s--;)if(!e[s](t,i,n))return!1;
return!0}:e[0]}function g(e,t,i,n,s){for(var a,r=[],o=0,l=e.length,c=null!=t;l>o;o++)(a=e[o])&&(!i||i(a,n,s))&&(r.push(a),c&&t.push(o));return r}function v(e,t,i,n,a,r){return n&&!n[U]&&(n=v(n)),a&&!a[U]&&(a=v(a,r)),s(function(s,r,o,l){var c,d,u,h=[],p=[],m=r.length,f=s||w(t||"*",o.nodeType?[o]:o,[]),v=!e||!s&&t?f:g(f,h,e,o,l),y=i?a||(s?e:m||n)?[]:r:v;if(i&&i(v,y,o,l),n)for(c=g(y,p),n(c,[],o,l),d=c.length;d--;)(u=c[d])&&(y[p[d]]=!(v[p[d]]=u));if(s){if(a||e){if(a){for(c=[],d=y.length;d--;)(u=y[d])&&c.push(v[d]=u);
a(null,y=[],c,l)}for(d=y.length;d--;)(u=y[d])&&(c=a?it.call(s,u):h[d])>-1&&(s[c]=!(r[c]=u))}}else y=g(y===r?y.splice(m,y.length):y),a?a(null,r,y,l):et.apply(r,y)})}function y(e){for(var t,i,n,s=e.length,a=P.relative[e[0].type],r=a||P.relative[" "],o=a?1:0,l=m(function(e){return e===t},r,!0),c=m(function(e){return it.call(t,e)>-1},r,!0),d=[function(e,i,n){return!a&&(n||i!==T)||((t=i).nodeType?l(e,i,n):c(e,i,n))}];s>o;o++)if(i=P.relative[e[o].type])d=[m(f(d),i)];else{if(i=P.filter[e[o].type].apply(null,e[o].matches),i[U]){for(n=++o;s>n&&!P.relative[e[n].type];n++);return v(o>1&&f(d),o>1&&p(e.slice(0,o-1).concat({value:" "===e[o-2].type?"*":""})).replace(ct,"$1"),i,n>o&&y(e.slice(o,n)),s>n&&y(e=e.slice(n)),s>n&&p(e))
}d.push(i)}return f(d)}function b(e,t){var n=0,a=t.length>0,r=e.length>0,o=function(s,o,l,c,d){var u,h,p,m=[],f=0,v="0",y=s&&[],b=null!=d,w=T,x=s||r&&P.find.TAG("*",d&&o.parentNode||o),k=z+=null==w?1:Math.random()||.1;for(b&&(T=o!==E&&o,C=n);null!=(u=x[v]);v++){if(r&&u){for(h=0;p=e[h++];)if(p(u,o,l)){c.push(u);break}b&&(z=k,C=++n)}a&&((u=!p&&u)&&f--,s&&y.push(u))}if(f+=v,a&&v!==f){for(h=0;p=t[h++];)p(y,m,o,l);if(s){if(f>0)for(;v--;)y[v]||m[v]||(m[v]=J.call(c));m=g(m)}et.apply(c,m),b&&!s&&m.length>0&&f+t.length>1&&i.uniqueSort(c)
}return b&&(z=k,T=w),y};return a?s(o):o}function w(e,t,n){for(var s=0,a=t.length;a>s;s++)i(e,t[s],n);return n}function x(e,t,i,n){var s,a,r,o,l,c=h(e);if(!n&&1===c.length){if(a=c[0]=c[0].slice(0),a.length>2&&"ID"===(r=a[0]).type&&S.getById&&9===t.nodeType&&R&&P.relative[a[1].type]){if(t=(P.find.ID(r.matches[0].replace(St,Ct),t)||[])[0],!t)return i;e=e.slice(a.shift().value.length)}for(s=vt.needsContext.test(e)?0:a.length;s--&&(r=a[s],!P.relative[o=r.type]);)if((l=P.find[o])&&(n=l(r.matches[0].replace(St,Ct),pt.test(a[0].type)&&t.parentNode||t))){if(a.splice(s,1),e=n.length&&p(a),!e)return et.apply(i,n),i;
break}}return I(e,c)(n,t,!R,i,pt.test(e)),i}var k,S,C,P,A,_,I,T,M,D,E,L,R,O,N,F,B,U="sizzle"+-new Date,V=e.document,z=0,j=0,q=n(),H=n(),W=n(),$=!1,Y=function(e,t){return e===t?($=!0,0):0},Q=typeof t,K=1<<31,X={}.hasOwnProperty,G=[],J=G.pop,Z=G.push,et=G.push,tt=G.slice,it=G.indexOf||function(e){for(var t=0,i=this.length;i>t;t++)if(this[t]===e)return t;return-1},nt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",st="[\\x20\\t\\r\\n\\f]",at="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",rt=at.replace("w","w#"),ot="\\["+st+"*("+at+")"+st+"*(?:([*^$|!~]?=)"+st+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+rt+")|)|)"+st+"*\\]",lt=":("+at+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+ot.replace(3,8)+")*)|.*)\\)|)",ct=new RegExp("^"+st+"+|((?:^|[^\\\\])(?:\\\\.)*)"+st+"+$","g"),ut=new RegExp("^"+st+"*,"+st+"*"),ht=new RegExp("^"+st+"*([>+~]|"+st+")"+st+"*"),pt=new RegExp(st+"*[+~]"),mt=new RegExp("="+st+"*([^\\]'\"]*)"+st+"*\\]","g"),ft=new RegExp(lt),gt=new RegExp("^"+rt+"$"),vt={ID:new RegExp("^#("+at+")"),CLASS:new RegExp("^\\.("+at+")"),TAG:new RegExp("^("+at.replace("w","w*")+")"),ATTR:new RegExp("^"+ot),PSEUDO:new RegExp("^"+lt),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+st+"*(even|odd|(([+-]|)(\\d*)n|)"+st+"*(?:([+-]|)"+st+"*(\\d+)|))"+st+"*\\)|)","i"),bool:new RegExp("^(?:"+nt+")$","i"),needsContext:new RegExp("^"+st+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+st+"*((?:-\\d)?\\d*)"+st+"*\\)|)(?=[^-]|$)","i")},yt=/^[^{]+\{\s*\[native \w/,bt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,wt=/^(?:input|select|textarea|button)$/i,xt=/^h\d$/i,kt=/'|\\/g,St=new RegExp("\\\\([\\da-f]{1,6}"+st+"?|("+st+")|.)","ig"),Ct=function(e,t,i){var n="0x"+t-65536;
return n!==n||i?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)};try{et.apply(G=tt.call(V.childNodes),V.childNodes),G[V.childNodes.length].nodeType}catch(Pt){et={apply:G.length?function(e,t){Z.apply(e,tt.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}_=i.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},S=i.support={},D=i.setDocument=function(e){var t=e?e.ownerDocument||e:V,i=t.defaultView;
return t!==E&&9===t.nodeType&&t.documentElement?(E=t,L=t.documentElement,R=!_(t),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){D()}),S.attributes=a(function(e){return e.className="i",!e.getAttribute("className")}),S.getElementsByTagName=a(function(e){return e.appendChild(t.createComment("")),!e.getElementsByTagName("*").length}),S.getElementsByClassName=a(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length
}),S.getById=a(function(e){return L.appendChild(e).id=U,!t.getElementsByName||!t.getElementsByName(U).length}),S.getById?(P.find.ID=function(e,t){if(typeof t.getElementById!==Q&&R){var i=t.getElementById(e);return i&&i.parentNode?[i]:[]}},P.filter.ID=function(e){var t=e.replace(St,Ct);return function(e){return e.getAttribute("id")===t}}):(delete P.find.ID,P.filter.ID=function(e){var t=e.replace(St,Ct);return function(e){var i=typeof e.getAttributeNode!==Q&&e.getAttributeNode("id");return i&&i.value===t
}}),P.find.TAG=S.getElementsByTagName?function(e,t){return typeof t.getElementsByTagName!==Q?t.getElementsByTagName(e):void 0}:function(e,t){var i,n=[],s=0,a=t.getElementsByTagName(e);if("*"===e){for(;i=a[s++];)1===i.nodeType&&n.push(i);return n}return a},P.find.CLASS=S.getElementsByClassName&&function(e,t){return typeof t.getElementsByClassName!==Q&&R?t.getElementsByClassName(e):void 0},N=[],O=[],(S.qsa=yt.test(t.querySelectorAll))&&(a(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||O.push("\\["+st+"*(?:value|"+nt+")"),e.querySelectorAll(":checked").length||O.push(":checked")
}),a(function(e){var i=t.createElement("input");i.setAttribute("type","hidden"),e.appendChild(i).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&O.push("[*^$]="+st+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||O.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),O.push(",.*:")})),(S.matchesSelector=yt.test(F=L.webkitMatchesSelector||L.mozMatchesSelector||L.oMatchesSelector||L.msMatchesSelector))&&a(function(e){S.disconnectedMatch=F.call(e,"div"),F.call(e,"[s!='']:x"),N.push("!=",lt)
}),O=O.length&&new RegExp(O.join("|")),N=N.length&&new RegExp(N.join("|")),B=yt.test(L.contains)||L.compareDocumentPosition?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},Y=L.compareDocumentPosition?function(e,i){if(e===i)return $=!0,0;var n=i.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(i);
return n?1&n||!S.sortDetached&&i.compareDocumentPosition(e)===n?e===t||B(V,e)?-1:i===t||B(V,i)?1:M?it.call(M,e)-it.call(M,i):0:4&n?-1:1:e.compareDocumentPosition?-1:1}:function(e,i){var n,s=0,a=e.parentNode,r=i.parentNode,l=[e],c=[i];if(e===i)return $=!0,0;if(!a||!r)return e===t?-1:i===t?1:a?-1:r?1:M?it.call(M,e)-it.call(M,i):0;if(a===r)return o(e,i);for(n=e;n=n.parentNode;)l.unshift(n);for(n=i;n=n.parentNode;)c.unshift(n);for(;l[s]===c[s];)s++;return s?o(l[s],c[s]):l[s]===V?-1:c[s]===V?1:0},t):E
},i.matches=function(e,t){return i(e,null,null,t)},i.matchesSelector=function(e,t){if((e.ownerDocument||e)!==E&&D(e),t=t.replace(mt,"='$1']"),!(!S.matchesSelector||!R||N&&N.test(t)||O&&O.test(t)))try{var n=F.call(e,t);if(n||S.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(s){}return i(t,E,null,[e]).length>0},i.contains=function(e,t){return(e.ownerDocument||e)!==E&&D(e),B(e,t)},i.attr=function(e,i){(e.ownerDocument||e)!==E&&D(e);var n=P.attrHandle[i.toLowerCase()],s=n&&X.call(P.attrHandle,i.toLowerCase())?n(e,i,!R):t;
return s===t?S.attributes||!R?e.getAttribute(i):(s=e.getAttributeNode(i))&&s.specified?s.value:null:s},i.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},i.uniqueSort=function(e){var t,i=[],n=0,s=0;if($=!S.detectDuplicates,M=!S.sortStable&&e.slice(0),e.sort(Y),$){for(;t=e[s++];)t===e[s]&&(n=i.push(s));for(;n--;)e.splice(i[n],1)}return e},A=i.getText=function(e){var t,i="",n=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if("string"==typeof e.textContent)return e.textContent;
for(e=e.firstChild;e;e=e.nextSibling)i+=A(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[n];n++)i+=A(t);return i},P=i.selectors={cacheLength:50,createPseudo:s,match:vt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(St,Ct),e[3]=(e[4]||e[5]||"").replace(St,Ct),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||i.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&i.error(e[0]),e
},PSEUDO:function(e){var i,n=!e[5]&&e[2];return vt.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:n&&ft.test(n)&&(i=h(n,!0))&&(i=n.indexOf(")",n.length-i)-n.length)&&(e[0]=e[0].slice(0,i),e[2]=n.slice(0,i)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(St,Ct).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=q[e+" "];return t||(t=new RegExp("(^|"+st+")"+e+"("+st+"|$)"))&&q(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==Q&&e.getAttribute("class")||"")
})},ATTR:function(e,t,n){return function(s){var a=i.attr(s,e);return null==a?"!="===t:t?(a+="","="===t?a===n:"!="===t?a!==n:"^="===t?n&&0===a.indexOf(n):"*="===t?n&&a.indexOf(n)>-1:"$="===t?n&&a.slice(-n.length)===n:"~="===t?(" "+a+" ").indexOf(n)>-1:"|="===t?a===n||a.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,i,n,s){var a="nth"!==e.slice(0,3),r="last"!==e.slice(-4),o="of-type"===t;return 1===n&&0===s?function(e){return!!e.parentNode}:function(t,i,l){var c,d,u,h,p,m,f=a!==r?"nextSibling":"previousSibling",g=t.parentNode,v=o&&t.nodeName.toLowerCase(),y=!l&&!o;
if(g){if(a){for(;f;){for(u=t;u=u[f];)if(o?u.nodeName.toLowerCase()===v:1===u.nodeType)return!1;m=f="only"===e&&!m&&"nextSibling"}return!0}if(m=[r?g.firstChild:g.lastChild],r&&y){for(d=g[U]||(g[U]={}),c=d[e]||[],p=c[0]===z&&c[1],h=c[0]===z&&c[2],u=p&&g.childNodes[p];u=++p&&u&&u[f]||(h=p=0)||m.pop();)if(1===u.nodeType&&++h&&u===t){d[e]=[z,p,h];break}}else if(y&&(c=(t[U]||(t[U]={}))[e])&&c[0]===z)h=c[1];else for(;(u=++p&&u&&u[f]||(h=p=0)||m.pop())&&((o?u.nodeName.toLowerCase()!==v:1!==u.nodeType)||!++h||(y&&((u[U]||(u[U]={}))[e]=[z,h]),u!==t)););return h-=s,h===n||h%n===0&&h/n>=0
}}},PSEUDO:function(e,t){var n,a=P.pseudos[e]||P.setFilters[e.toLowerCase()]||i.error("unsupported pseudo: "+e);return a[U]?a(t):a.length>1?(n=[e,e,"",t],P.setFilters.hasOwnProperty(e.toLowerCase())?s(function(e,i){for(var n,s=a(e,t),r=s.length;r--;)n=it.call(e,s[r]),e[n]=!(i[n]=s[r])}):function(e){return a(e,0,n)}):a}},pseudos:{not:s(function(e){var t=[],i=[],n=I(e.replace(ct,"$1"));return n[U]?s(function(e,t,i,s){for(var a,r=n(e,null,s,[]),o=e.length;o--;)(a=r[o])&&(e[o]=!(t[o]=a))}):function(e,s,a){return t[0]=e,n(t,null,a,i),!i.pop()
}}),has:s(function(e){return function(t){return i(e,t).length>0}}),contains:s(function(e){return function(t){return(t.textContent||t.innerText||A(t)).indexOf(e)>-1}}),lang:s(function(e){return gt.test(e||"")||i.error("unsupported lang: "+e),e=e.replace(St,Ct).toLowerCase(),function(t){var i;do if(i=R?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return i=i.toLowerCase(),i===e||0===i.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var i=e.location&&e.location.hash;
return i&&i.slice(1)===t.id},root:function(e){return e===L},focus:function(e){return e===E.activeElement&&(!E.hasFocus||E.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;
return!0},parent:function(e){return!P.pseudos.empty(e)},header:function(e){return xt.test(e.nodeName)},input:function(e){return wt.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:d(function(){return[0]}),last:d(function(e,t){return[t-1]}),eq:d(function(e,t,i){return[0>i?i+t:i]}),even:d(function(e,t){for(var i=0;t>i;i+=2)e.push(i);
return e}),odd:d(function(e,t){for(var i=1;t>i;i+=2)e.push(i);return e}),lt:d(function(e,t,i){for(var n=0>i?i+t:i;--n>=0;)e.push(n);return e}),gt:d(function(e,t,i){for(var n=0>i?i+t:i;++n<t;)e.push(n);return e})}},P.pseudos.nth=P.pseudos.eq;for(k in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})P.pseudos[k]=l(k);for(k in{submit:!0,reset:!0})P.pseudos[k]=c(k);u.prototype=P.filters=P.pseudos,P.setFilters=new u,I=i.compile=function(e,t){var i,n=[],s=[],a=W[e+" "];if(!a){for(t||(t=h(e)),i=t.length;i--;)a=y(t[i]),a[U]?n.push(a):s.push(a);
a=W(e,b(s,n))}return a},S.sortStable=U.split("").sort(Y).join("")===U,S.detectDuplicates=$,D(),S.sortDetached=a(function(e){return 1&e.compareDocumentPosition(E.createElement("div"))}),a(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||r("type|href|height|width",function(e,t,i){return i?void 0:e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),S.attributes&&a(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")
})||r("value",function(e,t,i){return i||"input"!==e.nodeName.toLowerCase()?void 0:e.defaultValue}),a(function(e){return null==e.getAttribute("disabled")})||r(nt,function(e,t,i){var n;return i?void 0:(n=e.getAttributeNode(t))&&n.specified?n.value:e[t]===!0?t.toLowerCase():null}),dt.find=i,dt.expr=i.selectors,dt.expr[":"]=dt.expr.pseudos,dt.unique=i.uniqueSort,dt.text=i.getText,dt.isXMLDoc=i.isXML,dt.contains=i.contains}(e);var Pt={};dt.Callbacks=function(e){e="string"==typeof e?Pt[e]||n(e):dt.extend({},e);
var i,s,a,r,o,l,c=[],d=!e.once&&[],u=function(t){for(s=e.memory&&t,a=!0,o=l||0,l=0,r=c.length,i=!0;c&&r>o;o++)if(c[o].apply(t[0],t[1])===!1&&e.stopOnFalse){s=!1;break}i=!1,c&&(d?d.length&&u(d.shift()):s?c=[]:h.disable())},h={add:function(){if(c){var t=c.length;!function n(t){dt.each(t,function(t,i){var s=dt.type(i);"function"===s?e.unique&&h.has(i)||c.push(i):i&&i.length&&"string"!==s&&n(i)})}(arguments),i?r=c.length:s&&(l=t,u(s))}return this},remove:function(){return c&&dt.each(arguments,function(e,t){for(var n;(n=dt.inArray(t,c,n))>-1;)c.splice(n,1),i&&(r>=n&&r--,o>=n&&o--)
}),this},has:function(e){return e?dt.inArray(e,c)>-1:!(!c||!c.length)},empty:function(){return c=[],r=0,this},disable:function(){return c=d=s=t,this},disabled:function(){return!c},lock:function(){return d=t,s||h.disable(),this},locked:function(){return!d},fireWith:function(e,t){return!c||a&&!d||(t=t||[],t=[e,t.slice?t.slice():t],i?d.push(t):u(t)),this},fire:function(){return h.fireWith(this,arguments),this},fired:function(){return!!a}};return h},dt.extend({Deferred:function(e){var t=[["resolve","done",dt.Callbacks("once memory"),"resolved"],["reject","fail",dt.Callbacks("once memory"),"rejected"],["notify","progress",dt.Callbacks("memory")]],i="pending",n={state:function(){return i
},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var e=arguments;return dt.Deferred(function(i){dt.each(t,function(t,a){var r=a[0],o=dt.isFunction(e[t])&&e[t];s[a[1]](function(){var e=o&&o.apply(this,arguments);e&&dt.isFunction(e.promise)?e.promise().done(i.resolve).fail(i.reject).progress(i.notify):i[r+"With"](this===n?i.promise():this,o?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?dt.extend(e,n):n}},s={};return n.pipe=n.then,dt.each(t,function(e,a){var r=a[2],o=a[3];
n[a[1]]=r.add,o&&r.add(function(){i=o},t[1^e][2].disable,t[2][2].lock),s[a[0]]=function(){return s[a[0]+"With"](this===s?n:this,arguments),this},s[a[0]+"With"]=r.fireWith}),n.promise(s),e&&e.call(s,s),s},when:function(e){var t,i,n,s=0,a=at.call(arguments),r=a.length,o=1!==r||e&&dt.isFunction(e.promise)?r:0,l=1===o?e:dt.Deferred(),c=function(e,i,n){return function(s){i[e]=this,n[e]=arguments.length>1?at.call(arguments):s,n===t?l.notifyWith(i,n):--o||l.resolveWith(i,n)}};if(r>1)for(t=new Array(r),i=new Array(r),n=new Array(r);r>s;s++)a[s]&&dt.isFunction(a[s].promise)?a[s].promise().done(c(s,n,a)).fail(l.reject).progress(c(s,i,t)):--o;
return o||l.resolveWith(n,a),l.promise()}}),dt.support=function(t){var i,n,s,a,r,o,l,c,d,u=X.createElement("div");if(u.setAttribute("className","t"),u.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",i=u.getElementsByTagName("*")||[],n=u.getElementsByTagName("a")[0],!n||!n.style||!i.length)return t;a=X.createElement("select"),o=a.appendChild(X.createElement("option")),s=u.getElementsByTagName("input")[0],n.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==u.className,t.leadingWhitespace=3===u.firstChild.nodeType,t.tbody=!u.getElementsByTagName("tbody").length,t.htmlSerialize=!!u.getElementsByTagName("link").length,t.style=/top/.test(n.getAttribute("style")),t.hrefNormalized="/a"===n.getAttribute("href"),t.opacity=/^0.5/.test(n.style.opacity),t.cssFloat=!!n.style.cssFloat,t.checkOn=!!s.value,t.optSelected=o.selected,t.enctype=!!X.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==X.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,s.checked=!0,t.noCloneChecked=s.cloneNode(!0).checked,a.disabled=!0,t.optDisabled=!o.disabled;
try{delete u.test}catch(h){t.deleteExpando=!1}s=X.createElement("input"),s.setAttribute("value",""),t.input=""===s.getAttribute("value"),s.value="t",s.setAttribute("type","radio"),t.radioValue="t"===s.value,s.setAttribute("checked","t"),s.setAttribute("name","t"),r=X.createDocumentFragment(),r.appendChild(s),t.appendChecked=s.checked,t.checkClone=r.cloneNode(!0).cloneNode(!0).lastChild.checked,u.attachEvent&&(u.attachEvent("onclick",function(){t.noCloneEvent=!1}),u.cloneNode(!0).click());for(d in{submit:!0,change:!0,focusin:!0})u.setAttribute(l="on"+d,"t"),t[d+"Bubbles"]=l in e||u.attributes[l].expando===!1;
u.style.backgroundClip="content-box",u.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===u.style.backgroundClip;for(d in dt(t))break;return t.ownLast="0"!==d,dt(function(){var i,n,s,a="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",r=X.getElementsByTagName("body")[0];r&&(i=X.createElement("div"),i.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",r.appendChild(i).appendChild(u),u.innerHTML="<table><tr><td></td><td>t</td></tr></table>",s=u.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=0===s[0].offsetHeight,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&0===s[0].offsetHeight,u.innerHTML="",u.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",dt.swap(r,null!=r.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===u.offsetWidth
}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(u,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(u,null)||{width:"4px"}).width,n=u.appendChild(X.createElement("div")),n.style.cssText=u.style.cssText=a,n.style.marginRight=n.style.width="0",u.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(n,null)||{}).marginRight)),typeof u.style.zoom!==Q&&(u.innerHTML="",u.style.cssText=a+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===u.offsetWidth,u.style.display="block",u.innerHTML="<div></div>",u.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==u.offsetWidth,t.inlineBlockNeedsLayout&&(r.style.zoom=1)),r.removeChild(i),i=u=s=n=null)
}),i=a=r=o=n=s=null,t}({});var At=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,_t=/([A-Z])/g;dt.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?dt.cache[e[dt.expando]]:e[dt.expando],!!e&&!o(e)},data:function(e,t,i){return s(e,t,i)},removeData:function(e,t){return a(e,t)},_data:function(e,t,i){return s(e,t,i,!0)},_removeData:function(e,t){return a(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;
var t=e.nodeName&&dt.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),dt.fn.extend({data:function(e,i){var n,s,a=null,o=0,l=this[0];if(e===t){if(this.length&&(a=dt.data(l),1===l.nodeType&&!dt._data(l,"parsedAttrs"))){for(n=l.attributes;o<n.length;o++)s=n[o].name,0===s.indexOf("data-")&&(s=dt.camelCase(s.slice(5)),r(l,s,a[s]));dt._data(l,"parsedAttrs",!0)}return a}return"object"==typeof e?this.each(function(){dt.data(this,e)}):arguments.length>1?this.each(function(){dt.data(this,e,i)
}):l?r(l,e,dt.data(l,e)):null},removeData:function(e){return this.each(function(){dt.removeData(this,e)})}}),dt.extend({queue:function(e,t,i){var n;return e?(t=(t||"fx")+"queue",n=dt._data(e,t),i&&(!n||dt.isArray(i)?n=dt._data(e,t,dt.makeArray(i)):n.push(i)),n||[]):void 0},dequeue:function(e,t){t=t||"fx";var i=dt.queue(e,t),n=i.length,s=i.shift(),a=dt._queueHooks(e,t),r=function(){dt.dequeue(e,t)};"inprogress"===s&&(s=i.shift(),n--),s&&("fx"===t&&i.unshift("inprogress"),delete a.stop,s.call(e,r,a)),!n&&a&&a.empty.fire()
},_queueHooks:function(e,t){var i=t+"queueHooks";return dt._data(e,i)||dt._data(e,i,{empty:dt.Callbacks("once memory").add(function(){dt._removeData(e,t+"queue"),dt._removeData(e,i)})})}}),dt.fn.extend({queue:function(e,i){var n=2;return"string"!=typeof e&&(i=e,e="fx",n--),arguments.length<n?dt.queue(this[0],e):i===t?this:this.each(function(){var t=dt.queue(this,e,i);dt._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&dt.dequeue(this,e)})},dequeue:function(e){return this.each(function(){dt.dequeue(this,e)
})},delay:function(e,t){return e=dt.fx?dt.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,i){var n=setTimeout(t,e);i.stop=function(){clearTimeout(n)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,i){var n,s=1,a=dt.Deferred(),r=this,o=this.length,l=function(){--s||a.resolveWith(r,[r])};for("string"!=typeof e&&(i=e,e=t),e=e||"fx";o--;)n=dt._data(r[o],e+"queueHooks"),n&&n.empty&&(s++,n.empty.add(l));return l(),a.promise(i)}});var It,Tt,Mt=/[\t\r\n\f]/g,Dt=/\r/g,Et=/^(?:input|select|textarea|button|object)$/i,Lt=/^(?:a|area)$/i,Rt=/^(?:checked|selected)$/i,Ot=dt.support.getSetAttribute,Nt=dt.support.input;
dt.fn.extend({attr:function(e,t){return dt.access(this,dt.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){dt.removeAttr(this,e)})},prop:function(e,t){return dt.access(this,dt.prop,e,t,arguments.length>1)},removeProp:function(e){return e=dt.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(i){}})},addClass:function(e){var t,i,n,s,a,r=0,o=this.length,l="string"==typeof e&&e;if(dt.isFunction(e))return this.each(function(t){dt(this).addClass(e.call(this,t,this.className))
});if(l)for(t=(e||"").match(ht)||[];o>r;r++)if(i=this[r],n=1===i.nodeType&&(i.className?(" "+i.className+" ").replace(Mt," "):" ")){for(a=0;s=t[a++];)n.indexOf(" "+s+" ")<0&&(n+=s+" ");i.className=dt.trim(n)}return this},removeClass:function(e){var t,i,n,s,a,r=0,o=this.length,l=0===arguments.length||"string"==typeof e&&e;if(dt.isFunction(e))return this.each(function(t){dt(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(ht)||[];o>r;r++)if(i=this[r],n=1===i.nodeType&&(i.className?(" "+i.className+" ").replace(Mt," "):"")){for(a=0;s=t[a++];)for(;n.indexOf(" "+s+" ")>=0;)n=n.replace(" "+s+" "," ");
i.className=e?dt.trim(n):""}return this},toggleClass:function(e,t){var i=typeof e;return"boolean"==typeof t&&"string"===i?t?this.addClass(e):this.removeClass(e):this.each(dt.isFunction(e)?function(i){dt(this).toggleClass(e.call(this,i,this.className,t),t)}:function(){if("string"===i)for(var t,n=0,s=dt(this),a=e.match(ht)||[];t=a[n++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else(i===Q||"boolean"===i)&&(this.className&&dt._data(this,"__className__",this.className),this.className=this.className||e===!1?"":dt._data(this,"__className__")||"")
})},hasClass:function(e){for(var t=" "+e+" ",i=0,n=this.length;n>i;i++)if(1===this[i].nodeType&&(" "+this[i].className+" ").replace(Mt," ").indexOf(t)>=0)return!0;return!1},val:function(e){var i,n,s,a=this[0];{if(arguments.length)return s=dt.isFunction(e),this.each(function(i){var a;1===this.nodeType&&(a=s?e.call(this,i,dt(this).val()):e,null==a?a="":"number"==typeof a?a+="":dt.isArray(a)&&(a=dt.map(a,function(e){return null==e?"":e+""})),n=dt.valHooks[this.type]||dt.valHooks[this.nodeName.toLowerCase()],n&&"set"in n&&n.set(this,a,"value")!==t||(this.value=a))
});if(a)return n=dt.valHooks[a.type]||dt.valHooks[a.nodeName.toLowerCase()],n&&"get"in n&&(i=n.get(a,"value"))!==t?i:(i=a.value,"string"==typeof i?i.replace(Dt,""):null==i?"":i)}}}),dt.extend({valHooks:{option:{get:function(e){var t=dt.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){for(var t,i,n=e.options,s=e.selectedIndex,a="select-one"===e.type||0>s,r=a?null:[],o=a?s+1:n.length,l=0>s?o:a?s:0;o>l;l++)if(i=n[l],!(!i.selected&&l!==s||(dt.support.optDisabled?i.disabled:null!==i.getAttribute("disabled"))||i.parentNode.disabled&&dt.nodeName(i.parentNode,"optgroup"))){if(t=dt(i).val(),a)return t;
r.push(t)}return r},set:function(e,t){for(var i,n,s=e.options,a=dt.makeArray(t),r=s.length;r--;)n=s[r],(n.selected=dt.inArray(dt(n).val(),a)>=0)&&(i=!0);return i||(e.selectedIndex=-1),a}}},attr:function(e,i,n){var s,a,r=e.nodeType;if(e&&3!==r&&8!==r&&2!==r)return typeof e.getAttribute===Q?dt.prop(e,i,n):(1===r&&dt.isXMLDoc(e)||(i=i.toLowerCase(),s=dt.attrHooks[i]||(dt.expr.match.bool.test(i)?Tt:It)),n===t?s&&"get"in s&&null!==(a=s.get(e,i))?a:(a=dt.find.attr(e,i),null==a?t:a):null!==n?s&&"set"in s&&(a=s.set(e,n,i))!==t?a:(e.setAttribute(i,n+""),n):void dt.removeAttr(e,i))
},removeAttr:function(e,t){var i,n,s=0,a=t&&t.match(ht);if(a&&1===e.nodeType)for(;i=a[s++];)n=dt.propFix[i]||i,dt.expr.match.bool.test(i)?Nt&&Ot||!Rt.test(i)?e[n]=!1:e[dt.camelCase("default-"+i)]=e[n]=!1:dt.attr(e,i,""),e.removeAttribute(Ot?i:n)},attrHooks:{type:{set:function(e,t){if(!dt.support.radioValue&&"radio"===t&&dt.nodeName(e,"input")){var i=e.value;return e.setAttribute("type",t),i&&(e.value=i),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,i,n){var s,a,r,o=e.nodeType;
if(e&&3!==o&&8!==o&&2!==o)return r=1!==o||!dt.isXMLDoc(e),r&&(i=dt.propFix[i]||i,a=dt.propHooks[i]),n!==t?a&&"set"in a&&(s=a.set(e,n,i))!==t?s:e[i]=n:a&&"get"in a&&null!==(s=a.get(e,i))?s:e[i]},propHooks:{tabIndex:{get:function(e){var t=dt.find.attr(e,"tabindex");return t?parseInt(t,10):Et.test(e.nodeName)||Lt.test(e.nodeName)&&e.href?0:-1}}}}),Tt={set:function(e,t,i){return t===!1?dt.removeAttr(e,i):Nt&&Ot||!Rt.test(i)?e.setAttribute(!Ot&&dt.propFix[i]||i,i):e[dt.camelCase("default-"+i)]=e[i]=!0,i
}},dt.each(dt.expr.match.bool.source.match(/\w+/g),function(e,i){var n=dt.expr.attrHandle[i]||dt.find.attr;dt.expr.attrHandle[i]=Nt&&Ot||!Rt.test(i)?function(e,i,s){var a=dt.expr.attrHandle[i],r=s?t:(dt.expr.attrHandle[i]=t)!=n(e,i,s)?i.toLowerCase():null;return dt.expr.attrHandle[i]=a,r}:function(e,i,n){return n?t:e[dt.camelCase("default-"+i)]?i.toLowerCase():null}}),Nt&&Ot||(dt.attrHooks.value={set:function(e,t,i){return dt.nodeName(e,"input")?void(e.defaultValue=t):It&&It.set(e,t,i)}}),Ot||(It={set:function(e,i,n){var s=e.getAttributeNode(n);
return s||e.setAttributeNode(s=e.ownerDocument.createAttribute(n)),s.value=i+="","value"===n||i===e.getAttribute(n)?i:t}},dt.expr.attrHandle.id=dt.expr.attrHandle.name=dt.expr.attrHandle.coords=function(e,i,n){var s;return n?t:(s=e.getAttributeNode(i))&&""!==s.value?s.value:null},dt.valHooks.button={get:function(e,i){var n=e.getAttributeNode(i);return n&&n.specified?n.value:t},set:It.set},dt.attrHooks.contenteditable={set:function(e,t,i){It.set(e,""===t?!1:t,i)}},dt.each(["width","height"],function(e,t){dt.attrHooks[t]={set:function(e,i){return""===i?(e.setAttribute(t,"auto"),i):void 0
}}})),dt.support.hrefNormalized||dt.each(["href","src"],function(e,t){dt.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),dt.support.style||(dt.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),dt.support.optSelected||(dt.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),dt.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){dt.propFix[this.toLowerCase()]=this
}),dt.support.enctype||(dt.propFix.enctype="encoding"),dt.each(["radio","checkbox"],function(){dt.valHooks[this]={set:function(e,t){return dt.isArray(t)?e.checked=dt.inArray(dt(e).val(),t)>=0:void 0}},dt.support.checkOn||(dt.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Ft=/^(?:input|select|textarea)$/i,Bt=/^key/,Ut=/^(?:mouse|contextmenu)|click/,Vt=/^(?:focusinfocus|focusoutblur)$/,zt=/^([^.]*)(?:\.(.+)|)$/;dt.event={global:{},add:function(e,i,n,s,a){var r,o,l,c,d,u,h,p,m,f,g,v=dt._data(e);
if(v){for(n.handler&&(c=n,n=c.handler,a=c.selector),n.guid||(n.guid=dt.guid++),(o=v.events)||(o=v.events={}),(u=v.handle)||(u=v.handle=function(e){return typeof dt===Q||e&&dt.event.triggered===e.type?t:dt.event.dispatch.apply(u.elem,arguments)},u.elem=e),i=(i||"").match(ht)||[""],l=i.length;l--;)r=zt.exec(i[l])||[],m=g=r[1],f=(r[2]||"").split(".").sort(),m&&(d=dt.event.special[m]||{},m=(a?d.delegateType:d.bindType)||m,d=dt.event.special[m]||{},h=dt.extend({type:m,origType:g,data:s,handler:n,guid:n.guid,selector:a,needsContext:a&&dt.expr.match.needsContext.test(a),namespace:f.join(".")},c),(p=o[m])||(p=o[m]=[],p.delegateCount=0,d.setup&&d.setup.call(e,s,f,u)!==!1||(e.addEventListener?e.addEventListener(m,u,!1):e.attachEvent&&e.attachEvent("on"+m,u))),d.add&&(d.add.call(e,h),h.handler.guid||(h.handler.guid=n.guid)),a?p.splice(p.delegateCount++,0,h):p.push(h),dt.event.global[m]=!0);
e=null}},remove:function(e,t,i,n,s){var a,r,o,l,c,d,u,h,p,m,f,g=dt.hasData(e)&&dt._data(e);if(g&&(d=g.events)){for(t=(t||"").match(ht)||[""],c=t.length;c--;)if(o=zt.exec(t[c])||[],p=f=o[1],m=(o[2]||"").split(".").sort(),p){for(u=dt.event.special[p]||{},p=(n?u.delegateType:u.bindType)||p,h=d[p]||[],o=o[2]&&new RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=a=h.length;a--;)r=h[a],!s&&f!==r.origType||i&&i.guid!==r.guid||o&&!o.test(r.namespace)||n&&n!==r.selector&&("**"!==n||!r.selector)||(h.splice(a,1),r.selector&&h.delegateCount--,u.remove&&u.remove.call(e,r));
l&&!h.length&&(u.teardown&&u.teardown.call(e,m,g.handle)!==!1||dt.removeEvent(e,p,g.handle),delete d[p])}else for(p in d)dt.event.remove(e,p+t[c],i,n,!0);dt.isEmptyObject(d)&&(delete g.handle,dt._removeData(e,"events"))}},trigger:function(i,n,s,a){var r,o,l,c,d,u,h,p=[s||X],m=lt.call(i,"type")?i.type:i,f=lt.call(i,"namespace")?i.namespace.split("."):[];if(l=u=s=s||X,3!==s.nodeType&&8!==s.nodeType&&!Vt.test(m+dt.event.triggered)&&(m.indexOf(".")>=0&&(f=m.split("."),m=f.shift(),f.sort()),o=m.indexOf(":")<0&&"on"+m,i=i[dt.expando]?i:new dt.Event(m,"object"==typeof i&&i),i.isTrigger=a?2:3,i.namespace=f.join("."),i.namespace_re=i.namespace?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,i.result=t,i.target||(i.target=s),n=null==n?[i]:dt.makeArray(n,[i]),d=dt.event.special[m]||{},a||!d.trigger||d.trigger.apply(s,n)!==!1)){if(!a&&!d.noBubble&&!dt.isWindow(s)){for(c=d.delegateType||m,Vt.test(c+m)||(l=l.parentNode);l;l=l.parentNode)p.push(l),u=l;
u===(s.ownerDocument||X)&&p.push(u.defaultView||u.parentWindow||e)}for(h=0;(l=p[h++])&&!i.isPropagationStopped();)i.type=h>1?c:d.bindType||m,r=(dt._data(l,"events")||{})[i.type]&&dt._data(l,"handle"),r&&r.apply(l,n),r=o&&l[o],r&&dt.acceptData(l)&&r.apply&&r.apply(l,n)===!1&&i.preventDefault();if(i.type=m,!a&&!i.isDefaultPrevented()&&(!d._default||d._default.apply(p.pop(),n)===!1)&&dt.acceptData(s)&&o&&s[m]&&!dt.isWindow(s)){u=s[o],u&&(s[o]=null),dt.event.triggered=m;try{s[m]()}catch(g){}dt.event.triggered=t,u&&(s[o]=u)
}return i.result}},dispatch:function(e){e=dt.event.fix(e);var i,n,s,a,r,o=[],l=at.call(arguments),c=(dt._data(this,"events")||{})[e.type]||[],d=dt.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!d.preDispatch||d.preDispatch.call(this,e)!==!1){for(o=dt.event.handlers.call(this,e,c),i=0;(a=o[i++])&&!e.isPropagationStopped();)for(e.currentTarget=a.elem,r=0;(s=a.handlers[r++])&&!e.isImmediatePropagationStopped();)(!e.namespace_re||e.namespace_re.test(s.namespace))&&(e.handleObj=s,e.data=s.data,n=((dt.event.special[s.origType]||{}).handle||s.handler).apply(a.elem,l),n!==t&&(e.result=n)===!1&&(e.preventDefault(),e.stopPropagation()));
return d.postDispatch&&d.postDispatch.call(this,e),e.result}},handlers:function(e,i){var n,s,a,r,o=[],l=i.delegateCount,c=e.target;if(l&&c.nodeType&&(!e.button||"click"!==e.type))for(;c!=this;c=c.parentNode||this)if(1===c.nodeType&&(c.disabled!==!0||"click"!==e.type)){for(a=[],r=0;l>r;r++)s=i[r],n=s.selector+" ",a[n]===t&&(a[n]=s.needsContext?dt(n,this).index(c)>=0:dt.find(n,this,null,[c]).length),a[n]&&a.push(s);a.length&&o.push({elem:c,handlers:a})}return l<i.length&&o.push({elem:this,handlers:i.slice(l)}),o
},fix:function(e){if(e[dt.expando])return e;var t,i,n,s=e.type,a=e,r=this.fixHooks[s];for(r||(this.fixHooks[s]=r=Ut.test(s)?this.mouseHooks:Bt.test(s)?this.keyHooks:{}),n=r.props?this.props.concat(r.props):this.props,e=new dt.Event(a),t=n.length;t--;)i=n[t],e[i]=a[i];return e.target||(e.target=a.srcElement||X),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,r.filter?r.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e
}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,i){var n,s,a,r=i.button,o=i.fromElement;return null==e.pageX&&null!=i.clientX&&(s=e.target.ownerDocument||X,a=s.documentElement,n=s.body,e.pageX=i.clientX+(a&&a.scrollLeft||n&&n.scrollLeft||0)-(a&&a.clientLeft||n&&n.clientLeft||0),e.pageY=i.clientY+(a&&a.scrollTop||n&&n.scrollTop||0)-(a&&a.clientTop||n&&n.clientTop||0)),!e.relatedTarget&&o&&(e.relatedTarget=o===e.target?i.toElement:o),e.which||r===t||(e.which=1&r?1:2&r?3:4&r?2:0),e
}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==d()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===d()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return dt.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(e){return dt.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)
}}},simulate:function(e,t,i,n){var s=dt.extend(new dt.Event,i,{type:e,isSimulated:!0,originalEvent:{}});n?dt.event.trigger(s,null,t):dt.event.dispatch.call(t,s),s.isDefaultPrevented()&&i.preventDefault()}},dt.removeEvent=X.removeEventListener?function(e,t,i){e.removeEventListener&&e.removeEventListener(t,i,!1)}:function(e,t,i){var n="on"+t;e.detachEvent&&(typeof e[n]===Q&&(e[n]=null),e.detachEvent(n,i))},dt.Event=function(e,t){return this instanceof dt.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?l:c):this.type=e,t&&dt.extend(this,t),this.timeStamp=e&&e.timeStamp||dt.now(),void(this[dt.expando]=!0)):new dt.Event(e,t)
},dt.Event.prototype={isDefaultPrevented:c,isPropagationStopped:c,isImmediatePropagationStopped:c,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=l,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=l,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=l,this.stopPropagation()}},dt.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){dt.event.special[e]={delegateType:t,bindType:t,handle:function(e){var i,n=this,s=e.relatedTarget,a=e.handleObj;
return(!s||s!==n&&!dt.contains(n,s))&&(e.type=a.origType,i=a.handler.apply(this,arguments),e.type=t),i}}}),dt.support.submitBubbles||(dt.event.special.submit={setup:function(){return dt.nodeName(this,"form")?!1:void dt.event.add(this,"click._submit keypress._submit",function(e){var i=e.target,n=dt.nodeName(i,"input")||dt.nodeName(i,"button")?i.form:t;n&&!dt._data(n,"submitBubbles")&&(dt.event.add(n,"submit._submit",function(e){e._submit_bubble=!0}),dt._data(n,"submitBubbles",!0))})},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&dt.event.simulate("submit",this.parentNode,e,!0))
},teardown:function(){return dt.nodeName(this,"form")?!1:void dt.event.remove(this,"._submit")}}),dt.support.changeBubbles||(dt.event.special.change={setup:function(){return Ft.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(dt.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),dt.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),dt.event.simulate("change",this,e,!0)
})),!1):void dt.event.add(this,"beforeactivate._change",function(e){var t=e.target;Ft.test(t.nodeName)&&!dt._data(t,"changeBubbles")&&(dt.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||dt.event.simulate("change",this.parentNode,e,!0)}),dt._data(t,"changeBubbles",!0))})},handle:function(e){var t=e.target;return this!==t||e.isSimulated||e.isTrigger||"radio"!==t.type&&"checkbox"!==t.type?e.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return dt.event.remove(this,"._change"),!Ft.test(this.nodeName)
}}),dt.support.focusinBubbles||dt.each({focus:"focusin",blur:"focusout"},function(e,t){var i=0,n=function(e){dt.event.simulate(t,e.target,dt.event.fix(e),!0)};dt.event.special[t]={setup:function(){0===i++&&X.addEventListener(e,n,!0)},teardown:function(){0===--i&&X.removeEventListener(e,n,!0)}}}),dt.fn.extend({on:function(e,i,n,s,a){var r,o;if("object"==typeof e){"string"!=typeof i&&(n=n||i,i=t);for(r in e)this.on(r,i,n,e[r],a);return this}if(null==n&&null==s?(s=i,n=i=t):null==s&&("string"==typeof i?(s=n,n=t):(s=n,n=i,i=t)),s===!1)s=c;
else if(!s)return this;return 1===a&&(o=s,s=function(e){return dt().off(e),o.apply(this,arguments)},s.guid=o.guid||(o.guid=dt.guid++)),this.each(function(){dt.event.add(this,e,s,n,i)})},one:function(e,t,i,n){return this.on(e,t,i,n,1)},off:function(e,i,n){var s,a;if(e&&e.preventDefault&&e.handleObj)return s=e.handleObj,dt(e.delegateTarget).off(s.namespace?s.origType+"."+s.namespace:s.origType,s.selector,s.handler),this;if("object"==typeof e){for(a in e)this.off(a,i,e[a]);return this}return(i===!1||"function"==typeof i)&&(n=i,i=t),n===!1&&(n=c),this.each(function(){dt.event.remove(this,e,n,i)
})},trigger:function(e,t){return this.each(function(){dt.event.trigger(e,t,this)})},triggerHandler:function(e,t){var i=this[0];return i?dt.event.trigger(e,t,i,!0):void 0}});var jt=/^.[^:#\[\.,]*$/,qt=/^(?:parents|prev(?:Until|All))/,Ht=dt.expr.match.needsContext,Wt={children:!0,contents:!0,next:!0,prev:!0};dt.fn.extend({find:function(e){var t,i=[],n=this,s=n.length;if("string"!=typeof e)return this.pushStack(dt(e).filter(function(){for(t=0;s>t;t++)if(dt.contains(n[t],this))return!0}));for(t=0;s>t;t++)dt.find(e,n[t],i);
return i=this.pushStack(s>1?dt.unique(i):i),i.selector=this.selector?this.selector+" "+e:e,i},has:function(e){var t,i=dt(e,this),n=i.length;return this.filter(function(){for(t=0;n>t;t++)if(dt.contains(this,i[t]))return!0})},not:function(e){return this.pushStack(h(this,e||[],!0))},filter:function(e){return this.pushStack(h(this,e||[],!1))},is:function(e){return!!h(this,"string"==typeof e&&Ht.test(e)?dt(e):e||[],!1).length},closest:function(e,t){for(var i,n=0,s=this.length,a=[],r=Ht.test(e)||"string"!=typeof e?dt(e,t||this.context):0;s>n;n++)for(i=this[n];i&&i!==t;i=i.parentNode)if(i.nodeType<11&&(r?r.index(i)>-1:1===i.nodeType&&dt.find.matchesSelector(i,e))){i=a.push(i);
break}return this.pushStack(a.length>1?dt.unique(a):a)},index:function(e){return e?"string"==typeof e?dt.inArray(this[0],dt(e)):dt.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var i="string"==typeof e?dt(e,t):dt.makeArray(e&&e.nodeType?[e]:e),n=dt.merge(this.get(),i);return this.pushStack(dt.unique(n))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),dt.each({parent:function(e){var t=e.parentNode;
return t&&11!==t.nodeType?t:null},parents:function(e){return dt.dir(e,"parentNode")},parentsUntil:function(e,t,i){return dt.dir(e,"parentNode",i)},next:function(e){return u(e,"nextSibling")},prev:function(e){return u(e,"previousSibling")},nextAll:function(e){return dt.dir(e,"nextSibling")},prevAll:function(e){return dt.dir(e,"previousSibling")},nextUntil:function(e,t,i){return dt.dir(e,"nextSibling",i)},prevUntil:function(e,t,i){return dt.dir(e,"previousSibling",i)},siblings:function(e){return dt.sibling((e.parentNode||{}).firstChild,e)
},children:function(e){return dt.sibling(e.firstChild)},contents:function(e){return dt.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:dt.merge([],e.childNodes)}},function(e,t){dt.fn[e]=function(i,n){var s=dt.map(this,t,i);return"Until"!==e.slice(-5)&&(n=i),n&&"string"==typeof n&&(s=dt.filter(n,s)),this.length>1&&(Wt[e]||(s=dt.unique(s)),qt.test(e)&&(s=s.reverse())),this.pushStack(s)}}),dt.extend({filter:function(e,t,i){var n=t[0];return i&&(e=":not("+e+")"),1===t.length&&1===n.nodeType?dt.find.matchesSelector(n,e)?[n]:[]:dt.find.matches(e,dt.grep(t,function(e){return 1===e.nodeType
}))},dir:function(e,i,n){for(var s=[],a=e[i];a&&9!==a.nodeType&&(n===t||1!==a.nodeType||!dt(a).is(n));)1===a.nodeType&&s.push(a),a=a[i];return s},sibling:function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i}});var $t="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Yt=/ jQuery\d+="(?:null|\d+)"/g,Qt=new RegExp("<(?:"+$t+")[\\s/>]","i"),Kt=/^\s+/,Xt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Gt=/<([\w:]+)/,Jt=/<tbody/i,Zt=/<|&#?\w+;/,ei=/<(?:script|style|link)/i,ti=/^(?:checkbox|radio)$/i,ii=/checked\s*(?:[^=]|=\s*.checked.)/i,ni=/^$|\/(?:java|ecma)script/i,si=/^true\/(.*)/,ai=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ri={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:dt.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},oi=p(X),li=oi.appendChild(X.createElement("div"));
ri.optgroup=ri.option,ri.tbody=ri.tfoot=ri.colgroup=ri.caption=ri.thead,ri.th=ri.td,dt.fn.extend({text:function(e){return dt.access(this,function(e){return e===t?dt.text(this):this.empty().append((this[0]&&this[0].ownerDocument||X).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=m(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=m(this,e);
t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){for(var i,n=e?dt.filter(e,this):this,s=0;null!=(i=n[s]);s++)t||1!==i.nodeType||dt.cleanData(w(i)),i.parentNode&&(t&&dt.contains(i.ownerDocument,i)&&v(w(i,"script")),i.parentNode.removeChild(i));return this
},empty:function(){for(var e,t=0;null!=(e=this[t]);t++){for(1===e.nodeType&&dt.cleanData(w(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&dt.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return dt.clone(this,e,t)})},html:function(e){return dt.access(this,function(e){var i=this[0]||{},n=0,s=this.length;if(e===t)return 1===i.nodeType?i.innerHTML.replace(Yt,""):t;if(!("string"!=typeof e||ei.test(e)||!dt.support.htmlSerialize&&Qt.test(e)||!dt.support.leadingWhitespace&&Kt.test(e)||ri[(Gt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(Xt,"<$1></$2>");
try{for(;s>n;n++)i=this[n]||{},1===i.nodeType&&(dt.cleanData(w(i,!1)),i.innerHTML=e);i=0}catch(a){}}i&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=dt.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(i){var n=e[t++],s=e[t++];s&&(n&&n.parentNode!==s&&(n=this.nextSibling),dt(this).remove(),s.insertBefore(i,n))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,i){e=nt.apply([],e);
var n,s,a,r,o,l,c=0,d=this.length,u=this,h=d-1,p=e[0],m=dt.isFunction(p);if(m||!(1>=d||"string"!=typeof p||dt.support.checkClone)&&ii.test(p))return this.each(function(n){var s=u.eq(n);m&&(e[0]=p.call(this,n,s.html())),s.domManip(e,t,i)});if(d&&(l=dt.buildFragment(e,this[0].ownerDocument,!1,!i&&this),n=l.firstChild,1===l.childNodes.length&&(l=n),n)){for(r=dt.map(w(l,"script"),f),a=r.length;d>c;c++)s=l,c!==h&&(s=dt.clone(s,!0,!0),a&&dt.merge(r,w(s,"script"))),t.call(this[c],s,c);if(a)for(o=r[r.length-1].ownerDocument,dt.map(r,g),c=0;a>c;c++)s=r[c],ni.test(s.type||"")&&!dt._data(s,"globalEval")&&dt.contains(o,s)&&(s.src?dt._evalUrl(s.src):dt.globalEval((s.text||s.textContent||s.innerHTML||"").replace(ai,"")));
l=n=null}return this}}),dt.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){dt.fn[e]=function(e){for(var i,n=0,s=[],a=dt(e),r=a.length-1;r>=n;n++)i=n===r?this:this.clone(!0),dt(a[n])[t](i),st.apply(s,i.get());return this.pushStack(s)}}),dt.extend({clone:function(e,t,i){var n,s,a,r,o,l=dt.contains(e.ownerDocument,e);if(dt.support.html5Clone||dt.isXMLDoc(e)||!Qt.test("<"+e.nodeName+">")?a=e.cloneNode(!0):(li.innerHTML=e.outerHTML,li.removeChild(a=li.firstChild)),!(dt.support.noCloneEvent&&dt.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||dt.isXMLDoc(e)))for(n=w(a),o=w(e),r=0;null!=(s=o[r]);++r)n[r]&&b(s,n[r]);
if(t)if(i)for(o=o||w(e),n=n||w(a),r=0;null!=(s=o[r]);r++)y(s,n[r]);else y(e,a);return n=w(a,"script"),n.length>0&&v(n,!l&&w(e,"script")),n=o=s=null,a},buildFragment:function(e,t,i,n){for(var s,a,r,o,l,c,d,u=e.length,h=p(t),m=[],f=0;u>f;f++)if(a=e[f],a||0===a)if("object"===dt.type(a))dt.merge(m,a.nodeType?[a]:a);else if(Zt.test(a)){for(o=o||h.appendChild(t.createElement("div")),l=(Gt.exec(a)||["",""])[1].toLowerCase(),d=ri[l]||ri._default,o.innerHTML=d[1]+a.replace(Xt,"<$1></$2>")+d[2],s=d[0];s--;)o=o.lastChild;
if(!dt.support.leadingWhitespace&&Kt.test(a)&&m.push(t.createTextNode(Kt.exec(a)[0])),!dt.support.tbody)for(a="table"!==l||Jt.test(a)?"<table>"!==d[1]||Jt.test(a)?0:o:o.firstChild,s=a&&a.childNodes.length;s--;)dt.nodeName(c=a.childNodes[s],"tbody")&&!c.childNodes.length&&a.removeChild(c);for(dt.merge(m,o.childNodes),o.textContent="";o.firstChild;)o.removeChild(o.firstChild);o=h.lastChild}else m.push(t.createTextNode(a));for(o&&h.removeChild(o),dt.support.appendChecked||dt.grep(w(m,"input"),x),f=0;a=m[f++];)if((!n||-1===dt.inArray(a,n))&&(r=dt.contains(a.ownerDocument,a),o=w(h.appendChild(a),"script"),r&&v(o),i))for(s=0;a=o[s++];)ni.test(a.type||"")&&i.push(a);
return o=null,h},cleanData:function(e,t){for(var i,n,s,a,r=0,o=dt.expando,l=dt.cache,c=dt.support.deleteExpando,d=dt.event.special;null!=(i=e[r]);r++)if((t||dt.acceptData(i))&&(s=i[o],a=s&&l[s])){if(a.events)for(n in a.events)d[n]?dt.event.remove(i,n):dt.removeEvent(i,n,a.handle);l[s]&&(delete l[s],c?delete i[o]:typeof i.removeAttribute!==Q?i.removeAttribute(o):i[o]=null,tt.push(s))}},_evalUrl:function(e){return dt.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),dt.fn.extend({wrapAll:function(e){if(dt.isFunction(e))return this.each(function(t){dt(this).wrapAll(e.call(this,t))
});if(this[0]){var t=dt(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return this.each(dt.isFunction(e)?function(t){dt(this).wrapInner(e.call(this,t))}:function(){var t=dt(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)})},wrap:function(e){var t=dt.isFunction(e);return this.each(function(i){dt(this).wrapAll(t?e.call(this,i):e)
})},unwrap:function(){return this.parent().each(function(){dt.nodeName(this,"body")||dt(this).replaceWith(this.childNodes)}).end()}});var ci,di,ui,hi=/alpha\([^)]*\)/i,pi=/opacity\s*=\s*([^)]*)/,mi=/^(top|right|bottom|left)$/,fi=/^(none|table(?!-c[ea]).+)/,gi=/^margin/,vi=new RegExp("^("+ut+")(.*)$","i"),yi=new RegExp("^("+ut+")(?!px)[a-z%]+$","i"),bi=new RegExp("^([+-])=("+ut+")","i"),wi={BODY:"block"},xi={position:"absolute",visibility:"hidden",display:"block"},ki={letterSpacing:0,fontWeight:400},Si=["Top","Right","Bottom","Left"],Ci=["Webkit","O","Moz","ms"];
dt.fn.extend({css:function(e,i){return dt.access(this,function(e,i,n){var s,a,r={},o=0;if(dt.isArray(i)){for(a=di(e),s=i.length;s>o;o++)r[i[o]]=dt.css(e,i[o],!1,a);return r}return n!==t?dt.style(e,i,n):dt.css(e,i)},e,i,arguments.length>1)},show:function(){return C(this,!0)},hide:function(){return C(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){S(this)?dt(this).show():dt(this).hide()})}}),dt.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=ui(e,"opacity");
return""===i?"1":i}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":dt.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,i,n,s){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var a,r,o,l=dt.camelCase(i),c=e.style;if(i=dt.cssProps[l]||(dt.cssProps[l]=k(c,l)),o=dt.cssHooks[i]||dt.cssHooks[l],n===t)return o&&"get"in o&&(a=o.get(e,!1,s))!==t?a:c[i];if(r=typeof n,"string"===r&&(a=bi.exec(n))&&(n=(a[1]+1)*a[2]+parseFloat(dt.css(e,i)),r="number"),!(null==n||"number"===r&&isNaN(n)||("number"!==r||dt.cssNumber[l]||(n+="px"),dt.support.clearCloneStyle||""!==n||0!==i.indexOf("background")||(c[i]="inherit"),o&&"set"in o&&(n=o.set(e,n,s))===t)))try{c[i]=n
}catch(d){}}},css:function(e,i,n,s){var a,r,o,l=dt.camelCase(i);return i=dt.cssProps[l]||(dt.cssProps[l]=k(e.style,l)),o=dt.cssHooks[i]||dt.cssHooks[l],o&&"get"in o&&(r=o.get(e,!0,n)),r===t&&(r=ui(e,i,s)),"normal"===r&&i in ki&&(r=ki[i]),""===n||n?(a=parseFloat(r),n===!0||dt.isNumeric(a)?a||0:r):r}}),e.getComputedStyle?(di=function(t){return e.getComputedStyle(t,null)},ui=function(e,i,n){var s,a,r,o=n||di(e),l=o?o.getPropertyValue(i)||o[i]:t,c=e.style;return o&&(""!==l||dt.contains(e.ownerDocument,e)||(l=dt.style(e,i)),yi.test(l)&&gi.test(i)&&(s=c.width,a=c.minWidth,r=c.maxWidth,c.minWidth=c.maxWidth=c.width=l,l=o.width,c.width=s,c.minWidth=a,c.maxWidth=r)),l
}):X.documentElement.currentStyle&&(di=function(e){return e.currentStyle},ui=function(e,i,n){var s,a,r,o=n||di(e),l=o?o[i]:t,c=e.style;return null==l&&c&&c[i]&&(l=c[i]),yi.test(l)&&!mi.test(i)&&(s=c.left,a=e.runtimeStyle,r=a&&a.left,r&&(a.left=e.currentStyle.left),c.left="fontSize"===i?"1em":l,l=c.pixelLeft+"px",c.left=s,r&&(a.left=r)),""===l?"auto":l}),dt.each(["height","width"],function(e,t){dt.cssHooks[t]={get:function(e,i,n){return i?0===e.offsetWidth&&fi.test(dt.css(e,"display"))?dt.swap(e,xi,function(){return _(e,t,n)
}):_(e,t,n):void 0},set:function(e,i,n){var s=n&&di(e);return P(e,i,n?A(e,t,n,dt.support.boxSizing&&"border-box"===dt.css(e,"boxSizing",!1,s),s):0)}}}),dt.support.opacity||(dt.cssHooks.opacity={get:function(e,t){return pi.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var i=e.style,n=e.currentStyle,s=dt.isNumeric(t)?"alpha(opacity="+100*t+")":"",a=n&&n.filter||i.filter||"";i.zoom=1,(t>=1||""===t)&&""===dt.trim(a.replace(hi,""))&&i.removeAttribute&&(i.removeAttribute("filter"),""===t||n&&!n.filter)||(i.filter=hi.test(a)?a.replace(hi,s):a+" "+s)
}}),dt(function(){dt.support.reliableMarginRight||(dt.cssHooks.marginRight={get:function(e,t){return t?dt.swap(e,{display:"inline-block"},ui,[e,"marginRight"]):void 0}}),!dt.support.pixelPosition&&dt.fn.position&&dt.each(["top","left"],function(e,t){dt.cssHooks[t]={get:function(e,i){return i?(i=ui(e,t),yi.test(i)?dt(e).position()[t]+"px":i):void 0}}})}),dt.expr&&dt.expr.filters&&(dt.expr.filters.hidden=function(e){return e.offsetWidth<=0&&e.offsetHeight<=0||!dt.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||dt.css(e,"display"))
},dt.expr.filters.visible=function(e){return!dt.expr.filters.hidden(e)}),dt.each({margin:"",padding:"",border:"Width"},function(e,t){dt.cssHooks[e+t]={expand:function(i){for(var n=0,s={},a="string"==typeof i?i.split(" "):[i];4>n;n++)s[e+Si[n]+t]=a[n]||a[n-2]||a[0];return s}},gi.test(e)||(dt.cssHooks[e+t].set=P)});var Pi=/%20/g,Ai=/\[\]$/,_i=/\r?\n/g,Ii=/^(?:submit|button|image|reset|file)$/i,Ti=/^(?:input|select|textarea|keygen)/i;dt.fn.extend({serialize:function(){return dt.param(this.serializeArray())
},serializeArray:function(){return this.map(function(){var e=dt.prop(this,"elements");return e?dt.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!dt(this).is(":disabled")&&Ti.test(this.nodeName)&&!Ii.test(e)&&(this.checked||!ti.test(e))}).map(function(e,t){var i=dt(this).val();return null==i?null:dt.isArray(i)?dt.map(i,function(e){return{name:t.name,value:e.replace(_i,"\r\n")}}):{name:t.name,value:i.replace(_i,"\r\n")}}).get()}}),dt.param=function(e,i){var n,s=[],a=function(e,t){t=dt.isFunction(t)?t():null==t?"":t,s[s.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)
};if(i===t&&(i=dt.ajaxSettings&&dt.ajaxSettings.traditional),dt.isArray(e)||e.jquery&&!dt.isPlainObject(e))dt.each(e,function(){a(this.name,this.value)});else for(n in e)M(n,e[n],i,a);return s.join("&").replace(Pi,"+")},dt.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){dt.fn[t]=function(e,i){return arguments.length>0?this.on(t,null,e,i):this.trigger(t)
}}),dt.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,i){return this.on(e,null,t,i)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,i,n){return this.on(t,e,i,n)},undelegate:function(e,t,i){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",i)}});var Mi,Di,Ei=dt.now(),Li=/\?/,Ri=/#.*$/,Oi=/([?&])_=[^&]*/,Ni=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Fi=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Bi=/^(?:GET|HEAD)$/,Ui=/^\/\//,Vi=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,zi=dt.fn.load,ji={},qi={},Hi="*/".concat("*");
try{Di=K.href}catch(Wi){Di=X.createElement("a"),Di.href="",Di=Di.href}Mi=Vi.exec(Di.toLowerCase())||[],dt.fn.load=function(e,i,n){if("string"!=typeof e&&zi)return zi.apply(this,arguments);var s,a,r,o=this,l=e.indexOf(" ");return l>=0&&(s=e.slice(l,e.length),e=e.slice(0,l)),dt.isFunction(i)?(n=i,i=t):i&&"object"==typeof i&&(r="POST"),o.length>0&&dt.ajax({url:e,type:r,dataType:"html",data:i}).done(function(e){a=arguments,o.html(s?dt("<div>").append(dt.parseHTML(e)).find(s):e)}).complete(n&&function(e,t){o.each(n,a||[e.responseText,t,e])
}),this},dt.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){dt.fn[t]=function(e){return this.on(t,e)}}),dt.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Di,type:"GET",isLocal:Fi.test(Mi[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hi,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":dt.parseJSON,"text xml":dt.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?L(L(e,dt.ajaxSettings),t):L(dt.ajaxSettings,e)
},ajaxPrefilter:D(ji),ajaxTransport:D(qi),ajax:function(e,i){function n(e,i,n,s){var a,u,y,b,x,S=i;2!==w&&(w=2,l&&clearTimeout(l),d=t,o=s||"",k.readyState=e>0?4:0,a=e>=200&&300>e||304===e,n&&(b=R(h,k,n)),b=O(h,b,k,a),a?(h.ifModified&&(x=k.getResponseHeader("Last-Modified"),x&&(dt.lastModified[r]=x),x=k.getResponseHeader("etag"),x&&(dt.etag[r]=x)),204===e||"HEAD"===h.type?S="nocontent":304===e?S="notmodified":(S=b.state,u=b.data,y=b.error,a=!y)):(y=S,(e||!S)&&(S="error",0>e&&(e=0))),k.status=e,k.statusText=(i||S)+"",a?f.resolveWith(p,[u,S,k]):f.rejectWith(p,[k,S,y]),k.statusCode(v),v=t,c&&m.trigger(a?"ajaxSuccess":"ajaxError",[k,h,a?u:y]),g.fireWith(p,[k,S]),c&&(m.trigger("ajaxComplete",[k,h]),--dt.active||dt.event.trigger("ajaxStop")))
}"object"==typeof e&&(i=e,e=t),i=i||{};var s,a,r,o,l,c,d,u,h=dt.ajaxSetup({},i),p=h.context||h,m=h.context&&(p.nodeType||p.jquery)?dt(p):dt.event,f=dt.Deferred(),g=dt.Callbacks("once memory"),v=h.statusCode||{},y={},b={},w=0,x="canceled",k={readyState:0,getResponseHeader:function(e){var t;if(2===w){if(!u)for(u={};t=Ni.exec(o);)u[t[1].toLowerCase()]=t[2];t=u[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===w?o:null},setRequestHeader:function(e,t){var i=e.toLowerCase();
return w||(e=b[i]=b[i]||e,y[e]=t),this},overrideMimeType:function(e){return w||(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>w)for(t in e)v[t]=[v[t],e[t]];else k.always(e[k.status]);return this},abort:function(e){var t=e||x;return d&&d.abort(t),n(0,t),this}};if(f.promise(k).complete=g.add,k.success=k.done,k.error=k.fail,h.url=((e||h.url||Di)+"").replace(Ri,"").replace(Ui,Mi[1]+"//"),h.type=i.method||i.type||h.method||h.type,h.dataTypes=dt.trim(h.dataType||"*").toLowerCase().match(ht)||[""],null==h.crossDomain&&(s=Vi.exec(h.url.toLowerCase()),h.crossDomain=!(!s||s[1]===Mi[1]&&s[2]===Mi[2]&&(s[3]||("http:"===s[1]?"80":"443"))===(Mi[3]||("http:"===Mi[1]?"80":"443")))),h.data&&h.processData&&"string"!=typeof h.data&&(h.data=dt.param(h.data,h.traditional)),E(ji,h,i,k),2===w)return k;
c=h.global,c&&0===dt.active++&&dt.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Bi.test(h.type),r=h.url,h.hasContent||(h.data&&(r=h.url+=(Li.test(r)?"&":"?")+h.data,delete h.data),h.cache===!1&&(h.url=Oi.test(r)?r.replace(Oi,"$1_="+Ei++):r+(Li.test(r)?"&":"?")+"_="+Ei++)),h.ifModified&&(dt.lastModified[r]&&k.setRequestHeader("If-Modified-Since",dt.lastModified[r]),dt.etag[r]&&k.setRequestHeader("If-None-Match",dt.etag[r])),(h.data&&h.hasContent&&h.contentType!==!1||i.contentType)&&k.setRequestHeader("Content-Type",h.contentType),k.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+Hi+"; q=0.01":""):h.accepts["*"]);
for(a in h.headers)k.setRequestHeader(a,h.headers[a]);if(h.beforeSend&&(h.beforeSend.call(p,k,h)===!1||2===w))return k.abort();x="abort";for(a in{success:1,error:1,complete:1})k[a](h[a]);if(d=E(qi,h,i,k)){k.readyState=1,c&&m.trigger("ajaxSend",[k,h]),h.async&&h.timeout>0&&(l=setTimeout(function(){k.abort("timeout")},h.timeout));try{w=1,d.send(y,n)}catch(S){if(!(2>w))throw S;n(-1,S)}}else n(-1,"No Transport");return k},getJSON:function(e,t,i){return dt.get(e,t,i,"json")},getScript:function(e,i){return dt.get(e,t,i,"script")
}}),dt.each(["get","post"],function(e,i){dt[i]=function(e,n,s,a){return dt.isFunction(n)&&(a=a||s,s=n,n=t),dt.ajax({url:e,type:i,dataType:a,data:n,success:s})}}),dt.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return dt.globalEval(e),e}}}),dt.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),dt.ajaxTransport("script",function(e){if(e.crossDomain){var i,n=X.head||dt("head")[0]||X.documentElement;
return{send:function(t,s){i=X.createElement("script"),i.async=!0,e.scriptCharset&&(i.charset=e.scriptCharset),i.src=e.url,i.onload=i.onreadystatechange=function(e,t){(t||!i.readyState||/loaded|complete/.test(i.readyState))&&(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),i=null,t||s(200,"success"))},n.insertBefore(i,n.firstChild)},abort:function(){i&&i.onload(t,!0)}}}});var $i=[],Yi=/(=)\?(?=&|$)|\?\?/;dt.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=$i.pop()||dt.expando+"_"+Ei++;
return this[e]=!0,e}}),dt.ajaxPrefilter("json jsonp",function(i,n,s){var a,r,o,l=i.jsonp!==!1&&(Yi.test(i.url)?"url":"string"==typeof i.data&&!(i.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yi.test(i.data)&&"data");return l||"jsonp"===i.dataTypes[0]?(a=i.jsonpCallback=dt.isFunction(i.jsonpCallback)?i.jsonpCallback():i.jsonpCallback,l?i[l]=i[l].replace(Yi,"$1"+a):i.jsonp!==!1&&(i.url+=(Li.test(i.url)?"&":"?")+i.jsonp+"="+a),i.converters["script json"]=function(){return o||dt.error(a+" was not called"),o[0]
},i.dataTypes[0]="json",r=e[a],e[a]=function(){o=arguments},s.always(function(){e[a]=r,i[a]&&(i.jsonpCallback=n.jsonpCallback,$i.push(a)),o&&dt.isFunction(r)&&r(o[0]),o=r=t}),"script"):void 0});var Qi,Ki,Xi=0,Gi=e.ActiveXObject&&function(){var e;for(e in Qi)Qi[e](t,!0)};dt.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&N()||F()}:N,Ki=dt.ajaxSettings.xhr(),dt.support.cors=!!Ki&&"withCredentials"in Ki,Ki=dt.support.ajax=!!Ki,Ki&&dt.ajaxTransport(function(i){if(!i.crossDomain||dt.support.cors){var n;
return{send:function(s,a){var r,o,l=i.xhr();if(i.username?l.open(i.type,i.url,i.async,i.username,i.password):l.open(i.type,i.url,i.async),i.xhrFields)for(o in i.xhrFields)l[o]=i.xhrFields[o];i.mimeType&&l.overrideMimeType&&l.overrideMimeType(i.mimeType),i.crossDomain||s["X-Requested-With"]||(s["X-Requested-With"]="XMLHttpRequest");try{for(o in s)l.setRequestHeader(o,s[o])}catch(c){}l.send(i.hasContent&&i.data||null),n=function(e,s){var o,c,d,u;try{if(n&&(s||4===l.readyState))if(n=t,r&&(l.onreadystatechange=dt.noop,Gi&&delete Qi[r]),s)4!==l.readyState&&l.abort();
else{u={},o=l.status,c=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(u.text=l.responseText);try{d=l.statusText}catch(h){d=""}o||!i.isLocal||i.crossDomain?1223===o&&(o=204):o=u.text?200:404}}catch(p){s||a(-1,p)}u&&a(o,d,u,c)},i.async?4===l.readyState?setTimeout(n):(r=++Xi,Gi&&(Qi||(Qi={},dt(e).unload(Gi)),Qi[r]=n),l.onreadystatechange=n):n()},abort:function(){n&&n(t,!0)}}}});var Ji,Zi,en=/^(?:toggle|show|hide)$/,tn=new RegExp("^(?:([+-])=|)("+ut+")([a-z%]*)$","i"),nn=/queueHooks$/,sn=[j],an={"*":[function(e,t){var i=this.createTween(e,t),n=i.cur(),s=tn.exec(t),a=s&&s[3]||(dt.cssNumber[e]?"":"px"),r=(dt.cssNumber[e]||"px"!==a&&+n)&&tn.exec(dt.css(i.elem,e)),o=1,l=20;
if(r&&r[3]!==a){a=a||r[3],s=s||[],r=+n||1;do o=o||".5",r/=o,dt.style(i.elem,e,r+a);while(o!==(o=i.cur()/n)&&1!==o&&--l)}return s&&(r=i.start=+r||+n||0,i.unit=a,i.end=s[1]?r+(s[1]+1)*s[2]:+s[2]),i}]};dt.Animation=dt.extend(V,{tweener:function(e,t){dt.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");for(var i,n=0,s=e.length;s>n;n++)i=e[n],an[i]=an[i]||[],an[i].unshift(t)},prefilter:function(e,t){t?sn.unshift(e):sn.push(e)}}),dt.Tween=q,q.prototype={constructor:q,init:function(e,t,i,n,s,a){this.elem=e,this.prop=i,this.easing=s||"swing",this.options=t,this.start=this.now=this.cur(),this.end=n,this.unit=a||(dt.cssNumber[i]?"":"px")
},cur:function(){var e=q.propHooks[this.prop];return e&&e.get?e.get(this):q.propHooks._default.get(this)},run:function(e){var t,i=q.propHooks[this.prop];return this.pos=t=this.options.duration?dt.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),i&&i.set?i.set(this):q.propHooks._default.set(this),this}},q.prototype.init.prototype=q.prototype,q.propHooks={_default:{get:function(e){var t;
return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=dt.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){dt.fx.step[e.prop]?dt.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[dt.cssProps[e.prop]]||dt.cssHooks[e.prop])?dt.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},q.propHooks.scrollTop=q.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},dt.each(["toggle","show","hide"],function(e,t){var i=dt.fn[t];
dt.fn[t]=function(e,n,s){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(H(t,!0),e,n,s)}}),dt.fn.extend({fadeTo:function(e,t,i,n){return this.filter(S).css("opacity",0).show().end().animate({opacity:t},e,i,n)},animate:function(e,t,i,n){var s=dt.isEmptyObject(e),a=dt.speed(t,i,n),r=function(){var t=V(this,dt.extend({},e),a);(s||dt._data(this,"finish"))&&t.stop(!0)};return r.finish=r,s||a.queue===!1?this.each(r):this.queue(a.queue,r)},stop:function(e,i,n){var s=function(e){var t=e.stop;
delete e.stop,t(n)};return"string"!=typeof e&&(n=i,i=e,e=t),i&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",a=dt.timers,r=dt._data(this);if(i)r[i]&&r[i].stop&&s(r[i]);else for(i in r)r[i]&&r[i].stop&&nn.test(i)&&s(r[i]);for(i=a.length;i--;)a[i].elem!==this||null!=e&&a[i].queue!==e||(a[i].anim.stop(n),t=!1,a.splice(i,1));(t||!n)&&dt.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,i=dt._data(this),n=i[e+"queue"],s=i[e+"queueHooks"],a=dt.timers,r=n?n.length:0;
for(i.finish=!0,dt.queue(this,e,[]),s&&s.stop&&s.stop.call(this,!0),t=a.length;t--;)a[t].elem===this&&a[t].queue===e&&(a[t].anim.stop(!0),a.splice(t,1));for(t=0;r>t;t++)n[t]&&n[t].finish&&n[t].finish.call(this);delete i.finish})}}),dt.each({slideDown:H("show"),slideUp:H("hide"),slideToggle:H("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){dt.fn[e]=function(e,i,n){return this.animate(t,e,i,n)}}),dt.speed=function(e,t,i){var n=e&&"object"==typeof e?dt.extend({},e):{complete:i||!i&&t||dt.isFunction(e)&&e,duration:e,easing:i&&t||t&&!dt.isFunction(t)&&t};
return n.duration=dt.fx.off?0:"number"==typeof n.duration?n.duration:n.duration in dt.fx.speeds?dt.fx.speeds[n.duration]:dt.fx.speeds._default,(null==n.queue||n.queue===!0)&&(n.queue="fx"),n.old=n.complete,n.complete=function(){dt.isFunction(n.old)&&n.old.call(this),n.queue&&dt.dequeue(this,n.queue)},n},dt.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},dt.timers=[],dt.fx=q.prototype.init,dt.fx.tick=function(){var e,i=dt.timers,n=0;for(Ji=dt.now();n<i.length;n++)e=i[n],e()||i[n]!==e||i.splice(n--,1);
i.length||dt.fx.stop(),Ji=t},dt.fx.timer=function(e){e()&&dt.timers.push(e)&&dt.fx.start()},dt.fx.interval=13,dt.fx.start=function(){Zi||(Zi=setInterval(dt.fx.tick,dt.fx.interval))},dt.fx.stop=function(){clearInterval(Zi),Zi=null},dt.fx.speeds={slow:600,fast:200,_default:400},dt.fx.step={},dt.expr&&dt.expr.filters&&(dt.expr.filters.animated=function(e){return dt.grep(dt.timers,function(t){return e===t.elem}).length}),dt.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){dt.offset.setOffset(this,e,t)
});var i,n,s={top:0,left:0},a=this[0],r=a&&a.ownerDocument;if(r)return i=r.documentElement,dt.contains(i,a)?(typeof a.getBoundingClientRect!==Q&&(s=a.getBoundingClientRect()),n=W(r),{top:s.top+(n.pageYOffset||i.scrollTop)-(i.clientTop||0),left:s.left+(n.pageXOffset||i.scrollLeft)-(i.clientLeft||0)}):s},dt.offset={setOffset:function(e,t,i){var n=dt.css(e,"position");"static"===n&&(e.style.position="relative");var s,a,r=dt(e),o=r.offset(),l=dt.css(e,"top"),c=dt.css(e,"left"),d=("absolute"===n||"fixed"===n)&&dt.inArray("auto",[l,c])>-1,u={},h={};
d?(h=r.position(),s=h.top,a=h.left):(s=parseFloat(l)||0,a=parseFloat(c)||0),dt.isFunction(t)&&(t=t.call(e,i,o)),null!=t.top&&(u.top=t.top-o.top+s),null!=t.left&&(u.left=t.left-o.left+a),"using"in t?t.using.call(e,u):r.css(u)}},dt.fn.extend({position:function(){if(this[0]){var e,t,i={top:0,left:0},n=this[0];return"fixed"===dt.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),dt.nodeName(e[0],"html")||(i=e.offset()),i.top+=dt.css(e[0],"borderTopWidth",!0),i.left+=dt.css(e[0],"borderLeftWidth",!0)),{top:t.top-i.top-dt.css(n,"marginTop",!0),left:t.left-i.left-dt.css(n,"marginLeft",!0)}
}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent||G;e&&!dt.nodeName(e,"html")&&"static"===dt.css(e,"position");)e=e.offsetParent;return e||G})}}),dt.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,i){var n=/Y/.test(i);dt.fn[e]=function(s){return dt.access(this,function(e,s,a){var r=W(e);return a===t?r?i in r?r[i]:r.document.documentElement[s]:e[s]:void(r?r.scrollTo(n?dt(r).scrollLeft():a,n?a:dt(r).scrollTop()):e[s]=a)},e,s,arguments.length,null)
}}),dt.each({Height:"height",Width:"width"},function(e,i){dt.each({padding:"inner"+e,content:i,"":"outer"+e},function(n,s){dt.fn[s]=function(s,a){var r=arguments.length&&(n||"boolean"!=typeof s),o=n||(s===!0||a===!0?"margin":"border");return dt.access(this,function(i,n,s){var a;return dt.isWindow(i)?i.document.documentElement["client"+e]:9===i.nodeType?(a=i.documentElement,Math.max(i.body["scroll"+e],a["scroll"+e],i.body["offset"+e],a["offset"+e],a["client"+e])):s===t?dt.css(i,n,o):dt.style(i,n,s,o)
},i,r?s:t,r,null)}})}),dt.fn.size=function(){return this.length},dt.fn.andSelf=dt.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=dt:(e.jQuery=e.$=dt,"function"==typeof define&&define.amd&&define("jquery-lib",[],function(){return dt}))}(window),define("plex/base/utils/jquery/selectText",["jquery-lib"],function(e){"use strict";e.fn.selectText=function(){var e,t=this[0];if(document.body.createTextRange)e=document.body.createTextRange(),e.moveToElementText(t),e.select();
else if(window.getSelection){var i=window.getSelection();e=document.createRange(),e.selectNodeContents(t),i.removeAllRanges(),i.addRange(e)}}}),define("plex/base/utils/jquery/isDisabled",["jquery-lib"],function(e){"use strict";e.fn.isDisabled=function(){return this.hasClass("disabled")||this.hasClass("active")||this.hasClass("hidden")}}),define("plex/base/utils/jquery/triggerReflow",["jquery-lib"],function(e){"use strict";e.fn.triggerReflow=function(){var e=this[0];return e&&e.offsetHeight,this}}),define("jquery",["underscore","jquery-lib","plex/base/utils/jquery/selectText","plex/base/utils/jquery/isDisabled","plex/base/utils/jquery/triggerReflow"],function(e,t){"use strict";
t.support.cors||t.ajaxPrefilter(function(t){if(t.crossDomain&&t.async){var i=t.type.toUpperCase();!t.data||"GET"!=i&&"HEAD"!=i||(t.url+="?"+t.data,delete t.data),t.headers||(t.headers={});var n="X-Plex-",s=e.filter(e.keys(t.headers),function(e){return 0===e.lastIndexOf(n,0)});e.each(s,function(e){t.headers["X-Plex-Proxy-"+e.slice(n.length)]=t.headers[e],delete t.headers[e]}),t.headers["X-Plex-Url"]=t.url,t.url="/system/proxy",t.crossDomain=!1,t.headers["X-Plex-Proxy-Token"]&&(t.headers["X-Plex-Token"]=t.headers["X-Plex-Proxy-Token"])
}});var i=["Cache-Control","Content-Language","Content-Type","Expires","Last-Modified","Pragma","Location"],n=t.ajaxSettings.xhr;return t.ajaxSettings.xhr=function(){var t=n(),s=t.getAllResponseHeaders;return t.getAllResponseHeaders=function(){var n=s.apply(t);if(n)return n;var a=[];return e.each(i,function(e){var i=t.getResponseHeader(e);i&&a.push(e+": "+i)}),a.join("\n")},t},t.ajaxPrefilter(function(e){return e.crossDomain&&!e.skipCorsWithRedirect?"cors_with_redirect":void 0}),t.ajaxTransport("cors_with_redirect",function(i,n,s){i.dataTypes.shift();
var a,r=e.extend({},n,{skipCorsWithRedirect:!0,complete:null,error:null,success:null});return{send:function(i,o){r.error=function(t,i){e.extend(s,t),o(t.status,i,{alreadyConverted:t.responseText},t.getAllResponseHeaders())},r.success=function(i,l,c){e.extend(s,c);var d=c.getResponseHeader("Location");200==c.status&&d&&n&&!n.skipCorsLocationRequest?(r.url=d,a=t.ajax(r)):o(c.status,l,{alreadyConverted:c.responseText},c.getAllResponseHeaders())},a=t.ajax(r)},abort:function(){a&&a.abort()}}}),t}),function(e,t){if("function"==typeof define&&define.amd)define("backbone-lib",["underscore","jquery","exports"],function(i,n,s){e.Backbone=t(e,s,i,n)
});else if("undefined"!=typeof exports){var i=require("underscore");t(e,exports,i)}else e.Backbone=t(e,{},e._,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,t,i,n){{var s=e.Backbone,a=[],r=(a.push,a.slice);a.splice}t.VERSION="1.1.2",t.$=n,t.noConflict=function(){return e.Backbone=s,this},t.emulateHTTP=!1,t.emulateJSON=!1;var o=t.Events={on:function(e,t,i){if(!c(this,"on",e,[t,i])||!t)return this;this._events||(this._events={});var n=this._events[e]||(this._events[e]=[]);return n.push({callback:t,context:i,ctx:i||this}),this
},once:function(e,t,n){if(!c(this,"once",e,[t,n])||!t)return this;var s=this,a=i.once(function(){s.off(e,a),t.apply(this,arguments)});return a._callback=t,this.on(e,a,n)},off:function(e,t,n){var s,a,r,o,l,d,u,h;if(!this._events||!c(this,"off",e,[t,n]))return this;if(!e&&!t&&!n)return this._events=void 0,this;for(o=e?[e]:i.keys(this._events),l=0,d=o.length;d>l;l++)if(e=o[l],r=this._events[e]){if(this._events[e]=s=[],t||n)for(u=0,h=r.length;h>u;u++)a=r[u],(t&&t!==a.callback&&t!==a.callback._callback||n&&n!==a.context)&&s.push(a);
s.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=r.call(arguments,1);if(!c(this,"trigger",e,t))return this;var i=this._events[e],n=this._events.all;return i&&d(i,t),n&&d(n,arguments),this},stopListening:function(e,t,n){var s=this._listeningTo;if(!s)return this;var a=!t&&!n;n||"object"!=typeof t||(n=this),e&&((s={})[e._listenId]=e);for(var r in s)e=s[r],e.off(t,n,this),(a||i.isEmpty(e._events))&&delete this._listeningTo[r];return this}},l=/\s+/,c=function(e,t,i,n){if(!i)return!0;
if("object"==typeof i){for(var s in i)e[t].apply(e,[s,i[s]].concat(n));return!1}if(l.test(i)){for(var a=i.split(l),r=0,o=a.length;o>r;r++)e[t].apply(e,[a[r]].concat(n));return!1}return!0},d=function(e,t){var i,n=-1,s=e.length,a=t[0],r=t[1],o=t[2];switch(t.length){case 0:for(;++n<s;)(i=e[n]).callback.call(i.ctx);return;case 1:for(;++n<s;)(i=e[n]).callback.call(i.ctx,a);return;case 2:for(;++n<s;)(i=e[n]).callback.call(i.ctx,a,r);return;case 3:for(;++n<s;)(i=e[n]).callback.call(i.ctx,a,r,o);return;default:for(;++n<s;)(i=e[n]).callback.apply(i.ctx,t);
return}},u={listenTo:"on",listenToOnce:"once"};i.each(u,function(e,t){o[t]=function(t,n,s){var a=this._listeningTo||(this._listeningTo={}),r=t._listenId||(t._listenId=i.uniqueId("l"));return a[r]=t,s||"object"!=typeof n||(s=this),t[e](n,s,this),this}}),o.bind=o.on,o.unbind=o.off,i.extend(t,o);var h=t.Model=function(e,t){var n=e||{};t||(t={}),this.cid=i.uniqueId("c"),this.attributes={},t.collection&&(this.collection=t.collection),t.parse&&(n=this.parse(n,t)||{}),n=i.defaults({},n,i.result(this,"defaults")),this.set(n,t),this.changed={},this.initialize.apply(this,arguments)
};i.extend(h.prototype,o,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(){return i.clone(this.attributes)},sync:function(){return t.sync.apply(this,arguments)},get:function(e){return this.attributes[e]},escape:function(e){return i.escape(this.get(e))},has:function(e){return null!=this.get(e)},set:function(e,t,n){var s,a,r,o,l,c,d,u;if(null==e)return this;if("object"==typeof e?(a=e,n=t):(a={})[e]=t,n||(n={}),!this._validate(a,n))return!1;r=n.unset,l=n.silent,o=[],c=this._changing,this._changing=!0,c||(this._previousAttributes=i.clone(this.attributes),this.changed={}),u=this.attributes,d=this._previousAttributes,this.idAttribute in a&&(this.id=a[this.idAttribute]);
for(s in a)t=a[s],i.isEqual(u[s],t)||o.push(s),i.isEqual(d[s],t)?delete this.changed[s]:this.changed[s]=t,r?delete u[s]:u[s]=t;if(!l){o.length&&(this._pending=n);for(var h=0,p=o.length;p>h;h++)this.trigger("change:"+o[h],this,u[o[h]],n)}if(c)return this;if(!l)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,i.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var n in this.attributes)t[n]=void 0;
return this.set(t,i.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!i.isEmpty(this.changed):i.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?i.clone(this.changed):!1;var t,n=!1,s=this._changing?this._previousAttributes:this.attributes;for(var a in e)i.isEqual(s[a],t=e[a])||((n||(n={}))[a]=t);return n},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return i.clone(this._previousAttributes)
},fetch:function(e){e=e?i.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,n=e.success;return e.success=function(i){return t.set(t.parse(i,e),e)?(n&&n(t,i,e),void t.trigger("sync",t,i,e)):!1},F(this,e),this.sync("read",this,e)},save:function(e,t,n){var s,a,r,o=this.attributes;if(null==e||"object"==typeof e?(s=e,n=t):(s={})[e]=t,n=i.extend({validate:!0},n),s&&!n.wait){if(!this.set(s,n))return!1}else if(!this._validate(s,n))return!1;s&&n.wait&&(this.attributes=i.extend({},o,s)),void 0===n.parse&&(n.parse=!0);
var l=this,c=n.success;return n.success=function(e){l.attributes=o;var t=l.parse(e,n);return n.wait&&(t=i.extend(s||{},t)),i.isObject(t)&&!l.set(t,n)?!1:(c&&c(l,e,n),void l.trigger("sync",l,e,n))},F(this,n),a=this.isNew()?"create":n.patch?"patch":"update","patch"===a&&(n.attrs=s),r=this.sync(a,this,n),s&&n.wait&&(this.attributes=o),r},destroy:function(e){e=e?i.clone(e):{};var t=this,n=e.success,s=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(i){(e.wait||t.isNew())&&s(),n&&n(t,i,e),t.isNew()||t.trigger("sync",t,i,e)
},this.isNew())return e.success(),!1;F(this,e);var a=this.sync("delete",this,e);return e.wait||s(),a},url:function(){var e=i.result(this,"urlRoot")||i.result(this.collection,"url")||N();return this.isNew()?e:e.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(e){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(e){return this._validate({},i.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;
e=i.extend({},this.attributes,e);var n=this.validationError=this.validate(e,t)||null;return n?(this.trigger("invalid",this,n,i.extend(t,{validationError:n})),!1):!0}});var p=["keys","values","pairs","invert","pick","omit"];i.each(p,function(e){h.prototype[e]=function(){var t=r.call(arguments);return t.unshift(this.attributes),i[e].apply(i,t)}});var m=t.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,i.extend({silent:!0},t))
},f={add:!0,remove:!0,merge:!0},g={add:!0,remove:!1};i.extend(m.prototype,o,{model:h,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return t.sync.apply(this,arguments)},add:function(e,t){return this.set(e,i.extend({merge:!1},t,g))},remove:function(e,t){var n=!i.isArray(e);e=n?[e]:i.clone(e),t||(t={});var s,a,r,o;for(s=0,a=e.length;a>s;s++)o=e[s]=this.get(e[s]),o&&(delete this._byId[o.id],delete this._byId[o.cid],r=this.indexOf(o),this.models.splice(r,1),this.length--,t.silent||(t.index=r,o.trigger("remove",o,this,t)),this._removeReference(o,t));
return n?e[0]:e},set:function(e,t){t=i.defaults({},t,f),t.parse&&(e=this.parse(e,t));var n=!i.isArray(e);e=n?e?[e]:[]:i.clone(e);var s,a,r,o,l,c,d,u=t.at,p=this.model,m=this.comparator&&null==u&&t.sort!==!1,g=i.isString(this.comparator)?this.comparator:null,v=[],y=[],b={},w=t.add,x=t.merge,k=t.remove,S=!m&&w&&k?[]:!1;for(s=0,a=e.length;a>s;s++){if(l=e[s]||{},r=l instanceof h?o=l:l[p.prototype.idAttribute||"id"],c=this.get(r))k&&(b[c.cid]=!0),x&&(l=l===o?o.attributes:l,t.parse&&(l=c.parse(l,t)),c.set(l,t),m&&!d&&c.hasChanged(g)&&(d=!0)),e[s]=c;
else if(w){if(o=e[s]=this._prepareModel(l,t),!o)continue;v.push(o),this._addReference(o,t)}o=c||o,!S||!o.isNew()&&b[o.id]||S.push(o),b[o.id]=!0}if(k){for(s=0,a=this.length;a>s;++s)b[(o=this.models[s]).cid]||y.push(o);y.length&&this.remove(y,t)}if(v.length||S&&S.length)if(m&&(d=!0),this.length+=v.length,null!=u)for(s=0,a=v.length;a>s;s++)this.models.splice(u+s,0,v[s]);else{S&&(this.models.length=0);var C=S||v;for(s=0,a=C.length;a>s;s++)this.models.push(C[s])}if(d&&this.sort({silent:!0}),!t.silent){for(s=0,a=v.length;a>s;s++)(o=v[s]).trigger("add",o,this,t);
(d||S&&S.length)&&this.trigger("sort",this,t)}return n?e[0]:e},reset:function(e,t){t||(t={});for(var n=0,s=this.models.length;s>n;n++)this._removeReference(this.models[n],t);return t.previousModels=this.models,this._reset(),e=this.add(e,i.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),e},push:function(e,t){return this.add(e,i.extend({at:this.length},t))},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return this.add(e,i.extend({at:0},t))
},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(){return r.apply(this.models,arguments)},get:function(e){return null==e?void 0:this._byId[e]||this._byId[e.id]||this._byId[e.cid]},at:function(e){return this.models[e]},where:function(e,t){return i.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var i in e)if(e[i]!==t.get(i))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");
return e||(e={}),i.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(i.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return i.invoke(this.models,"get",e)},fetch:function(e){e=e?i.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,n=this;return e.success=function(i){var s=e.reset?"reset":"set";n[s](i,e),t&&t(n,i,e),n.trigger("sync",n,i,e)},F(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?i.clone(t):{},!(e=this._prepareModel(e,t)))return!1;
t.wait||this.add(e,t);var n=this,s=t.success;return t.success=function(e,i){t.wait&&n.add(e,t),s&&s(e,i,t)},e.save(null,t),e},parse:function(e){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof h)return e;t=t?i.clone(t):{},t.collection=this;var n=new this.model(e,t);return n.validationError?(this.trigger("invalid",this,n.validationError,t),!1):n},_addReference:function(e){this._byId[e.cid]=e,null!=e.id&&(this._byId[e.id]=e),e.collection||(e.collection=this),e.on("all",this._onModelEvent,this)
},_removeReference:function(e){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,i,n){("add"!==e&&"remove"!==e||i===this)&&("destroy"===e&&this.remove(t,n),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var v=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];
i.each(v,function(e){m.prototype[e]=function(){var t=r.call(arguments);return t.unshift(this.models),i[e].apply(i,t)}});var y=["groupBy","countBy","sortBy","indexBy"];i.each(y,function(e){m.prototype[e]=function(t,n){var s=i.isFunction(t)?t:function(e){return e.get(t)};return i[e](this.models,s,n)}});var b=t.View=function(e){this.cid=i.uniqueId("view"),e||(e={}),i.extend(this,i.pick(e,x)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},w=/^(\S+)\s*(.*)$/,x=["model","collection","el","id","attributes","className","tagName","events"];
i.extend(b.prototype,o,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(e,i){return this.$el&&this.undelegateEvents(),this.$el=e instanceof t.$?e:t.$(e),this.el=this.$el[0],i!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=i.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var n=e[t];if(i.isFunction(n)||(n=this[e[t]]),n){var s=t.match(w),a=s[1],r=s[2];
n=i.bind(n,this),a+=".delegateEvents"+this.cid,""===r?this.$el.on(a,n):this.$el.on(a,r,n)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(i.result(this,"el"),!1);else{var e=i.extend({},i.result(this,"attributes"));this.id&&(e.id=i.result(this,"id")),this.className&&(e["class"]=i.result(this,"className"));var n=t.$("<"+i.result(this,"tagName")+">").attr(e);this.setElement(n,!1)}}}),t.sync=function(e,n,s){var a=S[e];
i.defaults(s||(s={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON});var r={type:a,dataType:"json"};if(s.url||(r.url=i.result(n,"url")||N()),null!=s.data||!n||"create"!==e&&"update"!==e&&"patch"!==e||(r.contentType="application/json",r.data=JSON.stringify(s.attrs||n.toJSON(s))),s.emulateJSON&&(r.contentType="application/x-www-form-urlencoded",r.data=r.data?{model:r.data}:{}),s.emulateHTTP&&("PUT"===a||"DELETE"===a||"PATCH"===a)){r.type="POST",s.emulateJSON&&(r.data._method=a);var o=s.beforeSend;
s.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",a),o?o.apply(this,arguments):void 0}}"GET"===r.type||s.emulateJSON||(r.processData=!1),"PATCH"===r.type&&k&&(r.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var l=s.xhr=t.ajax(i.extend(r,s));return n.trigger("request",n,l,s),l};var k=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),S={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};
t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var C=t.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},P=/\((.*?)\)/g,A=/(\(\?)?:\w+/g,_=/\*\w+/g,I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend(C.prototype,o,{initialize:function(){},route:function(e,n,s){i.isRegExp(e)||(e=this._routeToRegExp(e)),i.isFunction(n)&&(s=n,n=""),s||(s=this[n]);var a=this;return t.history.route(e,function(i){var r=a._extractParameters(e,i);a.execute(s,r),a.trigger.apply(a,["route:"+n].concat(r)),a.trigger("route",n,r),t.history.trigger("route",a,n,r)
}),this},execute:function(e,t){e&&e.apply(this,t)},navigate:function(e,i){return t.history.navigate(e,i),this},_bindRoutes:function(){if(this.routes){this.routes=i.result(this,"routes");for(var e,t=i.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(I,"\\$&").replace(P,"(?:$1)?").replace(A,function(e,t){return t?e:"([^/?]+)"}).replace(_,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){var n=e.exec(t).slice(1);
return i.map(n,function(e,t){return t===n.length-1?e||null:e?decodeURIComponent(e):null})}});var T=t.History=function(){this.handlers=[],i.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},M=/^[#\/]|\s+$/g,D=/^\/+|\/+$/g,E=/msie [\w.]+/,L=/\/$/,R=/#.*$/;T.started=!1,i.extend(T.prototype,o,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);
return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=decodeURI(this.location.pathname+this.location.search);var i=this.root.replace(L,"");e.indexOf(i)||(e=e.slice(i.length))}else e=this.getHash();return e.replace(M,"")},start:function(e){if(T.started)throw new Error("Backbone.history has already been started");T.started=!0,this.options=i.extend({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);
var n=this.getFragment(),s=document.documentMode,a=E.exec(navigator.userAgent.toLowerCase())&&(!s||7>=s);if(this.root=("/"+this.root+"/").replace(D,"/"),a&&this._wantsHashChange){var r=t.$('<iframe src="javascript:0" tabindex="-1">');this.iframe=r.hide().appendTo("body")[0].contentWindow,this.navigate(n)}this._hasPushState?t.$(window).on("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!a?t.$(window).on("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=n;
var o=this.location;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot())return this.fragment=this.getFragment(null,!0),this.location.replace(this.root+"#"+this.fragment),!0;this._hasPushState&&this.atRoot()&&o.hash&&(this.fragment=this.getHash().replace(M,""),this.history.replaceState({},document.title,this.root+this.fragment))}return this.options.silent?void 0:this.loadUrl()},stop:function(){t.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),T.started=!1
},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(){var e=this.getFragment();return e===this.fragment&&this.iframe&&(e=this.getFragment(this.getHash(this.iframe))),e===this.fragment?!1:(this.iframe&&this.navigate(e),void this.loadUrl())},loadUrl:function(e){return e=this.fragment=this.getFragment(e),i.any(this.handlers,function(t){return t.route.test(e)?(t.callback(e),!0):void 0})},navigate:function(e,t){if(!T.started)return!1;t&&t!==!0||(t={trigger:!!t});var i=this.root+(e=this.getFragment(e||""));
if(e=e.replace(R,""),this.fragment!==e){if(this.fragment=e,""===e&&"/"!==i&&(i=i.slice(0,-1)),this._hasPushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,i);else{if(!this._wantsHashChange)return this.location.assign(i);this._updateHash(this.location,e,t.replace),this.iframe&&e!==this.getFragment(this.getHash(this.iframe))&&(t.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,e,t.replace))}return t.trigger?this.loadUrl(e):void 0}},_updateHash:function(e,t,i){if(i){var n=e.href.replace(/(javascript:|#).*$/,"");
e.replace(n+"#"+t)}else e.hash="#"+t}}),t.history=new T;var O=function(e,t){var n,s=this;n=e&&i.has(e,"constructor")?e.constructor:function(){return s.apply(this,arguments)},i.extend(n,s,t);var a=function(){this.constructor=n};return a.prototype=s.prototype,n.prototype=new a,e&&i.extend(n.prototype,e),n.__super__=s.prototype,n};h.extend=m.extend=C.extend=b.extend=T.extend=O;var N=function(){throw new Error('A "url" property or function must be specified')},F=function(e,t){var i=t.error;t.error=function(n){i&&i(e,n,t),e.trigger("error",e,n,t)
}};return t}),define("plex/base/utils/BaseClass",["underscore"],function(e){"use strict";function t(){e.isFunction(this.initialize)&&this.initialize.apply(this,arguments)}var i=function(t,i){var n,s=this;n=t&&e.has(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)||null},e.extend(n,s,i);var a=function(){this.constructor=n};if(a.prototype=s.prototype,n.prototype=new a,t&&t.hasOwnProperty("mixins")){var r=t.mixins;delete t.mixins,e.isArray(r)||(r=[r]),e.each(r,function(t){e.extend(n.prototype,t)
})}return t&&e.extend(n.prototype,t),n.__super__=s.prototype,n};return t.extend=i,t}),define("plex/base/mixins/views/bindingsMixin",["underscore"],function(e){"use strict";var t={bindToModel:function(){this.bindings&&e.each(e.keys(this.bindings),function(t){var i,n=this.bindings[t];if(i=n.model?this[n.model]:this[this.bindingsModel]||this.model){var s=n.modelListeners||[n.modelAttribute];e.each(s,function(s){var a={obj:i,name:"change:"+s,callback:e.bind(this.renderBinding,this,t,n,i)};this._bindingListeners||(this._bindingListeners=[]),this._bindingListeners.push(a),this.listenTo(a.obj,a.name,a.callback)
},this),this.renderBinding(t,n,i)}},this)},unbindFromModel:function(){this.bindings&&(e.each(this._bindingListeners,function(e){this.stopListening(e.obj,e.name,e.callback)},this),this._bindingListeners=null)},renderBinding:function(t,i,n){var s=this.$(t),a=i.formatter,r=!!i.isHtml,o=i.autohide,l=n.get(i.modelAttribute);if(a&&(l=a.call(this,l,s)),o){var c=e.isFunction(o)?o.call(this,l):l;s.toggleClass("hidden",!c)}i.manual||(!r&&e.isString(l)&&(l=e.escape(l)),s.html(l))}};return t}),define("backbone",["underscore","jquery","backbone-lib","plex/base/utils/BaseClass","plex/base/mixins/views/bindingsMixin"],function(e,t,i,n,s){"use strict";
i=i.noConflict();var a=i.sync;return i.sync=function(i,n,s){s.url||(n.syncUrl?s.url=e.result(n,"syncUrl"):n.url&&(s.url=e.result(n,"url"))),e.isObject(s.data)&&(s.data=t.param(s.data,!0)),e.defaults(s,{headers:{},dataType:"text",processData:!1,timeout:s.data&&s.data.indexOf("checkFiles=1")>-1?6e4:15e3});var r=s.server||n.server||n;e.isFunction(r.resolveUrl)&&(s.url=r.resolveUrl(s.url),"cloudsync"===r.get("platform")&&(s.url+=s.url.indexOf("?")>-1?"&":"?",s.url+="redirect=0"),e.extend(s.headers,r.getHeaders()));
var o=a(i,n,s);return o.fail(function(e){e.aborting||0!==e.status&&401!==e.status||r.trigger("error:connection",r)}),o},i.wrapError=function(e,t){var i=t.error;t.error=function(n){i&&i(e,n,t),e.trigger("error",e,n,t)}},e.extend(i.View.prototype,s),i.Model.extend=n.extend,i.Collection.extend=n.extend,i.Router.extend=n.extend,i.View.extend=n.extend,i.History.extend=n.extend,i}),function(e,t){if("object"==typeof exports){var i=require("underscore"),n=require("backbone");module.exports=t(i,n)}else"function"==typeof define&&define.amd&&define("backbone.wreqr",["underscore","backbone"],t)
}(this,function(e,t){"use strict";return t.Wreqr=function(e,t,i){var n={};return n.Handlers=function(e,t){var i=function(e){this.options=e,this._wreqrHandlers={},t.isFunction(this.initialize)&&this.initialize(e)};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events,{setHandlers:function(e){t.each(e,function(e,i){var n=null;t.isObject(e)&&!t.isFunction(e)&&(n=e.context,e=e.callback),this.setHandler(i,e,n)},this)},setHandler:function(e,t,i){var n={callback:t,context:i};this._wreqrHandlers[e]=n,this.trigger("handler:add",e,t,i)
},hasHandler:function(e){return!!this._wreqrHandlers[e]},getHandler:function(e){var t=this._wreqrHandlers[e];if(t)return function(){var e=Array.prototype.slice.apply(arguments);return t.callback.apply(t.context,e)}},removeHandler:function(e){delete this._wreqrHandlers[e]},removeAllHandlers:function(){this._wreqrHandlers={}}}),i}(e,i),n.CommandStorage=function(){var t=function(e){this.options=e,this._commands={},i.isFunction(this.initialize)&&this.initialize(e)};return i.extend(t.prototype,e.Events,{getCommands:function(e){var t=this._commands[e];
return t||(t={command:e,instances:[]},this._commands[e]=t),t},addCommand:function(e,t){var i=this.getCommands(e);i.instances.push(t)},clearCommands:function(e){var t=this.getCommands(e);t.instances=[]}}),t}(),n.Commands=function(e){return e.Handlers.extend({storageType:e.CommandStorage,constructor:function(t){this.options=t||{},this._initializeStorage(this.options),this.on("handler:add",this._executeCommands,this);var i=Array.prototype.slice.call(arguments);e.Handlers.prototype.constructor.apply(this,i)
},execute:function(e,t){e=arguments[0],t=Array.prototype.slice.call(arguments,1),this.hasHandler(e)?this.getHandler(e).apply(this,t):this.storage.addCommand(e,t)},_executeCommands:function(e,t,n){var s=this.storage.getCommands(e);i.each(s.instances,function(e){t.apply(n,e)}),this.storage.clearCommands(e)},_initializeStorage:function(e){var t,n=e.storageType||this.storageType;t=i.isFunction(n)?new n:n,this.storage=t}})}(n),n.RequestResponse=function(e){return e.Handlers.extend({request:function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);
return this.hasHandler(e)?this.getHandler(e).apply(this,t):void 0}})}(n),n.EventAggregator=function(e,t){var i=function(){};return i.extend=e.Model.extend,t.extend(i.prototype,e.Events),i}(e,i),n}(t,t.Marionette,e),t.Wreqr}),function(e,t){if("object"==typeof exports){var i=require("underscore"),n=require("backbone");module.exports=t(i,n)}else"function"==typeof define&&define.amd&&define("backbone.babysitter",["underscore","backbone"],t)}(this,function(e,t){"option strict";return t.ChildViewContainer=function(e,t){var i=function(e){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(e,this.add,this)
};t.extend(i.prototype,{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._updateLength(),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){var i=e.cid;
return e.model&&delete this._indexByModel[e.model.cid],t.any(this._indexByCustom,function(e,t){return e===i?(delete this._indexByCustom[t],!0):void 0},this),delete this._views[i],this._updateLength(),this},call:function(e){this.apply(e,t.tail(arguments))},apply:function(e,i){t.each(this._views,function(n){t.isFunction(n[e])&&n[e].apply(n,i||[])})},_updateLength:function(){this.length=t.size(this._views)}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];
return t.each(n,function(e){i.prototype[e]=function(){var i=t.values(this._views),n=[i].concat(t.toArray(arguments));return t[e].apply(t,n)}}),i}(t,e),t.ChildViewContainer}),function(e,t){if("object"==typeof exports){var i=require("underscore"),n=require("backbone"),s=require("backbone.wreqr"),a=require("backbone.babysitter");module.exports=t(i,n,s,a)}else"function"==typeof define&&define.amd&&define("marionette-lib",["underscore","backbone","backbone.wreqr","backbone.babysitter"],t)}(this,function(e,t){!function(e,t,i){"use strict";
function n(e,t){var i=new Error(e);throw i.name=t||"Error",i}var s={};t.Marionette=s,s.$=t.$;var a=Array.prototype.slice;return s.extend=t.Model.extend,s.getOption=function(e,t){if(e&&t){var i;return i=e.options&&t in e.options&&void 0!==e.options[t]?e.options[t]:e[t]}},s.normalizeMethods=function(e){var t,n={};return i.each(e,function(e,s){t=e,i.isFunction(t)||(t=this[t]),t&&(n[s]=t)},this),n},s.triggerMethod=function(){function e(e,t,i){return i.toUpperCase()}var t=/(^|:)(\w)/gi,n=function(n){var s="on"+n.replace(t,e),a=this[s];
return i.isFunction(this.trigger)&&this.trigger.apply(this,arguments),i.isFunction(a)?a.apply(this,i.tail(arguments)):void 0};return n}(),s.MonitorDOMRefresh=function(e){function t(e){e._isShown=!0,s(e)}function n(e){e._isRendered=!0,s(e)}function s(e){e._isShown&&e._isRendered&&a(e)&&i.isFunction(e.triggerMethod)&&e.triggerMethod("dom:refresh")}function a(t){return e.contains(t.el)}return function(e){e.listenTo(e,"show",function(){t(e)}),e.listenTo(e,"render",function(){n(e)})}}(document.documentElement),function(e){function t(e,t,s,a){var r=a.split(/\s+/);
i.each(r,function(i){var a=e[i];a||n("Method '"+i+"' was configured as an event handler, but does not exist."),e.listenTo(t,s,a)})}function s(e,t,i,n){e.listenTo(t,i,n)}function a(e,t,n,s){var a=s.split(/\s+/);i.each(a,function(i){var s=e[i];e.stopListening(t,n,s)})}function r(e,t,i,n){e.stopListening(t,i,n)}function o(e,t,n,s,a){t&&n&&(i.isFunction(n)&&(n=n.call(e)),i.each(n,function(n,r){i.isFunction(n)?s(e,t,r,n):a(e,t,r,n)}))}e.bindEntityEvents=function(e,i,n){o(e,i,n,s,t)},e.unbindEntityEvents=function(e,t,i){o(e,t,i,r,a)
}}(s),s.Callbacks=function(){this._deferred=s.$.Deferred(),this._callbacks=[]},i.extend(s.Callbacks.prototype,{add:function(e,t){this._callbacks.push({cb:e,ctx:t}),this._deferred.done(function(i,n){t&&(i=t),e.call(i,n)})},run:function(e,t){this._deferred.resolve(t,e)},reset:function(){var e=this._callbacks;this._deferred=s.$.Deferred(),this._callbacks=[],i.each(e,function(e){this.add(e.cb,e.ctx)},this)}}),s.Controller=function(e){this.triggerMethod=s.triggerMethod,this.options=e||{},i.isFunction(this.initialize)&&this.initialize(this.options)
},s.Controller.extend=s.extend,i.extend(s.Controller.prototype,t.Events,{close:function(){this.stopListening(),this.triggerMethod("close"),this.unbind()}}),s.Region=function(e){if(this.options=e||{},this.el=s.getOption(this,"el"),this.el||n("An 'el' must be specified for a region.","NoElError"),this.initialize){var t=Array.prototype.slice.apply(arguments);this.initialize.apply(this,t)}},i.extend(s.Region,{buildRegion:function(e,t){var s=i.isString(e),a=i.isString(e.selector),r=i.isUndefined(e.regionType),o=i.isFunction(e);
o||s||a||n("Region must be specified as a Region type, a selector string or an object with selector property");var l,c;s&&(l=e),e.selector&&(l=e.selector,delete e.selector),o&&(c=e),!o&&r&&(c=t),e.regionType&&(c=e.regionType,delete e.regionType),(s||o)&&(e={}),e.el=l;var d=new c(e);return e.parentEl&&(d.getEl=function(t){var n=e.parentEl;return i.isFunction(n)&&(n=n()),n.find(t)}),d}}),i.extend(s.Region.prototype,t.Events,{show:function(e){this.ensureEl();var t=e.isClosed||i.isUndefined(e.$el),n=e!==this.currentView;
n&&this.close(),e.render(),(n||t)&&this.open(e),this.currentView=e,s.triggerMethod.call(this,"show",e),s.triggerMethod.call(e,"show")},ensureEl:function(){this.$el&&0!==this.$el.length||(this.$el=this.getEl(this.el))},getEl:function(e){return s.$(e)},open:function(e){this.$el.empty().append(e.el)},close:function(){var e=this.currentView;e&&!e.isClosed&&(e.close?e.close():e.remove&&e.remove(),s.triggerMethod.call(this,"close",e),delete this.currentView)},attachView:function(e){this.currentView=e},reset:function(){this.close(),delete this.$el
}}),s.Region.extend=s.extend,s.RegionManager=function(e){var t=e.Controller.extend({constructor:function(t){this._regions={},e.Controller.prototype.constructor.call(this,t)},addRegions:function(e,t){var n={};return i.each(e,function(e,s){i.isString(e)&&(e={selector:e}),e.selector&&(e=i.defaults({},e,t));var a=this.addRegion(s,e);n[s]=a},this),n},addRegion:function(t,n){var s,a=i.isObject(n),r=i.isString(n),o=!!n.selector;return s=r||a&&o?e.Region.buildRegion(n,e.Region):i.isFunction(n)?e.Region.buildRegion(n,e.Region):n,this._store(t,s),this.triggerMethod("region:add",t,s),s
},get:function(e){return this._regions[e]},removeRegion:function(e){var t=this._regions[e];this._remove(e,t)},removeRegions:function(){i.each(this._regions,function(e,t){this._remove(t,e)},this)},closeRegions:function(){i.each(this._regions,function(e){e.close()},this)},close:function(){this.removeRegions(),e.Controller.prototype.close.apply(this,arguments)},_store:function(e,t){this._regions[e]=t,this._setLength()},_remove:function(e,t){t.close(),delete this._regions[e],this._setLength(),this.triggerMethod("region:remove",e,t)
},_setLength:function(){this.length=i.size(this._regions)}}),n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return i.each(n,function(e){t.prototype[e]=function(){var t=i.values(this._regions),n=[t].concat(i.toArray(arguments));return i[e].apply(i,n)}}),t}(s),s.TemplateCache=function(e){this.templateId=e},i.extend(s.TemplateCache,{templateCaches:{},get:function(e){var t=this.templateCaches[e];
return t||(t=new s.TemplateCache(e),this.templateCaches[e]=t),t.load()},clear:function(){var e,t=a.call(arguments),i=t.length;if(i>0)for(e=0;i>e;e++)delete this.templateCaches[t[e]];else this.templateCaches={}}}),i.extend(s.TemplateCache.prototype,{load:function(){if(this.compiledTemplate)return this.compiledTemplate;var e=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(e),this.compiledTemplate},loadTemplate:function(e){var t=s.$(e).html();return t&&0!==t.length||n("Could not find template: '"+e+"'","NoTemplateError"),t
},compileTemplate:function(e){return i.template(e)}}),s.Renderer={render:function(e,t){e||n("Cannot render the template since it's false, null or undefined.","TemplateNotFoundError");var i;return(i="function"==typeof e?e:s.TemplateCache.get(e))(t)}},s.View=t.View.extend({constructor:function(e){i.bindAll(this,"render"),this.options=i.extend({},i.result(this,"options"),i.isFunction(e)?e.call(this):e),this.events=this.normalizeUIKeys(i.result(this,"events")),t.View.prototype.constructor.apply(this,arguments),s.MonitorDOMRefresh(this),this.listenTo(this,"show",this.onShowCalled)
},triggerMethod:s.triggerMethod,normalizeMethods:s.normalizeMethods,getTemplate:function(){return s.getOption(this,"template")},mixinTemplateHelpers:function(e){e=e||{};var t=s.getOption(this,"templateHelpers");return i.isFunction(t)&&(t=t.call(this)),i.extend(e,t)},normalizeUIKeys:function(e){var t=this;if("undefined"!=typeof e)return i.each(i.keys(e),function(n){var s=/@ui.[a-zA-Z_$0-9]*/g;n.match(s)&&(e[n.replace(s,function(e){return i.result(t,"ui")[e.slice(4)]})]=e[n],delete e[n])}),e},configureTriggers:function(){if(this.triggers){var e={},t=this.normalizeUIKeys(i.result(this,"triggers"));
return i.each(t,function(t,n){var s=i.isObject(t),a=s?t.event:t;e[n]=function(e){if(e){var i=e.preventDefault,n=e.stopPropagation,r=s?t.preventDefault:i,o=s?t.stopPropagation:n;r&&i&&i.apply(e),o&&n&&n.apply(e)}var l={view:this,model:this.model,collection:this.collection};this.triggerMethod(a,l)}},this),e}},delegateEvents:function(e){this._delegateDOMEvents(e),s.bindEntityEvents(this,this.model,s.getOption(this,"modelEvents")),s.bindEntityEvents(this,this.collection,s.getOption(this,"collectionEvents"))
},_delegateDOMEvents:function(e){e=e||this.events,i.isFunction(e)&&(e=e.call(this));var n={},s=this.configureTriggers();i.extend(n,e,s),t.View.prototype.delegateEvents.call(this,n)},undelegateEvents:function(){var e=Array.prototype.slice.call(arguments);t.View.prototype.undelegateEvents.apply(this,e),s.unbindEntityEvents(this,this.model,s.getOption(this,"modelEvents")),s.unbindEntityEvents(this,this.collection,s.getOption(this,"collectionEvents"))},onShowCalled:function(){},close:function(){if(!this.isClosed){var e=this.triggerMethod("before:close");
e!==!1&&(this.isClosed=!0,this.triggerMethod("close"),this.unbindUIElements(),this.remove())}},bindUIElements:function(){if(this.ui){this._uiBindings||(this._uiBindings=this.ui);var e=i.result(this,"_uiBindings");this.ui={},i.each(i.keys(e),function(t){var i=e[t];this.ui[t]=this.$(i)},this)}},unbindUIElements:function(){this.ui&&this._uiBindings&&(i.each(this.ui,function(e,t){delete this.ui[t]},this),this.ui=this._uiBindings,delete this._uiBindings)}}),s.ItemView=s.View.extend({constructor:function(){s.View.prototype.constructor.apply(this,arguments)
},serializeData:function(){var e={};return this.model?e=this.model.toJSON():this.collection&&(e={items:this.collection.toJSON()}),e},render:function(){this.isClosed=!1,this.triggerMethod("before:render",this),this.triggerMethod("item:before:render",this);var e=this.serializeData();e=this.mixinTemplateHelpers(e);var t=this.getTemplate(),i=s.Renderer.render(t,e);return this.$el.html(i),this.bindUIElements(),this.triggerMethod("render",this),this.triggerMethod("item:rendered",this),this},close:function(){this.isClosed||(this.triggerMethod("item:before:close"),s.View.prototype.close.apply(this,arguments),this.triggerMethod("item:closed"))
}}),s.CollectionView=s.View.extend({itemViewEventPrefix:"itemview",constructor:function(){this._initChildViewStorage(),s.View.prototype.constructor.apply(this,arguments),this._initialEvents(),this.initRenderBuffer()},initRenderBuffer:function(){this.elBuffer=document.createDocumentFragment(),this._bufferedChildren=[]},startBuffering:function(){this.initRenderBuffer(),this.isBuffering=!0},endBuffering:function(){this.isBuffering=!1,this.appendBuffer(this,this.elBuffer),this._triggerShowBufferedChildren(),this.initRenderBuffer()
},_triggerShowBufferedChildren:function(){this._isShown&&(i.each(this._bufferedChildren,function(e){s.triggerMethod.call(e,"show")}),this._bufferedChildren=[])},_initialEvents:function(){this.collection&&(this.listenTo(this.collection,"add",this.addChildView),this.listenTo(this.collection,"remove",this.removeItemView),this.listenTo(this.collection,"reset",this.render))},addChildView:function(e){this.closeEmptyView();var t=this.getItemView(e),i=this.collection.indexOf(e);this.addItemView(e,t,i)},onShowCalled:function(){this.children.each(function(e){s.triggerMethod.call(e,"show")
})},triggerBeforeRender:function(){this.triggerMethod("before:render",this),this.triggerMethod("collection:before:render",this)},triggerRendered:function(){this.triggerMethod("render",this),this.triggerMethod("collection:rendered",this)},render:function(){return this.isClosed=!1,this.triggerBeforeRender(),this._renderChildren(),this.triggerRendered(),this},_renderChildren:function(){this.startBuffering(),this.closeEmptyView(),this.closeChildren(),this.isEmpty(this.collection)?this.showEmptyView():this.showCollection(),this.endBuffering()
},showCollection:function(){var e;this.collection.each(function(t,i){e=this.getItemView(t),this.addItemView(t,e,i)},this)},showEmptyView:function(){var e=this.getEmptyView();if(e&&!this._showingEmptyView){this._showingEmptyView=!0;var i=new t.Model;this.addItemView(i,e,0)}},closeEmptyView:function(){this._showingEmptyView&&(this.closeChildren(),delete this._showingEmptyView)},getEmptyView:function(){return s.getOption(this,"emptyView")},getItemView:function(){var e=s.getOption(this,"itemView");return e||n("An `itemView` must be specified","NoItemViewError"),e
},addItemView:function(e,t,n){var a=s.getOption(this,"itemViewOptions");i.isFunction(a)&&(a=a.call(this,e,n));var r=this.buildItemView(e,t,a);return this.addChildViewEventForwarding(r),this.triggerMethod("before:item:added",r),this.children.add(r),this.renderItemView(r,n),this._isShown&&!this.isBuffering&&s.triggerMethod.call(r,"show"),this.triggerMethod("after:item:added",r),r},addChildViewEventForwarding:function(e){var t=s.getOption(this,"itemViewEventPrefix");this.listenTo(e,"all",function(){var n=a.call(arguments),r=n[0],o=this.normalizeMethods(this.getItemEvents());
n[0]=t+":"+r,n.splice(1,0,e),"undefined"!=typeof o&&i.isFunction(o[r])&&o[r].apply(this,n),s.triggerMethod.apply(this,n)},this)},getItemEvents:function(){return i.isFunction(this.itemEvents)?this.itemEvents.call(this):this.itemEvents},renderItemView:function(e,t){e.render(),this.appendHtml(this,e,t)},buildItemView:function(e,t,n){var s=i.extend({model:e},n);return new t(s)},removeItemView:function(e){var t=this.children.findByModel(e);this.removeChildView(t),this.checkEmpty()},removeChildView:function(e){e&&(this.stopListening(e),e.close?e.close():e.remove&&e.remove(),this.children.remove(e)),this.triggerMethod("item:removed",e)
},isEmpty:function(){return!this.collection||0===this.collection.length},checkEmpty:function(){this.isEmpty(this.collection)&&this.showEmptyView()},appendBuffer:function(e,t){e.$el.append(t)},appendHtml:function(e,t){e.isBuffering?(e.elBuffer.appendChild(t.el),e._bufferedChildren.push(t)):e.$el.append(t.el)},_initChildViewStorage:function(){this.children=new t.ChildViewContainer},close:function(){this.isClosed||(this.triggerMethod("collection:before:close"),this.closeChildren(),this.triggerMethod("collection:closed"),s.View.prototype.close.apply(this,arguments))
},closeChildren:function(){this.children.each(function(e){this.removeChildView(e)},this),this.checkEmpty()}}),s.CompositeView=s.CollectionView.extend({constructor:function(){s.CollectionView.prototype.constructor.apply(this,arguments)},_initialEvents:function(){this.once("render",function(){this.collection&&(this.listenTo(this.collection,"add",this.addChildView),this.listenTo(this.collection,"remove",this.removeItemView),this.listenTo(this.collection,"reset",this._renderChildren))})},getItemView:function(){var e=s.getOption(this,"itemView")||this.constructor;
return e||n("An `itemView` must be specified","NoItemViewError"),e},serializeData:function(){var e={};return this.model&&(e=this.model.toJSON()),e},render:function(){this.isRendered=!0,this.isClosed=!1,this.resetItemViewContainer(),this.triggerBeforeRender();var e=this.renderModel();return this.$el.html(e),this.bindUIElements(),this.triggerMethod("composite:model:rendered"),this._renderChildren(),this.triggerMethod("composite:rendered"),this.triggerRendered(),this},_renderChildren:function(){this.isRendered&&(this.triggerMethod("composite:collection:before:render"),s.CollectionView.prototype._renderChildren.call(this),this.triggerMethod("composite:collection:rendered"))
},renderModel:function(){var e={};e=this.serializeData(),e=this.mixinTemplateHelpers(e);var t=this.getTemplate();return s.Renderer.render(t,e)},appendBuffer:function(e,t){var i=this.getItemViewContainer(e);i.append(t)},appendHtml:function(e,t){if(e.isBuffering)e.elBuffer.appendChild(t.el),e._bufferedChildren.push(t);else{var i=this.getItemViewContainer(e);i.append(t.el)}},getItemViewContainer:function(e){if("$itemViewContainer"in e)return e.$itemViewContainer;var t,a=s.getOption(e,"itemViewContainer");
if(a){var r=i.isFunction(a)?a.call(this):a;t=e.$(r),t.length<=0&&n("The specified `itemViewContainer` was not found: "+e.itemViewContainer,"ItemViewContainerMissingError")}else t=e.$el;return e.$itemViewContainer=t,t},resetItemViewContainer:function(){this.$itemViewContainer&&delete this.$itemViewContainer}}),s.Layout=s.ItemView.extend({regionType:s.Region,constructor:function(e){e=e||{},this._firstRender=!0,this._initializeRegions(e),s.ItemView.prototype.constructor.call(this,e)},render:function(){return this.isClosed&&this._initializeRegions(),this._firstRender?this._firstRender=!1:this.isClosed||this._reInitializeRegions(),s.ItemView.prototype.render.apply(this,arguments)
},close:function(){this.isClosed||(this.regionManager.close(),s.ItemView.prototype.close.apply(this,arguments))},addRegion:function(e,t){var i={};return i[e]=t,this._buildRegions(i)[e]},addRegions:function(e){return this.regions=i.extend({},this.regions,e),this._buildRegions(e)},removeRegion:function(e){return delete this.regions[e],this.regionManager.removeRegion(e)},_buildRegions:function(e){var t=this,i={regionType:s.getOption(this,"regionType"),parentEl:function(){return t.$el}};return this.regionManager.addRegions(e,i)
},_initializeRegions:function(e){var t;this._initRegionManager(),t=i.isFunction(this.regions)?this.regions(e):this.regions||{},this.addRegions(t)},_reInitializeRegions:function(){this.regionManager.closeRegions(),this.regionManager.each(function(e){e.reset()})},_initRegionManager:function(){this.regionManager=new s.RegionManager,this.listenTo(this.regionManager,"region:add",function(e,t){this[e]=t,this.trigger("region:add",e,t)}),this.listenTo(this.regionManager,"region:remove",function(e,t){delete this[e],this.trigger("region:remove",e,t)
})}}),s.AppRouter=t.Router.extend({constructor:function(e){t.Router.prototype.constructor.apply(this,arguments),this.options=e||{};var i=s.getOption(this,"appRoutes"),n=this._getController();this.processAppRoutes(n,i)},appRoute:function(e,t){var i=this._getController();this._addAppRoute(i,e,t)},processAppRoutes:function(e,t){if(t){var n=i.keys(t).reverse();i.each(n,function(i){this._addAppRoute(e,i,t[i])},this)}},_getController:function(){return s.getOption(this,"controller")},_addAppRoute:function(e,t,s){var a=e[s];
a||n("Method '"+s+"' was not found on the controller"),this.route(t,s,i.bind(a,e))}}),s.Application=function(e){this._initRegionManager(),this._initCallbacks=new s.Callbacks,this.vent=new t.Wreqr.EventAggregator,this.commands=new t.Wreqr.Commands,this.reqres=new t.Wreqr.RequestResponse,this.submodules={},i.extend(this,e),this.triggerMethod=s.triggerMethod},i.extend(s.Application.prototype,t.Events,{execute:function(){this.commands.execute.apply(this.commands,arguments)},request:function(){return this.reqres.request.apply(this.reqres,arguments)
},addInitializer:function(e){this._initCallbacks.add(e)},start:function(e){this.triggerMethod("initialize:before",e),this._initCallbacks.run(e,this),this.triggerMethod("initialize:after",e),this.triggerMethod("start",e)},addRegions:function(e){return this._regionManager.addRegions(e)},closeRegions:function(){this._regionManager.closeRegions()},removeRegion:function(e){this._regionManager.removeRegion(e)},getRegion:function(e){return this._regionManager.get(e)},module:function(e,t){var i=s.Module.getClass(t),n=a.call(arguments);
return n.unshift(this),i.create.apply(i,n)},_initRegionManager:function(){this._regionManager=new s.RegionManager,this.listenTo(this._regionManager,"region:add",function(e,t){this[e]=t}),this.listenTo(this._regionManager,"region:remove",function(e){delete this[e]})}}),s.Application.extend=s.extend,s.Module=function(e,t,n){this.moduleName=e,this.options=i.extend({},this.options,n),this.initialize=n.initialize||this.initialize,this.submodules={},this._setupInitializersAndFinalizers(),this.app=t,this.startWithParent=!0,this.triggerMethod=s.triggerMethod,i.isFunction(this.initialize)&&this.initialize(this.options,e,t)
},s.Module.extend=s.extend,i.extend(s.Module.prototype,t.Events,{initialize:function(){},addInitializer:function(e){this._initializerCallbacks.add(e)},addFinalizer:function(e){this._finalizerCallbacks.add(e)},start:function(e){this._isInitialized||(i.each(this.submodules,function(t){t.startWithParent&&t.start(e)}),this.triggerMethod("before:start",e),this._initializerCallbacks.run(e,this),this._isInitialized=!0,this.triggerMethod("start",e))},stop:function(){this._isInitialized&&(this._isInitialized=!1,s.triggerMethod.call(this,"before:stop"),i.each(this.submodules,function(e){e.stop()
}),this._finalizerCallbacks.run(void 0,this),this._initializerCallbacks.reset(),this._finalizerCallbacks.reset(),s.triggerMethod.call(this,"stop"))},addDefinition:function(e,t){this._runModuleDefinition(e,t)},_runModuleDefinition:function(e,n){if(e){var a=i.flatten([this,this.app,t,s,s.$,i,n]);e.apply(this,a)}},_setupInitializersAndFinalizers:function(){this._initializerCallbacks=new s.Callbacks,this._finalizerCallbacks=new s.Callbacks}}),i.extend(s.Module,{create:function(e,t,n){var s=e,r=a.call(arguments);
r.splice(0,3),t=t.split(".");var o=t.length,l=[];return l[o-1]=n,i.each(t,function(t,i){var a=s;s=this._getModule(a,t,e,n),this._addModuleDefinition(a,s,l[i],r)},this),s},_getModule:function(e,t,n,s){var a=i.extend({},s),r=this.getClass(s),o=e[t];return o||(o=new r(t,n,a),e[t]=o,e.submodules[t]=o),o},getClass:function(e){var t=s.Module;return e?e.prototype instanceof t?e:e.moduleClass||t:t},_addModuleDefinition:function(e,t,n,a){var r,o;!i.isFunction(n)||n.prototype instanceof s.Module?i.isObject(n)?(r=n.define,o=i.isUndefined(n.startWithParent)?!0:n.startWithParent):o=!0:(r=n,o=!0),r&&t.addDefinition(r,a),t.startWithParent=t.startWithParent&&o,t.startWithParent&&!t.startWithParentIsConfigured&&(t.startWithParentIsConfigured=!0,e.addInitializer(function(e){t.startWithParent&&t.start(e)
}))}}),s}(this,t,e);return t.Marionette}),define("marionette",["underscore","backbone","marionette-lib"],function(e,t,i){"use strict";i.isNodeAttached=function(e){return t.$.contains(document.documentElement,e)};var n=e.clone(i.View.prototype),s=e.clone(i.CollectionView.prototype),a=e.clone(i.Region.prototype),r={constructor:function(){this.wrapAfterRender(),n.constructor.apply(this,arguments)},bindAllWhenRendered:function(){if(arguments<=0)throw new Error("bindAllWhenRendered requires at least one function");
var t=e.isArray(arguments[0])?arguments[0]:arguments;e.each(t,function(e){try{this[e]=this.whenRendered(this[e])}catch(t){throw new Error("bindAllWhenRendered unable to wrap "+JSON.stringify(e))}},this)},whenRendered:function(t){if(!e.isFunction(t))throw new Error("whenRendered must be called with a single function");return e.bind(function(){if(!this.isClosed){var i=e.toArray(arguments),n=e.bind(function(){this.isRendered&&!this.isClosed&&t.apply(this,i)},this);return this.isRendered?void e.defer(n):void this.listenToOnce(this,"render",function(){e.defer(n)
})}},this)},wrapAfterRender:function(){if(void 0!==this.onlyAfterRender){if(!e.isArray(this.onlyAfterRender))throw new Error("onlyAfterRender must be an array");this.bindAllWhenRendered.apply(this,this.onlyAfterRender)}},bindUIElements:function(){n.bindUIElements.apply(this,arguments),this.bindToModel(),this.isRendered=!0},unbindUIElements:function(){n.unbindUIElements.apply(this,arguments),this.unbindFromModel()},_getImmediateChildren:function(){return[]},_getNestedViews:function(){var t=this._getImmediateChildren();
return t.length?e.reduce(t,function(e,t){return t._getNestedViews?e.concat(t._getNestedViews()):e},t):t}},o={constructor:function(){s.constructor.apply(this,arguments)},triggerRendered:function(){return this.isRendered=!0,s.triggerRendered.apply(this,arguments)},rebase:function(t){return this.stopListening(this.collection),this.collection=t,this._initialEvents(),e.isFunction(this._renderChildren)?this._renderChildren():this.render(),this},_getImmediateChildren:function(){return e.values(this.children._views)
}},l={constructor:function(){s.constructor.apply(this,arguments)}},c={append:function(t,n,s){var a=t.isClosed||e.isUndefined(t.$el),r=t!==this.currentView;return r&&this.close(),t.render(),(r||a)&&(n||(n=this.getEl(this.el)),s?n.prepend(t.el):n.append(t.el)),this.attachView(t),i.triggerMethod.call(this,"show",t),i.triggerMethod.call(t,"show"),this._triggerAttached(t,n),this},prepend:function(e,t){return this.append(e,t,!0)},show:function(e){a.show.apply(this,arguments),this._triggerAttached(e,this.$el)
},_triggerAttached:function(t,n){if(i.isNodeAttached(n.get(0))){var s=e.union([t],e.result(t,"_getNestedViews")||[]);e.each(s,function(e){e.triggerMethod&&e.triggerMethod("attached",this)},this)}}},d={_getImmediateChildren:function(){return e.chain(this.regionManager._regions).values().pluck("currentView").compact().value()}};return e.extend(i.View.prototype,r),e.extend(i.ItemView.prototype,r),e.extend(i.CollectionView.prototype,r,o),e.extend(i.CompositeView.prototype,r,l),e.extend(i.Region.prototype,c),e.extend(i.Layout.prototype,d),i
}),define("plex/base/mixins/eventMixin",["underscore"],function(e){"use strict";var t=/\s+/,i=function(e,i,n,s){if(!n)return!0;if("object"==typeof n){for(var a in n)e[i].apply(e,[a,n[a]].concat(s));return!1}if(t.test(n)){for(var r=n.split(t),o=0,l=r.length;l>o;o++)e[i].apply(e,[r[o]].concat(s));return!1}return!0},n=function(e,t){var i,n=-1,s=e.length,a=t[0],r=t[1],o=t[2];switch(t.length){case 0:for(;++n<s;)(i=e[n]).callback.call(i.ctx);return;case 1:for(;++n<s;)(i=e[n]).callback.call(i.ctx,a);return;
case 2:for(;++n<s;)(i=e[n]).callback.call(i.ctx,a,r);return;case 3:for(;++n<s;)(i=e[n]).callback.call(i.ctx,a,r,o);return;default:for(;++n<s;)(i=e[n]).callback.apply(i.ctx,t)}},s={on:function(e,t,n){if(!i(this,"on",e,[t,n])||!t)return this;this._events||(this._events={});var s=this._events[e]||(this._events[e]=[]);return s.push({callback:t,context:n,ctx:n||this}),this},once:function(t,n,s){if(!i(this,"once",t,[n,s])||!n)return this;var a=this,r=e.once(function(){a.off(t,r),n.apply(this,arguments)
});return r._callback=n,this.on(t,r,s)},off:function(t,n,s){var a,r,o,l,c,d,u,h;if(!this._events||!i(this,"off",t,[n,s]))return this;if(!t&&!n&&!s)return this._events=void 0,this;for(l=t?[t]:e.keys(this._events),c=0,d=l.length;d>c;c++)if(t=l[c],o=this._events[t]){if(this._events[t]=a=[],n||s)for(u=0,h=o.length;h>u;u++)r=o[u],(n&&n!==r.callback&&n!==r.callback._callback||s&&s!==r.context)&&a.push(r);a.length||delete this._events[t]}return this},trigger:function(e){if(!this._events)return this;var t=[].slice.call(arguments,1);
if(!i(this,"trigger",e,t))return this;var s=this._events[e],a=this._events.all;return s&&n(s,t),a&&n(a,arguments),this},stopListening:function(t,i,n){var s=this._listeningTo;if(!s)return this;var a=!i&&!n;n||"object"!=typeof i||(n=this),t&&((s={})[t._listenId]=t);for(var r in s)t=s[r],t.off(i,n,this),(a||e.isEmpty(t._events))&&delete this._listeningTo[r];return this},hasListener:function(t){var i=this._events&&this._events[t];return e.isArray(i)&&i.length>0}},a={listenTo:"on",listenToOnce:"once"};
return e.each(a,function(t,i){s[i]=function(i,n,s){var a=this._listeningTo||(this._listeningTo={}),r=i._listenId||(i._listenId=e.uniqueId("l"));return a[r]=i,s||"object"!=typeof n||(s=this),i[t](n,s,this),this}}),s.bind=s.on,s.unbind=s.off,s}),define("plex/base/adapters/Adapter",["underscore","plex/base/utils/BaseClass","plex/base/mixins/eventMixin"],function(e,t,i){"use strict";var n=t.extend({mixins:i,initialize:function(t){t||(t={}),t["interface"]&&(this["interface"]=t["interface"]),t.props&&(this.props=t.props),e.each(this["interface"],function(t){this[t]=e.bind(this._proxy,this,t)
},this)},_proxy:function(t){var i=this.getInstance();return i[t].apply(i,e.rest(arguments))},register:function(e){this._instance=e,this.trigger("change:instance",e)},getInstance:function(){if(this.hasInstance())return this._instance;throw new Error("Nothing has been registered to this adapter.")},hasInstance:function(){return null!=this._instance},prop:function(t){if(e.contains(this.props,t))return this.getInstance()[t];throw new Error("The "+t+" property has not been defined for this adapter")}});
return n}),define("plex/base/adapters/settingsAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({"interface":["get","save","populate"]});return t}),define("plex/base/utils/browser",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=/version\/(\d+(\.\d+)?)/i,n=/(?:chrome|crios|gfibertv)[\/-](\d+(\.\d+)?)/i,s=/firefox[ \/](\d+(\.\d+)?)/i,a=/(msie |rv:)(\d+(\.\d+)?)/i,r=/(?:applewebkit|safari)\/(\d+(\.\d+)?)/i,o=t.extend({browsers:[{id:"konvergo",name:"Konvergo",webkit:!0,regex:/Konvergo/,versionRegex:/Konvergo\S* (\d+(\.\d+)+)/i},{id:"wiiu",name:"Wii U",msie:!0,regex:/wiiu/i,versionRegex:r},{id:"ps3",name:"Unknown Browser",regex:/\(PLAYSTATION 3 \d\./},{id:"ps3",name:"Unknown Browser",regex:/\(PlayStation 4 \d\./},{id:"ps3",name:"Mystery 3",webkit:!0,regex:/\(PlayStation 3\)/,versionRegex:r},{id:"ps4",name:"Mystery 4",webkit:!0,regex:/\(PlayStation 4\)/,versionRegex:r},{id:"ie",name:"Internet Explorer",msie:!0,regex:/(msie|trident)/i,versionRegex:a,versionMatchIndex:2},{id:"opera",name:"Opera",presto:!0,regex:/opera/i,versionRegex:i},{id:"opera",name:"Opera",webkit:!0,regex:/OPR\//,versionRegex:/OPR\/\s?(\d+(\.\d+)?)/},{id:"chrome",name:"Chrome",webkit:!0,regex:/(chrome|crios|gfiber)/i,versionRegex:n},{id:"firefox",name:"Firefox",gecko:!0,regex:/firefox/i,versionRegex:s},{id:"safari",name:"Safari",webkit:!0,regex:/os x.+safari/i,versionRegex:i},{id:"safari",name:"Safari",webkit:!0,regex:/applewebkit.+version/i,versionRegex:/applewebkit.+version\/(\d+(\.\d+)?)/i},{id:"safari",name:"Safari",webkit:!0,regex:/applewebkit/i,versionRegex:/(?:applewebkit|safari)\/(\d+(\.\d+)?)/i}],platforms:[{id:"webos",name:"webOS",tv:!0,predicate:function(e){var t=/web[o0]s/i.test(e)&&/large screen/i.test(e);
return this.version(e)?t:!1},version:function(){try{return JSON.parse(window.PalmSystem.deviceInfo).platformVersion}catch(e){}}},{id:"weboshybrid",name:"webOS",tv:!0,predicate:function(e){var t=/web[o0]s/i.test(e)&&/large screen/i.test(e);return!(!t||!window.NetCastGetMouseOnOff)}},{id:"netcast",name:"NetCast",tv:!0,regex:/netcast/i},{id:"fireos",name:"Fire TV Stick",tv:!0,regex:/AFTM/,version:function(e){var t=/cordova-amazon-fireos\/([\d\.]+)/.exec(e);return t&&t[1]||void 0}},{id:"fireos",name:"Fire TV",tv:!0,regex:/AFT./,version:function(e){var t=/cordova-amazon-fireos\/([\d\.]+)/.exec(e);
return t&&t[1]||void 0}},{id:"blackberry",name:"Blackberry",mobile:!0,regex:/BlackBerry|RIM|BB10/},{id:"ps3",name:"PlayStation 3",tv:!0,regex:/P(lay)?S(tation )?3/,version:function(){return window.WM_devSettings?window.WM_devSettings.version:void 0}},{id:"ps4",name:"PlayStation 4",tv:!0,regex:/P(lay)?S(tation )?4/,version:function(){return window.WM_devSettings?window.WM_devSettings.version:void 0}},{id:"wiiu",name:"Wii U",tv:!0,regex:/Nintendo WiiU/},{id:"smarthub",name:"SmartHub",tv:!0,regex:/smarthub/i},{id:"sta",name:"Smart TV Alliance",tv:!0,version:function(t){var i,n;
if(/SmartTvA/.test(t))n=/SmartTvA\/(\d+\.\d+)/.exec(t),i=n&&n[1]||i;else{var s=[/Linux i686.+Chromium\/18/,/nettv\/4.2/i,/toshiba-dtv/i,/viera/i],a=[/nettv\/4/i],r=[/nettv/i],o=function(e){return e.test(t)};e.some(s,o)?i="2.0":e.some(a,o)?i="1.0":e.some(r,o)&&(i="0.0")}return i},predicate:function(e){return void 0!==this.version(e)}},{id:"tivo",name:"TiVo",tv:!0,version:function(e){var t=/TiVo_(TCD[^,]+)/.exec(e);return t&&t[1]||void 0},predicate:function(e){return/opera/i.test(e)&&/tivo/i.test(e)
}},{id:"viziomtk",name:"Vizio MTK",tv:!0,predicate:function(e){return/opera/i.test(e)&&"undefined"!=typeof iMTK_JSP}},{id:"viziosigma",name:"Vizio Sigma",tv:!0,predicate:function(e){return/opera/i.test(e)&&/vizio/i.test(e)},version:function(e){var t=/\/([^\s]+) \(Vizio/.exec(e);return t&&t[1]||void 0}},{id:"operatvstore",name:"Opera TV Store",tv:!0,predicate:function(e){var t=/Opera TV Store/.test(e),i=/TV Store/.test(e)&&/OMI\//.test(e);return t||i}},{id:"operatv",name:"Opera TV",tv:!0,regex:/opera\/\d+\.\d+ \(linux (mips|arm)/i},{id:"googlefiber",name:"Google Fiber",tv:!0,regex:/gfibertv/i},{id:"ios",name:"iOS",mobile:!0,regex:/(iphone|ipad|ipod)/i},{id:"android",name:"Android",mobile:!0,regex:/android/i},{id:"windowsphone",name:"Windows Phone",mobile:!0,regex:/windows phone/i},{id:"webos",name:"webOS",mobile:!0,predicate:function(e){return/web[o0]s/i.test(e)&&!/large screen/i.test(e)
}},{id:"linuxrpi",name:"Linux Raspberry Pi",tv:!0,regex:/Konvergo-linux-rpi/i,version:function(e){var t=/\(([^\)]+)\)$/.exec(e);return t&&t[1]||void 0}},{id:"linux",name:"Linux",context:"platform",regex:/linux/i},{id:"osx",name:"OSX",context:"platform",regex:/mac/i},{id:"windows",name:"Windows",context:"platform",regex:/win/i}],id:"unknown",name:"Unknown Browser",platform:"Unknown Platform",version:"0",platformVersion:"0",platformModifierKey:"ctrl",webkit:!1,gecko:!1,msie:!1,presto:!1,constructor:function(e){var t="",i="";
e?(t=e.userAgent,i=e.platform):null!=navigator&&(t=navigator.userAgent,i=navigator.platform),this.detect({userAgent:t,platform:i})},detect:function(t){var i,n=this.runTests(this.browsers,t),s=this.runTests(this.platforms,t);n&&(this.id=n.id,this.name=n.name,this.version=this.getVersion(t.userAgent,n.versionRegex,n.versionMatchIndex||1),this.webkit=!!n.webkit,this.gecko=!!n.gecko,this.msie=!!n.msie,this.presto=!!n.presto),s&&(i=e.isFunction(s.version)?s.version(t.userAgent):s.version,this.platform=s.name,this.platformID=s.id,this.platformVersion=i||this.platformVersion,this.mobile=!!s.mobile,this.tv=!!s.tv,("OSX"===s.name||"iOS"===s.name)&&(this.platformModifierKey="command"))
},runTests:function(e,t){for(var i,n,s,a=0;n!==!0&&(s=e[a++]);)i=t[s.context||"userAgent"],s.regex?n=s.regex.test(i):s.predicate&&(n=s.predicate(i));return s},getVersion:function(e,t,i){var n=e.match(t);return n&&n.length>i&&n[i]||"0"},toJSON:function(){var t={};for(var i in this)e.has(this,i)&&this[i]&&(t[i]=this[i]);return t}});return new o}),define("plex/base/utils/constants/subtitlesBurnLevels",[],function(){"use strict";var e={AUTO:"auto",AVOID:"avoid",ALWAYS:"always",NEVER:"never"};return e.settings=[{value:e.AUTO,title:"Automatic"},{value:e.AVOID,title:"Only image formats"},{value:e.ALWAYS,title:"Always"}],e
}),define("plex/base/utils/languageUtil",[],function(){"use strict";var e={languages:{aa:"Afaraf",af:"Afrikaans",ab:"Abkhazian",ak:"Akan",sq:"Shqip",am:"Amharic",ar:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629",an:"Aragon\xe9s",hy:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576",as:"Assamese",av:"\u0430\u0432\u0430\u0440 \u043c\u0430\u0446\u04c0",ae:"avesta",ay:"aymar aru",az:"az\u0259rbaycan dili",ba:"\u0431\u0430\u0448\u04a1\u043e\u0440\u0442 \u0442\u0435\u043b\u0435",bm:"bamanankan",eu:"euskara",be:"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f",bn:"Bengali",bh:"\u092d\u094b\u091c\u092a\u0941\u0930\u0940",bi:"Bislama",bs:"bosanski jezik",br:"brezhoneg",bg:"\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438 \u0435\u0437\u0438\u043a",my:"Burmese",ca:"Catal\xe0",ch:"Chamoru",ce:"\u043d\u043e\u0445\u0447\u0438\u0439\u043d \u043c\u043e\u0442\u0442",cu:"\u0469\u0437\u044b\u043a\u044a \u0441\u043b\u043e\u0432\u0463\u043d\u044c\u0441\u043a\u044a",cv:"\u0447\u04d1\u0432\u0430\u0448 \u0447\u04d7\u043b\u0445\u0438",kw:"Kernewek",co:"corsu",cr:"\u14c0\u1426\u1403\u152d\u140d\u140f\u1423",dv:"Divehi",dz:"\u0f62\u0fab\u0f7c\u0f44\u0f0b\u0f41",en:"English","en-GB":"English (UK)",eo:"Esperanto",et:"eesti",ee:"E\u028begbe",fo:"f\xf8royskt",fj:"vosa Vakaviti",fy:"Frysk",ff:"Fulfulde",ka:"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8",gd:"G\xe0idhlig",ga:"Gaeilge",gl:"Galego",gv:"Gaelg",gn:"Ava\xf1e&apos;\u1ebd",gu:"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0",ht:"Krey\xf2l ayisyen",ha:"\u0647\u064e\u0648\u064f\u0633\u064e",hz:"Otjiherero",hi:"\u0939\u093f\u0928\u094d\u0926\u0940",ho:"Hiri Motu",hr:"hrvatski",ig:"As\u1ee5s\u1ee5 Igbo",is:"\xcdslenska",io:"Ido",ii:"\ua188\ua320\ua4bf Nuosuhxop",iu:"\u1403\u14c4\u1483\u144e\u1450\u1466",ie:"Interlingue",ia:"Interlingua",id:"Bahasa Indonesia",ik:"I\xf1upiaq",jv:"basa Jawa",kl:"kalaallisut",kn:"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1",ks:"\u0915\u0936\u094d\u092e\u0940\u0930\u0940",kr:"Kanuri",kk:"\u049a\u0430\u0437\u0430\u049b \u0442\u0456\u043b\u0456",km:"Khmer",ki:"G\u0129k\u0169y\u0169",rw:"Ikinyarwanda",ky:"\u043a\u044b\u0440\u0433\u044b\u0437 \u0442\u0438\u043b\u0438",kv:"\u043a\u043e\u043c\u0438 \u043a\u044b\u0432",kg:"KiKongo",kj:"Kuanyama",ku:"Kurd\xee",lo:"Lao",la:"latine",lv:"latvie\u0161u valoda",li:"Limburgs",ln:"Ling\xe1la",lt:"lietuvi\u0173 kalba",lb:"L\xebtzebuergesch",lu:"Luba-Katanga",lg:"Luganda",mk:"\u043c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 \u0458\u0430\u0437\u0438\u043a",mh:"Kajin M\u0327aje\u013c",ml:"Malayalam",mi:"te reo M\u0101ori",mr:"\u092e\u0930\u093e\u0920\u0940",ms:"bahasa Melayu",mg:"Malagasy fiteny",mt:"Malti",mo:"Moldavian",mn:"\u043c\u043e\u043d\u0433\u043e\u043b",na:"Ekakair\u0169 Naoero",nv:"Din\xe9 bizaad",nr:"isiNdebele (North)",nd:"isiNdebele (South)",ng:"Owambo",ne:"\u0928\u0947\u092a\u093e\u0932\u0940",nn:"Norsk nynorsk",nb:"Norsk bokm\xe5l",ny:"chiChe\u0175a",oc:"Occitan",oj:"\u140a\u14c2\u1511\u14c8\u142f\u14a7\u140e\u14d0",or:"Oriya",om:"Afaan Oromoo",os:"\u0438\u0440\u043e\u043d \xe6\u0432\u0437\u0430\u0433",pa:"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c\u0a40",pi:"\u092a\u093e\u0934\u093f",ps:"\u067e\u069a\u062a\u0648",qu:"Runa Simi",rm:"rumantsch grischun",ro:"rom\xe2n\u0103",rn:"kiRundi",sg:"y\xe2ng\xe2 t\xee s\xe4ng\xf6",sa:"\u0938\u0902\u0938\u094d\u0915\u0943\u0924\u092e\u094d",sr:"\u0441\u0440\u043f\u0441\u043a\u0438 \u0458\u0435\u0437\u0438\u043a",si:"Sinhala",sk:"sloven\u010dina",sl:"Sloven\u0161\u010dina",se:"Davvis\xe1megiella",sm:"gagana fa&apos;a Samoa",sn:"chiShona",sd:"\u0938\u093f\u0928\u094d\u0927\u0940",so:"Soomaaliga",st:"Sesotho",sc:"sardu",ss:"SiSwati",su:"Basa Sunda",sw:"Kiswahili",ty:"Reo Tahiti",ta:"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd",tt:"\u0442\u0430\u0442\u0430\u0440\u0447\u0430",te:"Telugu",tg:"\u0442\u043e\u04b7\u0438\u043a\u04e3",tl:"Wikang Tagalog",th:"\u0e44\u0e17\u0e22",bo:"\u0f56\u0f7c\u0f51\u0f0b\u0f61\u0f72\u0f42",ti:"Tigrinya",to:"faka Tonga",tn:"Setswana",ts:"Xitsonga",tk:"T\xfcrkmen",tw:"Twi",ug:"Uy\u01a3urq\u0259",uk:"\u0443\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430",ur:"\u0627\u0631\u062f\u0648",uz:"O&apos;zbek",ve:"Tshiven\u1e13a",vi:"Ti\u1ebfng Vi\u1ec7t",vo:"Volap\xfck",cy:"Cymraeg",wa:"Walon",wo:"Wollof",xh:"isiXhosa",yi:"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9",yo:"Yor\xf9b\xe1",za:"Sa\u026f cue\u014b\u0185",zu:"isiZulu",pb:"Portugu\xeas (Brasil)",fr:"Fran\xe7ais","fr-CA":"Fran\xe7ais Canadien",de:"Deutsch",sv:"Svenska",no:"Norsk",da:"Dansk",fi:"Suomeksi",nl:"Nederlands",it:"Italiano",es:"Espa\xf1ol","es-419":"Espa\xf1ol (Latinoam\xe9rica)",pl:"Polski",hu:"Magyar",el:"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac",tr:"T\xfcrk\xe7e",zh:"\u4e2d\u6587","zh-TW":"\u81fa\u8a9e",ru:"\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a",he:"\u05e2\u05d1\u05e8\u05d9\u05ea",ja:"\u65e5\u672c\u8a9e",pt:"Portugu\xeas","pt-BR":"Portugu\xeas Brasileiro",ko:"\ud55c\uad6d\uc5b4",cs:"\u010de\u0161tina",fa:"\u0641\u0627\u0631\u0633\u06cc",xx:"Unknown",xn:"None"},getLanguageName:function(e){return this.languages[e]||""
},parseHeader:function(e){return e&&e.match(/[a-zA-z\-]{2,10}/g)||[]},closestLanguage:function(t){var i,n;t=t||[];for(var s=0,a=t.length;a>s&&(n=t[s],"xx"!==n&&"xn"!==n&&(e.languages[n]?i=n:n.indexOf("-")>0&&(i=e.closestLanguage([n.split("-")[0]]))),!i);s++);return i}};return e}),define("plex/base/adapters/storageAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({"interface":["get","set","remove","clear"]});return t}),define("plex/base/models/StorageModel",["underscore","backbone","plex/base/adapters/storageAdapter"],function(e,t,i){"use strict";
function n(t,i){return t?e.reduce(i,function(e,i,n){return t[n]!==i&&(e[n]=i),e},{}):i}var s=t.Model.extend({save:function(s,a,r){var o,l=this.attributes;if(null==s||"object"==typeof s?(o=s,r=a):(o={})[s]=a,r=e.extend({validate:!0},r),o&&!r.wait){if(!this.set(o,r))return!1}else if(!this._validate(o,r))return!1;o&&r.wait&&(this.attributes=e.extend({},l,o)),void 0===r.parse&&(r.parse=!0);var c=this,d=r.success;r.success=function(){c.attributes=l,d&&d(c,l,r),c.trigger("sync",c,l,r)},t.wrapError(this,r);
var u=i.set(this._getStorageKey(),JSON.stringify(n(e.result(this,"defaults"),this.attributes)));return u.done(r.success).fail(r.error),o&&r.wait&&(this.attributes=l),u},populate:function(){return this.populatePromise||(this.populatePromise=this.fetch.apply(this,arguments)),this.populatePromise},fetch:function(n){n=n?e.clone(n):{},void 0===n.parse&&(n.parse=!0);var s=this,a=n.success;n.success=function(e){return s.set(s.parse(e,n),n)?(a&&a(s,e,n),void s.trigger("sync",s,e,n)):!1},t.wrapError(this,n);
var r=i.get(this._getStorageKey());return r.done(n.success).fail(n.error),this.populatePromise=r,r},destroy:function(n){n=n?e.clone(n):{};var s=this,a=n.success,r=function(){s.trigger("destroy",s,s.collection,n)};n.success=function(e){n.wait&&r(),a&&a(s,e,n),s.trigger("sync",s,e,n)},t.wrapError(this,n);var o=i.remove(this._getStorageKey());return o.done(n.success).fail(n.error),n.wait||r(),o},parse:function(e){return JSON.parse(e)},sync:function(){throw new Error("storage model doesn`t allow syncing to server")
},_getStorageKey:function(){var t=e.result(this,"storageKey");if(!t)throw new Error("storageKey is required");return t}});return s}),define("plex/base/models/AbstractSettingsModel",["plex/base/utils/languageUtil","plex/base/models/StorageModel"],function(e,t){"use strict";var i,n=window.PLEXWEB_OPTIONS&&window.PLEXWEB_OPTIONS.acceptLanguage,s=window.navigator;n?i=e.parseHeader(n):s.languages?i=s.languages:s.language?i=[s.language]:s.userLanguage&&(i=[s.userLanguage]);var a=e.closestLanguage(i)||"en",r=t.extend({defaults:{language:a,autoLogin:!1,extrasPrefixCount:0,debugLevel:0}});
return r}),define("plex/desktop/models/DesktopSettingsModel",["underscore","plex/base/utils/browser","plex/base/utils/constants/subtitlesBurnLevels","plex/base/models/AbstractSettingsModel"],function(e,t,i,n){"use strict";var s=n.extend({storageKey:"settingsv2",plexPassSettings:["syncVideoQuality","syncAudioQuality","syncPictureQuality"],defaults:e.extend({},n.prototype.defaults,{playThemeMusic:!1,keyboardShortcuts:!0,showUnwatchedIcons:!1,dashboardPriorityOnDeck:1,dashboardPriorityRecentlyAdded:2,dashboardPriorityChannels:3,dashboardPriorityQueue:4,dashboardPriorityRecommendations:5,dashboardOnDeckEnabled:!0,dashboardRecentlyAddedEnabled:!0,dashboardChannelsEnabled:!0,dashboardQueueEnabled:!0,dashboardRecommendationsEnabled:!0,sharedSearch:!0,channelSearch:!0,localQuality:-1,remoteQuality:8,channelQuality:-1,dash:!0,directPlay:!0,directStream:!0,autoResolution:!0,preferAAC:"wiiu"===t.id,allowAC3:!1,subtitleSize:100,subtitlesBurnLevel:i.ALWAYS,audioBoost:100,syncVideoQuality:"medium",syncAudioQuality:"medium",syncPictureQuality:"medium",sidebarOpen:!1,videoPlayerVolume:100,musicPlayerVolume:100,announcementsLastReadTimestamp:0,serverUpdateDismissedVersion:"",hasDismissedPremiumMusicAlert:!1,listType:"media-tile-list","listType!track":"media-list"}),getListTypeKey:function(e){var t="listType";
return e&&(t+="!"+e.get("typeString")),t},getListType:function(t){var i,n;return t=t||{},e.has(t,"mediaType")&&e.isObject(t.mediaType)&&(n=this.getListTypeKey(t.mediaType)),i=this.get(n)||this.get(t.fallbackKey)||this.get("listType")},saveListType:function(t,i){var n=this.getListTypeKey(t);this.save(n,i),e.isEqual(n,"listType")||this.trigger("change:listType",this,i)},getSectionListType:function(e,t){var i;return e&&(t=t||e.get("currentType"),i=e.getScopedKey("listType")),this.getListType({mediaType:t,fallbackKey:i})
}});return s}),define("plex/base/adapters/localizerAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({"interface":["getLanguages","load","t"]});return t}),define("plex/base/utils/dispatcher",["plex/base/utils/BaseClass","plex/base/mixins/eventMixin"],function(e,t){"use strict";var i=e.extend({mixins:t});return new i}),define("plex/base/mixins/localizerMixin",["underscore","jquery","plex/base/utils/dispatcher"],function(e,t,i){"use strict";var n={languages:{en:"en.json","en-GB":"en-GB.json",af:"af.json",my:"my.json",ca:"ca.json",cs:"cs.json",sr:"sr.json",da:"da.json",de:"de.json",et:"et.json",es:"es.json","es-419":"es-419.json",el:"el.json",fr:"fr.json","fr-CA":"fr-CA.json",hr:"hr.json",is:"is.json",it:"it.json",lt:"lt.json",hu:"hu.json",nl:"nl.json",no:"no.json",pl:"pl.json",pt:"pt.json","pt-BR":"pt-BR.json",ru:"ru.json",ro:"ro.json",sk:"sk.json",sl:"sl.json",fi:"fi.json",sv:"sv.json",vi:"vi.json",tr:"tr.json",uk:"uk.json",bg:"bg.json",zh:"zh.json","zh-TW":"zh-TW.json",ja:"ja.json",ko:"ko.json",th:"th.json",fa:"fa.json",ar:"ar.json",he:"he.json"},loadingPromise:null,loadingLanguage:null,getLanguages:function(){return this.languages
},getTranslation:function(e){return this.translations[this.language]?this.translations[this.language][e]:void 0},load:function(i){if(this.loadingLanguage&&this.loadingLanguage===i)return this.loadingPromise;var n,s=this.getLanguages();return n=e.has(s,i)?e.has(this.translations,i)?t.Deferred().resolve().promise():t.ajax({dataType:"json",url:this.basePath+s[i]}):t.Deferred().reject().promise(),this.loadingLanguage=i,this.loadingPromise=n,n.done(e.bind(this.onLoadSuccess,this,n)),n.fail(e.bind(this.onLoadError,this,n)),n
},t:function(t){if(!t)return"";var i,n=1,s=arguments.length;e.isObject(arguments[s-1])&&(i=arguments[s-1],s-=1);var a=this.getTranslation(t)||t;for(i&&i.escape&&(a=e.escape(a));s>n;)a=a.replace("{"+n+"}",arguments[n]),n++;return a},onLoadSuccess:function(e,t){var n=this.loadingLanguage;e===this.loadingPromise&&(this.loadingPromise=null,this.loadingLanguage=null,this.language=n,this.translations[n]=t,i.trigger("change:language",n))},onLoadError:function(e){e===this.loadingPromise&&(this.loadingPromise=null,this.loadingLanguage=null)
}};return n}),define("plex/desktop/adapters/DesktopLocalizer",["plex/base/utils/BaseClass","plex/base/mixins/localizerMixin","plex/base/adapters/settingsAdapter"],function(e,t,i){"use strict";var n=e.extend({mixins:t,constructor:function(){this.basePath="translations/",this.translations={},i.getInstance().on("change:language",function(e,t){this.load(t)},this)}});return n}),define("plex/base/adapters/errorTrackerAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({"interface":["init","enable","disable","set","capture"]});
return t}),function(e,t){"use strict";function i(e,t){var i,n;t=t||{},e="raven"+e.substr(0,1).toUpperCase()+e.substr(1),document.createEvent?(i=document.createEvent("HTMLEvents"),i.initEvent(e,!0,!0)):(i=document.createEventObject(),i.eventType=e);for(n in t)c(t,n)&&(i[n]=t[n]);if(document.createEvent)document.dispatchEvent(i);else try{document.fireEvent("on"+i.eventType.toLowerCase(),i)}catch(s){}}function n(e){this.name="RavenConfigError",this.message=e}function s(e){var t=j.exec(e),i={},s=7;try{for(;s--;)i[z[s]]=t[s]||""
}catch(a){throw new n("Invalid DSN: "+e)}if(i.pass)throw new n("Do not specify your private key in the DSN!");return i}function a(e){return"undefined"==typeof e}function r(e){return"function"==typeof e}function o(e){return"string"==typeof e}function l(e){for(var t in e)return!1;return!0}function c(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function d(e,t){var i,n;if(a(e.length))for(i in e)c(e,i)&&t.call(null,i,e[i]);else if(n=e.length)for(i=0;n>i;i++)t.call(null,i,e[i])}function u(){O="?sentry_version=4&sentry_client=raven-js/"+V.VERSION+"&sentry_key="+L
}function h(e,t){var n=[];e.stack&&e.stack.length&&d(e.stack,function(e,t){var i=p(t);i&&n.push(i)}),i("handle",{stackInfo:e,options:t}),f(e.name,e.message,e.url,e.lineno,n,t)}function p(e){if(e.url){var t,i={filename:e.url,lineno:e.line,colno:e.column,"function":e.func||"?"},n=m(e);if(n){var s=["pre_context","context_line","post_context"];for(t=3;t--;)i[s[t]]=n[t]}return i.in_app=!(!B.includePaths.test(i.filename)||/(Raven|TraceKit)\./.test(i["function"])||/raven\.(min\.)?js$/.test(i.filename)),i
}}function m(e){if(e.context&&B.fetchContext){for(var t=e.context,i=~~(t.length/2),n=t.length,s=!1;n--;)if(t[n].length>300){s=!0;break}if(s){if(a(e.column))return;return[[],t[i].substr(e.column,50),[]]}return[t.slice(0,i),t[i],t.slice(i+1)]}}function f(e,t,i,n,s,a){var r,o;t+="",("Error"!==e||t)&&(B.ignoreErrors.test(t)||(s&&s.length?(i=s[0].filename||i,s.reverse(),r={frames:s}):i&&(r={frames:[{filename:i,lineno:n,in_app:!0}]}),t=v(t,100),B.ignoreUrls&&B.ignoreUrls.test(i)||(!B.whitelistUrls||B.whitelistUrls.test(i))&&(o=n?t+" at "+n:t,b(g({exception:{type:e,value:t},stacktrace:r,culprit:i,message:o},a)))))
}function g(e,t){return t?(d(t,function(t,i){e[t]=i}),e):e}function v(e,t){return e.length<=t?e:e.substr(0,t)+"\u2026"}function y(){var e={url:document.location.href,headers:{"User-Agent":navigator.userAgent}};return document.referrer&&(e.headers.Referer=document.referrer),e}function b(e){x()&&(e=g({project:R,logger:B.logger,site:B.site,platform:"javascript",request:y()},e),e.tags=g(B.tags,e.tags),e.extra=g(B.extra,e.extra),l(e.tags)&&delete e.tags,l(e.extra)&&delete e.extra,E&&(e.user=E),r(B.dataCallback)&&(e=B.dataCallback(e)),(!r(B.shouldSendCallback)||B.shouldSendCallback(e))&&(M=e.event_id||(e.event_id=S()),w(e)))
}function w(e){var t=new Image,n=D+O+"&sentry_data="+encodeURIComponent(JSON.stringify(e));t.onload=function(){i("success",{data:e,src:n})},t.onerror=t.onabort=function(){i("failure",{data:e,src:n})},t.src=n}function x(){return F?D?!0:(C("error","Error: Raven has not been configured."),!1):!1}function k(e){for(var t,i=[],n=0,s=e.length;s>n;n++)t=e[n],o(t)?i.push(t.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):t&&t.source&&i.push(t.source);return new RegExp(i.join("|"),"i")}function S(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,i="x"==e?t:3&t|8;
return i.toString(16)})}function C(t,i){e.console&&console[t]&&V.debug&&console[t](i)}function P(){var t=e.RavenConfig;t&&V.config(t.dsn,t.config).install()}var A={remoteFetching:!1,collectWindowErrors:!0,linesOfContext:7},_=[].slice,I="?";A.wrap=function(e){function t(){try{return e.apply(this,arguments)}catch(t){throw A.report(t),t}}return t},A.report=function(){function i(e){o(),m.push(e)}function n(e){for(var t=m.length-1;t>=0;--t)m[t]===e&&m.splice(t,1)}function s(){l(),m=[]}function a(e,t){var i=null;
if(!t||A.collectWindowErrors){for(var n in m)if(c(m,n))try{m[n].apply(null,[e].concat(_.call(arguments,2)))}catch(s){i=s}if(i)throw i}}function r(e,t,i,n,s){var r=null;if(v)A.computeStackTrace.augmentStackTraceWithInitialElement(v,t,i,e),d();else if(s)r=A.computeStackTrace(s),a(r,!0);else{var o={url:t,line:i,column:n};o.func=A.computeStackTrace.guessFunctionName(o.url,o.line),o.context=A.computeStackTrace.gatherContext(o.url,o.line),r={message:e,url:document.location.href,stack:[o]},a(r,!0)}return h?h.apply(this,arguments):!1
}function o(){p||(h=e.onerror,e.onerror=r,p=!0)}function l(){p&&(e.onerror=h,p=!1,h=t)}function d(){var e=v,t=f;f=null,v=null,g=null,a.apply(null,[e,!1].concat(t))}function u(t,i){var n=_.call(arguments,1);if(v){if(g===t)return;d()}var s=A.computeStackTrace(t);if(v=s,g=t,f=n,e.setTimeout(function(){g===t&&d()},s.incomplete?2e3:0),i!==!1)throw t}var h,p,m=[],f=null,g=null,v=null;return u.subscribe=i,u.unsubscribe=n,u.uninstall=s,u}(),A.computeStackTrace=function(){function t(t){if(!A.remoteFetching)return"";
try{var i=function(){try{return new e.XMLHttpRequest}catch(t){return new e.ActiveXObject("Microsoft.XMLHTTP")}},n=i();return n.open("GET",t,!1),n.send(""),n.responseText}catch(s){return""}}function i(e){if(!o(e))return[];if(!c(x,e)){var i="";-1!==e.indexOf(document.domain)&&(i=t(e)),x[e]=i?i.split("\n"):[]}return x[e]}function n(e,t){var n,s=/function ([^(]*)\(([^)]*)\)/,r=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,o="",l=10,c=i(e);if(!c.length)return I;for(var d=0;l>d;++d)if(o=c[t-d]+o,!a(o)){if(n=r.exec(o))return n[1];
if(n=s.exec(o))return n[1]}return I}function s(e,t){var n=i(e);if(!n.length)return null;var s=[],r=Math.floor(A.linesOfContext/2),o=r+A.linesOfContext%2,l=Math.max(0,t-r-1),c=Math.min(n.length,t+o-1);t-=1;for(var d=l;c>d;++d)a(n[d])||s.push(n[d]);return s.length>0?s:null}function r(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function l(e){return r(e).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function d(e,t){for(var n,s,a=0,r=t.length;r>a;++a)if((n=i(t[a])).length&&(n=n.join("\n"),s=e.exec(n)))return{url:t[a],line:n.substring(0,s.index).split("\n").length,column:s.index-n.lastIndexOf("\n",s.index)-1};
return null}function u(e,t,n){var s,a=i(t),o=new RegExp("\\b"+r(e)+"\\b");return n-=1,a&&a.length>n&&(s=o.exec(a[n]))?s.index:null}function h(t){for(var i,n,s,a,o=[e.location.href],c=document.getElementsByTagName("script"),u=""+t,h=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,p=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,m=0;m<c.length;++m){var f=c[m];f.src&&o.push(f.src)}if(s=h.exec(u)){var g=s[1]?"\\s+"+s[1]:"",v=s[2].split(",").join("\\s*,\\s*");
i=r(s[3]).replace(/;$/,";?"),n=new RegExp("function"+g+"\\s*\\(\\s*"+v+"\\s*\\)\\s*{\\s*"+i+"\\s*}")}else n=new RegExp(r(u).replace(/\s+/g,"\\s+"));if(a=d(n,o))return a;if(s=p.exec(u)){var y=s[1];if(i=l(s[2]),n=new RegExp("on"+y+"=[\\'\"]\\s*"+i+"\\s*[\\'\"]","i"),a=d(n,o[0]))return a;if(n=new RegExp(i),a=d(n,o))return a}return null}function p(e){if(!e.stack)return null;for(var t,i,r=/^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,o=/^\s*(\S*)(?:\((.*?)\))?@((?:file|https?|chrome).*?):(\d+)(?::(\d+))?\s*$/i,l=e.stack.split("\n"),c=[],d=/^(.*) is undefined$/.exec(e.message),h=0,p=l.length;p>h;++h){if(t=o.exec(l[h]))i={url:t[3],func:t[1]||I,args:t[2]?t[2].split(","):"",line:+t[4],column:t[5]?+t[5]:null};
else{if(!(t=r.exec(l[h])))continue;i={url:t[2],func:t[1]||I,line:+t[3],column:t[4]?+t[4]:null}}!i.func&&i.line&&(i.func=n(i.url,i.line)),i.line&&(i.context=s(i.url,i.line)),c.push(i)}return c.length?(c[0].line&&!c[0].column&&d?c[0].column=u(d[1],c[0].url,c[0].line):c[0].column||a(e.columnNumber)||(c[0].column=e.columnNumber+1),{name:e.name,message:e.message,url:document.location.href,stack:c}):null}function m(e){for(var t,i=e.stacktrace,a=/ line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,r=i.split("\n"),o=[],l=0,c=r.length;c>l;l+=2)if(t=a.exec(r[l])){var d={line:+t[1],column:+t[2],func:t[3]||t[4],args:t[5]?t[5].split(","):[],url:t[6]};
if(!d.func&&d.line&&(d.func=n(d.url,d.line)),d.line)try{d.context=s(d.url,d.line)}catch(u){}d.context||(d.context=[r[l+1]]),o.push(d)}return o.length?{name:e.name,message:e.message,url:document.location.href,stack:o}:null}function f(t){var a=t.message.split("\n");if(a.length<4)return null;var r,o,u,h,p=/^\s*Line (\d+) of linked script ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,m=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,f=/^\s*Line (\d+) of function script\s*$/i,g=[],v=document.getElementsByTagName("script"),y=[];
for(o in v)c(v,o)&&!v[o].src&&y.push(v[o]);for(o=2,u=a.length;u>o;o+=2){var b=null;if(r=p.exec(a[o]))b={url:r[2],func:r[3],line:+r[1]};else if(r=m.exec(a[o])){b={url:r[3],func:r[4]};var w=+r[1],x=y[r[2]-1];if(x&&(h=i(b.url))){h=h.join("\n");var k=h.indexOf(x.innerText);k>=0&&(b.line=w+h.substring(0,k).split("\n").length)}}else if(r=f.exec(a[o])){var S=e.location.href.replace(/#.*$/,""),C=r[1],P=new RegExp(l(a[o+1]));h=d(P,[S]),b={url:S,line:h?h.line:C,func:""}}if(b){b.func||(b.func=n(b.url,b.line));
var A=s(b.url,b.line),_=A?A[Math.floor(A.length/2)]:null;b.context=A&&_.replace(/^\s*/,"")===a[o+1].replace(/^\s*/,"")?A:[a[o+1]],g.push(b)}}return g.length?{name:t.name,message:a[0],url:document.location.href,stack:g}:null}function g(e,t,i,a){var r={url:t,line:i};if(r.url&&r.line){e.incomplete=!1,r.func||(r.func=n(r.url,r.line)),r.context||(r.context=s(r.url,r.line));var o=/ '([^']+)' /.exec(a);if(o&&(r.column=u(o[1],r.url,r.line)),e.stack.length>0&&e.stack[0].url===r.url){if(e.stack[0].line===r.line)return!1;
if(!e.stack[0].line&&e.stack[0].func===r.func)return e.stack[0].line=r.line,e.stack[0].context=r.context,!1}return e.stack.unshift(r),e.partial=!0,!0}return e.incomplete=!0,!1}function v(e,t){for(var i,s,a,r=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,o=[],l={},c=!1,d=v.caller;d&&!c;d=d.caller)if(d!==y&&d!==A.report){if(s={url:null,func:I,line:null,column:null},d.name?s.func=d.name:(i=r.exec(d.toString()))&&(s.func=i[1]),a=h(d)){s.url=a.url,s.line=a.line,s.func===I&&(s.func=n(s.url,s.line));
var p=/ '([^']+)' /.exec(e.message||e.description);p&&(s.column=u(p[1],a.url,a.line))}l[""+d]?c=!0:l[""+d]=!0,o.push(s)}t&&o.splice(0,t);var m={name:e.name,message:e.message,url:document.location.href,stack:o};return g(m,e.sourceURL||e.fileName,e.line||e.lineNumber,e.message||e.description),m}function y(e,t){var i=null;t=null==t?0:+t;try{if(i=m(e))return i}catch(n){if(w)throw n}try{if(i=p(e))return i}catch(n){if(w)throw n}try{if(i=f(e))return i}catch(n){if(w)throw n}try{if(i=v(e,t+1))return i}catch(n){if(w)throw n
}return{}}function b(e){e=(null==e?0:+e)+1;try{throw new Error}catch(t){return y(t,e+1)}}var w=!1,x={};return y.augmentStackTraceWithInitialElement=g,y.guessFunctionName=n,y.gatherContext=s,y.ofCaller=b,y}();var T,M,D,E,L,R,O,N=e.Raven,F=!(!e.JSON||!e.JSON.stringify),B={logger:"javascript",ignoreErrors:[],ignoreUrls:[],whitelistUrls:[],includePaths:[],collectWindowErrors:!0,tags:{},extra:{}},U=!1,V={VERSION:"1.1.16",debug:!0,noConflict:function(){return e.Raven=N,V},config:function(e,t){if(D)return C("error","Error: Raven has already been configured"),V;
if(!e)return V;var i=s(e),n=i.path.lastIndexOf("/"),a=i.path.substr(1,n);return t&&d(t,function(e,t){B[e]=t}),B.ignoreErrors.push("Script error."),B.ignoreErrors.push("Script error"),B.ignoreErrors.push("Javascript error: Script error on line 0"),B.ignoreErrors.push("Javascript error: Script error. on line 0"),B.ignoreErrors=k(B.ignoreErrors),B.ignoreUrls=B.ignoreUrls.length?k(B.ignoreUrls):!1,B.whitelistUrls=B.whitelistUrls.length?k(B.whitelistUrls):!1,B.includePaths=k(B.includePaths),L=i.user,R=i.path.substr(n+1),D="//"+i.host+(i.port?":"+i.port:"")+"/"+a+"api/"+R+"/store/",i.protocol&&(D=i.protocol+":"+D),B.fetchContext&&(A.remoteFetching=!0),B.linesOfContext&&(A.linesOfContext=B.linesOfContext),A.collectWindowErrors=!!B.collectWindowErrors,u(),V
},install:function(){return x()&&!U&&(A.report.subscribe(h),U=!0),V},context:function(e,i,n){return r(e)&&(n=i||[],i=e,e=t),V.wrap(e,i).apply(this,n)},wrap:function(e,i){function n(){for(var t=[],n=arguments.length,s=!e||e&&e.deep!==!1;n--;)t[n]=s?V.wrap(e,arguments[n]):arguments[n];try{return i.apply(this,t)}catch(a){throw V.captureException(a,e),a}}if(a(i)&&!r(e))return e;if(r(e)&&(i=e,e=t),!r(i))return i;if(i.__raven__)return i;for(var s in i)c(i,s)&&(n[s]=i[s]);return n.__raven__=!0,n.__inner__=i,n
},uninstall:function(){return A.report.uninstall(),U=!1,V},captureException:function(e,t){if(!(e instanceof Error))return V.captureMessage(e,t);T=e;try{A.report(e,t)}catch(i){if(e!==i)throw i}return V},captureMessage:function(e,t){return b(g({message:e+""},t)),V},setUserContext:function(e){return E=e,V},setExtraContext:function(e){return B.extra=e||{},V},setTagsContext:function(e){return B.tags=e||{},V},lastException:function(){return T},lastEventId:function(){return M}};V.setUser=V.setUserContext;
var z="source protocol user pass host port path".split(" "),j=/^(?:(\w+):)?\/\/(\w+)(:\w+)?@([\w\.-]+)(?::(\d+))?(\/.*)/;n.prototype=new Error,n.prototype.constructor=n,P(),e.Raven=V,"function"==typeof define&&define.amd&&define("raven",[],function(){return V})}(this),define("plex/base/adapters/analytics/sentryTracker",["raven"],function(e){"use strict";var t={},i={init:function(t,i){e.config(t).install(),this.set("version",i)},enable:function(){e.install()},disable:function(){e.uninstall()},set:function(i,n){t[i]=n,e.setTagsContext(t)
},capture:function(t,i){e.captureException(t,i)}};return i}),define("plex/desktop/adapters/analytics/desktopSentryTracker",["underscore","raven","plex/base/adapters/analytics/sentryTracker"],function(e,t,i){"use strict";var n=e.extend({},i,{init:function(e,i){t.config(e,{shouldSendCallback:function(e){return/plex\.js/.test(e.culprit)}}).install(),this.set("version",i)}});return n}),define("plex/base/adapters/performanceAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({props:["name","taskThrottle"]});
return t}),define("plex/desktop/adapters/desktopPerformance",[],function(){"use strict";var e={name:"desktop",taskThrottle:{wait:10,batchSize:2}};return e}),define("plex/base/adapters/loggerAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({"interface":["log","success","info","warn","error","debug","group"]});return t}),define("plex/base/utils/capabilities",["plex/base/utils/browser"],function(e){"use strict";var t={hasConsole:!!(window.console&&window.console.log&&window.console.log.call),hasWebSocket:!!window.WebSocket,hasEventSource:!!window.EventSource,hasReplaceState:!(!window.history||!window.history.replaceState),hasFileUpload:!!(window.File&&window.FileList&&window.FileReader),hasMediaSource:!(!window.MediaSource&&!window.WebKitMediaSource),hasObjectUrl:function(){var t="ie"===e.id&&11===parseInt(e.version,10);
return t||e.presto?!1:!!(window.URL&&window.URL.createObjectURL&&window.URL.revokeObjectURL)}(),hasBlob:function(){try{return"fireos"===e.platformID?!1:!!new Blob}catch(t){return!1}}(),hasFullscreen:function(){var e=document.createElement("div");return!!(e.requestFullScreen||e.webkitRequestFullScreen||e.mozRequestFullScreen||e.msRequestFullscreen)}(),hasCanvas:function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))}(),hasTouchScreen:!!("ontouchstart"in window),hasPageVisibility:function(){return document.hidden===!0||document.hidden===!1
}(),hasWebKitPageVisibility:function(){return document.webkitHidden===!0||document.webkitHidden===!1}(),isChromeApp:!(!window.chrome||!window.chrome.storage)};return t}),define("plex/base/models/config",["underscore","backbone"],function(e,t){"use strict";var i=t.Model.extend({defaults:e.extend({env:"production",bundled:!1,hosted:!0,flash:!0,playerDiscovery:!0,colorizeLogs:!0,defaultTarget:"_self",serverUpdate:!1,serverSavePrimaryOnly:!1,requestAllConnections:!1,includeHttps:!1,allowMixedContent:!1},window.PLEXWEB)});
return new i}),define("plex/base/utils/ConsoleLogger",["underscore","plex/base/utils/BaseClass","plex/base/utils/capabilities","plex/base/mixins/eventMixin","plex/base/models/config"],function(e,t,i,n,s){"use strict";var a=t.extend({mixins:n,log:function(t){e.isString(t)&&(t={message:t});var n=t.type||"log",a=t.message||"";if(this.trigger("add",{type:n,message:a}),i.hasConsole){var r=t.logFn,o=t.color;r=r in console?console[r]:console.log,o&&s.get("colorizeLogs")?(a="%c"+a,o="color: "+o+";",r.call(console,a,o)):r.call(console,a)
}},success:function(e){this.log({type:"success",message:e,color:"green"})},info:function(e){this.log({type:"info",message:e,logFn:"info",color:"blue"})},debug:function(e){this.log({type:"debug",message:e,logFn:"trace",color:"#d500ff"})},warn:function(e){this.log({type:"warning",message:e,logFn:"warn",color:"#ff6600"})},error:function(e){this.log({type:"error",message:e,logFn:"error",color:"red"})},group:function(e,t){console.group&&console.group(e);for(var i=0,n=t.length;n>i;i++)this.log(t[i]);console.groupEnd&&console.groupEnd()
}});return a}),define("plex/base/utils/playerUtil",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";function i(t,i){var n=e.invert(t);return e.reduce(t,function(e,t){return e[t]=i[n[t]],e},{})}var n=t.extend({types:{VIDEO:"video",MUSIC:"music",PHOTO:"photo"},elements:{VIDEO:"video",MUSIC:"audio",PHOTO:"photo"},streams:{VIDEO:"video",MUSIC:"audio",PHOTO:"photo"},states:{STOPPED:"stopped",PAUSED:"paused",PLAYING:"playing",BUFFERING:"buffering",ERROR:"error"},castStates:{ERROR:"IDLE",STOPPED:"IDLE",PAUSED:"PAUSED",PLAYING:"PLAYING",BUFFERING:"BUFFERING"},initialize:function(){this.typeByElement=i(this.elements,this.types),this.elementByType=i(this.types,this.elements),this.typeByStream=i(this.streams,this.types),this.streamByType=i(this.types,this.streams),this.statebyCastState=i(this.castStates,this.states),this.castStateByState=i(this.states,this.castStates)
},getTypeByElement:function(e){return this.typeByElement[e]},getElementByType:function(e){return this.elementByType[e]},getTypeByStream:function(e){return this.typeByStream[e]},getStreamByType:function(e){return this.streamByType[e]},getStateByCastState:function(e){return this.statebyCastState[e]},getCastStateByState:function(e){return this.castStateByState[e]}});return new n}),define("plex/base/utils/t",["plex/base/adapters/localizerAdapter"],function(e){"use strict";return function(){return e.t.apply(e,arguments)
}}),define("x2js",function(e){return function(){var t;return t||e.X2JS}}(this)),define("plex/base/utils/parser",["underscore","x2js","plex/base/adapters/loggerAdapter"],function(e,t,i){"use strict";function n(t,i){e.isArray(i)?e.each(i,t):t(i)}function s(t){return e.reduce(t,function(e,t){var n=t.split("="),s=n[0],a=n[1];try{s=decodeURIComponent(s),a=void 0===a?null:decodeURIComponent(a),e.hasOwnProperty(s)?Array.isArray(e[s])?e[s].push(a):e[s]=[e[s],a]:e[s]=a}catch(r){i.warn("Unable to decode query string at "+s)
}return e},{})}var a=new t(!1,"",!0),r={parseXML:function(e){var t=a.parseXmlString(e);return t?(t.getElementsByTagName("parsererror").length&&i.warn("parseXML: Errors found while parsing XML document"),a.xml2json(t)):null},replaceXMLElementNames:function(t,i,n){e.isArray(i)||(i=[i]);var s=i.join("|"),a=new RegExp("<("+s+")","g"),r=new RegExp("</("+s+")>","g");return t=t.replace(a,"<"+n+' elementName="$1"'),t=t.replace(r,"</"+n+">")},parseEncodedString:function(e,t){function i(t){if(e.hasOwnProperty(t)){var i=e[t];
if(null==i)e[t]="";else try{e[t]=decodeURIComponent(i)}catch(n){}}}e&&n(i,t)},parseInteger:function(e,t){function i(t){if(e.hasOwnProperty(t)){var i=e[t];e[t]=null==i||""===i?0:parseInt(i,10)}}e&&n(i,t)},parseFloat:function(e,t){function i(t){if(e.hasOwnProperty(t)){var i=e[t];e[t]=null===i||""===i?0:parseFloat(i)}}e&&n(i,t)},parseBoolean:function(e,t){function i(t){if(e.hasOwnProperty(t)){var i=e[t];e[t]=i===!0||"true"==i||"1"==i}}e&&n(i,t)},parseArray:function(t,i){function s(i){if(t.hasOwnProperty(i)){var n=t[i];
e.isArray(n)||(t[i]=[n])}else t[i]=[]}t&&n(s,i)},parseQueryString:function(t,i,a){function r(i){if(t.hasOwnProperty(i)){var n=t[i];if(!e.isObject(n))return e.isString(n)&&(n=n.trim().replace(/^(\?|#)/,""))?void(t[i]=s(n.split(a))):void(t[i]={})}}t&&(a||(a="&"),n(r,i))}};return r}),define("plex/base/utils/cache/Cache",["underscore","plex/base/utils/BaseClass","plex/base/utils/dispatcher","plex/base/adapters/loggerAdapter","plex/base/mixins/eventMixin"],function(e,t,i,n,s){"use strict";var a=t.extend({mixins:s,maxCycles:3,maxSize:50,isListening:!1,initialize:function(){this._cache={},this.size=0,this.cycles=[],this.cycle()
},startListening:function(){this.isListening||(this.isListening=!0,this.listenTo(i,{"cycle:cache":this.cycle,"clearWhere:cache":this.clearWhere,"clearAll:cache":this.clearAll,"clearCycles:cache":this.clearCycles}))},get:function(t){var i=this._cache[t];return i&&i._cacheCycle&&this.setItemCycle(i,t,e.first(this.cycles)),i},store:function(t,i){i||(i=this.getItemCacheKey(t)),this.remove(t),i&&(this.startListening(),t._cacheKey=i,this._cache[i]=t,this.size++,t.persistInCache||this.setItemCycle(t,i,e.first(this.cycles)))
},getItemCacheKey:function(t){return e.result(t,"cacheKey")},setItemCycle:function(e,t,i){var n=e._cacheCycle;n&&n.hasOwnProperty(t)&&delete n[t],e._cacheCycle=i,i[t]=e},cycle:function(){this.size>this.maxSize&&(n.warn("Cache overflow, size: "+this.size),e.each(this.cycles.slice(1),this.removeCycle,this)),this.cycles.unshift({}),this.cycles.length>Math.max(this.maxCycles,1)&&this.removeCycle(e.last(this.cycles))},remove:function(e){if(e&&e._cacheKey){var t=e._cacheKey;this._cache.hasOwnProperty(t)&&(delete this._cache[t],this.size--),e._cacheCycle&&(e._cacheCycle.hasOwnProperty(t)&&delete e._cacheCycle[t],delete e._cacheCycle),delete e._cacheKey
}},removeCycle:function(t){e.each(e.values(t),this.remove,this);var i=e.indexOf(this.cycles,t);this.cycles.splice(i,1)},clearWhere:function(t){var i=e.where(e.values(this._cache),t);e.each(i,this.remove,this)},clearAll:function(){e.each(e.values(this._cache),this.remove,this),this.cycles.length=0,this.cycle(),this.stopListening(),this.isListening=!1},clearCycles:function(){for(var e=this.cycles;e.length;)this.removeCycle(e[e.length-1]);this.cycle()}});return a}),define("plex/base/utils/cache/CollectionCache",["underscore","plex/base/utils/cache/Cache"],function(e,t){"use strict";
var i=t.extend({maxCycles:3,maxSize:20,get:function(){var e=t.prototype.get.apply(this,arguments);return e&&e.every(function(e){return e.cache&&e.cache.isListening?(e.cache.store(e),!0):!1}),e},getItemCacheKey:function(t){var i=e.result(t,"url");return t.server?t.server.getScopedKey(i):i}});return i}),define("plex/base/utils/xhrTracker",["underscore","jquery","plex/base/utils/BaseClass"],function(e,t,i){"use strict";var n=i.extend({initialize:function(){e.bindAll(this,"onAjaxSend"),this.requests=[],this.byId={}
},startListening:function(){t(document).on("ajaxSend",this.onAjaxSend)},stopListening:function(){t(document).off("ajaxSend",this.onAjaxSend)},abortAll:function(e){for(var t=this.requests.length-1;t>-1;t--){var i=this.requests[t];(null==e||e===i.settings.scope)&&this.abort(i)}},abort:function(t){var i=e.isString(t)?this.byId[t]:t;i&&(i.xhr.aborting=!0,i.xhr.abort(),this.remove(i))},store:function(t,i){var n=e.uniqueId("r");t.rid=n;var s={xhr:t,settings:i};return this.requests.push(s),this.byId[n]=s,s
},remove:function(t){var i=e.indexOf(this.requests,t);i>-1&&this.requests.splice(i,1),this.byId.hasOwnProperty(t.xhr.rid)&&delete this.byId[t.xhr.rid]},onAjaxSend:function(t,i,n){if(!n.skipCorsWithRedirect){var s=this.store(i,n);i.always(e.bind(function(){i.aborting||this.remove(s)},this))}}});return new n}),define("plex/base/mixins/models/populateMixin",["underscore","jquery","backbone","plex/base/utils/xhrTracker"],function(e,t,i,n){"use strict";var s={hasPendingPopulate:function(){return!!this.populatePromise&&"pending"===this.populatePromise.state()
},populate:function(){return this.populatePromise||this.fetch.apply(this,arguments),this.populatePromise},fetch:function(){var n,s=t.Deferred();return this.hasPendingPopulate()?this.populatePromise:(n=this._fetch?this._fetch.apply(this,arguments):this instanceof i.Collection?i.Collection.prototype.fetch.apply(this,arguments):i.Model.prototype.fetch.apply(this,arguments),this.populatePromise=s.promise(),this.populatePromise.rid=n.rid,n.done(e.bind(function(e){s.resolveWith(this,[this,e]),this.resetPopulatePromise(t.Deferred().resolveWith(this,[this]).promise())
},this)),n.fail(e.bind(function(e){s.rejectWith(this,[this,e]),this.resetPopulatePromise(t.Deferred().rejectWith(this,[this]).promise())},this)),this.populatePromise)},abortPendingPopulate:function(){return this.hasPendingPopulate()&&n.abort(this.populatePromise.rid),this.populatePromise},resetPopulatePromise:function(e){return this.hasPendingPopulate()||(this.populatePromise=e),this.populatePromise},updatePopulatePromise:function(e){var i=this.populatePromise&&this.populatePromise.state();return i===e?this.populatePromise:(this.resetPopulatePromise(t.Deferred()),"resolved"===e?this.populatePromise.resolveWith(this,[this]):"rejected"===e&&this.populatePromise.rejectWith(this,[this]),this.populatePromise)
}};return s}),define("plex/base/models/BaseCollection",["underscore","backbone","jquery","plex/base/utils/parser","plex/base/utils/cache/CollectionCache","plex/base/mixins/models/populateMixin"],function(e,t,i,n,s,a){"use strict";var r=t.Collection.extend({mixins:[a],cache:new s,constructor:function(e,n){if(n||(n={}),this.server=n.server,this.section=n.section,this.channel=n.channel,this.device=n.device,this.parent=n.parent,this.allowInCache=n.allowInCache,this.persistInCache=n.persistInCache,this.skipCache=n.skipCache,n.url&&(this.url=n.url),n.path&&(this.path=n.path),(null!=n.pageStart||null!=n.pageSize)&&(this.pageStart=n.pageStart||0,this.pageSize=n.pageSize||0),n.populated&&this.resetPopulatePromise(i.Deferred().resolve().promise()),!n.allowInCache)return void t.Collection.prototype.constructor.apply(this,arguments);
this.initialize.apply(this,arguments);var s=this.cache.getItemCacheKey(this),a=this.cache.get(s);return a?a:n.onlyIfCached?{}:(t.Collection.prototype.constructor.apply(this,arguments),void this.cache.store(this,s))},sync:function(){return this.allowInCache&&this.cache.store(this),t.sync.apply(this,arguments)},syncUrl:function(){var t="";if(this.url&&(t=e.result(this,"url")),this.path){var n=e.result(this,"path");t+="/"!==t.substr(t.length-1)?"/":"",t+="/"===n[0]?n.substr(1):n}if(null!=this.pageStart||null!=this.pageSize){var s=this.pageStart||0,a=this.pageSize||0,r={};
r["X-Plex-Container-Start"]=s,r["X-Plex-Container-Size"]=a;var o=t.indexOf("?"),l=t.length;t+=o>-1?l-1>o?"&":"":"?",t+=i.param(r,!0)}return t},convert:function(t,i){var s=e.isObject(t)?t:n.parseXML(t);if(!i)return s;var a=s[i];return a?(e.isArray(a)||(a=[a]),a):[]},clone:function(e){var t={server:this.server,section:this.section,parent:this.parent,url:this.url};return e||(e=this.models),new this.constructor(e,t)},cloneDeep:function(e){return e||(e=this.map(function(e){return e.clone()})),this.clone(e)
},clear:function(t){t=e.extend({silent:!0},t),this.abortPendingPopulate(),this.resetPopulatePromise(null),this.reset([],t)}});return r.extend=function(){var e=t.Collection.extend.apply(this,arguments);return e.prototype.cache=new s,e},r}),define("plex/base/utils/cache/ModelCache",["underscore","plex/base/utils/cache/Cache"],function(e,t){"use strict";var i=t.extend({maxCycles:5,maxSize:100,getItemCacheKey:function(t,i){return e.isFunction(t.cacheKey)?(i||(i=t.toJSON()),t.cacheKey(i)):void 0}});return i
}),define("plex/base/models/BaseModel",["underscore","backbone","jquery","plex/base/utils/parser","plex/base/utils/cache/ModelCache","plex/base/mixins/models/populateMixin"],function(e,t,i,n,s,a){"use strict";var r=t.Model.extend({mixins:[a],cache:new s,constructor:function(i,n){i||(i={}),n||(n={}),this.server=this.findOption(n,"server"),this.section=this.findOption(n,"section"),this.channel=this.findOption(n,"channel"),this.device=this.findOption(n,"device"),this.parent=this.findOption(n,"parent");
var s=this.findOption(n,"skipCache");if(s)return void t.Model.prototype.constructor.apply(this,arguments);var a=this.cache.getItemCacheKey(this,i),r=this.cache.get(a);if(r)return n.parse&&(i=r.parse.call(r,i)),this.preserveCachedAttributes&&this.preserveCachedAttributes(n.url)?e.each(i,function(t,i){e.isUndefined(r.get(i))&&!e.isUndefined(t)&&r.set(i,t)}):r.set(i),r.server=this.server||r.server,r.section=this.section||r.section,r.channel=this.channel||r.channel,r.device=this.device||r.device,r.parent=this.parent||r.parent,n.collection&&(r.collection=n.collection),r;
var o=this.findOption(n,"onlyIfCached");return o?{}:(t.Model.prototype.constructor.apply(this,arguments),void this.cache.store(this,a))},findOption:function(e,t){return e[t]||e.collection&&e.collection[t]},clone:function(){var e={server:this.server,section:this.section,channel:this.channel,parent:this.parent,skipCache:!0};return new this.constructor(this.attributes,e)||null},convert:function(t){var i=e.isObject(t)?t:n.parseXML(t);return i},parse:function(t){var i=this.convert(t);return this.whitelistedAttrs&&(i=e.pick(i,this.whitelistedAttrs)),i
},save:function(n,s,a){var r,o,l,c=this.attributes;null==n||"object"==typeof n?(r=n,a=s):(r={})[n]=s,a=e.extend({validate:!0},a);var d=this.getSaveParams(r,a);if(e.extend(d,a.data),r&&!a.wait){if(!this.set(r,a))return!1}else if(!this._validate(r,a))return!1;if(r&&a.wait&&(this.attributes=e.extend({},c,r)),e.isEmpty(d)&&!a.force)return a.success&&a.success(this),i.Deferred().resolve(this);void 0===a.parse&&(a.parse=!0);var u=this,h=a.success;a.success=function(t){if(u.attributes=c,t){var i=u.parse(t,a);
if(a.wait&&(i=e.extend(r||{},i)),e.isObject(i)&&!u.set(i,a))return!1;u.cache.store(u)}h&&h(u,t,a),u.trigger("sync",u,t,a)},t.wrapError(this,a),o=this.isNew()?"create":a.patch?"patch":"update","patch"===o&&(a.attrs=r);var p=e.result(this,"saveUrl")||e.result(this,"url");if(!e.isEmpty(d)){var m=p.indexOf("?")>0?"&":"?";a.url=p+m+i.param(d,!0)}return a.data="",l=this.sync(o,this,a),r&&a.wait&&(this.attributes=c),l},getSaveParams:function(e){return this.isNew()?e||this.toJSON():this.changedAttributes(e)||{}
},getScopedKey:function(t){return null!=t&&e.isFunction(this.cacheKey)?this.cacheKey(this.attributes)+"!"+t:t}});return r.extend=function(){var e=t.Model.extend.apply(this,arguments);return e.prototype.cache=new s,e},r}),define("plex/base/models/AnnouncementModel",["underscore","plex/base/adapters/settingsAdapter","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({whitelistedAttrs:["promo","timestamp","link","thumb","title","description"],initialize:function(){this.listenTo(t.getInstance(),"change:announcementsLastReadTimestamp",this.onTimestampChange),this.onTimestampChange()
},parse:function(t){return e.pick(t,this.whitelistedAttrs)},onTimestampChange:function(){this.set("isUnread",this.get("timestamp")>t.get("announcementsLastReadTimestamp"))}});return n}),define("plex/base/models/AnnouncementCollection",["plex/base/models/BaseCollection","plex/base/models/AnnouncementModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"https://plex.r.worldssl.net/announcements/announcements.json?cb="+(new Date).getTime(),parse:function(e){return JSON.parse(e)}});return i
}),define("plex/base/models/debug/debugModel",["underscore","backbone","plex/base/utils/browser"],function(e,t,i){"use strict";var n=t.Model.extend({initialize:function(){this.set("host",window.location.host),this.set("userAgent",window.navigator.userAgent),this.set("browser",i)},toJSON:function(){var i=this.parent.get("primaryServer"),n=this.parent.get("user"),s=n.get("features");return this.set("version",this.parent.get("version")),i&&(this.set("primaryServerUrl",i.url()),this.set("primaryServerAuthToken",!!i.get("accessToken")),this.set("primaryServerVersion",i.get("versionFull"))),this.set("username",n.get("username")),this.set("cloudUrl",n.server.get("connections")),this.set("cloudAccessToken",!!n.server.get("accessToken")),s&&this.set("userFeatures",e.keys(s).join(", ")),t.Model.prototype.toJSON.apply(this,arguments)
}});return new n}),define("plex/base/models/debug/LogModel",["backbone"],function(e){"use strict";var t=e.Model.extend({initialize:function(){this.set("time",new Date)}});return t}),define("plex/base/models/debug/LogCollection",["underscore","jquery","backbone","plex/base/adapters/loggerAdapter","plex/base/adapters/settingsAdapter","plex/base/models/debug/debugModel","plex/base/models/debug/LogModel"],function(e,t,i,n,s,a,r){"use strict";var o=/(auth_token=|accessToken=|X-Plex-Token=)(\"?\w+\"?)/g,l=/(email=)(\"?[^&]+\"?)/g,c=/(password=)([^&]+)/,d=/(address=|host=)(\"?[^&]+\"?)/g,u=function(e){return e=e.replace(o,"$1TOKEN"),e.replace(c,"$1PASSWORD")
},h=function(e){return e&&e.hasOwnProperty("X-Plex-Token")&&(e["X-Plex-Token"]="TOKEN"),e&&e.hasOwnProperty("Authorization")&&(e.Authorization="BASIC AUTHORIZATION"),e},p=function(e){return e?(e=e.replace(o,'$1"TOKEN"'),e=e.replace(l,'$1"EMAIL"'),e=e.replace(d,'$1"IP ADRRESS"')):void 0},m=i.Collection.extend({model:r,initialize:function(t,i){e.bindAll(this,"onAjaxComplete"),this.parent=i.parent,a.parent=i.parent,s.hasInstance()&&this.onSettingsAdapterInstanceChange(),this.listenTo(s,"change:instance",this.onSettingsAdapterInstanceChange),n.on("change:instance",this.onLoggerChange,this),this.updateLogger()
},updateLogger:function(){this.logger&&(this.logger.off("add",this.onLogAdd,this),this.logger=null),n.hasInstance()&&(this.logger=n.getInstance(),this.startListening())},startListening:function(){!this.enabled&&this.logger&&s.get("debugLevel")&&(this.logger.on("add",this.onLogAdd,this),i.history.on("route",this.onRoute,this),t(document).on("ajaxComplete",this.onAjaxComplete),this.enabled=!0)},stopListening:function(){this.logger&&(this.logger.off("add",this.onLogAdd,this),i.history.off("route",this.onRoute,this),t(document).off("ajaxComplete",this.onAjaxComplete),this.reset(),this.enabled=!1)
},add:function(){this.length>200&&this.shift(),i.Collection.prototype.add.apply(this,arguments)},toJSON:function(){var t=i.Collection.prototype.toJSON.apply(this,arguments);return t.unshift(e.extend({type:"info"},a.toJSON())),t},toJSONString:function(){return JSON.stringify(this.toJSON(),null,2)},onDebugLevelChange:function(){0===s.get("debugLevel")?this.stopListening():this.startListening()},onLoggerChange:function(){this.updateLogger()},onSettingsAdapterInstanceChange:function(){this.settings&&this.stopListening(this.settings),this.settings=s.getInstance(),this.settings&&(this.listenTo(this.settings,"change:debugLevel",this.onDebugLevelChange),this.onDebugLevelChange())
},onLogAdd:function(e){this.add(e)},onRoute:function(e,t,i){var n={type:"navigation",route:t,args:i,fragment:window.location.hash};this.add(n)},onAjaxComplete:function(t,i,n){var a={type:"ajax",url:u(n.url),status:i.status};e.isEmpty(n.headers)||(a.headers=h(n.headers)),e.isEmpty(n.data)||(a.params=n.data),200===i.status?2===s.get("debugLevel")?a.response=p(i.responseText):a.responseLength=i.responseText.length:(a.statusText=i.statusText,a.response=p(i.responseText)),this.add(a)}});return m}),define("plex/base/adapters/dimensionsAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";
var t=new e({props:["X-Plex-Product","X-Plex-Version","X-Plex-Client-Identifier","X-Plex-Platform","X-Plex-Platform-Version","X-Plex-Device","X-Plex-Device-Name"]});return t}),define("plex/base/utils/types/sectionTypes",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=[{key:"movies",typeID:"1",typeString:"movie",title:"Movies",defaultAgent:"com.plexapp.agents.imdb",defaultLanguage:"en",defaultScanner:"Plex Movie Scanner",sectionTypeIcon:"film"},{key:"tv",typeID:"2",typeString:"show",title:"TV Shows",defaultAgent:"com.plexapp.agents.thetvdb",defaultLanguage:"en",defaultScanner:"Plex Series Scanner",sectionTypeIcon:"display"},{key:"music",typeID:"8",typeString:"artist",title:"Music",defaultAgent:"com.plexapp.agents.lastfm",defaultLanguage:"en",defaultScanner:"Plex Music Scanner",sectionTypeIcon:"music",exclusiveAgents:["com.plexapp.agents.plexmusic"],exclusiveScanners:["Plex Premium Music Scanner"]},{key:"photos",typeID:"13",typeString:"photo",title:"Photos",defaultAgent:"com.plexapp.agents.none",defaultLanguage:"xn",defaultScanner:"Plex Photo Scanner",sectionTypeIcon:"picture"},{key:"videos",typeID:"1",typeString:"movie",title:"Home Videos",defaultAgent:"com.plexapp.agents.none",defaultLanguage:"xn",defaultScanner:"Plex Video Files Scanner",sectionTypeIcon:"facetime-video"}],n=t.extend({initialize:function(){this.byKey=e.reduce(i,function(e,t){return e[t.key]=t,e
},{}),this.byType=e.reduceRight(i,function(e,t){return e[t.typeString]=t,e},{})},getSectionTypes:function(){return i},getSectionType:function(e){return this.byKey[e]},getSectionTypeByString:function(e){return this.byType[e]}});return new n}),define("plex/base/utils/types/subsetTypes",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=t.extend({types:[{key:"all",title:"All"},{key:"unwatched",title:"Unwatched"},{key:"newest",title:"Recently Released"},{key:"recentlyAdded",title:"Recently Added"},{key:"recentlyViewed",title:"Recently Viewed"},{key:"recentlyViewedShows",title:"Recently Viewed Shows"},{key:"onDeck",title:"On Deck"},{key:"folder",title:"By Folder"}],initialize:function(){this.byKey=e.reduce(this.types,function(e,t){return e[t.key]=t,e
},{})},getSubsetType:function(e){return this.byKey[e]}});return new i}),define("plex/base/models/library/section/SectionSubsetModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",whitelistedAttrs:["key","title","secondary"],whitelistedPrimarySubsets:["all","recentlyAdded","recentlyViewed","recentlyViewedShows","onDeck","newest","folder"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseBoolean(n,"secondary"),n
},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs),i.primary=!i.secondary&&e.contains(this.whitelistedPrimarySubsets,i.key),"all"===i.key&&(i.title="All"),i}});return n}),define("plex/base/models/library/section/SectionSubsetCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/section/SectionSubsetModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){return e.result(this.section,"url")},parse:function(e){return this.convert(e,"Directory")
},filterPrimaries:function(){var e=this.filter(function(e){return e.get("primary")});return this.clone(e)}});return n}),define("plex/base/models/library/section/MediaTypeModel",["underscore","plex/base/models/BaseModel"],function(e,t){"use strict";var i=t.extend({defaults:{selected:!1},whitelistedAttrs:["id","typeString","title","plural","element"],parse:function(t){var i=e.pick(t,this.whitelistedAttrs);return i}});return i}),define("plex/base/models/library/section/MediaTypeCollection",["plex/base/models/BaseCollection","plex/base/models/library/section/MediaTypeModel"],function(e,t){"use strict";
var i=e.extend({model:t});return i}),define("plex/base/models/library/section/FilterOptionModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",whitelistedAttrs:["key","type","title"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return n}),define("plex/base/models/library/section/FilterOptionCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/section/FilterOptionModel"],function(e,t,i){"use strict";
var n=t.extend({model:i,url:function(){var t=e.result(this.section,"url"),i=t+"/"+this.parent.id;return this.type?i+="?type="+this.type:this.standalone||(i+="?"+this.getUrlParams()),i},initialize:function(e,t){this.standalone=t.standalone,this.type=t.type},getUrlParams:function(){var t={},i=[],n=this.section.get("currentType"),s=this.section.get("currentFilters");n&&(t.type=n.id),e.each(s,function(e){e.key!==this.parent.id&&e.values.length&&(t[e.key]=e.values.join(","))},this);for(var a in t)i.push("unviewedLeafCount"===a?a+">="+t[a]:a+"="+t[a]);
return i.join("&")},parse:function(e){return this.convert(e,"Directory")},search:function(e){var t=this.filter(function(t){return t.get("title").toLowerCase().indexOf(e.toLowerCase())>-1});return this.clone(t)}});return n}),define("plex/base/models/library/section/FilterModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/library/section/FilterOptionCollection"],function(e,t,i,n){"use strict";var s=i.extend({idAttribute:"filter",whitelistedAttrs:["filter","filterType","key","title"],initialize:function(e,t){t||(t={}),this.set("options",new n([],{server:this.server,section:this.section,parent:this,standalone:t.standalone,type:t.type}))
},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return s}),define("plex/base/models/library/section/FilterCollection",["underscore","jquery","plex/base/models/BaseCollection","plex/base/models/library/section/FilterModel"],function(e,t,i,n){"use strict";var s=i.extend({model:n,comparator:"filterType",url:function(){var i=e.result(this.section,"url")+"/filters",n=this.section.get("currentType"),s={includeAdvanced:1};
return n&&(s.type=n.id),i+"?"+t.param(s,!0)},parse:function(e){return this.convert(e,"Directory")}});return s}),define("plex/base/models/library/section/LinearFilterModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/library/section/FilterOptionCollection"],function(e,t,i,n){"use strict";var s=i.extend({idAttribute:"key",whitelistedAttrs:["secondary","key","title"],initialize:function(){this.set("options",new n([],{server:this.server,section:this.section,parent:this}))
},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseBoolean(n,"secondary"),n},parse:function(t){var i=this.convert(t);return i.title=i.title.replace("By ",""),i=e.pick(i,this.whitelistedAttrs)}});return s}),define("plex/base/models/library/section/LinearFilterCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/section/LinearFilterModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){var t=e.result(this.section,"url");return t
},parse:function(e){return this.convert(e,"Directory")},filterBySecondary:function(){var e=this.filter(function(e){return e.get("secondary")});return this.clone(e)}});return n}),define("plex/base/models/library/section/SortModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",defaults:{selected:!1},whitelistedAttrs:["key","title","defaultDirection"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n
},parse:function(t){var i=this.convert(t);return i.defaultDirection=i["default"],i=e.pick(i,this.whitelistedAttrs)}});return n}),define("plex/base/models/library/section/SortCollection",["underscore","jquery","plex/base/models/BaseCollection","plex/base/models/library/section/SortModel"],function(e,t,i,n){"use strict";var s=i.extend({model:n,url:function(){var i=e.result(this.section,"url")+"/sorts",n=this.section.get("currentType"),s={};return n&&(s.type=n.id),i+"?"+t.param(s,!0)},parse:function(e){return this.convert(e,"Directory")
}});return s}),define("plex/base/models/library/section/AlphanumericModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",whitelistedAttrs:["key","title","size"],url:function(){return"/library/sections/"+this.section.id+"/firstCharacter/"+this.id},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseInteger(n,"size"),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)
}});return n}),define("plex/base/models/library/section/AlphanumericCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/section/AlphanumericModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){var t=e.result(this.section,"url"),i=t+"/firstCharacter?"+this.getUrlParams();return i},getUrlParams:function(){var t={},i=[],n=this.section.get("currentType");n&&(t.type=n.id);var s=this.section.get("currentFilters");e.each(s,function(e){e.values.length&&(t[e.key]=e.values.join(","))
},this);for(var a in t)i.push("unviewedLeafCount"===a?a+">="+t[a]:a+"="+t[a]);return i.join("&")},parse:function(e){return this.convert(e,"Directory")}});return n}),define("plex/base/utils/formatters/stringUtil",["underscore","plex/base/utils/t"],function(e,t){"use strict";var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n={encode64:function(e){var t,n,s,a,r,o="",l="",c="",d=0;do t=e.charCodeAt(d++),n=e.charCodeAt(d++),l=e.charCodeAt(d++),s=t>>2,a=(3&t)<<4|n>>4,r=(15&n)<<2|l>>6,c=63&l,isNaN(n)?r=c=64:isNaN(l)&&(c=64),o=o+i.charAt(s)+i.charAt(a)+i.charAt(r)+i.charAt(c),t=n=l="",s=a=r=c="";
while(d<e.length);return o},decode64:function(e){var t,n,s,a,r,o="",l="",c="",d=0,u=/[^A-Za-z0-9\+\/\=]/g;if(u.exec(e))throw new Error('There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, "+", "/", and "="\nExpect errors in decoding.');e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do s=i.indexOf(e.charAt(d++)),a=i.indexOf(e.charAt(d++)),r=i.indexOf(e.charAt(d++)),c=i.indexOf(e.charAt(d++)),t=s<<2|a>>4,n=(15&a)<<4|r>>2,l=(3&r)<<6|c,o+=String.fromCharCode(t),64!=r&&(o+=String.fromCharCode(n)),64!=c&&(o+=String.fromCharCode(l)),t=n=l="",s=a=r=c="";
while(d<e.length);return unescape(o)},toUtf8:function(e){for(var t="",i=0,n=0;n<e.length;n++){var s=e.charCodeAt(n);128>s||(2048>s?(n>i&&(t+=e.substring(i,n)),i=n+1,t+=String.fromCharCode(192|s>>>6),t+=String.fromCharCode(128|63&s)):(n>i&&(t+=e.substring(i,n)),i=n+1,t+=String.fromCharCode(224|s>>>12),t+=String.fromCharCode(128|s>>>6&63),t+=String.fromCharCode(128|63&s)))}return i>0&&i<e.length&&(t+=e.substring(i)),0===i?e:t},truncate:function(e,t){if(!e)return"";if(e.length>t){for(var i=e.substring(0,t-3);/\S/.test(i.charAt(i.length-1))===!1&&i.length>1;)i=i.slice(0,-1);
return i+"..."}return e},truncateMiddle:function(e,t,i){if(!e)return"";if(e.length>t){i=i||Math.floor((t-3)/2);var n=t-3-i;return e.substr(0,i)+"..."+e.substr(e.length-n)}return e},pluralize:function(e,t,i){return null==i&&(i=e+"s"),1===t?e:i},formatLabel:function(e){for(var t="",i=0,n=e.length;n>i;i++){var s=e.charAt(i),a=s.toUpperCase();t+=0===i?a:s===a?" "+a:s}return t},formatBoolean:function(e){return t(e&&0!==parseInt(e,10)?"Yes":"No")},upperCase:function(e){return(e||"").toUpperCase()},upperCaseFirstLetter:function(e){return e.charAt(0).toUpperCase()+e.slice(1)
},lowerCaseFirstLetter:function(e){return e.charAt(0).toLowerCase()+e.slice(1)},titleCase:function(e){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})},getLastSegment:function(t){return e.first(/[^\/\\]+$/.exec(t||"")||[])},random:function(){return Math.random().toString(36).substr(2)},shortFilename:function(e,t){return e?n.truncateMiddle(n.getLastSegment(e),t):void 0},escapeRegExp:function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},stableJSON:function(t){return JSON.stringify(e.reduce(e.keys(t).sort(),function(e,i){return e[i]=t[i],e
},{}))}};return n}),define("plex/base/utils/types/mediaTypes",["underscore","plex/base/utils/BaseClass","plex/base/utils/formatters/stringUtil"],function(e,t,i){"use strict";var n=t.extend({types:[{id:1,typeString:"movie",title:"Movie",plural:i.pluralize("Movie"),element:"video"},{id:2,typeString:"show",title:"Show",plural:i.pluralize("TV Show"),element:"directory",child:3,grandchild:4},{id:3,typeString:"season",title:"Season",plural:i.pluralize("Season"),element:"directory",parent:2,child:4},{id:4,typeString:"episode",title:"Episode",plural:i.pluralize("Episode"),element:"video",grandparent:2,parent:3},{id:5,typeString:"trailer",title:"Trailer",plural:i.pluralize("Trailer"),element:"video"},{id:6,typeString:"comic",title:"Comic",plural:i.pluralize("Comic"),element:"photo"},{id:7,typeString:"person",title:"Person",plural:i.pluralize("Person",null,"People"),element:"directory"},{id:8,typeString:"artist",title:"Artist",plural:i.pluralize("Artist"),element:"directory",child:9,grandchild:10},{id:9,typeString:"album",title:"Album",plural:i.pluralize("Album"),element:"directory",parent:8,child:10},{id:10,typeString:"track",title:"Track",plural:i.pluralize("Track"),element:"audio",grandparent:8,parent:9},{id:11,typeString:"picture",title:"Picture",plural:i.pluralize("Picture"),element:"photo"},{id:12,typeString:"clip",title:"Clip",plural:i.pluralize("Clip"),element:"video"},{id:13,typeString:"photo",title:"Photo",plural:i.pluralize("Photo"),element:"photo",parent:14},{id:14,typeString:"photoAlbum",title:"Photo Album",plural:i.pluralize("Photo Album"),element:"directory",child:13},{id:15,typeString:"playlist",title:"Playlist",plural:i.pluralize("Playlist"),element:"directory"},{id:16,typeString:"playlistFolder",title:"Playlist",plural:i.pluralize("Playlist"),element:"directory",child:15},{id:1001,typeString:"userPlaylistItem",title:"Clip",plural:i.pluralize("Clip"),element:"video"}],initialize:function(){this.byID=e.reduce(this.types,function(e,t){return e[t.id]=t,e
},{}),this.byType=e.reduce(this.types,function(e,t){return e[t.typeString]=t,e},{})},getMediaType:function(e){return this.byID[e]},getMediaTypeByString:function(e){return this.byType[e]},getRelatedMediaTypes:function(t){var i=this.byType[t];if(!i)return[];var n=["grandparent","parent","child","grandchild"],s=e.compact(e.map(n,e.bind(function(e){return i.hasOwnProperty(e)?this.byID[i[e]]:void 0},this)));return s.unshift(i),s},getChildMediaType:function(e){var t=this.byType[e];if(t){var i=t.grandchild||t.child;
return i?this.byID[i]:t}},typeHasChildMedia:function(e){var t=this.getChildMediaType(e);return t?t.typeString!==e:!1}});return new n}),define("plex/base/utils/rangeUtil",["underscore"],function(e){"use strict";function t(t){var i=e.clone(t);return"undefined"!=typeof i.last?(i.end=i.last+1,i.size=i.end-i.start):"undefined"!=typeof i.size?(i.end=i.start+i.size,i.last=i.end-1):"undefined"!=typeof i.end&&(i.last=i.end-1,i.size=i.end-i.start),i}function i(i,n){return e.filter(e.map(i,t),function(e){return n?e.size>=0:e.size>0
})}var n={difference:function(e,n,s){e=t(e),n=t(n);var a=[{start:e.start,last:Math.min(e.last,n.start-1)},{start:Math.max(e.start,n.end),last:e.last}];return i(a,s)},union:function(e,n,s){if(e=t(e),n=t(n),e.start>n.start){var a=e;e=n,n=a}var r=[e];return n.start<=e.end?r[0].last=Math.max(n.last,e.last):r.push(n),i(r,s)},degap:function(e,i){var n=t(e);return i=t(i),i.size?(n.start>i.end&&(n={start:i.end,end:n.end}),n.end<i.start&&(n={start:n.start,end:i.start}),t(n)):n},each:function(e,i,n){e=t(e);
for(var s=Math.min(e.start,e.end),a=Math.max(e.start,e.end);a>=s;s++)i.call(n,s)},roundByPage:function(e,i){return e=t(e),t({start:Math.floor(e.start/i)*i,end:Math.ceil(e.end/i)*i})}};return n}),define("plex/base/mixins/models/paginationMixin",["underscore","jquery","plex/base/utils/rangeUtil"],function(e,t,i){"use strict";var n={fetchRange:function(e){return e.remove=!1,e.scope="page",e.prepend&&(e.at=0),this.pageStart=e.start,this.pageSize=e.size,this.fetch(e).promise()},populateRange:function(n){var s=t.Deferred();
if(this.hasPendingPopulate())return s.reject().promise();this.populatedRange||(this.populatedRange={start:0,end:0});var a=i.difference(n,this.populatedRange)[0];if(!a)return s.resolve().promise();if(a=i.degap(a,this.populatedRange),n.reloadThreshold&&a.size>n.reloadThreshold)return this.reset([],{silent:!0}),this.populatedRange={start:0,end:0},this.populateRange(e.omit(n,"reloadThreshold"));var r=e.extend(n,a);r.prepend=a.start<this.populatedRange.start;var o=this.fetchRange(r);return o.done(e.bind(function(e){this.populatedRange={start:i.union(this.populatedRange,a)[0].start,size:e.length},s.resolve(e)
},this)),o.fail(s.reject),s.promise()},remove:function(t){var i=e.isArray(t)?t.length:1;this.populatedRange&&this.populatedRange.end&&(this.populatedRange.end-=i)}};return n}),function(e){function t(e,t){return function(i){return l(e.call(this,i),t)}}function i(e,t){return function(i){return this.lang().ordinal(e.call(this,i),t)}}function n(){}function s(e){w(e),r(this,e)}function a(e){var t=m(e),i=t.year||0,n=t.month||0,s=t.week||0,a=t.day||0,r=t.hour||0,o=t.minute||0,l=t.second||0,c=t.millisecond||0;
this._input=e,this._milliseconds=+c+1e3*l+6e4*o+36e5*r,this._days=+a+7*s,this._months=+n+12*i,this._data={},this._bubble()}function r(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return t.hasOwnProperty("toString")&&(e.toString=t.toString),t.hasOwnProperty("valueOf")&&(e.valueOf=t.valueOf),e}function o(e){return 0>e?Math.ceil(e):Math.floor(e)}function l(e,t){for(var i=e+"";i.length<t;)i="0"+i;return i}function c(e,t,i,n){var s,a,r=t._milliseconds,o=t._days,l=t._months;r&&e._d.setTime(+e._d+r*i),(o||l)&&(s=e.minute(),a=e.hour()),o&&e.date(e.date()+o*i),l&&e.month(e.month()+l*i),r&&!n&&tt.updateOffset(e),(o||l)&&(e.minute(s),e.hour(a))
}function d(e){return"[object Array]"===Object.prototype.toString.call(e)}function u(e){return"[object Date]"===Object.prototype.toString.call(e)||e instanceof Date}function h(e,t,i){var n,s=Math.min(e.length,t.length),a=Math.abs(e.length-t.length),r=0;for(n=0;s>n;n++)(i&&e[n]!==t[n]||!i&&g(e[n])!==g(t[n]))&&r++;return r+a}function p(e){if(e){var t=e.toLowerCase().replace(/(.)s$/,"$1");e=Nt[e]||Ft[t]||t}return e}function m(e){var t,i,n={};for(i in e)e.hasOwnProperty(i)&&(t=p(i),t&&(n[t]=e[i]));return n
}function f(t){var i,n;if(0===t.indexOf("week"))i=7,n="day";else{if(0!==t.indexOf("month"))return;i=12,n="month"}tt[t]=function(s,a){var r,o,l=tt.fn._lang[t],c=[];if("number"==typeof s&&(a=s,s=e),o=function(e){var t=tt().utc().set(n,e);return l.call(tt.fn._lang,t,s||"")},null!=a)return o(a);for(r=0;i>r;r++)c.push(o(r));return c}}function g(e){var t=+e,i=0;return 0!==t&&isFinite(t)&&(i=t>=0?Math.floor(t):Math.ceil(t)),i}function v(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}function y(e){return b(e)?366:365
}function b(e){return 0===e%4&&0!==e%100||0===e%400}function w(e){var t;e._a&&-2===e._pf.overflow&&(t=e._a[rt]<0||e._a[rt]>11?rt:e._a[ot]<1||e._a[ot]>v(e._a[at],e._a[rt])?ot:e._a[lt]<0||e._a[lt]>23?lt:e._a[ct]<0||e._a[ct]>59?ct:e._a[dt]<0||e._a[dt]>59?dt:e._a[ut]<0||e._a[ut]>999?ut:-1,e._pf._overflowDayOfYear&&(at>t||t>ot)&&(t=ot),e._pf.overflow=t)}function x(e){e._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}
}function k(e){return null==e._isValid&&(e._isValid=!isNaN(e._d.getTime())&&e._pf.overflow<0&&!e._pf.empty&&!e._pf.invalidMonth&&!e._pf.nullInput&&!e._pf.invalidFormat&&!e._pf.userInvalidated,e._strict&&(e._isValid=e._isValid&&0===e._pf.charsLeftOver&&0===e._pf.unusedTokens.length)),e._isValid}function S(e){return e?e.toLowerCase().replace("_","-"):e}function C(e,t){return t.abbr=e,ht[e]||(ht[e]=new n),ht[e].set(t),ht[e]}function P(e){delete ht[e]}function A(e){var t,i,n,s,a=0,r=function(e){if(!ht[e]&&pt)try{require("./lang/"+e)
}catch(t){}return ht[e]};if(!e)return tt.fn._lang;if(!d(e)){if(i=r(e))return i;e=[e]}for(;a<e.length;){for(s=S(e[a]).split("-"),t=s.length,n=S(e[a+1]),n=n?n.split("-"):null;t>0;){if(i=r(s.slice(0,t).join("-")))return i;if(n&&n.length>=t&&h(s,n,!0)>=t-1)break;t--}a++}return tt.fn._lang}function _(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function I(e){var t,i,n=e.match(vt);for(t=0,i=n.length;i>t;t++)n[t]=zt[n[t]]?zt[n[t]]:_(n[t]);return function(s){var a="";for(t=0;i>t;t++)a+=n[t]instanceof Function?n[t].call(s,e):n[t];
return a}}function T(e,t){return e.isValid()?(t=M(t,e.lang()),Bt[t]||(Bt[t]=I(t)),Bt[t](e)):e.lang().invalidDate()}function M(e,t){function i(e){return t.longDateFormat(e)||e}var n=5;for(yt.lastIndex=0;n>=0&&yt.test(e);)e=e.replace(yt,i),yt.lastIndex=0,n-=1;return e}function D(e,t){var i;switch(e){case"DDDD":return xt;case"YYYY":case"GGGG":case"gggg":return kt;case"YYYYY":case"GGGGG":case"ggggg":return St;case"S":case"SS":case"SSS":case"DDD":return wt;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Pt;
case"a":case"A":return A(t._l)._meridiemParse;case"X":return It;case"Z":case"ZZ":return At;case"T":return _t;case"SSSS":return Ct;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"ww":case"W":case"WW":case"e":case"E":return bt;default:return i=new RegExp(U(B(e.replace("\\","")),"i"))}}function E(e){var t=(At.exec(e)||[])[0],i=(t+"").match(Lt)||["-",0,0],n=+(60*i[1])+g(i[2]);return"+"===i[0]?-n:n}function L(e,t,i){var n,s=i._a;
switch(e){case"M":case"MM":null!=t&&(s[rt]=g(t)-1);break;case"MMM":case"MMMM":n=A(i._l).monthsParse(t),null!=n?s[rt]=n:i._pf.invalidMonth=t;break;case"D":case"DD":null!=t&&(s[ot]=g(t));break;case"DDD":case"DDDD":null!=t&&(i._dayOfYear=g(t));break;case"YY":s[at]=g(t)+(g(t)>68?1900:2e3);break;case"YYYY":case"YYYYY":s[at]=g(t);break;case"a":case"A":i._isPm=A(i._l).isPM(t);break;case"H":case"HH":case"h":case"hh":s[lt]=g(t);break;case"m":case"mm":s[ct]=g(t);break;case"s":case"ss":s[dt]=g(t);break;case"S":case"SS":case"SSS":case"SSSS":s[ut]=g(1e3*("0."+t));
break;case"X":i._d=new Date(1e3*parseFloat(t));break;case"Z":case"ZZ":i._useUTC=!0,i._tzm=E(t);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":e=e.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":e=e.substr(0,2),t&&(i._w=i._w||{},i._w[e]=t)}}function R(e){var t,i,n,s,a,r,o,l,c,d,u=[];if(!e._d){for(n=N(e),e._w&&null==e._a[ot]&&null==e._a[rt]&&(a=function(t){return t?t.length<3?parseInt(t,10)>68?"19"+t:"20"+t:t:null==e._a[at]?tt().weekYear():e._a[at]
},r=e._w,null!=r.GG||null!=r.W||null!=r.E?o=K(a(r.GG),r.W||1,r.E,4,1):(l=A(e._l),c=null!=r.d?W(r.d,l):null!=r.e?parseInt(r.e,10)+l._week.dow:0,d=parseInt(r.w,10)||1,null!=r.d&&c<l._week.dow&&d++,o=K(a(r.gg),d,c,l._week.doy,l._week.dow)),e._a[at]=o.year,e._dayOfYear=o.dayOfYear),e._dayOfYear&&(s=null==e._a[at]?n[at]:e._a[at],e._dayOfYear>y(s)&&(e._pf._overflowDayOfYear=!0),i=H(s,0,e._dayOfYear),e._a[rt]=i.getUTCMonth(),e._a[ot]=i.getUTCDate()),t=0;3>t&&null==e._a[t];++t)e._a[t]=u[t]=n[t];for(;7>t;t++)e._a[t]=u[t]=null==e._a[t]?2===t?1:0:e._a[t];
u[lt]+=g((e._tzm||0)/60),u[ct]+=g((e._tzm||0)%60),e._d=(e._useUTC?H:q).apply(null,u)}}function O(e){var t;e._d||(t=m(e._i),e._a=[t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond],R(e))}function N(e){var t=new Date;return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function F(e){e._a=[],e._pf.empty=!0;var t,i,n,s,a,r=A(e._l),o=""+e._i,l=o.length,c=0;for(n=M(e._f,r).match(vt)||[],t=0;t<n.length;t++)s=n[t],i=(D(s,e).exec(o)||[])[0],i&&(a=o.substr(0,o.indexOf(i)),a.length>0&&e._pf.unusedInput.push(a),o=o.slice(o.indexOf(i)+i.length),c+=i.length),zt[s]?(i?e._pf.empty=!1:e._pf.unusedTokens.push(s),L(s,i,e)):e._strict&&!i&&e._pf.unusedTokens.push(s);
e._pf.charsLeftOver=l-c,o.length>0&&e._pf.unusedInput.push(o),e._isPm&&e._a[lt]<12&&(e._a[lt]+=12),e._isPm===!1&&12===e._a[lt]&&(e._a[lt]=0),R(e),w(e)}function B(e){return e.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,i,n,s){return t||i||n||s})}function U(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function V(e){var t,i,n,s,a;if(0===e._f.length)return e._pf.invalidFormat=!0,void(e._d=new Date(0/0));for(s=0;s<e._f.length;s++)a=0,t=r({},e),x(t),t._f=e._f[s],F(t),k(t)&&(a+=t._pf.charsLeftOver,a+=10*t._pf.unusedTokens.length,t._pf.score=a,(null==n||n>a)&&(n=a,i=t));
r(e,i||t)}function z(e){var t,i=e._i,n=Tt.exec(i);if(n){for(e._pf.iso=!0,t=4;t>0;t--)if(n[t]){e._f=Dt[t-1]+(n[6]||" ");break}for(t=0;4>t;t++)if(Et[t][1].exec(i)){e._f+=Et[t][0];break}At.exec(i)&&(e._f+="Z"),F(e)}else e._d=new Date(i)}function j(t){var i=t._i,n=mt.exec(i);i===e?t._d=new Date:n?t._d=new Date(+n[1]):"string"==typeof i?z(t):d(i)?(t._a=i.slice(0),R(t)):u(i)?t._d=new Date(+i):"object"==typeof i?O(t):t._d=new Date(i)}function q(e,t,i,n,s,a,r){var o=new Date(e,t,i,n,s,a,r);return 1970>e&&o.setFullYear(e),o
}function H(e){var t=new Date(Date.UTC.apply(null,arguments));return 1970>e&&t.setUTCFullYear(e),t}function W(e,t){if("string"==typeof e)if(isNaN(e)){if(e=t.weekdaysParse(e),"number"!=typeof e)return null}else e=parseInt(e,10);return e}function $(e,t,i,n,s){return s.relativeTime(t||1,!!i,e,n)}function Y(e,t,i){var n=st(Math.abs(e)/1e3),s=st(n/60),a=st(s/60),r=st(a/24),o=st(r/365),l=45>n&&["s",n]||1===s&&["m"]||45>s&&["mm",s]||1===a&&["h"]||22>a&&["hh",a]||1===r&&["d"]||25>=r&&["dd",r]||45>=r&&["M"]||345>r&&["MM",st(r/30)]||1===o&&["y"]||["yy",o];
return l[2]=t,l[3]=e>0,l[4]=i,$.apply({},l)}function Q(e,t,i){var n,s=i-t,a=i-e.day();return a>s&&(a-=7),s-7>a&&(a+=7),n=tt(e).add("d",a),{week:Math.ceil(n.dayOfYear()/7),year:n.year()}}function K(e,t,i,n,s){var a,r,o=new Date(Date.UTC(e,0)).getUTCDay();return i=null!=i?i:s,a=s-o+(o>n?7:0),r=7*(t-1)+(i-s)+a+1,{year:r>0?e:e-1,dayOfYear:r>0?r:y(e-1)+r}}function X(e){var t=e._i,i=e._f;return"undefined"==typeof e._pf&&x(e),null===t?tt.invalid({nullInput:!0}):("string"==typeof t&&(e._i=t=A().preparse(t)),tt.isMoment(t)?(e=r({},t),e._d=new Date(+t._d)):i?d(i)?V(e):F(e):j(e),new s(e))
}function G(e,t){tt.fn[e]=tt.fn[e+"s"]=function(e){var i=this._isUTC?"UTC":"";return null!=e?(this._d["set"+i+t](e),tt.updateOffset(this),this):this._d["get"+i+t]()}}function J(e){tt.duration.fn[e]=function(){return this._data[e]}}function Z(e,t){tt.duration.fn["as"+e]=function(){return+this/t}}function et(e){var t=!1,i=tt;"undefined"==typeof ender&&(this.moment=e?function(){return!t&&console&&console.warn&&(t=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),i.apply(null,arguments)
}:tt)}for(var tt,it,nt="2.4.0",st=Math.round,at=0,rt=1,ot=2,lt=3,ct=4,dt=5,ut=6,ht={},pt="undefined"!=typeof module&&module.exports,mt=/^\/?Date\((\-?\d+)/i,ft=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,gt=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,vt=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,yt=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,bt=/\d\d?/,wt=/\d{1,3}/,xt=/\d{3}/,kt=/\d{1,4}/,St=/[+\-]?\d{1,6}/,Ct=/\d+/,Pt=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,At=/Z|[\+\-]\d\d:?\d\d/i,_t=/T/i,It=/[\+\-]?\d+(\.\d{1,3})?/,Tt=/^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d:?\d\d|Z)?)?$/,Mt="YYYY-MM-DDTHH:mm:ssZ",Dt=["YYYY-MM-DD","GGGG-[W]WW","GGGG-[W]WW-E","YYYY-DDD"],Et=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Lt=/([\+\-]|\d\d)/gi,Rt="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Ot={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Nt={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Ft={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Bt={},Ut="DDD w W M D d".split(" "),Vt="M D H h m s w W".split(" "),zt={M:function(){return this.month()+1
},MMM:function(e){return this.lang().monthsShort(this,e)},MMMM:function(e){return this.lang().months(this,e)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(e){return this.lang().weekdaysMin(this,e)},ddd:function(e){return this.lang().weekdaysShort(this,e)},dddd:function(e){return this.lang().weekdays(this,e)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return l(this.year()%100,2)},YYYY:function(){return l(this.year(),4)
},YYYYY:function(){return l(this.year(),5)},gg:function(){return l(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return l(this.weekYear(),5)},GG:function(){return l(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return l(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)
},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return g(this.milliseconds()/100)},SS:function(){return l(g(this.milliseconds()/10),2)},SSS:function(){return l(this.milliseconds(),3)},SSSS:function(){return l(this.milliseconds(),3)},Z:function(){var e=-this.zone(),t="+";return 0>e&&(e=-e,t="-"),t+l(g(e/60),2)+":"+l(g(e)%60,2)},ZZ:function(){var e=-this.zone(),t="+";return 0>e&&(e=-e,t="-"),t+l(g(10*e/6),4)
},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()}},jt=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Ut.length;)it=Ut.pop(),zt[it+"o"]=i(zt[it],it);for(;Vt.length;)it=Vt.pop(),zt[it+it]=t(zt[it],2);for(zt.DDDD=t(zt.DDD,3),r(n.prototype,{set:function(e){var t,i;for(i in e)t=e[i],"function"==typeof t?this[i]=t:this["_"+i]=t},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(e){return this._months[e.month()]
},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(e){return this._monthsShort[e.month()]},monthsParse:function(e){var t,i,n;for(this._monthsParse||(this._monthsParse=[]),t=0;12>t;t++)if(this._monthsParse[t]||(i=tt.utc([2e3,t]),n="^"+this.months(i,"")+"|^"+this.monthsShort(i,""),this._monthsParse[t]=new RegExp(n.replace(".",""),"i")),this._monthsParse[t].test(e))return t},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(e){return this._weekdays[e.day()]
},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(e){return this._weekdaysShort[e.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(e){return this._weekdaysMin[e.day()]},weekdaysParse:function(e){var t,i,n;for(this._weekdaysParse||(this._weekdaysParse=[]),t=0;7>t;t++)if(this._weekdaysParse[t]||(i=tt([2e3,1]).day(t),n="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[t]=new RegExp(n.replace(".",""),"i")),this._weekdaysParse[t].test(e))return t
},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(e){var t=this._longDateFormat[e];return!t&&this._longDateFormat[e.toUpperCase()]&&(t=this._longDateFormat[e.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(e){return e.slice(1)}),this._longDateFormat[e]=t),t},isPM:function(e){return"p"===(e+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(e,t,i){return e>11?i?"pm":"PM":i?"am":"AM"
},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(e,t){var i=this._calendar[e];return"function"==typeof i?i.apply(t):i},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(e,t,i,n){var s=this._relativeTime[i];
return"function"==typeof s?s(e,t,i,n):s.replace(/%d/i,e)},pastFuture:function(e,t){var i=this._relativeTime[e>0?"future":"past"];return"function"==typeof i?i(t):i.replace(/%s/i,t)},ordinal:function(e){return this._ordinal.replace("%d",e)},_ordinal:"%d",preparse:function(e){return e},postformat:function(e){return e},week:function(e){return Q(e,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),tt=function(t,i,n,s){return"boolean"==typeof n&&(s=n,n=e),X({_i:t,_f:i,_l:n,_strict:s,_isUTC:!1})
},tt.utc=function(t,i,n,s){var a;return"boolean"==typeof n&&(s=n,n=e),a=X({_useUTC:!0,_isUTC:!0,_l:n,_i:t,_f:i,_strict:s}).utc()},tt.unix=function(e){return tt(1e3*e)},tt.duration=function(e,t){var i,n,s,r=tt.isDuration(e),o="number"==typeof e,l=r?e._input:o?{}:e,c=null;return o?t?l[t]=e:l.milliseconds=e:(c=ft.exec(e))?(i="-"===c[1]?-1:1,l={y:0,d:g(c[ot])*i,h:g(c[lt])*i,m:g(c[ct])*i,s:g(c[dt])*i,ms:g(c[ut])*i}):(c=gt.exec(e))&&(i="-"===c[1]?-1:1,s=function(e){var t=e&&parseFloat(e.replace(",","."));
return(isNaN(t)?0:t)*i},l={y:s(c[2]),M:s(c[3]),d:s(c[4]),h:s(c[5]),m:s(c[6]),s:s(c[7]),w:s(c[8])}),n=new a(l),r&&e.hasOwnProperty("_lang")&&(n._lang=e._lang),n},tt.version=nt,tt.defaultFormat=Mt,tt.updateOffset=function(){},tt.lang=function(e,t){var i;return e?(t?C(S(e),t):null===t?(P(e),e="en"):ht[e]||A(e),i=tt.duration.fn._lang=tt.fn._lang=A(e),i._abbr):tt.fn._lang._abbr},tt.langData=function(e){return e&&e._lang&&e._lang._abbr&&(e=e._lang._abbr),A(e)},tt.isMoment=function(e){return e instanceof s
},tt.isDuration=function(e){return e instanceof a},it=jt.length-1;it>=0;--it)f(jt[it]);for(tt.normalizeUnits=function(e){return p(e)},tt.invalid=function(e){var t=tt.utc(0/0);return null!=e?r(t._pf,e):t._pf.userInvalidated=!0,t},tt.parseZone=function(e){return tt(e).parseZone()},r(tt.fn=s.prototype,{clone:function(){return tt(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")
},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){return T(tt(this).utc(),"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var e=this;return[e.year(),e.month(),e.date(),e.hours(),e.minutes(),e.seconds(),e.milliseconds()]},isValid:function(){return k(this)},isDSTShifted:function(){return this._a?this.isValid()&&h(this._a,(this._isUTC?tt.utc(this._a):tt(this._a)).toArray())>0:!1},parsingFlags:function(){return r({},this._pf)},invalidAt:function(){return this._pf.overflow
},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(e){var t=T(this,e||tt.defaultFormat);return this.lang().postformat(t)},add:function(e,t){var i;return i="string"==typeof e?tt.duration(+t,e):tt.duration(e,t),c(this,i,1),this},subtract:function(e,t){var i;return i="string"==typeof e?tt.duration(+t,e):tt.duration(e,t),c(this,i,-1),this},diff:function(e,t,i){var n,s,a=this._isUTC?tt(e).zone(this._offset||0):tt(e).local(),r=6e4*(this.zone()-a.zone());
return t=p(t),"year"===t||"month"===t?(n=432e5*(this.daysInMonth()+a.daysInMonth()),s=12*(this.year()-a.year())+(this.month()-a.month()),s+=(this-tt(this).startOf("month")-(a-tt(a).startOf("month")))/n,s-=6e4*(this.zone()-tt(this).startOf("month").zone()-(a.zone()-tt(a).startOf("month").zone()))/n,"year"===t&&(s/=12)):(n=this-a,s="second"===t?n/1e3:"minute"===t?n/6e4:"hour"===t?n/36e5:"day"===t?(n-r)/864e5:"week"===t?(n-r)/6048e5:n),i?s:o(s)},from:function(e,t){return tt.duration(this.diff(e)).lang(this.lang()._abbr).humanize(!t)
},fromNow:function(e){return this.from(tt(),e)},calendar:function(){var e=this.diff(tt().zone(this.zone()).startOf("day"),"days",!0),t=-6>e?"sameElse":-1>e?"lastWeek":0>e?"lastDay":1>e?"sameDay":2>e?"nextDay":7>e?"nextWeek":"sameElse";return this.format(this.lang().calendar(t,this))},isLeapYear:function(){return b(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(e){var t=this._isUTC?this._d.getUTCDay():this._d.getDay();
return null!=e?(e=W(e,this.lang()),this.add({d:e-t})):t},month:function(e){var t,i=this._isUTC?"UTC":"";return null!=e?"string"==typeof e&&(e=this.lang().monthsParse(e),"number"!=typeof e)?this:(t=this.date(),this.date(1),this._d["set"+i+"Month"](e),this.date(Math.min(t,this.daysInMonth())),tt.updateOffset(this),this):this._d["get"+i+"Month"]()},startOf:function(e){switch(e=p(e)){case"year":this.month(0);case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);
case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===e?this.weekday(0):"isoWeek"===e&&this.isoWeekday(1),this},endOf:function(e){return e=p(e),this.startOf(e).add("isoWeek"===e?"week":e,1).subtract("ms",1)},isAfter:function(e,t){return t="undefined"!=typeof t?t:"millisecond",+this.clone().startOf(t)>+tt(e).startOf(t)},isBefore:function(e,t){return t="undefined"!=typeof t?t:"millisecond",+this.clone().startOf(t)<+tt(e).startOf(t)},isSame:function(e,t){return t="undefined"!=typeof t?t:"millisecond",+this.clone().startOf(t)===+tt(e).startOf(t)
},min:function(e){return e=tt.apply(null,arguments),this>e?this:e},max:function(e){return e=tt.apply(null,arguments),e>this?this:e},zone:function(e){var t=this._offset||0;return null==e?this._isUTC?t:this._d.getTimezoneOffset():("string"==typeof e&&(e=E(e)),Math.abs(e)<16&&(e=60*e),this._offset=e,this._isUTC=!0,t!==e&&c(this,tt.duration(t-e,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return"string"==typeof this._i&&this.zone(this._i),this
},hasAlignedHourOffset:function(e){return e=e?tt(e).zone():0,0===(this.zone()-e)%60},daysInMonth:function(){return v(this.year(),this.month())},dayOfYear:function(e){var t=st((tt(this).startOf("day")-tt(this).startOf("year"))/864e5)+1;return null==e?t:this.add("d",e-t)},weekYear:function(e){var t=Q(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==e?t:this.add("y",e-t)},isoWeekYear:function(e){var t=Q(this,1,4).year;return null==e?t:this.add("y",e-t)},week:function(e){var t=this.lang().week(this);
return null==e?t:this.add("d",7*(e-t))},isoWeek:function(e){var t=Q(this,1,4).week;return null==e?t:this.add("d",7*(e-t))},weekday:function(e){var t=(this.day()+7-this.lang()._week.dow)%7;return null==e?t:this.add("d",e-t)},isoWeekday:function(e){return null==e?this.day()||7:this.day(this.day()%7?e:e-7)},get:function(e){return e=p(e),this[e]()},set:function(e,t){return e=p(e),"function"==typeof this[e]&&this[e](t),this},lang:function(t){return t===e?this._lang:(this._lang=A(t),this)}}),it=0;it<Rt.length;it++)G(Rt[it].toLowerCase().replace(/s$/,""),Rt[it]);
G("year","FullYear"),tt.fn.days=tt.fn.day,tt.fn.months=tt.fn.month,tt.fn.weeks=tt.fn.week,tt.fn.isoWeeks=tt.fn.isoWeek,tt.fn.toJSON=tt.fn.toISOString,r(tt.duration.fn=a.prototype,{_bubble:function(){var e,t,i,n,s=this._milliseconds,a=this._days,r=this._months,l=this._data;l.milliseconds=s%1e3,e=o(s/1e3),l.seconds=e%60,t=o(e/60),l.minutes=t%60,i=o(t/60),l.hours=i%24,a+=o(i/24),l.days=a%30,r+=o(a/30),l.months=r%12,n=o(r/12),l.years=n},weeks:function(){return o(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+2592e6*(this._months%12)+31536e6*g(this._months/12)
},humanize:function(e){var t=+this,i=Y(t,!e,this.lang());return e&&(i=this.lang().pastFuture(t,i)),this.lang().postformat(i)},add:function(e,t){var i=tt.duration(e,t);return this._milliseconds+=i._milliseconds,this._days+=i._days,this._months+=i._months,this._bubble(),this},subtract:function(e,t){var i=tt.duration(e,t);return this._milliseconds-=i._milliseconds,this._days-=i._days,this._months-=i._months,this._bubble(),this},get:function(e){return e=p(e),this[e.toLowerCase()+"s"]()},as:function(e){return e=p(e),this["as"+e.charAt(0).toUpperCase()+e.slice(1)+"s"]()
},lang:tt.fn.lang,toIsoString:function(){var e=Math.abs(this.years()),t=Math.abs(this.months()),i=Math.abs(this.days()),n=Math.abs(this.hours()),s=Math.abs(this.minutes()),a=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(e?e+"Y":"")+(t?t+"M":"")+(i?i+"D":"")+(n||s||a?"T":"")+(n?n+"H":"")+(s?s+"M":"")+(a?a+"S":""):"P0D"}});for(it in Ot)Ot.hasOwnProperty(it)&&(Z(it,Ot[it]),J(it.toLowerCase()));Z("Weeks",6048e5),tt.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()
},tt.lang("en",{ordinal:function(e){var t=e%10,i=1===g(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th";return e+i}}),pt?(module.exports=tt,et(!0)):"function"==typeof define&&define.amd?define("moment",["require","exports","module"],function(t,i,n){return n.config().noGlobal!==!0&&et(n.config().noGlobal===e),tt}):et()}.call(this),define("plex/base/utils/formatters/numberUtil",["underscore"],function(e){"use strict";var t={leadingZero:function(t){if(t=parseInt(t,10),e.isNaN(t))return"";var i=10>t?"0":"";
return i+t},bytesToSize:function(t,i){if(t=parseInt(t,10),i=i||1,e.isNaN(t))return"";if(0===t)return"0 Bytes";var n=["Bytes","KB","MB","GB","TB"],s=parseInt(Math.floor(Math.log(t)/Math.log(1024)),10);return(t/Math.pow(1024,s)).toFixed(i)+" "+n[s]}};return t}),define("plex/base/utils/types/streamTypes",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=t.extend({types:[{id:1,typeString:"video",key:"videoStreamID",title:"Video"},{id:2,typeString:"audio",key:"audioStreamID",title:"Audio"},{id:3,typeString:"subtitles",key:"subtitleStreamID",title:"Subtitles"}],initialize:function(){this.byID=e.reduce(this.types,function(e,t){return e[t.id]=t,e
},{}),this.byType=e.reduce(this.types,function(e,t){return e[t.typeString]=t,e},{})},getStreamType:function(e){return this.byID[e]},getStreamTypeByString:function(e){return this.byType[e]}});return new i}),define("plex/base/utils/mediaUtil",["underscore","jquery","moment","plex/base/utils/t","plex/base/utils/formatters/numberUtil","plex/base/utils/types/streamTypes","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r){"use strict";var o={capabilities:"protocols=http-live-streaming,http-mp4-streaming,http-streaming-video,http-streaming-video-720p,http-mp4-video,http-mp4-video-720p;videoDecoders=h264{profile:high&resolution:1080&level:51};audioDecoders=mp3,aac{bitrate:160000}",serverTimelineDelay:1e4,pingDelay:3e4,playbackDelay:1e3,timeline:function(i,n){var s=i.item,a=i.media,o=i.part,l=s.get("ratingKey"),c=s.get("type");
if(!l)return t.Deferred().resolve().promise();var d={ratingKey:l,key:s.get("key"),state:i.state};if(i.continuing&&(d.continuing="1"),s.get("playQueueItemID")&&(d.playQueueItemID=s.get("playQueueItemID")),!("photo"===c||a&&o))return t.Deferred().resolve().promise();if("photo"!==c){var u=s.get("viewOffset")||0,h=a.duration;if(e.isNumber(i.position)&&(u=i.position,u=this.getAbsoluteOffset(a,o,u)),h||e.isNumber(i.duration)&&(h=i.duration,a.duration=h),!h)return t.Deferred().resolve().promise();u>h&&(u=h),d.time=u,d.duration=h,"track"!==c&&s.isLibraryItem()&&this.setViewOffset(s,u,h)
}var p="timeline: "+d.state;null!=d.time&&(p+=", "+d.time+"/"+d.duration),r.log(p);var m="/:/timeline?"+t.param(d,!0);return n=e.extend(s.server.getXHROptions(m),n),t.ajax(n)},setViewOffset:function(e,t,i){1!==e.get("extraType")&&(6e4>t||(t>.9*i?(e.set("viewOffset",0),e.set("viewCount",1)):e.set("viewOffset",t)))},ping:function(e,i){if(!i)return t.Deferred().resolve().promise();r.log("ping transcoder");var n;return n=e.supports("universalTranscoder")?"/video/:/transcode/universal/ping?session="+i:"/video/:/transcode/segmented/ping?session="+i,t.ajax(e.getXHROptions(n))
},stop:function(i,n,s){if(!n)return t.Deferred().resolve().promise();r.log("stop transcoder");var a;return a=i.supports("universalTranscoder")?"/video/:/transcode/universal/stop?session="+n:"/video/:/transcode/segmented/stop?session="+n,s=e.extend(i.getXHROptions(a),s),t.ajax(s)},getMediaIndex:function(t,i){var n=t.get("Media"),s=e.indexOf(n,e.findWhere(n,{id:i}));return s},getPartIndex:function(t,i){var n=t.Part,s=e.indexOf(n,e.findWhere(n,{key:i}));return s},getPartCount:function(e){return e?e.Part.length:0
},getStreams:function(t,i){var n=[];if(t){var s=e.first(t.Part);s&&s.Stream&&n.push.apply(n,e.where(s.Stream,i))}return n},getSelectedVideo:function(t){var i=a.getStreamTypeByString("video"),n=this.getStreams(t,{streamType:i.id});return e.first(n)},getSelectedAudio:function(t){var i=a.getStreamTypeByString("audio"),n=this.getStreams(t,{streamType:i.id,selected:!0});return e.first(n)},getSelectedSubtitles:function(t){var i=a.getStreamTypeByString("subtitles"),n=this.getStreams(t,{streamType:i.id,selected:!0}),s=e.first(n);
return s&&s.id>0?s:void 0},selectStream:function(t,i,n){if(t){var s=this.getStreams(t,{streamType:i.id});e.each(s,function(e){e.selected=e.id===n})}},getMissingParts:function(t){var i=[];return e.isArray(t)||(t=[t]),e.each(t,function(t){var n=t.Part;n&&e.each(n,function(e){(e.exists===!1||e.accessible===!1)&&i.push(e)})}),i},getRelativeOffset:function(e,t,i){var n=i;if(e.Part.length>1)for(var s=0,a=e.Part.length;a>s;s++){var r=e.Part[s];if(!r.duration)break;if(t.key===r.key)break;n-=r.duration}return n
},getAbsoluteOffset:function(e,t,i){var n=i;if(e.Part.length>1)for(var s=0,a=e.Part.length;a>s;s++){var r=e.Part[s];if(!r.duration)break;if(t.key===r.key)break;n+=r.duration}return n},getPartByAbsoluteOffset:function(t,i){var n;if(t.Part.length>1)for(var s=0,a=0,r=t.Part.length;r>a&&(n=t.Part[a],n.duration)&&(s+=n.duration,!(s>i));a++);else n=e.first(t.Part);return n},getScreenshotIndex:function(t,i){if(t.indexes){var n=t.indexes.split(",");if(n.length)return e.indexOf(n,i)>-1?i:n[0]}},getScreenshotUrl:function(e,t,i){var n=this.getPartByAbsoluteOffset(e,t);
if(i=this.getScreenshotIndex(n,i)){var s=this.getRelativeOffset(e,n,t);return n.key.replace(/[^\/]*$/,"")+"indexes/"+i+"/"+s}},getSeasonIndex:function(e){var t=e.seasonPrefix||"S{1}",i=e.seasonIndex;return i>1e3?i:(e.noLeadingZero||(i=s.leadingZero(i)),n(t,i))},getSeasonEpisodeIndex:function(e){var t=e.seasonPrefix||"S{1}",a=e.episodePrefix||"E{1}",r=e.seasonIndex,o=e.episodeIndex;return o>0&&1e3>r?(e.noLeadingZero||(r=s.leadingZero(r),o=s.leadingZero(o)),n(t,r)+n(a,o)):e.date?i(e.date).format("M/D/YY"):""
},getEpisodeIndex:function(e){var t=e.episodePrefix||"E{1}",a=e.episodeIndex||0;return a>0?(e.noLeadingZero||(a=s.leadingZero(a)),n(t,a)):e.date?i(e.date).format("M/D/YY"):""},isMediaAnalysisRequired:function(t){var i=t?e.first(t.get("Media")):null;return!(!i||i.container)}};return o}),define("plex/base/utils/constants/timelineEvents",[],function(){"use strict";var e={CREATED:0,PROGRESS:1,MATCHING:2,DOWNLOADING_METADATA:3,LOADING_METADATA:4,PROCESSED:5,ANALYZING:6,DELETED:9};return e}),define("plex/base/models/library/OverlayModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";
var n=i.extend({whitelistedAttrs:["key","marginTop","marginRight","marginBottom","marginLeft","width","height","alignHorizontal","alignVertical","relative","imageScaling","marginScaling"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n},parse:function(i){var n=this.convert(i);return n=e.pick(n,this.whitelistedAttrs),t.parseInteger(n,["marginTop","marginRight","marginBottom","marginLeft","width","height"]),n}});return n}),define("plex/base/models/library/OverlayCollection",["plex/base/models/BaseCollection","plex/base/models/library/OverlayModel"],function(e,t){"use strict";
var i=e.extend({model:t});return i}),define("plex/base/models/library/ConcertModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({whitelistedAttrs:["id","tag","venue","city","country","url","at"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n},parse:function(i){var n=this.convert(i);return n=e.pick(n,this.whitelistedAttrs),t.parseInteger(n,["id","at"]),n}});return n}),define("plex/base/models/library/ConcertCollection",["plex/base/models/BaseCollection","plex/base/models/library/ConcertModel"],function(e,t){"use strict";
var i=e.extend({model:t});return i}),define("plex/base/models/library/MetadataModel",["require","underscore","jquery","plex/base/utils/t","plex/base/utils/parser","plex/base/utils/mediaUtil","plex/base/utils/types/mediaTypes","plex/base/utils/types/streamTypes","plex/base/utils/formatters/stringUtil","plex/base/utils/constants/timelineEvents","plex/base/models/BaseModel","plex/base/models/library/OverlayCollection","plex/base/models/library/ConcertCollection"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=d.extend({idAttribute:"ratingKey",defaults:{title:"",titleSort:"",tagline:"",rating:0,summary:"",year:"",studio:"",contentRating:"",originallyAvailableAt:"",originalTitle:"",thumb:"",parentThumb:"",grandparentThumb:"",banner:"",art:"",parentArt:"",grandparentArt:"",primaryExtraKey:""},omittedSaveAttrs:["updatedAt","thumb","banner","art","Media","Location"],tagAttrs:["Collection","Director","Writer","Genre","Country","Label"],subcollections:["Media","Genre","Collection","Field","Writer","Director","Role","Country","Location","Label"],metadataElementNames:["Directory","Video","Track","Photo","Hub"],url:function(){return this.get("key")
},urlRoot:function(){return this.get("key")},firstItemUrl:function(){return this.url()},singleMetadataModel:function(){return this},cacheKey:function(e){e.identifier&&!this.isLibraryItem(e)&&(e=this.normalizeKey(e));var t=this.normalizeChildrenKey(e.key);return this.server&&this.server.getScopedKey(t.key)},preserveCachedAttributes:function(e){return/\/(children|library\/sections\/\d+\/\w+)(\?.*)?$/.test(e)},initialize:function(){this.listenTo(this,"socket:timeline",function(e){e.state===c.PROCESSED?(this.fetch({data:{includeExtras:"1",includeRelated:"1",includeRelatedCount:"5",includeConcerts:"1",includeOnDeck:"1"}}),this.refreshChildren()):e.state===c.DELETED&&this.trigger("destroy",this,this.collection)
})},convert:function(e){t.isString(e)&&(e=s.replaceXMLElementNames(e,this.metadataElementNames,"Metadata"));var i=t.isObject(e)?e:s.parseXML(e);if(!i.ratingKey&&!i.key&&!i.id){var n=i.Metadata||i;n.identifier=i.identifier,n.mediaTagPrefix=i.mediaTagPrefix,n.mediaTagVersion=i.mediaTagVersion,n.allowSync=i.allowSync,n.librarySectionID=i.librarySectionID,n.librarySectionUUID=i.librarySectionUUID,i=n}s.parseBoolean(i,["allowSync","selected"]),s.parseInteger(i,["index","parentIndex","absoluteIndex","duration","viewOffset","viewCount","leafCount","viewedLeafCount","extraType","lastViewedAt","addedAt","updatedAt"]),s.parseFloat(i,["rating","userRating"]),s.parseArray(i,this.subcollections);
var a=i.Media;return t.each(a,function(e){s.parseBoolean(e,["indirect","optimizedForStreaming","premium"]),s.parseInteger(e,["id","duration","width","height","bitrate","audioChannels"]),s.parseArray(e,"Part");var i=e.Part;t.each(i,function(e){s.parseBoolean(e,"optimizedForStreaming"),s.parseInteger(e,["id","duration","size"]),s.parseEncodedString(e,"file"),s.parseArray(e,"Stream"),e.exists="0"!==e.exists,e.accessible="0"!==e.accessible;var i=e.Stream;t.each(i,function(e){s.parseBoolean(e,"selected"),s.parseInteger(e,["id","index","streamType","duration","width","height","bitrate","bitDepth","samplingRate","channels"])
})})}),i},parse:function(i){var s=this.convert(i);if(!s.key)return s;this.isLibraryItem(s)||(s=this.normalize(s)),"photo"===s.type&&/\/children$/.test(s.key)&&(s.type="photoAlbum"),"photoalbum"===s.type&&(s.type="photoAlbum"),s.isFolder=/\/folder\?parent\=/.test(s.key),s.isExtra=!!s.extraType;var r=e("plex/base/models/library/MetadataCollection"),l=e("plex/base/models/library/HubCollection");this.parseChildren(s,r),this.parseExtras(s,r),this.parseRelated(s,l),this.parseOverlays(s),this.parsePopularLeaves(s,r),this.parseConcerts(s,h),this.parseOnDeck(s),null!=s.viewedLeafCount&&(s.unviewedLeafCount=s.leafCount-s.viewedLeafCount);
var c=s.Media,d=o.getStreamTypeByString("subtitles");return t.each(c,function(e){var i=t.first(e.Part);if(i&&i.Stream){var s=i.Stream,r=a.getStreams(e,{streamType:d.id,selected:!0}),o={id:0,streamType:d.id,language:n("None")};r.length||(o.selected=!0),s.unshift(o)}}),t.defaults(s,this.defaults),s},parseChildren:function(e,t){var i=this.normalizeChildrenKey(e.key);if(i.hasChildren&&(e.key=i.key,!this.get("children"))){var n=i.previousKey;"album"===e.type&&(n+=n.indexOf("?")>-1?"&":"?",n+="includeRelated=1");
var s=new t([],{server:this.server,section:this.section,parent:this,url:n});this.set("children",s)}},parsePopularLeaves:function(e,t){if(!e.PopularLeaves)return void this.unset("popularLeaves");var i=this.get("popularLeaves"),n=[],s=!1;e.PopularLeaves.size>0&&(n=e.PopularLeaves,s=!0),i?i.set(n,{parse:s}):(i=new t(n,{server:this.server,section:this.section,parent:this,url:e.PopularLeaves.key,populated:!0,parse:s}),this.set("popularLeaves",i)),delete e.PopularLeaves},parseExtras:function(e,t){if(!e.Extras)return void this.unset("extras");
var i,n,s=this.get("extras");e.Extras.size>0?(i=e.Extras,n=!0):(i=[],n=!1),s?s.set(i,{parse:n}):(s=new t(i,{server:this.server,section:this.section,parent:this,url:e.key+"/extras",populated:!0,parse:n}),this.set("extras",s)),delete e.Extras},parseRelated:function(e,t){if(!e.Related)return void this.unset("related");var i,n,s=this.get("related");e.Related.Metadata?(i=e.Related,n=!0):(i=[],n=!1),s?s.reset(i,{parse:n}):(s=new t(i,{server:this.server,section:this.section,parent:this,populated:!0,parse:n}),this.set("related",s)),delete e.Related
},parseOverlays:function(e){if(!e.Overlay)return void this.unset("overlays");var i=this.get("overlays"),n=t.isArray(e.Overlay)?e.Overlay:[e.Overlay],s=!0;i?i.reset(n,{parse:s}):(i=new u(n,{server:this.server,section:this.section,parent:this,populated:!0,parse:s}),this.set("overlays",i)),delete e.Overlay},parseConcerts:function(e){if(!e.Concert)return void this.unset("concerts");var i=this.get("concerts"),n=t.isArray(e.Concert)?e.Concert:[e.Concert],s=!0;i?i.reset(n,{parse:s}):(i=new h(n,{server:this.server,section:this.section,parent:this,populated:!0,parse:s}),this.set("concerts",i)),delete e.Concert
},parseOnDeck:function(e){if(!e.OnDeck)return void this.unset("onDeck");var t=this.get("onDeck"),i=!0,n=e.OnDeck.Metadata;t?t.set(n,{parse:i}):(t=new p(n,{server:this.server,section:this.section,parse:i}),this.set("onDeck",t)),delete e.OnDeck},normalize:function(e){return e=this.normalizeKey(e),e=this.normalizeType(e),e=this.normalizeMetadata(e)},normalizeChildrenKey:function(e){var t=/(.*)\/children$/.exec(e),i=e;return t&&(e=t[1]),{key:e,previousKey:i,hasChildren:!!t}},normalizeKey:function(e){var t=e.key.split("/");
return 1===t.length&&e.containerKey&&(e.hasInvalidKey=!0,e.originalKey=e.key,e.key=e.containerKey+"/"+e.key),e.ratingKey||(e.ratingKey=e.originalKey||e.key),e},normalizeType:function(e){return e.mediaType&&!e.type&&(e.type=e.mediaType,delete e.mediaType),e.elementName&&!e.type&&(e.type=e.elementName.toLowerCase()),/image/i.test(e.type)?e.type="photo":/(movie|episode|video)/i.test(e.type)&&(e.type="clip"),r.getMediaTypeByString(e.type)||(e.type="channelDirectory"),e},normalizeMetadata:function(e){return e.label?(e.title=e.label,delete e.label):e.artist&&(e.track?(e.title=e.track,e.originalTitle=e.artist,e.parentTitle=e.album,e.grandparentTitle=e.albumArtist):e.album?(e.title=e.album,e.parentTitle=e.artist):e.title=e.artist,delete e.track,delete e.album,delete e.albumArtist,delete e.artist),e.totalTime&&(e.duration=e.totalTime,delete e.totalTime),e
},refreshChildren:function(){var e=this.get("children");if(e&&e.populatePromise){var t=e.fetch();t.always(function(){e.invoke("refreshChildren")})}},resolveIndirect:function(e,n){var s=i.Deferred();if(!e||!n)return s.reject(this).promise();if(!e.indirect)return s.resolve(this).promise();if(n.postURL)return this.resolvePostUrl(e,n);var a=n.key;this.server.get("cloud")&&(a=this.server.resolveUrl(n.key,{connection:{address:"node.plexapp.com",port:32400}}));var r=i.ajax(this.server.getXHROptions(a));
return r.done(t.bind(function(t){this.mergeIndirectResponse(t,e,n)?s.resolve(this):s.reject(this)},this)),r.fail(t.bind(function(){s.reject(this)},this)),s.promise()},resolvePostUrl:function(e,n){var s=i.Deferred(),a=this.server.get("cloud")||this.server.get("synced"),r=a?this.server.parent.get("primaryServer"):this.server;if(!r)return s.reject(this).promise();var o=r.getXHROptions("/system/proxy");o.headers=o.headers||{},o.headers["X-Plex-Url"]=n.postURL;var l=i.ajax(o);return l=l.then(t.bind(function(e,t,s){var a=n.key+"&postURL="+encodeURIComponent(n.postURL),r=s.getAllResponseHeaders()+"\r\n"+e;
this.server.get("cloud")&&(a=this.server.resolveUrl(a,{connection:{address:"node.plexapp.com",port:32400}}));var o=this.server.getXHROptions(a);return o.type="POST",o.data=r,i.ajax(o)},this)),l.done(t.bind(function(t){this.mergeIndirectResponse(t,e,n)?s.resolve(this):s.reject(this)},this)),l.fail(t.bind(function(){s.reject(this)},this)),s.promise()},mergeIndirectResponse:function(e,i,n){var a=s.parseXML(e);if(!(a&&a.Video&&a.Video.Media&&a.Video.Media.Part))return!1;var r=this.parse(a.Video),o=t.first(r.Media),l=t.first(o.Part);
if(o.Part.length>1){var c=t.indexOf(i.Part,n);c<o.Part.length&&(l=o.Part[c])}if(!o||!l)return!1;if(o.indirect=!1,t.extend(i,t.omit(o,"Part")),t.extend(n,l),a.httpHeaders){for(var d,u=new RegExp("([^=]+)=([^&]+)&?","g"),h={};d=u.exec(a.httpHeaders);)d[1]in h?(t.isArray(h[d[1]])||(h[d[1]]=[h[d[1]]]),h[d[1]].push(d[2])):h[d[1]]=d[2];this.set("indirectHttpHeaders",h,{silent:!0})}return!0},getSaveParams:function(e){return t.each(e.Field,function(t){e[t.name+".locked"]=t.locked}),delete e.Field,t.each(this.tagAttrs,function(i){i in e&&(t.isEmpty(e[i])?e[l.lowerCaseFirstLetter(i)+"[]"]="":t.each(e[i],function(t,n){e[l.lowerCaseFirstLetter(i)+"["+n+"].tag.tag"]=t.tag
}),delete e[i])}),e},batchAdd:function(e,n,s){var a=t.pluck(e,"id").join(","),r="/library/metadata/"+a+"/"+n+"/add?tag="+encodeURIComponent(s),o=t.extend(this.server.getXHROptions(r),{type:"PUT"});return i.ajax(o)},getDownloadUrl:function(){var e=t.first(this.get("Media"));if(e){var i=t.first(e.Part);if(i&&i.key)return this.server.resolveUrl(i.key,{appendToken:!0})}return""},getFilepath:function(){var e=t.first(this.get("Media"));if(e){var i=t.first(e.Part);if(i)return i.file}return null},getLocation:function(){var e=t.first(this.get("Location"));
return e?e.path:this.getFilepath()},getMediaKey:function(){var e=t.first(this.get("Media")),i=this.get("key");if(e){var n=t.first(e.Part);if(n)return n.key}return i},isLibraryItem:function(e){var t=e?e.identifier:this.get("identifier");if(t)return"com.plexapp.plugins.library"===t;var i=e?e.key:this.get("key");return/^(\/sync\/[A-Za-z0-9-\/]*)?\/library\//.test(i)},isPlexMusicItem:function(){var e=this.section;return e&&"com.plexapp.agents.plexmusic"===e.get("agent")}});return p}),define("plex/base/models/library/MetadataCollection",["underscore","plex/base/utils/parser","plex/base/mixins/models/paginationMixin","plex/base/models/BaseCollection","plex/base/models/library/MetadataModel"],function(e,t,i,n,s){"use strict";
var a=n.extend({mixins:i,model:s,metadataElementNames:["Directory","Video","Track","Photo","Hub"],collectionProperties:["key","totalSize","viewGroup","allowSync","title","grandparentTitle","art"],url:function(){var t=this.section||this.parent;return t?e.result(t,"url"):""},initialize:function(e,t){t||(t={}),this.allowAllLeaves=t.allowAllLeaves,this.populatedRange={start:0,end:0}},parse:function(i){var n=this.convert(this.mergeElements(i));null==n.totalSize&&(n.totalSize=n.size),t.parseInteger(n,"totalSize"),t.parseBoolean(n,"allowSync"),t.parseArray(n,"Metadata"),e.each(this.collectionProperties,function(e){var t=this[e],i=n[e],s=this.section?this.section.get("currentSubset").id:null,a=s&&"all"!==s&&"folder"!==s;
a&&"totalSize"===e&&i>200&&(i=200),"totalSize"===e&&this.totalSizeAdjustment&&(i+=this.totalSizeAdjustment),void 0!==i&&t!==i&&(this[e]=i,this.trigger("change:"+e,this,i))},this);var s=n.Metadata,a=e.result(this,"url");return e.each(s,function(e){e.containerKey=a,n.identifier&&(e.identifier=n.identifier),n.mediaTagPrefix&&(e.mediaTagPrefix=n.mediaTagPrefix),n.mediaTagVersion&&(e.mediaTagVersion=n.mediaTagVersion)}),this.allowAllLeaves?s:e.reject(s,function(e){var t=/\/allLeaves$/.test(e.key);return t&&this.totalSize&&(this.totalSize-=1,this.totalSizeAdjustment||(this.totalSizeAdjustment=0),this.totalSizeAdjustment-=1),t
},this)},mergeElements:function(i){if(e.isString(i))i=t.replaceXMLElementNames(i,this.metadataElementNames,"Metadata");else if(e.isObject(i)&&!i.Metadata){var n=e.compact(e.pick(i,this.metadataElementNames));i.Metadata=e.flatten(n,!0)}return i},remove:function(){n.prototype.remove.apply(this,arguments),i.remove.apply(this,arguments)},clear:function(){this.totalSize=null,this.trigger("change:totalSize",this,null),delete this.totalSizeAdjustment,this.populatedRange={start:0,end:0},n.prototype.clear.apply(this,arguments)
},splitByType:function(){var e={};return this.each(function(t){var i=t.get("type");e.hasOwnProperty(i)?e[i].push(t):e[i]=[t]}),e},filterByType:function(e){var t=this.filter(function(t){return t.get("type")===e});return this.clone(t)}});return a}),define("plex/base/models/library/SectionMetadataCollection",["underscore","plex/base/utils/types/mediaTypes","plex/base/models/library/MetadataCollection","plex/base/models/library/section/MediaTypeModel"],function(e,t,i,n){"use strict";var s=i.extend({pageStart:0,pageSize:0,url:function(){var t=this.section.get("currentFolderKey");
if(t)return t;var i=e.result(this.section,"url"),n=this.section.get("currentSubset"),s=n.id;if(!this.section.get("allowAdvancedFilters")){var a=this.section.get("currentFilters");return a.length?a[0].values[0]:i+"/"+s}("recentlyAdded"===s||"newest"===s)&&(s="all");var r=i+"/"+s,o=this.getUrlParams();return o.length&&(r+=r.indexOf("?")>-1?"&":"?",r+=o),r},initialize:function(){i.prototype.initialize.apply(this,arguments),this.server.get("synced")&&(this.pageStart=null,this.pageSize=null)},clear:function(){this.server.get("synced")?(this.pageStart=null,this.pageSize=null):(this.pageStart=0,this.pageSize=0),i.prototype.clear.apply(this,arguments)
},getUrlParams:function(){var e=this.getFilterUrlParams({sendType:!0});return this.section.get("refreshing")&&this.server.supports("timelineState")&&e.push("timelineState=1"),e.length?e.join("&"):""},getFilterUrlParams:function(i){i||(i={});var n={},s=[],a=this.getMediaType().id;i.sendType&&a&&a!==t.getMediaTypeByString("photo").id&&(n.type=a);var r=this.section.get("currentFilters");e.each(r,function(e){e.values.length&&(n[e.key]=e.values.join(","))});var o=this.getSort();o&&(n.sort=o);for(var l in n)s.push("unviewedLeafCount"===l?l+">="+n[l]:l+"="+n[l]);
return s},getMediaType:function(){var e=this.section.get("currentType"),i=this.section.get("currentSubset");if(e||(e=t.getMediaTypeByString(this.section.get("type")),this.section.set("currentType",new n(e))),/^(onDeck|recentlyAdded|recentlyViewed|newest)$/.test(i.id)){if(e.id===t.getMediaTypeByString("show").id)return t.getMediaTypeByString("episode");if(e.id===t.getMediaTypeByString("artist").id)return t.getMediaTypeByString("album")}return this.parent&&"season"===this.parent.get("type")?t.getMediaTypeByString("episode"):e
},getSort:function(){var e=this.section.get("currentSort"),t=this.section.get("currentSubset").id;return"recentlyAdded"===t?"addedAt:desc":"newest"===t?"originallyAvailableAt:desc":e?e.id+":"+e.get("direction"):!1}});return s}),define("plex/base/models/library/section/SectionModel",["underscore","plex/base/utils/parser","plex/base/utils/types/sectionTypes","plex/base/utils/types/subsetTypes","plex/base/models/BaseModel","plex/base/models/library/section/SectionSubsetModel","plex/base/models/library/section/SectionSubsetCollection","plex/base/models/library/section/MediaTypeCollection","plex/base/models/library/section/FilterCollection","plex/base/models/library/section/LinearFilterCollection","plex/base/models/library/section/SortCollection","plex/base/models/library/section/AlphanumericCollection","plex/base/models/library/SectionMetadataCollection"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=s.extend({idAttribute:"key",persistInCache:!0,defaults:function(){return{isSection:!0,currentType:null,currentFilters:[],currentSort:null,currentFirstCharacter:null,currentFolderKey:null}},url:function(){if(this.isNew())return e.result(this,"urlRoot")||e.result(this.collection,"url");var t=e.isNaN(parseInt(this.id,10)),i=t?this.id:"/library/sections/"+this.id;return i},whitelistedAttrs:["key","uuid","title","type","thumb","art","language","agent","scanner","createdAt","updatedAt","allowAdvancedFilters","refreshing","Location"],whitelistedSaveAttrs:["name","title","type","agent","scanner","language","importFromiTunes","Location"],cacheKey:function(e){return this.server&&this.server.getScopedKey(e.key)
},initialize:function(){var t={server:this.server,section:this},i=this.get("allowAdvancedFilters")?l:c;this.set("currentSubset",new a(n.getSubsetType("all"),t)),this.set("subsets",new r([],t)),this.set("types",new o([],t)),this.set("filters",new i([],t)),this.set("sorts",new d([],t)),this.set("alphanumeric",new u([],t));var s=new h([],t);s.on("change:allowSync",e.bind(function(e,t){this.set("allowSync",t)},this)),this.set("items",s)},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseBoolean(n,["filters","refreshing"]),t.parseInteger(n,["createdAt","updatedAt"]),t.parseArray(n,"Location"),n
},parse:function(t){var i=this.convert(t);return i.allowAdvancedFilters=i.filters,i=e.pick(i,this.whitelistedAttrs)},changedAttributes:function(){var t=s.prototype.changedAttributes.apply(this,arguments);return t&&(t=e.pick(t,this.whitelistedSaveAttrs)),t},getSectionType:function(){var e=this.get("type");return i.getSectionType(e)||i.getSectionTypeByString(e)},getSaveParams:function(){var t=s.prototype.getSaveParams.apply(this,arguments);if(t=e.pick(t,this.whitelistedSaveAttrs),"type"in t){var n=i.getSectionType(t.type)||i.getSectionTypeByString(t.type);
n&&(t.type=n.typeString)}return"title"in t&&(t.name=t.title,delete t.title),e.isObject(t.type)&&(t.type=t.type.typeString),"Location"in t&&(t.location=e.map(t.Location,function(e){return e.path}),delete t.Location),t},getSyncTitle:function(t){var i=this.get("title"),n=[],s=this.get("currentSubset"),a=this.get("currentFilters");return t?(e.each(t,function(e){n.push(e.get("title"))}),n=n.join(", "),i+": "+n):"all"!==s.id?i+": "+s.get("title"):a.length?(e.each(a,function(e){n.push(e.titles.join(", "))
}),i+": "+n.join(",")):i},setAgentAndScanner:function(e,t,i,n){var s=e.defaultAgent,a=e.defaultScanner;if(n){var r=e.exclusiveAgents,o=e.exclusiveScanners,l=t.hasExclusiveAgent(r),c=i.hasExclusiveScanner(o);l&&(s=r[0]),c&&(a=o[0])}this.set({agent:s,scanner:a})}});return p}),define("plex/base/mixins/serverMixin",["underscore","plex/base/adapters/dimensionsAdapter","plex/base/adapters/settingsAdapter","plex/base/models/library/section/SectionModel","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";
function a(e){if(e.section)return e.section;if(e.get("isSection"))return e;var t=e.get("librarySectionID");if(t){var i=new n({key:e.get("librarySectionID")},{server:e.server,onlyIfCached:!0});return i}return e.parent?a(e.parent):void 0}var r={idAttribute:"machineIdentifier",defaults:function(){return{friendlyName:"Unknown",cloud:!1,bundled:!1,relayed:!1,home:!1,shared:!1,synced:!1,isCloudSync:!1,protocolCapabilities:[],sources:[]}},whitelistedAttrs:["machineIdentifier","name","friendlyName","home","sourceTitle","accessToken","superToken","version","createdAt","updatedAt","protocol","protocolCapabilities","platform","platformVersion","startState","serverClass","synced","sync","multiuser","allowMediaDeletion","transcoderActiveVideoSessions","transcoderAudio","transcoderVideo","transcoderVideoRemuxOnly","flashInstalled","silverlightInstalled","soundflowerInstalled","myPlex","myPlexMappingState","myPlexSigninState","myPlexSubscription","myPlexUsername","product","presence"],features:{splitApart:"0.9.7.0",merge:"0.9.7.0",search:"0.9.7.0",advancedFilters:"0.9.7.0",cleanBundles:"0.9.7.0",timelineState:"0.9.7.2",firstRunPref:"0.9.7.3",artworkUpload:"0.9.7.9",sync:"0.9.7.10",universalTranscoder:"0.9.7.17",universalMusicTranscoder:"0.9.8.3",syncNotifications:"0.9.7.23",sharedSettings:"0.9.7.23",specificMediaDeletion:"0.9.7.23",dash:"0.9.8.6",chunkedHTTP:"0.9.9.3",streamingMKV:"0.9.9.16",hubFilters:"0.9.9.2",sectionSettings:"0.9.9.6",playQueues:"0.9.9.6",cancelAllUpdates:"0.9.9.10",hubFilterSigns:"0.9.9.12",imageFilters:"0.9.9.13",playlists:"0.9.9.13",playItemsBatchAdd:"0.9.9.16",updater:"0.9.11.1",labels:"0.9.11.2",publicNowPlaying:"0.9.11.3",photoPlayQueues:"0.9.11.12",reachability:"0.9.11.14",softSubtitles:"0.9.12.0",transientToken:"0.9.12.0",premiumMusic:"0.9.12.0",batchEdit:"0.9.12.0",compositeDelete:"0.9.12.0",audioAsVideo:"0.9.12.0",companionProxy:"0.9.12.3"},cacheKey:function(e){return e.machineIdentifier
},url:function(e){e||(e=this.get("activeConnection"));var t=e.uri;if(!t){var i=e.scheme||"http",n=e.address,s=e.port;t=i+"://"+n,s&&(t+=":"+s)}return/\/$/.test(t)||(t+="/"),t},useHostedHttps:"https:"===window.location.protocol,convert:function(t){var i=e.isObject(t)?t:s.parseXML(t);return s.parseInteger(i,["createdAt","updatedAt","transcoderActiveVideoSessions"]),s.parseBoolean(i,["home","synced","sync","multiuser","allowMediaDeletion","transcoderAudio","transcoderVideo","transcoderVideoRemuxOnly","flashInstalled","silverlightInstalled","soundflowerInstalled","myPlex","myPlexSubscription"]),i&&"undefined"==typeof i.startState&&(i.startState=null),i
},parse:function(t){var i=this.convert(t);if(!i||!i.machineIdentifier)return null;var n=i.scheme,s=i.address,a=parseInt(i.port,10),r=i.localAddresses;i=e.pick(i,this.whitelistedAttrs),!this.get("shared")||i.sourceTitle||i.home?i.sourceTitle&&!i.home?i.friendlyName=i.sourceTitle:i.friendlyName||(i.friendlyName=i.name):delete i.friendlyName,i.sourceTitle&&(i.shared=!0),i.fullVersion=i.version;var o=/(\d+\.){2,3}\d+/.exec(i.version);return o&&(i.version=o[0]),i.protocolCapabilities&&(i.protocolCapabilities=i.protocolCapabilities.split(",")),"secondary"===i.serverClass&&(i.synced=!0),"cloudsync"===i.platform&&(i.isCloudSync=!0),i.accessToken&&this.set("accessToken",i.accessToken),s&&a&&this.addConnection({scheme:n,address:s,port:a,accessToken:i.accessToken}),r&&(r=r.split(","),e.each(r,function(e){this.addConnection({address:e,port:32400,accessToken:i.accessToken})
},this)),i},resolveUrl:function(e,t){if(t||(t={}),/^\w+:\/\//.test(e))return e;var i=this.get("accessToken"),n=t.useLoopback?"http://127.0.0.1:32400/":this.url(t.connection);return e&&(n+="/"===e[0]?e.substr(1):e),t.appendToken&&i?(n+=n.indexOf("?")>0?"&":"?",n+="X-Plex-Token="+i):n},getXHROptions:function(e){var t={};return t.url=this.resolveUrl(e),t.dataType="text",t.headers=this.getHeaders(),t},getHeaders:function(){var n=t.getInstance(),s=e.clone(n),a=this.parent;if(a){var r=a.get("user");r&&r.get("username")&&(s["X-Plex-Username"]=r.get("username"))
}var o=this.get("accessToken");return o&&(s["X-Plex-Token"]=o),s["Accept-Language"]=i.get("language"),s},isLocalAddress:function(e){return this.isLoopbackAddress(e)||/(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)/.test(e)},isLoopbackAddress:function(e){return/^(127(\.\d+){1,3}|[0:]+1|localhost|0\.0\.0\.0)$/.test(e)},isPlexDirectAddress:function(e){return/plex\.direct$/.test(e)},hasLocalConnection:function(){var e=this.get("activeConnection");return e?e.isLocalAddress:null
},hasLoopbackConnection:function(){var e=this.get("activeConnection");return e?e.isLoopbackAddress:null},isSecure:function(e){return"https"===e},getSectionForItem:a,supports:function(e){var t=this.features[e];return t?this.isVersionOrNewer(t):!1},isVersionOrNewer:function(e){var t=this.get("version");if(e&&t){e=e.split("."),t=t.split(".");for(var i=0,n=e.length;n>i;i++)if(i<t.length){var s=parseInt(e[i],10),a=parseInt(t[i],10);if(a>s)return!0;if(s>a)return!1}return!0}return!0},getIpAddressFromPlexDirectAddress:function(e){if(this.isPlexDirectAddress(e)){var t=e.indexOf(".");
t>0&&(e=e.substring(0,t),e=e.replace(/\-/g,"."))}return e},getAddressFromUri:function(e){var t=document.createElement("a");return t.href=e,t.hostname}};return r}),define("plex/base/models/library/section/SectionCollection",["plex/base/models/BaseCollection","plex/base/models/library/section/SectionModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/library/sections",parse:function(e){return this.convert(e,"Directory")}});return i}),define("plex/base/models/library/PlayQueueItemModel",["underscore","plex/base/models/library/MetadataModel"],function(e,t){"use strict";
var i=t.extend({idAttribute:"playQueueItemID",propagatedAttributes:["viewOffset","viewCount"],cacheKey:function(e){return this.server&&this.server.getScopedKey(e.playQueueItemID)},initialize:function(){t.prototype.initialize.apply(this,arguments),this.listenTo(this,"change",function(){var i=this.changedAttributes(),n=e.intersection(e.keys(i),this.propagatedAttributes);e.each(n,function(i){var n=new t({key:this.get("key")},{server:this.server,onlyIfCached:!0});e.isEmpty(n)||n.set(i,this.get(i))},this)
})}});return i}),define("plex/base/models/library/PlayQueueItemCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/PlayQueueItemModel"],function(e,t,i){"use strict";var n=t.extend({model:i,parse:function(i){return e.extend(this,e.pick(i,["totalSize","availableRange"])),t.prototype.parse.apply(this,arguments)}});return n}),define("plex/base/models/library/LocalPlayQueueModel",["underscore","jquery","backbone","plex/base/models/BaseModel","plex/base/utils/types/mediaTypes","plex/base/models/library/PlayQueueItemCollection","plex/base/models/library/PlayQueueItemModel"],function(e,t,i,n,s,a,r){"use strict";
var o=function(e){return e instanceof i.Collection?e:e.get("children")},l=function(e){var t=e.get("type"),i="channelDirectory"===t,n=i||t&&"directory"===s.getMediaTypeByString(t).element||e.get("isFolder"),a=void 0===e.length;return a&&!n},c=function(t){var i=this.get("nextPlayQueueItemID");this.set("nextPlayQueueItemID",++i);var n=e.extend({},t.attributes,{playQueueItemID:i}),s=new r(n,{server:t.server,parent:t.parent});return s},d=n.extend({defaults:{selectedItem:null,mediaType:null,collection:null,owned:!0,lastAddedItem:null,hasUserAdditions:!1,nextPlayQueueItemID:0},url:"",initialize:function(e){this.set("mediaType",e.mediaType),this.set("collection",new a([],{type:e.mediaType,server:e.server}))
},fetch:function(){},queueContent:function(i,n,s){s||(s={});var a=t.Deferred().resolve().promise();return this.isItemQueueable(i)&&(i.get("children")&&e.result(i.get("children"),"url")&&(a=a.then(function(){return i.get("children").populate()})),a=a.done(e.bind(function(){this.set("lastAddedItem",i),this.get("collection").length&&this.set("hasUserAdditions",!0);var t=this.get("collection").indexOf(n);-1===t&&(t=0);var a=s.next?{at:t+1}:{},r=o(i);if(r){var d=r.filter(l);s.shuffle&&(d=e(d).shuffle());
var u=e.map(d,e.bind(c,this));this.get("collection").add(u,a)}else this.get("collection").add(c.apply(this,[i]),a);this.get("collection").trigger("reset",this.get("collection"))},this))),a},addContent:function(t,i){var n=this.queueContent(t,this.get("selectedItem"),i);return n.done(e.bind(function(){var e=null;i&&i.firstItem?e=this.get("collection").find(function(e){return e.get("key")===i.firstItem.get("key")}):this.get("collection").length&&(e=this.get("collection").at(0)),this.set("selectedItem",e)
},this)),n},removeItem:function(e){return e.get("playQueueItemID")===this.get("selectedItem").get("playQueueItemID")?t.Deferred().resolve().promise():(this.set("hasUserAdditions",!0),this.get("collection").remove(e),this.get("collection").trigger("reset",this.get("collection")),t.Deferred().resolve().promise())},moveItem:function(e,i){if(e===this.get("selectedItem").get("playQueueItemID"))return t.Deferred().resolve().promise();var n=this.get("collection"),s=n.findWhere({playQueueItemID:e});n.remove(s);
var a=i||this.get("selectedItem").get("playQueueItemID"),r=n.findWhere({playQueueItemID:a}),o=n.indexOf(r)+1;return this.set("hasUserAdditions",!0),n.add(s,{at:o}),n.trigger("reset",n),t.Deferred().resolve().promise()},isItemQueueable:function(t){if(t.get("currentSubset")&&"photo"!==t.viewGroup)return!1;if("photoAlbum"===t.get("type")&&!t.isLibraryItem())return!1;var i=["track","episode","movie","photo","clip","userPlaylistItem","photoAlbum","album","season"],n=e(i).contains(t.get("type")),s=o(t),a=s&&s.any(l);
return n||a},yieldOwnership:function(){var i=this.get("lastAddedItem"),n=e.result(i.get("children")||i,"url");return t.Deferred().resolve(n).promise()},takeOwnership:function(){return t.Deferred().resolve().promise()},release:function(){this.get("collection").release()},supports:function(e){return!(e&&(e.unwatched||e.remoteRefresh))}});return d}),define("plex/base/models/library/HubModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/library/MetadataCollection"],function(e,t,i,n){"use strict";
var s=i.extend({idAttribute:"hubIdentifier",whitelistedAttrs:["key","hubIdentifier","title","type","size","more","browse"],url:function(){return this.get("key")},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseInteger(n,"size"),t.parseBoolean(n,["more","browse"]),n},parse:function(t){var i=this.convert(t),s=this.get("children");return s||(s=new n([],{server:this.server,section:this.section,parent:this,url:i.key}),this.set("children",s)),s.set(t,{parse:!0}),i=e.pick(i,this.whitelistedAttrs)
}});return s}),define("plex/base/utils/contentUtil",["underscore","jquery","backbone","plex/base/utils/types/mediaTypes","plex/base/models/library/HubModel"],function(e,t,i,n,s){"use strict";var a={_resolveURI:function(t){var i=t.parts,n=e.map(i,function(e){return e?encodeURIComponent(e):""});return t.prefix+"://"+n.join("/")},_getSectionInfo:function(t){var i=t.get("librarySectionUUID"),n=t.get("librarySectionID");if(!i||!n){var s=t.server.getSectionForItem(t);e.isEmpty(s)||(i=s.get("uuid"),n=s.id)
}return{sectionUUID:i,sectionID:n}},uri:function(t,i){var n=i&&i.items;if(n&&n.length){if(n.length>1)return this.getBatchLibraryMetadataURI(n,i);t=e.first(n)}return t.get("isSection")?this.getSectionURI(t,i):this.getLibraryMetadataURI(t,i)},getSectionURI:function(t){var i=e.result(t,"url"),s=t.get("items").getFilterUrlParams().slice(0),a=t.get("currentType"),r=t.get("currentSubset"),o=s.indexOf("unwatchedLeaves=1");if(o>-1){var l=n.getChildMediaType(t.get("type")).typeString;s.splice(o,1,l+".unwatched=1")
}s.push("sourceType="+a.id);var c=i+"/"+r.id+"?"+s.join("&");return this._resolveURI({prefix:"library",parts:[t.get("uuid"),"directory",c]})},getBatchLibraryMetadataURI:function(t){var i=this._getSectionInfo(e.first(t)),n=e.map(t,function(e){return e.get("ratingKey")}),s="/library/metadata/"+n.join(",");return this._resolveURI({prefix:"library",parts:[i.sectionUUID,"directory",s]})},getLibraryMetadataURI:function(t,n){n||(n={});var a;e.isArray(t)&&(a=t,t=e.first(t));var r,o=this._getSectionInfo(t),l=e.result(t,"url");
if(n.excludeSeedItem&&(l+=l.indexOf("?")>-1?"&":"?",l+="excludeSeedItem=1"),r=t instanceof i.Collection||t instanceof s?"directory":"item",a){var c=e.map(a,function(e){return e.get("ratingKey")});r="directory",l="/library/metadata/"+c.join(",")}return this._resolveURI({prefix:"library",parts:[o.sectionUUID,r,l]})}};return a}),define("plex/base/models/library/PlayQueueModel",["underscore","jquery","plex/base/models/BaseModel","plex/base/utils/dispatcher","plex/base/utils/contentUtil","plex/base/utils/parser","plex/base/models/library/PlayQueueItemCollection"],function(e,t,i,n,s,a,r){"use strict";
var o={audio:"Track",photo:"Photo",video:"Video"},l=i.extend({idAttribute:"playQueueID",defaults:{selectedItem:null,mediaType:null,collection:null,server:null,owned:!0,allowedElement:null,hasUserAdditions:!1,playQueueID:null,playQueueVersion:0,playQueueSelectedItemID:null,message:null},url:function(){return"/playQueues/"+this.get("playQueueID")},initialize:function(e,t){this.set("server",t.server),this.set("allowedElement",o[this.get("mediaType")]),this.set("collection",new r([],{server:t.server}))
},_fetch:function(){var t=e.result(this,"url");return this._ajax("GET",t)},convert:function(t){var i=e.isObject(t)?t:a.parseXML(t);return a.parseInteger(i,"playQueueVersion"),a.parseArray(i,this.get("allowedElement")),i},parse:function(t){t=a.replaceXMLElementNames(t,["Directory"],"Metadata");var i=this.convert(t),n=["playQueueSelectedItemID","playQueueSelectedItemOffset","message"];i.playQueueVersion>this.get("playQueueVersion")&&n.push("playQueueID","playQueueVersion"),this.set(e.pick(i,n));var s=i[this.get("allowedElement")],r=e(s).pluck("playQueueItemID").indexOf(i.playQueueSelectedItemID),o=parseInt(i.playQueueSelectedItemOffset,10),l=o-r;
return e.each(s,function(e,t){e.queueIndex=l+t,i.identifier&&(e.identifier=i.identifier),i.mediaTagPrefix&&(e.mediaTagPrefix=i.mediaTagPrefix),i.mediaTagVersion&&(e.mediaTagVersion=i.mediaTagVersion)}),s.message=i.message,s.totalSize=parseInt(i.playQueueTotalCount,10),s.availableRange={start:l,end:l+s.length},s},_ajax:function(i,s){"audio"===this.get("mediaType")&&(s+=-1===s.indexOf("?")?"?":"&",s+="includeRelated=1");var a=e.extend(this.get("server").getXHROptions(s),{type:i}),r=t.ajax(a),o=e.bind(function(e){var t=this.parse(e);
t.message&&n.trigger("show:alert",{type:"error",message:t.message}),this.get("collection").reset(t,{parse:!0}),this.set("selectedItem",this.getCurrentItem())},this);return r.done(o,this)},getCurrentItem:function(){var e=this.get("playQueueSelectedItemID");return this.get("collection").findWhere({playQueueItemID:e})||null},queueContent:function(i,n){n||(n={});var a={type:this.get("mediaType")};if(i.get("playlistType"))a.playlistID=i.get("ratingKey");else{var r=e.pick(n,"unwatched","items","excludeSeedItem");
a.uri=s.uri(i,r)}return n.firstItem&&(a.key=n.firstItem.get("key")),n.extrasPrefixCount&&(a.extrasPrefixCount=n.extrasPrefixCount),a.shuffle=n.shuffle?1:0,n.continuous&&"episode"===i.get("type")&&(a.continuous=1),this.get("playQueueID")?(a.next=n.next?1:0,this.set("hasUserAdditions",!0),this._addContentPromise=this._ajax("PUT",this.url()+"?"+t.param(a,!0))):this._addContentPromise=this._ajax("POST","/playQueues?"+t.param(a,!0)),this._addContentPromise},addContent:function(t,i){var n=this.queueContent(t,i);
return n.done(i&&i.firstItem?e.bind(function(){var e=i.firstItem.get("key"),t=this.get("collection").find(function(t){return t.get("key")===e});this.set("selectedItem",t)},this):e.bind(function(){this.set("selectedItem",this.get("collection").at(0))},this))},removeItem:function(e){if(e.get("playQueueItemID")===this.get("selectedItem").get("playQueueItemID"))return t.Deferred().resolve().promise();this.set("hasUserAdditions",!0);var i=this.url()+"/items/"+e.get("playQueueItemID");return this._ajax("DELETE",i)
},moveItem:function(e,i){if(e===this.get("selectedItem").get("playQueueItemID"))return t.Deferred().resolve().promise();var n=i||this.get("selectedItem").get("playQueueItemID");this.set("hasUserAdditions",!0);var s={after:n},a=this.url()+"/items/"+e+"/move?"+t.param(s);return this._ajax("PUT",a)},isItemQueueable:function(t){var i=e(t).result("url"),n=/\/(library|hubs|services\/gracenote)\//.test(i)||t.get("playlistType"),s=-1!==i.indexOf("/sync/"),a=-1!==i.indexOf("/folder"),r=t.get("type")&&("photoAlbum"===t.get("type")||"photo"===t.get("type")),o="photo"===t.viewGroup||r,l=t.server.supports("photoPlayQueues"),c=!1;
return t.get("currentSubset")&&(c="all"!==t.get("currentSubset").id),!(!n||s||a||!l&&o||c)},yieldOwnership:function(){return this.set("owned",!1),this._addContentPromise.then(e.bind(function(){return this.get("collection").length>0?e.result(this,"url")+"?own=1&window=200":null},this))},takeOwnership:function(){if(this.get("owned"))return t.Deferred().resolve().promise();this.set("owned",!0);var i=e.result(this,"url")+"?own=1";return this._ajax("GET",i)},release:function(){this.get("collection").release()
},supports:function(){return!0}});return l}),define("plex/base/models/library/PlayQueueManager",["underscore","plex/base/utils/BaseClass","plex/base/mixins/eventMixin","plex/base/utils/types/mediaTypes","plex/base/models/library/LocalPlayQueueModel","plex/base/models/library/PlayQueueModel"],function(e,t,i,n,s,a){"use strict";var r=t.extend({mixins:i,initialize:function(e){this.server=e.server,this._queues={audio:null,photo:null,video:null},this.canCreateOnLocal=s.prototype.isItemQueueable,this.doesLocalSupport=s.prototype.supports
},createFor:function(e,t){t=t||e;var i;i=t.get("isPlaylist")?t.get("playlistType"):e.get("element")||n.getChildMediaType(t.get("type")).element;var r=null;return this.canCreateOnServer(e)?r=new a({mediaType:i},{server:this.server}):this.canCreateOnLocal(e)&&(r=new s({mediaType:i},{server:this.server})),this._queues[i]=r,this.trigger("change change:playQueue:"+i,r),r},getForType:function(e){return this._queues[e]},createForType:function(e,t){var i=null;return i=t.onServer?new a({mediaType:e},{server:this.server}):new s({mediaType:e}),this._queues[e]=i,this.trigger("change change:playQueue:"+e,i),i
},getFor:function(e){var t=e.get("type");if(!t||"channelDirectory"===t)return null;var i;i=e.get("isPlaylist")?e.get("playlistType"):e.get("element")||n.getChildMediaType(t).element;var s=this._queues[i];return s&&s.isItemQueueable(e)?s:null},get:function(t){return e.findWhere(this._queues,{id:t})},populateQueue:function(e,t){var i=new a({playQueueID:e,mediaType:t},{server:this.server});return this._queues[t]=i,i.populate()},remove:function(e){var t=this._queues[e];t&&(this._queues[e]=null,this.trigger("change remove:playQueue:"+e,t))
},removeAll:function(){e.each(e.keys(this._queues),this.remove,this)},canCreateOnServer:function(e){return this.server.supports("playQueues")&&!this.server.get("synced")&&a.prototype.isItemQueueable(e)},doesServerSupport:function(e){return this.server.supports("playQueues")&&a.prototype.supports(e)},canCreateFor:function(e,t){return this.canCreateOnServer(e)&&this.doesServerSupport(t)||this.canCreateOnLocal(e)&&this.doesLocalSupport(t)}});return r}),define("plex/base/models/library/PlaylistModel",["underscore","jquery","plex/base/utils/contentUtil","plex/base/models/BaseModel","plex/base/models/library/MetadataCollection","plex/base/utils/parser"],function(e,t,i,n,s,a){"use strict";
var r=n.extend({idAttribute:"ratingKey",whitelistedAttrs:["addedAt","composite","duration","key","leafCount","playlistType","ratingKey","smart","summary","title","type"],urlRoot:"/playlists",cacheKey:function(e){return e.key?this.server&&this.server.getScopedKey(e.key):void 0},saveUrl:function(){return"/library/metadata/"+this.id},parse:function(e){var t=this.convert(e);if(t.Playlist&&(t=t.Playlist),a.parseInteger(t,["duration","leafCount","addedAt"]),a.parseBoolean(t,"smart"),!this.get("children")){var i=new s([],{server:this.server,parent:this});
i.url="/playlists/"+t.ratingKey+"/items","audio"===t.playlistType&&(i.url+="?includeRelated=1"),this.set("children",i),i.once("add",function(e){this.set("art",e.get("art"))},this)}return t.isPlaylist=!0,t},moveItem:function(i,n){i=i.toString(),n&&(n=n.toString());var s=e.result(this,"url")+"/items/"+i+"/move";n&&(s+="?"+t.param({after:n},!0));var a=e.extend(this.server.getXHROptions(s),{type:"PUT"}),r=t.ajax(a),o=this.get("children"),l=o.findWhere({playlistItemID:i});o.remove(l);var c=o.findWhere({playlistItemID:n}),d=c?o.indexOf(c)+1:0;
return o.add(l,{at:d}),r},removeItem:function(i){i=i.toString();var n=e.result(this,"url")+"/items/"+i,s=e.extend(this.server.getXHROptions(n),{type:"DELETE"}),a=t.ajax(s);a.then(e.bind(function(e){this.set(this.parse(e))},this));var r=this.get("children"),o=r.findWhere({playlistItemID:i});return r.remove(o),a},addContent:function(n,s){var a=this.isNew()?"POST":"PUT",r=this.url(),o={};this.isNew()?(o.type=this.get("playlistType"),o.title=this.get("title"),o.smart=this.get("smart")?1:0):r+="/items",n.get("playQueueID")?o.playQueueID=n.get("playQueueID"):o.uri=i.uri(n,s),r+="?"+t.param(o,!0);
var l=e.extend(n.server.getXHROptions(r),{type:a}),c=t.ajax(l);return c.then(e.bind(function(e){this.set(this.parse(e))},this)),c.promise()},isLibraryItem:function(){return!0},isPlexMusicItem:function(){return!1}});return r}),define("plex/base/models/library/PlaylistCollection",["plex/base/models/BaseCollection","plex/base/models/library/PlaylistModel"],function(e,t){"use strict";var i=e.extend({model:t,comparator:"titleSort",url:function(){var e,t=this.filterOptions.get("currentSort");e=t?t.id+":"+t.get("direction"):"titleSort:asc";
var i="/playlists/all?type=15&sort="+e,n=this.filterOptions.get("currentType");return n&&(i+="&playlistType="+n),this.filterOptions.get("onlyDumb")&&(i+="&smart=0"),i},initialize:function(e,t){this.filterOptions=t.filterOptions},parse:function(e){return this.convert(e,"Playlist")}});return i}),define("plex/base/models/library/PlaylistsSectionModel",["underscore","plex/base/utils/t","plex/base/models/BaseModel","plex/base/models/library/section/SortCollection","plex/base/models/library/PlaylistCollection"],function(e,t,i,n,s){"use strict";
var a=i.extend({defaults:function(){return{pseudo:!0,currentType:0}},initialize:function(){var i=[{key:"title",title:t("Name"),defaultDirection:"asc"},{key:"viewCount",title:t("Plays")},{key:"lastViewedAt",title:t("Last Played")},{key:"duration",title:t("Duration")},{key:"addedAt",title:t("Date Added")}],a=new n([],{section:this,server:this.server});e.each(i,function(e){a.create(e)}),this.set({items:new s([],{filterOptions:this,server:this.server}),title:t("Playlists"),sorts:a})}});return a}),define("plex/base/models/server/ServerCloudAccountModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";
var n=i.extend({url:"/myplex/account",whitelistedAttrs:["username","mappingState","mappingError","mappingErrorMessage","signInState","publicAddress","publicPort","privateAddress","privatePort","subscriptionActive","subscriptionState"],defaults:{signedIn:!1,remoteAccessState:"",mappingState:"",mappingError:"",mappingErrorMessage:"",signInState:"",publicAddress:"",publicPort:"",privateAddress:"",privatePort:""},isNew:function(){return!this.get("signedIn")},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);
return e.defaults(n,e.result(this,"defaults")),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs),"ok"===i.signInState?i.signedIn=!0:(i.signedIn=!1,i.username=""),i.signedIn&&"mapped"===i.mappingState&&!i.mappingError?i.remoteAccessState="ok":(!i.signedIn||i.mappingError)&&(i.remoteAccessState="unreachable"),i},isWaiting:function(){var e=this.get("remoteAccessState");return"connecting"===e||"disconnecting"===e}});return n}),define("plex/base/models/server/ServerUpdateModel",["underscore","jquery","plex/base/utils/dispatcher","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i,n,s){"use strict";
var a=s.extend({url:"/updater/status",whitelistedAttrs:["status","canInstall","downloadURL","state","progress","version","error","added","fixed"],defaults:{state:"none",progress:0,version:"",error:"",added:"",fixed:"",shouldInstall:!1},fetch:function(){return this.server.supports("updater")?s.prototype.fetch.apply(this,arguments):t.Deferred().reject().promise()},convert:function(t){var i=e.isObject(t)?t:n.parseXML(t);return n.parseBoolean(i,"canInstall"),n.parseInteger(i,"status"),n.parseInteger(i.Release,"progress"),i
},parse:function(t){var i=this.convert(t);return i=e.extend(i,i.Release),i=e.pick(i,this.whitelistedAttrs),0!==i.status&&(i.state="error"),i}});return a}),define("plex/base/models/server/ServerSettingModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"id",url:"/:/prefs",defaults:{type:"string",summary:"",label:"",group:""},whitelistedAttrs:["id","label","default","summary","value","type","group","advanced","option","hidden","enumValues","values"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);
return"bool"===n.type?t.parseBoolean(n,"value"):"int"===n.type&&t.parseInteger(n,"value"),t.parseBoolean(n,["advanced","hidden"]),n},parse:function(t){var i=this.convert(t);if(i=e.pick(i,this.whitelistedAttrs),i.enumValues&&!e.isArray(i.enumValues)&&(i.enumValues=e.map(i.enumValues.split("|"),function(e){var t=e.indexOf(":");return t>0?{label:e.slice(t+1),value:e.slice(0,t)}:{label:e,value:e}})),"enum"===i.type&&i.values&&!e.isArray(i.values)){var n=0;i.enumValues=e.map(i.values.split("|"),function(e){return{label:e,value:n++}
})}return i},getSaveParams:function(t){if(e.has(t,"FriendlyName")&&this.server.set("friendlyName",t.FriendlyName),e.has(t,"allowMediaDeletion")&&this.server.set("allowMediaDeletion","1"==t.allowMediaDeletion),e.isEmpty(t)){var i={};return i[this.get("id")]=this.get("value"),i}return"value"in t&&(t[this.get("id")]=t.value,delete t.value),t}});return n}),define("plex/base/models/server/ServerSettingCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/server/ServerSettingModel"],function(e,t,i){"use strict";
var n=t.extend({model:i,url:"/:/prefs",initialize:function(){this.server.on("socket:setting",function(e){var t=this.get(e.id);t&&(e=t.parse(e),t.set("value",e.value),"FriendlyName"===e.id&&e.value?this.server.set("friendlyName",e.value):"allowMediaDeletion"===e.id&&this.server.set("allowMediaDeletion",e.value))},this)},parse:function(t){var i=this.convert(t,"Setting");return e.filter(i,function(e){return e.id})}});return n}),define("plex/base/models/PaginatedCollection",["plex/base/models/BaseCollection"],function(e){"use strict";
var t=e.extend({pageSize:10,pages:function(){return Math.max(Math.ceil(this.length/this.pageSize),1)},page:function(e,t){t||(t={});var i,n=0;return i=t.reverse?this.length-e*this.pageSize:e*this.pageSize-this.pageSize,0>i&&(n=i,i=0),this.models.slice(i,i+this.pageSize+n)}});return t}),define("plex/base/models/server/ServerAlertModel",["plex/base/models/BaseModel"],function(e){"use strict";var t=0,i=e.extend({idAttribute:"id",parse:function(e){var i=e;return i.time=new Date,i.id="evt"+t++,"preference"==i._type&&(i.value=i.value.toString()),i
}});return i}),define("plex/base/models/server/ServerAlertCollection",["underscore","plex/base/models/PaginatedCollection","plex/base/models/server/ServerAlertModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:"/servers",pageSize:20,limit:1e3,initialize:function(){this.startTime=new Date,this.listenTo(this.server,"socket:setting",this.onSettingChange),this.listenTo(this.server,"socket:timeline",this.onTimeline),this.listenTo(this.server,"socket:status",this.onStatus),this.listenTo(this.server,"socket:playing",this.onPlaying),this.listenTo(this.server,"socket:websocket",this.onWebSocket)
},add:function(){this.length+1>this.limit&&this.remove(this.at(0)),t.prototype.add.apply(this,arguments)},onSettingChange:function(t){this.add(e.extend({_type:"setting"},t),{parse:!0})},onTimeline:function(t){1===t.state||t.sectionID<0||this.add(e.extend({_type:"timeline"},t),{parse:!0})},onStatus:function(t){"ProgressNotification"!==t._elementType&&this.add(e.extend({_type:"status"},t),{parse:!0})},onPlaying:function(t){this.add(e.extend({_type:"playing"},t),{parse:!0})},onWebSocket:function(t){this.add(e.extend({_type:"websocket"},t),{parse:!0})
}});return n}),define("plex/base/models/server/TranscodeJobModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"syncItemId",whitelistedAttrs:["syncItemId","syncItemTitle","key","type","progress","speed","remaining","size","title","thumb"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseInteger(n,["syncItemId","speed"]),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)
}});return n}),define("plex/base/models/server/TranscodeJobCollection",["plex/base/models/BaseCollection","plex/base/models/server/TranscodeJobModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/sync/transcodeQueue",parse:function(e){return this.convert(e,"TranscodeJob")}});return i}),define("plex/base/models/server/SessionModel",["plex/base/models/library/MetadataModel"],function(e){"use strict";var t=e.extend({idAttribute:"sessionKey",cacheKey:function(e){return this.server&&this.server.getScopedKey(e.sessionKey)
}});return t}),define("plex/base/models/server/SessionCollection",["plex/base/models/library/MetadataCollection","plex/base/models/server/SessionModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/status/sessions"});return i}),define("plex/base/models/server/ServerModel",["underscore","jquery","backbone","plex/base/adapters/loggerAdapter","plex/base/mixins/serverMixin","plex/base/models/BaseModel","plex/base/models/config","plex/base/models/library/section/SectionCollection","plex/base/models/library/PlayQueueManager","plex/base/models/library/PlaylistsSectionModel","plex/base/models/server/ServerCloudAccountModel","plex/base/models/server/ServerUpdateModel","plex/base/models/server/ServerSettingCollection","plex/base/models/server/ServerAlertCollection","plex/base/models/server/TranscodeJobCollection","plex/base/models/server/SessionCollection"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f){"use strict";
var g=a.extend({mixins:s,persistInCache:!0,timeout:1e4,defaults:function(){return e.extend(s.defaults.apply(this,arguments),{cloudAccount:new d({},{server:this}),update:r.get("serverUpdate")?new u({},{server:this}):null,sections:new o([],{server:this}),settings:new h([],{server:this}),alerts:new p([],{server:this}),transcodeJobs:new m([],{server:this}),sessions:new f([],{server:this}),playQueueManager:new l({server:this}),playlists:new c({},{server:this})})},constructor:function(){return this.connections=[],this.resetPopulatePromise(t.Deferred()),a.prototype.constructor.apply(this,arguments)||null
},initialize:function(e,t){t&&t.source&&this.addSource(t.source),this.listenTo(this,"change:machineIdentifier",this.onMachineIdentifierChange)},fetch:function(){return i.Model.prototype.fetch.apply(this,arguments)},merge:function(t){t.set("isMerged",!0),t.get("bundled")&&this.set("bundled",!0);var i=t.get("sources");e.each(i,function(e){this.addSource(e,{silent:!0})},this),e.each(t.connections,function(t){n.log("Merging connection ("+t.address+") into "+this.get("friendlyName")),this.addConnection(e.pick(t,"uri","scheme","address","port","accessToken","bundled"))
},this),this.collection&&(this.collection.remove(t.cid,{silent:!0}),this.collection._byId[this.id]=this,this.collection.trigger("remove",t,this)),this.cache.remove(t)},toLiteJSON:function(){return this.pick(["friendlyName","machineIdentifier","accessToken","cloud","shared","synced","sources"])},addSource:function(t,i){i||(i={});var n=this.get("sources");t&&!e.contains(n,t)&&(n.push(t),i.silent||this.trigger("change:sources",this,n))},removeSource:function(t,i){i||(i={});var n=this.get("sources"),s=e.indexOf(n,t);
s>-1&&(n.splice(s,1),i.silent||this.trigger("change:sources",this,n))},addConnection:function(i){var n=e.findWhere(this.connections,{uri:i.uri,scheme:i.scheme,address:i.address,port:i.port});if(n){if(n.available||n.accessToken||!i.accessToken)return n;n.pending=!0,n.accessToken=i.accessToken,i=n}else i.pending=!0,i.isLocalAddress=this.isLocalAddress(i.address),i.isLoopbackAddress=this.isLoopbackAddress(i.address),i.isSecure=this.isSecure(i.scheme),this.connections.push(i);return"rejected"===this.populatePromise.state()&&(this.resetPopulatePromise(t.Deferred()),this.set("authorized",null)),this.trigger("change:connections",this,this.connections),i
},hasLocalConnection:function(){var e=this.get("activeConnection");return e?e.isLocalAddress:null},hasLoopbackConnection:function(){var e=this.get("activeConnection");return e?e.isLoopbackAddress:null},hasSecureConnection:function(){var e=this.get("activeConnection");return e?"https"===e.scheme:null},canBePrimary:function(e){return this.get("synced")||this.get("cloud")?!1:this.get("shared")&&!this.get("multiuser")?!1:this.get("available")&&this.get("authorized")?this.isVersionOrNewer(e):!1},onMachineIdentifierChange:function(){this.collection?this.listenToOnce(this.collection,"change:machineIdentifier",this.onMachineIdentifierChanged):this.onMachineIdentifierChanged()
},onMachineIdentifierChanged:function(){var e=this.cacheKey(this.attributes),t=this.cache.get(e);t?t.get("connected")||!this.get("connected")?t.merge(this):(this.merge(t),this.cache.store(this)):this.cache.store(this,e)}});return g}),define("plex/base/models/server/ServerCollection",["plex/base/models/BaseCollection","plex/base/models/server/ServerModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/servers",parse:function(e){return this.convert(e,"Server")},comparator:function(e){var t=e.get("friendlyName")||"",i=e.get("shared"),n=e.get("synced"),s=i?"1":"0";
return s+=n?"1":"0",s+=t.toLowerCase()},toLiteJSON:function(){return this.map(function(e){return e.toLiteJSON()})}});return i}),define("plex/base/models/server/ResourceModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"clientIdentifier",urlRoot:"/api/resources",whitelistedAttrs:["clientIdentifier","name","sourceTitle","accessToken","product","productVersion","platform","platformVersion","device","provides","owned","synced","presence","createdAt","lastSeenAt","Connection"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);
return n.Device&&(n=n.Device),t.parseBoolean(n,["owned","synced","presence"]),t.parseInteger(n,["createdAt","lastSeenAt"]),t.parseArray(n,"Connection"),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs),i.provides&&(i.provides=i.provides.split(","),e.contains(i.provides,"sync-target")&&(i.synced=!0)),i}});return n}),define("plex/base/models/server/ResourceCollection",["jquery","plex/base/models/config","plex/base/models/BaseCollection","plex/base/models/server/ResourceModel"],function(e,t,i,n){"use strict";
var s=i.extend({model:n,url:function(){var i="/api/resources",n={};return t.get("includeHttps")&&(n.includeHttps=1),t.get("requestAllConnections")||(n.filterByPublic=1),e.isEmptyObject(n)||(i+="?"+e.param(n,!0)),i},parse:function(e){return this.convert(e,"Device")}});return s}),define("plex/base/models/server/CloudServerModel",["underscore","jquery","plex/base/adapters/loggerAdapter","plex/base/models/server/ServerModel","plex/base/models/server/ResourceCollection","plex/base/models/library/PlayQueueManager"],function(e,t,i,n,s,a){"use strict";
var r=n.extend({baseUrl:"https://plex.tv",defaults:function(){return{machineIdentifier:"myPlex",friendlyName:"plex.tv",cloud:!0,downForMaintenance:!1,plexPassUrl:this.baseUrl+"/subscription/about",accountUrl:this.baseUrl+"/users/edit",cloudSyncUrl:this.baseUrl+"/cloudsync/providers",appsUrl:this.baseUrl+"/downloads",helpUrl:"http://support.plex.tv/hc/en-us",resources:new s([],{server:this}),playQueueManager:new a({server:this})}},initialize:function(){this.listenTo(this,"change:resources",this.onResourcesChange),this.forwardResourcesEvents()
},forwardResourcesEvents:function(){var t=this.get("resources");t&&this.listenTo(t,"all",function(){var t=e.toArray(arguments),i=t[0];t[0]="change:resources:"+i,this.trigger.apply(this,t)})},testConnection:function(n){var s=this.get("friendlyName"),a=this.resolveUrl("/pms/:/ip",{connection:n}),r=e.extend(this.getXHROptions(a),{timeout:this.timeout}),o=t.ajax(r);i.log("Testing connection to "+s+" at "+a),o.done(e.bind(function(){i.success("Setting active connection for "+s+" ("+a+")"),this.set({connected:!0,available:!0,downForMaintenance:!1,activeConnection:n})
},this)),o.fail(e.bind(function(e){i.error(s+" is unavailable at "+a+" (Status "+e.status+")"),this.set({connected:!1,available:!1,downForMaintenance:503===e.status}),this.populatePromise.rejectWith(this,[this,e])},this))},onResourcesChange:function(){var e=this.previous("resources");e&&this.stopListening(e),this.forwardResourcesEvents()}});return r.prototype.cache=n.prototype.cache,r}),define("plex/base/models/player/PlexPlayerModel",["plex/base/models/server/ServerModel","plex/base/models/library/MetadataCollection"],function(e,t){"use strict";
var i=e.extend({cacheKey:null,initialize:function(){this.set("activeConnection",this.connections[0]),this.set("nowPlaying",new t([],{server:this.server}))}});return i}),define("plex/base/models/player/PlexPlayerCollection",["plex/base/models/server/ServerCollection","plex/base/models/player/PlexPlayerModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/clients"});return i}),define("plex/base/models/server/serverStorageModel",["underscore","jquery","plex/base/adapters/storageAdapter","plex/base/models/StorageModel"],function(e,t,i,n){"use strict";
var s=n.extend({storageKey:"connections",defaults:function(){return{users:[]}},initialize:function(){this.debouncedSave=e.debounce(this.save,100)},getCurrentUser:function(){var n=i.get("myPlexAccessToken");return n=n.then(e.bind(function(i){var n=this.get("users"),s=e.findWhere(n,{accessToken:i});return s||(s={accessToken:i,servers:[]},n.push(s)),t.Deferred().resolve(s).promise()},this))},updateUser:function(t){var i=this.getCurrentUser();return i=i.then(e.bind(function(e){e.id=t.id,e.title=t.get("title"),e.home=t.get("home"),e.entitlements=t.get("entitlements");
var i=t.get("pin");return i?e.pin=i:e.pin&&delete e.pin,this.debouncedSave()},this))},updateLiteServer:function(i,n){n||(n={});var s=this.getCurrentUser();return s=s.then(e.bind(function(s){var a=s.servers,r=e.findWhere(a,{machineIdentifier:i.id});if(!r){if(!n.add)return t.Deferred().reject().promise();r={connections:[]},a.push(r)}return e.extend(r,i.toLiteJSON()),this.debouncedSave(),t.Deferred().resolve(r).promise()},this))},updateConnections:function(i,n){var s=this.updateLiteServer(i,{add:!0});
return s=s.then(e.bind(function(i){var s=e.map(n,function(t){return e.pick(t,"uri","scheme","address","port","bundled")});return i.connections=s,this.debouncedSave(),t.Deferred().resolve(s).promise()},this))},removeAllServers:function(){var t=this.getCurrentUser();return t.done(e.bind(function(e){e.servers.length=0,this.debouncedSave()},this)),t},removeLiteServer:function(t){var i=this.getCurrentUser();return i.done(e.bind(function(i){var n=i.servers,s=e.indexOf(n,e.findWhere(n,{machineIdentifier:t.id}));
s>-1&&(n.splice(s,1),this.debouncedSave())},this)),i},pruneLiteServers:function(t,i){var n=this.getCurrentUser();return n.done(e.bind(function(n){for(var s=i.server.id,a=n.servers,r=e.filter(a,function(t){return e.contains(t.sources,s)}),o=r.length-1;o>-1;o--){var l=r[o],c=l.machineIdentifier;if(!i.get(c)){var d=l.sources;if(d.splice(e.indexOf(d,s),1),!d.length||1===d.length&&d[0]===c){var u=t.get(c);u&&u.trigger("destroy",u,u.collection),a.splice(e.indexOf(a,l),1)}this.debouncedSave()}}},this)),n
}});return new s}),define("plex/base/utils/syncUtil",[],function(){"use strict";var e={waitingRegex:/^(transcoded|downloaded|directplay|processed)$/,processingRegex:/^(pending|transcoding|downloading)$/,failedRegex:/^(failed|error)$/,addVersionHeader:function(e,t){var i=t&&t.get("SyncList");return i&&i.version&&(e||(e={}),e.headers||(e.headers={}),e.headers["X-Plex-Sync-Version"]=i.version),e},getSyncStateFromPart:function(e){return e.transcodeState||e.syncState},getSyncStateContextFromPart:function(e){return e.transcodeStateContext||e.syncStateContext
}};return e}),define("plex/base/models/user/SyncItemModel",["underscore","plex/base/utils/parser","plex/base/utils/syncUtil","plex/base/models/BaseModel"],function(e,t,i,n){"use strict";var s=n.extend({whitelistedAttrs:["id","version","rootTitle","title","metadataType","clientIdentifier","Server","Status","MediaSettings","Policy","Location"],sync:function(e,t,s){var a=i.addVersionHeader(s,this.device);return n.prototype.sync.call(this,e,t,a)},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);
return t.parseInteger(n,["id","version"]),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs),i.Location&&i.Location.uri&&(i.isDirectory=/library\:\/\/([\w-]+)\/directory\//.test(i.Location.uri)),i}});return s}),define("plex/base/models/user/SyncItemCollection",["underscore","plex/base/utils/syncUtil","plex/base/models/BaseCollection","plex/base/models/user/SyncItemModel"],function(e,t,i,n){"use strict";var s=i.extend({model:n,url:function(){return this.device?"/devices/"+this.device.get("clientIdentifier")+"/sync_items":"/servers/"+this.parent.id+"/sync_lists"
},sync:function(e,n,s){var a=t.addVersionHeader(s,this.device);return i.prototype.sync.call(this,e,n,a)},parse:function(t){var i=this.convert(t),n=[],s=function(t,i){i&&(e.isArray(i)||(i=[i]),e.each(i,function(e){e.clientIdentifier=t,n.push(e)}))};return i.SyncList&&!e.isArray(i.SyncList)&&(i.SyncList=[i.SyncList]),e.each(i.SyncList,function(e){s(e.clientIdentifier,e.SyncItems.SyncItem)}),i.SyncItems&&s(i.clientIdentifier,i.SyncItems.SyncItem),n},filterByServer:function(e){var t=this.filter(function(t){var i=t.get("Server");
return i&&i.machineIdentifier===e});return this.clone(t)}});return s}),define("plex/base/models/user/DeviceModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/user/SyncItemCollection"],function(e,t,i,n){"use strict";var s=i.extend({whitelistedAttrs:["id","clientIdentifier","name","product","productVersion","platform","platformVersion","device","model","provides","screenResolution","screenDensity","lastSeenAt","SyncList"],url:function(){return"/devices/"+this.id+".xml"
},initialize:function(){this.set("syncItems",new n([],{server:this.server,device:this}))},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseInteger(n,"lastSeenAt"),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs),i.isCloudSync="cloudsync"===i.platform,i.provides=i.provides?i.provides.split(","):[],i},supports:function(t){var i=this.get("provides");return e.indexOf(i,t)>-1}});return s}),define("plex/base/models/user/DeviceCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/user/DeviceModel"],function(e,t,i){"use strict";
var n=t.extend({model:i,url:"/devices.xml",parse:function(e){return this.convert(e,"Device")},filterSyncDevices:function(t){var i=!(!t||!t.channel),n=this.filter(function(e){return e.supports("sync-target")&&(!i||!e.get("isCloudSync"))}),s=e.sortBy(n,function(e){return!e.get("isCloudSync")});return this.clone(s)},filterByProducts:function(t){var i=this.filter(function(i){return e.contains(t,i.get("product"))});return this.clone(i)},products:function(){var t=this.map(function(e){return e.get("product")
});return e.uniq(t)}});return n}),define("plex/base/models/user/HomeUserModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({urlRoot:"/api/home/users",whitelistedAttrs:["id","admin","protected","restricted","title","username","email","thumb"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n.User&&(n=n.User),t.parseInteger(n,"id"),t.parseBoolean(n,["admin","protected","restricted"]),n},parse:function(t){var i=this.convert(t);
return i=e.pick(i,this.whitelistedAttrs)},getSaveParams:function(t){if(e.isEmpty(t)){var n={};return this.get("restricted")?n.title=this.get("title"):this.isNew()&&(n.invitedEmail=this.get("username")),n}return i.prototype.getSaveParams.apply(this,arguments)}});return n}),define("plex/base/models/user/HomeUserCollection",["plex/base/models/BaseCollection","plex/base/models/user/HomeUserModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/api/home/users",parse:function(e){return this.convert(e,"User")
}});return i}),function(e,t){"object"==typeof exports?module.exports=t(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define("backbone.obscura",["underscore","backbone"],t):e.Backbone.Obscura=t(e._,e.Backbone)}(this,function(e,t){function i(i){return{underscore:e,backbone:t}[i]}var n=function(){function e(t){var i=e.cache[t];if(!i){var n={};i=e.cache[t]={id:t,exports:n},e.modules[t].call(n,i,n)}return i.exports}return e.cache=[],e.modules=[function(t){function n(e,t){this._superset=e,this._filtered=new r(e,t),this._sorted=new o(this._filtered,t),this._paginated=new l(this._sorted,t),c(this._paginated,this),d.call(this,this._filtered,p),d.call(this,this._sorted,f),d.call(this,this._paginated,v),this.initialize(t)
}var s=i("underscore"),a=i("backbone"),r=e(2),o=e(5),l=e(4),c=e(1),d=e(7),u={superset:function(){return this._superset},getFilteredLength:function(){return this._filtered.length},removeTransforms:function(){return this._filtered.resetFilters(),this._sorted.removeSort(),this._paginated.removePagination(),this},destroy:function(){this.stopListening(),this._filtered.destroy(),this._sorted.destroy(),this._paginated.destroy(),this.length=0,this.trigger("obscura:destroy")}},h=["filterBy","removeFilter","resetFilters","refilter","hasFilter","getFilters"],p=["filtered:add","filtered:remove","filtered:reset"],m=["setSort","reverseSort","removeSort"],f=["sorted:add","sorted:remove"],g=["setPerPage","setPage","getPerPage","getNumPages","getPage","hasNextPage","hasPrevPage","nextPage","prevPage","movePage","removePagination","firstPage","lastPage"],v=["paginated:change:perPage","paginated:change:page","paginated:change:numPages"],y=["add","create","remove","set","reset","sort","parse","sync","fetch","push","pop","shift","unshift"];
s.each(h,function(e){u[e]=function(){var t=r.prototype[e].apply(this._filtered,arguments);return t===this._filtered?this:t}}),s.each(g,function(e){u[e]=function(){var t=l.prototype[e].apply(this._paginated,arguments);return t===this._paginated?this:t}}),s.each(m,function(e){u[e]=function(){var t=o.prototype[e].apply(this._sorted,arguments);return t===this._sorted?this:t}}),s.each(y,function(e){u[e]=function(){throw new Error("Backbone.Obscura: Unsupported method: "+e+"called on read-only proxy")}
}),s.extend(n.prototype,u,a.Events),n=a.Collection.extend(n.prototype),n.FilteredCollection=r,n.SortedCollection=o,n.PaginatedCollection=l,t.exports=n},function(e){function t(e,t){function i(){t.length=e.length}function o(i){var s=n.toArray(arguments),a="change"===i||"change:"===i.slice(0,7);"reset"===i&&(t.models=e.models),n.contains(r,i)?(n.contains(["add","remove","destroy"],i)?s[2]=t:n.contains(["reset","sort"],i)&&(s[1]=t),t.trigger.apply(this,s)):a&&t.contains(s[1])&&t.trigger.apply(this,s)
}var l={};return n.each(n.functions(s.Collection.prototype),function(t){n.contains(a,t)||(l[t]=function(){return e[t].apply(e,arguments)})}),n.extend(t,s.Events,l),t.listenTo(e,"all",i),t.listenTo(e,"all",o),t.models=e.models,i(),t}var n=i("underscore"),s=i("backbone"),a=["_onModelEvent","_prepareModel","_removeReference","_reset","add","initialize","sync","remove","reset","set","push","pop","unshift","shift","sort","parse","fetch","create","model","off","on","listenTo","listenToOnce","bind","trigger","once","stopListening"],r=["add","remove","reset","sort","destroy","sync","request","error"];
e.exports=t},function(t){function n(){this._filterResultCache={}}function s(e){for(var t in this._filterResultCache)this._filterResultCache.hasOwnProperty(t)&&delete this._filterResultCache[t][e]}function a(e,t){this._filters[e]&&s.call(this,e),this._filters[e]=t,this.trigger("filtered:add",e)}function r(e){delete this._filters[e],s.call(this,e),this.trigger("filtered:remove",e)}function o(e){this._filterResultCache[e.cid]||(this._filterResultCache[e.cid]={});var t=this._filterResultCache[e.cid];
for(var i in this._filters)if(this._filters.hasOwnProperty(i)&&(t.hasOwnProperty(i)||(t[i]=this._filters[i].fn(e)),!t[i]))return!1;return!0}function l(e){e||(e={});var t=[];this._superset&&(t=this._superset.filter(g.bind(o,this))),e.reset?this._collection.reset(t):this._collection.set(t),this.length=this._collection.length}function c(){l.call(this,{reset:!0})}function d(){var e=!(!this._superset||!this._superset.comparator);l.call(this,{reset:e})}function u(e){if(this._filterResultCache[e.cid]={},o.call(this,e)){if(!this._collection.get(e.cid)){for(var t=this.superset().indexOf(e),i=null,n=t-1;n>=0;n-=1)if(this.contains(this.superset().at(n))){i=this.indexOf(this.superset().at(n))+1;
break}i=i||0,this._collection.add(e,{at:i})}}else this._collection.get(e.cid)&&this._collection.remove(e);this.length=this._collection.length}function h(e){this._filterResultCache[e.cid]={},o.call(this,e)||this._collection.get(e.cid)&&this._collection.remove(e)}function p(e){"change:"===e.slice(0,7)&&h.call(this,arguments[1])}function m(e){this.contains(e)&&this._collection.remove(e),this.length=this._collection.length}function f(e){this._superset=e,this._collection=new v.Collection(e.toArray()),y(this._collection,this),this.resetFilters(),this.listenTo(this._superset,"reset",c),this.listenTo(this._superset,"sort",d),this.listenTo(this._superset,"add change",u),this.listenTo(this._superset,"remove",m),this.listenTo(this._superset,"all",p)
}var g=i("underscore"),v=i("backbone"),y=e(1),b=e(3),w={defaultFilterName:"__default",filterBy:function(e,t){return t||(t=e,e=this.defaultFilterName),a.call(this,e,b(t)),l.call(this),this},removeFilter:function(e){return e||(e=this.defaultFilterName),r.call(this,e),l.call(this),this},resetFilters:function(){return this._filters={},n.call(this),this.trigger("filtered:reset"),l.call(this),this},superset:function(){return this._superset},refilter:function(e){return"object"==typeof e&&e.cid?u.call(this,e):(n.call(this),l.call(this)),this
},getFilters:function(){return g.keys(this._filters)},hasFilter:function(e){return g.contains(this.getFilters(),e)},destroy:function(){this.stopListening(),this._collection.reset([]),this._superset=this._collection,this.length=0,this.trigger("filtered:destroy")}};g.extend(f.prototype,w,v.Events),t.exports=f},function(e){function t(e,t){return function(i){return i.get(e)===t}}function n(e,t){return function(i){return t(i.get(e))}}function s(e,t){return o.isArray(t)||(t=null),{fn:e,keys:t}}function a(e){var i=o.keys(e),a=o.map(i,function(i){var s=e[i];
return o.isFunction(s)?n(i,s):t(i,s)}),r=function(e){for(var t=0;t<a.length;t++)if(!a[t](e))return!1;return!0};return s(r,i)}function r(e,t){return o.isFunction(e)?s(e,t):o.isObject(e)?a(e):void 0}var o=i("underscore");e.exports=r},function(t){function n(){var e=this.getPage()*this.getPerPage(),t=e+this.getPerPage();return[e,t]}function s(){var e=n.call(this);this._collection.reset(this.superset().slice(e[0],e[1]))}function a(){var e=(this._totalPages,this.superset().length),t=this.getPerPage(),i=e%t===0?e/t:Math.floor(e/t)+1,n=this._totalPages!==i;
return this._totalPages=i,n&&this.trigger("paginated:change:numPages",{numPages:i}),this.getPage()>=i?(this.setPage(i-1),!0):void 0}function r(){a.call(this)||s.call(this)}function o(e,t){for(var i=d.max([e.length,t.length]),n=0,s=0;i>n;n+=1,s+=1)if(e[n]!==t[s])if(t[n-1]===e[n])s-=1;else{if(t[n+1]!==e[n])return e[n];s+=1}}function l(){if(!a.call(this)){var e=n.call(this),t=e[0],i=e[1],s=o(this.superset().slice(t,i),this._collection.toArray()),r=o(this._collection.toArray(),this.superset().slice(t,i));
r&&this._collection.remove(r),s&&this._collection.add(s,{at:this.superset().indexOf(s)-t})}}function c(e,t){this._superset=e,this._collection=new u.Collection(e.toArray()),this._page=0,this.setPerPage(t&&t.perPage?t.perPage:null),h(this._collection,this),this.listenTo(this._superset,"add remove",l),this.listenTo(this._superset,"reset sort",r)}var d=i("underscore"),u=i("backbone"),h=e(1),p={removePagination:function(){return this.setPerPage(null),this},setPerPage:function(e){return this._perPage=e,r.call(this),this.setPage(0),this.trigger("paginated:change:perPage",{perPage:e,numPages:this.getNumPages()}),this
},setPage:function(e){var t=0,i=this.getNumPages()-1;return e=e>t?e:t,e=i>e?e:i,e=0>e?0:e,this._page=e,s.call(this),this.trigger("paginated:change:page",{page:e}),this},getPerPage:function(){return this._perPage||this.superset().length||1},getNumPages:function(){return this._totalPages},getPage:function(){return this._page},hasNextPage:function(){return this.getPage()<this.getNumPages()-1},hasPrevPage:function(){return this.getPage()>0},nextPage:function(){return this.movePage(1),this},prevPage:function(){return this.movePage(-1),this
},firstPage:function(){this.setPage(0)},lastPage:function(){this.setPage(this.getNumPages()-1)},movePage:function(e){return this.setPage(this.getPage()+e),this},superset:function(){return this._superset},destroy:function(){this.stopListening(),this._collection.reset([]),this._superset=this._collection,this._page=0,this._totalPages=0,this.length=0,this.trigger("paginated:destroy")}};d.extend(c.prototype,p,u.Events),t.exports=c},function(t){function n(e){return d.isFunction(e)?e:function(t){return t.get(e)
}}function s(e){return this._comparator?this._reverse?p(this._collection.toArray(),e,n(this._comparator)):d.sortedIndex(this._collection.toArray(),e,n(this._comparator)):this._superset.indexOf(e)}function a(e){var t=s.call(this,e);this._collection.add(e,{at:t})}function r(e){this.contains(e)&&this._collection.remove(e)}function o(e){this.contains(e)&&this._collection.indexOf(e)!==s.call(this,e)&&(this._collection.remove(e),a.call(this,e))}function l(){if(!this._comparator)return void this._collection.reset(this._superset.toArray());
var e=this._superset.sortBy(this._comparator);this._collection.reset(this._reverse?e.reverse():e)}function c(e){this._superset=e,this._reverse=!1,this._comparator=null,this._collection=new u.Collection(e.toArray()),h(this._collection,this),this.listenTo(this._superset,"add",a),this.listenTo(this._superset,"remove",r),this.listenTo(this._superset,"change",o),this.listenTo(this._superset,"reset",l)}var d=i("underscore"),u=i("backbone"),h=e(1),p=e(6),m={setSort:function(e,t){return this._reverse="desc"===t?!0:!1,this._comparator=e,l.call(this),this.trigger(e?"sorted:add":"sorted:remove"),this
},reverseSort:function(){return this._reverse=!this._reverse,l.call(this),this},removeSort:function(){return this.setSort(),this},superset:function(){return this._superset},destroy:function(){this.stopListening(),this._collection.reset([]),this._superset=this._collection,this.length=0,this.trigger("sorted:destroy")}};d.extend(c.prototype,m,u.Events),t.exports=c},function(e){function t(e){return s.isFunction(e)?e:function(t){return t[e]}}function n(e,i,n,a){n=null==n?s.identity:t(n);for(var r=n.call(a,i),o=0,l=e.length;l>o;){var c=o+l>>>1;
n.call(a,e[c])<r?l=c:o=c+1}return o}var s=i("underscore");e.exports=n},function(e){function t(e,t){n.each(t,function(t){this.listenTo(e,t,function(){var e=n.toArray(arguments);e.unshift(t),this.trigger.apply(this,e)})},this)}var n=i("underscore");e.exports=t}],e(0)}();return n}),define("plex/base/models/user/ServerShareModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({whitelistedAttrs:["id","serverId","machineIdentifier","name","owned","admin","pending","lastSeenAt","invitedAt","acceptedAt","allLibraries","numLibraries","allowSync","allowCameraUpload","Section"],urlRoot:function(){return"/api/servers/"+this.get("machineIdentifier")+"/shared_servers"
},isActive:function(){return!(!this.get("numLibraries")&&!this.get("allLibraries"))},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);n.SharedServer&&(n=n.SharedServer),t.parseInteger(n,["id","serverId","lastSeenAt","invitedAt","acceptedAt","numLibraries"]),t.parseBoolean(n,["owned","admin","pending","allLibraries","allowSync","allowCameraUpload"]),t.parseArray(n,"Section");var s=n.Section;return e.each(s,function(e){t.parseInteger(e,"id"),t.parseBoolean(e,"shared")}),n},parse:function(t){var i=this.convert(t);
return i=e.pick(i,this.whitelistedAttrs),!i.numLibraries&&i.Section.length&&(i.numLibraries=e.where(i.Section,{shared:!0}).length),i}});return n}),define("plex/base/models/user/ServerShareCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/user/ServerShareModel"],function(e,t,i){"use strict";var n=t.extend({model:i,filterByOwned:function(){var e=this.filter(function(e){return e.get("owned")});return this.clone(e)},filterByShared:function(){var e=this.filter(function(e){return!e.get("owned")&&!e.get("pending")
});return this.clone(e)},getLibraryCount:function(t){var i=this.where(t);return e.reduce(i,function(e,t){return e+=t.get("numLibraries")},0)},getOwnedLibraryCount:function(){return this.getLibraryCount({owned:!0})},getSharedLibraryCount:function(){return this.getLibraryCount({owned:!1})},getActiveCount:function(){return this.reduce(function(e,t){return t.isActive()&&e++,e},0)}});return n}),define("plex/base/models/user/FriendModel",["underscore","jquery","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/user/ServerShareCollection"],function(e,t,i,n,s){"use strict";
var a=n.extend({whitelistedAttrs:["id","home","protected","restricted","title","username","email","thumb","recommendationsPlaylistId","allowSync","allowCameraUpload","filterMovies","filterTelevision","filterMusic","filterPhotos"],saveAttrs:["allowSync","allowCameraUpload","filterMovies","filterTelevision","filterMusic","filterPhotos"],filterAttrs:["filterMovies","filterTelevision","filterMusic","filterPhotos"],urlRoot:function(){return this.get("home")?"/api/users":"/api/friends"},convert:function(t){var n=e.isObject(t)?t:i.parseXML(t);
return n.User&&(n=n.User),i.parseInteger(n,"id"),i.parseBoolean(n,["home","protected","restricted","allowSync","allowCameraUpload"]),i.parseQueryString(n,["filterMovies","filterTelevision","filterMusic","filterPhotos"],"|"),i.parseArray(n,"Server"),n},parse:function(t){var i=this.convert(t);return this.parseServers(i),i=e.pick(i,this.whitelistedAttrs)},parseServers:function(e){var t=this.get("serverShares"),i=e.Server;t?t.set(i,{parse:!0}):(t=new s(i,{server:this.server,parent:this,populated:!0,parse:!0}),this.set("serverShares",t))
},cloneDeep:function(){var e=this.toJSON();e.Server=e.serverShares.toJSON(),e.serverShares=null;var i={server:this.server,section:this.section,channel:this.channel,parent:this.parent,parse:!0,skipCache:!0};return new this.constructor(t.extend(!0,{},e),i)||null},getSaveParams:function(t){if(e.isEmpty(t)){var i=this.pick(this.saveAttrs);return e.map(i,function(t,i,n){e.isBoolean(t)?n[i]=t?"1":"0":e.contains(this.filterAttrs,i)&&(n[i]=this.stringifyFilter(t))},this),i}return n.prototype.getSaveParams.apply(this,arguments)
},stringifyFilter:function(t){var i=e.map(e.keys(t),function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])});return i.join("|")}});return a}),define("plex/base/models/user/FriendCollection",["backbone.obscura","plex/base/models/BaseCollection","plex/base/models/user/FriendModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:"/api/users",parse:function(e){return this.convert(e,"User")},filterByHome:function(){var t=new e(this);return t.filterBy(function(e){return e.get("home")
}),t},filterByUnrestricted:function(){var t=new e(this);return t.filterBy(function(e){return!e.get("restricted")}),t},filterByServerShares:function(t){var i=new e(this);return i.filterBy(function(e){var i=e.get("serverShares");return!!i.findWhere({machineIdentifier:t})}),i}});return n}),define("plex/base/models/user/InviteModel",["underscore","jquery","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i,n){"use strict";var s=n.extend({whitelistedAttrs:["id","friend","server","home","friendlyName","username","email","thumb","createdAt","Server"],urlRoot:"/api/invites/requests",url:function(){var i;
if(this.isNew())i=e.result(this,"urlRoot");else{var n=this.pick("friend","server","home");e.each(e.keys(n),function(e){n[e]=n[e]?"1":"0"}),i=this.collection?e.result(this.collection,"url"):e.result(this,"urlRoot"),i=i.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.get("id")),i+="?"+t.param(n,!0)}return i},convert:function(t){var n=e.isObject(t)?t:i.parseXML(t);i.parseInteger(n,"createdAt"),i.parseBoolean(n,["friend","server","home"]),i.parseArray(n,"Server");var s=n.Server;return e.each(s,function(e){i.parseInteger(e,"numLibraries")
}),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return s}),define("plex/base/models/user/InviteCollection",["backbone.obscura","plex/base/models/BaseCollection","plex/base/models/user/InviteModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){return"/api/invites/"+this.subset},initialize:function(e,t){t||(t={}),this.subset=t.subset||"requests"},parse:function(e){return this.convert(e,"Invite")},filterByHome:function(){var t=new e(this);
return t.filterBy(function(e){return e.get("home")}),t},filterByFriends:function(){var t=new e(this);return t.filterBy(function(e){return!e.get("home")}),t}});return n}),define("plex/base/models/user/SocialNetworkModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",whitelistedAttrs:["key","title","linked","maxLength"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseBoolean(n,["linked","maxLength"]),n
},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return n}),define("plex/base/models/user/SocialNetworkCollection",["plex/base/models/BaseCollection","plex/base/models/user/SocialNetworkModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/pms/social/networks",parse:function(e){return this.convert(e,"Directory")}});return i}),SHA256_hexchars=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"),SHA256_K=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),define("jssha256",function(){}),define("plex/base/models/user/UserModel",["underscore","jquery","plex/base/utils/parser","plex/base/adapters/loggerAdapter","plex/base/adapters/storageAdapter","plex/base/adapters/settingsAdapter","plex/base/models/BaseModel","plex/base/models/server/serverStorageModel","plex/base/models/user/DeviceCollection","plex/base/models/user/HomeUserCollection","plex/base/models/user/FriendCollection","plex/base/models/user/InviteCollection","plex/base/models/user/SocialNetworkCollection","jssha256"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=r.extend({url:"/users/account",defaults:function(){var t={server:this.server,parent:this};return{signedIn:null,hasInvalidToken:!1,subscription:!1,locked:null,devices:new l([],t),homeUsers:new c([],t),friends:new d([],t),invites:new u([],t),sentInvites:new u([],e.extend({subset:"requested"},t)),socialNetworks:new h([],t)}},whitelistedAttrs:["id","pin","restricted","home","maxHomeSize","username","email","thumb","title","queueUid","queueEmail","accessToken"],initialize:function(){this.listenTo(this.server,"change:available",this.onServerAvailableChange)
},convert:function(t){var n=e.isObject(t)?t:i.parseXML(t),s=n.subscription,a=n.entitlements;return i.parseInteger(n,["id","maxHomeSize"]),i.parseBoolean(n,["restricted","home"]),i.parseArray(n,"roles"),s&&(i.parseBoolean(s,"active"),i.parseArray(s,"feature")),a&&(i.parseBoolean(a,"all"),i.parseArray(a,"entitlement")),n},parse:function(t){var i=this.convert(t),s=i.roles,a=i.subscription,r=i.entitlements,o=[];if(i.accessToken=i.authenticationToken,i=e.pick(i,this.whitelistedAttrs),i.signedIn=!0,i.hasInvalidToken=!1,a){var l=a.feature;
i.subscription=a.active,i.plan=a.plan,o.push("subscription: "+i.plan),i.features=e.reduce(l,function(e,t){return e[t.id]=!0,e},{}),o.push("features: "+e.keys(i.features).join(", "))}else o.push("features: none"),i.features=void 0,i.plan=void 0,i.subscription=void 0;return s&&s.length?(s=s[0].role,i.roles=e.reduce(s,function(e,t){return e[t.id]=!0,e},{}),o.push("roles: "+e.keys(i.roles).join(", "))):i.roles=void 0,r?(e(r.entitlement).each(function(e){r[e.id]=!0}),i.entitlements=e(r).omit("entitlement"),o.push("entitlements: "+e.keys(i.entitlements).join(", "))):o.push("entitlements: none"),n.group(i.title,o),i
},switchUser:function(i,n){var a=this.parse(i),r=a.accessToken,o=this.parent.get("servers");o.resetPopulatePromise(t.Deferred()),this.parent.get("primaryServer")===!1&&this.parent.set("primaryServer",null);var l=s.set("myPlexAccessToken",r,{session:!n.remember});l.always(e.bind(function(){this.server.set("accessToken",r),this.set(a),this.resolveServerPromise()},this))},resolveServerPromise:function(){var e=this.get("signedIn"),t=e?"resolved":"rejected";this.server.updatePopulatePromise(t),this.server.set("authorized",e)
},clearAccountAttributes:function(t){t||(t={}),this.clear(),this.set(e.extend({},e.result(this,"defaults"),t)),t.hasInvalidToken&&(this.server.get("resources").reset(),this.clearAccessToken())},clearAccessToken:function(){this.server.set("accessToken",null);var t=s.clear({session:!0});return t=t.then(function(){return window.PLEXWEB&&window.PLEXWEB.myPlexAccessToken&&delete window.PLEXWEB.myPlexAccessToken,s.remove("myPlexAccessToken")}),t=t.then(function(){return o.clear(),o.save(e.result(o,"defaults"))
})},hashPIN:function(e,t){return t||(t=this.get("accessToken")),SHA256_hash(e+t)},isFullUser:function(){return!!this.get("username")},isEmployee:function(){var e=this.get("roles");return!!(e&&"employee"in e)},isNinja:function(){var e=this.get("roles");return this.isEmployee()||!!(e&&"ninja"in e)},hasPlexPass:function(){var e=this.get("features");return!!(e&&"pass"in e)},hasEntitlement:function(e){var t=this.get("entitlements");return!(!t||!t.all&&!t[e])},hasSync:function(){var e=this.get("features");
return!!(e&&"sync"in e)},hasHome:function(){return!!this.get("pin")||this.get("homeUsers").length>1},onServerAvailableChange:function(t,i){if(null!=i){if(i===!1)return this.clearAccountAttributes({signedIn:!1}),void this.resolveServerPromise();this.get("signedIn")&&this.set("locked",!1);var n=s.get("myPlexAccessToken",{session:!0}),r=e.bind(function(t){this.server.set("accessToken",t);var i=this.fetch();i.done(e.bind(function(){this.get("locked")!==!1&&this.set("locked",!!this.get("home")&&!a.get("autoLogin"))
},this)),i.fail(e.bind(function(e,t){this.clearAccountAttributes({signedIn:!1,hasInvalidToken:401===t.status||422===t.status})},this)),i.always(e.bind(function(){this.resolveServerPromise()},this))},this),o=e.bind(function(){this.clearAccountAttributes({signedIn:!1}),this.resolveServerPromise()},this);n=n.then(function(e){return e},function(){return s.get("myPlexAccessToken")}),n.done(r).fail(o)}}});return p}),define("plex/base/models/InputActivityModel",["underscore","backbone","plex/base/adapters/settingsAdapter"],function(e,t){"use strict";
var i=t.Model.extend({AWAKE:"awake",ASLEEP:"asleep",IDLE:"idle",NONE:"none",defaults:{state:"none",idleTime:void 0,sleepTime:void 0},initialize:function(t){t||(t={}),e.bindAll(this,"onIdleTimeout","onSleepTimeout"),this._locks={},this.listenTo(this,{"change:idleTime":this.notice,"change:sleepTime":this.notice})},notice:function(){{var e;this.get("enabled")}this.timer=clearTimeout(this.timer),this.has("idleTime")&&!this.isLocked()?(this.timer=setTimeout(this.onIdleTimeout,this.get("idleTime")),e=this.AWAKE):e=this.NONE,this.set("state",e)
},isInactive:function(){var e=this.get("state");return e===this.IDLE||e===this.ASLEEP},lock:function(e){this._locks[e]=!0,this.notice()},unlock:function(e){delete this._locks[e],this.notice()},toggleLock:function(e,t){t?this.lock(e):this.unlock(e)},isLocked:function(){return e.keys(this._locks).length>0},onIdleTimeout:function(){this.set("state",this.IDLE),this.timer=this.has("sleepTime")?setTimeout(this.onSleepTimeout,this.get("sleepTime")):clearTimeout(this.timer)},onSleepTimeout:function(){this.set("state",this.ASLEEP),this.timer=clearTimeout(this.timer)
}});return i}),define("plex/base/models/appModel",["backbone","plex/base/models/AnnouncementCollection","plex/base/models/debug/LogCollection","plex/base/models/server/ServerCollection","plex/base/models/server/CloudServerModel","plex/base/models/player/PlexPlayerCollection","plex/base/models/user/UserModel","plex/base/models/InputActivityModel"],function(e,t,i,n,s,a,r,o){"use strict";var l=e.Model.extend({defaults:function(){return{version:"9.9.9",updateState:"none",authorized:!1,multiserver:!1,multiplayer:!1,isCastApiAvailable:!1,isCastDeviceAvailable:!1,history:[],forwardHistory:[]}
},initialize:function(){var e=new s({machineIdentifier:"myPlex"},{parent:this});this.set({announcements:new t,inputActivity:new o,logs:new i([],{parent:this}),players:new a([],{parent:this}),servers:new n([e],{parent:this}),user:new r({},{server:e,parent:this})})}});return new l}),define("plex/base/adapters/playerControllerAdapter",["underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/Adapter","plex/base/adapters/loggerAdapter","plex/base/models/appModel"],function(e,t,i,n,s,a){"use strict";
var r=n.extend({initialize:function(){this.controllers=[]},register:function(e){this.controllers.push(e)},getInstance:function(n,r){r||(r={});var o,l=a.get("primaryPlayer");o=l&&!r.forceLocal?l.get("protocol")||"legacy":"local";var c=e.find(this.controllers,function(e){var t=o===e.protocol,i=n===e.type||"*"===e.type;return t&&i});if(c)return c.create(n);if(r.forceLocal)throw new Error("No player controller found for: "+n);return s.warn("A player did not match the protocol ("+o+") and type ("+n+")."),i.trigger("show:alert",{type:"error",message:t("Playback of this media is not supported with the selected player.")}),this.getInstance(n,{forceLocal:!0})
}});return new r}),define("plex/base/commands/server/testServerConnectionCommand",["underscore","jquery","plex/base/adapters/loggerAdapter"],function(e,t,i){"use strict";function n(n){var s=n.server,a=n.connection,r=s.get("friendlyName"),o=s.url(a),l=t.Deferred();a.test&&"pending"===a.test.state()&&(a.aborting=!0,a.test.abort(),a.aborting=!1),i.log("Testing connection to "+r+" at "+o);var c=e.extend(s.getXHROptions(o),{timeout:s.timeout});c.data=e.extend(c.headers,c.data||{}),delete c.headers;var d=t.ajax(c);
return a.test=d,d.always(function(){a.test=null}),d.done(function(e,t,n){var c=s.parse(e),d=c&&c.machineIdentifier;!d||s.id&&c.machineIdentifier!==s.id?(i.warn(r+" is unavailable at "+o+" (Invalid Response)"),l.reject(s,a,n)):(i.success(r+" is available at "+o),l.resolve(s,a,c,o))}),d.fail(function(e){i.warn(r+" is unavailable at "+o+" (Status "+e.status+")"),l.reject(s,a,e)}),l.promise()}return n}),define("plex/base/commands/server/testServerImageCommand",["jquery","plex/base/adapters/loggerAdapter"],function(e,t){"use strict";
function i(i){var n,s=i.server,a=i.connection,r=s.get("friendlyName"),o=(new Date).getTime(),l=s.resolveUrl("/web/img/blank.png?cb="+o,{connection:a}),c=e.Deferred();t.log("Testing image for "+r+" at "+l);var d=new Image;return d.onload=function(){d.onload=d.onerror=d.onabort=null,n=clearTimeout(n),t.success("Image test for "+r+" was successful. Show mixed content warning."),c.resolve(s,a)},d.onerror=d.onabort=function(){d.onload=d.onerror=d.onabort=null,n=clearTimeout(n),t.warn(r+" is unavailable at "+l),c.reject(s,a)
},n=setTimeout(function(){d.onload=d.onerror=d.onabort=null,d.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",t.warn(r+" is unavailable at "+l+" (Timeout)"),c.reject(s,a)},5e3),d.src=l,c.promise()}return i}),define("plex/base/commands/server/relayServerCommand",["jquery","underscore","plex/base/utils/dispatcher","plex/base/models/appModel"],function(e,t,i,n){"use strict";function s(i){var s=i.server,r=n.get("user"),o="/devices/"+r.id+"/"+s.id+"/relay",l=t.extend(r.server.getXHROptions(o),{type:"POST"}),c=e.ajax(l).promise();
return c=c.then(function(){function t(){s.off("change:connected",i),s.populate().then(r.resolve,r.reject)}function i(e,t){t&&(clearTimeout(n),s.off("change:connected",i),r.resolve())}if(!s.get("connected")){var n,r=e.Deferred();return n=setTimeout(t,a),s.on("change:connected",i),r.promise()}})}var a=1e4;return s}),define("plex/base/commands/user/signInCommand",["jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/formatters/stringUtil","plex/base/models/appModel"],function(e,t,i,n,s){"use strict";
function a(a){var r,o=s.get("user");if(a.username&&a.password){r=o.server.getXHROptions("/users/sign_in.xml"),r.type="POST";var l="Basic "+n.encode64(n.toUtf8(a.username+":"+a.password));r.headers.Authorization=l,c=e.ajax(r)}else r=o.server.getXHROptions("/users/account.xml?auth_token="+a.accessToken),r.type="GET";var c=e.ajax(r);return c.done(function(e){o.switchUser(e,{remember:a.remember})}),c.fail(function(e){var n;n=t(401===e.status&&a.username&&a.password?"The username or password is incorrect.":"There was a problem connecting to Plex."),i.trigger("show:alert",{type:"error",message:n})
}),c.promise()}return a}),define("plex/base/commands/user/signUpCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser","plex/base/adapters/storageAdapter","plex/base/models/appModel"],function(e,t,i,n,s,a,r){"use strict";function o(o){var l=r.get("user"),c=e.pick(o,"username","email","password");o.birthday&&(c.birthday_str=o.birthday.format("YYYY/MM/DD"));var d=l.server.getXHROptions("/users?format=xml");d.type="POST",d.data=c;var u=t.ajax(d);return u.done(function(e){var t=l.parse(e),i=t.accessToken;
l.server.set("accessToken",i),l.set(t),l.resolveServerPromise(),a.set("myPlexAccessToken",i,{session:!o.remember})}),u.fail(function(t){var a;if(422===t.status){var r=t.responseText,o=s.parseXML(r);s.parseArray(o,"error"),a=i(o.error.length?e.first(o.error):"This account information is invalid.")}else a=i("There was a problem connecting to Plex.");n.trigger("show:alert",{type:"error",message:a})}),u.promise()}return o}),define("plex/base/commands/user/signOutCommand",["underscore","jquery","plex/base/utils/dispatcher","plex/base/utils/xhrTracker","plex/base/adapters/loggerAdapter","plex/base/models/config","plex/base/models/appModel"],function(e,t,i,n,s,a,r){"use strict";
function o(o){o||(o={});var l=r.get("user"),c=l.clearAccessToken();return c.fail(function(){s.warn("Failed to clear session and server storage")}).always(function(){var s=r.get("servers"),c=l.server;return a.get("hosted")&&!o.skipHostedRedirect?(window.location="/users/sign_out",t.Deferred().reject().promise()):(n.abortAll(),l.stopListening(),l.clear(),l.set(e.result(l,"defaults")),l.initialize(),c.resetPopulatePromise(t.Deferred()),c.connections=[],c.clear(),c.set(e.result(c,"defaults")),s.reset([c]),i.trigger("clearAll:cache"),c.cache.store(c),r.set({authorized:!1,primaryServer:null,history:[]}),i.trigger("request:disconnect:serverEvents"),void i.trigger("initialize:servers"))
}),c}return o}),define("plex/base/commands/user/switchUserCommand",["jquery","underscore","plex/base/utils/dispatcher","plex/base/adapters/storageAdapter","plex/base/models/appModel","plex/base/models/config","plex/base/models/server/serverStorageModel"],function(e,t,i,n,s,a,r){"use strict";function o(e){var t,i=s.get("user"),n=i.get("signedIn"),a=i.id!==e.homeUser.id;return t=n?l(e):c(e),n&&a?t=t.then(function(e){return d(e)}):t.done(function(){i.set("locked",!1)}),t}function l(i){var n=i.homeUser,r=s.get("user"),o=n.id||r.id,l={pin:i.pin},c="/api/home/users/"+o+"/switch?"+e.param(l,!0),d=t.extend(n.server.getXHROptions(c),{type:"POST",xhrFields:{withCredentials:a.get("hosted")}});
return e.ajax(d).promise()}function c(t){var i=r.getCurrentUser();return i=i.then(function(i){if(!i.pin&&!t.pin)return e.Deferred().resolve().promise();var n=s.get("user"),a=n.hashPIN(t.pin,i.accessToken);return i.pin===a?e.Deferred().resolve().promise():e.Deferred().reject().promise()})}function d(t){var a=e.Deferred(),r=n.get("myPlexAccessToken");return r.always(function(){var e=!1;"resolved"===r.state()&&(e=!0),i.trigger("command","signOut",{skipHostedRedirect:!0},function(n){n.done(function(){var n=s.get("user");
n.switchUser(t,{remember:e}),n.set("locked",!1),i.trigger("home:userswitched",n),a.resolve(n)}),n.fail(function(){a.reject()})})}),a.promise()}return o}),define("plex/base/commands/user/shareCommand",["jquery","underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel"],function(e,t,i,n,s){"use strict";function a(a){var r=s.get("user"),o=[],l={url:a.item.get("url"),message:a.message};t.each(a.networkIDs,function(i){var n="/pms/social/networks/"+i+"/share?"+e.param(l,!0),s=t.extend(r.server.getXHROptions(n),{type:"POST"});
o.push(e.ajax(s))});var c=e.when.apply(e,o);return c.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem sharing this item.")})}),c.promise()}return a}),define("plex/base/commands/user/recommendCommand",["jquery","underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel"],function(e,t,i,n,s){"use strict";function a(a){var r=s.get("user"),o=[],l={url:a.item.get("url"),message:a.message};t.each(a.playlistIDs,function(i){var n="/pms/playlists/"+i+"/items?"+e.param(l,!0),s=t.extend(r.server.getXHROptions(n),{type:"POST"});
o.push(e.ajax(s))});var c=e.when.apply(e,o);return c.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem recommending this item.")})}),c.promise()}return a}),define("plex/base/commands/library/selectStreamCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/mediaUtil"],function(e,t,i,n,s){"use strict";function a(a){var r=t.Deferred(),o=a.item,l=a.media||e.first(o.get("Media")),c=a.part||l&&e.first(l.Part),d=a.streamType,u=a.streamID;
if(!l||!c)return r.reject().promise();var h="/library/parts/"+c.id+"?"+d.key+"="+u,p=e.extend(o.server.getXHROptions(h),{type:"PUT"}),m=t.ajax(p);return m.done(function(){s.selectStream(l,d,u),o.trigger("change:streams"),r.resolve()}),m.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem selecting the stream for this item.")}),r.reject(e)}),r.promise()}return a}),define("plex/base/commands/library/rateCommand",["jquery","plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t,i){"use strict";
function n(n){var s=n.item,a=n.rating,r=s.get("userRating");if(s.set("userRating",a),n.passive)return e.Deferred().resolve().promise();var o={key:s.get("ratingKey"),identifier:s.get("identifier"),rating:a},l="/:/rate?"+e.param(o,!0),c=e.ajax(s.server.getXHROptions(l));return c.fail(function(){s.set("userRating",r),i.trigger("show:alert",{type:"error",message:t("There was a problem rating this item.")})}),c.promise()}return n}),define("plex/base/commands/security/getTransientTokenCommand",["underscore","jquery","plex/base/utils/parser"],function(e,t,i){"use strict";
function n(e){var n=t.Deferred(),s=e.server;if(!s.supports("transientToken"))return n.resolve(s.get("accessToken")).promise();var a={type:e.type||"delegation",scope:e.scope||"all"},r="/security/token?"+t.param(a,!0),o=t.ajax(s.getXHROptions(r));return o.done(function(e){var t=i.parseXML(e);n.resolve(t.token)}),o.fail(function(e){n.reject(e)}),n.promise()}return n}),define("plex/base/commands/commands",["underscore","plex/base/utils/dispatcher","plex/base/commands/server/testServerConnectionCommand","plex/base/commands/server/testServerImageCommand","plex/base/commands/server/relayServerCommand","plex/base/commands/user/signInCommand","plex/base/commands/user/signUpCommand","plex/base/commands/user/signOutCommand","plex/base/commands/user/switchUserCommand","plex/base/commands/user/shareCommand","plex/base/commands/user/recommendCommand","plex/base/commands/library/selectStreamCommand","plex/base/commands/library/rateCommand","plex/base/commands/security/getTransientTokenCommand"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p){"use strict";
var m={map:{testServerConnection:i,testServerImage:n,relayServer:s,signIn:a,signUp:r,signOut:o,switchUser:l,share:c,recommend:d,selectStream:u,rate:h,getTransientToken:p},execute:function(t){var i=m.map;if(i.hasOwnProperty(t))return i[t].apply(m,e.rest(arguments));throw new Error("Bad command "+t)}};return t.on("command",function(t,i,n){var s=m.execute.apply(this,arguments);e.isFunction(n)&&n(s)}),m}),define("plex/desktop/adapters/player/CompanionPlayerManager",["underscore","plex/base/utils/BaseClass","plex/base/utils/playerUtil","plex/base/utils/types/mediaTypes","plex/base/commands/commands","plex/base/mixins/eventMixin","plex/base/adapters/loggerAdapter","plex/base/models/appModel","plex/base/models/server/ServerModel","plex/base/models/library/MetadataModel","plex/base/models/library/MetadataCollection"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";
var u=t.extend({mixins:[a],types:[i.types.VIDEO,i.types.MUSIC,i.types.PHOTO],initialize:function(){this.items={},this.containers={},this.controllers={},this.listenTo(o,"change:primaryPlayer",this.onPrimaryPlayerChange)},start:function(e){r.success("Casting to "+e.get("friendlyName")),this.player=e,e&&this.listenTo(e.get("nowPlaying"),"add",this.onNowPlayingAdd)},stop:function(){if(this.player){r.log("Stopped casting to "+this.player.get("friendlyName"));var t=this.player.get("nowPlaying");t.clear(),this.stopListening(t)
}this.items={},this.containers={},e.each(this.types,this.removeController,this)},addController:function(e){var t=this.controllers[e];return t?(t.references++,t):(t=new this.controller({type:e,manager:this}),this.controllers[e]=t,t)},removeController:function(e){var t=this.controllers[e];t&&--t.references<=0&&(t.stopListening(),this.controllers[e]=null)},updateNowPlaying:function(t){var n=t.type,s=t.key,a=t.state===i.states.STOPPED||t.state===i.states.ERROR,r=this.items[n],o=this.containers[n];if(r){if(s===r.get("key")&&!a)return;
this.removeFromNowPlaying(r,t)}s&&!a&&this.addToNowPlaying(e.extend({},t,{previousItem:r,previousContainer:o}))},addToNowPlaying:function(t){var n=t.type,s=t.machineIdentifier,a=t.key,r=t.containerKey,o=t.previousContainer;"node"===s&&(s="myPlex");var u=new l({machineIdentifier:s},{onlyIfCached:!0});if(!e.isEmpty(u)){if("myPlex"===s){var h=u.parent.get("primaryServer");a=h?h.resolveUrl(a):u.resolveUrl(a,{connection:{address:"node.plexapp.com",port:32400}})}var p=new c({key:a},{server:u,skipCache:!0}),m=p.populate();
if(this.items[n]=p,r&&"myPlex"!==s){var f;if(o&&o.key===r)f=o.playQueue;else{var g=r.match(/playQueues\/(\d+)/),v=p.server.get("playQueueManager"),y=i.getElementByType(n);if(g)f=v.getForType(y),f&&f.get("playQueueID")===g[1]||(f=v.createForType(y,{onServer:!0}),f.set("playQueueID",g[1]),m=m.then(function(){return f.fetch({reset:!0})}));else{var b=new d([],{server:u,skipCache:!0});b.url=r,m=m.then(function(){return b.populate()}),m=m.then(function(){return f=v.createForType(y,{onServer:!1}),f.addContent(b)
})}m.done(function(){var e=f.get("collection").findWhere({key:a});f.set("selectedItem",e)})}this.containers[n]={key:r,playQueue:f}}else this.containers[n]=null;m.done(e.bind(function(){p.set("key",a);var e=this.player.get("nowPlaying");e.add(p)},this)),m.fail(e.bind(function(){this.removeFromNowPlaying(p,t)},this))}},removeFromNowPlaying:function(e,t){this.items[t.type]=null,this.containers[t.type]=null;var i=this.player.get("nowPlaying");i.remove(e)},onPrimaryPlayerChange:function(e,t){t&&t.get("protocol")===this.protocol?this.start(t):this.stop()
},onNowPlayingAdd:function(e){var t=e.get("type");if(t){var a=n.getChildMediaType(t),r=i.getTypeByElement(a.element);this.controllers[r]||s.execute("playMedia",{item:e,useMiniPlayer:!0,isCompanionConnect:!0})}}});return u}),define("plex/base/utils/promiseUtil",["underscore","jquery"],function(e,t){"use strict";function i(e){var i=t.Deferred();return e.done(function(){i.resolve({resolved:!0,args:arguments})}).fail(function(){i.resolve({resolved:!1,args:arguments})}),i.promise()}function n(n){return t.when.apply(t,e.map(n,i))
}function s(i){if(!i.length)return t.Deferred().reject().promise();var n=t.Deferred(),s=i.length;return e.each(i,function(e){e.done(function(){s--,n.resolveWith(this,arguments)}).fail(function(){s--,0===s&&n.reject()})}),n.promise()}var a={toStatePromise:i,whenEach:n,whenFirstSucceed:s};return a}),define("plex/base/adapters/analyticsAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=e.extend({"interface":["enable","disable","set","trackView","trackEvent"],register:function(e){this._Analytics=e
},init:function(e,t){return this._instance=new this._Analytics(e,t),this._instance}});return new t}),define("plex/base/models/sessionStatsModel",["underscore","plex/base/models/StorageModel"],function(e,t){"use strict";var i=t.extend({storageKey:"sessionstats",incPlaybackCount:function(){this.save("playbackCount",this.get("playbackCount")+1)},startSession:function(){var t=(new Date).getTime();this.save({playbackCount:0,startTime:t,heartbeatTime:t}),setInterval(e.bind(function(){this.save("heartbeatTime",(new Date).getTime())
},this),1e4)}});return new i}),define("plex/base/mixins/player/playerControllerMixin",["underscore","jquery","plex/base/utils/playerUtil","plex/base/utils/mediaUtil","plex/base/adapters/analyticsAdapter","plex/base/models/sessionStatsModel"],function(e,t,i,n,s,a){"use strict";var r={playbackDuration:0,modelDefaults:function(){var t=e.omit(this.model.defaults,["item","playQueue","transcodeServer","state","stopped","paused","playing","buffering","error","volume","shuffle","repeat"]);return e.extend(t,{item:this.currentItem,type:this.type,canSkipPrevious:!!this.previousItem,canSkipNext:!!this.nextItem})
},initialize:function(){this.stoppedSessions={},this.stop=e.wrap(this.stop,e.bind(function(e){return!this.model||this.model.get("stopped")?t.Deferred().resolve().promise():e.apply(this,[].slice.call(arguments,1))},this)),this.seekBackward=e.bind(this.seek,this,-15e3,0,0),this.seekForward=e.bind(this.seek,this,3e4,0,3e3),this.stepBackward=e.bind(this.seek,this,-6e5,0,0),this.stepForward=e.bind(this.seek,this,6e5,0,3e3)},request:function(t){return this.pendingRequests||(this.pendingRequests=[]),this.pendingRequests.push(t),t.always(e.bind(function(){var i=e.indexOf(this.pendingRequests,t);
this.pendingRequests.splice(i,1)},this)),t},waitForRequests:function(){return t.when.apply(t,this.pendingRequests)},reset:function(t){return this.currentItem&&(this.timeline({state:i.states.STOPPED,continuing:!0}),this.stopTimeline(),this.stopSession()),this.currentItem=t,this.previousItem=this.getPreviousItem(t),this.nextItem=this.getNextItem(t),this.model.set(e.result(this,"modelDefaults")),t},getPreviousItem:function(e,t){e||(e=this.model.get("item")),t||(t={});var i=this.model.get("playQueue");
if(i=i&&i.get("collection"),!i||!e)return null;var n=i.get(e.id||e.cid),s=i.indexOf(n);return s>0?i.at(s-1):t.loop&&i.length>1?i.at(i.length-1):null},getNextItem:function(e,t){e||(e=this.model.get("item")),t||(t={});var i=this.model.get("playQueue");if(i=i&&i.get("collection"),!i||!e)return null;var n=i.get(e.id||e.cid),s=i.indexOf(n);return s+1<i.length?i.at(s+1):t.loop&&i.length>1?i.at(0):null},mirror:function(){},play:function(){},pause:function(){},playPause:function(){this.model.get("state")===i.states.PAUSED?this.play():this.pause()
},setPosition:function(){},canSeek:function(e){return e!==this.model.get("position")&&e<=this.model.get("duration")&&e>=0},seek:function(e,t,i,n){var s=this.model.get("position")+e,a=0+(t>=0?t:0),r=this.model.get("duration")-(i>=0?i:0);s=Math.max(a,Math.min(s,r)),this.setPosition(s,n)},setVolume:function(){},decreaseVolume:function(){var e=this.model.get("volume");this.setVolume(Math.round(Math.max(e-10,0)))},increaseVolume:function(){var e=this.model.get("volume");this.setVolume(Math.round(Math.min(e+10,100)))
},skipPrevious:function(){return this.previousItem?this.reset(this.previousItem):!1},skipNext:function(){return this.nextItem?this.reset(this.nextItem):!1},skipTo:function(e){var t=this.model.get("playQueue");if(t=t&&t.get("collection"),!t)return!1;var i=t.findWhere({key:e});return this.reset(i)},removeItem:function(e){return this.model.get("playQueue").removeItem(e)},moveItem:function(e,t){return this.model.get("playQueue").moveItem(e,t)},refreshPlayQueue:function(){var e=this.model.get("playQueue");
e&&e.fetch()},stop:function(e){e&&e.silent||this.model.set("state",i.states.STOPPED);var t=this.model.get("item"),n=t.server.get("playQueueManager");if(n){var s=this.model.get("playQueue"),a=n.getFor(t);a&&s&&a===s&&n.remove(s.get("mediaType"))}this.stopListening()},timeline:function(i){return i||(i={}),e.defaults(i,this.model.attributes),this.companion||!i.item?t.Deferred().resolve().promise():this.request(n.timeline(i))},startTimeline:function(){this.companion||this.serverTimelineInterval||(this.serverTimelineInterval=setInterval(e.bind(this.timeline,this),n.serverTimelineDelay))
},stopTimeline:function(){this.serverTimelineInterval=clearInterval(this.serverTimelineInterval),this.trackPlaybackEvent()},updatePlayQueue:function(){var e=this.model.get("playQueue");return e&&e.get("playQueueSelectedItemID")!==this.model.get("item").id?e.fetch():t.Deferred().resolve().promise()},ping:function(){return this.companion?t.Deferred().resolve().promise():this.request(n.ping(this.model.get("transcodeServer"),this.session))},startPing:function(){var t=this.model.get("directPlay"),s=!this.companion&&this.type!==i.types.PHOTO;
!s||t||this.pingInterval||(this.pingInterval=setInterval(e.bind(this.ping,this),n.pingDelay))},stopPing:function(){this.pingInterval=clearInterval(this.pingInterval)},stopSession:function(s){var a=this.session,r=a||e.uniqueId("no-session-"),o=s&&s.xhrOptions||{};if(this.stoppedSessions.hasOwnProperty(r))return this.stoppedSessions[r];this.subcontroller&&this.subcontroller.stop(s);var l;return l=a&&this.type!==i.types.PHOTO&&!this.model.get("directPlay")?this.request(n.stop(this.model.get("transcodeServer"),a,o)):t.Deferred().resolve().promise(),this.stoppedSessions[r]=l,l
},startPlaybackTracking:function(){this.companion||this.playbackInterval||(this.playbackInterval=setInterval(e.bind(function(){this.playbackDuration++},this),n.playbackDelay))},stopPlaybackTracking:function(){this.playbackInterval=clearInterval(this.playbackInterval)},trackPlaybackEvent:function(){if(!this.companion){a.incPlaybackCount();var e=this.model.get("item"),t=e.get("identifier");!t&&e.parent&&(t=e.parent.get("identifier")),s.trackEvent({eventCategory:"Playback",eventAction:e.get("type"),eventLabel:t,eventValue:this.playbackDuration}),this.playbackDuration=0
}}};return r});var Handlebars=function(){var e=function(){"use strict";function e(e){this.string=e}var t;return e.prototype.toString=function(){return""+this.string},t=e}(),t=function(e){"use strict";function t(e){return o[e]||"&amp;"}function i(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])}function n(e){return e instanceof r?e.toString():e||0===e?(e=""+e,c.test(e)?e.replace(l,t):e):""}function s(e){return e||0===e?h(e)&&0===e.length?!0:!1:!0}var a={},r=e,o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},l=/[&<>"'`]/g,c=/[&<>"'`]/;
a.extend=i;var d=Object.prototype.toString;a.toString=d;var u=function(e){return"function"==typeof e};u(/x/)&&(u=function(e){return"function"==typeof e&&"[object Function]"===d.call(e)});var u;a.isFunction=u;var h=Array.isArray||function(e){return e&&"object"==typeof e?"[object Array]"===d.call(e):!1};return a.isArray=h,a.escapeExpression=n,a.isEmpty=s,a}(e),i=function(){"use strict";function e(){for(var e=Error.prototype.constructor.apply(this,arguments),t=0;t<i.length;t++)this[i[t]]=e[i[t]]}var t,i=["description","fileName","lineNumber","message","name","number","stack"];
return e.prototype=new Error,t=e}(),n=function(e,t){"use strict";function i(e,t){this.helpers=e||{},this.partials=t||{},n(this)}function n(e){e.registerHelper("helperMissing",function(e){if(2===arguments.length)return void 0;throw new Error("Missing helper: '"+e+"'")}),e.registerHelper("blockHelperMissing",function(t,i){var n=i.inverse||function(){},s=i.fn;return h(t)&&(t=t.call(this)),t===!0?s(this):t===!1||null==t?n(this):u(t)?t.length>0?e.helpers.each(t,i):n(this):s(t)}),e.registerHelper("each",function(e,t){var i,n=t.fn,s=t.inverse,a=0,r="";
if(h(e)&&(e=e.call(this)),t.data&&(i=g(t.data)),e&&"object"==typeof e)if(u(e))for(var o=e.length;o>a;a++)i&&(i.index=a,i.first=0===a,i.last=a===e.length-1),r+=n(e[a],{data:i});else for(var l in e)e.hasOwnProperty(l)&&(i&&(i.key=l),r+=n(e[l],{data:i}),a++);return 0===a&&(r=s(this)),r}),e.registerHelper("if",function(e,t){return h(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||r.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,i){return e.helpers["if"].call(this,t,{fn:i.inverse,inverse:i.fn,hash:i.hash})
}),e.registerHelper("with",function(e,t){return h(e)&&(e=e.call(this)),r.isEmpty(e)?void 0:t.fn(e)}),e.registerHelper("log",function(t,i){var n=i.data&&null!=i.data.level?parseInt(i.data.level,10):1;e.log(n,t)})}function s(e,t){f.log(e,t)}var a={},r=e,o=t,l="1.1.2";a.VERSION=l;var c=4;a.COMPILER_REVISION=c;var d={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:">= 1.0.0"};a.REVISION_CHANGES=d;var u=r.isArray,h=r.isFunction,p=r.toString,m="[object Object]";a.HandlebarsEnvironment=i,i.prototype={constructor:i,logger:f,log:s,registerHelper:function(e,t,i){if(p.call(e)===m){if(i||t)throw new o("Arg not supported with multiple helpers");
r.extend(this.helpers,e)}else i&&(t.not=i),this.helpers[e]=t},registerPartial:function(e,t){p.call(e)===m?r.extend(this.partials,e):this.partials[e]=t}};var f={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(e,t){if(f.level<=e){var i=f.methodMap[e];"undefined"!=typeof console&&console[i]&&console[i].call(console,t)}}};a.logger=f,a.log=s;var g=function(e){var t={};return r.extend(t,e),t};return a.createFrame=g,a}(t,i),s=function(e,t,i){"use strict";
function n(e){var t=e&&e[0]||1,i=h;if(t!==i){if(i>t){var n=p[i],s=p[t];throw new Error("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+n+") or downgrade your runtime to an older version ("+s+").")}throw new Error("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}}function s(e,t){if(!t)throw new Error("No environment passed to template");
var i;i=t.compile?function(e,i,n,s,a,r){var l=o.apply(this,arguments);if(l)return l;var c={helpers:s,partials:a,data:r};return a[i]=t.compile(e,{data:void 0!==r},t),a[i](n,c)}:function(e,t){var i=o.apply(this,arguments);if(i)return i;throw new u("The partial "+t+" could not be compiled when running in runtime-only mode")};var s={escapeExpression:d.escapeExpression,invokePartial:i,programs:[],program:function(e,t,i){var n=this.programs[e];return i?n=r(e,t,i):n||(n=this.programs[e]=r(e,t)),n},merge:function(e,t){var i=e||t;
return e&&t&&e!==t&&(i={},d.extend(i,t),d.extend(i,e)),i},programWithDepth:a,noop:l,compilerInfo:null};return function(i,a){a=a||{};var r,o,l=a.partial?a:t;a.partial||(r=a.helpers,o=a.partials);var c=e.call(s,l,i,r,o,a.data);return a.partial||n(s.compilerInfo),c}}function a(e,t,i){var n=Array.prototype.slice.call(arguments,3),s=function(e,s){return s=s||{},t.apply(this,[e,s.data||i].concat(n))};return s.program=e,s.depth=n.length,s}function r(e,t,i){var n=function(e,n){return n=n||{},t(e,n.data||i)
};return n.program=e,n.depth=0,n}function o(e,t,i,n,s,a){var r={partial:!0,helpers:n,partials:s,data:a};if(void 0===e)throw new u("The partial "+t+" could not be found");return e instanceof Function?e(i,r):void 0}function l(){return""}var c={},d=e,u=t,h=i.COMPILER_REVISION,p=i.REVISION_CHANGES;return c.template=s,c.programWithDepth=a,c.program=r,c.invokePartial=o,c.noop=l,c}(t,i,n),a=function(e,t,i,n,s){"use strict";var a,r=e,o=t,l=i,c=n,d=s,u=function(){var e=new r.HandlebarsEnvironment;return c.extend(e,r),e.SafeString=o,e.Exception=l,e.Utils=c,e.VM=d,e.template=function(t){return d.template(t,e)
},e},h=u();return h.create=u,a=h}(n,e,i,t,s),r=function(e){"use strict";function t(e,i,n){this.type="program",this.statements=e,this.strip={},n?(this.inverse=new t(n,i),this.strip.right=i.left):i&&(this.strip.left=i.right)}function i(e,t,i,n){this.type="mustache",this.hash=t,this.strip=n;var s=i[3]||i[2];this.escaped="{"!==s&&"&"!==s;var a=this.id=e[0],r=this.params=e.slice(1),o=this.eligibleHelper=a.isSimple;this.isHelper=o&&(r.length||t)}function n(e,t,i){this.type="partial",this.partialName=e,this.context=t,this.strip=i
}function s(e,t,i,n){if(e.id.original!==n.path.original)throw new f(e.id.original+" doesn't match "+n.path.original);this.type="block",this.mustache=e,this.program=t,this.inverse=i,this.strip={left:e.strip.left,right:n.strip.right},(t||i).strip.left=e.strip.right,(i||t).strip.right=n.strip.left,i&&!t&&(this.isInverse=!0)}function a(e){this.type="content",this.string=e}function r(e){this.type="hash",this.pairs=e}function o(e){this.type="ID";for(var t="",i=[],n=0,s=0,a=e.length;a>s;s++){var r=e[s].part;
if(t+=(e[s].separator||"")+r,".."===r||"."===r||"this"===r){if(i.length>0)throw new f("Invalid path: "+t);".."===r?n++:this.isScoped=!0}else i.push(r)}this.original=t,this.parts=i,this.string=i.join("."),this.depth=n,this.isSimple=1===e.length&&!this.isScoped&&0===n,this.stringModeValue=this.string}function l(e){this.type="PARTIAL_NAME",this.name=e.original}function c(e){this.type="DATA",this.id=e}function d(e){this.type="STRING",this.original=this.string=this.stringModeValue=e}function u(e){this.type="INTEGER",this.original=this.integer=e,this.stringModeValue=Number(e)
}function h(e){this.type="BOOLEAN",this.bool=e,this.stringModeValue="true"===e}function p(e){this.type="comment",this.comment=e}var m={},f=e;return m.ProgramNode=t,m.MustacheNode=i,m.PartialNode=n,m.BlockNode=s,m.ContentNode=a,m.HashNode=r,m.IdNode=o,m.PartialNameNode=l,m.DataNode=c,m.StringNode=d,m.IntegerNode=u,m.BooleanNode=h,m.CommentNode=p,m}(i),o=function(){"use strict";var e,t=function(){function e(e,t){return{left:"~"===e[2],right:"~"===t[0]||"~"===t[1]}}function t(){this.yy={}}var i={trace:function(){},yy:{},symbols_:{error:2,root:3,statements:4,EOF:5,program:6,simpleInverse:7,statement:8,openInverse:9,closeBlock:10,openBlock:11,mustache:12,partial:13,CONTENT:14,COMMENT:15,OPEN_BLOCK:16,inMustache:17,CLOSE:18,OPEN_INVERSE:19,OPEN_ENDBLOCK:20,path:21,OPEN:22,OPEN_UNESCAPED:23,CLOSE_UNESCAPED:24,OPEN_PARTIAL:25,partialName:26,partial_option0:27,inMustache_repetition0:28,inMustache_option0:29,dataName:30,param:31,STRING:32,INTEGER:33,BOOLEAN:34,hash:35,hash_repetition_plus0:36,hashSegment:37,ID:38,EQUALS:39,DATA:40,pathSegments:41,SEP:42,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",32:"STRING",33:"INTEGER",34:"BOOLEAN",38:"ID",39:"EQUALS",40:"DATA",42:"SEP"},productions_:[0,[3,2],[3,1],[6,2],[6,3],[6,2],[6,1],[6,1],[6,0],[4,1],[4,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,4],[7,2],[17,3],[17,1],[31,1],[31,1],[31,1],[31,1],[31,1],[35,1],[37,3],[26,1],[26,1],[26,1],[30,2],[21,1],[41,3],[41,1],[27,0],[27,1],[28,0],[28,2],[29,0],[29,1],[36,1],[36,2]],performAction:function(t,i,n,s,a,r){var o=r.length-1;
switch(a){case 1:return new s.ProgramNode(r[o-1]);case 2:return new s.ProgramNode([]);case 3:this.$=new s.ProgramNode([],r[o-1],r[o]);break;case 4:this.$=new s.ProgramNode(r[o-2],r[o-1],r[o]);break;case 5:this.$=new s.ProgramNode(r[o-1],r[o],[]);break;case 6:this.$=new s.ProgramNode(r[o]);break;case 7:this.$=new s.ProgramNode([]);break;case 8:this.$=new s.ProgramNode([]);break;case 9:this.$=[r[o]];break;case 10:r[o-1].push(r[o]),this.$=r[o-1];break;case 11:this.$=new s.BlockNode(r[o-2],r[o-1].inverse,r[o-1],r[o]);
break;case 12:this.$=new s.BlockNode(r[o-2],r[o-1],r[o-1].inverse,r[o]);break;case 13:this.$=r[o];break;case 14:this.$=r[o];break;case 15:this.$=new s.ContentNode(r[o]);break;case 16:this.$=new s.CommentNode(r[o]);break;case 17:this.$=new s.MustacheNode(r[o-1][0],r[o-1][1],r[o-2],e(r[o-2],r[o]));break;case 18:this.$=new s.MustacheNode(r[o-1][0],r[o-1][1],r[o-2],e(r[o-2],r[o]));break;case 19:this.$={path:r[o-1],strip:e(r[o-2],r[o])};break;case 20:this.$=new s.MustacheNode(r[o-1][0],r[o-1][1],r[o-2],e(r[o-2],r[o]));
break;case 21:this.$=new s.MustacheNode(r[o-1][0],r[o-1][1],r[o-2],e(r[o-2],r[o]));break;case 22:this.$=new s.PartialNode(r[o-2],r[o-1],e(r[o-3],r[o]));break;case 23:this.$=e(r[o-1],r[o]);break;case 24:this.$=[[r[o-2]].concat(r[o-1]),r[o]];break;case 25:this.$=[[r[o]],null];break;case 26:this.$=r[o];break;case 27:this.$=new s.StringNode(r[o]);break;case 28:this.$=new s.IntegerNode(r[o]);break;case 29:this.$=new s.BooleanNode(r[o]);break;case 30:this.$=r[o];break;case 31:this.$=new s.HashNode(r[o]);
break;case 32:this.$=[r[o-2],r[o]];break;case 33:this.$=new s.PartialNameNode(r[o]);break;case 34:this.$=new s.PartialNameNode(new s.StringNode(r[o]));break;case 35:this.$=new s.PartialNameNode(new s.IntegerNode(r[o]));break;case 36:this.$=new s.DataNode(r[o]);break;case 37:this.$=new s.IdNode(r[o]);break;case 38:r[o-2].push({part:r[o],separator:r[o-1]}),this.$=r[o-2];break;case 39:this.$=[{part:r[o]}];break;case 42:this.$=[];break;case 43:r[o-1].push(r[o]);break;case 46:this.$=[r[o]];break;case 47:r[o-1].push(r[o])
}},table:[{3:1,4:2,5:[1,3],8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[3]},{5:[1,16],8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[2,2]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{4:20,6:18,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{4:20,6:22,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{17:23,21:24,30:25,38:[1,28],40:[1,27],41:26},{17:29,21:24,30:25,38:[1,28],40:[1,27],41:26},{17:30,21:24,30:25,38:[1,28],40:[1,27],41:26},{17:31,21:24,30:25,38:[1,28],40:[1,27],41:26},{21:33,26:32,32:[1,34],33:[1,35],38:[1,28],41:26},{1:[2,1]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{10:36,20:[1,37]},{4:38,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,7],22:[1,13],23:[1,14],25:[1,15]},{7:39,8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,6],22:[1,13],23:[1,14],25:[1,15]},{17:23,18:[1,40],21:24,30:25,38:[1,28],40:[1,27],41:26},{10:41,20:[1,37]},{18:[1,42]},{18:[2,42],24:[2,42],28:43,32:[2,42],33:[2,42],34:[2,42],38:[2,42],40:[2,42]},{18:[2,25],24:[2,25]},{18:[2,37],24:[2,37],32:[2,37],33:[2,37],34:[2,37],38:[2,37],40:[2,37],42:[1,44]},{21:45,38:[1,28],41:26},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],38:[2,39],40:[2,39],42:[2,39]},{18:[1,46]},{18:[1,47]},{24:[1,48]},{18:[2,40],21:50,27:49,38:[1,28],41:26},{18:[2,33],38:[2,33]},{18:[2,34],38:[2,34]},{18:[2,35],38:[2,35]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{21:51,38:[1,28],41:26},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,3],22:[1,13],23:[1,14],25:[1,15]},{4:52,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,5],22:[1,13],23:[1,14],25:[1,15]},{14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]},{18:[2,44],21:56,24:[2,44],29:53,30:60,31:54,32:[1,57],33:[1,58],34:[1,59],35:55,36:61,37:62,38:[1,63],40:[1,27],41:26},{38:[1,64]},{18:[2,36],24:[2,36],32:[2,36],33:[2,36],34:[2,36],38:[2,36],40:[2,36]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,65]},{18:[2,41]},{18:[1,66]},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],25:[1,15]},{18:[2,24],24:[2,24]},{18:[2,43],24:[2,43],32:[2,43],33:[2,43],34:[2,43],38:[2,43],40:[2,43]},{18:[2,45],24:[2,45]},{18:[2,26],24:[2,26],32:[2,26],33:[2,26],34:[2,26],38:[2,26],40:[2,26]},{18:[2,27],24:[2,27],32:[2,27],33:[2,27],34:[2,27],38:[2,27],40:[2,27]},{18:[2,28],24:[2,28],32:[2,28],33:[2,28],34:[2,28],38:[2,28],40:[2,28]},{18:[2,29],24:[2,29],32:[2,29],33:[2,29],34:[2,29],38:[2,29],40:[2,29]},{18:[2,30],24:[2,30],32:[2,30],33:[2,30],34:[2,30],38:[2,30],40:[2,30]},{18:[2,31],24:[2,31],37:67,38:[1,68]},{18:[2,46],24:[2,46],38:[2,46]},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],38:[2,39],39:[1,69],40:[2,39],42:[2,39]},{18:[2,38],24:[2,38],32:[2,38],33:[2,38],34:[2,38],38:[2,38],40:[2,38],42:[2,38]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{18:[2,47],24:[2,47],38:[2,47]},{39:[1,69]},{21:56,30:60,31:70,32:[1,57],33:[1,58],34:[1,59],38:[1,28],40:[1,27],41:26},{18:[2,32],24:[2,32],38:[2,32]}],defaultActions:{3:[2,2],16:[2,1],50:[2,41]},parseError:function(e){throw new Error(e)
},parse:function(e){function t(){var e;return e=i.lexer.lex()||1,"number"!=typeof e&&(e=i.symbols_[e]||e),e}var i=this,n=[0],s=[null],a=[],r=this.table,o="",l=0,c=0,d=0;this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;a.push(u);var h=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var p,m,f,g,v,y,b,w,x,k={};;){if(f=n[n.length-1],this.defaultActions[f]?g=this.defaultActions[f]:((null===p||"undefined"==typeof p)&&(p=t()),g=r[f]&&r[f][p]),"undefined"==typeof g||!g.length||!g[0]){var S="";
if(!d){x=[];for(y in r[f])this.terminals_[y]&&y>2&&x.push("'"+this.terminals_[y]+"'");S=this.lexer.showPosition?"Parse error on line "+(l+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(l+1)+": Unexpected "+(1==p?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(S,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:u,expected:x})}}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+f+", token: "+p);
switch(g[0]){case 1:n.push(p),s.push(this.lexer.yytext),a.push(this.lexer.yylloc),n.push(g[1]),p=null,m?(p=m,m=null):(c=this.lexer.yyleng,o=this.lexer.yytext,l=this.lexer.yylineno,u=this.lexer.yylloc,d>0&&d--);break;case 2:if(b=this.productions_[g[1]][1],k.$=s[s.length-b],k._$={first_line:a[a.length-(b||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(b||1)].first_column,last_column:a[a.length-1].last_column},h&&(k._$.range=[a[a.length-(b||1)].range[0],a[a.length-1].range[1]]),v=this.performAction.call(k,o,c,l,this.yy,g[1],s,a),"undefined"!=typeof v)return v;
b&&(n=n.slice(0,-1*b*2),s=s.slice(0,-1*b),a=a.slice(0,-1*b)),n.push(this.productions_[g[1]][0]),s.push(k.$),a.push(k._$),w=r[n[n.length-2]][n[n.length-1]],n.push(w);break;case 3:return!0}}return!0}},n=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this
},input:function(){var e=this._input[0];this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e;var t=e.match(/(?:\r\n?|\n).*/g);return t?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,i=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);
this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===n.length?this.yylloc.first_column:0)+n[n.length-i.length].length-i[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-t]),this},more:function(){return this._more=!0,this
},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;
this._input||(this.done=!0);var e,t,i,n,s;this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),r=0;r<a.length&&(i=this._input.match(this.rules[a[r]]),!i||t&&!(i[0].length>t[0].length)||(t=i,n=r,this.options.flex));r++);return t?(s=t[0].match(/(?:\r\n?|\n).*/g),s&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],e=this.performAction.call(this,this.yy,this,a[n],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e?e:void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})
},lex:function(){var e=this.next();return"undefined"!=typeof e?e:this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(e){this.begin(e)}};return e.options={},e.performAction=function(e,t,i,n){function s(e,i){return t.yytext=t.yytext.substr(e,t.yyleng-i)
}switch(i){case 0:if("\\\\"===t.yytext.slice(-2)?(s(0,1),this.begin("mu")):"\\"===t.yytext.slice(-1)?(s(0,1),this.begin("emu")):this.begin("mu"),t.yytext)return 14;break;case 1:return 14;case 2:return"\\"!==t.yytext.slice(-1)&&this.popState(),"\\"===t.yytext.slice(-1)&&s(0,1),14;case 3:return s(0,4),this.popState(),15;case 4:return 25;case 5:return 16;case 6:return 20;case 7:return 19;case 8:return 19;case 9:return 23;case 10:return 22;case 11:this.popState(),this.begin("com");break;case 12:return s(3,5),this.popState(),15;
case 13:return 22;case 14:return 39;case 15:return 38;case 16:return 38;case 17:return 42;case 18:break;case 19:return this.popState(),24;case 20:return this.popState(),18;case 21:return t.yytext=s(1,2).replace(/\\"/g,'"'),32;case 22:return t.yytext=s(1,2).replace(/\\'/g,"'"),32;case 23:return 40;case 24:return 34;case 25:return 34;case 26:return 33;case 27:return 38;case 28:return t.yytext=s(1,2),38;case 29:return"INVALID";case 30:return 5}},e.rules=[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s])))/,/^(?:false(?=([~}\s])))/,/^(?:-?[0-9]+(?=([~}\s])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/],e.conditions={mu:{rules:[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[3],inclusive:!1},INITIAL:{rules:[0,1,30],inclusive:!0}},e
}();return i.lexer=n,t.prototype=i,i.Parser=t,new t}();return e=t}(),l=function(e,t){"use strict";function i(e){return e.constructor===a.ProgramNode?e:(s.yy=a,s.parse(e))}var n={},s=e,a=t;return n.parser=s,n.parse=i,n}(o,r),c=function(e){"use strict";function t(e){this.value=e}function i(){}var n,s=e.COMPILER_REVISION,a=e.REVISION_CHANGES,r=e.log;i.prototype={nameLookup:function(e,t){var n,s;return 0===e.indexOf("depth")&&(n=!0),s=/^[0-9]+$/.test(t)?e+"["+t+"]":i.isValidJavaScriptVariableName(t)?e+"."+t:e+"['"+t+"']",n?"("+e+" && "+s+")":s
},appendToBuffer:function(e){return this.environment.isSimple?"return "+e+";":{appendToBuffer:!0,content:e,toString:function(){return"buffer += "+e+";"}}},initializeBuffer:function(){return this.quotedString("")},namespace:"Handlebars",compile:function(e,t,i,n){this.environment=e,this.options=t||{},r("debug",this.environment.disassemble()+"\n\n"),this.name=this.environment.name,this.isChild=!!i,this.context=i||{programs:[],environments:[],aliases:{}},this.preamble(),this.stackSlot=0,this.stackVars=[],this.registers={list:[]},this.compileStack=[],this.inlineStack=[],this.compileChildren(e,t);
var s,a=e.opcodes;this.i=0;for(var o=a.length;this.i<o;this.i++)s=a[this.i],"DECLARE"===s.opcode?this[s.name]=s.value:this[s.opcode].apply(this,s.args),s.opcode!==this.stripNext&&(this.stripNext=!1);return this.pushSource(""),this.createFunctionContext(n)},preamble:function(){var e=[];if(this.isChild)e.push("");else{var t=this.namespace,i="helpers = this.merge(helpers, "+t+".helpers);";this.environment.usePartial&&(i=i+" partials = this.merge(partials, "+t+".partials);"),this.options.data&&(i+=" data = data || {};"),e.push(i)
}e.push(this.environment.isSimple?"":", buffer = "+this.initializeBuffer()),this.lastContext=0,this.source=e},createFunctionContext:function(e){var t=this.stackVars.concat(this.registers.list);if(t.length>0&&(this.source[1]=this.source[1]+", "+t.join(", ")),!this.isChild)for(var i in this.context.aliases)this.context.aliases.hasOwnProperty(i)&&(this.source[1]=this.source[1]+", "+i+"="+this.context.aliases[i]);this.source[1]&&(this.source[1]="var "+this.source[1].substring(2)+";"),this.isChild||(this.source[1]+="\n"+this.context.programs.join("\n")+"\n"),this.environment.isSimple||this.pushSource("return buffer;");
for(var n=this.isChild?["depth0","data"]:["Handlebars","depth0","helpers","partials","data"],o=0,l=this.environment.depths.list.length;l>o;o++)n.push("depth"+this.environment.depths.list[o]);var c=this.mergeSource();if(!this.isChild){var d=s,u=a[d];c="this.compilerInfo = ["+d+",'"+u+"'];\n"+c}if(e)return n.push(c),Function.apply(this,n);var h="function "+(this.name||"")+"("+n.join(",")+") {\n  "+c+"}";return r("debug",h+"\n\n"),h},mergeSource:function(){for(var e,t="",i=0,n=this.source.length;n>i;i++){var s=this.source[i];
s.appendToBuffer?e=e?e+"\n    + "+s.content:s.content:(e&&(t+="buffer += "+e+";\n  ",e=void 0),t+=s+"\n  ")}return t},blockValue:function(){this.context.aliases.blockHelperMissing="helpers.blockHelperMissing";var e=["depth0"];this.setupParams(0,e),this.replaceStack(function(t){return e.splice(1,0,t),"blockHelperMissing.call("+e.join(", ")+")"})},ambiguousBlockValue:function(){this.context.aliases.blockHelperMissing="helpers.blockHelperMissing";var e=["depth0"];this.setupParams(0,e);var t=this.topStack();
e.splice(1,0,t),e[e.length-1]="options",this.pushSource("if (!"+this.lastHelper+") { "+t+" = blockHelperMissing.call("+e.join(", ")+"); }")},appendContent:function(e){this.pendingContent&&(e=this.pendingContent+e),this.stripNext&&(e=e.replace(/^\s+/,"")),this.pendingContent=e},strip:function(){this.pendingContent&&(this.pendingContent=this.pendingContent.replace(/\s+$/,"")),this.stripNext="strip"},append:function(){this.flushInline();var e=this.popStack();this.pushSource("if("+e+" || "+e+" === 0) { "+this.appendToBuffer(e)+" }"),this.environment.isSimple&&this.pushSource("else { "+this.appendToBuffer("''")+" }")
},appendEscaped:function(){this.context.aliases.escapeExpression="this.escapeExpression",this.pushSource(this.appendToBuffer("escapeExpression("+this.popStack()+")"))},getContext:function(e){this.lastContext!==e&&(this.lastContext=e)},lookupOnContext:function(e){this.push(this.nameLookup("depth"+this.lastContext,e,"context"))},pushContext:function(){this.pushStackLiteral("depth"+this.lastContext)},resolvePossibleLambda:function(){this.context.aliases.functionType='"function"',this.replaceStack(function(e){return"typeof "+e+" === functionType ? "+e+".apply(depth0) : "+e
})},lookup:function(e){this.replaceStack(function(t){return t+" == null || "+t+" === false ? "+t+" : "+this.nameLookup(t,e,"context")})},lookupData:function(){this.push("data")},pushStringParam:function(e,t){this.pushStackLiteral("depth"+this.lastContext),this.pushString(t),"string"==typeof e?this.pushString(e):this.pushStackLiteral(e)},emptyHash:function(){this.pushStackLiteral("{}"),this.options.stringParams&&(this.register("hashTypes","{}"),this.register("hashContexts","{}"))},pushHash:function(){this.hash={values:[],types:[],contexts:[]}
},popHash:function(){var e=this.hash;this.hash=void 0,this.options.stringParams&&(this.register("hashContexts","{"+e.contexts.join(",")+"}"),this.register("hashTypes","{"+e.types.join(",")+"}")),this.push("{\n    "+e.values.join(",\n    ")+"\n  }")},pushString:function(e){this.pushStackLiteral(this.quotedString(e))},push:function(e){return this.inlineStack.push(e),e},pushLiteral:function(e){this.pushStackLiteral(e)},pushProgram:function(e){this.pushStackLiteral(null!=e?this.programExpression(e):null)
},invokeHelper:function(e,t){this.context.aliases.helperMissing="helpers.helperMissing";var i=this.lastHelper=this.setupHelper(e,t,!0),n=this.nameLookup("depth"+this.lastContext,t,"context");this.push(i.name+" || "+n),this.replaceStack(function(e){return e+" ? "+e+".call("+i.callParams+") : helperMissing.call("+i.helperMissingParams+")"})},invokeKnownHelper:function(e,t){var i=this.setupHelper(e,t);this.push(i.name+".call("+i.callParams+")")},invokeAmbiguous:function(e,t){this.context.aliases.functionType='"function"',this.pushStackLiteral("{}");
var i=this.setupHelper(0,e,t),n=this.lastHelper=this.nameLookup("helpers",e,"helper"),s=this.nameLookup("depth"+this.lastContext,e,"context"),a=this.nextStack();this.pushSource("if ("+a+" = "+n+") { "+a+" = "+a+".call("+i.callParams+"); }"),this.pushSource("else { "+a+" = "+s+"; "+a+" = typeof "+a+" === functionType ? "+a+".call("+i.callParams+") : "+a+"; }")},invokePartial:function(e){var t=[this.nameLookup("partials",e,"partial"),"'"+e+"'",this.popStack(),"helpers","partials"];this.options.data&&t.push("data"),this.context.aliases.self="this",this.push("self.invokePartial("+t.join(", ")+")")
},assignToHash:function(e){var t,i,n=this.popStack();this.options.stringParams&&(i=this.popStack(),t=this.popStack());var s=this.hash;t&&s.contexts.push("'"+e+"': "+t),i&&s.types.push("'"+e+"': "+i),s.values.push("'"+e+"': ("+n+")")},compiler:i,compileChildren:function(e,t){for(var i,n,s=e.children,a=0,r=s.length;r>a;a++){i=s[a],n=new this.compiler;var o=this.matchExistingProgram(i);null==o?(this.context.programs.push(""),o=this.context.programs.length,i.index=o,i.name="program"+o,this.context.programs[o]=n.compile(i,t,this.context),this.context.environments[o]=i):(i.index=o,i.name="program"+o)
}},matchExistingProgram:function(e){for(var t=0,i=this.context.environments.length;i>t;t++){var n=this.context.environments[t];if(n&&n.equals(e))return t}},programExpression:function(e){if(this.context.aliases.self="this",null==e)return"self.noop";for(var t,i=this.environment.children[e],n=i.depths.list,s=[i.index,i.name,"data"],a=0,r=n.length;r>a;a++)t=n[a],s.push(1===t?"depth0":"depth"+(t-1));return(0===n.length?"self.program(":"self.programWithDepth(")+s.join(", ")+")"},register:function(e,t){this.useRegister(e),this.pushSource(e+" = "+t+";")
},useRegister:function(e){this.registers[e]||(this.registers[e]=!0,this.registers.list.push(e))},pushStackLiteral:function(e){return this.push(new t(e))},pushSource:function(e){this.pendingContent&&(this.source.push(this.appendToBuffer(this.quotedString(this.pendingContent))),this.pendingContent=void 0),e&&this.source.push(e)},pushStack:function(e){this.flushInline();var t=this.incrStack();return e&&this.pushSource(t+" = "+e+";"),this.compileStack.push(t),t},replaceStack:function(e){var i,n="",s=this.isInline();
if(s){var a=this.popStack(!0);if(a instanceof t)i=a.value;else{var r=this.stackSlot?this.topStackName():this.incrStack();n="("+this.push(r)+" = "+a+"),",i=this.topStack()}}else i=this.topStack();var o=e.call(this,i);return s?((this.inlineStack.length||this.compileStack.length)&&this.popStack(),this.push("("+n+o+")")):(/^stack/.test(i)||(i=this.nextStack()),this.pushSource(i+" = ("+n+o+");")),i},nextStack:function(){return this.pushStack()},incrStack:function(){return this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()
},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;if(e.length){this.inlineStack=[];for(var i=0,n=e.length;n>i;i++){var s=e[i];s instanceof t?this.compileStack.push(s):this.pushStack(s)}}},isInline:function(){return this.inlineStack.length},popStack:function(e){var i=this.isInline(),n=(i?this.inlineStack:this.compileStack).pop();return!e&&n instanceof t?n.value:(i||this.stackSlot--,n)},topStack:function(e){var i=this.isInline()?this.inlineStack:this.compileStack,n=i[i.length-1];
return!e&&n instanceof t?n.value:n},quotedString:function(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")+'"'},setupHelper:function(e,t,i){var n=[];this.setupParams(e,n,i);var s=this.nameLookup("helpers",t,"helper");return{params:n,name:s,callParams:["depth0"].concat(n).join(", "),helperMissingParams:i&&["depth0",this.quotedString(t)].concat(n).join(", ")}},setupParams:function(e,t,i){var n,s,a,r=[],o=[],l=[];
r.push("hash:"+this.popStack()),s=this.popStack(),a=this.popStack(),(a||s)&&(a||(this.context.aliases.self="this",a="self.noop"),s||(this.context.aliases.self="this",s="self.noop"),r.push("inverse:"+s),r.push("fn:"+a));for(var c=0;e>c;c++)n=this.popStack(),t.push(n),this.options.stringParams&&(l.push(this.popStack()),o.push(this.popStack()));return this.options.stringParams&&(r.push("contexts:["+o.join(",")+"]"),r.push("types:["+l.join(",")+"]"),r.push("hashContexts:hashContexts"),r.push("hashTypes:hashTypes")),this.options.data&&r.push("data:data"),r="{"+r.join(",")+"}",i?(this.register("options",r),t.push("options")):t.push(r),t.join(", ")
}};for(var o="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" "),l=i.RESERVED_WORDS={},c=0,d=o.length;d>c;c++)l[o[c]]=!0;return i.isValidJavaScriptVariableName=function(e){return!i.RESERVED_WORDS[e]&&/^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(e)?!0:!1
},n=i}(n),d=function(e,t,i,n){"use strict";function s(){}function a(e,t){if(null==e||"string"!=typeof e&&e.constructor!==u.ProgramNode)throw new l("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+e);t=t||{},"data"in t||(t.data=!0);var i=c(e),n=(new s).compile(i,t);return(new d).compile(n,t)}function r(e,t,i){function n(){var n=c(e),a=(new s).compile(n,t),r=(new d).compile(a,t,void 0,!0);return i.template(r)}if(null==e||"string"!=typeof e&&e.constructor!==u.ProgramNode)throw new l("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+e);
t=t||{},"data"in t||(t.data=!0);var a;return function(e,t){return a||(a=n()),a.call(this,e,t)}}var o={},l=e,c=t.parse,d=i,u=n;return o.Compiler=s,s.prototype={compiler:s,disassemble:function(){for(var e,t,i,n=this.opcodes,s=[],a=0,r=n.length;r>a;a++)if(e=n[a],"DECLARE"===e.opcode)s.push("DECLARE "+e.name+"="+e.value);else{t=[];for(var o=0;o<e.args.length;o++)i=e.args[o],"string"==typeof i&&(i='"'+i.replace("\n","\\n")+'"'),t.push(i);s.push(e.opcode+" "+t.join(" "))}return s.join("\n")},equals:function(e){var t=this.opcodes.length;
if(e.opcodes.length!==t)return!1;for(var i=0;t>i;i++){var n=this.opcodes[i],s=e.opcodes[i];if(n.opcode!==s.opcode||n.args.length!==s.args.length)return!1;for(var a=0;a<n.args.length;a++)if(n.args[a]!==s.args[a])return!1}if(t=this.children.length,e.children.length!==t)return!1;for(i=0;t>i;i++)if(!this.children[i].equals(e.children[i]))return!1;return!0},guid:0,compile:function(e,t){this.opcodes=[],this.children=[],this.depths={list:[]},this.options=t;var i=this.options.knownHelpers;if(this.options.knownHelpers={helperMissing:!0,blockHelperMissing:!0,each:!0,"if":!0,unless:!0,"with":!0,log:!0},i)for(var n in i)this.options.knownHelpers[n]=i[n];
return this.accept(e)},accept:function(e){var t,i=e.strip||{};return i.left&&this.opcode("strip"),t=this[e.type](e),i.right&&this.opcode("strip"),t},program:function(e){for(var t=e.statements,i=0,n=t.length;n>i;i++)this.accept(t[i]);return this.isSimple=1===n,this.depths.list=this.depths.list.sort(function(e,t){return e-t}),this},compileProgram:function(e){var t,i=(new this.compiler).compile(e,this.options),n=this.guid++;this.usePartial=this.usePartial||i.usePartial,this.children[n]=i;for(var s=0,a=i.depths.list.length;a>s;s++)t=i.depths.list[s],2>t||this.addDepth(t-1);
return n},block:function(e){var t=e.mustache,i=e.program,n=e.inverse;i&&(i=this.compileProgram(i)),n&&(n=this.compileProgram(n));var s=this.classifyMustache(t);"helper"===s?this.helperMustache(t,i,n):"simple"===s?(this.simpleMustache(t),this.opcode("pushProgram",i),this.opcode("pushProgram",n),this.opcode("emptyHash"),this.opcode("blockValue")):(this.ambiguousMustache(t,i,n),this.opcode("pushProgram",i),this.opcode("pushProgram",n),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue")),this.opcode("append")
},hash:function(e){var t,i,n=e.pairs;this.opcode("pushHash");for(var s=0,a=n.length;a>s;s++)t=n[s],i=t[1],this.options.stringParams?(i.depth&&this.addDepth(i.depth),this.opcode("getContext",i.depth||0),this.opcode("pushStringParam",i.stringModeValue,i.type)):this.accept(i),this.opcode("assignToHash",t[0]);this.opcode("popHash")},partial:function(e){var t=e.partialName;this.usePartial=!0,e.context?this.ID(e.context):this.opcode("push","depth0"),this.opcode("invokePartial",t.name),this.opcode("append")
},content:function(e){this.opcode("appendContent",e.string)},mustache:function(e){var t=this.options,i=this.classifyMustache(e);"simple"===i?this.simpleMustache(e):"helper"===i?this.helperMustache(e):this.ambiguousMustache(e),this.opcode(e.escaped&&!t.noEscape?"appendEscaped":"append")},ambiguousMustache:function(e,t,i){var n=e.id,s=n.parts[0],a=null!=t||null!=i;this.opcode("getContext",n.depth),this.opcode("pushProgram",t),this.opcode("pushProgram",i),this.opcode("invokeAmbiguous",s,a)},simpleMustache:function(e){var t=e.id;
"DATA"===t.type?this.DATA(t):t.parts.length?this.ID(t):(this.addDepth(t.depth),this.opcode("getContext",t.depth),this.opcode("pushContext")),this.opcode("resolvePossibleLambda")},helperMustache:function(e,t,i){var n=this.setupFullMustacheParams(e,t,i),s=e.id.parts[0];if(this.options.knownHelpers[s])this.opcode("invokeKnownHelper",n.length,s);else{if(this.options.knownHelpersOnly)throw new Error("You specified knownHelpersOnly, but used the unknown helper "+s);this.opcode("invokeHelper",n.length,s)
}},ID:function(e){this.addDepth(e.depth),this.opcode("getContext",e.depth);var t=e.parts[0];t?this.opcode("lookupOnContext",e.parts[0]):this.opcode("pushContext");for(var i=1,n=e.parts.length;n>i;i++)this.opcode("lookup",e.parts[i])},DATA:function(e){if(this.options.data=!0,e.id.isScoped||e.id.depth)throw new l("Scoped data references are not supported: "+e.original);this.opcode("lookupData");for(var t=e.id.parts,i=0,n=t.length;n>i;i++)this.opcode("lookup",t[i])},STRING:function(e){this.opcode("pushString",e.string)
},INTEGER:function(e){this.opcode("pushLiteral",e.integer)},BOOLEAN:function(e){this.opcode("pushLiteral",e.bool)},comment:function(){},opcode:function(e){this.opcodes.push({opcode:e,args:[].slice.call(arguments,1)})},declare:function(e,t){this.opcodes.push({opcode:"DECLARE",name:e,value:t})},addDepth:function(e){if(isNaN(e))throw new Error("EWOT");0!==e&&(this.depths[e]||(this.depths[e]=!0,this.depths.list.push(e)))},classifyMustache:function(e){var t=e.isHelper,i=e.eligibleHelper,n=this.options;
if(i&&!t){var s=e.id.parts[0];n.knownHelpers[s]?t=!0:n.knownHelpersOnly&&(i=!1)}return t?"helper":i?"ambiguous":"simple"},pushParams:function(e){for(var t,i=e.length;i--;)t=e[i],this.options.stringParams?(t.depth&&this.addDepth(t.depth),this.opcode("getContext",t.depth||0),this.opcode("pushStringParam",t.stringModeValue,t.type)):this[t.type](t)},setupMustacheParams:function(e){var t=e.params;return this.pushParams(t),e.hash?this.hash(e.hash):this.opcode("emptyHash"),t},setupFullMustacheParams:function(e,t,i){var n=e.params;
return this.pushParams(n),this.opcode("pushProgram",t),this.opcode("pushProgram",i),e.hash?this.hash(e.hash):this.opcode("emptyHash"),n}},o.precompile=a,o.compile=r,o}(i,l,c,r),u=function(e,t,i,n,s){"use strict";var a,r=e,o=t,l=i.parser,c=i.parse,d=n.Compiler,u=n.compile,h=n.precompile,p=s,m=r.create,f=function(){var e=m();return e.compile=function(t,i){return u(t,i,e)},e.precompile=h,e.AST=o,e.Compiler=d,e.JavaScriptCompiler=p,e.Parser=l,e.parse=c,e};return r=f(),r.create=f,a=r}(a,r,l,d,c);return u
}();define("handlebars-lib",function(e){return function(){var t;return t||e.Handlebars}}(this)),define("plex/base/utils/formatters/dateTimeUtil",["underscore","moment","plex/base/utils/t"],function(e,t,i){"use strict";var n={formatHoursMinutes:function(e){var n=t.duration(e),s=n.hours()+24*n.days(),a=n.minutes(),r=n.seconds();return s&&a?i("{1} hr {2} min",s,a):s?i("{1} hr",s):a?i("{1} min",a):r>0?i("{1} sec",r):""},formatMinutes:function(e){var n=t.duration(e),s=24*n.days()*60,a=60*n.hours(),r=n.minutes()+a+s,o=n.seconds();
return r?i("{1} min",r):o>0?i("{1} sec",o):""},formatDaysHours:function(e){var n=t.duration(e),s=n.days(),a=n.hours(),r=i(s>1?"days":"day"),o=i(a>1||0>=a?"hours":"hour");return s&&a?s+" "+r+", "+a+" "+o:s?s+" "+r:a+" "+o},formatDays:function(e){var n=t.duration(e),s=365*n.years(),a=30*n.months(),r=s+a+n.days(),o=i(r>1||0>=r?"days":"day");return r+" "+o},formatBroadDuration:function(e){return 54e5>=e?this.formatMinutes(e):864e5>=e?this.formatHoursMinutes(e):6048e5>=e?this.formatDaysHours(e):this.formatDays(e)
},formatDate:function(e,i){return i||(i="MMMM D, YYYY"),e?t(e).format(i):""},formatTimestamp:function(e,i){return i||(i="MMMM D, YYYY"),e?t.unix(e).format(i):""},formatDuration:function(i){if(!e.isNumber(i))return"0:00";var n=t.duration(i),s=n.seconds(),a=n.minutes(),r=n.hours()+24*n.days(),o="";return o=10>s?":0"+s:":"+s,o=10>a&&r>0?"0"+a+o:a+o,r>0&&(o=r+":"+o),o},formatMinutesRemaining:function(e){if(!e)return"";if(60>e)return 1===e?i("{1} second left",e):i("{1} seconds left",e);var t=Math.ceil(e/60);
return 1===t?i("{1} minute left",t):i("{1} minutes left",t)},formatTimeAgo:function(e){return e?t.unix(e).fromNow():""}};return n}),define("plex/base/utils/playerQualities",["underscore","plex/base/utils/mediaUtil","plex/base/adapters/loggerAdapter"],function(e,t,i){"use strict";var n={bitrates:[64,96,208,320,720,1500,2e3,3e3,4e3,8e3,1e4,12e3,2e4],videoResolutions:["220x180","220x128","284x160","420x240","576x320","720x480","1280x720","1280x720","1280x720","1920x1080","1920x1080","1920x1080","1920x1080"],videoQualities:[10,20,30,30,40,60,60,75,100,60,75,90,100],getQualityByIndex:function(e){return 0>e?{index:-1}:{index:e,bitrate:this.bitrates[e],videoResolution:this.videoResolutions[e],videoQuality:this.videoQualities[e]}
},getQualityAttribute:function(e){return e.isLibraryItem()?e.server.hasLocalConnection()?"localQuality":"remoteQuality":"channelQuality"},getCurrentQuality:function(t,n){var s=this.getQualityAttribute(t),a=n.get(s);return a>=this.bitrates.length&&(i.warn("Quality index "+a+" is out of bounds"),a=n.defaults[s],n.save(s,a)),e.extend(this.getQualityByIndex(a),{attribute:s})},getAvailableQualities:function(e){e||(e={});for(var t=e.lowestQualityIndex,i=e.highestQualityIndex,n=e.comparator,s=[],a=0,r=this.bitrates.length;r>a;a++)if(!(t&&t>a)){if(i&&a>i)return s;
if(n&&n.call(this,a))return s;s.push(this.getQualityByIndex(a))}return s},getAvailableQualitiesFor:function(e,i,n){if(!e||!i)return[];var s=i.get("transcoderVideo"),a=i.get("transcoderVideoRemuxOnly"),r=t.getSelectedVideo(e),o=!(!r||!r.bitrate),l=!!e.videoResolution;if(!s||a||!o&&!l)return[];var c=o?this.getAvailableQualitiesBelowBitrate(r.bitrate,n):this.getAvailableQualitiesBelowResolution(e.videoResolution,n);return c},getAvailableQualitiesBelowBitrate:function(e,t){return t||(t={}),t.comparator=function(t){var i=this.bitrates[t];
return i>=e},this.getAvailableQualities(t)},getAvailableQualitiesBelowResolution:function(e,t){t||(t={});var i=this.getHeightFromResolution(e);return t.comparator=function(e){var t=this.videoResolutions[e],n=this.getHeightFromResolution(this.getResolutionFromSize(t));return n>=i},this.getAvailableQualities(t)},getResolutionFromSize:function(e){var t=e.split("x"),i=parseInt(t[1],10);return i>2560?"8k":i>1100?"4k":i>720?"1080":i>576?"720":i>480?"576":i>360?"480":"sd"},getHeightFromResolution:function(e){switch(e){case"8k":return 5120;
case"4k":return 2560;case"1080":return 1080;case"720":return 720;case"576":return 576;case"480":return 480;case"sd":return 360;default:return 360}},getNearestQualityIndex:function(e){if(!e)return-1;var t=this.bitrates.indexOf(e);if(0>t){t=0;for(var i=0;i<this.bitrates.length;i++){var n=this.bitrates[i];if(n>e)break;t=i}}return t}};return n}),define("plex/base/utils/formatters/metadataUtil",["underscore","plex/base/utils/t","plex/base/utils/playerQualities"],function(e,t,i){"use strict";var n={formatBitrate:function(e,t){var i=["bps","kbps","Mbps","Gbps","Tbps"],n=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);
return(e/Math.pow(1e3,n)).toFixed(t)+" "+i[n+1]},formatVideoQuality:function(e){var n=e.bitrate,s=e.videoResolution;if(!n&&!s)return t("Unknown");var a=[];if(n){var r=1e3>n||n%1e3===0?0:1;a.push(this.formatBitrate(n,r))}if(s&&(!n||n>=1e3)){var o=i.getResolutionFromSize(s);a.push(this.formatResolution(o))}return a.join(" ")},formatBytes:function(e){var t=["B","KB","MB","GB","TB"],i=parseInt(Math.floor(Math.log(e)/Math.log(1024)),10);return(e/Math.pow(1024,i)).toFixed(2)+" "+t[i]},formatVideoLevel:function(e){return e=parseInt(e,10),(e/10).toFixed(1)
},formatResolution:function(t){if(!t)return"";if("8k"===t)return"8K";if("4k"===t)return"4K";var i=parseInt(t,10);return e.isNaN(i)?t.toUpperCase():t+"p"},formatAudioCodec:function(e){return e?"dca"===e?"DTS":e.toUpperCase():""},formatAudioChannels:function(e){return e=parseInt(e,10),e?2>e?t("Mono"):3>e?t("Stereo"):(e-1).toString()+".1":""},formatStreamLanguage:function(e,i){if(!i)return t("None");var n=i.language||t("Unknown");return"subtitles"===e?i.codec&&(n+=" ("+i.codec.toUpperCase(),i.forced&&(n+=" "+t("Forced")),n+=")"):"audio"===e&&i.codec&&(n+=" ("+this.formatAudioCodec(i.codec),i.channels&&(n+=" "+this.formatAudioChannels(i.channels)),n+=")"),n
}};return n}),define("handlebars",["underscore","handlebars-lib","plex/base/utils/t","plex/base/utils/formatters/stringUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/utils/formatters/metadataUtil"],function(e,t,i,n,s,a){"use strict";t.registerHelper("if_eq",function(e,t,i){return e==t?i.fn(this):i.inverse(this)}),t.registerHelper("if_neq",function(e,t,i){return e!=t?i.fn(this):i.inverse(this)}),t.registerHelper("t",function(){var n=e.initial(arguments).concat({escape:!0});return new t.SafeString(i.apply(i,n))
}),t.registerHelper("csl",function(e){return e.join(", ")}),t.registerHelper("encodeUrl",function(e){return encodeURIComponent(e||"")}),t.registerHelper("tags",function(t){return e.pluck(t,"tag").join(",")}),t.registerHelper("json",function(e,t){return 2!==arguments.length||t||(t=2),1===arguments.length&&(e=this),JSON.stringify(e,null,t)});var r=[{util:n,helpers:["truncate","truncateMiddle","formatLabel","formatBoolean","upperCase","getLastSegment","shortFilename"]},{util:a,helpers:["formatBitrate","formatVideoQuality","formatBytes","formatVideoLevel","formatResolution","formatAudioCodec","formatAudioChannels","formatStreamLanguage"]},{util:s,helpers:["formatDate","formatTimestamp","formatDuration","formatTimeAgo"]}];
return e.each(r,function(i){e.each(i.helpers,function(n){t.registerHelper(n,function(){return i.util[n].apply(i.util,e.initial(arguments))})})}),t.registerHelper("partial",function(i,n){var s=t.partials[i],a=e.extend({},n.hash.context||this,n.hash);return new t.SafeString(s(a))}),t}),define("text",["module"],function(e){"use strict";var t,i,n,s,a,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],o=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,l=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,c="undefined"!=typeof location&&location.href,d=c&&location.protocol&&location.protocol.replace(/\:/,""),u=c&&location.hostname,h=c&&(location.port||void 0),p={},m=e.config&&e.config()||{};
return t={version:"2.0.10",strip:function(e){if(e){e=e.replace(o,"");var t=e.match(l);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:m.createXhr||function(){var e,t,i;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(t=0;3>t;t+=1){i=r[t];
try{e=new ActiveXObject(i)}catch(n){}if(e){r=[i];break}}return e},parseName:function(e){var t,i,n,s=!1,a=e.indexOf("."),r=0===e.indexOf("./")||0===e.indexOf("../");return-1!==a&&(!r||a>1)?(t=e.substring(0,a),i=e.substring(a+1,e.length)):t=e,n=i||t,a=n.indexOf("!"),-1!==a&&(s="strip"===n.substring(a+1),n=n.substring(0,a),i?i=n:t=n),{moduleName:t,ext:i,strip:s}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,i,n,s){var a,r,o,l=t.xdRegExp.exec(e);return l?(a=l[2],r=l[3],r=r.split(":"),o=r[1],r=r[0],!(a&&a!==i||r&&r.toLowerCase()!==n.toLowerCase()||(o||r)&&o!==s)):!0
},finishLoad:function(e,i,n,s){n=i?t.strip(n):n,m.isBuild&&(p[e]=n),s(n)},load:function(e,i,n,s){if(s.isBuild&&!s.inlineText)return void n();m.isBuild=s.isBuild;var a=t.parseName(e),r=a.moduleName+(a.ext?"."+a.ext:""),o=i.toUrl(r),l=m.useXhr||t.useXhr;return 0===o.indexOf("empty:")?void n():void(!c||l(o,d,u,h)?t.get(o,function(i){t.finishLoad(e,a.strip,i,n)},function(e){n.error&&n.error(e)}):i([r],function(e){t.finishLoad(a.moduleName+"."+a.ext,a.strip,e,n)}))},write:function(e,i,n){if(p.hasOwnProperty(i)){var s=t.jsEscape(p[i]);
n.asModule(e+"!"+i,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,i,n,s,a){var r=t.parseName(i),o=r.ext?"."+r.ext:"",l=r.moduleName+o,c=n.toUrl(r.moduleName+o)+".js";t.load(l,n,function(){var i=function(e){return s(c,e)};i.asModule=function(e,t){return s.asModule(e,c,t)},t.write(e,l,i,a)},a)}},"node"===m.env||!m.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(i=require.nodeRequire("fs"),t.get=function(e,t,n){try{var s=i.readFileSync(e,"utf8");
0===s.indexOf("\ufeff")&&(s=s.substring(1)),t(s)}catch(a){n(a)}}):"xhr"===m.env||!m.env&&t.createXhr()?t.get=function(e,i,n,s){var a,r=t.createXhr();if(r.open("GET",e,!0),s)for(a in s)s.hasOwnProperty(a)&&r.setRequestHeader(a.toLowerCase(),s[a]);m.onXhr&&m.onXhr(r,e),r.onreadystatechange=function(){var t,s;4===r.readyState&&(t=r.status,t>399&&600>t?(s=new Error(e+" HTTP status: "+t),s.xhr=r,n(s)):i(r.responseText),m.onXhrComplete&&m.onXhrComplete(r,e))},r.send(null)}:"rhino"===m.env||!m.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?t.get=function(e,t){var i,n,s="utf-8",a=new java.io.File(e),r=java.lang.System.getProperty("line.separator"),o=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(a),s)),l="";
try{for(i=new java.lang.StringBuffer,n=o.readLine(),n&&n.length()&&65279===n.charAt(0)&&(n=n.substring(1)),null!==n&&i.append(n);null!==(n=o.readLine());)i.append(r),i.append(n);l=String(i.toString())}finally{o.close()}t(l)}:("xpconnect"===m.env||!m.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(n=Components.classes,s=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),a="@mozilla.org/windows-registry-key;1"in n,t.get=function(e,t){var i,r,o,l={};
a&&(e=e.replace(/\//g,"\\")),o=new FileUtils.File(e);try{i=n["@mozilla.org/network/file-input-stream;1"].createInstance(s.nsIFileInputStream),i.init(o,1,0,!1),r=n["@mozilla.org/intl/converter-input-stream;1"].createInstance(s.nsIConverterInputStream),r.init(i,"utf-8",i.available(),s.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),r.readString(i.available(),l),r.close(),i.close(),t(l.value)}catch(c){throw new Error((o&&o.path||"")+": "+c)}}),t}),define("hb",["underscore","handlebars-lib","text"],function(e,t,i){"use strict";
var n={},s=function(s,a,r,o){if(o.isBuild&&"undefined"!=typeof process&&process.versions&&process.versions.node){var l=require.nodeRequire("fs"),c=e.chain(o.templatePathPrefixs).map(function(e){return e+s+".tpl"}).filter(function(e){return l.existsSync(e)}).map(function(e){return l.readFileSync(e,"utf8")}).first().value(),d=t.precompile(c);n[s]=d,r(d)}else i.get(a.toUrl(s+".tpl"),function(e){var i=t.compile(e);r(i)})},a=function(e,t,i){if(t in n){var s=n[t];i('define("'+e+"!"+t+'", ["handlebars"], function (Handlebars){return Handlebars.template('+s+");});\n")
}},r=function(e,t){return".tpl"==e.substr(e.length-4,4)&&(e=e.substr(0,e.length-4)),t(e)};return{load:s,write:a,normalize:r}}),define("hb!templates/desktop/modals/ConfirmModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n        <button type="button" class="cancel-btn btn btn-lg btn-default" data-dismiss="modal">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,e&&e.cancelLabel,s):u.call(e,"t",e&&e.cancelLabel,s)))+"</button>\n      "
}function r(){return"btn-danger"}function o(){return"btn-primary"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d="",u=i.helperMissing,h=this.escapeExpression,p="function",m=this;return d+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-exclamation-mark"></i> ',(l=i.title)?l=l.call(t,{hash:{},data:s}):(l=t&&t.title,l=typeof l===p?l.call(t,{hash:{},data:s}):l),d+=h(l)+'</h4>\n    </div>\n\n    <div class="modal-body">\n      <p class="confirm-message">',(l=i.message)?l=l.call(t,{hash:{},data:s}):(l=t&&t.message,l=typeof l===p?l.call(t,{hash:{},data:s}):l),d+=h(l)+'</p>\n      <p class="double-confirm-message text-warning"></p>\n    </div>\n\n    <div class="modal-footer">\n      ',l=i.unless.call(t,t&&t.hideCancel,{hash:{},inverse:m.noop,fn:m.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='\n      <button type="button" class="confirm-btn btn btn-lg ',l=i["if"].call(t,t&&t.hasDanger,{hash:{},inverse:m.program(5,o,s),fn:m.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+=' btn-loading">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',c={hash:{},data:s},d+=h((l=i.t||t&&t.t,l?l.call(t,t&&t.confirmLabel,c):u.call(t,"t",t&&t.confirmLabel,c)))+"</span>\n      </button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/BaseModal",["underscore","jquery","marionette","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";var s=0,a=[],r=i.Layout.extend({className:"modal fade",focusDelay:200,animationDelay:500,events:{"hide.bs.modal":"onHide"},initialize:function(){this.once("render",function(){s+=1,n.trigger("anyModalOpen")}),this.once("close",function(){s-=1,0===s&&n.trigger("allModalsClosed")})},hide:function(){this.isClosed||this.isHidden||this.$el.modal("hide")},onRender:function(){this.rerender||(this.isForced?this.$el.modal({backdrop:"static",keyboard:!1}):(this.listenTo(n,"shortcut:escape",e.bind(function(){a[0]===this&&this.hide()
},this)),this.listenToOnce(this,"close",function(){var e=a.indexOf(this);-1!==e&&a.splice(e,1)}),a.unshift(this),this.$el.modal()),t(":focus").blur())},onHide:function(){this.isHidden=!0,e.each(this.panes,function(e){var t=e.constructor.onModalClose;t&&t.apply(this)},this),setTimeout(e.bind(function(){n.trigger("hide:modal",this),this.trigger("close")},this),this.animationDelay)}});return r}),define("plex/desktop/views/modals/ConfirmModal",["hb!templates/desktop/modals/ConfirmModal.tpl","underscore","jquery","plex/desktop/views/modals/BaseModal"],function(e,t,i,n){"use strict";
var s=n.extend({className:"confirm-modal modal modal-sm fade",template:e,ui:{doubleConfirmMessage:".double-confirm-message",confirmBtn:".confirm-btn"},events:t.extend({"click .confirm-btn":"onConfirm"},n.prototype.events),whitelistedOptions:["title","message","confirmLabel","cancelLabel","hasDanger","hideCancel"],initialize:function(e){n.prototype.initialize.apply(this,arguments),this.async=e.async,this.data=t.pick(e,this.whitelistedOptions),this.promise=i.Deferred()},serializeData:function(){return t.defaults(this.data,{confirmLabel:"Yes",cancelLabel:"No"})
},onRender:function(){n.prototype.onRender.apply(this,arguments),setTimeout(t.bind(function(){this.ui.confirmBtn.focus()},this),this.focusDelay)},onHide:function(){n.prototype.onHide.apply(this,arguments),this.promise.reject()},onConfirm:function(e){if(e.preventDefault(),this.options.requireDoubleConfirm&&!this.hasConfirmedOnce){this.hasConfirmedOnce=!0;var t=this.options.doubleConfirmMessage,i=this.options.doubleConfirmLabel;return t&&this.ui.doubleConfirmMessage.text(t),void(i&&this.ui.confirmBtn.text(i))
}this.promise.resolve(),this.async?this.ui.confirmBtn.addClass("active"):this.hide()}});return s}),define("plex/desktop/adapters/player/CompanionPlayerController",["underscore","plex/base/utils/t","plex/base/utils/BaseClass","plex/base/utils/dispatcher","plex/base/utils/mediaUtil","plex/base/utils/playerUtil","plex/base/utils/types/streamTypes","plex/base/mixins/eventMixin","plex/base/mixins/player/playerControllerMixin","plex/base/models/appModel","plex/base/commands/commands","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=i.extend({mixins:[o,l],companion:!0,modelDefaults:function(){var t=l.modelDefaults.apply(this,arguments);return e.extend(t,{state:a.states.BUFFERING,showMinimize:!0,showMaximize:this.type!==a.types.MUSIC,showSeekBar:this.type!==a.types.PHOTO})},initialize:function(t){l.initialize.apply(this,arguments),e.bindAll(this,"skipPrevious","skipNext"),this.type=t.type,this.manager=t.manager,this.references=1},getServerConnection:function(t,i){i||(i={});var n=t.get("activeConnection");return n.isLoopbackAddress&&(n=e.find(t.connections,function(e){return e.available&&!e.isLoopbackAddress
})),n?{protocol:n.scheme||"http",address:n.uri?t.getAddressFromUri(n.uri):n.address,port:n.port}:void(i.isRequired&&this.showLoopbackWarning(t))},showLoopbackWarning:function(e){var i=c.get("user");if(!i.get("signedIn")||"ok"!==e.get("myPlexSigninState")){var s;s=t(i.get("signedIn")?"This server is unavailable to the player. Please sign this server in to your Plex account and try again.":"This server is unavailable to the player. Please sign in to your Plex account and try again.");var a=new u({title:t("Unable to Cast"),message:s,confirmLabel:t("OK"),cancelLabel:t("Ignore")});
a.promise.done(function(){n.trigger("hide:player"),i.get("signedIn")?n.trigger("navigate","serverSettings",{serverID:e.id}):n.trigger("navigate","login",{silent:!0})}),n.trigger("show:modal",a)}},getTransientToken:function(e){return d.execute("getTransientToken",{server:e})},reset:function(t){var i={loop:"photo"===this.type};return this.currentItem=t,this.previousItem=this.getPreviousItem(t,i),this.nextItem=this.getNextItem(t,i),this.model.set(e.result(this,"modelDefaults")),t},stop:function(){l.stop.apply(this,arguments);
var e=this.model.get("playQueue");e&&!c.get("primaryPlayer")&&e.takeOwnership(),this.manager.removeController(this.type)},setStream:function(){},refreshRemotePlayQueue:function(){},onFinishedChange:function(e,t){t&&(this.manager.removeController(this.type),n.trigger("hide:player"))},onItemChange:function(){var t,i,n=this.model.get("item"),s=this.model.get("mediaIndex"),a=this.model.get("partIndex"),r=n.get("Media");if(t=s>1&&r.length>s?r[s]:e.first(r)){var o=t.Part;i=a>1&&o.length>a?o[a]:e.first(o)
}this.model.set({media:t,part:i})},onAudioStreamIDChange:function(e,t){var i=e.previous("audioStreamID");if(null!=t&&null!=i){if(this.isTimelineChange){var n=r.getStreamTypeByString("audio");return void s.selectStream(e.get("media"),n,t)}this.setStream("audio",t)}},onSubtitleStreamIDChange:function(e,t){var i=e.previous("subtitleStreamID");if(null!=t&&null!=i){if(this.isTimelineChange){var n=r.getStreamTypeByString("subtitles");return void s.selectStream(e.get("media"),n,t)}this.setStream("subtitles",t)
}},onPlayQueueChange:function(){this.previousItem=this.getPreviousItem(),this.nextItem=this.getNextItem(),this.model.set({canSkipPrevious:!!this.previousItem,canSkipNext:!!this.nextItem}),this.refreshRemotePlayQueue()}});return h}),define("plex/desktop/adapters/player/PlexPlayerController",["underscore","jquery","plex/base/utils/playerUtil","plex/base/utils/mediaUtil","plex/base/utils/types/streamTypes","plex/base/utils/promiseUtil","plex/desktop/adapters/player/CompanionPlayerController"],function(e,t,i,n,s,a,r){"use strict";
var o=r.extend({modelDefaults:function(){var t=r.prototype.modelDefaults.apply(this,arguments),i=this.manager.player.get("protocolCapabilities"),n=e.contains(i,"playqueues"),s=this.model.get("playQueue");return e.extend(t,{canStop:!0,showPlayQueue:!!(n&&s&&s.supports({remoteRefresh:!0}))})},load:function(i){this.model=i.model,this.mediaElement=i.mediaElement||document.createElement(this.type),this.reset(this.model.get("item")),this.listenTo(this.manager,"timeline",this.onTimeline),this.listenTo(this.model,{"change:item":this.onItemChange,"change:mediaIndex":this.onItemChange,"change:partIndex":this.onItemChange,"change:audioStreamID":this.onAudioStreamIDChange,"change:subtitleStreamID":this.onSubtitleStreamIDChange,"change:finished":this.onFinishedChange});
var n=this.model.get("item"),s=n.server,r=this.getServerInfo(s,{isRequired:!0});if(!r)return t.Deferred().reject().promise();var o;if("node"===r.machineIdentifier?this.model.set("playQueue",null):(o=this.model.get("playQueue"),o&&this.listenTo(o.get("collection"),"reset",this.onPlayQueueChange)),i.silent)return t.Deferred().resolve().promise();var l=e.extend({key:n.get("key"),offset:i.offset||0},r),c=t.Deferred().resolve().promise(),d=this.getTransientTokenFor(s,l);return o&&(c=o.yieldOwnership().then(function(e){l.containerKey=e
})),c=c.then(function(){return a.toStatePromise(d)}),c=c.then(e.bind(function(){var e="/player/playback/playMedia?"+t.param(l,!0);return this.manager.request(e)},this))},mirror:function(i){if(e.contains(this.manager.player.get("protocolCapabilities"),"mirror")){var n=i.item,s=n.server,r=this.getServerInfo(s,{isRequired:!0});if(!r)return t.Deferred().reject().promise();var o=e.extend({type:this.type,key:n.get("key")},r),l=a.toStatePromise(this.getTransientTokenFor(s,o));return l=l.then(e.bind(function(){return this.manager.request("/player/mirror/details?"+t.param(o,!0))
},this))}this.manager.removeController(this.type)},getServerInfo:function(t,i){var n=this.getServerConnection(t,i);if(n){var s=e.extend({machineIdentifier:t.id},n);return"myPlex"===s.machineIdentifier&&(s.machineIdentifier="node",s.address="node.plexapp.com"),s}},getTransientTokenFor:function(e,t){var i=this.getTransientToken(e).then(function(e){t.token=e});return i},reset:function(){return this.hasStarted=!1,r.prototype.reset.apply(this,arguments)},play:function(){return this.model.set("state",i.states.PLAYING),this.manager.request("/player/playback/play?type="+this.type)
},pause:function(){return this.model.set("state",i.states.PAUSED),this.manager.request("/player/playback/pause?type="+this.type)},setPosition:function(e){return this.canSeek(e)?(this.model.set("position",e),this.sendPositionRequest(e)):void 0},sendPositionRequest:e.throttle(function(e){var i={type:this.type,offset:e},n="/player/playback/seekTo?"+t.param(i,!0);return this.manager.request(n)},500),setVolume:function(e){this.model.set("volume",e),this.sendVolumeRequest(e)},sendVolumeRequest:e.throttle(function(e){var i={type:this.type,volume:e},n="/player/playback/setParameters?"+t.param(i,!0);
return this.manager.request(n)},500),setStream:function(e,t){var i=s.getStreamTypeByString(e).key;return this.manager.request("/player/playback/setStreams?"+i+"="+t+"&type="+this.type)},refreshRemotePlayQueue:function(){var i=this.model.get("playQueue"),n=this.manager.player.get("protocolCapabilities");if(i&&e.contains(n,"playqueues")){var s=i.get("playQueueID");return this.manager.request("/player/playback/refreshPlayQueue?playQueueID="+s)}return t.Deferred().resolve().promise()},skipPrevious:function(){return r.prototype.skipPrevious.apply(this,arguments),this.manager.request("/player/playback/skipPrevious?type="+this.type)
},skipNext:function(){return r.prototype.skipNext.apply(this,arguments),this.manager.request("/player/playback/skipNext?type="+this.type)},skipTo:function(e){return r.prototype.skipTo.apply(this,arguments),this.manager.request("/player/playback/skipTo?type="+this.type+"&key="+e)},stop:function(){return r.prototype.stop.apply(this,arguments),this.manager.request("/player/playback/stop?type="+this.type)},removeItem:function(){var t=r.prototype.removeItem.apply(this,arguments);return t.then(e.bind(this.refreshRemotePlayQueue,this))
},moveItem:function(){var t=r.prototype.moveItem.apply(this,arguments);return t.then(e.bind(this.refreshRemotePlayQueue,this))},onTimeline:function(t){if(this.type===t.type&&!t.continuing){var s=this.model.get("playQueue"),a=this.model.get("item");if(s){if(t.key&&t.key!==a.get("key")){if(a=s.get("collection").findWhere({key:t.key}),!a)return;this.reset(a)}var r=parseInt(t.playQueueVersion,10);r&&r>s.get("playQueueVersion")&&s.fetch()}t.state!==i.states.STOPPED&&(this.hasStarted=!0);var o=this.manager.player.get("protocolCapabilities"),l=(e.contains(o,"playqueues"),parseInt(t.audioStreamID,10)),c=parseInt(t.subtitleStreamID,10);
this.isTimelineChange=!0,this.model.set({mediaIndex:t.mediaIndex,partIndex:t.partIndex,partCount:t.partCount,audioStreamID:e.isNaN(l)?null:l,subtitleStreamID:e.isNaN(c)?null:c,state:t.state,ready:!0,loaded:"photo"===this.type?!1:!0,finished:this.hasStarted&&t.state===i.states.STOPPED,duration:t.duration,position:t.time,volume:t.volume,shuffle:t.shuffle,repeat:t.repeat,canPlayPause:t.controllable.indexOf("playPause")>-1,canStop:t.controllable.indexOf("stop")>-1,canSeek:t.controllable.indexOf("seekTo")>-1,canSetVolume:t.controllable.indexOf("volume")>-1,canSetVideoStream:t.controllable.indexOf("videoStream")>-1,canSetAudioStream:t.controllable.indexOf("audioStream")>-1,canSetSubtitleStream:t.controllable.indexOf("subtitleStream")>-1,canShuffle:t.controllable.indexOf("shuffle")>-1,canRepeat:t.controllable.indexOf("repeat")>-1,canSkipPrevious:t.controllable.indexOf("skipPrevious")>-1,canSkipNext:t.controllable.indexOf("skipNext")>-1}),this.isTimelineChange=!1,"video"===this.type&&n.setViewOffset(a,t.time,t.duration)
}}});return o}),define("plex/desktop/adapters/player/PlexPlayerManager",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser","plex/desktop/adapters/player/CompanionPlayerManager","plex/base/models/appModel","plex/desktop/adapters/player/PlexPlayerController"],function(e,t,i,n,s,a,r,o){"use strict";var l=a.extend({protocol:"plex",controller:o,initialize:function(){e.bindAll(this,"error"),a.prototype.initialize.apply(this,arguments)},start:function(){a.prototype.start.apply(this,arguments),this.commandID=0,this.stopPolling=!1,this.poll()
},stop:function(){this.stopPolling=!0,this.pollRequest&&this.pollRequest.abort(),a.prototype.stop.apply(this,arguments)},request:function(e,i){i||(i={}),i.skipIncrement||this.commandID++,e+=e.indexOf("?")>-1?"&":"?",e+="commandID="+this.commandID;var n=this.player.useHostedHttps?this.player.server:this.player,s=n.getXHROptions(e);return s.headers["X-Plex-Target-Client-Identifier"]=this.player.id,t.ajax(s)},poll:function(t){t||(t={});var i="/player/timeline/poll?wait=";i+=t.wait?"1":"0",this.pollRequest=this.request(i,{skipIncrement:!0}),this.pollRequest.done(e.bind(function(e,t,i){this.player.id===i.getResponseHeader("X-Plex-Client-Identifier")&&this.onTimeline(e),this.poll({wait:!0})
},this)),this.pollRequest.fail(e.bind(function(){this.stopPolling||this.error()},this))},error:function(){n.trigger("show:alert",{type:"error",message:i("There was a problem connecting to this player.")}),r.set("primaryPlayer",null),r.get("players").fetch({reset:!0})},onTimeline:function(t){var i=s.parseXML(t);s.parseArray(i,"Timeline"),i.commandID<this.commandID||e.each(i.Timeline,function(e){s.parseInteger(e,["time","duration","volume"]),s.parseBoolean(e,["repeat","shuffle","continuing"]),e.controllable=e.controllable?e.controllable.split(","):[],this.trigger("timeline",e),this.updateNowPlaying(e)
},this)}});return l}),define("plex/base/utils/Backlog",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=t.extend({initialize:function(){this._entries=[]},wrapAll:function(t,i,n){e.each(t,function(e){this.wrap(e,i,n)},this)},wrap:function(t,i,n){n[t]=e.wrap(n[t],e.bind(function(t){var s=e.toArray(arguments).slice(1);return i.call(n)?t.apply(n,s):void this.add({fn:t,args:s,context:n})},this))},add:function(e){this._entries.push(e)},process:function(){e.each(this._entries,function(e){var t=e.context||this;
e.fn.apply(t,e.args)},this),this.clear()},clear:function(){this._entries.length=0}});return i}),define("plex/base/utils/transcoder",["underscore","jquery","plex/base/utils/mediaUtil","plex/base/adapters/loggerAdapter"],function(e,t,i,n){"use strict";var s={extensions:{dash:".mpd",hls:".m3u8",http:""},logParams:function(t,i){var s=[];e.each(e.keys(i),function(e){s.push(e+": "+i[e])}),n.group("Transcoder: "+t+" options",s)},serializeParams:function(i){var n,s={},a={},r=/^X-Plex/;return e.each(i,function(e,t){r.test(t)?a[t]=e:s[t]=e
}),s=t.param(s,!0),a=t.param(a,!0),n=s&&a?s+"&"+a:s||a},image:function(t,i,n){if(!i)return"";var s=n.fallbackServer,a=!1;if(s)if(t.get("cloud"))a=!0;else if(t.get("synced")){var r=!t.get("activeConnection").isLocalAddress,o=s.get("activeConnection").isLocalAddress;a=r||o}var l=a?s:t,c=l.id===t.id;t.get("cloud")&&(i=s?s.resolveUrl(i,{appendToken:!0}):t.resolveUrl(i,{appendToken:!0,connection:{address:"node.plexapp.com",port:"32400"}}));var d={url:t.resolveUrl(i,{useLoopback:c,appendToken:!0}),width:parseInt(n.width,10),height:parseInt(n.height,10)};
n.minSize&&(d.minSize=1),n.format&&(d.format=n.format),n.filters&&e.each(n.filters,function(e,t){void 0!==e&&(d[t]=e)});var u="/photo/:/transcode?"+this.serializeParams(d,l);return l.resolveUrl(u,{appendToken:!0})},music:function(t,i,n){var s=e.first(i.get("Media"));if(s){var a=e.first(s.Part);if(a){var r,o;return t.supports("universalMusicTranscoder")?(r=e.extend({path:t.resolveUrl(i.get("key"),{useLoopback:!0}),mediaIndex:0,partIndex:0},n),o="/music/:/transcode/universal/start.mp3"):(r={identifier:i.get("identifier"),url:t.resolveUrl(a.key,{useLoopback:!0}),format:"mp3",audioCodec:"libmp3lame",audioBitrate:320,audioSamples:44100},o="/music/:/transcode/generic.mp3"),this.logParams("Music",r),r=e.extend(r,t.getHeaders()),t.resolveUrl(o+"?"+this.serializeParams(r,t))
}}},video:function(t,n,s,a,r){r||(r={});var o=t.id===n.server.id,l=n.server.get("cloud")?t:n.server,c=e.extend({path:l.resolveUrl(n.get("key"),{useLoopback:o,appendToken:!o}),mediaIndex:i.getMediaIndex(n,s.id),partIndex:i.getPartIndex(s,a.key),protocol:"hls",offset:0,fastSeek:1,directPlay:0,directStream:1,subtitleSize:100,audioBoost:100},r);c.path=c.path.replace(/^http[s]?:\/\/node.plexapp.com:[\d]+\//,t.url()),this.logParams("Video",c);var d=n.get("indirectHttpHeaders");d&&(c.httpCookies=d.Cookie,c.userAgent=d["User-Agent"]),c=e.extend(c,t.getHeaders());
var u=this.extensions[c.protocol],h="/video/:/transcode/universal/start"+u;return t.resolveUrl(h+"?"+this.serializeParams(c,t))}};return s}),define("plex/desktop/utils/constants/castAppIDs",[],function(){"use strict";var e={PRODUCTION:"9AC194DC",QA:"4289C4E0",CUSTOM:"custom"};return e.settings=[{value:e.PRODUCTION,title:"Production"},{value:e.QA,title:"QA"},{value:e.CUSTOM,title:"Custom"}],e}),define("plex/base/models/player/CastPlayerModel",["underscore","plex/base/models/BaseModel","plex/base/models/library/MetadataCollection"],function(e,t,i){"use strict";
var n=t.extend({whitelistedAttrs:["friendlyName","label","capabilities"],defaults:{protocolCapabilities:["playback","timeline","mirror","playqueues"]},initialize:function(){this.set("nowPlaying",new i([],{server:this.server}))},parse:function(t){var i=e.pick(t,this.whitelistedAttrs);return i.protocol=t.receiverType,i.volume=t.volume.level,i.muted=t.volume.muted,i}});return n}),define("plex/chromecast/utils/constants/castCustomMessages",[],function(){"use strict";var e={PLAY:"PLAY",PAUSE:"PAUSE",STOP:"STOP",PREVIOUS:"PREVIOUS",NEXT:"NEXT",SKIPTO:"SKIPTO",SHOWDETAILS:"SHOWDETAILS",REFRESHPLAYQUEUE:"REFRESHPLAYQUEUE",SETSTREAM:"SETSTREAM",SETQUALITY:"SETQUALITY"};
return e}),define("plex/chromecast/models/CastServerModel",["plex/base/mixins/serverMixin","plex/base/models/BaseModel"],function(e,t){"use strict";var i=t.extend({mixins:e});return i}),define("plex/desktop/adapters/player/CastPlayerController",["underscore","jquery","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/utils/playerQualities","plex/base/utils/mediaUtil","plex/base/utils/types/streamTypes","plex/base/utils/promiseUtil","plex/base/adapters/settingsAdapter","plex/chromecast/utils/constants/castCustomMessages","plex/desktop/adapters/player/CompanionPlayerController","plex/chromecast/models/CastServerModel","plex/base/models/appModel"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=d.extend({modelDefaults:function(){var t=d.prototype.modelDefaults.apply(this,arguments),i=this.model.get("playQueue");return e.extend(t,{canPlayPause:!0,canStop:!0,canSeek:!0,canSetVolume:this.type!==n.types.PHOTO,canSetAudioStream:!0,canSetSubtitleStream:!0,canSetQuality:!0,showPlayQueue:!(!i||!i.supports({remoteRefresh:!0}))})},load:function(i){this.model=i.model,this.mediaElement=i.mediaElement||document.createElement(this.type),this.reset(this.model.get("item")),this.listenTo(this.manager,{timeline:this.onTimeline,progress:this.onProgress,error:this.onError}),this.listenTo(this.model,{"change:item":this.onItemChange,"change:mediaIndex":this.onItemChange,"change:partIndex":this.onItemChange,"change:qualityIndex":this.onQualityIndexChange,"change:audioStreamID":this.onAudioStreamIDChange,"change:subtitleStreamID":this.onSubtitleStreamIDChange,"change:finished":this.onFinishedChange});
var n=this.model.get("playQueue");if(n&&this.listenTo(n.get("collection"),"reset",this.onPlayQueueChange),i.silent)return this.manager.updatePlayer(),t.Deferred().resolve().promise();var a=this.model.get("item"),r=a.server,c=h.get("primaryServer"),d=i.offset/1e3||0,u=s.getCurrentQuality(a,l.getInstance()),p=h.get("user"),m={offset:d,directPlay:l.get("directPlay"),directStream:l.get("directStream"),bitrate:u.bitrate,subtitleSize:l.get("subtitleSize"),audioBoost:l.get("audioBoost"),server:this.getServerInfo(r,{isRequired:!0}),user:{username:p.get("username")}};
if(!m.server)return t.Deferred().reject().promise();var f=[];f.push(this.getTransientTokenFor(r,m.server)),c&&r.id!==c.id&&(m.primaryServer=this.getServerInfo(c),m.primaryServer&&f.push(this.getTransientTokenFor(c,m.primaryServer)));var g=t.Deferred().resolve().promise();return n&&(g=n.yieldOwnership().then(function(e){m.containerKey=e})),g=g.then(function(){return o.whenEach(f)}),g.done(e.bind(function(){var e=new chrome.cast.media.MediaInfo(a.get("key"),this.type);e.customData=m;var t=new chrome.cast.media.LoadRequest(e);
t.currentTime=d,t.autoplay=!0,this.manager.loadMedia(t)},this)),g},mirror:function(i){var n=i.item,s=n.server,a=h.get("primaryServer"),r=h.get("user"),l={server:this.getServerInfo(s,{isRequired:!0}),user:{username:r.get("username")}};if(!l.server)return t.Deferred().reject().promise();var d=[];d.push(this.getTransientTokenFor(s,l.server)),a&&s.id!==a.id&&(l.primaryServer=this.getServerInfo(a),l.primaryServer&&d.push(this.getTransientTokenFor(a,l.primaryServer)));var u=o.whenEach(d);return u.done(e.bind(function(){var e=new chrome.cast.media.MediaInfo(n.get("key"),this.type);
e.customData=l;var t={type:c.SHOWDETAILS};t.media=e,this.manager.sendCustomMessage(t),this.manager.removeController(this.type)},this)),u},getServerInfo:function(t,i){var n=this.getServerConnection(t,i);if(n){var s=e.extend({machineIdentifier:t.id,transcoderVideo:t.get("transcoderVideo")||!1,transcoderVideoRemuxOnly:t.get("transcoderVideoRemuxOnly")||!1,transcoderAudio:t.get("transcoderAudio")||!1,version:t.get("version"),myPlexSubscription:t.get("myPlexSubscription"),isVerifiedHostname:"https"===n.protocol},n);
return s}},getTransientTokenFor:function(e,t){var i=this.getTransientToken(e).then(function(e){t.accessToken=e});return i},play:function(){this.model.set("state",n.states.PLAYING),this.manager.sendCustomMessage({type:c.PLAY})},pause:function(){this.model.set("state",n.states.PAUSED),this.manager.sendCustomMessage({type:c.PAUSE})},setPosition:function(e){if(this.canSeek(e)){this.model.set({state:n.states.BUFFERING,position:e});var t=e/1e3;this.manager.startSeek(t),this.sendPositionRequest(t)}},sendPositionRequest:e.debounce(function(e){var t=new chrome.cast.media.SeekRequest;
t.currentTime=e,this.manager.sendMediaCommand("seek",t)},500),setVolume:function(e){this.model.set("volume",e),this.sendVolumeRequest(e/100)},sendVolumeRequest:e.debounce(function(e){this.manager.sendSessionCommand("setReceiverVolumeLevel",e)},200),skipPrevious:function(){this.manager.sendCustomMessage({type:c.PREVIOUS})},skipNext:function(){this.manager.sendCustomMessage({type:c.NEXT})},skipTo:function(e){this.manager.sendCustomMessage({type:c.SKIPTO,key:e})},stop:function(){d.prototype.stop.apply(this,arguments),this.manager.sendCustomMessage({type:c.STOP})
},refreshRemotePlayQueue:function(){this.manager.sendCustomMessage({type:c.REFRESHPLAYQUEUE})},setStream:function(e,t){this.manager.sendCustomMessage({type:c.SETSTREAM,stream:{type:e,id:t}})},setQualityIndex:function(){var e=this.model.get("item"),t=s.getCurrentQuality(e,l.getInstance());this.manager.sendCustomMessage({type:c.SETQUALITY,bitrate:t.bitrate})},onTimeline:function(t){var i=this.model.get("playQueue"),a=this.model.get("item");if(t.containerKey){var r=t.containerKey.split("?")[0],o=e.result(i,"url");
if(!i||o&&o!==r)return}if(t.key!==a.get("key")){var l=i&&i.get("collection");if(a=l&&l.findWhere({key:t.key}),!a)return;this.reset(a)}var c=null;if(t.transcodeServerID){var d=h.get("servers");c=d.get(t.transcodeServerID)}var u=s.getNearestQualityIndex(t.bitrate),p=e.isNumber(t.audioStreamID)?t.audioStreamID:null,m=e.isNumber(t.subtitleStreamID)?t.subtitleStreamID:null;this.isTimelineChange=!0,this.model.set({mediaIndex:t.mediaIndex,partIndex:t.partIndex,qualityIndex:u,audioStreamID:p,subtitleStreamID:m,transcodeServer:c,state:t.state,ready:!0,loaded:"photo"===this.type?!1:!0,finished:t.state===n.states.STOPPED,errorMessage:t.errorMessage,duration:1e3*t.duration,volume:100*t.volume}),this.isTimelineChange=!1,this.onProgress(t.position)
},onProgress:function(e){var t=this.model.get("item"),i=this.model.get("duration"),n=1e3*e;a.setViewOffset(t,n,i),this.model.set("position",n)},onError:function(e){this.model.set({state:n.states.ERROR,errorMessage:e})},onQualityIndexChange:function(e,t){var i=e.previous("qualityIndex");null==t||null==i||this.isTimelineChange||this.setQualityIndex()}});return p}),define("plex/desktop/adapters/player/CastPlayerManager",["underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/browser","plex/base/utils/Backlog","plex/base/utils/playerUtil","plex/base/utils/transcoder","plex/desktop/utils/constants/castAppIDs","plex/base/adapters/loggerAdapter","plex/base/adapters/settingsAdapter","plex/desktop/adapters/player/CompanionPlayerManager","plex/base/models/appModel","plex/base/models/player/CastPlayerModel","plex/desktop/adapters/player/CastPlayerController"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p){"use strict";
var m=d.extend({protocol:"cast",namespace:"urn:x-cast:plex",progressDelay:100,controller:p,sessionWrapped:["loadMedia","sendSessionCommand","sendCustomMessage"],mediaSessionWrapped:["sendMediaCommand","startSeek"],appID:function(){var e=c.get("chromecastAppID"),t=c.get("chromecastCustomAppID");return e===o.CUSTOM&&t?t:e||o.PRODUCTION},initialize:function(){if("chrome"===n.id){e.bindAll(this,"onApiAvailable","onApiLoadSuccess","onApiLoadError","onReceiverAvailable","onReceiverAction","onCustomReceiversError","onSessionAvailable","onSessionError","onSessionUpdate","onMediaSessionDiscovered","onMediaSessionError","onMediaSessionUpdate"),d.prototype.initialize.apply(this,arguments),this.sessionBacklog=new s,this.sessionBacklog.wrapAll(this.sessionWrapped,function(){return!!this.session
},this),this.mediaSessionBacklog=new s,this.mediaSessionBacklog.wrapAll(this.mediaSessionWrapped,function(){return!!this.mediaSession},this),this.listenTo(i,"cast:launch",this.onLaunch),window.__onGCastApiAvailable=this.onApiAvailable;var t=document.createElement("script");t.src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js",document.head.appendChild(t)}},load:function(){c.populate({reset:!0}).always(e.bind(function(){var t=e.result(this,"appID"),i=new chrome.cast.SessionRequest(t),n=new chrome.cast.ApiConfig(i,this.onSessionAvailable,this.onReceiverAvailable);
chrome.cast.initialize(n,this.onApiLoadSuccess,this.onApiLoadError)},this))},loadCustomReceivers:function(){var e=u.get("players");e.length&&(this.customReceivers=[],e.each(function(e){var t=new chrome.cast.Receiver(this.getCustomReceiverLabel(e),e.get("name"));t.receiverType=chrome.cast.ReceiverType.CUSTOM,this.customReceivers.push(t)},this),chrome.cast.setCustomReceivers(this.customReceivers,null,this.onCustomReceiversError))},getCustomReceiverLabel:function(e){return"custom-"+e.id},stop:function(){this.session&&this.session.stop(null,this.onSessionStopError),this.activeCustomReceiver&&u.set("primaryPlayer",null),d.prototype.stop.apply(this,arguments)
},loadMedia:function(e){l.log("Load media command"),this.session.loadMedia(e,this.onMediaSessionDiscovered,this.onMediaSessionError)},sendSessionCommand:function(e,t){l.log("Sending session command: "+e),this.session[e].call(this.session,t,null,this.onMessageError)},sendMediaCommand:function(e,t){l.log("Sending media command: "+e),"seek"===e&&(this.seeking=!1),this.mediaSession[e].call(this.mediaSession,t,null,this.onMessageError)},sendCustomMessage:function(e){l.log("Sending custom message: "+e.type),this.session.sendMessage(this.namespace,e,null,this.onMessageError)
},startSeek:function(e){this.seeking=!0,this.mediaSession.playerState=chrome.cast.media.PlayerState.BUFFERING,this.mediaSession.currentTime=e},error:function(){i.trigger("show:alert",{type:"error",message:t("There was a problem connecting to this player.")}),u.set("primaryPlayer",null)},updatePlayer:function(){clearInterval(this.progressInterval);var t=this.mediaSession.media,i=this.mediaSession.customData;if(t&&i){var n=e.extend({machineIdentifier:i.server.machineIdentifier,state:a.getStateByCastState(this.mediaSession.playerState),duration:t.duration,position:this.mediaSession.currentTime,volume:this.session.receiver.volume.level},e.omit(i,["server","primaryServer","user"]));
n.state===a.states.PLAYING&&"photo"!==t.contentType&&(this.progressInterval=setInterval(e.bind(this.onProgress,this),this.progressDelay)),this.mediaSession.idleReason===chrome.cast.media.IdleReason.ERROR&&(n.state=a.states.ERROR,n.errorMessage=i.errorMessage),this.trigger("timeline",n),this.updateNowPlaying(n)}},updateCustomReceiverDisplayStatus:function(e,t){var i,n;if(t){var s=r.image(t.server,t.get("thumb"),{fallbackServer:u.get("primaryServer"),width:32,height:32,minSize:1});i=t.get("title"),n=[new chrome.cast.Image(s)]
}else{var a=u.get("primaryPlayer");i=a.get("product")||"Plex"}e.displayStatus=new chrome.cast.ReceiverDisplayStatus(i,n),chrome.cast.setReceiverDisplayStatus(e)},resetCustomReceiverDisplayStatus:function(e){e.displayStatus=null,chrome.cast.setReceiverDisplayStatus(e)},resetSession:function(){this.session&&(this.session.removeUpdateListener(this.onSessionUpdate),this.session=null),this.sessionBacklog.clear()},resetMediaSession:function(){this.mediaSession&&(this.mediaSession.removeUpdateListener(this.onMediaSessionUpdate),this.mediaSession=null),clearInterval(this.progressInterval),this.mediaSessionBacklog.clear()
},onPrimaryPlayerChange:function(t,i){if(d.prototype.onPrimaryPlayerChange.apply(this,arguments),this.activeCustomReceiver){var n=u.previous("primaryPlayer");n&&this.stopListening(n.get("nowPlaying")),this.resetCustomReceiverDisplayStatus(this.activeCustomReceiver),this.activeCustomReceiver=null}if(i){var s=e.findWhere(this.customReceivers,{label:this.getCustomReceiverLabel(i)});if(s){var a=i.get("nowPlaying");this.updateCustomReceiverDisplayStatus(s),this.activeCustomReceiver=s,this.listenTo(a,"add",this.onCustomNowPlayingAdd),this.listenTo(a,"remove",this.onCustomNowPlayingRemove)
}}},onCustomNowPlayingAdd:function(e){this.activeCustomReceiver&&this.updateCustomReceiverDisplayStatus(this.activeCustomReceiver,e)},onCustomNowPlayingRemove:function(){this.activeCustomReceiver&&this.updateCustomReceiverDisplayStatus(this.activeCustomReceiver)},onApiAvailable:function(e,t){e?this.load():l.warn(t)},onApiLoadSuccess:function(){l.log("Loaded the cast api"),u.set("isCastApiAvailable",!0),this.listenTo(u.get("players"),"add remove reset",this.loadCustomReceivers),this.loadCustomReceivers(),chrome.cast.addReceiverActionListener(this.onReceiverAction)
},onApiLoadError:function(e){l.error("Unable to load the cast api: "+JSON.stringify(e)),u.set("isCastApiAvailable",!1)},onReceiverAvailable:function(e){e===chrome.cast.ReceiverAvailability.AVAILABLE?(l.log("Receivers are available"),u.set("isCastDeviceAvailable",!0)):(l.warn("No receivers are available"),u.set("isCastDeviceAvailable",!1))},onReceiverAction:function(e,t){l.log(e.friendlyName+" -> "+t);var i=/^custom-(.*)/.exec(e.label);if(i){l.info(e.friendlyName+" is a custom receiver");var n=u.get("players"),s=n.get(i[1]);
"cast"===t?u.set("primaryPlayer",s):"stop"===t&&u.set("primaryPlayer",null)}},onCustomReceiversError:function(e){l.warn("Custom receivers error: "+JSON.stringify(e))},onLaunch:function(){this.sessionBacklog.clear(),this.mediaSessionBacklog.clear(),chrome.cast.requestSession(this.onSessionAvailable,this.onSessionError)},onSessionAvailable:function(e){if(l.log("Session: "+JSON.stringify(e)),this.session=e,e.sessionId==chrome.cast.Session.CUSTOM_RECEIVER_SESSION_ID){l.info("Custom receiver: "+e.receiver.friendlyName);
var t=/^custom-(.*)/.exec(e.receiver.label);if(t){var i=u.get("players");u.set("primaryPlayer",i.get(t[1]))}}else u.set("primaryPlayer",new h(e.receiver,{parse:!0})),e.addUpdateListener(this.onSessionUpdate),e.addMediaListener(this.onMediaSessionDiscovered),e.media.length&&(l.log("Found existing media sessions."),this.onMediaSessionDiscovered(e.media[0])),this.sessionBacklog.process()},onSessionError:function(e){l.error("Unable to launch new session: "+JSON.stringify(e))},onSessionUpdate:function(e){e||(l.log("Session ended"),this.resetSession(),this.resetMediaSession(),this.activeCustomReceiver||u.set("primaryPlayer",null))
},onSessionStopError:function(e){l.error("Unable to stop session: "+JSON.stringify(e))},onMediaSessionDiscovered:function(e){return l.log("Media session discovered: "+JSON.stringify(e)),e.playerState===a.castStates.STOPPED?void this.resetMediaSession():(this.mediaSession=e,e.addUpdateListener(this.onMediaSessionUpdate),this.updatePlayer(),void this.mediaSessionBacklog.process())},onMediaSessionError:function(e){l.error("Media session error: "+JSON.stringify(e)),this.resetMediaSession(),e.details&&e.details.customData&&this.trigger("error",e.details.customData.errorMessage)
},onMediaSessionUpdate:function(){return this.seeking?void(this.mediaSession.playerState=chrome.cast.media.PlayerState.BUFFERING):void this.updatePlayer()},onMessageError:function(e){l.warn("Message error: "+JSON.stringify(e))},onProgress:function(){this.trigger("progress",this.mediaSession.getEstimatedTime())}});return m}),define("plex/base/adapters/player/PhotoPlayerController",["underscore","jquery","plex/base/utils/BaseClass","plex/base/utils/capabilities","plex/base/utils/playerUtil","plex/base/mixins/eventMixin","plex/base/mixins/player/playerControllerMixin"],function(e,t,i,n,s,a,r){"use strict";
var o=i.extend({mixins:[a,r],type:s.types.PHOTO,slideshowDelay:5e3,skipTransition:!1,modelDefaults:function(){var t=r.modelDefaults.apply(this,arguments);return e.extend(t,{ready:!0,canPlayPause:!0,canStop:!0,showEnterFullscreen:n.hasFullscreen})},initialize:function(t){r.initialize.apply(this,arguments),this.loop=!(!t||!t.loop),e.bindAll(this,"skipPrevious","skipNext")},load:function(e){return this.model=e.model,e.autoplay?this.play():this.pause(),this.reset(this.model.get("item")),this.listenTo(this.model,{"change:state":this.onStateChange,"change:loaded":this.onLoadedChange}),t.Deferred().resolve().promise()
},reset:function(t){this.currentItem&&this.timeline({state:s.states.STOPPED,continuing:!0});var i={loop:this.loop};return this.currentItem=t,this.previousItem=this.getPreviousItem(t,i),this.nextItem=this.getNextItem(t,i),this.model.set(e.result(this,"modelDefaults")),this.timeline().done(e.bind(this.updatePlayQueue,this)),t},play:function(){this.model.set("state",s.states.PLAYING),this.model.get("loaded")&&(this.slideshowTimeout=setTimeout(this.skipNext,this.slideshowDelay)),this.startPlaybackTracking()
},pause:function(){this.model.set("state",s.states.PAUSED),this.slideshowTimeout=clearTimeout(this.slideshowTimeout),this.stopPlaybackTracking()},skipPrevious:function(e){return e||(e={}),this.model.get("loaded")||this.model.get("error")?(this.skipTransition=!!e.manual,this.previousItem&&(this.slideshowTimeout=clearTimeout(this.slideshowTimeout)),r.skipPrevious.apply(this,arguments)):!1},skipNext:function(e){return e||(e={}),this.model.get("loaded")||this.model.get("error")?(this.skipTransition=!!e.manual,this.nextItem&&(this.slideshowTimeout=clearTimeout(this.slideshowTimeout)),r.skipNext.apply(this,arguments)):!1
},stop:function(){r.stop.apply(this,arguments),this.slideshowTimeout=clearTimeout(this.slideshowTimeout),this.stopPlaybackTracking(),this.trackPlaybackEvent()},onStateChange:function(){this.timeline().done(e.bind(this.updatePlayQueue,this))},onLoadedChange:function(e,t){t&&e.get("playing")&&(clearTimeout(this.slideshowTimeout),this.slideshowTimeout=setTimeout(this.skipNext,this.slideshowDelay))}});return o}),define("plex/desktop/adapters/baseDesktopAdapters",["plex/base/adapters/settingsAdapter","plex/desktop/models/DesktopSettingsModel","plex/base/adapters/localizerAdapter","plex/desktop/adapters/DesktopLocalizer","plex/base/adapters/errorTrackerAdapter","plex/desktop/adapters/analytics/desktopSentryTracker","plex/base/adapters/performanceAdapter","plex/desktop/adapters/desktopPerformance","plex/base/adapters/loggerAdapter","plex/base/utils/ConsoleLogger","plex/base/utils/playerUtil","plex/base/adapters/playerControllerAdapter","plex/desktop/adapters/player/PlexPlayerManager","plex/desktop/adapters/player/CastPlayerManager","plex/base/adapters/player/PhotoPlayerController"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f={registerAll:function(){e.register(new t),i.register(new n),s.register(a),r.register(o),l.register(new c);var f=new h,g=new p;u.register({protocol:"plex",type:"*",create:function(e){return f.addController(e)}}),u.register({protocol:"cast",type:"*",create:function(e){return g.addController(e)}}),u.register({protocol:"local",type:d.types.PHOTO,create:function(e){return new m({type:e})}})}};return f}),define("plex/base/adapters/webStorage",["jquery","plex/base/adapters/loggerAdapter"],function(e,t){"use strict";
function i(e){return e?window.sessionStorage:window.localStorage}function n(n,s){var a=i(s.session),r=e.Deferred();try{r.resolve(n(a))}catch(o){t.warn(o.message),r.reject(o)}return r.promise()}try{"string"==typeof localStorage.getItem&&delete localStorage.getItem,"string"==typeof localStorage.setItem&&delete localStorage.setItem,"string"==typeof localStorage.removeItem&&delete localStorage.removeItem,"string"==typeof localStorage.clear&&delete localStorage.clear}catch(s){}var a={get:function(e,t){return t||(t={}),n(function(i){var n=window.PLEXWEB,s=n&&e in n?n[e]:i.getItem(e);
if(null==s){var a=t.session?"session":"local";throw new Error(e+" is not in "+a+" storage")}return s},t)},set:function(e,t,i){return i||(i={}),n(function(i){return i.setItem(e,t)},i)},remove:function(e,t){return t||(t={}),n(function(t){return t.removeItem(e)},t)},clear:function(e){return e||(e={}),n(function(e){return e.clear()},e)}};return a}),define("plex/desktop/adapters/desktopDimensions",["plex/base/utils/browser","plex/base/models/appModel"],function(e,t){"use strict";var i={"X-Plex-Product":"Plex Web","X-Plex-Version":t.get("version"),"X-Plex-Client-Identifier":t.get("clientID"),"X-Plex-Platform":e.name,"X-Plex-Platform-Version":e.version,"X-Plex-Device":e.platform,"X-Plex-Device-Name":"Plex Web ("+e.name+")"};
return t.on("change:clientID",function(e,t){i["X-Plex-Client-Identifier"]=t}),t.on("change:version",function(e,t){i["X-Plex-Version"]=t}),i}),function(){function e(e,t){return e.name=t}function t(e,t){return e.href=t}function i(e){yt.set(e)}function n(e){return"function"==typeof e}function s(e){return void 0!=e&&-1<(e.constructor+"")[H]("String")}function a(){return N.round(2147483647*N.random())}function r(e){var t=St[Q]("img");return t.width=1,t.height=1,t.src=e,t}function o(){}function l(e){return L instanceof Function?L(e):(i(28),e)
}function c(e){return l(e)[z](/\(/g,"%28")[z](/\)/g,"%29")}function d(e,t){if(e){var i=St[Q]("script");i.type="text/javascript",i.async=!0,i.src=e,i.id=t;var n=St.getElementsByTagName("script")[0];n[ft].insertBefore(i,n)}}function u(){var e=""+St[nt][st];return 0==e[H]("www.")?e[ut](4):e}function h(e){var t=St.referrer;if(/^https?:\/\//i.test(t)){if(e)return t;e="//"+St[nt][st];var i=t[H](e);if((5==i||6==i)&&(e=t.charAt(i+e[Z]),"/"==e||"?"==e||""==e||":"==e))return;return t}}function p(e,t){if(1==t[Z]&&null!=t[0]&&"object"==typeof t[0])return t[0];
for(var i={},n=N.min(e[Z]+1,t[Z]),s=0;n>s;s++){if("object"==typeof t[s]){for(var a in t[s])t[s].hasOwnProperty(a)&&(i[a]=t[s][a]);break}s<e[Z]&&(i[e[s]]=t[s])}return i}function m(e){if(100!=e.get(fn)&&E(zt(e,sn))%1e4>=100*jt(e,fn))throw"abort"}function f(e){if(Ct(zt(e,an)))throw"abort"}function g(){var e=St[nt][lt];if("http:"!=e&&"https:"!=e)throw"abort"}function v(e){e.set(oi,jt(e,oi)+1);var t=[];Ut.map(function(i,n){if(n.p){var s=e.get(i);void 0!=s&&s!=n[$]&&("boolean"==typeof s&&(s*=1),t[B](n.p+"="+l(""+s)))
}}),t[B]("z="+a()),e.set(ri,t[gt]("&"),!0)}function y(e){Lt(zt(e,ri),e.get(ai)),e.set(ai,o,!0)}function b(e){var t=kt.gaData;t&&(t.expId&&e.set(Fi,t.expId),t.expVar&&e.set(Bi,t.expVar))}function w(){if(kt[mt]&&"preview"==kt[mt].loadPurpose)throw"abort"}function x(e){var t=jt(e,ji);t>=500&&i(15);var n=zt(e,si);if("transaction"!=n&&"item"!=n){var n=jt(e,Hi),s=(new Date)[G](),a=jt(e,qi);if(0==a&&e.set(qi,s),a=N.round(2*(s-a)/1e3),a>0&&(n=N.min(n+a,20),e.set(qi,s)),0>=n)throw"abort";e.set(Hi,--n)}e.set(ji,++t)
}function k(){var e=Gn;S("create",e,e.create,3),S("getByName",e,e.j,5),S("getAll",e,e.K,6),e=jn[et],S("get",e,e.get,7),S("set",e,e.set,4),S("send",e,e.send,2),e=Bt[et],S("get",e,e.get),S("set",e,e.set),(kt.gaplugins=kt.gaplugins||{}).Linker=Rn,e=Rn[et],Kn.C("linker",Rn),S("decorate",e,e.Q,20),S("autoLink",e,e.S,25),Kn.C("displayfeatures",Vn)}function S(e,t,n,s){t[e]=function(){try{return s&&i(s),n[pt](this,arguments)}catch(t){var r=t&&t[X];if(!(1<=100*N.random()||Ct("?"))){var o=["t=error","_e=exc","_v=j15","sr=1"];
e&&o[B]("_f="+e),r&&o[B]("_m="+l(r[ut](0,100))),o[B]("aip=1"),o[B]("z="+a()),Lt(o[gt]("&"))}throw t}}}function C(){var e,t,i;if((i=(i=kt[mt])?i.plugins:null)&&i[Z])for(var n=0;n<i[Z]&&!t;n++){var s=i[n];-1<s[X][H]("Shockwave Flash")&&(t=s.description)}if(!t)try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),t=e.GetVariable("$version")}catch(a){}if(!t)try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"),t="WIN 6,0,21,0",e.AllowScriptAccess="always",t=e.GetVariable("$version")}catch(r){}if(!t)try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),t=e.GetVariable("$version")
}catch(o){}return t&&(e=t[W](/[\d]+/g))&&3<=e[Z]&&(t=e[0]+"."+e[1]+" r"+e[2]),t||void 0}function P(e,t,i){"none"==t&&(t="");var n=[],s=At(e);e="__utma"==e?6:2;for(var a=0;a<s[Z];a++){var r=(""+s[a])[it](".");r[Z]>=e&&n[B]({hash:r[0],R:s[a],O:r})}return 0==n[Z]?void 0:1==n[Z]?n[0]:A(t,n)||A(i,n)||A(null,n)||n[0]}function A(e,t){var i,n;null==e?i=n=1:(i=E(e),n=E(0==e[H](".")?e[ut](1):"."+e));for(var s=0;s<t[Z];s++)if(t[s][U]==i||t[s][U]==n)return t[s]}function _(e){e=e.get(sn);var t=I(e,0);return"_ga=1."+l(t+"."+e)
}function I(e,t){for(var i=new Date,n=kt.screen||{},s=kt[mt],a=s.plugins||[],i=[e,s.userAgent,n.width,n.height,i.getTimezoneOffset(),i.getYear(),i.getDate(),i.getHours(),i.getMinutes()+t],n=0;n<a[Z];++n)i[B](a[n].description);return E(i[gt]("."))}function T(e,t){if(t==St[nt][st])return!1;for(var i=0;i<e[Z];i++)if(0<=t[H](e[i]))return!0;return!1}function M(){var e=kt.gaGlobal=kt.gaGlobal||{};return e.hid=e.hid||a()}function D(e){function i(e){var t=(e[st]||"")[it](":")[0][vt](),i=(e[lt]||"")[vt](),i=1*e[Y]||("http:"==i?80:"https:"==i?443:"");
return e=e.pathname||"",0==e[H]("/")||(e="/"+e),[t,""+i,e]}var n=St[Q]("a");t(n,St[nt][dt]);var s=(n[lt]||"")[vt](),a=i(n),r=n[at]||"",o=s+"//"+a[0]+(a[1]?":"+a[1]:"");return 0==e[H]("//")?e=s+e:0==e[H]("/")?e=o+e:e&&0!=e[H]("?")?0>e[it]("/")[0][H](":")&&(e=o+a[2][ut](0,a[2].lastIndexOf("/"))+"/"+e):e=o+a[2]+(e||r),t(n,e),s=i(n),{protocol:(n[lt]||"")[vt](),host:s[0],port:s[1],path:s[2],G:n[at]||"",url:e||""}}function E(e){var t,i=1,n=0;if(e)for(i=0,t=e[Z]-1;t>=0;t--)n=e.charCodeAt(t),i=(i<<6&268435455)+n+(n<<14),n=266338304&i,i=0!=n?i^n>>21:i;
return i}var L=encodeURIComponent,R=window,O=setTimeout,N=Math,F=RegExp,B="push",U="hash",V="slice",z="replace",j="data",q="cookie",H="indexOf",W="match",$="defaultValue",Y="port",Q="createElement",K="setAttribute",X="name",G="getTime",J="host",Z="length",et="prototype",tt="clientWidth",it="split",nt="location",st="hostname",at="search",rt="target",ot="call",lt="protocol",ct="clientHeight",dt="href",ut="substring",ht="action",pt="apply",mt="navigator",ft="parentNode",gt="join",vt="toLowerCase",yt=new function(){var e=[];
this.set=function(t){e[t]=!0},this.M=function(){for(var t=[],i=0;i<e[Z];i++)e[i]&&(t[N.floor(i/6)]=t[N.floor(i/6)]^1<<i%6);for(i=0;i<t[Z];i++)t[i]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".charAt(t[i]||0);return t[gt]("")+"~"}},bt=function(e,t,n,s){try{e.addEventListener?e.addEventListener(t,n,!!s):e.attachEvent&&e.attachEvent("on"+t,n)}catch(a){i(27)}},wt=function(e,t,i){e.removeEventListener?e.removeEventListener(t,i,!1):e.detachEvent&&e.detachEvent("on"+t,i)},xt=function(){this.keys=[],this.w={},this.m={}
};xt[et].set=function(e,t,i){this.keys[B](e),i?this.m[":"+e]=t:this.w[":"+e]=t},xt[et].get=function(e){return this.m.hasOwnProperty(":"+e)?this.m[":"+e]:this.w[":"+e]},xt[et].map=function(e){for(var t=0;t<this.keys[Z];t++){var i=this.keys[t],n=this.get(i);n&&e(i,n)}};var kt=R,St=document,Ct=function(e){var t=kt._gaUserPrefs;if(t&&t.ioo&&t.ioo()||e&&!0===kt["ga-disable-"+e])return!0;try{var i=kt.external;if(i&&i._gaUserPrefs&&"oo"==i._gaUserPrefs)return!0}catch(n){}return!1},Pt=function(e){O(e,100)
},At=function(e){var t=[],i=St[q][it](";");e=F("^\\s*"+e+"=\\s*(.*?)\\s*$");for(var n=0;n<i[Z];n++){var s=i[n][W](e);s&&t[B](s[1])}return t},_t=function(e,t,n,s,a,r){if(a=Ct(a)?!1:Tt.test(St[nt][st])||"/"==n&&It.test(s)?!1:!0,!a)return!1;if(t&&200<t[Z]&&(t=t[ut](0,200),i(24)),n=e+"="+t+"; path="+n+"; ",r&&(n+="expires="+new Date((new Date)[G]()+r).toGMTString()+"; "),s&&"none"!=s&&(n+="domain="+s+";"),s=St[q],St.cookie=n,!(s=s!=St[q]))e:{for(e=At(e),s=0;s<e[Z];s++)if(t==e[s]){s=!0;break e}s=!1}return s
},It=F(/^(www\.)?google(\.com?)?(\.[a-z]{2})?$/),Tt=F(/(^|\.)doubleclick\.net$/i),Mt=function(){return(ei||"https:"==St[nt][lt]?"https:":"http:")+"//www.google-analytics.com"},Dt=function(t){e(this,"len"),this.message=t+"-8192"},Et=function(t){e(this,"ff2post"),this.message=t+"-2036"},Lt=function(e,t){if(t=t||o,2036>=e[Z])Rt(e,t);else{if(!(8192>=e[Z]))throw new Dt(e[Z]);var i=t;if(0<=kt[mt].userAgent[H]("Firefox")&&![].reduce)throw new Et(e[Z]);Ot(e,i)||Nt(e,i)}},Rt=function(e,t){var i=r(Mt()+"/collect?"+e);
i.onload=i.onerror=function(){i.onload=null,i.onerror=null,t()}},Ot=function(e,t){var i,n=kt.XDomainRequest;return n?(i=new n,i.open("POST",Mt()+"/collect")):(n=kt.XMLHttpRequest)&&(n=new n,"withCredentials"in n&&(i=n,i.open("POST",Mt()+"/collect",!0),i.setRequestHeader("Content-Type","text/plain"))),i?(i.onreadystatechange=function(){4==i.readyState&&(t(),i=null)},i.send(e),!0):void 0},Nt=function(t,i){if(St.body){t=L(t);try{var n=St[Q]('<iframe name="'+t+'"></iframe>')}catch(s){n=St[Q]("iframe"),e(n,t)
}n.height="0",n.width="0",n.style.display="none",n.style.visibility="hidden";var a=St[nt],a=Mt()+"/analytics_iframe.html#"+L(a[lt]+"//"+a[J]+"/favicon.ico"),r=function(){n.src="",n[ft]&&n[ft].removeChild(n)};bt(kt,"beforeunload",r);var o=!1,l=0,c=function(){if(!o){try{if(l>9||n.contentWindow[nt][J]==St[nt][J])return o=!0,r(),wt(kt,"beforeunload",r),void i()}catch(e){}l++,O(c,200)}};bt(n,"load",c),St.body.appendChild(n),n.src=a}else Pt(function(){Nt(t,i)})},Ft=function(){this.t=[]};Ft[et].add=function(e){this.t[B](e)
},Ft[et].execute=function(e){try{for(var t=0;t<this.t[Z];t++){var i=e.get(this.t[t]);i&&n(i)&&i[ot](kt,e)}}catch(s){}t=e.get(ai),t!=o&&n(t)&&(e.set(ai,o,!0),O(t,10))};var Bt=function(){this.data=new xt},Ut=new xt,Vt=[];Bt[et].get=function(e){var t=$t(e),i=this[j].get(e);return t&&void 0==i&&(i=n(t[$])?t[$]():t[$]),t&&t.n?t.n(this,e,i):i};var zt=function(e,t){var i=e.get(t);return void 0==i?"":""+i},jt=function(e,t){var i=e.get(t);return void 0==i||""===i?0:1*i};Bt[et].set=function(e,t,i){if(e)if("object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&Ht(this,n,e[n],i);
else Ht(this,e,t,i)};var qt,Ht=function(e,t,i,n){var s=$t(t);s&&s.o?s.o(e,t,i,n):e[j].set(t,i,n)},Wt=function(t,i,n,s,a){e(this,t),this.p=i,this.n=s,this.o=a,this.defaultValue=n},$t=function(e){var t=Ut.get(e);if(!t)for(var i=0;i<Vt[Z];i++){var n=Vt[i],s=n[0].exec(e);if(s){t=n[1](s),Ut.set(t[X],t);break}}return t},Yt=function(e){var t;return Ut.map(function(i,n){n.p==e&&(t=n)}),t&&t[X]},Qt=function(e,t,i,n,s){return e=new Wt(e,t,i,n,s),Ut.set(e[X],e),e[X]},Kt=function(e,t){Vt[B]([F("^"+e+"$"),t])
},Xt=function(e,t,i){return Qt(e,t,i,void 0,Gt)},Gt=function(){};if(qt=s(R.GoogleAnalyticsObject)){var Jt=R.GoogleAnalyticsObject;qt=Jt?Jt[z](/^[\s\xa0]+|[\s\xa0]+$/g,""):""}var Zt=qt||"ga",ei=!1,ti=Xt("apiVersion","v"),ii=Xt("clientVersion","_v");Qt("anonymizeIp","aip");var ni=Qt("adSenseId","a"),si=Qt("hitType","t"),ai=Qt("hitCallback"),ri=Qt("hitPayload");Qt("nonInteraction","ni"),Qt("currencyCode","cu"),Qt("sessionControl","sc",""),Qt("queueTime","qt");var oi=Qt("_s","_s");Qt("description","cd");
var li=Qt("location","dl",""),ci=Qt("referrer","dr"),di=Qt("page","dp","");Qt("hostname","dh");var ui=Qt("language","ul"),hi=Qt("encoding","de");Qt("title","dt",function(){return St.title||void 0}),Kt("contentGroup([0-9]+)",function(e){return new Wt(e[0],"cg"+e[1])});var pi=Qt("screenColors","sd"),mi=Qt("screenResolution","sr"),fi=Qt("viewportSize","vp"),gi=Qt("javaEnabled","je"),vi=Qt("flashVersion","fl");Qt("campaignId","ci"),Qt("campaignName","cn"),Qt("campaignSource","cs"),Qt("campaignMedium","cm"),Qt("campaignKeyword","ck"),Qt("campaignContent","cc");
var yi=Qt("eventCategory","ec"),bi=Qt("eventAction","ea"),wi=Qt("eventLabel","el"),xi=Qt("eventValue","ev"),ki=Qt("socialNetwork","sn"),Si=Qt("socialAction","sa"),Ci=Qt("socialTarget","st"),Pi=Qt("l1","plt"),Ai=Qt("l2","pdt"),_i=Qt("l3","dns"),Ii=Qt("l4","rrt"),Ti=Qt("l5","srt"),Mi=Qt("l6","tcp"),Di=Qt("l7","dit"),Ei=Qt("l8","clt"),Li=Qt("timingCategory","utc"),Ri=Qt("timingVar","utv"),Oi=Qt("timingLabel","utl"),Ni=Qt("timingValue","utt");Qt("appName","an"),Qt("appVersion","av",""),Qt("appId","aid",""),Qt("appInstallerId","aiid",""),Qt("exDescription","exd"),Qt("exFatal","exf");
var Fi=Qt("expId","xid"),Bi=Qt("expVar","xvar"),Ui=Qt("_utma","_utma"),Vi=Qt("_utmz","_utmz"),zi=Qt("_utmht","_utmht"),ji=Qt("_hc",void 0,0),qi=Qt("_ti",void 0,0),Hi=Qt("_to",void 0,20);Kt("dimension([0-9]+)",function(e){return new Wt(e[0],"cd"+e[1])}),Kt("metric([0-9]+)",function(e){return new Wt(e[0],"cm"+e[1])}),Qt("linkerParam",void 0,void 0,_,Gt),Qt("usage","_u",void 0,function(){return yt.M()},Gt),Qt("forceSSL",void 0,void 0,function(){return ei},function(e,t,i){ei=!!i});var Wi=Qt("joinId","jid");
Kt("\\&(.*)",function(e){var t=new Wt(e[0],e[1]),i=Yt(e[0][ut](1));return i&&(t.n=function(e){return e.get(i)},t.o=function(e,t,n,s){e.set(i,n,s)},t.p=void 0),t});var $i=Xt("oot"),Yi=Qt("previewTask"),Qi=Qt("checkProtocolTask"),Ki=Qt("checkStorageTask"),Xi=Qt("historyImportTask"),Gi=Qt("samplerTask"),Ji=Xt("rateLimiterTask"),Zi=Qt("buildHitTask"),en=Qt("sendHitTask"),tn=Qt("ceTask"),nn=Xt("name"),sn=Xt("clientId","cid"),an=Xt("trackingId","tid"),rn=Xt("cookieName",void 0,"_ga"),on=Xt("cookieDomain"),ln=Xt("cookiePath",void 0,"/"),cn=Xt("cookieExpires",void 0,63072e3),dn=Xt("legacyCookieDomain"),un=Xt("legacyHistoryImport",void 0,!0),hn=Xt("storage",void 0,"cookie"),pn=Xt("allowLinker",void 0,!1),mn=Xt("allowAnchor",void 0,!0),fn=Xt("sampleRate","sf",100),gn=Xt("siteSpeedSampleRate",void 0,1),vn=Xt("alwaysSendReferrer",void 0,!1),yn=function(e,t){var i=N.min(jt(e,gn),100);
if(!(E(zt(e,sn))%100>=i)&&(i={},bn(i)||wn(i))){var n=i[Pi];void 0==n||1/0==n||isNaN(n)||(n>0?(xn(i,_i),xn(i,Mi),xn(i,Ti),xn(i,Ai),xn(i,Ii),xn(i,Di),xn(i,Ei),t(i)):bt(kt,"load",function(){yn(e,t)},!1))}},bn=function(e){var t=kt.performance||kt.webkitPerformance,t=t&&t.timing;if(!t)return!1;var i=t.navigationStart;return 0==i?!1:(e[Pi]=t.loadEventStart-i,e[_i]=t.domainLookupEnd-t.domainLookupStart,e[Mi]=t.connectEnd-t.connectStart,e[Ti]=t.responseStart-t.requestStart,e[Ai]=t.responseEnd-t.responseStart,e[Ii]=t.fetchStart-i,e[Di]=t.domInteractive-i,e[Ei]=t.domContentLoadedEventStart-i,!0)
},wn=function(e){if(kt.top!=kt)return!1;var t=kt.external,i=t&&t.onloadT;return t&&!t.isValidLoadTime&&(i=void 0),i>2147483648&&(i=void 0),i>0&&t.setPageReadyTime(),void 0==i?!1:(e[Pi]=i,!0)},xn=function(e,t){var i=e[t];(isNaN(i)||1/0==i||0>i)&&(e[t]=void 0)},kn=!1,Sn=function(e){if("cookie"==zt(e,hn)){var t=zt(e,rn),n=An(e),s=Mn(zt(e,ln)),a=In(zt(e,on)),r=1e3*jt(e,cn),o=zt(e,an);if("auto"!=a)_t(t,n,s,a,o,r)&&(kn=!0);else{i(32);var l;if(n=[],a=u()[it]("."),4!=a[Z]||(l=a[a[Z]-1],parseInt(l,10)!=l)){for(l=a[Z]-2;l>=0;l--)n[B](a[V](l)[gt]("."));
n[B]("none"),l=n}else l=["none"];for(var c=0;c<l[Z];c++)if(a=l[c],e[j].set(on,a),n=An(e),_t(t,n,s,a,o,r))return void(kn=!0);e[j].set(on,"auto")}}},Cn=function(e){if("cookie"==zt(e,hn)&&!kn&&(Sn(e),!kn))throw"abort"},Pn=function(e){if(e.get(un)){var t=zt(e,on),n=zt(e,dn)||u(),s=P("__utma",n,t);s&&(i(19),e.set(zi,(new Date)[G](),!0),e.set(Ui,s.R),(t=P("__utmz",n,t))&&s[U]==t[U]&&e.set(Vi,t.R))}},An=function(e){var t=c(zt(e,sn)),i=Tn(zt(e,on));return e=Dn(zt(e,ln)),e>1&&(i+="-"+e),["GA1",i,t][gt](".")
},_n=function(e,t,i){for(var n,s=[],a=[],r=0;r<e[Z];r++){var o=e[r];o.r[i]==t?s[B](o):void 0==n||o.r[i]<n?(a=[o],n=o.r[i]):o.r[i]==n&&a[B](o)}return 0<s[Z]?s:a},In=function(e){return 0==e[H](".")?e.substr(1):e},Tn=function(e){return In(e)[it](".")[Z]},Mn=function(e){return e?(1<e[Z]&&e.lastIndexOf("/")==e[Z]-1&&(e=e.substr(0,e[Z]-1)),0!=e[H]("/")&&(e="/"+e),e):"/"},Dn=function(e){return e=Mn(e),"/"==e?1:e[it]("/")[Z]},En=F(/^https?:\/\/([^\/:]+)/),Ln=/(.*)([?&#])(?:_ga=[^&]*)(?:&?)(.*)/,Rn=function(e){this.target=e,this.T=!1
};Rn[et].Q=function(e,i){if(e.tagName){if("a"==e.tagName[vt]())return void(e[dt]&&t(e,On(this,e[dt],i)));if("form"==e.tagName[vt]())return Nn(this,e)}return"string"==typeof e?On(this,e,i):void 0};var On=function(e,t,i){var n=Ln.exec(t);n&&3<=n[Z]&&(t=n[1]+(n[3]?n[2]+n[3]:"")),e=e[rt].get("linkerParam");var s=t[H]("?"),n=t[H]("#");return i?t+=(-1==n?"#":"&")+e:(i=-1==s?"?":"&",t=-1==n?t+(i+e):t[ut](0,n)+i+e+t[ut](n)),t},Nn=function(e,t){if(t&&t[ht]){var i=e[rt].get("linkerParam")[it]("=")[1];if("get"==t.method[vt]()){for(var n=t.childNodes||[],s=0;s<n[Z];s++)if("_ga"==n[s][X])return void n[s][K]("value",i);
n=St[Q]("input"),n[K]("type","hidden"),n[K]("name","_ga"),n[K]("value",i),t.appendChild(n)}else"post"==t.method[vt]()&&(t.action=On(e,t[ht]))}};Rn[et].S=function(e,n,s){function a(s){try{s=s||kt.event;var a;e:{var o=s[rt]||s.srcElement;for(s=100;o&&s>0;){if(o[dt]&&o.nodeName[W](/^a(?:rea)?$/i)){a=o;break e}o=o[ft],s--}a={}}("http:"==a[lt]||"https:"==a[lt])&&T(e,a[st]||"")&&a[dt]&&t(a,On(r,a[dt],n))}catch(l){i(26)}}var r=this;if(this.T||(this.T=!0,bt(St,"mousedown",a,!1),bt(St,"touchstart",a,!1),bt(St,"keyup",a,!1)),s){s=function(t){if(t=t||kt.event,(t=t[rt]||t.srcElement)&&t[ht]){var i=t[ht][W](En);
i&&T(e,i[1])&&Nn(r,t)}};for(var o=0;o<St.forms[Z];o++)bt(St.forms[o],"submit",s)}};var Fn,Bn=function(e){return e.get(nn)&&"t0"!=e.get(nn)?"_dc_"+c(e.get(nn)):"_dc"},Un=function(e){if(e.get(Wi)){var t=new xt,i=function(i){t.set($t(i).p,e.get(i))};i(ti),i(ii),i(an),i(sn),i(Wi);var n=jt(e,"forceSSL")||"https:"==St[nt][lt]?"https:":"http:",n=n+"//stats.g.doubleclick.net/collect?t=dc&aip=1&";t.map(function(e,t){n+=l(e)+"="+l(""+t)+"&"}),n+="z="+a(),r(n),e.set(Wi,"",!0)}},Vn=function(e){i(29),e=e.b;var t=e.get(Zi);
e.set(Zi,function(e){return e.get(Wi)||(-1!=St[q][H](Bn(e)+"=1")?e.set(Wi,"",!0):(Bn(e),_t(Bn(e),"1",e.get(ln),e.get(on),e.get(an),6e5)?e.set(Wi,""+a(),!0):i(30))),t(e)});var n=e.get(en);e.set(en,function(e){var t=n(e);return Un(e),t})},zn=function(e,t,i){if(!Fn){var n;n=St[nt][U];var s=kt[X],r=/^#?gaso=([^&]*)/;(s=(n=(n=n&&n[W](r)||s&&s[W](r))?n[1]:At("GASO")[0]||"")&&n[W](/^(?:!([-0-9a-z.]{1,40})!)?([-.\w]{10,1200})$/i))&&(_t("GASO",""+n,i,t,e,0),R._udo||(R._udo=t),R._utcp||(R._utcp=i),e=s[1],d("https://www.google.com/analytics/web/inpage/pub/inpage.js?"+(e?"prefix="+e+"&":"")+a(),"_gasojs")),Fn=!0
}},jn=function(e){function t(e,t){n.b[j].set(e,t)}function i(e,i){t(e,i),n.filters.add(e)}var n=this;this.b=new Bt,this.filters=new Ft,t(nn,e[nn]),t(an,e[an]),t(rn,e[rn]),t(on,e[on]||u()),t(ln,e[ln]),t(cn,e[cn]),t(dn,e[dn]),t(un,e[un]),t(pn,e[pn]),t(mn,e[mn]),t(fn,e[fn]),t(gn,e[gn]),t(vn,e[vn]),t(hn,e[hn]),t(ti,1),t(ii,"j15"),i($i,f),i(Yi,w),i(Qi,g),i(Ki,Cn),i(Xi,Pn),i(Gi,m),i(Ji,x),i(tn,b),i(Zi,v),i(en,y),qn(this.b,e[sn]),Hn(this.b),this.b.set(ni,M()),zn(this.b.get(an),this.b.get(on),this.b.get(ln))
},qn=function(e,t){if("cookie"==zt(e,hn)){kn=!1;var n;e:{var s=At(zt(e,rn));if(s&&!(1>s[Z])){n=[];for(var r=0;r<s[Z];r++){var o;o=s[r][it](".");var c=o.shift();("GA1"==c||"1"==c)&&1<o[Z]?(c=o.shift()[it]("-"),1==c[Z]&&(c[1]="1"),c[0]*=1,c[1]*=1,o={r:c,s:o[gt](".")}):o=void 0,o&&n[B](o)}if(1==n[Z]){i(13),n=n[0].s;break e}if(0!=n[Z]){if(i(14),s=Tn(zt(e,on)),n=_n(n,s,0),1==n[Z]){n=n[0].s;break e}s=Dn(zt(e,ln)),n=_n(n,s,1),n=n[0]&&n[0].s;break e}i(12)}n=void 0}n||(n=zt(e,on),s=zt(e,dn)||u(),n=P("__utma",s,n),(n=void 0==n?void 0:n.O[1]+"."+n.O[2])&&i(10)),n&&(e[j].set(sn,n),kn=!0)
}if(n=e.get(mn),(r=(n=St[nt][n?"href":"search"][W]("(?:&|#|\\?)"+l("_ga")[z](/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")+"=([^&#]*)"))&&2==n[Z]?n[1]:"")&&(e.get(pn)?(n=r[H]("."),-1==n?i(22):(s=r[ut](n+1),"1"!=r[ut](0,n)?i(22):(n=s[H]("."),-1==n?i(22):(r=s[ut](0,n),n=s[ut](n+1),r!=I(n,0)&&r!=I(n,-1)&&r!=I(n,-2)?i(23):(i(11),e[j].set(sn,n)))))):i(21)),t&&(i(9),e[j].set(sn,l(t))),!e.get(sn))if(n=(n=kt.gaGlobal&&kt.gaGlobal.vid)&&-1!=n[at](/^(?:utma\.)?\d+\.\d+$/)?n:void 0)i(17),e[j].set(sn,n);else{for(i(8),n=kt[mt],n=n.appName+n.version+n.platform+n.userAgent+(St[q]?St[q]:"")+(St.referrer?St.referrer:""),s=n[Z],r=kt.history[Z];r>0;)n+=r--^s++;
e[j].set(sn,[a()^2147483647&E(n),N.round((new Date)[G]()/1e3)][gt]("."))}Sn(e)},Hn=function(e){var t=kt[mt],n=kt.screen,s=St[nt];if(e.set(ci,h(e.get(vn))),s){var a=s.pathname||"";"/"!=a.charAt(0)&&(i(31),a="/"+a),e.set(li,s[lt]+"//"+s[st]+a+s[at])}n&&e.set(mi,n.width+"x"+n.height),n&&e.set(pi,n.colorDepth+"-bit");var n=St.documentElement,r=(a=St.body)&&a[tt]&&a[ct],o=[];if(n&&n[tt]&&n[ct]&&("CSS1Compat"===St.compatMode||!r)?o=[n[tt],n[ct]]:r&&(o=[a[tt],a[ct]]),n=0>=o[0]||0>=o[1]?"":o[gt]("x"),e.set(fi,n),e.set(vi,C()),e.set(hi,St.characterSet||St.charset),e.set(gi,t&&"function"==typeof t.javaEnabled&&t.javaEnabled()||!1),e.set(ui,(t&&(t.language||t.browserLanguage)||"")[vt]()),s&&e.get(mn)&&(t=St[nt][U])){for(t=t[ut](1),t=t[it]("&"),s=[],n=0;n<t[Z];++n)0!=t[n][H]("utm_id")&&0!=t[n][H]("utm_campaign")&&0!=t[n][H]("utm_source")&&0!=t[n][H]("utm_medium")&&0!=t[n][H]("utm_term")&&0!=t[n][H]("utm_content")||s[B](t[n]);
0<s[Z]&&(t="#"+s[gt]("&"),e.set(li,e.get(li)+t))}};jn[et].get=function(e){return this.b.get(e)},jn[et].set=function(e,t){this.b.set(e,t)};var Wn={pageview:[di],event:[yi,bi,wi,xi],social:[ki,Si,Ci],timing:[Li,Ri,Ni,Oi]};jn[et].send=function(){if(!(1>arguments[Z])){var e,t;"string"==typeof arguments[0]?(e=arguments[0],t=[][V][ot](arguments,1)):(e=arguments[0]&&arguments[0][si],t=arguments),e&&(t=p(Wn[e]||[],t),t[si]=e,this.b.set(t,void 0,!0),this.filters.execute(this.b),"pageview"==e&&$n(this),this.b[j].m={})
}};var $n=function(e){e.I||(e.I=!0,yn(e.b,function(t){e.send("timing",t)}))},Yn=function(e){return"prerender"==St.webkitVisibilityState?!1:(e(),!0)},Qn=function(e){if(!Yn(e)){i(16);var t=!1,n=function(){!t&&Yn(e)&&(t=!0,wt(St,"webkitvisibilitychange",n))};bt(St,"webkitvisibilitychange",n)}},Kn={F:"/plugins/ua/",D:/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/};Kn.k=new xt,Kn.f=[];var Xn=function(e){if(n(e[0]))this.u=e[0];else{var t=Kn.D.exec(e[0]);if(null!=t&&4==t[Z]&&(this.c=t[1]||"t0",this.e=t[2]||"",this.d=t[3],this.a=[][V][ot](e,1),this.e||(this.A="create"==this.d,this.i="require"==this.d,this.g="provide"==this.d)),!n(e[0])){if(t=e[1],e=e[2],!this.d)throw"abort";
if(this.i&&(!s(t)||""==t))throw"abort";if(this.g&&(!s(t)||""==t||!n(e)))throw"abort";if(0<=this.c[H](".")||0<=this.c[H](":")||0<=this.e[H](".")||0<=this.e[H](":"))throw"abort";if(this.g&&"t0"!=this.c)throw"abort"}}};Kn.B=function(e,t,i){var s=Kn.k.get(e);return n(s)?(t.plugins_=t.plugins_||new xt,t.plugins_.set(e,new s(t,i||{})),!0):!1},Kn.C=function(e,t){Kn.k.set(e,t)},Kn.execute=function(){var e=Kn.J[pt](Kn,arguments),e=Kn.f.concat(e);for(Kn.f=[];0<e[Z]&&!Kn.v(e[0])&&(e.shift(),!(0<Kn.f[Z])););Kn.f=Kn.f.concat(e)
},Kn.J=function(){for(var e=[],t=0;t<arguments[Z];t++)try{var i=new Xn(arguments[t]);if(i.g)Kn.v(i);else{if(i.i){var s=i.a[1];if(!n(Kn.k.get(i.a[0]))&&!i.H&&s){var a,r=s+"",s=r&&0<=r[H]("/")?r:"//www.google-analytics.com"+Kn.F+r,o=D(""+s),l=o[lt],c=St[nt][lt];a="https:"==l||l==c?!0:"http:"!=l?!1:"http:"==c;var u;if(u=a){var r=o,h=D(St[nt][dt]);if(r.G||0<=r.url[H]("?")||0<=r.path[H]("://"))u=!1;else if(r[J]==h[J]&&r[Y]==h[Y])u=!0;else{var p="http:"==r[lt]?80:443;u="www.google-analytics.com"==r[J]&&(r[Y]||p)==p&&0==r.path[H]("/plugins/")?!0:!1
}}u&&(i.H=!!d(o.url))}}e[B](i)}}catch(m){}return e},Kn.v=function(e){try{if(e.u)e.u[ot](kt,Gn.j("t0"));else if(e.g)Kn.C(e.a[0],e.a[1]);else{var t=e.c==Zt?Gn:Gn.j(e.c);if(e.A)"t0"==e.c&&Gn.create[pt](Gn,e.a);else if(t)if(e.i){if(!Kn.B(e.a[0],t,e.a[2]))return!0}else e.e&&(t=t.plugins_.get(e.e)),t[e.d][pt](t,e.a)}}catch(i){}};var Gn=function(){i(1),Kn.execute[pt](Kn,[arguments])};Gn.h={},Gn.P=[],Gn.L=0,Gn.answer=42;var Jn=[an,on,nn];Gn.create=function(){var e=p(Jn,[][V][ot](arguments));e[nn]||(e[nn]="t0");
var t=""+e[nn];return Gn.h[t]?Gn.h[t]:(e=new jn(e),Gn.h[t]=e,Gn.P[B](e),e)},Gn.j=function(e){return Gn.h[e]},Gn.K=function(){return Gn.P[V](0)},Gn.N=function(){var e=kt[Zt];if(!e||42!=e.answer){Gn.L=e&&e.l,Gn.loaded=!0,kt[Zt]=Gn,k();var t=e&&e.q;"[object Array]"==Object[et].toString[ot](Object(t))&&Qn(function(){Kn.execute[pt](Gn,t)})}},Gn.N()}(window),define("google-analytics",function(e){return function(){var t;return t||e.ga}}(this)),define("plex/base/adapters/analytics/GoogleAnalytics",["google-analytics","plex/base/utils/BaseClass"],function(e,t){"use strict";
var i=t.extend({constructor:function(t,i){this.ga=this.createGaQueue(),e("create",t,"auto"),e("set",{appName:i.name,appVersion:i.version})},createGaQueue:function(){var t=function(){t.queue.push(arguments)};return t.queue=[],t.run=function(){for(;t.queue.length;)e.apply(window,t.queue.shift())},t},enable:function(){this.ga.run&&this.ga.run(),this.ga=e},disable:function(){this.ga=function(){}},set:function(t){e("set",t)},trackView:function(e){this.ga("send",{hitType:"appview",description:e})},trackEvent:function(e){this.ga("send","event",e)
}});return i}),define("plex/base/adapters/keyboardShortcutsAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";var t=new e({props:["shortcuts"]});return t}),define("hb!templates/desktop/modals/KeyboardShortcutsModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n        <h5 class="keyboard-shortcuts-header">',(n=i.label)?n=n.call(e,{hash:{},data:t}):(n=e&&e.label,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'</h5>\n\n        <ul class="list keyboard-shortcuts-list">\n          ',n=i.each.call(e,e&&e.shortcuts,{hash:{},inverse:v.noop,fn:v.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\n        </ul>\n      "
}function r(e,t){var n,s,a="";return a+='\n            <li>\n              <span class="keyboard-shortcuts-keys">\n                ',n=i.each.call(e,e&&e.keys,{hash:{},inverse:v.noop,fn:v.program(3,o,t),data:t}),(n||0===n)&&(a+=n),a+='\n              </span>\n              <span class="keyboard-shortcuts-label text-muted">',s={hash:{},data:t},a+=g((n=i.t||e&&e.t,n?n.call(e,e&&e.label,s):y.call(e,"t",e&&e.label,s)))+"</span>\n            </li>\n          "}function o(e,t){var n,s="";return s+="\n\n                  ",n=i["if"].call(e,e&&e.plain,{hash:{},inverse:v.noop,fn:v.program(4,l,t),data:t}),(n||0===n)&&(s+=n),s+="\n\n                  ",n=i.unless.call(e,e&&e.plain,{hash:{},inverse:v.noop,fn:v.program(6,c,t),data:t}),(n||0===n)&&(s+=n),s+="\n\n                  ",n=i["if"].call(e,e&&e.split,{hash:{},inverse:v.noop,fn:v.program(8,d,t),data:t}),(n||0===n)&&(s+=n),s+="\n\n                "
}function l(e,t){var n,s="";return s+='\n                    <span class="keyboard-shortcuts-keys-plain">',(n=i.s)?n=n.call(e,{hash:{},data:t}):(n=e&&e.s,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+"</span>\n                  "}function c(e,t){var n,s="";return s+='\n                    <span class="keyboard-shortcuts-keys-key">',(n=i.s)?n=n.call(e,{hash:{},data:t}):(n=e&&e.s,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+"</span>\n                  "}function d(){return"\n                    <br>\n                  "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var u,h,p,m="",f="function",g=this.escapeExpression,v=this,y=i.helperMissing;return m+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon glyphicon keyboard-wireless"></i>\n        ',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Keyboard Shortcuts",p):y.call(t,"t","Keyboard Shortcuts",p)))+'\n      </h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      ',h=i.each.call(t,t&&t.groups,{hash:{},inverse:v.noop,fn:v.program(1,a,s),data:s}),(h||0===h)&&(m+=h),m+="\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/KeyboardShortcutsModal",["hb!templates/desktop/modals/KeyboardShortcutsModal.tpl","underscore","plex/desktop/views/modals/BaseModal"],function(e,t,i){"use strict";function n(e){return t.reduce(e,function(e,t,i){var n=s(t);if(0===i)return e.concat(n);var a=n.length>1;return e.concat({plain:!0,split:a,s:"or"},n)},[])}function s(e){var i=e.match(/(.+) (.+)/);if(i)return s(i[1]).concat({plain:!0,s:"then"}).concat(s(i[2]));var n=e.match(/(.+)\+(\S+)/);if(n)return s(n[1]).concat({plain:!0,s:"+"}).concat(s(n[2]));
var a=t.reduce([[/command/,"\u2318"],[/up/,"\u2191"],[/down/,"\u2193"],[/left/,"\u2190"],[/right/,"\u2192"]],function(e,t){return e.replace(t[0],t[1])},e);return[{s:a}]}var a=i.extend({name:"keyboardShortcutsModal",className:"keyboard-shortcuts-modal modal fade",template:e,orderedGroups:[{group:"navigation",label:"Navigation"},{group:"actions",label:"Actions"},{group:"player",label:"Player"}],initialize:function(e){i.prototype.initialize.apply(this,arguments),this.shortcuts=e.shortcuts},serializeData:function(){var e={};
t.each(this.shortcuts,function(t){var i=t.group;e[i]||(e[i]=[]),e[i].push(this.humanizeShortcut(t))},this);var i=t.map(this.orderedGroups,function(i){var n=t.clone(i);return n.shortcuts=e[i.group],n},this);return{groups:i}},humanizeShortcut:function(e){return e=t.clone(e),e.keys=n(e.keys),e}});return a}),define("plex/desktop/adapters/DesktopKeyboardShortcuts",["plex/base/utils/dispatcher","plex/base/utils/BaseClass","plex/desktop/views/modals/KeyboardShortcutsModal"],function(e,t,i){"use strict";
var n=t.extend({shortcuts:[{keys:["?"],fn:"help",group:"navigation",label:"Open Keyboard Shortcuts"},{keys:["esc"],fn:"escape",group:"navigation",label:"Close Modal or Close Player or Navigate Back"},{keys:["`"],fn:"sidebar",group:"navigation",label:"Toggle Sidebar"},{keys:["g d"],fn:"dashboard",group:"navigation",label:"Navigate to Dashboard"},{keys:["g s"],fn:"settings",group:"navigation",label:"Navigate to Settings"},{keys:["g a"],fn:"activity",group:"navigation",label:"Navigate to Activity"},{keys:["g w"],fn:"watchLater",group:"navigation",label:"Navigate to Watch Later"},{keys:["g r"],fn:"recommendations",group:"navigation",label:"Navigate to Recommended"},{keys:["g u"],fn:"users",group:"navigation",label:"Navigate to Users"},{keys:["/"],fn:"search",group:"actions",label:"Focus Search"},{keys:["p"],fn:"play",group:"actions",label:"Open Player"},{keys:["e"],fn:"edit",group:"actions",label:"Edit Library or Edit Item"},{keys:["#","del"],fn:"remove",group:"actions",label:"Delete Library or Delete Item"},{keys:["shift+s"],fn:"save",group:"actions",label:"Save Changes"},{keys:["r"],fn:"refresh",group:"actions",label:"Update Library or Refresh Item"},{keys:["a"],fn:"analyze",group:"actions",label:"Analyze Library or Analyze Item"},{keys:["w"],fn:"markWatched",group:"actions",label:"Mark as Watched"},{keys:["u"],fn:"markUnwatched",group:"actions",label:"Mark as Unwatched"},{keys:["s"],fn:"sync",group:"actions",label:"Sync"},{keys:["i"],fn:"info",group:"actions",label:"Info"},{keys:["space"],fn:"playPause",group:"player",label:"Play or Pause"},{keys:["down"],fn:"decreaseVolume",group:"player",label:"Decrease Volume"},{keys:["up"],fn:"increaseVolume",group:"player",label:"Increase Volume"},{keys:[",","shift+left"],fn:"seekBackward",group:"player",label:"Seek Backward (15 seconds)"},{keys:[".","shift+right"],fn:"seekForward",group:"player",label:"Seek Forward (30 seconds)"},{keys:["[","alt+left"],fn:"stepBackward",group:"player",label:"Step Backward (10 minutes)"},{keys:["]","alt+right"],fn:"stepForward",group:"player",label:"Step Forward (10 minutes)"},{keys:["left"],fn:"skipPrevious",group:"player",label:"Skip to Previous Item"},{keys:["right"],fn:"skipNext",group:"player",label:"Skip to Next Item"}],help:function(){e.trigger("show:modal",new i({shortcuts:this.shortcuts}))
},escape:function(){e.trigger(e.hasListener("shortcut:escape")?"shortcut:escape":e.hasListener("shortcut:stop")?"shortcut:stop":"navigate:back")},sidebar:function(){e.trigger("shortcut:sidebar")},dashboard:function(){e.trigger("navigate","dashboard")},settings:function(){e.trigger("navigate","settings")},activity:function(){e.trigger("navigate","activity")},watchLater:function(){e.trigger("navigate","userPlaylist",{key:"queue"})},recommendations:function(){e.trigger("navigate","userPlaylist",{key:"recommendations"})
},users:function(){e.trigger("navigate","users")},search:function(){return e.trigger("shortcut:search"),!1},edit:function(){e.trigger("shortcut:edit")},play:function(){e.trigger("shortcut:play")},remove:function(){e.trigger("shortcut:delete")},save:function(){e.trigger("shortcut:save")},refresh:function(){e.trigger("shortcut:refresh")},analyze:function(){e.trigger("shortcut:analyze")},markWatched:function(){e.trigger("shortcut:markWatched")},markUnwatched:function(){e.trigger("shortcut:markUnwatched")
},sync:function(){e.trigger("shortcut:sync")},info:function(){e.trigger("shortcut:info")},playPause:function(){return e.hasListener("shortcut:playPause")?(e.trigger("shortcut:playPause"),!1):void 0},decreaseVolume:function(){return e.hasListener("shortcut:decreaseVolume")?(e.trigger("shortcut:decreaseVolume"),!1):void 0},increaseVolume:function(){return e.hasListener("shortcut:increaseVolume")?(e.trigger("shortcut:increaseVolume"),!1):void 0},seekBackward:function(){e.trigger("shortcut:seekBackward")
},seekForward:function(){e.trigger("shortcut:seekForward")},stepBackward:function(){e.trigger("shortcut:stepBackward")},stepForward:function(){e.trigger("shortcut:stepForward")},skipPrevious:function(){return e.hasListener("shortcut:skipPrevious")?(e.trigger("shortcut:skipPrevious"),!1):void 0},skipNext:function(){return e.hasListener("shortcut:skipNext")?(e.trigger("shortcut:skipNext"),!1):void 0}});return n}),define("plex/base/adapters/playerProfileAdapter",["plex/base/adapters/Adapter"],function(e){"use strict";
var t=new e({props:["capabilities","video","music","photo"]});return t}),define("plex/desktop/adapters/player/desktopPlayerProfile",["plex/base/utils/browser"],function(e){"use strict";var t={capabilities:{embed:!0,redirect:!0},video:{protocols:{hls:{mimeType:"application/x-mpegURL"}},directPlay:{generic:{video:{maxWidth:1920,maxHeight:1280,maxFrameRate:60}},mp4:{mimeType:'video/mp4; codecs="avc1.42E01E"',video:{codec:"h264"},audio:{codec:"aac"}},mkv:{mimeType:"video/webm",video:{codec:"vp8"},audio:{codec:"vorbis"}},ogg:{mimeType:"video/ogg"},mpegts:{protocol:"hls"},flv:{}},directStream:{video:{codec:"h264",maxWidth:1920,maxHeight:1280,maxBitDepth:8},audio:{codec:"aac",maxBitrate:192,maxChannels:2}}},music:{directPlay:{generic:{maxBitrate:350},mp4:{mimeType:"audio/mp4",audioCodec:"aac"},mp3:{mimeType:'audio/mpeg; codecs="mp3"',audioCodec:"mp3"},ogg:{mimeType:'audio/ogg; codecs="vorbis"',audioCodec:"vorbis"},wav:{mimeType:"audio/wav",audioCodec:"pcm"}},directStream:{audio:{codec:"mp3",maxBitrate:320,maxChannels:2}}}};
return"ie"===e.id&&"9.0"===e.version&&(t.video.directPlay.mp4.optimizedForStreaming=!0),t});var swfobject=function(){function e(){if(!q){try{var e=N.getElementsByTagName("body")[0].appendChild(g("span"));e.parentNode.removeChild(e)}catch(t){return}q=!0;for(var i=U.length,n=0;i>n;n++)U[n]()}}function t(e){q?e():U[U.length]=e}function i(e){if(typeof O.addEventListener!=I)O.addEventListener("load",e,!1);else if(typeof N.addEventListener!=I)N.addEventListener("load",e,!1);else if(typeof O.attachEvent!=I)v(O,"onload",e);
else if("function"==typeof O.onload){var t=O.onload;O.onload=function(){t(),e()}}else O.onload=e}function n(){B?s():a()}function s(){var e=N.getElementsByTagName("body")[0],t=g(T);t.setAttribute("type",E);var i=e.appendChild(t);if(i){var n=0;!function(){if(typeof i.GetVariable!=I){var s=i.GetVariable("$version");s&&(s=s.split(" ")[1].split(","),$.pv=[parseInt(s[0],10),parseInt(s[1],10),parseInt(s[2],10)])}else if(10>n)return n++,void setTimeout(arguments.callee,10);e.removeChild(t),i=null,a()}()}else a()
}function a(){var e=V.length;if(e>0)for(var t=0;e>t;t++){var i=V[t].id,n=V[t].callbackFn,s={success:!1,id:i};if($.pv[0]>0){var a=f(i);if(a)if(!y(V[t].swfVersion)||$.wk&&$.wk<312)if(V[t].expressInstall&&o()){var d={};d.data=V[t].expressInstall,d.width=a.getAttribute("width")||"0",d.height=a.getAttribute("height")||"0",a.getAttribute("class")&&(d.styleclass=a.getAttribute("class")),a.getAttribute("align")&&(d.align=a.getAttribute("align"));for(var u={},h=a.getElementsByTagName("param"),p=h.length,m=0;p>m;m++)"movie"!=h[m].getAttribute("name").toLowerCase()&&(u[h[m].getAttribute("name")]=h[m].getAttribute("value"));
l(d,u,i,n)}else c(a),n&&n(s);else w(i,!0),n&&(s.success=!0,s.ref=r(i),n(s))}else if(w(i,!0),n){var g=r(i);g&&typeof g.SetVariable!=I&&(s.success=!0,s.ref=g),n(s)}}}function r(e){var t=null,i=f(e);if(i&&"OBJECT"==i.nodeName)if(typeof i.SetVariable!=I)t=i;else{var n=i.getElementsByTagName(T)[0];n&&(t=n)}return t}function o(){return!H&&y("6.0.65")&&($.win||$.mac)&&!($.wk&&$.wk<312)}function l(e,t,i,n){H=!0,C=n||null,P={success:!1,id:i};var s=f(i);if(s){"OBJECT"==s.nodeName?(k=d(s),S=null):(k=s,S=i),e.id=L,(typeof e.width==I||!/%$/.test(e.width)&&parseInt(e.width,10)<310)&&(e.width="310"),(typeof e.height==I||!/%$/.test(e.height)&&parseInt(e.height,10)<137)&&(e.height="137"),N.title=N.title.slice(0,47)+" - Flash Player Installation";
var a=$.ie&&$.win?"ActiveX":"PlugIn",r="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+a+"&MMdoctitle="+N.title;if(typeof t.flashvars!=I?t.flashvars+="&"+r:t.flashvars=r,$.ie&&$.win&&4!=s.readyState){var o=g("div");i+="SWFObjectNew",o.setAttribute("id",i),s.parentNode.insertBefore(o,s),s.style.display="none",function(){4==s.readyState?s.parentNode.removeChild(s):setTimeout(arguments.callee,10)}()}u(e,t,i)}}function c(e){if($.ie&&$.win&&4!=e.readyState){var t=g("div");e.parentNode.insertBefore(t,e),t.parentNode.replaceChild(d(e),t),e.style.display="none",function(){4==e.readyState?e.parentNode.removeChild(e):setTimeout(arguments.callee,10)
}()}else e.parentNode.replaceChild(d(e),e)}function d(e){var t=g("div");if($.win&&$.ie)t.innerHTML=e.innerHTML;else{var i=e.getElementsByTagName(T)[0];if(i){var n=i.childNodes;if(n)for(var s=n.length,a=0;s>a;a++)1==n[a].nodeType&&"PARAM"==n[a].nodeName||8==n[a].nodeType||t.appendChild(n[a].cloneNode(!0))}}return t}function u(e,t,i){var n,s=f(i);if($.wk&&$.wk<312)return n;if(s)if(typeof e.id==I&&(e.id=i),$.ie&&$.win){var a="";for(var r in e)e[r]!=Object.prototype[r]&&("data"==r.toLowerCase()?t.movie=e[r]:"styleclass"==r.toLowerCase()?a+=' class="'+e[r]+'"':"classid"!=r.toLowerCase()&&(a+=" "+r+'="'+e[r]+'"'));
var o="";for(var l in t)t[l]!=Object.prototype[l]&&(o+='<param name="'+l+'" value="'+t[l]+'" />');s.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+a+">"+o+"</object>",z[z.length]=e.id,n=f(e.id)}else{var c=g(T);c.setAttribute("type",E);for(var d in e)e[d]!=Object.prototype[d]&&("styleclass"==d.toLowerCase()?c.setAttribute("class",e[d]):"classid"!=d.toLowerCase()&&c.setAttribute(d,e[d]));for(var u in t)t[u]!=Object.prototype[u]&&"movie"!=u.toLowerCase()&&h(c,u,t[u]);s.parentNode.replaceChild(c,s),n=c
}return n}function h(e,t,i){var n=g("param");n.setAttribute("name",t),n.setAttribute("value",i),e.appendChild(n)}function p(e){var t=f(e);t&&"OBJECT"==t.nodeName&&($.ie&&$.win?(t.style.display="none",function(){4==t.readyState?m(e):setTimeout(arguments.callee,10)}()):t.parentNode.removeChild(t))}function m(e){var t=f(e);if(t){for(var i in t)"function"==typeof t[i]&&(t[i]=null);t.parentNode.removeChild(t)}}function f(e){var t=null;try{t=N.getElementById(e)}catch(i){}return t}function g(e){return N.createElement(e)
}function v(e,t,i){e.attachEvent(t,i),j[j.length]=[e,t,i]}function y(e){var t=$.pv,i=e.split(".");return i[0]=parseInt(i[0],10),i[1]=parseInt(i[1],10)||0,i[2]=parseInt(i[2],10)||0,t[0]>i[0]||t[0]==i[0]&&t[1]>i[1]||t[0]==i[0]&&t[1]==i[1]&&t[2]>=i[2]?!0:!1}function b(e,t,i,n){if(!$.ie||!$.mac){var s=N.getElementsByTagName("head")[0];if(s){var a=i&&"string"==typeof i?i:"screen";if(n&&(A=null,_=null),!A||_!=a){var r=g("style");r.setAttribute("type","text/css"),r.setAttribute("media",a),A=s.appendChild(r),$.ie&&$.win&&typeof N.styleSheets!=I&&N.styleSheets.length>0&&(A=N.styleSheets[N.styleSheets.length-1]),_=a
}$.ie&&$.win?A&&typeof A.addRule==T&&A.addRule(e,t):A&&typeof N.createTextNode!=I&&A.appendChild(N.createTextNode(e+" {"+t+"}"))}}}function w(e,t){if(W){var i=t?"visible":"hidden";q&&f(e)?f(e).style.visibility=i:b("#"+e,"visibility:"+i)}}function x(e){var t=/[\\\"<>\.;]/,i=null!=t.exec(e);return i&&typeof encodeURIComponent!=I?encodeURIComponent(e):e}{var k,S,C,P,A,_,I="undefined",T="object",M="Shockwave Flash",D="ShockwaveFlash.ShockwaveFlash",E="application/x-shockwave-flash",L="SWFObjectExprInst",R="onreadystatechange",O=window,N=document,F=navigator,B=!1,U=[n],V=[],z=[],j=[],q=!1,H=!1,W=!0,$=function(){var e=typeof N.getElementById!=I&&typeof N.getElementsByTagName!=I&&typeof N.createElement!=I,t=F.userAgent.toLowerCase(),i=F.platform.toLowerCase(),n=/win/.test(i?i:t),s=/mac/.test(i?i:t),a=/webkit/.test(t)?parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,r=!1,o=[0,0,0],l=null;
if(typeof F.plugins!=I&&typeof F.plugins[M]==T)l=F.plugins[M].description,!l||typeof F.mimeTypes!=I&&F.mimeTypes[E]&&!F.mimeTypes[E].enabledPlugin||(B=!0,r=!1,l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),o[0]=parseInt(l.replace(/^(.*)\..*$/,"$1"),10),o[1]=parseInt(l.replace(/^.*\.(.*)\s.*$/,"$1"),10),o[2]=/[a-zA-Z]/.test(l)?parseInt(l.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof O.ActiveXObject!=I)try{var c=new ActiveXObject(D);c&&(l=c.GetVariable("$version"),l&&(r=!0,l=l.split(" ")[1].split(","),o=[parseInt(l[0],10),parseInt(l[1],10),parseInt(l[2],10)]))
}catch(d){}return{w3:e,pv:o,wk:a,ie:r,win:n,mac:s}}();!function(){$.w3&&((typeof N.readyState!=I&&"complete"==N.readyState||typeof N.readyState==I&&(N.getElementsByTagName("body")[0]||N.body))&&e(),q||(typeof N.addEventListener!=I&&N.addEventListener("DOMContentLoaded",e,!1),$.ie&&$.win&&(N.attachEvent(R,function(){"complete"==N.readyState&&(N.detachEvent(R,arguments.callee),e())}),O==top&&!function(){if(!q){try{N.documentElement.doScroll("left")}catch(t){return void setTimeout(arguments.callee,0)
}e()}}()),$.wk&&!function(){return q?void 0:/loaded|complete/.test(N.readyState)?void e():void setTimeout(arguments.callee,0)}(),i(e)))}(),function(){$.ie&&$.win&&window.attachEvent("onunload",function(){for(var e=j.length,t=0;e>t;t++)j[t][0].detachEvent(j[t][1],j[t][2]);for(var i=z.length,n=0;i>n;n++)p(z[n]);for(var s in $)$[s]=null;$=null;for(var a in swfobject)swfobject[a]=null;swfobject=null})}()}return{registerObject:function(e,t,i,n){if($.w3&&e&&t){var s={};s.id=e,s.swfVersion=t,s.expressInstall=i,s.callbackFn=n,V[V.length]=s,w(e,!1)
}else n&&n({success:!1,id:e})},getObjectById:function(e){return $.w3?r(e):void 0},embedSWF:function(e,i,n,s,a,r,c,d,h,p){var m={success:!1,id:i};$.w3&&!($.wk&&$.wk<312)&&e&&i&&n&&s&&a?(w(i,!1),t(function(){n+="",s+="";var t={};if(h&&typeof h===T)for(var f in h)t[f]=h[f];t.data=e,t.width=n,t.height=s;var g={};if(d&&typeof d===T)for(var v in d)g[v]=d[v];if(c&&typeof c===T)for(var b in c)typeof g.flashvars!=I?g.flashvars+="&"+b+"="+c[b]:g.flashvars=b+"="+c[b];if(y(a)){var x=u(t,g,i);t.id==i&&w(i,!0),m.success=!0,m.ref=x
}else{if(r&&o())return t.data=r,void l(t,g,i,p);w(i,!0)}p&&p(m)})):p&&p(m)},switchOffAutoHideShow:function(){W=!1},ua:$,getFlashPlayerVersion:function(){return{major:$.pv[0],minor:$.pv[1],release:$.pv[2]}},hasFlashPlayerVersion:y,createSWF:function(e,t,i){return $.w3?u(e,t,i):void 0},showExpressInstall:function(e,t,i,n){$.w3&&o()&&l(e,t,i,n)},removeSWF:function(e){$.w3&&p(e)},createCSS:function(e,t,i,n){$.w3&&b(e,t,i,n)},addDomLoadEvent:t,addLoadEvent:i,getQueryParamValue:function(e){var t=N.location.search||N.location.hash;
if(t){if(/\?/.test(t)&&(t=t.split("?")[1]),null==e)return x(t);for(var i=t.split("&"),n=0;n<i.length;n++)if(i[n].substring(0,i[n].indexOf("="))==e)return x(i[n].substring(i[n].indexOf("=")+1))}return""},expressInstallCallback:function(){if(H){var e=f(L);e&&k&&(e.parentNode.replaceChild(k,e),S&&(w(S,!0),$.ie&&$.win&&(k.style.display="block")),C&&C(P)),H=!1}}}}();define("swfobject",function(e){return function(){var t;return t||e.swfobject}}(this)),define("plex/base/utils/mediaDecisionEngine",["underscore","jquery","plex/base/utils/t","plex/base/utils/mediaUtil","plex/base/utils/playerUtil","plex/base/utils/playerQualities","plex/base/utils/types/streamTypes","plex/base/utils/constants/subtitlesBurnLevels","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c={getMediaDecision:function(t){var i=this.augmentProfile(t);if(t.media)return this.analyzeMedia(t.media,i,t);var n=t.item,s=n.get("Media");if(!s.length)return{canPlay:!0,canDirectPlay:!0};if(1===s.length)return this.analyzeMedia(e.first(s),i,t);var a=e.map(s,function(e){return this.analyzeMedia(e,i,t)},this);return this.getBestDecision(a)},augmentProfile:function(i){var n=i.profile;if(!n)throw new Error("MDE: No player profile provided for "+i.type);var s=t.extend(!0,{},n.directPlay),a=t.extend(!0,{},n.directStream),r=s.generic;
return r&&delete s.generic,e.each(s,function(e,t){this.mergeGenericOptions(e,r),this.mergeMaxBitrateOption(e,i),this.mergeMaxVideoResolutionOption(e,i),"mp4"===t&&this.mergeAC3Option(e,i)},this),this.mergeMaxBitrateOption(a,i),this.mergeMaxVideoResolutionOption(a,i),{directPlay:s,directStream:a}},mergeGenericOptions:function(t,i){if(i){var n=i.video,s=i.audio;e.defaults(t,e.omit(i,"video","audio")),n&&(t.video||(t.video={}),e.defaults(t.video,n)),s&&(t.audio||(t.audio={}),e.defaults(t.audio,s))}},mergeMaxBitrateOption:function(e,t){var i=s.getStreamByType(t.type),n=this.getMaxQualityOption(e,"bitrate",t);
if(null!=n)if(e.hasOwnProperty("maxBitrate"))e.maxBitrate=n;else{var a=e[i]||{};a.maxBitrate=n,e[i]=a}},mergeMaxVideoResolutionOption:function(e,t){if(t.type===s.types.VIDEO){var i=(s.getStreamByType(t.type),this.getMaxQualityOption(e,"videoResolution",t));null!=i&&(e.maxVideoResolution=i)}},getMaxQualityOption:function(e,t,i){var n=i.quality||{},s="max"+t.charAt(0).toUpperCase()+t.slice(1),r=n[t],o=this.getPrimaryStreamProperty(e,s,i);if("videoResolution"===t&&r&&(r=a.getResolutionFromSize(r)),r||o){var l;
return l=r&&o?Math.min(r,o):r||o}},mergeAC3Option:function(t,i){if(i.type===s.types.VIDEO&&i.allowAC3){var n=t.audioCodec;!n&&t.audio&&(n=t.audio.codec),n&&(e.isArray(n)||(n=[n]),e.contains(n,"ac3")||n.push("ac3"),t.audio?t.audio.codec=n:t.audioCodec=n)}},analyzeMedia:function(t,i,a){l.log("MDE: Starting analysis of "+this.getMediaTitle(t)),l.log("MDE: Analyzing direct play");var r={transcodeServer:a.transcodeServer,media:t,canDirectPlay:this.canDirectPlay(t,i.directPlay,a)},o=a.transcoderOptions||{};
if(e.isFunction(o)&&(o=o(r)),a.type===s.types.VIDEO){l.log("MDE: Analyzing video direct stream");var c=n.getSelectedVideo(t);c&&(r.canDirectStreamVideo=this.canDirectStream(c,i.directStream.video,a,o))}if(a.type!==s.types.PHOTO){l.log("MDE: Analyzing audio direct stream");var d=n.getSelectedAudio(t);d&&(r.canDirectStreamAudio=this.canDirectStream(d,i.directStream.audio,a,o))}var u=n.getSelectedSubtitles(r.media);return u&&(l.log("MDE: Analyzing subtitles"),e.extend(r,this.analyzeSubtitles(u,a))),l.log("MDE: Analyzing playability"),e.extend(r,this.canPlay(r,a)),e.extend(r,this.getEffectiveQuality(t,i.directStream,a)),l.group("MDE: Finished analysis of "+this.getMediaTitle(t),this.getDecisionLogs(r)),r
},canDirectPlay:function(t,i,a){if(a.forceDirectPlay)return l.log("MDE: Direct play forced"),!0;if(a.type===s.types.VIDEO&&!this.canDirectPlayVideo(t,a))return!1;var o=i[t.container];if(!o)return l.warn("MDE: Direct play failed; unsupported container: "+t.container),!1;var c=e.keys(o);if(c&&c.length){for(var d=0,u=c.length;u>d;d++){var h=c[d],p=o[h];if("mimeType"===h){if(!this.canPlayType(s.getElementByType(a.type),p))return l.warn("MDE: Direct play failed; canPlayType test, "+h+": "+p),!1}else if("video"===h||"audio"===h){var m=r.getStreamTypeByString(h),f=n.getStreams(t,{streamType:m.id}),g="video"===h?n.getSelectedVideo(t):n.getSelectedAudio(t);
if(!g)continue;var v="audio"===h&&g!==f[0];if(v&&!a.allowMultiTrackAudio)return l.warn("MDE: Direct play failed; multi-track audio is required"),!1;if(!this.analyzeStream(g,p,a))return!1}else if("photo"===h){if(!this.analyzeStream(e.first(t.Part),p,a))return!1}else if(!this.validateProfileProperty(h,p,t))return!1}return!0}return!0},canDirectPlayVideo:function(e,t){return t.allowDirectPlay?"hls"!==e.protocol||t.hasFlash||t.hasNativeHLS?"flv"!==e.container||t.hasFlash?!0:(l.warn("MDE: Direct play failed; cannot play FLV"),!1):(l.warn("MDE: Direct play failed; cannot play HLS"),!1):(l.warn("MDE: Direct play failed; option is disabled"),!1)
},canPlayType:function(e,t){if(e===s.elements.PHOTO)return!0;if(e===s.elements.MUSIC&&window.soundManager)return window.soundManager.canPlayMIME(t);var i=document.createElement(e);return!(!i.canPlayType||!i.canPlayType(t).replace(/^no$/,""))},canDirectStream:function(e,t,i,n){return n.directStream?this.analyzeStream(e,t,i):(l.warn("MDE: Direct stream failed; option is disabled"),!1)},analyzeStream:function(t,i){var n=e.keys(i);if(n&&n.length)for(var s=0,a=n.length;a>s;s++){var r=n[s],o=i[r];if(!this.validateProfileProperty(r,o,t))return!1
}return!0},validateProfileProperty:function(t,i,n){var s,r=t.match(/^max(\w)(\w*)/);if(r){if(t=r[1].toLowerCase()+r[2],s=n[t],null!=s&&"videoResolution"===t&&(s=a.getHeightFromResolution(s),i=a.getHeightFromResolution(i)),null!=s&&s>i)return l.warn("MDE: Invalid profile property; "+t+": "+s+" > "+i),!1}else if(s=n[t],s!=i&&!e.contains(i,s))return l.warn("MDE: Invalid profile property; "+t+": "+s+" != "+i),!1;return!0},analyzeSubtitles:function(e,t){var i=t.subtitlesBurnLevel||o.ALWAYS,n=e.codec;return l.log("MDE: Subtitle codec: "+n),l.log("MDE: Burn level: "+i),i===o.ALWAYS?(l.warn("MDE: Direct play failed; asked to always burn subtitles"),{useSoftSubtitles:!1,canDirectPlay:!1,canDirectStreamVideo:!1}):t.transcodeServer.supports("softSubtitles")?i===o.NEVER?{useSoftSubtitles:!0}:(l.warn("MDE: Direct play failed;"+n+" subtitles"),/^(pgs|vobsub)$/i.test(n)?(l.warn("MDE: Soft subtitles failed; bitmap subtitles"),{useSoftSubtitles:!1,canDirectPlay:!1,canDirectStreamVideo:!1}):/^(ass|ssa)$/i.test(n)&&i===o.AUTO?(l.warn("MDE: Soft subtitles failed; ASS subtitles"),{useSoftSubtitles:!1,canDirectPlay:!1,canDirectStreamVideo:!1}):{useSoftSubtitles:!0,canDirectPlay:!1}):(l.warn("MDE: Direct play failed; server support requires burn subtitles"),l.warn("MDE: Soft subtitles failed; server version"),{useSoftSubtitles:!1,canDirectPlay:!1,canDirectStreamVideo:!1})
},canPlay:function(e,t){var i=this.validateParts(e,t)||this.validatePremium(e,t)||this.validateTranscoder(e,t);return i?{canPlay:!1,errorMessage:i}:{canPlay:!0}},validateParts:function(t){var s=n.getMissingParts(t.media);if(s.length){l.warn("MDE: Unable to play; missing parts");var a=e.first(s);return i(1==a.exists?"Please check the permissions for this file.":"Please check that the file exists and the necessary drive is mounted.")}},validatePremium:function(e,t){var n=t.item.server.get("myPlexSubscription");
return e.media.premium&&n===!1?(l.warn("MDE: Unable to play; premium content requires a Plex Pass"),i("Premium content requires your server be connected with a Plex Pass subscription.")):void 0},validateTranscoder:function(e,t){if(!e.canDirectPlay){var n=t.transcodeServer;if(t.type===s.types.VIDEO){var a=n.get("transcoderVideo"),r=e.canDirectStreamVideo||!n.get("transcoderVideoRemuxOnly");if(!a||!r)return l.warn("MDE: Unable to play; server unable to transcode video"),i("This server is not powerful enough to convert video.")
}else if(t.type===s.types.MUSIC){var o=n.get("transcoderAudio");if(!o)return l.warn("MDE: Unable to play; server unable to transcode music"),i("This server is not powerful enough to convert music.")}}},getEffectiveQuality:function(e,t,i){var r=i.quality,o={},l={};if(i.type===s.types.VIDEO){o.bitrate=e.bitrate,o.videoResolution=a.getHeightFromResolution(e.videoResolution);var c=this.getPrimaryStreamProperty(t,"maxBitrate",i);if(c){var d=n.getSelectedVideo(e),u=d?d.bitrate:e.bitrate;o.bitrate=Math.min(u,c),l.maxVideoBitrate=c
}if(r){var h=r.videoResolution;if(h){var p=a.getResolutionFromSize(r.videoResolution),m=a.getHeightFromResolution(p);o.videoResolution=Math.min(o.videoResolution,m)}l.videoQuality=r.videoQuality,l.videoResolution=r.videoResolution}}else if(i.type===s.types.MUSIC){o.bitrate=e.bitrate;var f=this.getPrimaryStreamProperty(t,"maxBitrate",i);f&&(o.bitrate=Math.min(e.bitrate,f),l.maxAudioBitrate=f)}return o.transcoderQualityOptions=l,o},getPrimaryStreamProperty:function(e,t,i){var n=s.getStreamByType(i.type),a=e[n],r=e[t];
return null==r&&a&&(r=a[t]),r},getMediaTitle:function(t){if(t.title)return t.title;var i=t.videoResolution||t.bitrate,s=e.compact([t.container,t.videoCodec,t.audioCodec]),a=n.getSelectedVideo(t);return a&&s.push(a.level,a.profile),s.length&&(i+=" ("+s.join(", ")+")"),i},getDecisionLogs:function(t){var i=["canPlay: "+t.canPlay,"canDirectPlay: "+t.canDirectPlay],n=t.canDirectStreamVideo;null!=n&&i.push("canDirectStreamVideo: "+n);var s=t.canDirectStreamAudio;null!=s&&i.push("canDirectStreamAudio: "+s);
var a=t.useSoftSubtitles;null!=a&&i.push("useSoftSubtitles: "+a);var r=t.bitrate;null==r||e.isNaN(r)||i.push("bitrate: "+r);var o=t.videoResolution;return null==o||e.isNaN(o)||i.push("videoResolution: "+o),i},getBestDecision:function(t){var i=e.last(this.sortDecisions(t));return l.group("MDE: Selected "+this.getMediaTitle(i.media)+" to play",this.getDecisionLogs(i)),i},sortDecisions:function(t){return e.chain(t).reverse().sortBy(this.preferHigherBitrate,this).sortBy(this.preferMoreAudioChannels,this).sortBy(this.preferDirectStreamAudio,this).sortBy(this.preferHigherResolution,this).sortBy(this.preferDirectStreamVideo,this).sortBy(this.preferDirectPlay,this).sortBy(this.preferHigherResolutionIfCapable,this).sortBy(this.preferPlayable,this).value()
},preferPlayable:function(e){return void 0===e.canPlay?null:e.canPlay},preferHigherResolutionIfCapable:function(e){var t=e.transcodeServer,i=t.get("transcoderVideo"),n=t.get("transcoderVideoRemuxOnly");return i&&!n&&(e.canDirectPlay||e.canDirectStreamVideo)?this.preferHigherResolution(e):null},preferDirectPlay:function(e){return void 0===e.canDirectPlay?null:e.canDirectPlay},preferDirectStreamVideo:function(e){return void 0===e.canDirectStreamVideo?null:e.canDirectStreamVideo},preferHigherResolution:function(e){return void 0===e.videoResolution?null:e.videoResolution
},preferDirectStreamAudio:function(e){return void 0===e.canDirectStreamAudio?null:e.canDirectStreamAudio},preferMoreAudioChannels:function(e){var t=e.media.audioChannels;return void 0===t?null:t},preferHigherBitrate:function(e){return void 0===e.bitrate?null:e.bitrate}};return c}),define("plex/base/utils/playerDecisionEngine",["underscore","jquery","plex/base/utils/t","plex/base/utils/playerUtil","plex/base/utils/mediaUtil","plex/base/utils/mediaDecisionEngine","plex/base/utils/constants/subtitlesBurnLevels","plex/base/utils/formatters/stringUtil","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c={getPlayerDecision:function(i){var n=i.item.server;e.defaults(i,{offset:0,minVersionForDASH:n.features.dash,minVersionForStreamingMKV:n.features.streamingMKV,transcoderOptions:{}});var s={session:o.random(),offset:i.offset},a=this.populateMedia(s,i);return a=a.then(e.bind(function(){return this.resolveMedia(s,i)},this)),a=a.then(function(){return t.when(s.url)}),a=a.then(function(e){return s.url=e,s})},populateMedia:function(i,n){var a=t.Deferred(),r=e.bind(a.resolve,a,i);return n.requireAnalysis&&s.isMediaAnalysisRequired(n.item)?n.item.fetch({scope:"player"}).always(r):e.defer(r),a.promise()
},resolveMedia:function(i,n){var s=e.extend({transcodeServer:this.resolveTranscodeServer(n)},n),r=a.getMediaDecision(s),o=r.media,c=t.Deferred();return e.extend(i,r),o?i.canPlay?"webkit"===o.protocol?(l.warn("PDE: Webkit videos are not supported"),i.redirect=!0,c.reject(i).promise()):"embed"===o.protocol?(l.warn("PDE: An embed is required"),i.embed=!0,i.part=e.first(o.Part),c.reject(i).promise()):this.resolvePart(i,n):(l.warn("PDE: Unable to play item; "+i.errorMessage),c.reject(i).promise()):this.resolveUrls(i,n)
},resolveTranscodeServer:function(e){var t=e.item.server,i=e.fallbackServer;if(t===i||!i)return t;var s;return e.type===n.types.VIDEO?s="transcoderVideo":e.type===n.types.MUSIC&&(s="transcoderAudio"),s&&!t.get(s)&&i.get(s)?i:t},resolvePart:function(t,i){return i.part?t.part=i.part:i.offset?1===t.media.Part.length?t.part=t.media.Part[0]:(t.part=s.getPartByAbsoluteOffset(t.media,i.offset),t.offset=s.getRelativeOffset(t.media,t.part,i.offset)):t.part=e.first(t.media.Part),t.media.indirect?this.resolveIndirect(t,i):this.resolveUrls(t,i)
},resolveIndirect:function(i,n){l.log("PDE: Resolving indirect item");var s=n.item.resolveIndirect(i.media,i.part),a=e.bind(function(){return this.resolveMedia(i,n)},this),r=e.bind(function(){return l.warn("PDE: A redirect is required"),i.redirect=!0,t.Deferred().reject(i).promise()},this);return s=s.then(a,r)},resolveUrls:function(e,i){var n=t.Deferred();return this.validatePlayerType(e,i)?(this.validateSoftSubtitles(e,i)?e.subtitlesUrl=this.resolveSubtitlesUrl(e,i):e.useSoftSubtitles&&(e.useSoftSubtitles=!1),l.group("PDE: Player decision",["Player: "+e.playerType,"Protocol: "+e.protocol,"Direct Play: "+e.canDirectPlay]),e.url=e.canDirectPlay?this.resolveDirectPlayUrl(e,i):this.resolveTranscoderUrl(e,i),n.resolve(e).promise()):n.reject(e).promise()
},validatePlayerType:function(e,t){if(!e.media||t.type!==n.types.VIDEO)return e.protocol="http",e.playerType="html",!0;if(e.canDirectPlay)return e.protocol="http",e.playerType="hls"!==e.media.protocol||t.hasNativeHLS?"flv"===e.media.container?"flash":"html":"flash",!0;var s=e.transcodeServer;return t.hasNativeHLS?(e.protocol="hls",e.playerType="html",!0):t.hasStreamingMKV&&s.isVersionOrNewer(t.minVersionForStreamingMKV)?(e.protocol="http",e.playerType="html",!0):t.hasDASH?s.isVersionOrNewer(t.minVersionForDASH)?(e.protocol="dash",e.playerType="html",!0):(e.errorMessage=i("HTML5 streaming requires Plex Media Server {1} or later.",t.minVersionForDASH),!1):t.hasFlash?(e.protocol="hls",e.playerType="flash",!0):(e.errorMessage=i("This browser does not support video streaming."),!1)
},validateSoftSubtitles:function(e){return e.useSoftSubtitles&&"html"!==e.playerType?(l.warn("PDE: Only the HTML player supports soft subtitles"),!1):e.useSoftSubtitles},resolveDirectPlayUrl:function(e,t){var i=t.item,n=e.part;if(n){var s=/(googlevideo|youtube).com/.test(n.key);return"flv"===n.container&&s&&n.postURL?n.postURL:i.server.resolveUrl(n.key,{appendToken:!0})}return i.server.resolveUrl(i.get("key"),{appendToken:!0})},resolveTranscoderUrl:function(t,i){var s=i.item,a=t.media,o=t.part,c=i.transcoderOptions;
e.isFunction(c)&&(c=c(t)),c=e.extend({},t.transcoderQualityOptions,c,{protocol:t.protocol,session:t.session,offset:t.offset/1e3}),i.type===n.types.VIDEO&&(t.useSoftSubtitles?(c.subtitles="auto",i.subtitlesBurnLevel===r.AVOID&&(c.advancedSubtitles="text")):c.subtitles="burn");var d=i.profileExtra;e.isFunction(d)&&(d=d(t)),c["X-Plex-Client-Profile-Extra"]=d,("hls"===c.protocol&&!i.useOffsetHLS||"dash"===c.protocol)&&(l.log("PDE: DASH and HLS should seek forward by default, offset=0"),c.offset=0),"hls"===c.protocol&&i.useOffsetHLS&&(t.useOffsetHLS=!0,c.offset&&(l.log("PDE: HLS started with an offset, copyts=0"),c.copyts=0)),"http"===c.protocol&&(c.copyts=1),"http"!==c.protocol||t.canDirectPlay||(c["X-Plex-Chunked"]=1),e.each(e.keys(c),function(e){var t=c[e];
null==t&&delete c[e]});var u=i.type,h=i.transcoder,p=t.transcodeServer;return u===n.types.VIDEO?h.video(p,s,a,o,c):u===n.types.MUSIC?h.music(p,s,c):u===n.types.PHOTO?(c.fallbackServer=i.fallbackServer,h.image(p,s.getMediaKey(),c)):void 0},resolveSubtitlesUrl:function(e,t){var i=this.resolveTranscoderUrl(e,t),n=i.substring(i.indexOf("?"));return e.transcodeServer.resolveUrl("/video/:/transcode/universal/subtitles"+n)}};return c}),define("plex/desktop/utils/desktopTranscoder",["underscore","jquery","plex/base/utils/transcoder","plex/base/utils/mediaUtil","plex/base/utils/playerQualities","plex/base/utils/formatters/stringUtil","plex/base/adapters/settingsAdapter","jssha256"],function(e,t,i,n,s,a,r){"use strict";
var o="KQMIY6GATPC63AIMC4R2",l=a.decode64("k3U6GLkZOoNIoSgjDshPErvqMIFdE0xMTx8kgsrhnC0="),c=e.extend({},i,{video:function(e,n,s,a,r){if(r||(r={}),e.supports("universalTranscoder"))return i.video(e,n,s,a,r);var o=t.Deferred(),l=this.getTranscoderUrl(e,n,a,r),c=t.ajax(e.getXHROptions(l));return c.done(function(t){var i=t.replace(/[\s\S]+(session.+?\.m3u8)[\s\S]+/,"$1"),n=e.resolveUrl("video/:/transcode/segmented/")+i;o.resolve(n)}),c.fail(function(){o.reject()}),o.promise()},getTranscoderUrl:function(i,c,d,u){var h=s.getCurrentQuality(c,r.getInstance()).index,p=Math.round((new Date).getTime()/1e3),m={identifier:c.get("identifier"),key:i.resolveUrl(c.get("key"),{useLoopback:!0}),url:i.resolveUrl(d.key,{useLoopback:!0}),session:u.session,offset:0,quality:h,subtitleSize:r.get("subtitleSize"),audioBoost:r.get("audioBoost"),"3g":0},f=c.get("indirectHttpHeaders");
f&&(m.httpCookies=f.Cookie,m.userAgent=f["User-Agent"]);var g="/video/:/transcode/segmented/start.m3u8?"+t.param(m,!0);HMAC_SHA256_init(l),HMAC_SHA256_write(g+"@"+p);var v=HMAC_SHA256_finalize(),y=a.encode64(array_to_string(v)),b=n.capabilities;r.get("preferAAC")&&(b=n.capabilities.replace("audioDecoders=mp3,aac","audioDecoders=aac")),r.get("directStream")||(b=n.capabilities.replace(/videoDecoders=[^;]+;audioDecoders=[^;]+/,""));var w=e.extend(i.getHeaders(),{"X-Plex-Access-Key":o,"X-Plex-Access-Code":y,"X-Plex-Access-Time":p,"X-Plex-Client-Capabilities":b});
return g+"&"+t.param(w,!0)}});return c}),function(){"use strict";var e={};!function(){function t(){n||console.log.apply(console,arguments);for(var e=Math.round(Date.now()-a),t=[],i=0;i<arguments.length;i++){var s=""+arguments[i];"[obj"!=s.slice(0,4)&&t.push(s)}var r=e+": "+t.join(", "),o=document.getElementById("console");o&&(o.value+=r+"\n"),n&&console.log(r)}function i(e){s>=e&&t.apply(null,arguments)}var n=!!(window.console&&window.console.log&&window.console.log.call),s=0,a=(new Date).getTime();
e.dlog=i,e.log=t,e.DLOG_LEVEL=s}(),function(){var t={SMOOTH_STREAMING:"smoothstreaming",DASH:"dash"};e.StreamingType=t}(),function(){var t=function(e){this.ttml_=e,this.frameRate_=30};t.prototype.xmlDecode_=function(e){return e.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")},t.prototype.parseChildElements_=function(e,t,i){var n=[];if(null==i)return n;for(var s=i.firstElementChild;null!=s;s=s.nextElementSibling)s.nodeName==e&&n.push(t.call(this,s));
return n},t.prototype.parseAttributes_=function(e,t){var i={};for(var n in e)null!=t.attributes.getNamedItem(n)&&(i[n]=e[n](t.attributes[n].value));return i},t.prototype.parseTime_=function(e){var t=e.split(":"),i=3600*parseFloat(t[0])+60*parseFloat(t[1])+parseFloat(t[2])+parseFloat(t[3])/this.frameRate_;return i},t.prototype.parseTextTrack_=function(e){var t=this.xmlDecode_(e.replace(/[\r\n]+/g,"").replace(/ {2,}/g," ").replace(/<[^>]+>/g,"").replace(/<br\s*\/>/g,"\n"));return t.trim()},t.prototype.parse_cue_=function(e){var t=this.parseAttributes_({begin:this.parseTime_.bind(this),end:this.parseTime_.bind(this)},e);
return t&&(t.caption=this.parseTextTrack_(e.textContent),t.start=t.begin,delete t.begin),t},t.prototype.parse_div_=function(e){return this.parseChildElements_("p",this.parse_cue_,e)},t.prototype.parse_body_=function(e){var t=this.parseChildElements_("div",this.parse_div_,e);return t[0]},t.prototype.parse_ttml_=function(e){var t=this.parseChildElements_("body",this.parse_body_,e);return t[0]},t.prototype.parse=function(){for(var e=new DOMParser,t=e.parseFromString(this.ttml_,"text/xml"),i=0;i<t.childNodes.length;i++)if("tt"===t.childNodes[i].nodeName)return this.parse_ttml_(t.childNodes[i])
},e.Ttml=t}(),function(){var t=0,i=1,n=function(e){if(null==e)throw new Error("A url for the close captions location is required");this._url=e,this._callback=null,this._ccInfo=null};n.prototype.ccType=function(){return t},n.prototype.requestCC=function(){var e=new XMLHttpRequest;e.addEventListener("load",this.onCCLoad.bind(this)),e.addEventListener("error",this.onCCError.bind(this)),e.open("GET",this._url),e.send()},n.prototype.load=function(t){if(null==t)throw new Error("A callback is required");
this._callback=t,this.requestCC(),e.dlog(1,"Sent request to get the close captions info")},n.prototype.getCCInfo=function(){return this._ccInfo},n.prototype.onCCError=function(){var t="Error geting captions from "+this._url;return e.log(t),this._callback(t)},n.prototype.onCCLoad=function(n){e.dlog(2,"Close Captions Info received");var s=null;if(200!==n.target.status||n.target.status>299)return s="HTTP error "+n.target.status+" retrieving close captions from "+this._url,e.log(s),this._callback(s);
switch(this.ccType()){case t:this._ccInfo=new e.Ttml(n.target.responseText).parse();break;case i:throw new Error("VTT parsing not implemented yet")}return null===this._ccInfo?(s="Error parsing the close captions info",e.log(s),this._callback(s)):this._callback(s,this._ccInfo)},e.CloseCaptionsLoader=n}(),function(){function t(e){return e}function i(e){var t=/PT(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?/,i=t.exec(e);return i?3600*parseFloat(i[2]||0)+60*parseFloat(i[4]||0)+parseFloat(i[6]||0):parseFloat(e)
}function n(e,t,i){var n=[];if(null==i)return n;for(var s=i.firstElementChild;null!=s;s=s.nextElementSibling)s.nodeName==e&&n.push(t(s));return n}function s(e,t,i){return n(e,t,i)[0]||null}function a(e,t,i){i=i||{};for(var n in e)null!=t.attributes.getNamedItem(n)&&(i[n]=e[n](t.attributes[n].value));return i}function r(e){var t=/([0-9]+)(\/([0-9]+))?/.exec(e);return t?t[3]?parseFloat(t[1])/(parseFloat(t[3])||1):parseFloat(t[1]):1}function o(e){var t=/([0-9]+)-([0-9]+)/.exec(e);if(!t)return null;var i=parseInt(t[1]),n=parseInt(t[2]);
return{start:i,end:n,length:n-i+1}}function l(e){return a(x,e)}function c(e){return e.textContent}function d(e){return o(e.attributes.range.value)}function u(e){var t=a(k,e);return t.initialization=s("Initialization",d,e),t}function h(e){return a(S,e)}function p(e){var t=u(e);return t.durationSeconds=t.timescale&&t.duration?t.duration/t.timescale:t.duration,t.segmentURLs=n("SegmentURL",l,e),t}function m(e){var t=a(P,e);return t.baseURLs=n("BaseURL",c,e),t.segmentBase=s("SegmentBase",u,e),t.segmentList=s("SegmentList",p,e),t.contentProtection=s("ContentProtection",C,e),t
}function f(e){var t=m(e);return a(A,e,t),t}function g(e){var t=m(e);t.representations=n("Representation",f,e),t.segmentTemplate=s("SegmentTemplate",h,e);for(var i=0;i<t.representations.length;i++)t.representations[i].segmentTemplate=t.segmentTemplate;return t}function v(e){var t=m(e);return a(_,e,t),t.adaptationSets=n("AdaptationSet",g,e),t}function y(e){var t={};return a({mediaPresentationDuration:i},e,t),t.periods=n("Period",v,e),t.baseURLs=n("BaseURL",c,e),t}function b(e,t){e.manifestURL=t,e.duration=e.mediaPresentationDuration,delete e.mediaPresentationDuration,e.adaptationSets=e.periods[0].adaptationSets,delete e.periods;
for(var i=0;i<e.adaptationSets.length;i++)e.adaptationSets[i].mimeType?(e.adaptationSets[i].mime=e.adaptationSets[i].mimeType,delete e.adaptationSets[i].mimeType):e.adaptationSets[i].mime=e.adaptationSets[i].representations[0].mimeType,e.adaptationSets[i].codecs||(e.adaptationSets[i].codecs=e.adaptationSets[i].representations[0].codecs);return e}function w(e,t){var i=new DOMParser,n=i.parseFromString(e,"text/xml");return b(y(n.firstChild),t)}var x={media:t,mediaRange:o,index:t,indexRange:o},k={timescale:parseInt,duration:parseInt,indexRange:o,presentationTimeOffset:parseInt,startNumber:parseInt},S={timescale:parseInt,duration:parseInt,initialization:t,media:t,startNumber:parseInt},C=function(e){var t=e.attributes.schemeIdUri;
if(!t||"http://youtube.com/drm/2012/10/10"!=t.textContent)return null;for(var i={},n=e.firstElementChild;null!=n;n=n.nextElementSibling)if("yt:SystemURL"==n.nodeName){var s=n.attributes.type.textContent;i[s]=n.textContent}return i},P={id:t,profiles:t,width:parseInt,height:parseInt,frameRate:r,audioSamplingRate:parseInt,mimeType:t,codecs:t},A={bandwidth:parseInt,qualityRanking:parseInt},_={id:parseInt,start:i,duration:i};e.parseDASHManifest=w}(),function(){function t(e){for(var t=new DataView(e),i=0;i<e.byteLength;){var n=t.getUint32(i+4,!1);
if(1936286840==n||1836019558==n)break;i+=t.getUint32(i,!1)}return new Uint8Array(e.slice(0,i))}function i(e,t){for(var i=new DataView(e),n=0;1936286840!=i.getUint32(n+4,!1);)if(n+=i.getUint32(n,!1),n>=e.byteLength)throw"Could not find sidx";var s=i.getUint32(n,!1)+n;if(s>e.byteLength)throw"sidx terminates after array buffer";var a=i.getUint8(n+8);n+=12;var r=i.getUint32(n+4,!1);n+=8;var o,l;0==a?(o=i.getUint32(n,!1),l=i.getUint32(n+4,!1),n+=8):(o=(i.getUint32(n,!1)<<32)+i.getUint32(n+4,!1),l=(i.getUint32(n+8,!1)<<32)+i.getUint32(n+12,!1),n+=16),l+=s+(t||0);
var c=i.getUint16(n+2,!1);n+=4;for(var d=l,u=o,h=[],p=0;c>p;p++){var m=i.getUint32(n,!1),f=2147483648&m;if(f)throw"Unhandled indirect reference";m=2147483647&m;var g=i.getUint32(n+4,!1);n+=12,h.push({size:m,offset:d,duration:g/r,time:u/r}),d+=m,u+=g}if(n!=s)throw"Error: final pos "+n+" differs from SIDX end "+s;return h}window.ArrayBuffer&&!window.ArrayBuffer.prototype.slice&&(window.ArrayBuffer.prototype.slice=function(e,t){var i=new Uint8Array(this);null==t&&(t=i.length);for(var n=new ArrayBuffer(t-e),s=new Uint8Array(n),a=0;a<s.length;a++)s[a]=i[a+e];
return n}),e.extractInit=t,e.parseSIDX=i}(),function(){function t(e){return e}function i(e){for(var t=new ArrayBuffer(e.length/2),i=new Uint8Array(t),n=0;n<e.length;n+=2)i[n/2]=parseInt(e.substr(n,2),16);return i}function n(e){for(var t=[],i=0;i<e.length;i+=2)t.push(parseInt(e.substr(i,2),16));return t}function s(e){return i(e.replace(/[{}-]/g,""))}function a(e,t,i){var n=[];if(null==i)return n;for(var s=i.firstElementChild;null!=s;s=s.nextElementSibling)s.nodeName==e&&n.push(t(s));return n}function r(e,t,i){i=i||{};
for(var n in e)null!=t.attributes.getNamedItem(n)&&(i[n]=e[n](t.attributes[n].value));return i}function o(t){var i={},s=t.split("00000001");return 3!==s.length?(t||(e.log("Warning, Audio codec private data is not specified."),t="1210"),i=n(t)):(i.SPS=n(s[1]),i.PPS=n(s[2])),i}function l(t){return"AACL"==t?"mp4a.40.2":"H264"==t||"AVC1"==t?"avc1.4d40":(e.log("Warning, unsupported FourCC encountered: "+t),"")}function c(e){var t={};return r({Bitrate:parseInt},e,t),r({CodecPrivateData:o},e,t),r({MaxWidth:parseInt},e,t),r({MaxHeight:parseInt},e,t),r({FourCC:l},e,t),t
}function d(e){var t={};return r({Bitrate:parseInt},e,t),r({CodecPrivateData:o},e,t),r({SamplingRate:parseInt},e,t),r({Channels:parseInt},e,t),r({BitsPerSample:parseInt},e,t),r({PacketSize:parseInt},e,t),r({FourCC:l},e,t),t}function u(e){var t=[];if(null==e)return t;for(var i=-1,n=e.firstElementChild;null!=n;n=n.nextElementSibling)if("c"==n.nodeName){var s={};if(-1==i&&(i=null!=n.attributes.getNamedItem("t")?parseInt(n.attributes.t.value):0),s.time=i/1e7,s.timeURL=i,null==n.attributes.getNamedItem("d"))throw"Expected attribute 'd' not found";
var a=parseInt(n.attributes.d.value);s.duration=a/1e7,s.durationURL=a,i+=a,t.push(s)}return t}function h(e){var i={};return r({Type:t},e,i),r({Url:t},e,i),"video"===i.Type?i.QualityLevels=a("QualityLevel",c,e):"audio"==i.Type&&(i.QualityLevels=a("QualityLevel",d,e)),i.Fragments=u(e),i}function p(e,t){for(var i=[],n=[],s=!1,a=!1,r=e.length-1;r>=0&&(a||"video"!==e[r].Type||(n.push(r),a=!0),s||"audio"!==e[r].Type||(n.push(r),s=!0),!a||!s);r--);for(var r=0;r<e.length;r++)if(-1!==n.indexOf(r)){var o={};
switch(o.contentProtection=null,e[r].Type){case"audio":o.mime="audio/mp4";break;case"video":o.mime="video/mp4"}if(e[r].QualityLevels){o.representations=[];for(var l=0;l<e[r].QualityLevels.length;l++){var c={};switch(c.bandwidth=e[r].QualityLevels[l].Bitrate,c.baseURLs=[],c.baseURLs[0]=e[r].Url,c.segmentBase=null,c.segs=e[r].Fragments,e[r].Type){case"audio":c.codecs=e[r].QualityLevels[l].FourCC,c.audio_codec_private_data=e[r].QualityLevels[l].CodecPrivateData,c.audio_sample_rate=e[r].QualityLevels[l].SamplingRate;
break;case"video":c.codecs=e[r].QualityLevels[l].FourCC+e[r].QualityLevels[l].CodecPrivateData.SPS[3].toString(16).toLowerCase(),c.sps=e[r].QualityLevels[l].CodecPrivateData.SPS,c.pps=e[r].QualityLevels[l].CodecPrivateData.PPS,c.width=e[r].QualityLevels[l].MaxWidth,c.height=e[r].QualityLevels[l].MaxHeight}o.representations.push(c)}o.codecs=o.representations[0].codecs}t&&(o.contentProtection=t),i.push(o)}return i}function m(e){for(var t=atob(e.trim()),i=new ArrayBuffer(t.length),n=new Uint8Array(i),s=0;s<t.length;s++)n[s]=t.charCodeAt(s);
return{ab:i,u8:n}}function f(e){for(var t=0,i=[],n=[],s=new Uint16Array(e),a=e.byteLength/2;a>t&&(0===i.length||0===n.length);){for(;a>t&&60!==s[t];)t++;if(75===s[t+1]&&73===s[t+2]&&68===s[t+3]&&62===s[t+4])for(t+=5;a>t&&60!==s[t];)i.push(s[t]),t++;else if(76===s[t+1]&&65===s[t+2]&&95===s[t+3]&&85===s[t+4]&&82===s[t+5]&&76===s[t+6]&&62===s[t+7])for(t+=8;a>t&&60!==s[t];)n.push(s[t]),t++;else t++}return{kid:String.fromCharCode.apply(null,i),url:String.fromCharCode.apply(null,n)}}function g(e){var t={};
r({SystemID:s},e,t);var i=m(e.textContent),n=f(i.ab);return t.KID=m(n.kid).u8,t.url=n.url,t.PrHeader=i.u8,t}function v(e){var t={};return t.ProtectionHeader=a("ProtectionHeader",g,e)[0],t}function y(e){var t={};r({TimeScale:parseInt},e,t),t.TimeScale||(t.TimeScale=1e7),r({Duration:parseInt},e,t),t.StreamIndexes=a("StreamIndex",h,e);var i=a("Protection",v,e);i&&i[0]&&(t.Protection=i[0]),t.duration=t.Duration/t.TimeScale;var n;return t.Protection&&(n={},n.playready=t.Protection.ProtectionHeader.url?t.Protection.ProtectionHeader.url:"http://playready.directtaps.net/pr/svc/rightsmanager.asmx"),t.adaptationSets=p(t.StreamIndexes,n),t.Protection&&(t.pr={},t.pr.systemId=t.Protection.ProtectionHeader.SystemID,t.pr.prHeader=t.Protection.ProtectionHeader.PrHeader,t.pr.ivsize=8,t.pr.kid=t.Protection.ProtectionHeader.KID),t
}function b(t,i){return t.manifestURL=i,t.type=e.StreamingType.SMOOTH_STREAMING,t}function w(e,t){for(var i,n=new DOMParser,s=n.parseFromString(e,"text/xml"),a=0;a<s.childNodes.length;a++)if("SmoothStreamingMedia"===s.childNodes[a].nodeName){i=s.childNodes[a];break}return b(y(i),t)}e.parseSSManifest=w}(),function(){function t(e,t,i){e.setUint32(t,i)}function i(e,t,i){for(var n=0;4>n;n++)e.setUint8(t+4+n,i.charCodeAt(n));return 8}function n(e,t,i,n,s){return i.set(s,n),n+s.length}function s(e,n,s,a,r,o){var l=a;
return a+=i(n,a,r),o&&(a=o(e,n,s,a)),t(n,l,a-l),a}function a(e,t,i,a,r,o){return s(e,t,i,a,r,function(e,t,i,s){return n(e,t,i,s,o)})}function r(e,t,i,n){return a(e,t,i,n,"smhd",[0,0,0,0,0,0,0,0])}function o(e,t,i,n){return a(e,t,i,n,"vmhd",[0,0,0,1,0,0,0,0,0,0,0,0])}function l(e,t,i,a){return s(e,t,i,a,"esds",function(e,t,i,s){var a=e.audio_codec_private_data[0],r=e.audio_codec_private_data[1];return s=n(e,t,i,s,[0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,a,r,6,1,2])})}function c(e,t,i,a){return s(e,t,i,a,"avcC",function(e,t,i,s){return s=n(e,t,i,s,[1,77,64,30,255,225]),t.setUint16(s,e.sps.length),s+=2,s=n(e,t,i,s,e.sps),t.setUint8(s,1),s+=1,t.setUint16(s,e.pps.length),s+=2,s=n(e,t,i,s,e.pps)
})}function d(e,t,i){for(var n=i-t+1,s=0,a=t;t+n/2>a;a++)s=e[a],e[a]=e[i-a+t],e[i-a+t]=s}function u(e){var t=new ArrayBuffer(e.length),i=new Uint8Array(t);return i.set(e),d(i,0,3),d(i,4,5),d(i,6,7),i}function h(e,t,i,a){return s(e,t,i,a,"tenc",function(e,t,i,s){s=n(e,t,i,s,[0,0,0,0,0,0,1]),t.setUint8(s,e.pr.ivsize),s++;var a=u(e.pr.kid);return s=n(e,t,i,s,a)})}function p(e,t,i,n){return s(e,t,i,n,"schi",function(e,t,i,n){return n=h(e,t,i,n)})}function m(e,t,i,n){return a(e,t,i,n,"schm",[0,0,0,0,99,101,110,99,0,1,0,0])
}function f(e,t,i,n){return"audio/mp4"!==e.mime?a(e,t,i,n,"frma",[97,118,99,49]):a(e,t,i,n,"frma",[109,112,52,97])}function g(e,t,i,n){return s(e,t,i,n,"sinf",function(e,t,i,n){return n=f(e,t,i,n),n=m(e,t,i,n),n=p(e,t,i,n)})}function v(e,t,i,a,r){return s(e,t,i,a,r,function(e,t,i,s){var a=e.audio_sample_rate>>8&255,o=255&e.audio_sample_rate;return s=n(e,t,i,s,[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,a,o,0,0]),s=l(e,t,i,s),"enca"===r&&(s=g(e,t,i,s)),s})}function y(e,t,i,a,r){return s(e,t,i,a,r,function(e,t,i,s){return s=n(e,t,i,s,[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.setUint16(s,e.width),s+=2,t.setUint16(s,e.height),s+=2,s=n(e,t,i,s,[0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]),s=c(e,t,i,s),"encv"===r&&(s=g(e,t,i,s)),s
})}function b(e,t,i,a){return s(e,t,i,a,"stsd",function(e,t,i,s){return s=n(e,t,i,s,[0,0,0,0,0,0,0,1]),"audio/mp4"!==e.mime?(e.pr&&(s=y(e,t,i,s,"encv")),s=y(e,t,i,s,"avc1")):(e.pr&&(s=v(e,t,i,s,"enca")),s=v(e,t,i,s,"mp4a")),s})}function w(e,t,i,a){return s(e,t,i,a,"stbl",function(e,t,i,s){return s=b(e,t,i,s),s="audio/mp4"!==e.mime?n(e,t,i,s,[0,0,0,16,115,116,116,115,0,0,0,0,0,0,0,0,0,0,0,16,115,116,115,99,0,0,0,0,0,0,0,0,0,0,0,16,115,116,99,111,0,0,0,0,0,0,0,0,0,0,0,20,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,115,116,115,115,0,0,0,0,0,0,0,0]):n(e,t,i,s,[0,0,0,16,115,116,116,115,0,0,0,0,0,0,0,0,0,0,0,16,115,116,115,99,0,0,0,0,0,0,0,0,0,0,0,16,115,116,99,111,0,0,0,0,0,0,0,0,0,0,0,20,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,0])
})}function x(e,t,i,n){return a(e,t,i,n,"url ",[0,0,0,1])}function k(e,t,i,a){return s(e,t,i,a,"dref",function(e,t,i,s){return s=n(e,t,i,s,[0,0,0,0,0,0,0,1]),s=x(e,t,i,s)})}function S(e,t,i,n){return s(e,t,i,n,"dinf",function(e,t,i,n){return n=k(e,t,i,n)})}function C(e,t,i,n){return s(e,t,i,n,"minf",function(e,t,i,n){return n=S(e,t,i,n),n=w(e,t,i,n),n="audio/mp4"!==e.mime?o(e,t,i,n):r(e,t,i,n)})}function P(e,t,i,n){return"audio/mp4"!==e.mime?a(e,t,i,n,"hdlr",[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]):a(e,t,i,n,"hdlr",[0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])
}function A(e,t,i,n){return a(e,t,i,n,"mdhd",[0,0,0,0,204,96,118,241,204,96,118,241,0,152,150,128,0,0,0,0,85,196,0,0])}function _(e,t,i,n){return s(e,t,i,n,"mdia",function(e,t,i,n){return n=A(e,t,i,n),n=P(e,t,i,n),n=C(e,t,i,n)})}function I(e,t,i,a){return s(e,t,i,a,"tkhd",function(e,t,i,s){return s=n(e,t,i,s,[0,0,0,3,204,96,118,241,204,96,118,241,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0]),t.setUint32(s,e.width),s+=4,t.setUint32(s,e.height),s+=4,t.setUint16(s,0),s+=2
})}function T(e,t,i,n){return s(e,t,i,n,"trak",function(e,t,i,n){return n=I(e,t,i,n),n=_(e,t,i,n)})}function M(e,t,i,n){return a(e,t,i,n,"trex",[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])}function D(e,t,i,n){return s(e,t,i,n,"mvex",function(e,t,i,n){return n=M(e,t,i,n)})}function E(e,t,i,a){return s(e,t,i,a,"pssh",function(e,t,i,s){return s=n(e,t,i,s,[0,0,0,0]),s=n(e,t,i,s,e.pr.systemId),t.setUint32(s,e.pr.prHeader.length),s+=4,s=n(e,t,i,s,e.pr.prHeader)})}function L(e,t,i,n){return a(e,t,i,n,"mvhd",[0,0,0,0,204,96,118,241,204,96,118,241,0,152,150,128,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2])
}function R(e,t,i,n){return s(e,t,i,n,"moov",function(e,t,i,n){return n=L(e,t,i,n),e.pr&&(n=E(e,t,i,n)),n=D(e,t,i,n),n=T(e,t,i,n)})}function O(e){var t=new ArrayBuffer(2e4),i=new DataView(t),n=new Uint8Array(t),s=0,a=0;s=R(e,i,n,s),a=s-1;var r={};return r.data=t.slice(0,s),r.init={},r.init.start=0,r.init.end=a,r}function N(e,t,i){for(var n=0,s=t,a=0;4>a;a++)n<<=8,n+=i.charCodeAt(a);for(;e.getUint32(s+4,!1)!=n;)if(s+=e.getUint32(s),s>=e.byteLength)throw"Could not find box: "+i;return s}function F(e,t){var i=N(e,t,"traf");
i=N(e,i+8,"tfhd"),e.setUint32(i+12,1)}function B(e,t,i,n){var s=N(e,t,i),a=e.getUint32(s);return e.setUint32(s,a+n),s}function U(e,t,i){var n=0;if(n=B(e,n,"moof",t),n=B(e,n+8,"traf",t),n=N(e,n+8,"trun"),1&e.getUint32(n+8)){var s=n+16;e.setUint32(s,i)}return n}function V(e,t,i){var n=0;if(n=B(e,n,"moof",t),n=B(e,n+8,"traf",t),n=N(e,n+8,"trun"),1&e.getUint32(n+8)){var s=n+16,a=e.getUint32(s);e.setUint32(s,a+i)}return n}function z(e,t){var i=[0,0,0,20,116,102,100,116,1,0,0,0],n=i.length+8,s=new ArrayBuffer(e.byteLength+n),a=(new Uint8Array(e),new DataView(e)),r=new Uint8Array(s),o=new DataView(s),l=0;
return F(a,8),l=V(a,n,n),r.set(new Uint8Array(e,0,l)),r.set(i,l),o.setUint32(l+12,t/4294967295&4294967295),o.setUint32(l+16,4294967295&t),r.set(new Uint8Array(e,l,e.byteLength-l),l+n),s}function j(e,t,i,n,s){if(!s)return new Uint8Array(0);for(var a=new Uint8Array(i),r=0,o=0,l=t,c=0;i>c;c++)r=e.getUint16(l+n),o=n+2+6*r,a[c]=o,l+=o;return a}function q(e,t,i,a,r,o){return s(e,t,i,a,"mdat",function(e,t,i,s){return s=n(e,t,i,s,r),s=n(e,t,i,s,o)})}function H(e,t,i,a){return s(e,t,i,a,"saio",function(e,t,i,s){s=n(e,t,i,s,[0,0,0,0,0,0,0,1]);
var a=s+4+8;return t.setUint32(s,a),s+=4})}function W(e,t,i,a,r,o,l,c){return s(e,t,i,a,"saiz",function(e,t,i,s){return s=l?n(e,t,i,s,[0,0,0,0,0]):n(e,t,i,s,[0,0,0,0,c]),t.setUint32(s,r),s+=4,i.set(o,s),s+=o.length})}function $(e){var t=new DataView(e),i=0,n=0,s=0,a=t.getUint32(i);i=N(t,i+8,"traf"),i=N(t,i+8,"trun"),n=t.getUint32(i+12),i=N(t,i,"uuid");var r=t.getUint8(i+27),o=!1;if(2!==r&&0!==r)throw"uuid flags expected is 0x02 or 0x00 but found: "+r;2===r&&(o=!0);var l=t.getUint32(i+28);if(n!==l)throw"Samples count does not match "+n+" "+l;
var c=t.getUint32(i);s=c-32;var d=200,u=new ArrayBuffer(e.byteLength+d),h=new Uint8Array(u),p=new DataView(u);h.set(new Uint8Array(e,0,i));var m=i,f=8,g=i+32,v=i+c,y=t.getUint32(v),b=j(t,g,n,f,o);if(m=W(null,p,h,m,n,b,o,f),m=H(null,p,h,m),o){for(var w=0,x=0;x<b.length;x++)w+=b[x];if(w!==s)throw"Samples size does not match "+w+" "+s}else if(f*n!==s)throw"Samples size does not match "+f*n+" "+s;var k=new Uint8Array(e,g,s),S=new Uint8Array(e,v+8,y-8),C=m-a,P=m;return m=q(null,p,h,m,k,S),U(p,C,P+8+s),new Uint8Array(u,0,m)
}function Y(e,t,i){var n=z(e,t);return i?$(n):new Uint8Array(n)}e.abtohex=function(e){for(var t=[],i=0;i<e.byteLength;i++)t.push(e[i].toString(16));return t},e.abtob64=function(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e)))},e.createSSInit=O,e.process_traf=Y}(),function(){function t(e){for(var t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}function i(e){return String.fromCharCode.apply(String,e)}var n=function(e){this.video=e,!e.generateKeyRequest&&e.webkitGenerateKeyRequest&&(e.generateKeyRequest=e.webkitGenerateKeyRequest),!e.addKey&&e.webkitAddKey&&(e.addKey=e.webkitAddKey),this.initDataQueue=[],this.flavor=null,this.keySystem=null,this.licenseServerURL=null,e.generateKeyRequest&&e.addKey&&(e.addEventListener("needkey",this.onNeedKey.bind(this)),e.addEventListener("keymessage",this.onKeyMessage.bind(this)),e.addEventListener("keyerror",this.onKeyError.bind(this)),e.addEventListener("webkitneedkey",this.onNeedKey.bind(this)),e.addEventListener("webkitkeymessage",this.onKeyMessage.bind(this)),e.addEventListener("webkitkeyerror",this.onKeyError.bind(this)))
};n.kMime='video/mp4; codecs="avc1.640028"',n.kFlavorToSystem={clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.youtube.playready","com.microsoft.playready"]},n.prototype.init=function(e,t){this.chooseFlavor(n.kMime,e,t),this.isClearKey="clearkey"==this.flavor},n.prototype.chooseFlavor=function(e,t,i){for(var s in t)if(!i||s==i){var a=n.kFlavorToSystem[s];if(a)for(var r in a)if(this.video.canPlayType(e,a[r]))return this.flavor=s,this.keySystem=a[r],void(this.licenseServerURL=t[s])
}throw"Could not find a compatible key system"},n.prototype.extractBMFFClearKeyID=function(e){var t=new ArrayBuffer(e.length),i=new Uint8Array(t);i.set(e);for(var n=new DataView(t),s=0;s<t.byteLength;){var a=n.getUint32(s,!1),r=n.getUint32(s+4,!1);if(1886614376!=r)throw"Box type "+r.toString(16)+' not equal to "pssh"';if(1477738184==n.getUint32(s+12,!1)&&69420633==n.getUint32(s+16,!1)&&2464609580==n.getUint32(s+20,!1)&&1558758348==n.getUint32(s+24,!1)){var o=n.getUint32(s+28,!1);if(16!=o)throw"Unexpected KID size "+o;
return new Uint8Array(t.slice(s+32,s+32+o))}if(3991899049==n.getUint32(s+12,!1)&&2044086990==n.getUint32(s+16,!1)&&2747803612==n.getUint32(s+20,!1)&&3575456237==n.getUint32(s+24,!1))return new Uint8Array(t.slice(s+36,s+52));s+=a}return e},n.prototype.onNeedKey=function(t){if(e.dlog(2,"onNeedKey()"),!this.keySystem)throw"Not initialized! Bad manifest parse?";if(16==t.initData.length)return void e.log("Dropping non-BMFF needKey event");var i=t.initData;this.isClearKey&&(i=this.extractBMFFClearKeyID(t.initData)),this.video.generateKeyRequest(this.keySystem,i),this.initDataQueue.push(i)
},n.prototype.onKeyMessage=function(t){e.dlog(2,"onKeyMessage() Sending request: "+this.licenseServerURL+" "+t.sessionId);var i=this.initDataQueue.shift(),n=new XMLHttpRequest;n.open("POST",this.licenseServerURL),n.setRequestHeader("content-type","text/xml;charset=utf-8"),n.addEventListener("load",this.onLoad.bind(this,i,t.sessionId)),n.responseType="arraybuffer",n.send(t.message)},n.prototype.onKeyError=function(t){e.dlog(2,"onKeyError("+t.keySystem+", "+t.errorCode.code+", "+t.systemCode+")")},n.prototype.onLoad=function(n,s,a){if(e.dlog(2,"onLoad("+this.licenseServerURL+"): "+s),a.target.status<200||a.target.status>299)throw"Bad XHR status: "+a.target.statusText;
{var r=i(new Uint8Array(a.target.response)).split("\r\n").pop();this.video.addKey(this.keySystem,t(r),n,s)}},e.EMEManager=n}(),function(){var t=function(e,t,i,n,s,a,r){this.url=e,this.bandwidth=t,this.width=i,this.height=n,this.sps=s,this.pps=a,this.codecs=r,this.initFragment=null,this.initRequestData=null,this.indexRequestData=null,this.isInitialized=!1,this.segs=null};e.Representation=t}(),function(){var t={ENOUGH:20},i=function(e,t,i,n,s,a){if(this.sourceBuffer_=t,this.sourceBuffer_.appendBuffer)this.appendBuffer_=this.sourceBuffer_.appendBuffer,this.sourceBuffer_.addEventListener("updateend",this.onUpdateEnd.bind(this));
else{if(!this.sourceBuffer_.append)throw new Error("Unknown SourceBuffer interface");this.appendBuffer_=this.sourceBuffer_.append}this.representations_=i,this.currentRep=0,this.segIndex=null,this.mime=n,this.resetReason=null,this.active=!0,this.type=s,this.pr_=a,this.seekingStartTime=null,this.mediaSrc_=e,this.bitrates=[];for(var r=0;r<this.representations_.length;r++)this.bitrates.push(this.representations_[r].bandwidth);this.deferredAppends_=[],this.segmentQueue=[],this.segmentSize=0,this.segmentLastEndTime=0,this.waitingForBuffer=!1,this.segmentTimeout=null
};i.prototype.getCurrentTime=function(){return window.googledash.player.getMediaElement().currentTime},i.prototype.updateBuffer=function(){var t=this.sourceBuffer_.buffered;if(t.length>0){var i=t.end(t.length-1)-this.segmentLastEndTime;e.dlog(3,"["+this.mime+"] Play head: "+this.getCurrentTime()+" Segment size: "+(this.segmentSize/1024/1024).toFixed(2)+" MB Segment duration: "+i),this.segmentQueue.push({size:this.segmentSize,duration:i,offset:this.segmentLastEndTime})}},i.prototype.reset=function(t){e.dlog(1,"SourceBuffer["+this.mime+"] reset: "+t),this.segIndex=null,this.representations_[this.currentRep].isInitialized=!1,this.resetReason=t||null,this.active=!0,this.segmentQueue=[],this.segmentSize=0,this.segmentLastEndTime=0,this.waitingForBuffer=!1,null!=this.segmentTimeout&&clearTimeout(this.segmentTimeout),"open"==this.mediaSrc_.readyState&&this.sourceBuffer_.abort()
},i.prototype.isInitialized=function(){return this.representations_[this.currentRep].isInitialized},i.prototype.initialize=function(){this.representations_[this.currentRep].isInitialized=!0},i.prototype.updating=function(){return this.sourceBuffer_.updating},i.prototype.onUpdateEnd=function(){this.updateBuffer(),this.deferredAppends_.length>0&&(e.dlog(2,"SourceBuffer["+this.mime+"] appended deferred data"),this.append(this.deferredAppends_.pop()))},i.prototype.append=function(t){var i=this.sourceBuffer_.buffered;
if(this.segmentSize=t.length,this.segmentLastEndTime=0,i.length>0&&(this.segmentLastEndTime=i.end(i.length-1)),this.sourceBuffer_.updating){if(this.deferredAppends_.length<5)return e.dlog(2,"SourceBuffer["+this.mime+"] deferring append"),void this.deferredAppends_.push(t);e.log("SourceBuffer["+this.mime+"] too many deferrals, aborting"),this.deferredAppends_=[],this.appendBuffer_.abort()}this.appendBuffer_.call(this.sourceBuffer_,t),"appendBuffer"in this.sourceBuffer_||this.updateBuffer()},i.prototype.getCurrentRep=function(){return this.representations_[this.currentRep]
},i.prototype.changeQuality=function(t){if(t===this.currentRep)return!1;e.dlog(2,"Bandwitdth change sourceBuffer["+this.mime+"]: "+this.active),e.dlog(2,"bandwidthChange["+this.mime+"]: "+this.currentRep+" "+t);var i,n=this.representations_[this.currentRep].bandwidth,s=this.representations_[t].bandwidth;e.dlog(2,"bandwidthChange["+this.mime+"]: "+n+" "+s),i=n>s?"rep_down":"rep_up",this.reset(i),this.currentRep=t},i.prototype.getRangesString=function(){for(var e=this.sourceBuffer_.buffered,t="Ranges["+this.mime+"]:",i=0;i<e.length;i++)t+=" ["+e.start(i)+","+e.end(i)+"]";
return t},i.prototype.findRangeForPlaybackTime=function(e){for(var t=this.sourceBuffer_.buffered,i=0;i<t.length;i++)if(t.start(i)<=e&&t.end(i)>=e)return{start:t.start(i),end:t.end(i)};return null},i.prototype.getBufferSize=function(t){e.dlog(4,"Time: "+t+" Ranges in onProgress: "+this.getRangesString());var i=this.findRangeForPlaybackTime(t),n=i&&i.end||0;if(null!==this.segIndex){var s=this.representations_[this.currentRep].segs[this.segIndex].time;n=s>n?s:n}if(i){var a=Math.abs(i.end-n);a>.001&&e.dlog(2,"Difference in available data: "+i.end+" "+n)
}return n-t},i.prototype.findSegmentIndexForTime=function(t){for(var i=this.representations_[this.currentRep].segs,n=0;n<i.length;n++){var s=i[n];if(s.time<=t&&s.time+s.duration>=t)return n==i.length-1&&s.time+s.duration+.5<t?null:n}return e.dlog(5,"Could not find segment for time "+t),null},i.prototype.identifyNextFragment=function(i){var n=this.findRangeForPlaybackTime(i),s=n&&n.end||i;if(s>i+t.ENOUGH)return e.dlog(3,"Enough buffering currentTime in rage: "+this.mime+" "+i+"  "+s),null;if(1==this.waitingForBuffer)return null;
if(null==this.segIndex){if(e.dlog(4,"Non existing index, finding the index for the next request["+this.mime+"]"),this.segIndex=this.findSegmentIndexForTime(s),null===this.segIndex)return this.active=!1,null;e.dlog(4,"New Index["+this.mime+"]: "+s+" "+this.segIndex)}else{null==n&&e.log("Playback head outside of buffer in append-continue state.");var a=this.representations_[this.currentRep].segs[this.segIndex].time;if(a>i+t.ENOUGH)return e.dlog(3,"Enough buffering: "+this.mime+" "+this.segIndex+" "+i+"  "+a),null
}return s},i.prototype.appendData=function(t){for(e.dlog(2,"["+this.mime+"] Time is "+this.getCurrentTime()+", asked to add a "+(t.byteLength/1024/1024).toFixed(2)+" MB segment, see if we can."),this.segmentQueue.length>0&&e.dlog(2,"["+this.mime+"] End of first segment is "+(this.segmentQueue[0].offset+this.segmentQueue[0].duration).toFixed(2));this.segmentQueue.length>0&&this.segmentQueue[0].offset+this.segmentQueue[0].duration<this.getCurrentTime()+2;)e.dlog(2,"["+this.mime+"] Removing collectable segment."),this.segmentQueue.shift();
for(var i=0,n=0;n<this.segmentQueue.length;n++)i+=this.segmentQueue[n].size;e.dlog(2,"["+this.mime+"] Time is "+this.getCurrentTime()+" and there are "+(i/1024/1024).toFixed(2)+" MB uncollectable, bringing the proposed total to "+((i+t.byteLength)/1024/1024).toFixed(2)+" MB."),(i+t.byteLength)/1024/1024>24&&this.segmentQueue.length>0?(e.dlog(2,"["+this.mime+"] Waiting for buffer to have enough room."),this.waitingForBuffer=!0,this.segmentTimeout=setTimeout(function(){this.appendData(t)}.bind(this),1e3)):(this.reallyAppendData(t),this.waitingForBuffer=!1)
},i.prototype.reallyAppendData=function(t){e.dlog(3,"["+this.mime+"] Current Time: "+this.getCurrentTime()+" Ranges in appendData1: "+this.getRangesString());var i,n=this.representations_[this.currentRep].segs[this.segIndex].time,s=n+this.representations_[this.currentRep].segs[this.segIndex].duration;e.dlog(4,"Appending Response ["+this.mime+"] : ["+n+","+s+"]"),i=this.type===e.StreamingType.SMOOTH_STREAMING?process_traf(t,this.representations_[this.currentRep].segs[this.segIndex].timeURL,this.pr_):new Uint8Array(t),this.append(i),this.segIndex++,this.segIndex>=this.representations_[this.currentRep].segs.length&&(this.active=!1,e.dlog(2,"Source["+this.mime+"] is not active: "+this.segIndex+" "+this.representations_[this.currentRep].segs.length)),e.dlog(3,"Ranges in appendData2: "+this.getRangesString())
},e.SourceBufferManager=i}(),function(){var t=function(){this.mediaSrc_=null,this.sourceBufferManagers_=[],this.videoSrcBufIndex_=0,this.emeMgr_=null,this.type=null,this.pr,this.manifest_=null,this.attachedHandlers_={}};t.prototype.getMediaSource=function(){return this.mediaSrc_},t.prototype.dispose=function(){null!=this.mediaSrc_&&(this.detachAllHandlers_(),this.resetAll(),this.mediaSrc_=null,this.sourceBufferManagers_=[])},t.prototype.getSourceBufferCount=function(){return this.sourceBufferManagers_.length
},t.prototype.getVideoSrcBufferIndex=function(){return this.videoSrcBufIndex_},t.prototype.getLevel=function(e){return this.sourceBufferManagers_[e].currentRep},t.prototype.getSegIndex=function(e){return this.sourceBufferManagers_[e].segIndex},t.prototype.getCurrentRep=function(e){return this.sourceBufferManagers_[e].getCurrentRep()},t.prototype.getBufferSize=function(e,t){return this.sourceBufferManagers_[e].getBufferSize(t)},t.prototype.getLevel=function(e){return this.sourceBufferManagers_[e].currentRep
},t.prototype.appendData=function(e,t){this.mediaSrc_&&"closed"!==this.mediaSrc_.readyState&&this.sourceBufferManagers_[e].appendData(t)},t.prototype.append=function(e,t){this.mediaSrc_&&"closed"!==this.mediaSrc_.readyState&&this.sourceBufferManagers_[e].append(t)},t.prototype.isActive=function(e){return this.sourceBufferManagers_[e].active},t.prototype.isInitialized=function(e){return this.sourceBufferManagers_[e].isInitialized()},t.prototype.initialize=function(e){this.sourceBufferManagers_[e].initialize()
},t.prototype.mime=function(e){return this.sourceBufferManagers_[e].mime},t.prototype.getBitrates=function(e){return this.sourceBufferManagers_[e].bitrates},t.prototype.identifyNextFragment=function(e,t){return this.sourceBufferManagers_[e].identifyNextFragment(t)},t.prototype.resetAll=function(e){for(var t=0;t<this.sourceBufferManagers_.length;t++)this.sourceBufferManagers_[t].reset(e)},t.prototype.reset=function(e,t){this.sourceBufferManagers_[e].reset(t)},t.prototype.changeQuality=function(e,t){return this.sourceBufferManagers_[e].changeQuality(t)
},t.prototype.endOfStream=function(){if(this.mediaSrc_&&"open"===this.mediaSrc_.readyState){for(var t=!1,i=0;i<this.sourceBufferManagers_.length;i++)if(this.sourceBufferManagers_[i].updating()){t=!0;break}t||(e.log("Ending stream"),this.mediaSrc_.endOfStream())}},t.prototype.absolutizeURL=function(e,t){if(void 0===t&&(t=""),t.match(/^[a-z]*:\/\//))return t;var i;return i="/"==t[0]?e.match(/^[a-z]*:\/\/[^\/]*/)[0]:e.replace(/\/[^\/]*$/,"/"),i+t},t.prototype.displaySourceBuffers=function(t){for(var i=0;i<this.mediaSrc_.sourceBuffers.length;i++){var n=this.mediaSrc_.sourceBuffers[i];
e.dlog(5,t+" SourceBuffer["+n.mime+"]: "+n.active)}},t.prototype.normalizeRepresentation=function(t){var i={url:this.absolutizeURL(this.manifest_.manifestURL,t.baseURLs[0]),bandwidth:t.bandwidth,width:t.width,height:t.height,sps:t.sps,pps:t.pps,audio_codec_private_data:t.audio_codec_private_data,audio_sample_rate:t.audio_sample_rate};if(this.type===e.StreamingType.SMOOTH_STREAMING)return i.segs=t.segs,i;var n=null;if(null!=t.segmentList){n=t.segmentList.initialization,i.segs=[];for(var s=0;s<t.segmentList.segmentURLs.length;s++){var a=t.segmentList.segmentURLs[s],r={start:a.mediaRange.start,end:a.mediaRange.end,index:a.indexRange&&a.indexRange.end||null,time:t.segmentList.durationSeconds*s,duration:t.segmentList.durationSeconds,subsegments:null};
i.segs.push(r)}}else if(null!=t.segmentTemplate){i.segs=[];var o=t.segmentTemplate.duration/t.segmentTemplate.timescale,r={url:i.url+t.segmentTemplate.initialization.replace("$RepresentationID$",t.id)};i.segs.push(r);for(var l=0;l*o<this.manifest_.duration;l++){var r={start:-1,end:-1,index:null,time:l*o,duration:o,subsegments:null,url:i.url+t.segmentTemplate.media.replace("$RepresentationID$",t.id).replace("$Number$",l)};i.segs.push(r)}}else{var r={start:null,end:null,index:null,time:0,duration:this.manifest_.duration,subsegments:null};
if(null!=t.segmentBase){var a=t.segmentBase;n=a.initialization,null!=a.indexRange&&(i.indexRequestData=a.indexRange)}i.segs=[r]}return this.type!==e.StreamingType.SMOOTH_STREAMING&&(i.initRequestData={start:n&&n.start||0,end:n&&n.end||i.segs[0].index||null}),i},t.prototype.onSourceOpen=function(t,i,n){e.dlog(2,"onSourceOpen()");var s,a,r,o;if(this.mediaSrc_.sourceBuffers.length)for(e.dlog(2,"onSourceOpen(): Target already has buffers, bailing."),r=0;r<this.mediaSrc_.sourceBuffers.length;r++)this.mediaSrc_.sourceBuffers[r].active=!0;
else{for(this.mediaSrc_.duration=this.manifest_.duration,this.sourceBufferManagers_=[],this.emeMgr_=new e.EMEManager(t),this.type=this.manifest_.type,this.pr=this.manifest_.pr,r=0;r<this.manifest_.adaptationSets.length;r++)if(o=this.manifest_.adaptationSets[r],!(o.mime&&o.mime.indexOf("webm")>=0)){o.contentProtection&&this.emeMgr_.init(o.contentProtection,options.flavor),s=o.representations.map(this.normalizeRepresentation.bind(this)),a=this.mediaSrc_.addSourceBuffer(o.mime+'; codecs="'+o.codecs+'"'),e.dlog(2,"Buffer added properly: "+(this.mediaSrc_.sourceBuffers[r]===a));
var l=new e.SourceBufferManager(this.mediaSrc_,a,s,o.mime,this.type,this.pr);o.mime.indexOf("video")>=0&&(this.videoSrcBufIndex_=r),this.sourceBufferManagers_.push(l),e.dlog(2,"onSourceOpen. Initialized SourceBuffer["+o.mime+"]")}n()}},t.prototype.isSupported=function(){return null==window.MediaSource&&null==window.WebKitMediaSource?!1:(null==window.MediaSource&&(window.MediaSource=window.WebKitMediaSource),!0)},t.prototype.init=function(){this.mediaSrc_=new MediaSource},t.prototype.attach=function(e,t,i,n){if(!this.mediaSrc_)throw new Error("MediaSourceManager has not been initialized, please call init()");
this.manifest_=t,this.attachHandler_("sourceopen",this.onSourceOpen.bind(this,e,i,n)),this.attachHandler_("webkitsourceopen",this.onSourceOpen.bind(this,e,i,n)),e.src=window.URL.createObjectURL(this.mediaSrc_)},t.prototype.attachHandler_=function(e,t){this.attachedHandlers_[e]||(this.attachedHandlers_[e]=[]),this.attachedHandlers_[e].push(t),this.mediaSrc_.addEventListener(e,t)},t.prototype.detachAllHandlers_=function(){var e,t=this.attachedHandlers_,i=this.mediaSrc_;for(var n in t){e=t[n];for(var s=0;s<e.length;s++)i.removeEventListener(n,e[s]);
e.length=0}},e.MediaSourceManager=t}(),function(){var t=0,i=1,n=function(e){if(null==e)throw new Error("A url for the manifest is required");this.url_=e,this.callback_=null,this.manifest_=null};n.prototype.load=function(t){if(null==t)throw new Error("A callback is required");this.callback_=t,this.requestManifest_(),e.dlog(1,"Sent request to get the manifest")},n.prototype.getManifest=function(){return this.manifest_},n.prototype.manifestType_=function(){return-1!=this.url_.lastIndexOf(".mpd")?t:i
},n.prototype.requestManifest_=function(){var e=new XMLHttpRequest;e.addEventListener("load",this.onManifestLoad_.bind(this)),e.addEventListener("error",this.onManifestError_.bind(this)),e.open("GET",this.url_),e.send()},n.prototype.onManifestError_=function(){var t="Error retrieving manifest from "+this.url_;return e.log(t),this.callback_(t)},n.prototype.onManifestLoad_=function(n){e.dlog(2,"Manifest received");var s=null;if(n.target.status<200||n.target.status>299)return s="HTTP error "+n.target.status+" retrieving manifest from "+this.url_,e.log(s),this.callback_(s);
switch(this.manifestType_()){case t:this.manifest_=e.parseDASHManifest(n.target.responseText,this.url_);break;case i:this.manifest_=e.parseSSManifest(n.target.responseText,this.url_)}return null===this.manifest_?(s="Error parsing the manifest",e.log(s),this.callback_(s)):this.callback_(s,this.manifest_)},e.ManifestLoader=n}(),function(){var t=.99,i=.98,n=5e5,s=5e5,a=function(e,t,i){this.bitrates_=e,this.levelCount_=this.bitrates_.length,this.algorithm_=t||"adaptive",this.cooldownPeriod_=2,i&&(this.level_=parseInt(i))
};a.prototype.onBandwithTracking=function(a){var r=a.target;if(null!=r.lastTime&&a.timeStamp!=r.lastTime){var o=8e3*(a.loaded-r.lastSize)/(a.timeStamp-r.lastTime);n=t*n+(1-t)*o,s=i*s+(1-i)*o}r.lastTime=a.timeStamp,r.lastSize=a.loaded,e.dlog(5,"Calculated bandwidth: "+n+" "+s)},a.prototype.adapt=function(t){if(!this.bitrates_||this.bitrates_.length<=1)return-1;var i=-1;if("fixed"===this.algorithm_)i=this.level_;else if("random"===this.algorithm_)Math.random()>.5&&(i=Math.floor(Math.random()*this.levelCount_));
else if("adaptive"===this.algorithm_)if(this.cooldownPeriod_)this.cooldownPeriod_--;else{var a=0,r=0,o=.85,l=Math.min(n,s);e.dlog(5,"Calculated Bandwidth: "+l+" globalSlowBandwidth: "+n+" globalFastBandwidth: "+s);for(var c=0;c<this.bitrates_.length;c++){var d=this.bitrates_[c];d>a&&o*l-128e3>d&&(a=d,r=c)}if(r!==t)return e.dlog(2,"Selected new rate "+a+" for bandwidth "+l+" (from "+n+", "+s+")"),this.cooldownPeriod_=8,r}return t!==i&&-1!==i?(e.dlog(2,"Selected new bitrate level: "+i),i):-1},e.AdaptiveManager=a
}(),function(){var t=function(e,t,i){this.mediaSrcMgr_=e,this.bufferIndex_=t,this.adaptiveManager_=i,this.fragmentRequest_=null};t.prototype.appendInit=function(){e.dlog(2,"Appending init ["+this.mediaSrcMgr_.mime(this.bufferIndex_)+"]: "+this.mediaSrcMgr_.getLevel(this.bufferIndex_)),this.mediaSrcMgr_.initialize(this.bufferIndex_),this.mediaSrcMgr_.append(this.bufferIndex_,this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).initFragment)},t.prototype.onXHRAbort=function(){e.log("Received abort of XHR.")
},t.prototype.onXHRError=function(t){return this.fragmentRequest_!==t.target?void e.log("Received error of untracked XHR."):(e.log("Received error of XHR."),void(this.fragmentRequest_=null))},t.prototype.onXHRLoad=function(t){this.fragmentRequest_!==t.target&&e.log("Error, HTTP response for unknown request");var i=this.fragmentRequest_;return this.fragmentRequest_=null,i.readyState==i.DONE?i.status>=300?void e.log("HTTP Request failure, status="+i.status):(i.is_index&&(e.dlog(2,"Index Response"),this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).segs=e.parseSIDX(i.response,i.startByte)),i.is_init?(e.dlog(2,"Init Response"),this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).initFragment=e.extractInit(i.response),void(this.mediaSrcMgr_.isInitialized(this.bufferIndex_)||this.appendInit())):void this.mediaSrcMgr_.appendData(this.bufferIndex_,i.response)):void 0
},t.prototype.cancelRequests=function(){null!=this.fragmentRequest_&&(this.fragmentRequest_.abort(),this.fragmentRequest_=null)},t.prototype.makeSSXHR=function(){var t=new XMLHttpRequest,i=this.mediaSrcMgr_.getSegIndex(this.bufferIndex_),n=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).url,s=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).bandwidth,a=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).segs[i].timeURL;if(n=n.replace("{bitrate}",s),n=n.replace("{start time}",a),t.open("GET",n),t.responseType="arraybuffer",t.addEventListener("load",this.onXHRLoad.bind(this)),t.addEventListener("error",this.onXHRError.bind(this)),t.addEventListener("abort",this.onXHRAbort.bind(this)),null==n)throw"Null URL";
return t.is_init=!1,t.is_index=!1,t.lastTime=null,t.lastSize=null,t.addEventListener("progress",this.adaptiveManager_.onBandwithTracking.bind(this.adaptiveManager_)),t.send(),e.dlog(2,"Sent XHR: url="+n),t},t.prototype.makeXHR=function(t){var i,n,s=new XMLHttpRequest,a=this.mediaSrcMgr_.getSegIndex(this.bufferIndex_),r=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_),o=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).url,l=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).segs[a],c=!1;null==a&&(a=0),null!=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).segs[a].url&&(o=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).segs[a].url),t?(i=0,n=r.initRequestData.end,null!=r.indexRequestData&&(n=r.indexRequestData.end,c=!0)):(i=l.offset,n=l.offset+l.size-1);
var d=null;null!=i&&null!=n&&(d="bytes="+i+"-"+n);var u=!!/youtube.com/.exec(o);if(d&&u&&(o=o.replace(/&range=[^&]*/,""),o+="&range="+d.substring(6)),s.open("GET",o),s.responseType="arraybuffer",s.startByte=i,null==d||u||s.setRequestHeader("Range",d),s.addEventListener("load",this.onXHRLoad.bind(this)),null==o)throw"Null URL";return s.is_init=t,s.is_index=c,s.lastTime=null,s.lastSize=null,s.addEventListener("progress",this.adaptiveManager_.onBandwithTracking.bind(this.adaptiveManager_)),s.send(),e.dlog(2,"Sent XHR: url="+o+", range="+d),s
},t.prototype.findRangeForPlaybackTime=function(e,t){for(var i=e.buffered,n=0;n<i.length;n++)if(i.start(n)<=t&&i.end(n)>=t)return{start:i.start(n),end:i.end(n)}},t.prototype.initFragmentRequestNeeded=function(){if(null==this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).initFragment){e.dlog(2,"Creating Init segment["+this.mediaSrcMgr_.mime(this.bufferIndex_)+"]");var t=this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_);if(this.mediaSrcMgr_.type===e.StreamingType.SMOOTH_STREAMING){var i={pps:t.pps,sps:t.sps,width:t.width,height:t.height,mime:this.mediaSrcMgr_.mime(this.bufferIndex_),pr:this.mediaSrcMgr_.pr,audio_codec_private_data:t.audio_codec_private_data,audio_sample_rate:t.audio_sample_rate},n=e.createSSInit(i);
return this.mediaSrcMgr_.getCurrentRep(this.bufferIndex_).initFragment=e.extractInit(n.data),this.appendInit(),!1}return this.fragmentRequest_=this.makeXHR(!0),!0}return this.mediaSrcMgr_.isInitialized(this.bufferIndex_)||this.appendInit(),!1},t.prototype.requestNextFragment=function(t,i){this.fragmentRequest_=this.mediaSrcMgr_.type===e.StreamingType.SMOOTH_STREAMING?this.makeSSXHR():this.makeXHR(!1),this.fragmentRequest_.expected_time=i},t.prototype.tick=function(t){if(!this.mediaSrcMgr_.isActive(this.bufferIndex_))return e.dlog(4,"Not active["+this.mediaSrcMgr_.mime(this.bufferIndex_)+"]"),!1;
if(this.fragmentRequest_)e.dlog(4,"Will not request next segment["+this.mediaSrcMgr_.mime(this.bufferIndex_)+"] request pending");else if(!this.initFragmentRequestNeeded()){var i=this.mediaSrcMgr_.identifyNextFragment(this.bufferIndex_,t);if(null!==i){var n=-1;this.mediaSrcMgr_.mime(this.bufferIndex_).indexOf("video")>=0&&(n=this.adaptiveManager_.adapt(this.mediaSrcMgr_.getLevel(this.bufferIndex_))),n>=0?(this.cancelRequests(),this.mediaSrcMgr_.changeQuality(this.bufferIndex_,n)):this.requestNextFragment(t,i)
}}return!0},e.FragmentManager=t}(),function(){function t(e){var t=new RegExp("[?&]"+e+"=([^&]*)"),i=t.exec(window.location.search);return null!=i?(i=i[1],/%/.exec(i)&&(i=decodeURIComponent(i)),i):null}function i(){for(var e={},i=["autoplay","algorithm","flavor","level","cc","url"],n=0;n<i.length;n++){var s=t(i[n]);e[i[n]]=s}if(e&&e.url)for(var a in e)e.hasOwnProperty(a)&&(this.options[a]=e[a])}var n={Audio_Type:"audio",Video_Type:"video",Image_Type:"img",MSE_Type:"mse"},s=function(t){t||(t={}),this.options=t,this.mediaElementType_=null,this.manifestLoader_=null,this.closeCaptionsLoader_=null,this.progressTimer_=null,this.mediaSrcMgr_=new e.MediaSourceManager,this.fragmentManagers_=null,this.showControls_=t.showControls,this.mediaElement_=null,this.imageElement_=null,this.mediaEvents_=new Object,t.mediaElement?this.mediaElement_=t.mediaElement:t.imageElement?this.imageElement_=t.imageElement:this.createMediaElement(),e.player=this
},a={AUTO_PAUSE_START:1,PAUSE_RESUME:5};s.prototype.getMediaElement=function(){return this.mediaElement_},s.prototype.onPause=function(){e.log("Paused, auto="+this.mediaElement_.autopause_pending),this.mediaElement_.autopaused=this.mediaElement_.autopause_pending,this.mediaElement_.autopause_time=(new Date).getTime(),this.mediaElement_.autopause_pending=!1},s.prototype.onPlay=function(){e.log("Playing"),this.mediaElement_.autopause_pending=!1,this.mediaElement_.autopaused=!1,this.mediaElement_.autopause_time=null
},s.prototype.onError=function(){e.log("Error ("+this.mediaElement_.error.code+")")},s.prototype.cancelRequests=function(){for(var e=0;e<this.fragmentManagers_.length;e++)this.fragmentManagers_[e].cancelRequests()},s.prototype.onSeeking=function(){e.log("Seeking"),this.cancelRequests(),this.mediaSrcMgr_.resetAll("seeking")},s.prototype.onSeeked=function(){e.log("Seeked")},s.prototype.onProgress=function(){var t=this.mediaSrcMgr_.getMediaSource();if(!t||"closed"===t.readyState)return void this.stopProgressTimer();
var i=this.mediaElement_.currentTime;if(this.mediaElement_.error)return void e.dlog(2,"Video Error: "+this.mediaElement_.error);for(var n=!1,s=0,r=0,o=0;o<this.fragmentManagers_.length;o++)if(this.fragmentManagers_[o].tick(i)){var l=this.mediaSrcMgr_.getBufferSize(o,i);this.mediaElement_.paused?l>=a.PAUSE_RESUME&&r++:l<a.AUTO_PAUSE_START&&(n=!0)}else s++;return s>0?void(s===this.fragmentManagers_.length&&this.mediaSrcMgr_.endOfStream()):void(this.mediaElement_.paused?this.mediaElement_.autopaused&&r===this.fragmentManagers_.length&&(e.dlog(2,"Autoresuming"),this.mediaElement_.play()):n&&(e.dlog(2,"Autopausing"),this.mediaElement_.autopause_pending=!0,this.mediaElement_.pause()))
},s.prototype.createMediaElement=function(){var t=document.getElementById("mediaElement");this.mediaElement_=document.createElement(n.Video_Type),this.imageElement_=document.createElement(n.Image_Type),t.appendChild(this.mediaElement_),t.appendChild(this.imageElement_),e.me=this.mediaElement_,e.img=this.imageElement_,this.showControls_?this.mediaElement_.hasAttribute("controls")||this.mediaElement_.setAttribute("controls","controls"):this.mediaElement_.hasAttribute("controls")&&this.mediaElement_.removeAttribute("controls")
},s.prototype.showMediaElement=function(t){var i=document.getElementById("mediaElement");this.mediaElementType_===n.MSE_Type&&(this.removeMediaEventListener("seeking"),this.removeMediaEventListener("seeked"),this.removeMediaEventListener("pause"),this.removeMediaEventListener("play"),this.removeMediaEventListener("error"),t!==n.MSE_Type&&(this.stopProgressTimer(),this.mediaSrcMgr_.dispose(),this.mediaSrcMgr_=new e.MediaSourceManager)),this.mediaElementType_!==n.Image_Type&&(this.mediaElement_.play(0),this.mediaElement_.pause());
var s=i.children;if(s&&s.length>0)for(var a=0;a<s.length;a++)"VIDEO"===s[a].nodeName&&t!==n.Image_Type?s[a].style.display="block":"IMG"===s[a].nodeName&&t===n.Image_Type?s[a].style.display="block":(s[a].style.display="none",s[a].src=null);this.mediaElementType_=t},s.prototype.addMediaEventListener=function(e,t){var i=t.bind(this);this.mediaElement_.addEventListener(e,i),this.mediaEvents_[e]=i},s.prototype.removeMediaEventListener=function(e){this.mediaElement_.removeEventListener(e,this.mediaEvents_[e]),this.mediaEvents_[e]=null
},s.prototype.initMseVideoElement=function(e){e&&this.addCaptionInfo(e),this.addMediaEventListener("seeking",this.onSeeking),this.addMediaEventListener("seeked",this.onSeeked),this.addMediaEventListener("pause",this.onPause),this.addMediaEventListener("play",this.onPlay),this.addMediaEventListener("error",this.onError),this.mediaElement_.autopause_pending=!1,this.mediaElement_.autopaused=this.options.autoplay?!0:!1,this.mediaElement_.seekingStatus="none"},s.prototype.onManifestLoad=function(t){return this.destroyed_?void e.log("Ignoring manifest load after destruction"):t?void e.log("Unable to load manifest"):void(this.options.cc?(this.closeCaptionsLoader_=new e.CloseCaptionsLoader(this.options.cc),this.closeCaptionsLoader_.load(this.onLoadcloseCaptions.bind(this))):this.onLoadcloseCaptions.call(this))
},s.prototype.addCaptionInfo=function(e){var t;t=this.mediaElement_.textTracks.length>0?this.mediaElement_.textTracks[0]:this.mediaElement_.addTextTrack("captions"),t.mode="showing";for(var i=e[0].start,n=e[0].end,s=[],a=0;a<e.length;a++){var r=new TextTrackCue(e[a].start,e[a].end,e[a].caption);if(i===e[a].start&&n===e[a].end&&s.push(r),i!==e[a].start||n!==e[a].end||a===e.length-1){for(var o=s.length-1;o>=0;o--)t.addCue(s[o]);s.length=0,i=e[a].start,n=e[a].end,a<e.length&&s.push(r)}}},s.prototype.onMediaSourceManagerInitialized=function(t){if(this.destroyed_)return void e.log("Ignoring MediaSourceManager initialization after destruction");
this.initMseVideoElement(t);for(var i=0;i<this.mediaSrcMgr_.getSourceBufferCount();i++)this.fragmentManagers_.push(new e.FragmentManager(this.mediaSrcMgr_,i,new e.AdaptiveManager(this.mediaSrcMgr_.getBitrates(i),this.options.algorithm,this.options.level)));this.startProgressTimer()},s.prototype.initializeMsePlayer=function(){var e=null;this.closeCaptionsLoader_&&(e=this.closeCaptionsLoader_.getCCInfo()),this.fragmentManagers_=[],this.mediaSrcMgr_.init(),window.msrc=this.mediaSrcMgr_.getMediaSource(),this.mediaSrcMgr_.attach(this.mediaElement_,this.manifestLoader_.getManifest(),e,this.onMediaSourceManagerInitialized.bind(this,e))
},s.prototype.stopProgressTimer=function(){null!==this.progressTimer_&&(e.dlog(2,"Deregistering progress timer"),window.clearInterval(this.progressTimer_),this.progressTimer_=null)},s.prototype.startProgressTimer=function(){null===this.progressTimer_&&(e.dlog(2,"Starting progress timer"),this.progressTimer_=setInterval(this.onProgress.bind(this),250))},s.prototype.initializeSimplePlayer=function(e,t){e!==n.Image_Type?(this.mediaElement_.src=t,this.mediaElement_.play()):this.imageElement_.src=t},s.prototype.onLoadcloseCaptions=function(t){return this.destroyed_?void e.log("Ignoring close captions load after destruction"):t?void e.log("Unable to load close captions"):void this.initializeMsePlayer()
},s.prototype.onManifestLoad=function(t){return this.destroyed_?void e.log("Ignoring manifest load after destruction"):t?void e.log("Unable to load manifest"):void(this.options.cc?(this.closeCaptionsLoader_=new e.CloseCaptionsLoader(this.options.cc),this.closeCaptionsLoader_.load(this.onLoadcloseCaptions.bind(this))):this.onLoadcloseCaptions.call(this))},s.prototype.getMediaType=function(t){var i=t.length;if(5>i)return e.log("Error invalid url"),null;var s=t.substring(t.length-4,t.length);switch(s){case".webm":case".mkv":case".mp4":return n.Video_Type;
case".mp3":return n.Audio_Type;case".jpg":return n.Image_Type;case".mpd":return n.MSE_Type;default:return n.MSE_Type}},s.prototype.init=function(){if(e.log("-------- Initializing --------"),!this.mediaSrcMgr_.isSupported())return e.log("Incompatible browser: Media Source extensions not suported"),!1;if(i(),!this.options.url)return e.log("No manifest URL found, please provide one"),!1;var t=this.getMediaType(this.options.url);this.mediaElementType_=t,this.options.mediaElement||this.options.imageElement||this.showMediaElement(t),t===n.MSE_Type?(this.manifestLoader_=new e.ManifestLoader(this.options.url),this.manifestLoader_.load(this.onManifestLoad.bind(this))):this.initializeSimplePlayer(t,this.options.url)
},s.prototype.destroy=function(){return this.destroyed_?void e.log("Refusing to destroy a second time"):(this.mediaElementType_===n.MSE_Type&&(this.removeMediaEventListener("seeking"),this.removeMediaEventListener("seeked"),this.removeMediaEventListener("pause"),this.removeMediaEventListener("play"),this.removeMediaEventListener("error"),this.stopProgressTimer(),this.mediaSrcMgr_.dispose(),this.mediaSrcMgr_=new e.MediaSourceManager),this.mediaElementType_!==n.Image_Type&&(this.mediaElement_.play(0),this.mediaElement_.pause()),void(this.destroyed_=!0))
},e.BasicPlayer=s}(),window.googledash=e}(),define("googledash",function(e){return function(){var t;return t||e.googledash}}(this)),define("plex/base/adapters/player/HTMLPlayerSubcontroller",["underscore","googledash","plex/base/utils/t","plex/base/utils/BaseClass","plex/base/utils/playerUtil","plex/base/utils/mediaUtil","plex/base/utils/Backlog","plex/base/utils/browser","plex/base/utils/types/streamTypes","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r,o,l,c){"use strict";var d=n.extend({readyEvent:"loadedmetadata",wrapped:["play","pause","setVolume","setPosition","resume","stop"],initialize:function(t){e.bindAll(this,"onReady","onWaiting","onPlaying","onProgress","onTime","onPause","onVolume","onEnded","onError"),this.type=t,this.backlog=new r,this.backlog.wrapAll(this.wrapped,function(){return!!this.mediaElement
},this)},setMediaSrc:function(e){this.mediaElement.setAttribute("src",e)},removeMediaSrc:function(){this.mediaElement.setAttribute("src","")},addMediaListeners:function(){var e=this.mediaElement;e.addEventListener(this.readyEvent,this.onReady),e.addEventListener("waiting",this.onWaiting),e.addEventListener("playing",this.onPlaying),e.addEventListener("progress",this.onProgress),e.addEventListener("timeupdate",this.onTime),e.addEventListener("pause",this.onPause),e.addEventListener("volumechange",this.onVolume),e.addEventListener("ended",this.onEnded),e.addEventListener("error",this.onError)
},removeMediaListeners:function(){var e=this.mediaElement;e.removeEventListener(this.readyEvent,this.onReady),e.removeEventListener("waiting",this.onWaiting),e.removeEventListener("playing",this.onPlaying),e.removeEventListener("progress",this.onProgress),e.removeEventListener("timeupdate",this.onTime),e.removeEventListener("pause",this.onPause),e.removeEventListener("volumechange",this.onVolume),e.removeEventListener("ended",this.onEnded),e.removeEventListener("error",this.onError)},load:function(e){var i=e.model,n=e.model.get("url"),s=e.mediaElement||this.createManagedMediaElement();
this.backlog.clear(),this.model=i,this.mediaElement=s,this.autoplay=null==e.autoplay?!0:e.autoplay,this.offset=i.get("position");var a=!i.get("directPlay")&&"http"===e.protocol;this.useSeekStreamSwitch=a||e.useOffsetHLS,this.useOffset=e.useOffsetHLS,this.useOffset&&this.model.set("offset",this.offset),s.stream_restart=!1,s.autoplay=this.autoplay,this.addMediaListeners(),c.group("HTML Player",["URL: "+n,"Autoplay: "+this.autoplay,"Offset: "+this.offset]),"dash"===e.protocol?(this.dashPlayer=new t.BasicPlayer({url:n,mediaElement:s}),this.dashPlayer.init()):(this.setMediaSrc(n,e.mimeType),s.load())
},play:function(){this.mediaElement.play()},pause:function(){this.mediaElement.pause(),this.mediaElement.autoplay=!1},setVolume:function(e){this.mediaElement.volume=e/100},setPosition:function(e){this.mediaElement.readyState>0&&(this.mediaElement.currentTime=e/1e3)},resume:function(){c.log("Resuming at "+this.offset),this.setPosition(this.offset),this.offset=0},stop:function(){var e=this.dashPlayer;if(c.log("Stopping playback"),this.removeMediaListeners(),this.model.set("ready",!1),e){this.dashPlayer=null;
try{e.destroy()}catch(t){}}else this.setPosition(0),this.pause();this.removeMediaSrc(),this.removeManagedMediaElement(),this.mediaElement=null},preferElementDuration:function(){if(!e.isFinite(this.mediaElement.duration))return!1;if(this.model.get("type")!==s.types.PHOTO){var t=e.first(a.getStreams(this.model.get("media"),{streamType:l.getStreamTypeByString("audio").id,selected:!0}));if(t&&"vbr"===t.bitrateMode)return!1}return!0},getErrorMessage:function(){return i("There was a problem playing this item.")
},beforeStreamSwitch:function(){this.mediaElement&&(this.mediaElement.stream_restart=!0)},createManagedMediaElement:function(){var e=s.getElementByType(this.type),t=document.createElement(e);return t.style.cssText="position:absolute;width:1px;height:1px;",t.managed=!0,document.body.appendChild(t),t},removeManagedMediaElement:function(){var e=this.mediaElement;e&&e.managed&&(e.managed=!1,e.parentNode&&e.parentNode.removeChild(e))},onReady:function(){var e=this.model;if(!e.get("ready")){c.log("Playback is ready");
var t=this.mediaElement,i={ready:!0,loaded:!0};if(e.get("type")===s.types.VIDEO&&(i.videoDimensions={width:t.videoWidth,height:t.videoHeight}),e.set(i),this.preferElementDuration()){var n=1e3*t.duration;this.useOffset&&(n+=this.offset),e.set("duration",Math.round(n))}var a=e.get("volume");null!=a&&this.setVolume(a),this.backlog.process()}},onWaiting:function(){this.model.set("state",s.states.BUFFERING)},onPlaying:function(){this.model.set("state",s.states.PLAYING)},onProgress:function(){for(var e=this.mediaElement.buffered,t=null,i=null,n=0,s=e.length;s>n;n++){var a=e.start(n),r=e.end(n);
(null===t||t>a)&&(t=a),(null===i||r>i)&&(i=r)}this.model.set({startBuffer:Math.round(1e3*t),endBuffer:Math.round(1e3*i)})},onTime:function(){var e=this.mediaElement,t=this.offset&&!this.useSeekStreamSwitch,i=e.stream_restart;if(t||i)return void(t&&this.resume());var n=1e3*e.currentTime;if(this.useOffset&&(n+=this.offset),!e.paused){var a=this.model;a.get("buffering")&&a.set("state",s.states.PLAYING),a.set("position",Math.round(n))}},onPause:function(){var e=this.model.get("partIndex")+1<this.model.get("partCount");
this.mediaElement.ended&&e||(this.mediaElement.resume_pending||this.mediaElement.autopause_pending||this.mediaElement.autopaused||this.mediaElement.stream_restart?this.model.set("state",s.states.BUFFERING):this.model.set("state",s.states.PAUSED))},onVolume:function(){this.model.set("volume",Math.round(100*this.mediaElement.volume))},onEnded:function(){this.model.set("ended",!0)},onError:function(e){var t=e.target.error,i=t&&t.code;i&&c.warn("Media element error code: "+i),this.model.set({state:s.states.ERROR,errorMessage:this.getErrorMessage(i)})
}});return d}),define("plex/base/adapters/player/LocalPlayerController",["underscore","jquery","plex/base/utils/t","plex/base/utils/BaseClass","plex/base/utils/mediaUtil","plex/base/utils/playerUtil","plex/base/utils/Backlog","plex/base/adapters/playerProfileAdapter","plex/base/mixins/eventMixin","plex/base/mixins/player/playerControllerMixin","plex/base/adapters/player/HTMLPlayerSubcontroller"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";var u=n.extend({mixins:[l,c],playerProfileAdapter:o,resetStreamDebounce:200,handleSetPositionDebounce:0,wrapped:["play","pause","setVolume","setPosition"],modelDefaults:function(){var t=c.modelDefaults.apply(this,arguments);
return e.extend(t,{state:a.states.BUFFERING})},initialize:function(t){t||(t={}),c.initialize.apply(this,arguments),e.bindAll(this,"onDecisionSuccess","onDecisionError"),this.profile=this.playerProfileAdapter.prop(this.type),this.backlog=new r,this.backlog.wrapAll(this.wrapped,function(){return!!this.subcontroller},this),this.resetStreamDebounce&&(this.resetStream=e.debounce(this.resetStream,this.resetStreamDebounce)),this.handleSetPositionDebounce&&(this.handleSetPosition=e.debounce(this.handleSetPosition,this.handleSetPositionDebounce))
},load:function(e){this.originalOptions=e,this.model=e.model,this.autoplay=e.autoplay,this.postplay=e.postplay;var t=this.model.get("item"),i=this.model.get("playQueue");return i=i&&i.get("collection"),this.reset(t),this.listenTo(this.model,{"change:state":this.onStateChange,"change:qualityIndex":this.onQualityIndexChange,"change:audioStreamID":this.onAudioStreamIDChange,"change:subtitleStreamID":this.onSubtitleStreamIDChange,"change:ended":this.onEndedChange,"change:softSubtitlesFailed":this.onSoftSubtitlesFailedChange}),i&&this.listenTo(i,{reset:this.onPlayQueueChange}),this.getPlayerDecision(t,e)
},populateItem:function(e){var t={reset:!0,scope:"player"};return e.isLibraryItem()&&(t.data={checkFiles:"1"}),e.populate(t)},loadMediaElement:function(t){this.subcontroller=this.getSubcontrollerByType(this.playerType),this.backlog.process();var i,n=this.profile&&this.profile.protocols,s=this.protocol;s&&n&&n[s]&&(i=n[s].mimeType),this.subcontroller.load(e.extend({},this.originalOptions,{model:this.model,protocol:s,autoplay:this.autoplay,mimeType:i,useOffsetHLS:t.useOffsetHLS}))},getSubcontrollerByType:function(){return new d(this.type)
},embed:function(n){var s=this.model.get("item"),r=t.ajax(s.server.getXHROptions(n.key));r.done(e.bind(function(e){this.model.set("embedHtml",e)},this)),r.fail(e.bind(function(){this.model.set({state:a.states.ERROR,errorMessage:i("There was a problem embedding this video.")})},this))},redirect:function(t){var i=this.model.get("item"),n=i.get("url");if(!n&&t){var s=t.key.match(/\/webkit\?url=([^&]+)/);s&&(n=decodeURIComponent(s[1]))}window.open(n),e.defer(e.bind(function(){this.model.set("finished",!0)
},this))},play:function(){this.model.get("state")!==a.states.PLAYING&&this.subcontroller.play()},pause:function(){this.model.get("state")!==a.states.PAUSED&&this.subcontroller.pause()},setPosition:function(e,t){t||(t={}),this.canSeek(e)&&(this.model.set("finished",!1),this.model.set("position",e),this.model.trigger("seeking",this.model),this.subcontroller.useSeekStreamSwitch?(this.resetStreamDebounce&&this.pause(),this.switchStreams(t)):(this.handleSetPositionDebounce&&this.pause(),this.handleSetPosition(e,t)))
},handleSetPosition:function(e,t){this.canHandleDebounce()&&(this.subcontroller.setPosition(e),t.autoplay&&this.play())},canHandleDebounce:function(){var e=this.model&&this.model.get("state");return void 0===e?!1:e!==a.states.STOPPED},setVolume:function(e){this.model.set("volume",e),this.subcontroller.setVolume(e)},skipPrevious:function(){var e=c.skipPrevious.apply(this,arguments);return e&&this.switchStreams({autoplay:!0}),e},skipNext:function(){var e=c.skipNext.apply(this,arguments);return e&&this.switchStreams({autoplay:!0}),e
},skipTo:function(){var e=c.skipTo.apply(this,arguments);return e&&this.switchStreams({autoplay:!0}),e},switchStreams:function(e){e||(e={}),null==e.autoplay&&(e.autoplay=!this.model.get("paused")),this.subcontroller&&this.subcontroller.beforeStreamSwitch&&this.subcontroller.beforeStreamSwitch(),this.originalOptions.media=this.model.get("media"),this.originalOptions.part=this.model.get("part"),this.originalOptions.offset=this.model.get("position"),this.pause(),this.resetStream(e)},resetStream:function(t){if(this.canHandleDebounce()){var i=this.stopSession();
i.done(e.bind(function(){this.autoplay=t.autoplay,this.getPlayerDecision(this.currentItem,this.originalOptions)},this))}},stop:function(e){return c.stop.apply(this,arguments),this.stopSession(e)},onDecisionSuccess:function(e){var t=this.model,i=t.get("state"),n=0;if(i!==a.states.STOPPED&&i!==a.states.ERROR){e.part&&e.part.duration&&(n=e.part.duration),this.session=e.session,this.playerType=e.playerType,this.protocol=e.protocol;var r=e.media,o=e.part,l=s.getSelectedAudio(r),c=s.getSelectedSubtitles(r);
this.model.set({media:r,part:o,url:e.url,subtitlesUrl:e.subtitlesUrl,transcodeServer:e.transcodeServer,mediaIndex:r?s.getMediaIndex(t.get("item"),r.id):0,partIndex:o?s.getPartIndex(r,o.key):0,partCount:s.getPartCount(e.media),audioStreamID:l?l.id:0,subtitleStreamID:c?c.id:0,state:this.autoplay?a.states.BUFFERING:a.states.PAUSED,position:e.offset,duration:n,directPlay:e.canDirectPlay,softSubtitlesFailed:!1}),this.loadMediaElement(e)}},onDecisionError:function(e){var t=this.model,n=t.get("state");if(n!==a.states.STOPPED&&n!==a.states.ERROR){var s=this.playerProfileAdapter.prop("capabilities");
if(e.embed&&s.embed)return void this.embed(e.part);if(e.redirect&&s.redirect)return void this.redirect(e.part);var r=e.errorMessage||i("There was a problem playing this item.");t.set({state:a.states.ERROR,errorMessage:r})}},onQualityIndexChange:function(e,t){var i=e.previous("qualityIndex");null!=t&&null!=i&&this.switchStreams()},onAudioStreamIDChange:function(e,t){var i=e.previous("audioStreamID");null!=t&&null!=i&&this.switchStreams()},onSubtitleStreamIDChange:function(e,t){var i=e.previous("subtitleStreamID");
null!=t&&null!=i&&this.switchStreams()},onPlayQueueChange:function(){this.previousItem=this.getPreviousItem(),this.nextItem=this.getNextItem(),this.model.set({canSkipPrevious:!!this.previousItem,canSkipNext:!!this.nextItem})},onStateChange:function(t,i){var n=this.timeline();i===a.states.PLAYING&&n.done(e.bind(this.updatePlayQueue,this)),i===a.states.STOPPED||i===a.states.ERROR?this.stopTimeline():this.startTimeline(),i===a.states.PAUSED?this.startPing():this.stopPing(),i===a.states.PLAYING?this.startPlaybackTracking():this.stopPlaybackTracking()
},onEndedChange:function(e,t){if(t){var i=e.get("partIndex"),n=e.get("partCount");if(++i>=n)this.nextItem&&!this.postplay?this.skipNext():(!this.nextItem&&this.postplay?this.stop():this.pause(),this.model.set("finished",!0));else{var s=e.get("media");this.model.set({part:s.Part[i],position:0}),this.switchStreams({autoplay:!0})}}},onSoftSubtitlesFailedChange:function(e,t){!t||e.get("stopped")||e.get("error")||this.switchStreams()}});return u}),define("plex/desktop/adapters/player/DesktopHTMLPlayerSubcontroller",["underscore","googledash","plex/base/utils/capabilities","plex/base/adapters/loggerAdapter","plex/base/adapters/player/HTMLPlayerSubcontroller"],function(e,t,i,n,s){"use strict";
var a=s.extend({load:function(){s.prototype.load.apply(this,arguments),i.hasTouchScreen&&this.model.set("ready",!0)},resume:function(){n.log("resuming at "+this.offset);var t=this.offset;this.offset=0,this.autoplay&&(this.mediaElement.resume_pending=!0,this.pause()),this.resumePositionTimeout=setTimeout(e.bind(function(){this.setPosition(t)},this),1e3),this.autoplay&&(this.resumePlayTimeout=setTimeout(e.bind(function(){this.mediaElement.resume_pending=!1,this.play()},this),1500))},stop:function(){s.prototype.stop.apply(this,arguments),this.resumePositionTimeout=clearTimeout(this.resumePositionTimeout),this.resumePlayTimeout=clearTimeout(this.resumePlayTimeout)
},onReady:function(){s.prototype.onReady.apply(this,arguments);var e=this.model.get("showEnterFullscreen")||this.model.get("showExitFullscreen");!e&&this.mediaElement.webkitSupportsFullscreen&&this.model.set({showEnterFullscreen:!0,forceWebkitVideoFullscreen:!0})}});return a}),"undefined"==typeof jwplayer&&(jwplayer=function(e){return jwplayer.api?jwplayer.api.selectPlayer(e):void 0},jwplayer.version="6.8.4616",jwplayer.vid=document.createElement("video"),jwplayer.audio=document.createElement("audio"),jwplayer.source=document.createElement("source"),function(e){function t(e){return function(){return l(e)
}}function i(e,t,i,n,s){return function(){var a,o;if(s)i(e);else{try{if((a=e.responseXML)&&(o=a.firstChild,a.lastChild&&"parsererror"===a.lastChild.nodeName))return void(n&&n("Invalid XML"))}catch(l){}if(a&&o)return i(e);(a=r.parseXML(e.responseText))&&a.firstChild?(e=r.extend({},e,{responseXML:a}),i(e)):n&&n(e.responseText?"Invalid XML":t)}}}var n=document,s=window,a=navigator,r=e.utils=function(){};r.exists=function(e){switch(typeof e){case"string":return 0<e.length;case"object":return null!==e;
case"undefined":return!1}return!0},r.styleDimension=function(e){return e+(0<e.toString().indexOf("%")?"":"px")},r.getAbsolutePath=function(e,t){if(r.exists(t)||(t=n.location.href),r.exists(e)){var i;if(r.exists(e)){i=e.indexOf("://");var s=e.indexOf("?");i=i>0&&(0>s||s>i)}else i=void 0;if(i)return e;i=t.substring(0,t.indexOf("://")+3);var a,s=t.substring(i.length,t.indexOf("/",i.length+1));0===e.indexOf("/")?a=e.split("/"):(a=t.split("?")[0],a=a.substring(i.length+s.length+1,a.lastIndexOf("/")),a=a.split("/").concat(e.split("/")));
for(var o=[],l=0;l<a.length;l++)a[l]&&r.exists(a[l])&&"."!=a[l]&&(".."==a[l]?o.pop():o.push(a[l]));return i+s+"/"+o.join("/")}},r.extend=function(){var e=r.extend.arguments;if(1<e.length){for(var t=1;t<e.length;t++)r.foreach(e[t],function(t,i){try{r.exists(i)&&(e[0][t]=i)}catch(n){}});return e[0]}return null};var o=window.console=window.console||{log:function(){}};r.log=function(){var e=Array.prototype.slice.call(arguments,0);"object"==typeof o.log?o.log(e):o.log.apply(o,e)};var l=r.userAgentMatch=function(e){return null!==a.userAgent.toLowerCase().match(e)
};r.isIE=r.isMSIE=t(/msie/i),r.isFF=t(/firefox/i),r.isChrome=t(/chrome/i),r.isIPod=t(/iP(hone|od)/i),r.isIPad=t(/iPad/i),r.isSafari602=t(/Macintosh.*Mac OS X 10_8.*6\.0\.\d* Safari/i),r.isIETrident=function(e){return e?(e=parseFloat(e).toFixed(1),l(RegExp("msie\\s*"+e+"|trident/.+rv:\\s*"+e,"i"))):l(/msie|trident/i)},r.isSafari=function(){return l(/safari/i)&&!l(/chrome/i)&&!l(/chromium/i)&&!l(/android/i)},r.isIOS=function(e){return l(e?RegExp("iP(hone|ad|od).+\\sOS\\s"+e,"i"):/iP(hone|ad|od)/i)},r.isAndroid=function(e,t){var i=t?!l(/chrome\/[23456789]/i):!0;
return e?i&&l(RegExp("android.*"+e,"i")):i&&l(/android/i)},r.isMobile=function(){return r.isIOS()||r.isAndroid()},r.saveCookie=function(e,t){n.cookie="jwplayer."+e+"="+t+"; path=/"},r.getCookies=function(){for(var e={},t=n.cookie.split("; "),i=0;i<t.length;i++){var s=t[i].split("=");0===s[0].indexOf("jwplayer.")&&(e[s[0].substring(9,s[0].length)]=s[1])}return e},r.typeOf=function(e){var t=typeof e;return"object"===t?e?e instanceof Array?"array":t:"null":t},r.translateEventResponse=function(t,i){var n=r.extend({},i);
if(t!=e.events.JWPLAYER_FULLSCREEN||n.fullscreen)if("object"==typeof n.data){var s=n.data;delete n.data,n=r.extend(n,s)}else"object"==typeof n.metadata&&r.deepReplaceKeyName(n.metadata,["__dot__","__spc__","__dsh__","__default__"],["."," ","-","default"]);else n.fullscreen="true"==n.message?!0:!1,delete n.message;return r.foreach(["position","duration","offset"],function(e,t){n[t]&&(n[t]=Math.round(1e3*n[t])/1e3)}),n},r.flashVersion=function(){if(r.isAndroid())return 0;var e,t=a.plugins;try{if("undefined"!==t&&(e=t["Shockwave Flash"]))return parseInt(e.description.replace(/\D+(\d+)\..*/,"$1"),10)
}catch(i){}if("undefined"!=typeof s.ActiveXObject)try{if(e=new s.ActiveXObject("ShockwaveFlash.ShockwaveFlash"))return parseInt(e.GetVariable("$version").split(" ")[1].split(",")[0],10)}catch(n){}return 0},r.getScriptPath=function(e){for(var t=n.getElementsByTagName("script"),i=0;i<t.length;i++){var s=t[i].src;if(s&&0<=s.indexOf(e))return s.substr(0,s.indexOf(e))}return""},r.deepReplaceKeyName=function(t,i,n){switch(e.utils.typeOf(t)){case"array":for(var s=0;s<t.length;s++)t[s]=e.utils.deepReplaceKeyName(t[s],i,n);
break;case"object":r.foreach(t,function(s,a){var r;if(i instanceof Array&&n instanceof Array){if(i.length!=n.length)return;r=i}else r=[i];for(var o=s,l=0;l<r.length;l++)o=o.replace(RegExp(i[l],"g"),n[l]);t[o]=e.utils.deepReplaceKeyName(a,i,n),s!=o&&delete t[s]})}return t};var c=r.pluginPathType={ABSOLUTE:0,RELATIVE:1,CDN:2};r.getPluginPathType=function(e){if("string"==typeof e){e=e.split("?")[0];var t=e.indexOf("://");if(t>0)return c.ABSOLUTE;var i=e.indexOf("/");return e=r.extension(e),!(0>t&&0>i)||e&&isNaN(e)?c.RELATIVE:c.CDN
}},r.getPluginName=function(e){return e.replace(/^(.*\/)?([^-]*)-?.*\.(swf|js)$/,"$2")},r.getPluginVersion=function(e){return e.replace(/[^-]*-?([^\.]*).*$/,"$1")},r.isYouTube=function(e){return/^(http|\/\/).*(youtube\.com|youtu\.be)\/.+/.test(e)},r.youTubeID=function(e){try{return/v[=\/]([^?&]*)|youtu\.be\/([^?]*)|^([\w-]*)$/i.exec(e).slice(1).join("").replace("?","")}catch(t){return""}},r.isRtmp=function(e,t){return 0===e.indexOf("rtmp")||"rtmp"==t},r.foreach=function(e,t){var i,n;for(i in e)"function"==r.typeOf(e.hasOwnProperty)?e.hasOwnProperty(i)&&(n=e[i],t(i,n)):(n=e[i],t(i,n))
},r.isHTTPS=function(){return 0===s.location.href.indexOf("https")},r.repo=function(){var t="http://p.jwpcdn.com/"+e.version.split(/\W/).splice(0,2).join("/")+"/";try{r.isHTTPS()&&(t=t.replace("http://","https://ssl."))}catch(i){}return t},r.ajax=function(e,t,n,a){var o;if(0<e.indexOf("#")&&(e=e.replace(/#.*$/,"")),e&&0<=e.indexOf("://")&&e.split("/")[2]!=s.location.href.split("/")[2]&&r.exists(s.XDomainRequest))o=new s.XDomainRequest,o.onload=i(o,e,t,n,a),o.ontimeout=o.onprogress=function(){},o.timeout=5e3;
else{if(!r.exists(s.XMLHttpRequest))return n&&n(),o;var l=o=new s.XMLHttpRequest,c=e;o.onreadystatechange=function(){if(4===l.readyState)switch(l.status){case 200:i(l,c,t,n,a)();break;case 404:n("File not found")}}}return o.overrideMimeType&&o.overrideMimeType("text/xml"),o.onerror=function(){n("Error loading file")},setTimeout(function(){try{o.open("GET",e,!0),o.send()}catch(t){n&&n(e)}},0),o},r.parseXML=function(e){var t;try{if(s.DOMParser){if(t=(new s.DOMParser).parseFromString(e,"text/xml"),t.childNodes&&t.childNodes.length&&"parsererror"==t.childNodes[0].firstChild.nodeName)return
}else t=new s.ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)}catch(i){return}return t},r.filterPlaylist=function(e,t){var i,n,s,a,o=[];for(i=0;i<e.length;i++)if(n=r.extend({},e[i]),n.sources=r.filterSources(n.sources),0<n.sources.length){for(s=0;s<n.sources.length;s++)a=n.sources[s],a.label||(a.label=s.toString());o.push(n)}if(t&&0===o.length)for(i=0;i<e.length;i++)if(n=r.extend({},e[i]),n.sources=r.filterSources(n.sources,!0),0<n.sources.length){for(s=0;s<n.sources.length;s++)a=n.sources[s],a.label||(a.label=s.toString());
o.push(n)}return o},r.filterSources=function(t,i){var n,s,a=r.extensionmap;if(t){s=[];for(var o=0;o<t.length;o++){var l=t[o].type,c=t[o].file;c&&(c=r.trim(c)),l||(l=a.extType(r.extension(c)),t[o].type=l),i?e.embed.flashCanPlay(c,l)&&(n||(n=l),l==n&&s.push(r.extend({},t[o]))):r.canPlayHTML5(l)&&(n||(n=l),l==n&&s.push(r.extend({},t[o])))}}return s},r.canPlayHTML5=function(t){return!r.isAndroid()||"hls"!=t&&"m3u"!=t&&"m3u8"!=t?(t=r.extensionmap.types[t],!!t&&!!e.vid.canPlayType&&e.vid.canPlayType(t)):!1
},r.seconds=function(e){e=e.replace(",",".");var t=e.split(":"),i=0;return"s"==e.slice(-1)?i=parseFloat(e):"m"==e.slice(-1)?i=60*parseFloat(e):"h"==e.slice(-1)?i=3600*parseFloat(e):1<t.length?(i=parseFloat(t[t.length-1]),i+=60*parseFloat(t[t.length-2]),3==t.length&&(i+=3600*parseFloat(t[t.length-3]))):i=parseFloat(e),i},r.serialize=function(e){return null==e?null:"true"==e.toString().toLowerCase()?!0:"false"==e.toString().toLowerCase()?!1:isNaN(Number(e))||5<e.length||0===e.length?e:Number(e)}}(jwplayer),function(e){var t="video/",i=e.foreach,n={mp4:t+"mp4",vorbis:"audio/ogg",ogg:t+"ogg",webm:t+"webm",aac:"audio/mp4",mp3:"audio/mpeg",hls:"application/vnd.apple.mpegurl"},s={mp4:n.mp4,f4v:n.mp4,m4v:n.mp4,mov:n.mp4,m4a:n.aac,f4a:n.aac,aac:n.aac,mp3:n.mp3,ogv:n.ogg,ogg:n.vorbis,oga:n.vorbis,webm:n.webm,m3u8:n.hls,hls:n.hls},t="video",t={flv:t,f4v:t,mov:t,m4a:t,m4v:t,mp4:t,aac:t,f4a:t,mp3:"sound",smil:"rtmp",m3u8:"hls",hls:"hls"},a=e.extensionmap={};
i(s,function(e,t){a[e]={html5:t}}),i(t,function(e,t){a[e]||(a[e]={}),a[e].flash=t}),a.types=n,a.mimeType=function(e){var t;return i(n,function(i,n){!t&&n==e&&(t=i)}),t},a.extType=function(e){return a.mimeType(s[e])}}(jwplayer.utils),function(e){var t=e.loaderstatus={NEW:0,LOADING:1,ERROR:2,COMPLETE:3},i=document;e.scriptloader=function(n){function s(){r=t.ERROR,l.sendEvent(o.ERROR)}function a(){r=t.COMPLETE,l.sendEvent(o.COMPLETE)}var r=t.NEW,o=jwplayer.events,l=new o.eventdispatcher;e.extend(this,l),this.load=function(){var l=e.scriptloader.loaders[n];
if(!l||l.getStatus()!=t.NEW&&l.getStatus()!=t.LOADING){if(e.scriptloader.loaders[n]=this,r==t.NEW){r=t.LOADING;var c=i.createElement("script");c.addEventListener?(c.onload=a,c.onerror=s):c.readyState&&(c.onreadystatechange=function(){("loaded"==c.readyState||"complete"==c.readyState)&&a()}),i.getElementsByTagName("head")[0].appendChild(c),c.src=n}}else l.addEventListener(o.ERROR,s),l.addEventListener(o.COMPLETE,a)},this.getStatus=function(){return r}},e.scriptloader.loaders={}}(jwplayer.utils),function(e){e.trim=function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")
},e.pad=function(e,t,i){for(i||(i="0");e.length<t;)e=i+e;return e},e.xmlAttribute=function(e,t){for(var i=0;i<e.attributes.length;i++)if(e.attributes[i].name&&e.attributes[i].name.toLowerCase()==t.toLowerCase())return e.attributes[i].value.toString();return""},e.extension=function(e){return e&&"rtmp"!=e.substr(0,4)?(e=e.substring(e.lastIndexOf("/")+1,e.length).split("?")[0].split("#")[0],-1<e.lastIndexOf(".")?e.substr(e.lastIndexOf(".")+1,e.length).toLowerCase():void 0):""},e.stringToColor=function(e){return e=e.replace(/(#|0x)?([0-9A-F]{3,6})$/gi,"$2"),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)
}}(jwplayer.utils),function(e){var t="touchmove",i="touchstart";e.touch=function(n){function s(e){e.type==i?(l=!0,d=r(h.DRAG_START,e)):e.type==t?l&&(u||(a(h.DRAG_START,e,d),u=!0),a(h.DRAG,e)):(l&&(u?a(h.DRAG_END,e):(e.cancelBubble=!0,a(h.TAP,e))),l=u=!1,d=null)}function a(e,t,i){c[e]&&(t.preventManipulation&&t.preventManipulation(),t.preventDefault&&t.preventDefault(),t=i?i:r(e,t))&&c[e](t)}function r(e,t){var i=null;if(t.touches&&t.touches.length?i=t.touches[0]:t.changedTouches&&t.changedTouches.length&&(i=t.changedTouches[0]),!i)return null;
var n=o.getBoundingClientRect(),i={type:e,target:o,x:i.pageX-window.pageXOffset-n.left,y:i.pageY,deltaX:0,deltaY:0};return e!=h.TAP&&d&&(i.deltaX=i.x-d.x,i.deltaY=i.y-d.y),i}var o=n,l=!1,c={},d=null,u=!1,h=e.touchEvents;return document.addEventListener(t,s),document.addEventListener("touchend",function(e){l&&u&&a(h.DRAG_END,e),l=u=!1,d=null}),document.addEventListener("touchcancel",s),n.addEventListener(i,s),n.addEventListener("touchend",s),this.addEventListener=function(e,t){c[e]=t},this.removeEventListener=function(e){delete c[e]
},this}}(jwplayer.utils),function(e){e.touchEvents={DRAG:"jwplayerDrag",DRAG_START:"jwplayerDragStart",DRAG_END:"jwplayerDragEnd",TAP:"jwplayerTap"}}(jwplayer.utils),function(e){e.key=function(t){var i,n,s;this.edition=function(){return s&&s.getTime()<(new Date).getTime()?"invalid":i},this.token=function(){return n},e.exists(t)||(t="");try{t=e.tea.decrypt(t,"36QXq4W@GSBV^teR");var a=t.split("/");(i=a[0])?/^(free|pro|premium|ads)$/i.test(i)?(n=a[1],a[2]&&0<parseInt(a[2])&&(s=new Date,s.setTime(String(a[2])))):i="invalid":i="free"
}catch(r){i="invalid"}}}(jwplayer.utils),function(e){var t=e.tea={};t.encrypt=function(e,s){if(0==e.length)return"";var a=t.strToLongs(n.encode(e));1>=a.length&&(a[1]=0);for(var r,o=t.strToLongs(n.encode(s).slice(0,16)),l=a.length,c=a[l-1],d=a[0],u=Math.floor(6+52/l),h=0;0<u--;){h+=2654435769,r=h>>>2&3;for(var p=0;l>p;p++)d=a[(p+1)%l],c=(c>>>5^d<<2)+(d>>>3^c<<4)^(h^d)+(o[3&p^r]^c),c=a[p]+=c}return a=t.longsToStr(a),i.encode(a)},t.decrypt=function(e,s){if(0==e.length)return"";for(var a,r=t.strToLongs(i.decode(e)),o=t.strToLongs(n.encode(s).slice(0,16)),l=r.length,c=r[l-1],d=r[0],u=2654435769*Math.floor(6+52/l);0!=u;){a=u>>>2&3;
for(var h=l-1;h>=0;h--)c=r[h>0?h-1:l-1],c=(c>>>5^d<<2)+(d>>>3^c<<4)^(u^d)+(o[3&h^a]^c),d=r[h]-=c;u-=2654435769}return r=t.longsToStr(r),r=r.replace(/\0+$/,""),n.decode(r)},t.strToLongs=function(e){for(var t=Array(Math.ceil(e.length/4)),i=0;i<t.length;i++)t[i]=e.charCodeAt(4*i)+(e.charCodeAt(4*i+1)<<8)+(e.charCodeAt(4*i+2)<<16)+(e.charCodeAt(4*i+3)<<24);return t},t.longsToStr=function(e){for(var t=Array(e.length),i=0;i<e.length;i++)t[i]=String.fromCharCode(255&e[i],e[i]>>>8&255,e[i]>>>16&255,e[i]>>>24&255);
return t.join("")};var i={code:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e,t){var s,a,r,o,l,c,d=[],u="",h=i.code;if(c=("undefined"==typeof t?0:t)?n.encode(e):e,l=c.length%3,l>0)for(;3>l++;)u+="=",c+="\x00";for(l=0;l<c.length;l+=3)s=c.charCodeAt(l),a=c.charCodeAt(l+1),r=c.charCodeAt(l+2),o=s<<16|a<<8|r,s=o>>18&63,a=o>>12&63,r=o>>6&63,o&=63,d[l/3]=h.charAt(s)+h.charAt(a)+h.charAt(r)+h.charAt(o);return d=d.join(""),d=d.slice(0,d.length-u.length)+u},decode:function(e,t){t="undefined"==typeof t?!1:t;
var s,a,r,o,l,c,d=[],u=i.code;c=t?n.decode(e):e;for(var h=0;h<c.length;h+=4)s=u.indexOf(c.charAt(h)),a=u.indexOf(c.charAt(h+1)),o=u.indexOf(c.charAt(h+2)),l=u.indexOf(c.charAt(h+3)),r=s<<18|a<<12|o<<6|l,s=r>>>16&255,a=r>>>8&255,r&=255,d[h/4]=String.fromCharCode(s,a,r),64==l&&(d[h/4]=String.fromCharCode(s,a)),64==o&&(d[h/4]=String.fromCharCode(s));return o=d.join(""),t?n.decode(o):o}},n={encode:function(e){return e=e.replace(/[\u0080-\u07ff]/g,function(e){return e=e.charCodeAt(0),String.fromCharCode(192|e>>6,128|63&e)
}),e=e.replace(/[\u0800-\uffff]/g,function(e){return e=e.charCodeAt(0),String.fromCharCode(224|e>>12,128|e>>6&63,128|63&e)})},decode:function(e){return e=e.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g,function(e){return e=(15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2),String.fromCharCode(e)}),e=e.replace(/[\u00c0-\u00df][\u0080-\u00bf]/g,function(e){return e=(31&e.charCodeAt(0))<<6|63&e.charCodeAt(1),String.fromCharCode(e)})}}}(jwplayer.utils),function(e){e.events={COMPLETE:"COMPLETE",ERROR:"ERROR",API_READY:"jwplayerAPIReady",JWPLAYER_READY:"jwplayerReady",JWPLAYER_FULLSCREEN:"jwplayerFullscreen",JWPLAYER_RESIZE:"jwplayerResize",JWPLAYER_ERROR:"jwplayerError",JWPLAYER_SETUP_ERROR:"jwplayerSetupError",JWPLAYER_MEDIA_BEFOREPLAY:"jwplayerMediaBeforePlay",JWPLAYER_MEDIA_BEFORECOMPLETE:"jwplayerMediaBeforeComplete",JWPLAYER_COMPONENT_SHOW:"jwplayerComponentShow",JWPLAYER_COMPONENT_HIDE:"jwplayerComponentHide",JWPLAYER_MEDIA_BUFFER:"jwplayerMediaBuffer",JWPLAYER_MEDIA_BUFFER_FULL:"jwplayerMediaBufferFull",JWPLAYER_MEDIA_ERROR:"jwplayerMediaError",JWPLAYER_MEDIA_LOADED:"jwplayerMediaLoaded",JWPLAYER_MEDIA_COMPLETE:"jwplayerMediaComplete",JWPLAYER_MEDIA_SEEK:"jwplayerMediaSeek",JWPLAYER_MEDIA_TIME:"jwplayerMediaTime",JWPLAYER_MEDIA_VOLUME:"jwplayerMediaVolume",JWPLAYER_MEDIA_META:"jwplayerMediaMeta",JWPLAYER_MEDIA_MUTE:"jwplayerMediaMute",JWPLAYER_MEDIA_LEVELS:"jwplayerMediaLevels",JWPLAYER_MEDIA_LEVEL_CHANGED:"jwplayerMediaLevelChanged",JWPLAYER_CAPTIONS_CHANGED:"jwplayerCaptionsChanged",JWPLAYER_CAPTIONS_LIST:"jwplayerCaptionsList",JWPLAYER_CAPTIONS_LOADED:"jwplayerCaptionsLoaded",JWPLAYER_PLAYER_STATE:"jwplayerPlayerState",state:{BUFFERING:"BUFFERING",IDLE:"IDLE",PAUSED:"PAUSED",PLAYING:"PLAYING"},JWPLAYER_PLAYLIST_LOADED:"jwplayerPlaylistLoaded",JWPLAYER_PLAYLIST_ITEM:"jwplayerPlaylistItem",JWPLAYER_PLAYLIST_COMPLETE:"jwplayerPlaylistComplete",JWPLAYER_DISPLAY_CLICK:"jwplayerViewClick",JWPLAYER_CONTROLS:"jwplayerViewControls",JWPLAYER_USER_ACTION:"jwplayerUserAction",JWPLAYER_INSTREAM_CLICK:"jwplayerInstreamClicked",JWPLAYER_INSTREAM_DESTROYED:"jwplayerInstreamDestroyed",JWPLAYER_AD_TIME:"jwplayerAdTime",JWPLAYER_AD_ERROR:"jwplayerAdError",JWPLAYER_AD_CLICK:"jwplayerAdClicked",JWPLAYER_AD_COMPLETE:"jwplayerAdComplete",JWPLAYER_AD_IMPRESSION:"jwplayerAdImpression",JWPLAYER_AD_COMPANIONS:"jwplayerAdCompanions",JWPLAYER_AD_SKIPPED:"jwplayerAdSkipped"}
}(jwplayer),function(e){var t=e.utils;e.events.eventdispatcher=function(i,n){function s(e,i,n){if(e)for(var s=0;s<e.length;s++){var a=e[s];if(a){null!==a.count&&0===--a.count&&delete e[s];try{a.listener(i)}catch(r){t.log('Error handling "'+n+'" event listener ['+s+"]: "+r.toString(),a.listener,i)}}}}var a,r;this.resetEventListeners=function(){a={},r=[]},this.resetEventListeners(),this.addEventListener=function(e,i,n){try{t.exists(a[e])||(a[e]=[]),"string"==t.typeOf(i)&&(i=new Function("return "+i)()),a[e].push({listener:i,count:n||null})
}catch(s){t.log("error",s)}return!1},this.removeEventListener=function(e,i){if(a[e]){try{for(var n=0;n<a[e].length;n++)if(a[e][n].listener.toString()==i.toString()){a[e].splice(n,1);break}}catch(s){t.log("error",s)}return!1}},this.addGlobalListener=function(e,i){try{"string"==t.typeOf(e)&&(e=new Function("return "+e)()),r.push({listener:e,count:i||null})}catch(n){t.log("error",n)}return!1},this.removeGlobalListener=function(e){if(e){try{for(var i=r.length;i--;)r[i].listener.toString()==e.toString()&&r.splice(i,1)
}catch(n){t.log("error",n)}return!1}},this.sendEvent=function(o,l){t.exists(l)||(l={}),t.extend(l,{id:i,version:e.version,type:o}),n&&t.log(o,l),s(a[o],l,o),s(r,l,o)}}}(window.jwplayer),function(e){var t={},i={};e.plugins=function(){},e.plugins.loadPlugins=function(n,s){return i[n]=new e.plugins.pluginloader(new e.plugins.model(t),s),i[n]},e.plugins.registerPlugin=function(i,n,s,a){var r=e.utils.getPluginName(i);t[r]||(t[r]=new e.plugins.plugin(i)),t[r].registerPlugin(i,n,s,a)}}(jwplayer),function(e){e.plugins.model=function(t){this.addPlugin=function(i){var n=e.utils.getPluginName(i);
return t[n]||(t[n]=new e.plugins.plugin(i)),t[n]},this.getPlugins=function(){return t}}}(jwplayer),function(e){var t=jwplayer.utils,i=jwplayer.events;e.pluginmodes={FLASH:0,JAVASCRIPT:1,HYBRID:2},e.plugin=function(n){function s(){switch(t.getPluginPathType(n)){case t.pluginPathType.ABSOLUTE:return n;case t.pluginPathType.RELATIVE:return t.getAbsolutePath(n,window.location.href)}}function a(){d=setTimeout(function(){u=t.loaderstatus.COMPLETE,h.sendEvent(i.COMPLETE)},1e3)}function r(){u=t.loaderstatus.ERROR,h.sendEvent(i.ERROR)
}var o,l,c,d,u=t.loaderstatus.NEW,h=new i.eventdispatcher;t.extend(this,h),this.load=function(){if(u==t.loaderstatus.NEW)if(0<n.lastIndexOf(".swf"))o=n,u=t.loaderstatus.COMPLETE,h.sendEvent(i.COMPLETE);else if(t.getPluginPathType(n)==t.pluginPathType.CDN)u=t.loaderstatus.COMPLETE,h.sendEvent(i.COMPLETE);else{u=t.loaderstatus.LOADING;var e=new t.scriptloader(s());e.addEventListener(i.COMPLETE,a),e.addEventListener(i.ERROR,r),e.load()}},this.registerPlugin=function(e,n,s,a){d&&(clearTimeout(d),d=void 0),c=n,s&&a?(o=a,l=s):"string"==typeof s?o=s:"function"==typeof s?l=s:!s&&!a&&(o=e),u=t.loaderstatus.COMPLETE,h.sendEvent(i.COMPLETE)
},this.getStatus=function(){return u},this.getPluginName=function(){return t.getPluginName(n)},this.getFlashPath=function(){if(o)switch(t.getPluginPathType(o)){case t.pluginPathType.ABSOLUTE:return o;case t.pluginPathType.RELATIVE:return 0<n.lastIndexOf(".swf")?t.getAbsolutePath(o,window.location.href):t.getAbsolutePath(o,s())}return null},this.getJS=function(){return l},this.getTarget=function(){return c},this.getPluginmode=function(){return"undefined"!=typeof o&&"undefined"!=typeof l?e.pluginmodes.HYBRID:"undefined"!=typeof o?e.pluginmodes.FLASH:"undefined"!=typeof l?e.pluginmodes.JAVASCRIPT:void 0
},this.getNewInstance=function(e,t,i){return new l(e,t,i)},this.getURL=function(){return n}}}(jwplayer.plugins),function(e){var t=e.utils,i=e.events,n=t.foreach;e.plugins.pluginloader=function(s,a){function r(){u?p.sendEvent(i.ERROR,{message:l}):d||(d=!0,c=t.loaderstatus.COMPLETE,p.sendEvent(i.COMPLETE))}function o(){if(h||r(),!d&&!u){var i=0,n=s.getPlugins();t.foreach(h,function(s){s=t.getPluginName(s);var a=n[s];s=a.getJS();var o=a.getTarget(),a=a.getStatus();a==t.loaderstatus.LOADING||a==t.loaderstatus.NEW?i++:s&&(!o||parseFloat(o)>parseFloat(e.version))&&(u=!0,l="Incompatible player version",r())
}),0==i&&r()}}var l,c=t.loaderstatus.NEW,d=!1,u=!1,h=a,p=new i.eventdispatcher;t.extend(this,p),this.setupPlugins=function(e,i,a){var r={length:0,plugins:{}},o=0,l={},c=s.getPlugins();return n(i.plugins,function(n,s){var d=t.getPluginName(n),u=c[d],h=u.getFlashPath(),p=u.getJS(),m=u.getURL();h&&(r.plugins[h]=t.extend({},s),r.plugins[h].pluginmode=u.getPluginmode(),r.length++);try{if(p&&i.plugins&&i.plugins[m]){var f=document.createElement("div");f.id=e.id+"_"+d,f.style.position="absolute",f.style.top=0,f.style.zIndex=o+10,l[d]=u.getNewInstance(e,t.extend({},i.plugins[m]),f),o++,e.onReady(a(l[d],f,!0)),e.onResize(a(l[d],f))
}}catch(g){t.log("ERROR: Failed to load "+d+".")}}),e.plugins=l,r},this.load=function(){if(!t.exists(a)||"object"==t.typeOf(a)){c=t.loaderstatus.LOADING,n(a,function(e){t.exists(e)&&(e=s.addPlugin(e),e.addEventListener(i.COMPLETE,o),e.addEventListener(i.ERROR,m))});var e=s.getPlugins();n(e,function(e,t){t.load()})}o()};var m=this.pluginFailed=function(){u||(u=!0,l="File not found",r())};this.getStatus=function(){return c}}}(jwplayer),function(){jwplayer.parsers={localName:function(e){return e?e.localName?e.localName:e.baseName?e.baseName:"":""
},textContent:function(e){return e?e.textContent?jwplayer.utils.trim(e.textContent):e.text?jwplayer.utils.trim(e.text):"":""},getChildNode:function(e,t){return e.childNodes[t]},numChildren:function(e){return e.childNodes?e.childNodes.length:0}}}(jwplayer),function(e){var t=e.parsers;(t.jwparser=function(){}).parseEntry=function(i,n){for(var s=[],a=[],r=e.utils.xmlAttribute,o=0;o<i.childNodes.length;o++){var l=i.childNodes[o];if("jwplayer"==l.prefix){var c=t.localName(l);"source"==c?(delete n.sources,s.push({file:r(l,"file"),"default":r(l,"default"),label:r(l,"label"),type:r(l,"type")})):"track"==c?(delete n.tracks,a.push({file:r(l,"file"),"default":r(l,"default"),kind:r(l,"kind"),label:r(l,"label")})):(n[c]=e.utils.serialize(t.textContent(l)),"file"==c&&n.sources&&delete n.sources)
}n.file||(n.file=n.link)}if(s.length)for(n.sources=[],o=0;o<s.length;o++)0<s[o].file.length&&(s[o]["default"]="true"==s[o]["default"]?!0:!1,s[o].label.length||delete s[o].label,n.sources.push(s[o]));if(a.length)for(n.tracks=[],o=0;o<a.length;o++)0<a[o].file.length&&(a[o]["default"]="true"==a[o]["default"]?!0:!1,a[o].kind=a[o].kind.length?a[o].kind:"captions",a[o].label.length||delete a[o].label,n.tracks.push(a[o]));return n}}(jwplayer),function(e){var t=jwplayer.utils,i=t.xmlAttribute,n=e.localName,s=e.textContent,a=e.numChildren,r=e.mediaparser=function(){};
r.parseGroup=function(e,o){var l,c,d=[];for(c=0;c<a(e);c++)if(l=e.childNodes[c],"media"==l.prefix&&n(l))switch(n(l).toLowerCase()){case"content":i(l,"duration")&&(o.duration=t.seconds(i(l,"duration"))),0<a(l)&&(o=r.parseGroup(l,o)),i(l,"url")&&(o.sources||(o.sources=[]),o.sources.push({file:i(l,"url"),type:i(l,"type"),width:i(l,"width"),label:i(l,"label")}));break;case"title":o.title=s(l);break;case"description":o.description=s(l);break;case"guid":o.mediaid=s(l);break;case"thumbnail":o.image||(o.image=i(l,"url"));
break;case"group":r.parseGroup(l,o);break;case"subtitle":var u={};if(u.file=i(l,"url"),u.kind="captions",0<i(l,"lang").length){var h=u;l=i(l,"lang");var p={zh:"Chinese",nl:"Dutch",en:"English",fr:"French",de:"German",it:"Italian",ja:"Japanese",pt:"Portuguese",ru:"Russian",es:"Spanish"};l=p[l]?p[l]:l,h.label=l}d.push(u)}for(o.hasOwnProperty("tracks")||(o.tracks=[]),c=0;c<d.length;c++)o.tracks.push(d[c]);return o}}(jwplayer.parsers),function(e){function t(t){for(var s={},a=0;a<t.childNodes.length;a++){var o=t.childNodes[a],l=r(o);
if(l)switch(l.toLowerCase()){case"enclosure":s.file=i.xmlAttribute(o,"url");break;case"title":s.title=n(o);break;case"guid":s.mediaid=n(o);break;case"pubdate":s.date=n(o);break;case"description":s.description=n(o);break;case"link":s.link=n(o);break;case"category":s.tags=s.tags?s.tags+n(o):n(o)}}return s=e.mediaparser.parseGroup(t,s),s=e.jwparser.parseEntry(t,s),new jwplayer.playlist.item(s)}var i=jwplayer.utils,n=e.textContent,s=e.getChildNode,a=e.numChildren,r=e.localName;e.rssparser={},e.rssparser.parse=function(e){for(var i=[],n=0;n<a(e);n++){var o=s(e,n);
if("channel"==r(o).toLowerCase())for(var l=0;l<a(o);l++){var c=s(o,l);"item"==r(c).toLowerCase()&&i.push(t(c))}}return i}}(jwplayer.parsers),function(e){e.playlist=function(t){var i=[];if("array"==e.utils.typeOf(t))for(var n=0;n<t.length;n++)i.push(new e.playlist.item(t[n]));else i.push(new e.playlist.item(t));return i}}(jwplayer),function(e){var t=e.item=function(i){var n=jwplayer.utils,s=n.extend({},t.defaults,i);s.tracks=i&&n.exists(i.tracks)?i.tracks:[],0==s.sources.length&&(s.sources=[new e.source(s)]);
for(var a=0;a<s.sources.length;a++){var r=s.sources[a]["default"];s.sources[a]["default"]=r?"true"==r.toString():!1,s.sources[a]=new e.source(s.sources[a])}if(s.captions&&!n.exists(i.tracks)){for(i=0;i<s.captions.length;i++)s.tracks.push(s.captions[i]);delete s.captions}for(a=0;a<s.tracks.length;a++)s.tracks[a]=new e.track(s.tracks[a]);return s};t.defaults={description:"",image:"",mediaid:"",title:"",sources:[],tracks:[]}}(jwplayer.playlist),function(e){var t=jwplayer,i=t.utils,n=t.events,s=t.parsers;
e.loader=function(){function t(t){try{var i=t.responseXML.childNodes;t="";for(var a=0;a<i.length&&(t=i[a],!(8!=t.nodeType));a++);if("xml"==s.localName(t)&&(t=t.nextSibling),"rss"!=s.localName(t))r("Not a valid RSS feed");else{var l=new e(s.rssparser.parse(t));o.sendEvent(n.JWPLAYER_PLAYLIST_LOADED,{playlist:l})}}catch(c){r()}}function a(e){r(e.match(/invalid/i)?"Not a valid RSS feed":"")}function r(e){o.sendEvent(n.JWPLAYER_ERROR,{message:e?e:"Error loading file"})}var o=new n.eventdispatcher;i.extend(this,o),this.load=function(e){i.ajax(e,t,a)
}}}(jwplayer.playlist),function(e){var t=jwplayer.utils,i={file:void 0,label:void 0,type:void 0,"default":void 0};e.source=function(e){var n=t.extend({},i);return t.foreach(i,function(i){t.exists(e[i])&&(n[i]=e[i],delete e[i])}),n.type&&0<n.type.indexOf("/")&&(n.type=t.extensionmap.mimeType(n.type)),"m3u8"==n.type&&(n.type="hls"),"smil"==n.type&&(n.type="rtmp"),n}}(jwplayer.playlist),function(e){var t=jwplayer.utils,i={file:void 0,label:void 0,kind:"captions","default":!1};e.track=function(e){var n=t.extend({},i);
return e||(e={}),t.foreach(i,function(i){t.exists(e[i])&&(n[i]=e[i],delete e[i])}),n}}(jwplayer.playlist),function(e){function t(e,t,n){var s=e.style;s.backgroundColor="#000",s.color="#FFF",s.width=i.styleDimension(n.width),s.height=i.styleDimension(n.height),s.display="table",s.opacity=1,n=document.createElement("p"),s=n.style,s.verticalAlign="middle",s.textAlign="center",s.display="table-cell",s.font="15px/20px Arial, Helvetica, sans-serif",n.innerHTML=t.replace(":",":<br>"),e.innerHTML="",e.appendChild(n)
}var i=e.utils,n=e.events,s=!0,a=!1,r=document,o=e.embed=function(l){function c(e,t){i.foreach(t,function(t,i){"function"==typeof e[t]&&e[t].call(e,i)})}function d(){if(!P)if("array"==i.typeOf(b.playlist)&&2>b.playlist.length&&(0==b.playlist.length||!b.playlist[0].sources||0==b.playlist[0].sources.length))p();else if(!C)if("string"==i.typeOf(b.playlist)){var t=new e.playlist.loader;t.addEventListener(n.JWPLAYER_PLAYLIST_LOADED,function(e){b.playlist=e.playlist,C=a,d()}),t.addEventListener(n.JWPLAYER_ERROR,function(e){C=a,p(e)
}),C=s,t.load(b.playlist)}else if(S.getStatus()==i.loaderstatus.COMPLETE){for(t=0;t<b.modes.length;t++)if(b.modes[t].type&&o[b.modes[t].type]){var r=i.extend({},b),h=new o[b.modes[t].type](g,b.modes[t],r,S,l);if(h.supportsConfig())return h.addEventListener(n.ERROR,u),h.embed(),c(l,r.events),l}var f;b.fallback?(f="No suitable players found and fallback enabled",A=setTimeout(function(){m(f,s)},10),i.log(f),new o.download(g,b,p)):(f="No suitable players found and fallback disabled",m(f,a),i.log(f),g.parentNode.replaceChild(y,g))
}}function u(e){f(k+e.message)}function h(e){f("Could not load plugins: "+e.message)}function p(e){f(e&&e.message?"Error loading playlist: "+e.message:k+"No playable sources found")}function m(e,t){A&&(clearTimeout(A),A=null),A=setTimeout(function(){A=null,l.dispatchEvent(n.JWPLAYER_SETUP_ERROR,{message:e,fallback:t})},0)}function f(e){P||(b.fallback?(P=s,t(g,e,b),m(e,s)):m(e,a))}var g,v,y,b=new o.config(l.config),w=b.width,x=b.height,k="Error loading player: ",S=e.plugins.loadPlugins(l.id,b.plugins),C=a,P=a,A=null;
return b.fallbackDiv&&(y=b.fallbackDiv,delete b.fallbackDiv),b.id=l.id,v=r.getElementById(l.id),b.aspectratio?l.config.aspectratio=b.aspectratio:delete l.config.aspectratio,g=r.createElement("div"),g.id=v.id,g.style.width=0<w.toString().indexOf("%")?w:w+"px",g.style.height=0<x.toString().indexOf("%")?x:x+"px",v.parentNode.replaceChild(g,v),this.embed=function(){P||(S.addEventListener(n.COMPLETE,d),S.addEventListener(n.ERROR,h),S.load())},this.errorScreen=f,this};e.embed.errorScreen=t}(jwplayer),function(e){function t(e){if(e.playlist)for(var t=0;t<e.playlist.length;t++)e.playlist[t]=new s(e.playlist[t]);
else{var a={};n.foreach(s.defaults,function(t){i(e,a,t)}),a.sources||(e.levels?(a.sources=e.levels,delete e.levels):(t={},i(e,t,"file"),i(e,t,"type"),a.sources=t.file?[t]:[])),e.playlist=[new s(a)]}}function i(e,t,i){n.exists(e[i])&&(t[i]=e[i],delete e[i])}var n=e.utils,s=e.playlist.item;(e.embed.config=function(i){var s={fallback:!0,height:270,primary:"html5",width:480,base:i.base?i.base:n.getScriptPath("jwplayer.js"),aspectratio:""};i=n.extend(s,e.defaults,i);var s={type:"html5",src:i.base+"jwplayer.html5.js"},a={type:"flash",src:i.base+"jwplayer.flash.swf"};
if(i.modes="flash"==i.primary?[a,s]:[s,a],i.listbar&&(i.playlistsize=i.listbar.size,i.playlistposition=i.listbar.position,i.playlistlayout=i.listbar.layout),i.flashplayer&&(a.src=i.flashplayer),i.html5player&&(s.src=i.html5player),t(i),a=i.aspectratio,"string"==typeof a&&n.exists(a)){var r=a.indexOf(":");-1==r?s=0:(s=parseFloat(a.substr(0,r)),a=parseFloat(a.substr(r+1)),s=0>=s||0>=a?0:100*(a/s)+"%")}else s=0;return-1==i.width.toString().indexOf("%")?delete i.aspectratio:s?i.aspectratio=s:delete i.aspectratio,i
}).addConfig=function(e,i){return t(i),n.extend(e,i)}}(jwplayer),function(e){var t=e.utils,i=document;e.embed.download=function(e,n,s){function a(e,n){for(var s=i.querySelectorAll(e),a=0;a<s.length;a++)t.foreach(n,function(e,t){s[a].style[e]=t})}function r(e,t,n){return e=i.createElement(e),t&&(e.className="jwdownload"+t),n&&n.appendChild(e),e}var o,l=t.extend({},n),c=l.width?l.width:480,d=l.height?l.height:320;n=n.logo?n.logo:{prefix:t.repo(),file:"logo.png",margin:10};var u,h,p,m,l=l.playlist,f=["mp4","aac","mp3"];
if(l&&l.length){for(m=l[0],o=m.sources,l=0;l<o.length;l++){var g=o[l],v=g.type?g.type:t.extensionmap.extType(t.extension(g.file));g.file&&t.foreach(f,function(e){v==f[e]?(u=g.file,h=m.image):t.isYouTube(g.file)&&(p=g.file)})}u?(o=u,s=h,e&&(l=r("a","display",e),r("div","icon",l),r("div","logo",l),o&&l.setAttribute("href",t.getAbsolutePath(o))),l="#"+e.id+" .jwdownload",e.style.width="",e.style.height="",a(l+"display",{width:t.styleDimension(Math.max(320,c)),height:t.styleDimension(Math.max(180,d)),background:"black center no-repeat "+(s?"url("+s+")":""),backgroundSize:"contain",position:"relative",border:"none",display:"block"}),a(l+"display div",{position:"absolute",width:"100%",height:"100%"}),a(l+"logo",{top:n.margin+"px",right:n.margin+"px",background:"top right no-repeat url("+n.prefix+n.file+")"}),a(l+"icon",{background:"center no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAgNJREFUeNrs28lqwkAYB/CZqNVDDj2r6FN41QeIy8Fe+gj6BL275Q08u9FbT8ZdwVfotSBYEPUkxFOoks4EKiJdaDuTjMn3wWBO0V/+sySR8SNSqVRKIR8qaXHkzlqS9jCfzzWcTCYp9hF5o+59sVjsiRzcegSckFzcjT+ruN80TeSlAjCAAXzdJSGPFXRpAAMYwACGZQkSdhG4WCzehMNhqV6vG6vVSrirKVEw66YoSqDb7cqlUilE8JjHd/y1MQefVzqdDmiaJpfLZWHgXMHn8F6vJ1cqlVAkEsGuAn83J4gAd2RZymQygX6/L1erVQt+9ZPWb+CDwcCC2zXGJaewl/DhcHhK3DVj+KfKZrMWvFarcYNLomAv4aPRSFZVlTlcSPA5fDweW/BoNIqFnKV53JvncjkLns/n/cLdS+92O7RYLLgsKfv9/t8XlDn4eDyiw+HA9Jyz2eyt0+kY2+3WFC5hluej0Ha7zQQq9PPwdDq1Et1sNsx/nFBgCqWJ8oAK1aUptNVqcYWewE4nahfU0YQnk4ntUEfGMIU2m01HoLaCKbTRaDgKtaVLk9tBYaBcE/6Artdr4RZ5TB6/dC+9iIe/WgAMYADDpAUJAxjAAAYwgGFZgoS/AtNNTF7Z2bL0BYPBV3Jw5xFwwWcYxgtBP5OkE8i9G7aWGOOCruvauwADALMLMEbKf4SdAAAAAElFTkSuQmCC)"})):p?(n=p,e=r("iframe","",e),e.src="http://www.youtube.com/embed/"+t.youTubeID(n),e.width=c,e.height=d,e.style.border="none"):s()
}}}(jwplayer),function(e){var t=e.utils,i=e.events,n={};(e.embed.flash=function(a,r,o,l,c){function d(e,t,i){var n=document.createElement("param");n.setAttribute("name",t),n.setAttribute("value",i),e.appendChild(n)}function u(e,t,i){return function(){try{i&&document.getElementById(c.id+"_wrapper").appendChild(t);var n=document.getElementById(c.id).getPluginConfig("display");"function"==typeof e.resize&&e.resize(n.width,n.height),t.style.left=n.x,t.style.top=n.h}catch(s){}}}function h(e){if(!e)return{};
var i={},n=[];return t.foreach(e,function(e,s){var a=t.getPluginName(e);n.push(e),t.foreach(s,function(e,t){i[a+"."+e]=t})}),i.plugins=n.join(","),i}var p=new e.events.eventdispatcher,m=t.flashVersion();t.extend(this,p),this.embed=function(){if(o.id=c.id,10>m)return p.sendEvent(i.ERROR,{message:"Flash version must be 10.0 or greater"}),!1;var e,s,f=c.config.listbar,g=t.extend({},o);if(a.id+"_wrapper"==a.parentNode.id)e=document.getElementById(a.id+"_wrapper");else{if(e=document.createElement("div"),s=document.createElement("div"),s.style.display="none",s.id=a.id+"_aspect",e.id=a.id+"_wrapper",e.style.position="relative",e.style.display="block",e.style.width=t.styleDimension(g.width),e.style.height=t.styleDimension(g.height),c.config.aspectratio){var v=parseFloat(c.config.aspectratio);
s.style.display="block",s.style.marginTop=c.config.aspectratio,e.style.height="auto",e.style.display="inline-block",f&&("bottom"==f.position?s.style.paddingBottom=f.size+"px":"right"==f.position&&(s.style.marginBottom=-1*f.size*(v/100)+"px"))}a.parentNode.replaceChild(e,a),e.appendChild(a),e.appendChild(s)}for(e=l.setupPlugins(c,g,u),0<e.length?t.extend(g,h(e.plugins)):delete g.plugins,"undefined"!=typeof g["dock.position"]&&"false"==g["dock.position"].toString().toLowerCase()&&(g.dock=g["dock.position"],delete g["dock.position"]),e=g.wmode?g.wmode:g.height&&40>=g.height?"transparent":"opaque",s="height width modes events primary base fallback volume".split(" "),f=0;f<s.length;f++)delete g[s[f]];
s=t.getCookies(),t.foreach(s,function(e,t){"undefined"==typeof g[e]&&(g[e]=t)}),s=window.location.href.split("/"),s.splice(s.length-1,1),s=s.join("/"),g.base=s+"/",n[a.id]=g,t.isIE()?(s='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" " width="100%" height="100%"id="'+a.id+'" name="'+a.id+'" tabindex=0"">',s+='<param name="movie" value="'+r.src+'">',s+='<param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always">',s+='<param name="seamlesstabbing" value="true">',s+='<param name="wmode" value="'+e+'">',s+='<param name="bgcolor" value="#000000">',s+="</object>",a.outerHTML=s,e=document.getElementById(a.id)):(s=document.createElement("object"),s.setAttribute("type","application/x-shockwave-flash"),s.setAttribute("data",r.src),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("bgcolor","#000000"),s.setAttribute("id",a.id),s.setAttribute("name",a.id),s.setAttribute("tabindex",0),d(s,"allowfullscreen","true"),d(s,"allowscriptaccess","always"),d(s,"seamlesstabbing","true"),d(s,"wmode",e),a.parentNode.replaceChild(s,a),e=s),c.config.aspectratio&&(e.style.position="absolute"),c.container=e,c.setPlayer(e,"flash")
},this.supportsConfig=function(){if(m){if(!o)return!0;if("string"==t.typeOf(o.playlist))return!0;try{var e=o.playlist[0].sources;if("undefined"==typeof e)return!0;for(var i=0;i<e.length;i++)if(e[i].file&&s(e[i].file,e[i].type))return!0}catch(n){}}return!1}}).getVars=function(e){return n[e]};var s=e.embed.flashCanPlay=function(e,i){if(t.isYouTube(e)||t.isRtmp(e,i)||"hls"==i)return!0;var n=t.extensionmap[i?i:t.extension(e)];return n?!!n.flash:!1}}(jwplayer),function(e){var t=e.utils,i=t.extensionmap,n=e.events;
e.embed.html5=function(s,a,r,o,l){function c(e,t,i){return function(){try{var n=document.querySelector("#"+s.id+" .jwmain");i&&n.appendChild(t),"function"==typeof e.resize&&(e.resize(n.clientWidth,n.clientHeight),setTimeout(function(){e.resize(n.clientWidth,n.clientHeight)},400)),t.left=n.style.left,t.top=n.style.top}catch(a){}}}function d(e){u.sendEvent(e.type,{message:"HTML5 player not found"})}var u=this,h=new n.eventdispatcher;t.extend(u,h),u.embed=function(){if(e.html5){o.setupPlugins(l,r,c),s.innerHTML="";
var i=e.utils.extend({},r);delete i.volume,i=new e.html5.player(i),l.container=document.getElementById(l.id),l.setPlayer(i,"html5")}else i=new t.scriptloader(a.src),i.addEventListener(n.ERROR,d),i.addEventListener(n.COMPLETE,u.embed),i.load()},u.supportsConfig=function(){if(e.vid.canPlayType)try{if("string"==t.typeOf(r.playlist))return!0;for(var n=r.playlist[0].sources,s=0;s<n.length;s++){var a,o=n[s].file,l=n[s].type;if(null!==navigator.userAgent.match(/BlackBerry/i)||t.isAndroid()&&("m3u"==t.extension(o)||"m3u8"==t.extension(o))||t.isRtmp(o,l))a=!1;
else{var c,d=i[l?l:t.extension(o)];if(!d||d.flash&&!d.html5)c=!1;else{var u=d.html5,h=e.vid;if(u)try{c=h.canPlayType(u)?!0:!1}catch(p){c=!1}else c=!0}a=c}if(a)return!0}}catch(m){}return!1}}}(jwplayer),function(e){var t=e.embed,i=e.utils,n=/\.(js|swf)$/;e.embed=i.extend(function(s){function a(){r="Adobe SiteCatalyst Error: Could not find Media Module"}var r,o=i.repo(),l=i.extend({},e.defaults),c=i.extend({},l,s.config),d=s.config,u=c.plugins,h=c.analytics,p=o+"jwpsrv.js",m=o+"sharing.js",f=o+"related.js",g=o+"gapro.js",l=e.key?e.key:l.key,v=new e.utils.key(l).edition(),u=u?u:{};
switch("ads"==v&&c.advertising&&(n.test(c.advertising.client)?u[c.advertising.client]=c.advertising:u[o+c.advertising.client+".js"]=c.advertising),delete d.advertising,d.key=l,c.analytics&&n.test(c.analytics.client)&&(p=c.analytics.client),delete d.analytics,h&&"ads"!==v&&delete h.enabled,"free"!=v&&h&&!1===h.enabled||(u[p]=h?h:{}),delete u.sharing,delete u.related,v){case"ads":if(d.sitecatalyst)try{window.s&&window.s.hasOwnProperty("Media")?new e.embed.sitecatalyst(s):a()}catch(y){a()}case"premium":c.related&&(n.test(c.related.client)&&(f=c.related.client),u[f]=c.related),c.ga&&(n.test(c.ga.client)&&(g=c.ga.client),u[g]=c.ga);
case"pro":c.sharing&&(n.test(c.sharing.client)&&(m=c.sharing.client),u[m]=c.sharing),c.skin&&(d.skin=c.skin.replace(/^(beelden|bekle|five|glow|modieus|roundster|stormtrooper|vapor)$/i,i.repo()+"skins/$1.xml"))}return d.plugins=u,s.config=d,s=new t(s),r&&s.errorScreen(r),s},e.embed)}(jwplayer),function(e){var t=jwplayer.utils;e.sitecatalyst=function(e){function i(e){h.debug&&t.log(e)}function n(e){return e=e.split("/"),e=e[e.length-1],e=e.split("?"),e[0]}function a(){if(!m){m=!0;var e=u.getPosition();
i("stop: "+o+" : "+e),s.Media.stop(o,e)}}function r(){f||(a(),f=!0,i("close: "+o),s.Media.close(o),d=!0,c=0)}var o,l,c,d,u=e,h=t.extend({},u.config.sitecatalyst),p={onPlay:function(){if(!d){var e=u.getPosition();m=!1,i("play: "+o+" : "+e),s.Media.play(o,e)}},onPause:a,onBuffer:a,onIdle:r,onPlaylistItem:function(e){try{d=!0,r(),c=0;var i;if(h.mediaName)i=h.mediaName;else{var s=u.getPlaylistItem(e.index);i=s.title?s.title:s.file?n(s.file):s.sources&&s.sources.length?n(s.sources[0].file):""}o=i,l=h.playerName?h.playerName:u.id
}catch(a){t.log(a)}},onTime:function(){if(d){var e=u.getDuration();if(-1==e)return;f=m=d=!1,i("open: "+o+" : "+e+" : "+l),s.Media.open(o,e,l),i("play: "+o+" : 0"),s.Media.play(o,0)}if(e=u.getPosition(),3<=Math.abs(e-c)){var t=c;i("seek: "+t+" to "+e),i("stop: "+o+" : "+t),s.Media.stop(o,t),i("play: "+o+" : "+e),s.Media.play(o,e)}c=e},onComplete:r},m=!0,f=!0;t.foreach(p,function(e){u[e](p[e])})}}(jwplayer.embed),function(e,t){var i=[],n=e.utils,s=e.events,a=s.state,r=document,o=e.api=function(i){function l(e,t){return function(i){return t(e,i)
}}function c(e,t){return v[e]||(v[e]=[],u(s.JWPLAYER_PLAYER_STATE,function(t){var i=t.newstate;if(t=t.oldstate,i==e){var n=v[i];if(n)for(var s=0;s<n.length;s++){var a=n[s];"function"==typeof a&&a.call(this,{oldstate:t,newstate:i})}}})),v[e].push(t),f}function d(e,t){try{e.jwAddEventListener(t,'function(dat) { jwplayer("'+f.id+'").dispatchEvent("'+t+'", dat); }')}catch(i){n.log("Could not add internal listener")}}function u(e,t){return g[e]||(g[e]=[],p&&y&&d(p,e)),g[e].push(t),f}function h(){if(y){if(p){var e=Array.prototype.slice.call(arguments,0),t=e.shift();
if("function"==typeof p[t]){switch(e.length){case 6:return p[t](e[0],e[1],e[2],e[3],e[4],e[5]);case 5:return p[t](e[0],e[1],e[2],e[3],e[4]);case 4:return p[t](e[0],e[1],e[2],e[3]);case 3:return p[t](e[0],e[1],e[2]);case 2:return p[t](e[0],e[1]);case 1:return p[t](e[0])}return p[t]()}}return null}b.push(arguments)}var p,m,f=this,g={},v={},y=!1,b=[],w={},x={};f.container=i,f.id=i.id,f.getBuffer=function(){return h("jwGetBuffer")},f.getContainer=function(){return f.container},f.addButton=function(e,t,i,s){try{x[s]=i,h("jwDockAddButton",e,t,"jwplayer('"+f.id+"').callback('"+s+"')",s)
}catch(a){n.log("Could not add dock button"+a.message)}},f.removeButton=function(e){h("jwDockRemoveButton",e)},f.callback=function(e){x[e]&&x[e]()},f.forceState=function(e){return h("jwForceState",e),f},f.releaseState=function(){return h("jwReleaseState")},f.getDuration=function(){return h("jwGetDuration")},f.getFullscreen=function(){return h("jwGetFullscreen")},f.getHeight=function(){return h("jwGetHeight")},f.getLockState=function(){return h("jwGetLockState")},f.getMeta=function(){return f.getItemMeta()
},f.getMute=function(){return h("jwGetMute")},f.getPlaylist=function(){var e=h("jwGetPlaylist");return"flash"==f.renderingMode&&n.deepReplaceKeyName(e,["__dot__","__spc__","__dsh__","__default__"],["."," ","-","default"]),e},f.getPlaylistItem=function(e){return n.exists(e)||(e=f.getPlaylistIndex()),f.getPlaylist()[e]},f.getPlaylistIndex=function(){return h("jwGetPlaylistIndex")},f.getPosition=function(){return h("jwGetPosition")},f.getRenderingMode=function(){return f.renderingMode},f.getState=function(){return h("jwGetState")
},f.getVolume=function(){return h("jwGetVolume")},f.getWidth=function(){return h("jwGetWidth")},f.setFullscreen=function(e){return n.exists(e)?h("jwSetFullscreen",e):h("jwSetFullscreen",!h("jwGetFullscreen")),f},f.setMute=function(e){return n.exists(e)?h("jwSetMute",e):h("jwSetMute",!h("jwGetMute")),f},f.lock=function(){return f},f.unlock=function(){return f},f.load=function(e){return h("jwLoad",e),f},f.playlistItem=function(e){return h("jwPlaylistItem",parseInt(e,10)),f},f.playlistPrev=function(){return h("jwPlaylistPrev"),f
},f.playlistNext=function(){return h("jwPlaylistNext"),f},f.resize=function(e,t){if("flash"!==f.renderingMode)h("jwResize",e,t);else{var i=r.getElementById(f.id+"_wrapper"),s=r.getElementById(f.id+"_aspect");s&&(s.style.display="none"),i&&(i.style.display="block",i.style.width=n.styleDimension(e),i.style.height=n.styleDimension(t))}return f},f.play=function(e){return e===t?(e=f.getState(),h(e==a.PLAYING||e==a.BUFFERING?"jwPause":"jwPlay")):h("jwPlay",e),f},f.pause=function(e){return e===t?(e=f.getState(),h(e==a.PLAYING||e==a.BUFFERING?"jwPause":"jwPlay")):h("jwPause",e),f
},f.stop=function(){return h("jwStop"),f},f.seek=function(e){return h("jwSeek",e),f},f.setVolume=function(e){return h("jwSetVolume",e),f},f.createInstream=function(){return new o.instream(this,p)},f.setInstream=function(e){return m=e},f.loadInstream=function(e,t){return m=f.setInstream(f.createInstream()).init(t),m.loadItem(e),m},f.getQualityLevels=function(){return h("jwGetQualityLevels")},f.getCurrentQuality=function(){return h("jwGetCurrentQuality")},f.setCurrentQuality=function(e){h("jwSetCurrentQuality",e)
},f.getCaptionsList=function(){return h("jwGetCaptionsList")},f.getCurrentCaptions=function(){return h("jwGetCurrentCaptions")},f.setCurrentCaptions=function(e){h("jwSetCurrentCaptions",e)},f.getControls=function(){return h("jwGetControls")},f.getSafeRegion=function(){return h("jwGetSafeRegion")},f.setControls=function(e){h("jwSetControls",e)},f.destroyPlayer=function(){h("jwPlayerDestroy")},f.playAd=function(t){var i=e(f.id).plugins;i.vast&&i.vast.jwPlayAd(t)},f.pauseAd=function(){var t=e(f.id).plugins;
t.vast?t.vast.jwPauseAd():h("jwPauseAd")};var k={onBufferChange:s.JWPLAYER_MEDIA_BUFFER,onBufferFull:s.JWPLAYER_MEDIA_BUFFER_FULL,onError:s.JWPLAYER_ERROR,onSetupError:s.JWPLAYER_SETUP_ERROR,onFullscreen:s.JWPLAYER_FULLSCREEN,onMeta:s.JWPLAYER_MEDIA_META,onMute:s.JWPLAYER_MEDIA_MUTE,onPlaylist:s.JWPLAYER_PLAYLIST_LOADED,onPlaylistItem:s.JWPLAYER_PLAYLIST_ITEM,onPlaylistComplete:s.JWPLAYER_PLAYLIST_COMPLETE,onReady:s.API_READY,onResize:s.JWPLAYER_RESIZE,onComplete:s.JWPLAYER_MEDIA_COMPLETE,onSeek:s.JWPLAYER_MEDIA_SEEK,onTime:s.JWPLAYER_MEDIA_TIME,onVolume:s.JWPLAYER_MEDIA_VOLUME,onBeforePlay:s.JWPLAYER_MEDIA_BEFOREPLAY,onBeforeComplete:s.JWPLAYER_MEDIA_BEFORECOMPLETE,onDisplayClick:s.JWPLAYER_DISPLAY_CLICK,onControls:s.JWPLAYER_CONTROLS,onQualityLevels:s.JWPLAYER_MEDIA_LEVELS,onQualityChange:s.JWPLAYER_MEDIA_LEVEL_CHANGED,onCaptionsList:s.JWPLAYER_CAPTIONS_LIST,onCaptionsChange:s.JWPLAYER_CAPTIONS_CHANGED,onAdError:s.JWPLAYER_AD_ERROR,onAdClick:s.JWPLAYER_AD_CLICK,onAdImpression:s.JWPLAYER_AD_IMPRESSION,onAdTime:s.JWPLAYER_AD_TIME,onAdComplete:s.JWPLAYER_AD_COMPLETE,onAdCompanions:s.JWPLAYER_AD_COMPANIONS,onAdSkipped:s.JWPLAYER_AD_SKIPPED};
n.foreach(k,function(e){f[e]=l(k[e],u)});var S={onBuffer:a.BUFFERING,onPause:a.PAUSED,onPlay:a.PLAYING,onIdle:a.IDLE};return n.foreach(S,function(e){f[e]=l(S[e],c)}),f.remove=function(){if(!y)throw"Cannot call remove() before player is ready";b=[],o.destroyPlayer(this.id)},f.setup=function(t){if(e.embed){var i=r.getElementById(f.id);return i&&(t.fallbackDiv=i),i=f,b=[],o.destroyPlayer(i.id),i=e(f.id),i.config=t,new e.embed(i).embed(),i}return f},f.registerPlugin=function(t,i,n,s){e.plugins.registerPlugin(t,i,n,s)
},f.setPlayer=function(e,t){p=e,f.renderingMode=t},f.detachMedia=function(){return"html5"==f.renderingMode?h("jwDetachMedia"):void 0},f.attachMedia=function(e){return"html5"==f.renderingMode?h("jwAttachMedia",e):void 0},f.removeEventListener=function(e,t){var i=g[e];if(i)for(var n=i.length;n--;)i[n]===t&&i.splice(n,1)},f.dispatchEvent=function(e,t){var i=g[e];if(i)for(var i=i.slice(0),a=n.translateEventResponse(e,t),r=0;r<i.length;r++){var o=i[r];if("function"==typeof o)try{e===s.JWPLAYER_PLAYLIST_LOADED&&n.deepReplaceKeyName(a.playlist,["__dot__","__spc__","__dsh__","__default__"],["."," ","-","default"]),o.call(this,a)
}catch(l){n.log("There was an error calling back an event handler")}}},f.dispatchInstreamEvent=function(e){m&&m.dispatchEvent(e,arguments)},f.callInternal=h,f.playerReady=function(e){for(y=!0,p||f.setPlayer(r.getElementById(e.id)),f.container=r.getElementById(f.id),n.foreach(g,function(e){d(p,e)}),u(s.JWPLAYER_PLAYLIST_ITEM,function(){w={}}),u(s.JWPLAYER_MEDIA_META,function(e){n.extend(w,e.metadata)}),f.dispatchEvent(s.API_READY);0<b.length;)h.apply(this,b.shift())},f.getItemMeta=function(){return w
},f.isBeforePlay=function(){return h("jwIsBeforePlay")},f.isBeforeComplete=function(){return h("jwIsBeforeComplete")},f};o.selectPlayer=function(e){var t;return n.exists(e)||(e=0),e.nodeType?t=e:"string"==typeof e&&(t=r.getElementById(e)),t?(e=o.playerById(t.id))?e:o.addPlayer(new o(t)):"number"==typeof e?i[e]:null},o.playerById=function(e){for(var t=0;t<i.length;t++)if(i[t].id==e)return i[t];return null},o.addPlayer=function(e){for(var t=0;t<i.length;t++)if(i[t]==e)return e;return i.push(e),e},o.destroyPlayer=function(e){for(var t,s=-1,a=0;a<i.length;a++)i[a].id==e&&(s=a,t=i[a]);
return s>=0&&(e=t.id,a=r.getElementById(e+("flash"==t.renderingMode?"_wrapper":"")),n.clearCss&&n.clearCss("#"+e),a&&("html5"==t.renderingMode&&t.destroyPlayer(),t=r.createElement("div"),t.id=e,a.parentNode.replaceChild(t,a)),i.splice(s,1)),null},e.playerReady=function(t){var i=e.api.playerById(t.id);i?i.playerReady(t):e.api.selectPlayer(t.id).playerReady(t)}}(window.jwplayer),function(e){var t=e.events,i=e.utils,n=t.state;e.api.instream=function(e,s){function a(t,i){return c[t]||(c[t]=[],s.jwInstreamAddEventListener(t,'function(dat) { jwplayer("'+e.id+'").dispatchInstreamEvent("'+t+'", dat); }')),c[t].push(i),this
}function r(e,i){return d[e]||(d[e]=[],a(t.JWPLAYER_PLAYER_STATE,function(t){var i=t.newstate,n=t.oldstate;if(i==e){var s=d[i];if(s)for(var a=0;a<s.length;a++){var r=s[a];"function"==typeof r&&r.call(this,{oldstate:n,newstate:i,type:t.type})}}})),d[e].push(i),this}var o,l,c={},d={},u=this;u.type="instream",u.init=function(){return e.callInternal("jwInitInstream"),u},u.loadItem=function(t,n){o=t,l=n||{},"array"==i.typeOf(t)?e.callInternal("jwLoadArrayInstream",o,l):e.callInternal("jwLoadItemInstream",o,l)
},u.removeEvents=function(){c=d={}},u.removeEventListener=function(e,t){var i=c[e];if(i)for(var n=i.length;n--;)i[n]===t&&i.splice(n,1)},u.dispatchEvent=function(e,t){var n=c[e];if(n)for(var n=n.slice(0),s=i.translateEventResponse(e,t[1]),a=0;a<n.length;a++){var r=n[a];"function"==typeof r&&r.call(this,s)}},u.onError=function(e){return a(t.JWPLAYER_ERROR,e)},u.onMediaError=function(e){return a(t.JWPLAYER_MEDIA_ERROR,e)},u.onFullscreen=function(e){return a(t.JWPLAYER_FULLSCREEN,e)},u.onMeta=function(e){return a(t.JWPLAYER_MEDIA_META,e)
},u.onMute=function(e){return a(t.JWPLAYER_MEDIA_MUTE,e)},u.onComplete=function(e){return a(t.JWPLAYER_MEDIA_COMPLETE,e)},u.onPlaylistComplete=function(e){return a(t.JWPLAYER_PLAYLIST_COMPLETE,e)},u.onPlaylistItem=function(e){return a(t.JWPLAYER_PLAYLIST_ITEM,e)},u.onTime=function(e){return a(t.JWPLAYER_MEDIA_TIME,e)},u.onBuffer=function(e){return r(n.BUFFERING,e)},u.onPause=function(e){return r(n.PAUSED,e)},u.onPlay=function(e){return r(n.PLAYING,e)},u.onIdle=function(e){return r(n.IDLE,e)},u.onClick=function(e){return a(t.JWPLAYER_INSTREAM_CLICK,e)
},u.onInstreamDestroyed=function(e){return a(t.JWPLAYER_INSTREAM_DESTROYED,e)},u.onAdSkipped=function(e){return a(t.JWPLAYER_AD_SKIPPED,e)},u.play=function(e){s.jwInstreamPlay(e)},u.pause=function(e){s.jwInstreamPause(e)},u.hide=function(){e.callInternal("jwInstreamHide")},u.destroy=function(){u.removeEvents(),e.callInternal("jwInstreamDestroy")},u.setText=function(e){s.jwInstreamSetText(e?e:"")},u.getState=function(){return s.jwInstreamState()},u.setClick=function(e){s.jwInstreamClick&&s.jwInstreamClick(e)
}}}(window.jwplayer),function(e){var t=e.api,i=t.selectPlayer;t.selectPlayer=function(t){return(t=i(t))?t:{registerPlugin:function(t,i,n){e.plugins.registerPlugin(t,i,n)}}}}(jwplayer)),define("jwplayer",function(e){return function(){var t;return t||e.jwplayer}}(this)),define("plex/desktop/adapters/player/DesktopFlashPlayerSubcontroller",["underscore","jwplayer","plex/base/utils/t","plex/base/utils/BaseClass","plex/base/utils/playerUtil","plex/base/utils/Backlog","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r){"use strict";
t.key="fv2ELs9q2gEZxE9uuiAGfhbE9Qhc4DyhZjt1j0GaxUI=";var o=n.extend({wrapped:["play","pause","playPause","getState","setVolume","setPosition","resume","stop"],initialize:function(t){e.bindAll(this,"onReady","onPlay","onTime","onBuffer","onPause","onVolume","onComplete","onError"),this.type=t,this.backlog=new a,this.backlog.wrapAll(this.wrapped,function(){return!!this.video},this)},load:function(n){this.model=n.model,this.offset=this.model.get("position"),this.backlog.clear(),e.defer(e.bind(function(){var n=t("flash-video-placeholder"),a=this.model.get("url");
return e.isFunction(n.setup)?(r.group("Flash Player",["URL: "+a,"Autoplay: true","Offset: "+this.offset]),this.model.set("ready",!0),void(this.video=n.setup({file:a,skin:"swf/jwplayer/plex.xml",flashplayer:"swf/jwplayer/jwplayer.swf",stretching:"uniform",width:"100%",height:"100%",volume:100,mute:!1,autostart:!0,analytics:{enabled:!1},events:{onReady:this.onReady,onPlay:this.onPlay,onTime:this.onTime,onBuffer:this.onBuffer,onPause:this.onPause,onVolume:this.onVolume,onComplete:this.onComplete,onError:this.onError}}))):void this.model.set({state:s.states.ERROR,errorMessage:i("Your browser does not support video streaming.")})
},this))},play:function(){this.video.play(!0)},pause:function(){this.video.pause(!0)},setVolume:function(e){this.video.setVolume(e)},setPosition:function(e){this.video.seek(e/1e3)},resume:function(){r.log("resuming at "+this.offset);var e=this.offset;this.offset=null,this.setPosition(e)},stop:function(){this.model.get("loaded")&&this.video.remove(),this.video=null},onReady:function(){this.model.set("loaded",!0),this.setVolume(this.model.get("volume")),this.backlog.process()},onPlay:function(){this.model.set("state",s.states.PLAYING)
},onTime:function(e){return this.offset?void this.resume():(this.model.set("duration",Math.round(1e3*e.duration)),void this.model.set("position",Math.round(1e3*e.position)))},onBuffer:function(){this.model.set("state",s.states.BUFFERING)},onPause:function(){this.model.set("state",s.states.PAUSED)},onVolume:function(e){this.model.set("volume",e.volume)},onComplete:function(){this.model.set("ended",!0)},onError:function(e){this.model.set({state:s.states.ERROR,errorMessage:e.message})}});return o}),define("plex/desktop/adapters/player/DesktopVideoPlayerController",["underscore","swfobject","plex/base/utils/t","plex/base/utils/capabilities","plex/base/utils/browser","plex/base/utils/playerUtil","plex/base/utils/playerQualities","plex/base/utils/playerDecisionEngine","plex/base/utils/mediaDecisionEngine","plex/base/utils/constants/subtitlesBurnLevels","plex/desktop/utils/desktopTranscoder","plex/base/adapters/settingsAdapter","plex/base/adapters/player/LocalPlayerController","plex/desktop/adapters/player/DesktopHTMLPlayerSubcontroller","plex/desktop/adapters/player/DesktopFlashPlayerSubcontroller","plex/base/models/appModel"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f){"use strict";
var g=h.extend({type:a.types.VIDEO,modelDefaults:function(){var t=h.prototype.modelDefaults.apply(this,arguments);return e.extend(t,{canPlayPause:!0,canStop:!0,canSeek:!0,canSetVolume:!s.mobile,canSetAudioStream:!0,canSetSubtitleStream:!0,canSetQuality:!0,showSeekBar:!0,showPlayQueue:!0,showEnterFullscreen:n.hasFullscreen})},getPlayerDecision:function(t,n){this.backlog.clear();var s=this.populateItem(t);return s=s.then(e.bind(function(){var e=r.getCurrentQuality(t,u.getInstance());this.model.set("qualityIndex",e.index);
var i=o.getPlayerDecision({type:this.type,profile:this.profile,item:t,media:n.media,part:n.part,offset:n.offset,fallbackServer:f.get("primaryServer"),allowDirectPlay:u.get("directPlay"),allowAC3:u.get("allowAC3"),subtitlesBurnLevel:this.model.get("softSubtitlesFailed")?c.ALWAYS:u.get("subtitlesBurnLevel"),hasFlash:this.canPlayFlash(),hasNativeHLS:this.canPlayHLS(),useOffsetHLS:!1,hasDASH:this.canPlayDASH(),hasStreamingMKV:this.canPlayStreamingMKV(),minVersionForStreamingMKV:t.server.features.streamingMKV,quality:e,transcoder:d,transcoderOptions:{directStream:u.get("directStream")?1:0,subtitleSize:u.get("subtitleSize"),audioBoost:u.get("audioBoost")},profileExtra:u.get("preferAAC")?"add-transcode-target-audio-codec(type=videoProfile&context=streaming&protocol=hls&audioCodec=aac)":null});
return i.done(this.onDecisionSuccess),i.fail(this.onDecisionError),i},this),e.bind(function(){this.model.set({state:"error",errorMessage:i("Plex Media Server is not responding.")})},this))},getSubcontrollerByType:function(e){return"flash"===e?new m(this.type):new p(this.type)},canPlayFlash:function(){return t.hasFlashPlayerVersion("10")},canPlayHLS:function(){var e=this.profile.protocols;if(!e||!e.hls)return!1;var t=l.canPlayType("video",e.hls.mimeType),i="Android"===s.platform;return t||i},canPlayDASH:function(){var e=this.profile.directPlay;
if(!e.hasOwnProperty("mp4"))return!1;var t=l.canPlayType("video",e.mp4.mimeType);return u.get("dash")&&t&&n.hasMediaSource},canPlayStreamingMKV:function(){var e=this.profile.directPlay,t=l.canPlayType("video",e.mp4.mimeType);return u.get("dash")&&"chrome"===s.id&&!s.mobile&&t}});return g}),define("plex/desktop/adapters/player/DesktopMusicPlayerController",["underscore","plex/base/utils/t","plex/base/utils/BaseClass","plex/base/utils/dispatcher","plex/base/utils/browser","plex/base/utils/playerUtil","plex/base/utils/Backlog","plex/base/utils/mediaUtil","plex/base/utils/playerDecisionEngine","plex/desktop/utils/desktopTranscoder","plex/base/adapters/loggerAdapter","plex/base/adapters/playerProfileAdapter","plex/base/commands/commands","plex/base/mixins/eventMixin","plex/base/mixins/player/playerControllerMixin","plex/base/models/appModel"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f){"use strict";
var g=i.extend({mixins:[p,m],type:a.types.MUSIC,wrapped:["play","pause","playPause","setVolume","setPosition","whileLoading","whilePlaying"],modelDefaults:function(){var t=m.modelDefaults.apply(this,arguments);return e.extend(t,{canPlayPause:!0,canStop:!0,canSetVolume:!s.mobile,showSeekBar:!0,showPlayQueue:!0})},initialize:function(){m.initialize.apply(this,arguments),e.bindAll(this,"onDecisionSuccess","onDecisionError","onCreate","onLoad","onFinish"),this.profile=u.prop(this.type),this.backlog=new r,this.backlog.wrapAll(this.wrapped,function(){return!!this.sound
},this)},load:function(e){this.model=e.model,this.autoplay=e.autoplay;var t=this.model.get("item"),i=this.model.get("playQueue").get("collection");return this.reset(t),this.listenTo(this.model,"change:state",this.onStateChange),this.listenTo(i,"reset remove add sync",this.onPlayQueueChange),this.getPlayerDecision(t)},getPlayerDecision:function(e){this.errorTimeout&&(this.errorTimeout=clearTimeout(this.errorTimeout)),this.backlog.clear();var t=l.getPlayerDecision({profile:this.profile,type:this.type,item:e,fallbackServer:f.get("primaryServer"),transcoder:c});
return t.done(this.onDecisionSuccess),t.fail(this.onDecisionError),t},play:function(){this.model.set("state",a.states.PLAYING),this.sound.play()},pause:function(){this.model.set("state",a.states.PAUSED),this.sound.pause()},setPosition:function(e){this.canSeek(e)&&(this.model.set("position",e),this.sound.setPosition(e))},setVolume:function(e){this.model.set("volume",e),this.sound.setVolume(e)},skipPrevious:function(){var e=m.skipPrevious.apply(this,arguments);return e&&this.getPlayerDecision(e),e},skipNext:function(){var e=m.skipNext.apply(this,arguments);
return e&&this.getPlayerDecision(e),e},skipTo:function(){var e=m.skipTo.apply(this,arguments);return e&&this.getPlayerDecision(e),e},stop:function(){return m.stop.apply(this,arguments),this.sound=null,h.execute("playSound",{key:this.currentItem.get("key"),stop:!0}),this.stopSession()},onDecisionSuccess:function(e){var t=this.model.get("item"),i=0;e.part&&e.part.duration&&(i=e.part.duration),this.session=e.session,this.model.set({media:e.media,part:e.part,url:e.url,transcodeServer:e.transcodeServer,mediaIndex:e.media?o.getMediaIndex(t,e.media.id):0,partIndex:e.part?o.getPartIndex(e.media,e.part.key):0,partCount:o.getPartCount(e.media),state:this.autoplay?a.states.BUFFERING:a.states.PAUSED,position:e.offset,duration:i,directPlay:e.canDirectPlay,canSeek:e.canDirectPlay}),h.execute("playSound",{key:this.currentItem.get("key"),url:e.url,autoLoad:!0,autoPlay:this.autoplay,volume:this.model.get("volume"),oncreate:this.onCreate,onload:this.onLoad,whileloading:this.whileLoading,whileplaying:this.whilePlaying,onfinish:this.onFinish})
},onDecisionError:function(e){this.model.set("state",a.states.ERROR),n.trigger("stop:music"),e.errorMessage&&n.trigger("show:alert",{type:"error",message:t(e.errorMessage)})},onStateChange:function(t,i){var n=this.timeline();i===a.states.PLAYING&&n.done(e.bind(this.updatePlayQueue,this)),i===a.states.STOPPED||i===a.states.ERROR?this.stopTimeline():this.startTimeline(),i===a.states.PLAYING?this.startPlaybackTracking():this.stopPlaybackTracking(),i===a.states.ERROR&&(this.errorTimeout=setTimeout(e.bind(function(){d.warn("Track failed to play, automatically skipping to the next track"),n.done(e.bind(function(){this.model.get("error")&&this.skipNext()
},this))},this),2e3))},onPlayQueueChange:function(){this.previousItem=this.getPreviousItem(),this.nextItem=this.getNextItem(),this.model.set({canSkipPrevious:!!this.previousItem,canSkipNext:!!this.nextItem})},onCreate:function(e){this.sound=e,this.backlog.process(),this.model.set("ready",!0)},onLoad:function(e){if(!e)return void this.model.set("state",a.states.ERROR);var t=this.model.get("media"),i=this.model.get("directPlay");this.model.set("loaded",!0),!i&&t&&this.model.set({endBuffer:t.duration,canSeek:!0})
},whileLoading:function(){if(this.sound.url===this.model.get("url")){var e,t,i=this.model.get("media"),n=this.model.get("directPlay");if(!n&&i)e=i.duration,t=0;else{var s=!this.sound.isHTML5&&this.sound.bytesLoaded>=this.sound.bytesTotal,a=!i||!i.duration||s;e=a?this.sound.durationEstimate:i.duration,t=this.sound.bytesLoaded/this.sound.bytesTotal*e}this.model.set({endBuffer:t,duration:e})}},whilePlaying:function(){this.sound.url===this.model.get("url")&&(this.model.get("playing")||this.sound.paused||this.model.set("state",a.states.PLAYING),this.model.set("position",Math.round(this.sound.position)))
},onFinish:function(){this.sound=null,this.nextItem?this.skipNext():this.model.set({state:a.states.STOPPED,finished:!0})}});return g}),define("plex/desktop/adapters/desktopAdapters",["plex/desktop/adapters/baseDesktopAdapters","plex/base/adapters/storageAdapter","plex/base/adapters/webStorage","plex/base/adapters/dimensionsAdapter","plex/desktop/adapters/desktopDimensions","plex/base/adapters/analyticsAdapter","plex/base/adapters/analytics/GoogleAnalytics","plex/base/adapters/keyboardShortcutsAdapter","plex/desktop/adapters/DesktopKeyboardShortcuts","plex/base/adapters/playerProfileAdapter","plex/desktop/adapters/player/desktopPlayerProfile","plex/base/utils/playerUtil","plex/base/adapters/playerControllerAdapter","plex/desktop/adapters/player/DesktopVideoPlayerController","plex/desktop/adapters/player/DesktopMusicPlayerController"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f={registerAll:function(){t.register(i),n.register(s),a.register(r),o.register(new l),c.register(d),h.register({protocol:"local",type:u.types.VIDEO,create:function(e){return new p({type:e})}}),h.register({protocol:"local",type:u.types.MUSIC,create:function(e){return new m({type:e})}}),e.registerAll()}};return f}),define("hb!templates/desktop/partials/Setting",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"advanced-setting"}function r(e,t){var n,s,a,r="";return r+='\n    <label class="control-label" for="input_',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n),(n=i.idSuffix)?n=n.call(e,{hash:{},data:t}):(n=e&&e.idSuffix,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n)+'">\n      <input type="checkbox" id="input_',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n),(n=i.idSuffix)?n=n.call(e,{hash:{},data:t}):(n=e&&e.idSuffix,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n)+'" name="',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n)+'" value="1" ',n=i["if"].call(e,e&&e.value,{hash:{},inverse:C.noop,fn:C.program(4,o,t),data:t}),(n||0===n)&&(r+=n),r+="> ",a={hash:{},data:t},r+=k((n=i.t||e&&e.t,n?n.call(e,e&&e.label,a):x.call(e,"t",e&&e.label,a)))+"\n    </label>\n\n    ",s=i["if"].call(e,e&&e.summary,{hash:{},inverse:C.noop,fn:C.program(6,l,t),data:t}),(s||0===s)&&(r+=s),r+="\n  "
}function o(){return"checked"}function l(e,t){var n,s,a="";return a+='\n      <p class="help-block">',s={hash:{},data:t},a+=k((n=i.t||e&&e.t,n?n.call(e,e&&e.summary,s):x.call(e,"t",e&&e.summary,s)))+"</p>\n    "}function c(e,t){var n,s,a,r="";return r+='\n    <label class="control-label" for="input_',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n),(n=i.idSuffix)?n=n.call(e,{hash:{},data:t}):(n=e&&e.idSuffix,n=typeof n===S?n.call(e,{hash:{},data:t}):n),r+=k(n)+'">',a={hash:{},data:t},r+=k((n=i.t||e&&e.t,n?n.call(e,e&&e.label,a):x.call(e,"t",e&&e.label,a)))+"</label>\n\n    ",s=i["if"].call(e,e&&e.enumValues,{hash:{},inverse:C.program(13,p,t),fn:C.program(9,d,t),data:t}),(s||0===s)&&(r+=s),r+="\n\n    ",s=i["if"].call(e,e&&e.summary,{hash:{},inverse:C.noop,fn:C.program(6,l,t),data:t}),(s||0===s)&&(r+=s),r+="\n  "
}function d(e,t){var n,s="";return s+='\n      <select id="input_',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===S?n.call(e,{hash:{},data:t}):n),s+=k(n),(n=i.idSuffix)?n=n.call(e,{hash:{},data:t}):(n=e&&e.idSuffix,n=typeof n===S?n.call(e,{hash:{},data:t}):n),s+=k(n)+'" name="',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===S?n.call(e,{hash:{},data:t}):n),s+=k(n)+'">\n        ',n=i.each.call(e,e&&e.enumValues,{hash:{},inverse:C.noop,fn:C.programWithDepth(10,u,t,e),data:t}),(n||0===n)&&(s+=n),s+="\n      </select>\n    "
}function u(e,t,n){var s,a,r,o="";return o+='\n          <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===S?s.call(e,{hash:{},data:t}):s),o+=k(s)+'" ',r={hash:{},inverse:C.noop,fn:C.program(11,h,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,n&&n.value,r):x.call(e,"if_eq",e&&e.value,n&&n.value,r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=k((s=i.t||e&&e.t,s?s.call(e,e&&e.label,r):x.call(e,"t",e&&e.label,r)))+"</option>\n        "}function h(){return'selected="selected"'
}function p(e,t){var n,s,a,r="";return r+='\n      <input type="',a={hash:{},inverse:C.program(16,f,t),fn:C.program(14,m,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.option,"hidden",a):x.call(e,"if_eq",e&&e.option,"hidden",a),(s||0===s)&&(r+=s),r+='" id="input_',(s=i.id)?s=s.call(e,{hash:{},data:t}):(s=e&&e.id,s=typeof s===S?s.call(e,{hash:{},data:t}):s),r+=k(s),(s=i.idSuffix)?s=s.call(e,{hash:{},data:t}):(s=e&&e.idSuffix,s=typeof s===S?s.call(e,{hash:{},data:t}):s),r+=k(s)+'" class="form-control" name="',(s=i.id)?s=s.call(e,{hash:{},data:t}):(s=e&&e.id,s=typeof s===S?s.call(e,{hash:{},data:t}):s),r+=k(s)+'" value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===S?s.call(e,{hash:{},data:t}):s),r+=k(s)+'" ',s=i["if"].call(e,e&&e.placeholder,{hash:{},inverse:C.noop,fn:C.program(18,g,t),data:t}),(s||0===s)&&(r+=s),r+=">\n    "
}function m(){return"password"}function f(){return"text"}function g(e,t){var n,s="";return s+='placeholder="',(n=i.placeholder)?n=n.call(e,{hash:{},data:t}):(n=e&&e.placeholder,n=typeof n===S?n.call(e,{hash:{},data:t}):n),s+=k(n)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var v,y,b,w="",x=i.helperMissing,k=this.escapeExpression,S="function",C=this;return w+='<div class="form-group ',v=i["if"].call(t,t&&t.advanced,{hash:{},inverse:C.noop,fn:C.program(1,a,s),data:s}),(v||0===v)&&(w+=v),w+='">\n  ',b={hash:{},inverse:C.program(8,c,s),fn:C.program(3,r,s),data:s},v=i.if_eq||t&&t.if_eq,y=v?v.call(t,t&&t.type,"bool",b):x.call(t,"if_eq",t&&t.type,"bool",b),(y||0===y)&&(w+=y),w+="\n</div>\n"
})}),define("hb!templates/desktop/partials/LockableTagInput",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return" locked"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<div class="form-group">\n  <label for="lockable-',(r=i.name)?r=r.call(t,{hash:{},data:s}):(r=t&&t.name,r=typeof r===d?r.call(t,{hash:{},data:s}):r),c+=u(r)+'">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,t&&t.label,l):h.call(t,"t",t&&t.label,l)))+'</label>\n\n  <div class="input-group selectize-group">\n    <a href="#" data-field="',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" class="input-group-addon edit-lock-addon',o=i["if"].call(t,t&&t.locked,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='"><i class="glyphicon lock"></i></a>\n\n    <input type="text" id="lockable-',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" class="form-control lockable-field tag-input-hidden" data-name="',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'">\n  </div>\n</div>\n'
})}),define("hb!templates/desktop/partials/LockableTextInput",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return" locked"}function r(e,t){var n,s="";return s+='\n      <textarea class="form-control lockable-field" id="lockable-',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'" name="',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'"',n=i["if"].call(e,e&&e.rows,{hash:{},inverse:v.noop,fn:v.program(4,o,t),data:t}),(n||0===n)&&(s+=n),s+=' placeholder="',(n=i.placeholder)?n=n.call(e,{hash:{},data:t}):(n=e&&e.placeholder,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'">',(n=i.value)?n=n.call(e,{hash:{},data:t}):(n=e&&e.value,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+"</textarea>\n    "
}function o(e,t){var n,s="";return s+=' rows="',(n=i.rows)?n=n.call(e,{hash:{},data:t}):(n=e&&e.rows,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'"'}function l(e,t){var n,s="";return s+='\n      <input type="text" id="lockable-',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'" class="form-control lockable-field" name="',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'" value="',(n=i.value)?n=n.call(e,{hash:{},data:t}):(n=e&&e.value,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'" placeholder="',(n=i.placeholder)?n=n.call(e,{hash:{},data:t}):(n=e&&e.placeholder,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'" ',n=i["if"].call(e,e&&e.scopeToAttr,{hash:{},inverse:v.noop,fn:v.program(7,c,t),data:t}),(n||0===n)&&(s+=n),s+=" ",n=i["if"].call(e,e&&e.ratingKey,{hash:{},inverse:v.noop,fn:v.program(9,d,t),data:t}),(n||0===n)&&(s+=n),s+=">\n    "
}function c(e,t){var n,s="";return s+='data-scope-to-attr="',(n=i.scopeToAttr)?n=n.call(e,{hash:{},data:t}):(n=e&&e.scopeToAttr,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'" data-scope-to-param="',(n=i.scopeToParam)?n=n.call(e,{hash:{},data:t}):(n=e&&e.scopeToParam,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'"'}function d(e,t){var n,s="";return s+='data-rating-key="',(n=i.ratingKey)?n=n.call(e,{hash:{},data:t}):(n=e&&e.ratingKey,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=g(n)+'"'
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var u,h,p,m="",f="function",g=this.escapeExpression,v=this,y=i.helperMissing;return m+='<div class="form-group selectize-group">\n  <label for="lockable-',(u=i.name)?u=u.call(t,{hash:{},data:s}):(u=t&&t.name,u=typeof u===f?u.call(t,{hash:{},data:s}):u),m+=g(u)+'">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,t&&t.label,p):y.call(t,"t",t&&t.label,p)))+'</label>\n  <div class="input-group">\n    <a href="#" data-field="',(h=i.name)?h=h.call(t,{hash:{},data:s}):(h=t&&t.name,h=typeof h===f?h.call(t,{hash:{},data:s}):h),m+=g(h)+'" class="input-group-addon edit-lock-addon',h=i["if"].call(t,t&&t.locked,{hash:{},inverse:v.noop,fn:v.program(1,a,s),data:s}),(h||0===h)&&(m+=h),m+='" tabindex="-1"><i class="glyphicon lock"></i></a>\n    ',p={hash:{},inverse:v.program(6,l,s),fn:v.program(3,r,s),data:s},u=i.if_eq||t&&t.if_eq,h=u?u.call(t,t&&t.type,"textarea",p):y.call(t,"if_eq",t&&t.type,"textarea",p),(h||0===h)&&(m+=h),m+="\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/partials/LockableNumericInput",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"locked"}function r(){return"disabled"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u="function",h=this.escapeExpression,p=i.helperMissing,m=this;return d+='<div class="form-group">\n  <label for="lockable-',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===u?o.call(t,{hash:{},data:s}):o),d+=h(o)+'">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,t&&t.label,c):p.call(t,"t",t&&t.label,c)))+'</label>\n  <div class="input-group">\n    <a href="#" data-field="',(l=i.name)?l=l.call(t,{hash:{},data:s}):(l=t&&t.name,l=typeof l===u?l.call(t,{hash:{},data:s}):l),d+=h(l)+'" class="input-group-addon edit-lock-addon ',l=i["if"].call(t,t&&t.locked,{hash:{},inverse:m.noop,fn:m.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+=" ",l=i["if"].call(t,t&&t.disabled,{hash:{},inverse:m.noop,fn:m.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='" tabindex="-1"><i class="glyphicon lock"></i></a>\n    <input type="number" id="lockable-',(l=i.name)?l=l.call(t,{hash:{},data:s}):(l=t&&t.name,l=typeof l===u?l.call(t,{hash:{},data:s}):l),d+=h(l)+'" class="form-control lockable-field" name="',(l=i.name)?l=l.call(t,{hash:{},data:s}):(l=t&&t.name,l=typeof l===u?l.call(t,{hash:{},data:s}):l),d+=h(l)+'" value="',(l=i.value)?l=l.call(t,{hash:{},data:s}):(l=t&&t.value,l=typeof l===u?l.call(t,{hash:{},data:s}):l),d+=h(l)+'" placeholder="',(l=i.placeholder)?l=l.call(t,{hash:{},data:s}):(l=t&&t.placeholder,l=typeof l===u?l.call(t,{hash:{},data:s}):l),d+=h(l)+'" ',l=i["if"].call(t,t&&t.disabled,{hash:{},inverse:m.noop,fn:m.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+=">\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/partials/TextInput",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n    <textarea class="form-control text-field" id="text-',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" name="',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'"',n=i["if"].call(e,e&&e.rows,{hash:{},inverse:f.noop,fn:f.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+=' placeholder="',(n=i.placeholder)?n=n.call(e,{hash:{},data:t}):(n=e&&e.placeholder,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'">',(n=i.value)?n=n.call(e,{hash:{},data:t}):(n=e&&e.value,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</textarea>\n  "
}function r(e,t){var n,s="";return s+=' rows="',(n=i.rows)?n=n.call(e,{hash:{},data:t}):(n=e&&e.rows,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'"'}function o(e,t){var n,s="";return s+='\n    <input type="text" id="text-',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" class="form-control text-field" name="',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" value="',(n=i.value)?n=n.call(e,{hash:{},data:t}):(n=e&&e.value,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" placeholder="',(n=i.placeholder)?n=n.call(e,{hash:{},data:t}):(n=e&&e.placeholder,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" ',n=i["if"].call(e,e&&e.excludeParam,{hash:{},inverse:f.noop,fn:f.program(5,l,t),data:t}),(n||0===n)&&(s+=n),s+=">\n  "
}function l(e,t){var n,s="";return s+='data-exclude-param="',(n=i.excludeParam)?n=n.call(e,{hash:{},data:t}):(n=e&&e.excludeParam,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" data-exclude-value="',(n=i.excludeValue)?n=n.call(e,{hash:{},data:t}):(n=e&&e.excludeValue,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p="function",m=this.escapeExpression,f=this,g=i.helperMissing;return h+='<div class="form-group">\n  <label for="text-',(c=i.name)?c=c.call(t,{hash:{},data:s}):(c=t&&t.name,c=typeof c===p?c.call(t,{hash:{},data:s}):c),h+=m(c)+'">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,t&&t.label,u):g.call(t,"t",t&&t.label,u)))+"</label>\n  ",u={hash:{},inverse:f.program(4,o,s),fn:f.program(1,a,s),data:s},c=i.if_eq||t&&t.if_eq,d=c?c.call(t,t&&t.type,"textarea",u):g.call(t,"if_eq",t&&t.type,"textarea",u),(d||0===d)&&(h+=d),h+="\n</div>\n"
})}),define("hb!templates/desktop/partials/AutocompleteTextInput",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='data-scope-to-attr="',(n=i.scopeToAttr)?n=n.call(e,{hash:{},data:t}):(n=e&&e.scopeToAttr,n=typeof n===d?n.call(e,{hash:{},data:t}):n),s+=u(n)+'" data-scope-to-param="',(n=i.scopeToParam)?n=n.call(e,{hash:{},data:t}):(n=e&&e.scopeToParam,n=typeof n===d?n.call(e,{hash:{},data:t}):n),s+=u(n)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<div class="form-group" data-attr="',(r=i.name)?r=r.call(t,{hash:{},data:s}):(r=t&&t.name,r=typeof r===d?r.call(t,{hash:{},data:s}):r),c+=u(r)+'">\n  <label for="text-',(r=i.name)?r=r.call(t,{hash:{},data:s}):(r=t&&t.name,r=typeof r===d?r.call(t,{hash:{},data:s}):r),c+=u(r)+'" class="control-label">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,t&&t.label,l):h.call(t,"t",t&&t.label,l)))+'<span class="control-error"></span></label>\n  <div class="input-group selectize-group">\n    <input type="text" id="text-',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" class="form-control text-field" name="',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" placeholder="',(o=i.placeholder)?o=o.call(t,{hash:{},data:s}):(o=t&&t.placeholder,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" data-rating-key="',(o=i.ratingKey)?o=o.call(t,{hash:{},data:s}):(o=t&&t.ratingKey,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" data-title="',(o=i.title)?o=o.call(t,{hash:{},data:s}):(o=t&&t.title,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" ',o=i["if"].call(t,t&&t.scopeToAttr,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+=">\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/partials/ConnectError",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <h4 class="server-connect-error-header">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"Problem Connecting to Plex",s):m.call(e,"t","Problem Connecting to Plex",s)))+'</h4>\n  <p class="text-muted">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"Plex was unable to authenticate your server. Please sign your server out and try again.",s):m.call(e,"t","Plex was unable to authenticate your server. Please sign your server out and try again.",s)))+"</p>\n"
}function r(e,t){var n,s,a,r="";return a={hash:{},inverse:g.program(6,l,t),fn:g.program(4,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.mappingError,"myplexgone",a):m.call(e,"if_eq",e&&e.mappingError,"myplexgone",a),(s||0===s)&&(r+=s),r+="\n"}function o(e,t){var n,s,a="";return a+='\n  <h4 class="server-connect-error-header">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"Problem Connecting to Plex",s):m.call(e,"t","Problem Connecting to Plex",s)))+'</h4>\n  <p class="text-muted">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"Your server was unable to reach Plex. Please ensure that the computer or device running your server can access the internet.",s):m.call(e,"t","Your server was unable to reach Plex. Please ensure that the computer or device running your server can access the internet.",s)))+"</p>\n"
}function l(e,t){var n,s,a="";return a+='\n  <h4 class="server-connect-error-header">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"Signed in to Plex",s):m.call(e,"t","Signed in to Plex",s)))+'</h4>\n  <p class="text-muted">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"You have successfully signed your server in to Plex, but we were unable to reach it from outside your network.",s):m.call(e,"t","You have successfully signed your server in to Plex, but we were unable to reach it from outside your network.",s)))+"</p>\n"
}function c(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"If you skip this step you will not be able to share or stream media outside your home. If you change your mind later, you can adjust this in Settings.",s):m.call(e,"t","If you skip this step you will not be able to share or stream media outside your home. If you change your mind later, you can adjust this in Settings.",s)))+"</p>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var d,u,h,p="",m=i.helperMissing,f=this.escapeExpression,g=this;return h={hash:{},inverse:g.program(3,r,s),fn:g.program(1,a,s),data:s},d=i.if_eq||t&&t.if_eq,u=d?d.call(t,t&&t.mappingError,"badauth",h):m.call(t,"if_eq",t&&t.mappingError,"badauth",h),(u||0===u)&&(p+=u),p+="\n\n",h={hash:{},inverse:g.noop,fn:g.program(8,c,s),data:s},d=i.if_neq||t&&t.if_neq,u=d?d.call(t,t&&t.context,"settings",h):m.call(t,"if_neq",t&&t.context,"settings",h),(u||0===u)&&(p+=u),p+='\n\n<p class="text-muted">',h={hash:{},data:s},p+=f((d=i.t||t&&t.t,d?d.call(t,"If you would like to enable this now, you will need to configure your router or firewall to allow Plex to contact your server. Please refer to our {1}Connecting a Server{2} article for more information.","<a href='http://support.plex.tv/hc/en-us/articles/200484543-Connecting-a-Server' target='_blank'>","</a>",h):m.call(t,"t","If you would like to enable this now, you will need to configure your router or firewall to allow Plex to contact your server. Please refer to our {1}Connecting a Server{2} article for more information.","<a href='http://support.plex.tv/hc/en-us/articles/200484543-Connecting-a-Server' target='_blank'>","</a>",h)))+"</p>\n"
})}),define("hb!templates/desktop/partials/Terms",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<p>\n  Thank you for using Plex!  By accessing, using, downloading, or visiting any Plex \u201cService(s)\u201d, which includes the Plex website, Plex software and products described <a href="https://plex.tv/downloads" target="_blank">here</a>, and any other products or materials provided by Plex, you agree to the terms (\u201cTerms\u201d) listed in this agreement (\u201cAgreement\u201d). Plex reserves the right to amend these Terms at any time and without notice. Any revisions to the Terms will be posted on the Plex website. By continuing to access or use the Services, you accept any changes or revisions to the Terms. Plex reserves the right to amend these Terms at any time and without notice. Any revisions to the Terms will be posted on the Plex website. By continuing to access or use the Services, you accept any changes or revisions to the Terms.\n</p>\n\n<h4>Plex Software</h4>\n<ol>\n  <li>Plex gives you a personal, worldwide, royalty-free, revocable, non-transferable, non-sublicensable, and non-exclusive license to use the software provided to you by Plex as part of the Services (\u201cSoftware\u201d). This license is for the sole purpose of enabling you to use and enjoy the benefit of the Services in the manner permitted by these Terms.</li>\n  <li>The Software includes certain executable modules that Plex has licensed from third party providers (\u201cThird Party Components\u201d) that may be subject to different end user license terms as specified in the license agreement(s) provided with such Third Party Components.</li>\n  <li>You may not, or allow anyone else to, directly or indirectly to: (1) copy, modify, distribute, sell, or lease any part of the Software; (2) reverse engineer, disassemble, decompile, or otherwise attempt to discover the source code or structure, sequence, and/or organization of all or any part of the Software, unless laws prohibit those restrictions or you have our written permission; (3) rent, lease, or use the Software for timesharing or service bureau purposes; (4) develop any improvement, modification, or derivative works of the Software, or include any portion thereof in any other product, software, work, equipment, or item (except that you may customize and/or modify the Software only as set forth in the documentation or as authorized in any license agreement of Plex\u2019s third party licensors and applicable to Third Party Components); or (5) allow the transfer, transmission, export, or re-export of the Software or any portion thereof or any technical data associated with any Software.</li>\n  <li>You shall not incorporate any of Plex\u2019s Software or any part thereof into any other product(s) or use the proprietary software in any manner that would cause the proprietary software to become subject to any \u201copen source license\u201d that would impose obligations on Plex\u2019s use of the proprietary software or impair any rights of Plex or third parties thereto.</li>\n  <li>You shall maintain and shall not remove nor obscure any proprietary notices on the Software, and shall reproduce such notices exactly on all permitted copies of the Software.</li>\n  <li>You may reverse engineer the Software solely (1) as permitted by applicable law, or (2) for the purpose of debugging modifications made by you to certain third party files in source code format that are licensed under the GNU Lesser General Public License (LGPL) or under the GNU General Public License diversion 2 (GPL2) and only provided that you have made, prior to any such reverse engineering permitted under this sentence, unsuccessful prior reasonable good faith efforts to debug such modifications using techniques other than the reverse engineering of the Software.</li>\n  <li>As between the parties and except as otherwise provided in any license agreement for Third Party Components, Plex shall own all title, ownership rights, and intellectual property rights in and to the Software, and any copies or derivative works thereof, except that by downloading the Software, you retain any title that you may own in and to the recording media on which the Software is recorded.</li>\n  <li>You understand that Plex or its licensors may modify or discontinue offering the Services at any time.</li>\n  <li>You shall not make, or assist others in making, any use of data adapters or similar technologies used by or with the Services that are designed to receive and use data from Plex, its third party data providers, and their affiliates and third parties, other than to receive and use such data in accordance with these Terms and your agreement with the third party data providers, and their affiliates and third parties, including without limitation any data passing through the Services or otherwise effectively made available by any Service through an API, a download, a database, or the like.</li>\n  <li>This Agreement does not entitle you to any support, upgrades, patches, enhancements, or \ufb01xes (collectively, "Support") for the Services. Any such Support for the Services that may be made available by Plex, in its sole discretion, shall become part of the Services and will be subject to these Terms.</li>\n</ol>\n\n<h4>Data</h4>\n<p>\n  Data provided by Plex or other third party data providers may be delayed or unavailable as specified by Plex or such third party data providers. Plex does not verify any data provided by Plex or other third party data providers and disclaims any obligation to do so. Plex, its third party data providers, and each of their affiliates and business partners: (1) expressly disclaim the availability, accuracy, adequacy, or completeness of any data or third party data provider, and (2) shall not be liable for any errors, omissions, or other defects in, unavailability of, delays or interruptions in such data or third party data provider.\n</p>\n\n<h4>Acceptable Use</h4>\n<ol>\n  <li>\n    You may not, or allow anyone else to, use any of the Services to do the following:\n    <ol>\n      <li>Infringe the intellectual property rights, proprietary rights, or rights of publicity or privacy of any third party;</li>\n      <li>Violate any law, statute, ordinance, or regulation, or perform any other action that would incur civil liability or constitute a crime;</li>\n      <li>Disseminate, transfer or store information or materials in any form or format that is harmful, threatening, abusive, harassing, tortuous, defamatory, vulgar, obscene, libelous, or otherwise objectionable, or that otherwise violate any law or right of any third party; or</li>\n      <li>Disseminate any software viruses or any other computer code, files, programs, or the like that may without limitation interrupt, destroy, or limit the functionality of any computer software or hardware or telecommunications equipment, violate the security of any computer network, or the like.</li>\n    </ol>\n  </li>\n  <li>If the occurrence of any prohibited use comes to our attention, we reserve the right to disable any accounts associated with prohibited use or otherwise terminate your access to the Services.</li>\n</ol>\n\n<h4>Your Content</h4>\n<ol>\n  <li>You continue to retain any ownership rights you have in content you make available via the Services, or otherwise use in conjunction with the Services. However, by using the Services with particular content, for example by using the Services to share particular content or access particular content, you grant to Plex (and to each of the third parties with whom we work to provide you with the Services) a worldwide license to reproduce, modify, create derivative works, transmit, publish, publicly perform, publicly display, distribute, and otherwise use the particular content and metadata associated with the content, such as poster images. The rights you grant us in this license are only for the limited purpose of providing you with our Services. You may not use the Services in connection with any content for which you do not have the right to grant us this license.</li>\n  <li>The Services may include features that allow you to share your content with others. Please be careful when choosing to share content with other users; Plex is not responsible for how others use your content. Additionally, you hereby grant to any user with whom you share content a non-exclusive license to access the content through the Service, and to use, reproduce in copies, distribute, display and perform the shared content as permitted through the functionality of the Service and under this Agreement.\xa0You may not share any content with others via the Services if you do not have the right to grant this license to any user with whom you share the content.</li>\n  <li>You understand that all content imported, published, shared, transmitted, or otherwise made available via the Services is the sole responsibility of the person from whom such content originated, and that you, and not Plex, are solely responsible for any civil or criminal legal liability that may arise or result from any content that you import, publish, share, transmit, or otherwise make available through your use of the Services.</li>\n</ol>\n\n<h4>Content of Others</h4>\n<ol>\n  <li>You acknowledge that all content that you access through use of the Software or other Services is accessed at your own risk, and you will be solely responsible for any damage or liability to any party resulting from such access.</li>\n  <li>You understand that by using the Services you may encounter content that you may find offensive, indecent, or objectionable. Plex does not inspect, screen, or otherwise control the content that is posted, shared or made available via the Services, and Plex does not guarantee the accuracy, integrity or quality of such content.</li>\n  <li>You acknowledge that unauthorized use of copyrighted content of others may subject you to civil and criminal penalties, including possible monetary damages, for copyright infringement.</li>\n</ol>\n\n<h4>Developers and Interfacing Software</h4>\n<ol>\n  <li>"Interfacing Software" means any software that you obtain or provide and that accesses or calls any Software provided by Plex as part of the Services including, but not limited to, plug-ins for the Services, channel plug-ins, metadata agents, and client applications that communicate directly or indirectly with the Services.</li>\n  <li>\n    By making, or assisting others in making, Interfacing Software, you agree to the following terms:\n    <ol>\n      <li>You grant Plex and its affiliates worldwide a worldwide, non-exclusive, and royalty-free right and license to use (including testing, hosting and linking to), copy, publicly perform, publicly display, reproduce in copies for distribution, and distribute the copies of any Interfacing Software made by you or with your assistance.</li>\n      <li>\n        You may notify us at legal@plex.tv if you do not wish for Plex to use, distribute, copy, publicly perform, publicly display, reproduce in copies for distribution, or distribute copies of any Interfacing Software that was created by you. Plex will comply with such a request but Plex must be granted a transition period of thirty (30) days after receipt of the request to comply. A request to take down Interfacing Software must include (1) an identification of the Interfacing Software you wish to be removed; (2) your signature in either electronic or physical form; and (3) the following statements:\n        <ul>\n          <li>"I swear under penalty of perjury that I am the owner of the Interfacing Software or I am authorized to act on behalf of the owner of the Interfacing Software.\u201d</li>\n          <li>"I swear under penalty of perjury that the information in this notification is accurate.\u201d</li>\n        </ul>\n      </li>\n      <li>You shall protect the privacy and legal rights of Plex users. If the users provide, or the Interfacing Software accesses or uses, user names, passwords, or other login information or personal information, you must make the users aware that such information will be available to the Interfacing Software, and you must provide privacy notices and protection for those users in compliance with applicable law. Further, the Interfacing Software may use that information only for the limited purposes for which the user has given you permission to do so. If the Interfacing Software stores personally identifying information of users or information that a reasonable user would consider to be sensitive, then the Interfacing Software must do so securely and only for as long as it is needed. However, if the user has opted or entered into a separate agreement with you that allows you or the Interfacing Software to store or use personally identifying information of users or information that a reasonable user would consider to be sensitive, then the terms of that separate agreement will govern your use of such information. If the user provides the Interfacing Software with Plex account information, the Interfacing Software may only use that information to access the user\u2019s Plex account when, and for the limited purposes for which, the user has given you permission to do so.</li>\n      <li>\n        Prohibited Uses. Plex prohibits performing certain actions using the Interfacing Software. You shall not make, or assist others in making, any Interfacing Software that:\n        <ol>\n          <li>Knowingly violates a third party\u2019s terms of service;</li>\n          <li>Violates any applicable laws or regulations;</li>\n          <li>Interferes with, disrupts, damages, harms, or accesses in an unauthorized manner the machines, hardware. devices, servers, networks, data, or other properties or services of any other party including, but not limited to, Plex users, Plex or any network operator;</li>\n          <li>Posts misleading information about an application\u2019s purpose;</li>\n          <li>Infringes on the intellectual property rights of others; or</li>\n          <li>Performs any other prohibited action listed under \u201cAcceptable Use\u201d above.</li>\n        </ol>\n      </li>\n      <li>You will require your end users to comply with any applicable law and these Terms. You will not knowingly enable your end users to violate applicable law or these Terms.</li>\n      <li>You shall indemnify and hold harmless Plex and its officers, directors, employees, contractors, licensors, suppliers, distributors, contractors, agents, and third party contributors from any claims, damages, liabilities, costs and fees (including reasonable attorney fees) arising from any use of the Interfacing Software or from Plex\u2019s distribution of the Interfacing Software.</li>\n      <li>Brand Features and Attribution\n        <ol>\n          <li>"Brand Features" is defined as the trade names, trademarks, service marks, logos, domain names, and other distinctive brand features of a party. Except where expressly stated, these terms do not grant either party any right, title, or interest in or to the other party\'s Brand Features. Any use by you of\xa0Plex\u2019s Brand Features (including any goodwill associated therewith) will inure to the benefit of\xa0Plex. Plex Brand Features include the Plex Play Logo (\u201c>\u201d in stylized format) and the trademarks, trade names and designs as may be identified from time to time in the Plex Trademark Notice that is posted at <a href="https://plex.tv/legal" target="_blank">www.plex.tv/legal</a>.</li>\n          <li>You must seek prior written approval from Plex to display\xa0Plex\'s Brand Features, including for the purpose of promoting or advertising that your Interfacing Software is for use in conjunction with Plex Services. Plex, in its sole discretion and in a separate writing such as an e-mail from an authorized representative of Plex, may grant you a revocable, non-transferable, nonexclusive license, without right of sub-license, to display\xa0Plex\'s Brand Features for the purpose of promoting or advertising that your Interfacing Software is for use in conjunction with Plex Services. You understand and agree that Plex\xa0has the sole discretion to determine whether your attribution(s) and use of\xa0Plex\'s Brand Features are in accordance with the above requirements and guidelines and that Plex may revoke the license granted herein at any time, or may require you to modify your use of Plex\u2019s Brand Features, for any reason in its sole discretion.</li>\n          <li>You will not make any statement that suggests a partnership with, sponsorship by, or endorsement by\xa0Plex,\xa0without\xa0Plex\'s express prior written approval.</li>\n          <li>In the course of promoting, marketing, or demonstrating the Services, Plex\xa0may produce and distribute incidental depictions, including screenshots, video, or other content from your Interfacing Software, and may use your company or product name. You grant\xa0us\xa0all necessary rights for the above purposes.</li>\n        </ol>\n      </li>\n    </ol>\n  </li>\n</ol>\n\n<h4>Children</h4>\n<p>\n  While Plex does distribute products that may be used by children, the Services are not intended to be used by children, without involvement, supervision, and approval of a parent or legal guardian.\xa0Therefore, if an account owner sets parental controls or establishes sub-accounts that the account owner intends to permit a child to use, the account owner should not reveal the account password to the child.\xa0Plex and its contributors may not provide controls that restrict the maturity level of content available via Plex and an adult account owner has sole responsibility for determining what maturity level is appropriate for or accessible to any children whom the account owner permits to use the Plex service or a sub-account.\n</p>\n\n<h4>NO WARRANTY</h4>\n<ol>\n  <li>PLEX SERVICES ARE PROVIDED "AS IS". PLEX MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, AND PLEX EXPRESSLY DISCLAIMS ALL WARRANTIES WITH RESPECT TO THE PLEX SERVICES, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. FURTHER, PLEX DOES NOT WARRANT AGAINST ERRORS, OMISSIONS, RESULTS OF USE, OR THAT PLEX SERVICES ARE BUG FREE OR ERROR FREE OR THAT USE WILL BE UNINTERRUPTED. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THE AGREEMENT. ALL THE FOREGOING DISCLAIMERS ALSO APPLY IN\xa0FULL WITH RESPECT TO PLEX\'S LICENSORS, SUPPLIERS, DISTRIBUTORS, CONTRACTORS, AGENTS, AND THIRD PARTY CONTRIBUTORS. SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU.</li>\n  <li>You agree that Plex and its officers, directors, employees, and contractors are not responsible for any fault, inaccuracy, error, omission, delay or any other failure of your equipment and/or services caused by Plex\u2019s hardware, software, cabling, network services, or the like, or arising from Plex\u2019s use of such equipment and/or services.</li>\n  <li>The above disclaimer of warranty applies to software developed by Plex and any software developed by a third party and provided by Plex including, but not limited to, Interfacing Software developed by any Plex user.</li>\n</ol>\n\n<h4>Limitation of Liability and Damages</h4>\n<ol>\n  <li>UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, INCLUDING, BUT NOT LIMITED TO, TORT, CONTRACT, NEGLIGENCE, STRICT LIABILITY, OR OTHERWISE, SHALL PLEX BE LIABLE TO YOU OR ANY OTHER PERSON OR ENTITY: (I) FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, ACCURACY OF RESULTS, COMPUTER FAILURE OR MALFUNCTION, LOSS OF DATA, OR OTHER DAMAGES RESULTING FROM YOUR USE OF THE SOFTWARE; OR (II) FOR ANY MATTER BEYOND ITS REASONABLE CONTROL. PLEX\'S AGGREGATE LIABILITY FOR DAMAGES OF ANY KIND WHATSOEVER ARISING OUT OF THIS AGREEMENT SHALL BE LIMITED TO THE LESSER OF THE TOTAL FEES PAID BY YOU TO PLEX (IF ANY) FOR THE PORTION OF THE SOFTWARE THAT GAVE RISE TO SUCH DAMAGES OR $100 (U.S.), EXCEPT WHERE NOT PERMITTED BY APPLICABLE LAW, IN WHICH CASE PLEX\'S LIABILITY SHALL BE LIMITED TO THE MINIMUM AMOUNT PERMITTED BY SUCH APPLICABLE LAW. ALL THE FOREGOING LIMITATIONS SHALL APPLY EVEN IF EITHER PARTY HAS BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. ALL THE FOREGOING LIMITATIONS ALSO APPLY WITH RESPECT TO PLEX\'S SUPPLIERS, LICENSORS, DISTRIBUTORS, CONTRACTORS, AGENTS, AND THIRD PARTY CONTRIBUTORS. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATION AND EXCLUSION MAY NOT APPLY TO YOU.</li>\n  <li>The above limitations and exclusions apply to software developed by Plex and any software developed by a third party and provided by Plex including, but not limited to, Interfacing Software developed by Plex user.</li>\n</ol>\n\n<h4>Third-Party Materials</h4>\n<p>\n  This website and other Services may provide links to websites, software, or other materials provided by third parties.  Plex does not endorse and is not responsible or liable for the availability, accuracy, safety, or intellectual property rights of or relating to such content. Plex is not liable for any harm caused by any such materials.\n</p>\n\n<h4>Malware</h4>\n<p>\n  "Malware" means any known, discovered, envisioned, or invented, or any yet to be known, discovered, envisioned, or invented: (i) virus, Trojan horse, or any other harmful, harassing, or malicious software; or (ii) method, use, or means by which any software, firmware, equipment, device, communications medium, person, entity, or the like directly or indirectly engages in or is used for: (a) any unauthorized access; (b) any unauthorized communication; or (c) any cracks, hacks, exploits, or other activity, method, use, or means, that may cause harassment, harm, data loss, data theft, loss of communication, loss of privacy, or the like. You acknowledge that the Internet, Internet service providers, shared or dedicated telecommunication lines, wireless access points and wireless networks, other forms of communication, online resources including websites and cloud computing environments, or other means that you use to connect to the Software may not be secure and may be vulnerable to attack by third parties, and that it is possible to receive Malware by using the Internet, dedicated lines, other forms of communication, or other means. In order to protect the Software, you shall regularly obtain, use, and update appropriate third party software or other means to protect yourself from Malware and to detect and remove Malware that may be downloaded using the Internet, dedicated lines, other forms of communication, or other means. Plex does not warrant that the Software will be free of Malware including, but not limited to, Malware that is introduced by third parties, the Internet, dedicated lines, other forms of communication, or other means.\n</p>\n\n<h4>Waiver and Indemnity</h4>\n<p>\n  You agree that Plex and its licensors, distributors, contractors, agents, and third party contributors shall have no liability whatsoever for any use you make of the Services. You shall indemnify and hold harmless Plex and its licensors, suppliers, distributors, contractors, agents, and third party contributors from any claims, damages, liabilities, costs and fees (including reasonable attorney fees) arising from your use of the Plex Services as well as from your failure to comply with any of the Terms, or any losses, damages, claims, costs, and/or attorneys\u2019 fees arising from any use of or reliance upon any information received in connection with the Services that comprises or is based upon data provided by Plex or any third party.\n</p>\n\n<h4>Termination of Services</h4>\n<p>\n  Plex may at any time, with or without cause and with or without prior notice, immediately terminate or suspend your Plex account or otherwise terminate or suspend your access to all or a portion of the Services. Cause for such termination may include: (a) violations of the Terms or any other policies or guidelines that are referenced herein; (b) a request by you to cancel or terminate your account; (c) a request and/or order from law enforcement, a judicial body, or other government agency; (d) where providing the Services to you is or may become unlawful; or (e) unexpected technical or security issues or problems; (f) your participation in fraudulent or illegal activities. Any such termination or suspension shall be made by Plex in its sole discretion and Plex will not be responsible to you or any third party for any damages that may result or arise out of such termination or suspension of your access to the Services.\n</p>\n\n<h4>Miscellaneous</h4>\n<ol>\n  <li>This Agreement does not give you any rights not expressly and unambiguously granted herein.</li>\n  <li>No agency, partnership, joint venture, or employment is created as a result of this Agreement and you do not have any authority of any kind to bind Plex in any respect whatsoever.</li>\n  <li>If any provision of this Agreement is found to be unenforceable or invalid, that provision shall be limited or eliminated to the minimum extent necessary so that this Agreement shall otherwise remain in full force and effect and enforceable.</li>\n  <li>This Agreement is not assignable, transferable, or sublicensable by you except with Plex\'s prior written consent. Plex may transfer, assign, or delegate this Agreement and its rights and obligations without consent.</li>\n  <li>Plex\'s failure to enforce any right or provisions in this Agreement will not constitute a waiver of such or any other provision.</li>\n  <li>This Agreement shall be governed by and construed in accordance with the laws of the state of California, as if made within California between two residents thereof, and the parties submit to the exclusive jurisdiction of the Superior Court of Santa Clara County and the United States District Court for the Northern District of California. Notwithstanding the foregoing sentence, but without limiting Plex\'s right to seek injunctive or other equitable relief in any court of competent jurisdiction, any disputes arising with respect to this Agreement shall be referred to an arbitrator affiliated with the Judicial Arbitration and Mediation Services, Inc. ("JAMS"). The arbitrator shall be selected by joint agreement of the parties. In the event the parties cannot agree on an arbitrator within thirty (30) days of the initiating party providing the other party with written notice that it plans to seek arbitration, the parties shall each select an arbitrator affiliated with JAMS, which arbitrators shall jointly select a third such arbitrator to resolve the dispute. The written decision of the arbitrator shall be final and binding on the parties. The arbitration proceeding shall be carried on and heard in Santa Clara County, California using the English language and pursuant to the rules of (and administered by) JAMS. In any action or proceeding to enforce rights under this Agreement, the prevailing party will be entitled to recover costs and reasonable attorneys\' fees from the other party. A separate written license agreement or order and signed by Plex and you or your company, employer, or principal may state other terms and conditions that apply to you, including terms relating to price, payment, delivery, confidential information, support services, and the like. You are solely responsible to review such terms or conditions with your company, employer or principal. In the event of any conflict in terms, the terms of the separate license agreement shall supersede the terms of this Agreement.</li>\n  <li>Both parties agree that this Agreement is the complete and exclusive statement of the mutual understanding of the parties and supersedes and cancels all previous written and oral agreements, communications, and other understandings relating to the subject matter of this Agreement.</li>\n</ol>\n'
})}),define("plex/desktop/initializers/configs/desktopPartials",["hb!templates/desktop/partials/Setting.tpl","hb!templates/desktop/partials/LockableTagInput.tpl","hb!templates/desktop/partials/LockableTextInput.tpl","hb!templates/desktop/partials/LockableNumericInput.tpl","hb!templates/desktop/partials/TextInput.tpl","hb!templates/desktop/partials/AutocompleteTextInput.tpl","hb!templates/desktop/partials/ConnectError.tpl","hb!templates/desktop/partials/Terms.tpl","handlebars"],function(e,t,i,n,s,a,r,o,l){"use strict";
l.registerPartial("setting",e),l.registerPartial("lockableTagInput",t),l.registerPartial("lockableTextInput",i),l.registerPartial("lockableNumericInput",n),l.registerPartial("textInput",s),l.registerPartial("autocompleteTextInput",a),l.registerPartial("connectError",r),l.registerPartial("terms",o)}),FastClick.prototype.deviceIsAndroid=navigator.userAgent.indexOf("Android")>0,FastClick.prototype.deviceIsIOS=/iP(ad|hone|od)/.test(navigator.userAgent),FastClick.prototype.deviceIsIOS4=FastClick.prototype.deviceIsIOS&&/OS 4_\d(_\d)?/.test(navigator.userAgent),FastClick.prototype.deviceIsIOSWithBadTarget=FastClick.prototype.deviceIsIOS&&/OS ([6-9]|\d{2})_\d/.test(navigator.userAgent),FastClick.prototype.needsClick=function(e){"use strict";
switch(e.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(e.disabled)return!0;break;case"input":if(this.deviceIsIOS&&"file"===e.type||e.disabled)return!0;break;case"label":case"video":return!0}return/\bneedsclick\b/.test(e.className)},FastClick.prototype.needsFocus=function(e){"use strict";switch(e.nodeName.toLowerCase()){case"textarea":return!0;case"select":return!this.deviceIsAndroid;case"input":switch(e.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1
}return!e.disabled&&!e.readOnly;default:return/\bneedsfocus\b/.test(e.className)}},FastClick.prototype.sendClick=function(e,t){"use strict";var i,n;document.activeElement&&document.activeElement!==e&&document.activeElement.blur(),n=t.changedTouches[0],i=document.createEvent("MouseEvents"),i.initMouseEvent(this.determineEventType(e),!0,!0,window,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),i.forwardedTouchEvent=!0,e.dispatchEvent(i)},FastClick.prototype.determineEventType=function(e){"use strict";
return this.deviceIsAndroid&&"select"===e.tagName.toLowerCase()?"mousedown":"click"},FastClick.prototype.focus=function(e){"use strict";var t;this.deviceIsIOS&&e.setSelectionRange&&0!==e.type.indexOf("date")&&"time"!==e.type?(t=e.value.length,e.setSelectionRange(t,t)):e.focus()},FastClick.prototype.updateScrollParent=function(e){"use strict";var t,i;if(t=e.fastClickScrollParent,!t||!t.contains(e)){i=e;do{if(i.scrollHeight>i.offsetHeight){t=i,e.fastClickScrollParent=i;break}i=i.parentElement}while(i)
}t&&(t.fastClickLastScrollTop=t.scrollTop)},FastClick.prototype.getTargetElementFromEventTarget=function(e){"use strict";return e.nodeType===Node.TEXT_NODE?e.parentNode:e},FastClick.prototype.onTouchStart=function(e){"use strict";var t,i,n;if(e.targetTouches.length>1)return!0;if(t=this.getTargetElementFromEventTarget(e.target),i=e.targetTouches[0],this.deviceIsIOS){if(n=window.getSelection(),n.rangeCount&&!n.isCollapsed)return!0;if(!this.deviceIsIOS4){if(i.identifier===this.lastTouchIdentifier)return e.preventDefault(),!1;
this.lastTouchIdentifier=i.identifier,this.updateScrollParent(t)}}return this.trackingClick=!0,this.trackingClickStart=e.timeStamp,this.targetElement=t,this.touchStartX=i.pageX,this.touchStartY=i.pageY,e.timeStamp-this.lastClickTime<200&&e.preventDefault(),!0},FastClick.prototype.touchHasMoved=function(e){"use strict";var t=e.changedTouches[0],i=this.touchBoundary;return Math.abs(t.pageX-this.touchStartX)>i||Math.abs(t.pageY-this.touchStartY)>i?!0:!1},FastClick.prototype.onTouchMove=function(e){"use strict";
return this.trackingClick?((this.targetElement!==this.getTargetElementFromEventTarget(e.target)||this.touchHasMoved(e))&&(this.trackingClick=!1,this.targetElement=null),!0):!0},FastClick.prototype.findControl=function(e){"use strict";return void 0!==e.control?e.control:e.htmlFor?document.getElementById(e.htmlFor):e.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")},FastClick.prototype.onTouchEnd=function(e){"use strict";var t,i,n,s,a,r=this.targetElement;
if(!this.trackingClick)return!0;if(e.timeStamp-this.lastClickTime<200)return this.cancelNextClick=!0,!0;if(this.cancelNextClick=!1,this.lastClickTime=e.timeStamp,i=this.trackingClickStart,this.trackingClick=!1,this.trackingClickStart=0,this.deviceIsIOSWithBadTarget&&(a=e.changedTouches[0],r=document.elementFromPoint(a.pageX-window.pageXOffset,a.pageY-window.pageYOffset)||r,r.fastClickScrollParent=this.targetElement.fastClickScrollParent),n=r.tagName.toLowerCase(),"label"===n){if(t=this.findControl(r)){if(this.focus(r),this.deviceIsAndroid)return!1;
r=t}}else if(this.needsFocus(r))return e.timeStamp-i>100||this.deviceIsIOS&&window.top!==window&&"input"===n?(this.targetElement=null,!1):(this.focus(r),this.deviceIsIOS4&&"select"===n||(this.targetElement=null,e.preventDefault()),!1);return this.deviceIsIOS&&!this.deviceIsIOS4&&(s=r.fastClickScrollParent,s&&s.fastClickLastScrollTop!==s.scrollTop)?!0:(this.needsClick(r)||(e.preventDefault(),this.sendClick(r,e)),!1)},FastClick.prototype.onTouchCancel=function(){"use strict";this.trackingClick=!1,this.targetElement=null
},FastClick.prototype.onMouse=function(e){"use strict";return this.targetElement?e.forwardedTouchEvent?!0:e.cancelable&&(!this.needsClick(this.targetElement)||this.cancelNextClick)?(e.stopImmediatePropagation?e.stopImmediatePropagation():e.propagationStopped=!0,e.stopPropagation(),e.preventDefault(),!1):!0:!0},FastClick.prototype.onClick=function(e){"use strict";var t;return this.trackingClick?(this.targetElement=null,this.trackingClick=!1,!0):"submit"===e.target.type&&0===e.detail?!0:(t=this.onMouse(e),t||(this.targetElement=null),t)
},FastClick.prototype.destroy=function(){"use strict";var e=this.layer;this.deviceIsAndroid&&(e.removeEventListener("mouseover",this.onMouse,!0),e.removeEventListener("mousedown",this.onMouse,!0),e.removeEventListener("mouseup",this.onMouse,!0)),e.removeEventListener("click",this.onClick,!0),e.removeEventListener("touchstart",this.onTouchStart,!1),e.removeEventListener("touchmove",this.onTouchMove,!1),e.removeEventListener("touchend",this.onTouchEnd,!1),e.removeEventListener("touchcancel",this.onTouchCancel,!1)
},FastClick.notNeeded=function(e){"use strict";var t;if("undefined"==typeof window.ontouchstart)return!0;if(/Chrome\/[0-9]+/.test(navigator.userAgent)){if(!FastClick.prototype.deviceIsAndroid)return!0;if(t=document.querySelector("meta[name=viewport]"),t&&-1!==t.content.indexOf("user-scalable=no"))return!0}return"none"===e.style.msTouchAction?!0:!1},FastClick.attach=function(e){"use strict";return new FastClick(e)},"undefined"!=typeof define&&define.amd?define("fastclick",[],function(){"use strict";
return FastClick}):"undefined"!=typeof module&&module.exports?(module.exports=FastClick.attach,module.exports.FastClick=FastClick):window.FastClick=FastClick,define("plex/base/initializers/appInitializer",["jquery","plex/base/utils/xhrTracker","plex/base/utils/formatters/stringUtil","plex/base/adapters/storageAdapter"],function(e,t,i,n){"use strict";var s={init:function(s){var a=e.Deferred();if(window.PLEXWEB&&window.PLEXWEB.appVersion)s.set("version",window.PLEXWEB.appVersion);else{var r=e("#plex-script");
if(r.length){var o=/version=([\.\w]+)$/.exec(r[0].src);o&&s.set("version",o[1])}}t.startListening();var l=n.get("clientID");return l.done(function(e){s.set("clientID",e)}),l.fail(function(){var e=i.random();n.set("clientID",e),s.set("clientID",e)}),l.always(function(){a.resolve()}),a.promise()}};return s}),define("plex/base/initializers/settingsInitializer",["jquery","plex/base/adapters/localizerAdapter","plex/base/adapters/settingsAdapter","plex/base/models/server/serverStorageModel"],function(e,t,i,n){"use strict";
var s={init:function(){var s=e.Deferred(),a=i.populate({reset:!0}),r=n.populate({reset:!0});return e.when(a,r).always(function(){var e=i.get("language");t.load(e).always(function(){s.resolve()})}),s.promise()}};return s}),define("plex/base/adapters/analytics/loggingErrorTracker",["plex/base/adapters/loggerAdapter"],function(e){"use strict";var t={init:function(){e.info("Error tracker initialized")},enable:function(){e.info("Error tracker enabled")},disable:function(){e.info("Error tracker disabled")
},set:function(t){e.info("Error tracker set options "+JSON.stringify(t,null,2))},capture:function(t,i){e.error(t),e.info("Tracked error "+JSON.stringify(i,null,2))}};return t}),define("plex/base/adapters/analytics/LoggingAnalytics",["plex/base/utils/BaseClass","plex/base/adapters/loggerAdapter"],function(e,t){"use strict";var i=e.extend({enable:function(){t.info("Analytics enabled")},disable:function(){t.info("Analytics disabled")},set:function(e){t.info("Analytics set options "+JSON.stringify(e,null,2))
},trackView:function(e){t.info('Analytics tracked view "'+e+'"')},trackEvent:function(e){t.info("Analytics tracked event "+JSON.stringify(e,null,2))}});return i}),define("plex/base/initializers/analyticsInitializer",["plex/base/adapters/dimensionsAdapter","plex/base/adapters/errorTrackerAdapter","plex/base/adapters/analyticsAdapter","plex/base/adapters/analytics/loggingErrorTracker","plex/base/adapters/analytics/LoggingAnalytics","plex/base/models/config","plex/base/models/sessionStatsModel"],function(e,t,i,n,s,a,r){"use strict";
function o(i){("production"!==a.get("env")||i.disableErrorTracking)&&(t.disable(),t.register(n)),d=i.errorTrackerID||d,t.init(d,e.prop("X-Plex-Version")),t.set("X-Plex-Product",e.prop("X-Plex-Product")),t.set("X-Plex-Device",e.prop("X-Plex-Device")),t.set("X-Plex-Platform",e.prop("X-Plex-Platform")),t.set("X-Plex-Platform-Version",e.prop("X-Plex-Platform-Version"))}function l(t){("production"!==a.get("env")||t.disableAnalytics)&&i.register(s),c=t.googleAnalyticsID||c,i.init(c,{name:e.prop("X-Plex-Product"),version:e.prop("X-Plex-Version")}),i.set({dimension1:e.prop("X-Plex-Product"),dimension2:e.prop("X-Plex-Client-Identifier"),dimension3:e.prop("X-Plex-Platform"),dimension4:e.prop("X-Plex-Platform-Version"),dimension5:e.prop("X-Plex-Device"),dimension6:e.prop("X-Plex-Version")}),r.populate().done(function(){var e=r.get("heartbeatTime")-r.get("startTime"),t=Math.round(e/1e3),n=r.get("playbackCount");
i.trackEvent({eventCategory:"App",eventAction:"Shutdown",eventValue:t,metric1:n})}),r.populate().always(function(){r.startSession(),i.trackEvent({eventCategory:"App",eventAction:"Start",eventValue:1,sessionControl:"start"})})}var c="UA-6111912-18",d="https://67349abf654648e18514f1fbcb1603c8@app.getsentry.com/34246",u={init:function(e){e||(e={}),o(e),l(e)}};return u}),define("plex/desktop/initializers/desktopAnalyticsInitializer",["plex/base/utils/dispatcher","plex/base/initializers/analyticsInitializer","plex/base/adapters/analyticsAdapter"],function(e,t,i){"use strict";
var n={init:function(){t.init(),e.on("show:modal",function(e){e.name&&i.trackView(e.name)})}};return n}),define("plex/base/utils/pubsub/CloudServerEventConnection",["underscore","jquery","plex/base/utils/BaseClass","plex/base/utils/capabilities","plex/base/utils/xhrTracker","plex/base/utils/parser","plex/base/mixins/eventMixin","plex/base/models/appModel"],function(e,t,i,n,s,a,r,o){"use strict";var l=i.extend({mixins:r,url:function(){var e=o.get("user"),t="/sub/"+this.requestType+"/"+e.id+"/"+o.get("clientID"),i=this.server.resolveUrl(t,{connection:{scheme:"websockets"===this.requestType?"wss":"https",address:"websockets"===this.requestType?"pubsubload.plex.tv":"pubsubpoll.plex.tv"},appendToken:!0});
return i},initialize:function(t){e.bindAll(this,"onSocketOpen","onSocketClose","onSocketError","onSocketMessage","onPollSuccess","onPollError"),this.server=t.server},open:function(){return(this.socket||this.pollRequest)&&this.close(),n.hasWebSocket?(this._deferred=t.Deferred(),this.requestType="websockets",this.socket=new WebSocket(e.result(this,"url")),this.socket.onopen=this.onSocketOpen,this.socket.onclose=this.onSocketClose,this.socket.onerror=this.onSocketError,this.socket.onmessage=this.onSocketMessage,this._deferred.promise()):this.poll()
},close:function(){this.pollRequest&&(s.abort(this.pollRequest.rid),this.pollRequest=null),this._deferred&&"pending"===this._deferred.state()&&this._deferred.reject(),this.socket&&(this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close(),this.socket=null)},poll:function(){this.requestType="longpolling";var i=e.result(this,"url"),n=this.server.getXHROptions(i);return this.pollRequest=t.ajax(n).done(this.onPollSuccess).fail(this.onPollError),this.pollRequest.promise()
},handleResponse:function(t){if(t){var i=a.parseXML(t);if(e.isObject(i)){var n=this[i.command];e.isFunction(n)&&n.call(this,i)}}},relayStarted:function(e){var t=o.get("servers"),i=t.get(e.clientIdentifier);i&&i.addConnection({address:e.host,port:e.port,accessToken:i.get("accessToken"),relay:!0})},onSocketOpen:function(e){this.trigger("open",this.server,e),this._deferred.resolve(this.server,e)},onSocketClose:function(e){this.close(),this.trigger("close",this.server,e),this._deferred.reject(this.server,e)
},onSocketError:function(e){this.close(),this.trigger("error",this.server,e),this._deferred.reject(this.server,e)},onSocketMessage:function(e){this.handleResponse(e.data)},onPollSuccess:function(e){this.trigger("open",this.server,e),this.handleResponse(e),this.poll()},onPollError:function(e){this.pollRequest.aborting||this.trigger("error",this.server,e)}});return l}),define("plex/base/utils/workers/BaseWorker",["underscore","jquery","plex/base/utils/BaseClass","plex/base/adapters/loggerAdapter"],function(e,t,i,n){"use strict";
var s=i.extend({initialize:function(){this.jobs=[]},minDelay:2e3,maxJobAge:0,schedule:function(){throw new Error("`schedule` must be implemented by a subclass")},process:function(){throw new Error("`process` must be implemented by a subclass")},timeout:function(){throw new Error("`timeout` must be implemented by a subclass")},add:function(t){var i=e.find(this.jobs,function(e){return e.data===t});if(i)return i.promise;var n=+new Date,s={data:t,addedAt:n};this.jobs.push(s),this.rescheduleJobInQueue(s),this.scheduleNextTick()
},remove:function(t){this.jobs=e.filter(this.jobs,function(e){return e.data!==t}),this.scheduleNextTick()},rescheduleJobInQueue:function(t){var i=this.jobAge(t),n=this.schedule(t.data,i);this.logRescheduledJob(t,{jobName:"job",delay:n});var s=+new Date;t.processAt=s+n,this.jobs=e.sortBy(this.jobs,function(e){return e.processAt})},logRescheduledJob:function(e,t){var i=Math.round(t.delay/1e3),s="Retrying "+t.jobName;t.subjectName&&(s+=" for "+t.subjectName),s+=" in "+i+" seconds",n.log(s)},scheduleNextTick:function(){var t=this.jobs[0];
this._timeout&&clearTimeout(this._timeout),t&&(this._timeout=setTimeout(e.bind(this.processJob,this,t),this.jobDelay(t)))},jobDelay:function(e){var t=+new Date;return Math.max(e.processAt-t,1,this.minDelay)},jobAge:function(e){var t=+new Date;return t-e.addedAt},processJob:function(i){var n=i.data,s=this.jobAge(i);if(this.maxJobAge&&s>=this.maxJobAge)return this.removeJob(i),this.scheduleNextTick(),void this.timeout(n);var a,r=this.process(n,s);a=r?r.then?r:t.when(r):t.Deferred().reject(),a.then(e.bind(this.onProcessSuccessful,this,i),e.bind(this.onProcessFailure,this,i))
},removeJob:function(t){this.jobs.splice(e.indexOf(this.jobs,t),1)},onProcessSuccessful:function(e){this.removeJob(e),this.scheduleNextTick()},onProcessFailure:function(e){this.rescheduleJobInQueue(e),this.scheduleNextTick()}});return s}),define("plex/base/utils/workers/ServerEventRetryWorker",["plex/base/utils/workers/BaseWorker"],function(e){"use strict";var t=e.extend({minDelay:3e3,maxDelay:6e5,initialize:function(t){e.prototype.initialize.apply(this,arguments),this.serverEventManager=t},process:function(e){return this.serverEventManager.connect({server:e})
},schedule:function(e,t){return Math.max(Math.min(Math.floor(2*t),this.maxDelay),this.minDelay)},logRescheduledJob:function(t,i){e.prototype.logRescheduledJob.call(this,t,{jobName:"server events connection",subjectName:t.data.get("friendlyName"),delay:i.delay})}});return t}),define("plex/base/managers/ServerEventManager",["underscore","plex/base/utils/BaseClass","plex/base/utils/workers/ServerEventRetryWorker","plex/base/mixins/eventMixin"],function(e,t,i,n){"use strict";var s=t.extend({mixins:n,initialize:function(e){this.ServerEventConnection=e.ServerEventConnection,this.retryWorker=new i(this),this.connections={}
},connect:function(e){var t=e.server,i=this.connections[t.id];return i||(i=new this.ServerEventConnection({server:t}),this.connections[t.id]=i,this.listenTo(i,{open:this.onOpen,close:this.onClose,error:this.onClose})),i.open()},disconnectAll:function(){e.each(this.connections,function(e){this.disconnect({connection:e})},this)},disconnect:function(e){var t=e.connection;t||(t=this.connections[e.server.id]),t&&(this.stopListening(t),this.retryWorker.remove(t.server),t.close(),delete this.connections[t.server.id])
},onOpen:function(e){this.retryWorker.remove(e)},onClose:function(e){this.retryWorker.add(e)}});return s}),define("plex/base/initializers/cloudServerEventInitializer",["plex/base/utils/dispatcher","plex/base/utils/pubsub/CloudServerEventConnection","plex/base/managers/ServerEventManager","plex/base/models/appModel"],function(e,t,i,n){"use strict";function s(e,t){t?r.connect({server:o.server}):r.disconnect({server:o.server})}function a(){r.disconnectAll()}var r=new i({ServerEventConnection:t}),o=n.get("user"),l={init:function(){o.on("change:signedIn",s),e.on("request:disconnect:serverEvents",a)
}};return l}),define("plex/base/models/library/SyncMetadataModel",["plex/base/models/library/MetadataModel"],function(e){"use strict";var t=e.extend({cacheKey:function(t){var i=e.prototype.cacheKey.apply(this,arguments);return i+"!"+t.syncItemId}});return t}),define("plex/base/utils/pubsub/MediaServerEventConnection",["underscore","jquery","plex/base/utils/t","plex/base/utils/BaseClass","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/utils/syncUtil","plex/base/mixins/eventMixin","plex/base/models/appModel","plex/base/models/library/section/SectionModel","plex/base/models/library/MetadataModel","plex/base/models/library/SyncMetadataModel","plex/base/models/server/SessionModel"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=n.extend({mixins:o,url:function(){var t=this.server.get("activeConnection"),i=e.pick(t,"address","port");i.scheme="https"===t.scheme?"wss":"ws",t.uri&&(i.uri=t.uri.replace(/^http/,"ws"));var n=this.server.resolveUrl("/:/websockets/notifications",{connection:i,appendToken:!0});return n},initialize:function(t){e.bindAll(this,"onOpen","onClose","onError","onMessage"),this.server=t.server},open:function(){return this.socket&&this.close(),this._deferred=t.Deferred(),this.socket=new WebSocket(e.result(this,"url")),this.socket.onopen=this.onOpen,this.socket.onclose=this.onClose,this.socket.onerror=this.onError,this.socket.onmessage=this.onMessage,this._deferred.promise()
},close:function(){this._deferred&&"pending"===this._deferred.state()&&this._deferred.reject(),this.socket&&(this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close(),this.socket=null)},testConnection:function(){if(this.server.get("connected")){var e=this.server.get("update");e&&"installing"===e.get("state")&&this.server.set("connected",null),this.server.trigger("error:connection",this.server)}},preference:function(e){e.key=e.id,e.server=this.server,this.server.trigger("socket:setting",e)
},timeline:function(t){t.server=this.server;var i={server:this.server,onlyIfCached:!0},n=new c({key:t.sectionID},i);if(!e.isEmpty(n)){i.section=n,t.section=n;var a="/library/metadata/"+t.itemID,r=new d({key:a},i);if(e.isEmpty(r)||(t.item=r,r.set({metadataState:t.metadataState,mediaState:t.mediaState}),r.trigger("socket:timeline",t)),t.rootItemID){var o="/library/metadata/"+t.rootItemID,l=new d({key:o},i);e.isEmpty(l)||(l.fetch(),l.refreshChildren())}if(t.parentItemID){var u="/library/metadata/"+t.parentItemID,h=new d({key:u},i);
e.isEmpty(h)||(h.fetch(),h.refreshChildren())}n.trigger("socket:timeline",t)}t.server.trigger("socket:timeline",t),s.trigger("timeline",t)},status:function(e){var t=e.title+(e.description?": "+e.description:"");s.trigger("show:status",this.server,t),this.server.trigger("socket:status",e),"LIBRARY_UPDATE"===e.notificationName&&this.server.get("sections").fetch()},progress:function(e){s.trigger("show:status",this.server,e.message),this.server.trigger("socket:status",e)},playing:function(t){if(t.sessionKey&&!this.server.get("shared")){var n={server:this.server,onlyIfCached:!0},r=this.server.get("sessions"),o=new h({sessionKey:t.sessionKey},n);
if(e.isEmpty(o)||o.get("key")!==t.key){var c=r.fetch();c.done(e.bind(function(){if(o=r.get(t.sessionKey)){var n=l.get("user"),a=o.get("Player").title,c=o.get("User").title,d=o.get("grandparentTitle"),u=o.get("title");d&&(u=d+" - "+u);var h=i("{1} started playing {2} on {3}.",c,u,a);c&&c!==n.get("username")&&s.trigger("show:status",this.server,h),this.server.trigger("socket:playing",e.extend(t,{username:c||i("Unknown"),title:u,player:a}))}},this))}else if(t.state===a.states.STOPPED)o.trigger("destroy",o,o.collection),o.cache.remove(o);
else{var d=o.get("Player");d&&(d.state=t.state,o.trigger("change:Player",o,d)),o.set("viewOffset",t.viewOffset)}}},syncState:function(t){var i={server:this.server,onlyIfCached:!0},n=new u({key:t.key,syncItemId:t.syncItemId},i);if(!e.isEmpty(n)){var s=n.get("Media");e.each(s,function(i){var s=i.Part;e.each(s,function(e){e.transcodeState=t.syncFileState,e.transcodeStateContext=t.syncFileStateContext,e.syncState=t.syncState,e.syncStateContext=t.syncStateContext;var i=r.getSyncStateFromPart(e);r.waitingRegex.test(i)&&(e.key="placeholder"),n.trigger("change:Media",n,n.get("Media"))
})})}},"update.statechange":function(t){var i=this.server.get("update"),n=e.pick(t,i.whitelistedAttrs);e.defaults(n,e.result(i,"defaults")),"downloading"===i.get("state")&&"available"===n.state&&(n.state="downloading"),i.set(n)},reachability:function(){var e=this.server.get("cloudAccount");e.fetch()},account:function(e){this.server.set("myPlexSubscription",e.hasPlexPass)},onOpen:function(e){this.server.trigger("socket:websocket",{opened:!0}),this.trigger("open",this.server,e),this._deferred.resolve(this.server,e)
},onClose:function(e){this.close(),this.server.trigger("socket:websocket",{closed:!0}),this.trigger("close",this.server,e),this._deferred.reject(this.server,e),this.testConnection()},onError:function(e){this.close(),this.server.trigger("socket:websocket",{error:!0}),this.trigger("error",this.server,e),this._deferred.reject(this.server,e),this.testConnection()},onMessage:function(t){var i;try{i=JSON.parse(t.data)}catch(n){return}var s=i.type,a=this[s];e.each(i._children,function(t){this.trigger("message",t),e.isFunction(a)&&a.call(this,t)
},this)}});return p}),define("plex/base/initializers/mediaServerEventInitializer",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/capabilities","plex/base/utils/constants/timelineEvents","plex/base/utils/pubsub/MediaServerEventConnection","plex/base/managers/ServerEventManager","plex/base/models/appModel"],function(e,t,i,n,s,a,r){"use strict";function o(e,t){e.get("shared")||e.get("synced")||e.get("cloud")||(t?i.hasWebSocket?u.connect({server:e}):e.trigger("socket:websocket",{error:!0}):u.disconnect({server:e}))
}function l(e){if(u.disconnect({server:e}),e.get("isMerged")){var t=h.get(e.id);t.get("connected")&&u.connect({server:t})}}function c(){u.disconnectAll()}function d(i){var s;switch(i.state){case n.CREATED:s="Created {1} in {2} on {3}";break;case n.MATCHING:s="Matching {1} in {2} on {3}";break;case n.DOWNLOADING_METADATA:s="Downloading metadata for {1} in {2} on {3}";break;case n.LOADING_METADATA:s="Loading metadata for {1} in {2} on {3}";break;case n.PROCESSED:s="Finished processing {1} in {2} on {3}";
break;case n.ANALYZING:s="Analyzing {1} in {2} on {3}";break;case n.DELETED:s="Deleted {1} in {2} on {3}"}if(s&&!(i.sectionID<0)){var a=i.title||e("an item"),r=i.section?i.section.get("title"):"section "+i.sectionID;t.trigger("show:status",i.server,e(s,a,r,i.server.get("friendlyName")))}}var u=new a({ServerEventConnection:s}),h=r.get("servers"),p={init:function(){h.on({"change:connected":o,remove:l}),t.on({"request:disconnect:serverEvents":c,timeline:d})}};return p}),define("hb!templates/desktop/modals/user/UserSelectModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="modal-dialog">\n  <div class="modal-content"></div>\n</div>\n'
})}),define("hb!templates/desktop/modals/user/UserSelectModalUsersPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="modal-header">\n  <h4 class="modal-title">\n    ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Select User",r):l.call(t,"t","Select User",r)))+'\n\n    <span class="loading loading-sm"></span>\n  </h4>\n</div>\n\n<div class="modal-body"></div>\n'
})}),define("plex/desktop/views/lists/BaseList",["underscore","marionette"],function(e,t){"use strict";var i=t.CollectionView.extend({appendHtml:function(){return this.sorted?this.sortedAppendHtml.apply(this,arguments):this.reversed?this.reversedAppendHtml.apply(this,arguments):t.CollectionView.prototype.appendHtml.apply(this,arguments)},sortedAppendHtml:function(e,t,i){if(e.isBuffering){var n=e.elBuffer.childNodes;n.length<=i?e.elBuffer.appendChild(t.el):e.elBuffer.insertBefore(t.el,n[i]),e._bufferedChildren.push(t)
}else{var s=e.itemViewContainer?e.$(e.itemViewContainer):e.$el,a=s.children();a.size()<=i?s.append(t.el):a.eq(i).before(t.el)}},reversedAppendHtml:function(e,t){if(e.isBuffering)e.elBuffer.insertBefore(t.el,e.elBuffer.firstChild),e._bufferedChildren.push(t);else{var i=e.itemViewContainer?e.$(e.itemViewContainer):e.$el;i.prepend(t.el)}},measureList:function(){if(this.children.length){var t=this.children._views,i=t[e.first(e.keys(t))];e.defer(e.bind(function(){this.itemWidth=i.$el.outerWidth(!0),this.itemHeight=i.$el.outerHeight(!0),this.itemMarginRight=parseInt(i.$el.css("margin-right"),10),this.itemMarginBottom=parseInt(i.$el.css("margin-bottom"),10),this.triggerMethod("measure",this)
},this))}},getViewForModel:function(e){var t=this.children._indexByModel[e.cid];return this.children._views[t]},onCollectionRendered:function(){this.measure&&this.measureList()}});return i}),define("hb!templates/desktop/modals/user/UserSelectModalUserListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n  <div class="user-select-container">\n'}function r(){return'\n  <a class="user-select-container" href="#">\n'}function o(){return"\n  </div>\n"}function l(){return"\n  </a>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d="",u=this;return c=i["if"].call(t,t&&t.disabled,{hash:{},inverse:u.program(3,r,s),fn:u.program(1,a,s),data:s}),(c||0===c)&&(d+=c),d+='\n  <div class="user-select-top">\n    <div class="user-poster img-circle"></div>\n    <i class="protected-icon user-icon glyphicon lock"></i>\n    <i class="admin-icon user-icon glyphicon crown"></i>\n  </div>\n\n  <div class="username"></div>\n',c=i["if"].call(t,t&&t.disabled,{hash:{},inverse:u.program(7,l,s),fn:u.program(5,o,s),data:s}),(c||0===c)&&(d+=c),d+="\n"
})}),define("plex/base/utils/posterSizes",[],function(){"use strict";var e={sizes:{movie:"portrait",show:"portrait",season:"portrait",episode:"landscape",artist:"square",album:"square",track:"square",photo:"square",photoAlbum:"square",clip:"landscape",playlist:"square",playlistFolder:"square",userPlaylistItem:"landscape",channel:"square",channelDirectory:"square",folder:"portrait",friend:"square",poster:"portrait",art:"landscape",banner:"banner"},ratios:{portrait:1/1.5,square:1,landscape:16/9,banner:5.2},getRatioByType:function(e){return this.ratios[this.sizes[e]]
},getPosterWidth:function(e,t){return t*this.getRatioByType(e)},getPosterHeight:function(e,t){return t/this.getRatioByType(e)}};return e}),define("plex/base/utils/posterPlaceholders",[],function(){"use strict";var e="placeholder-standard",t="placeholder-square",i="placeholder-widescreen",n="placeholder-folder",s="placeholder-friend",a={movie:e,show:e,season:e,episode:i,artist:t,album:t,track:t,photo:t,photoAlbum:t,clip:i,userPlaylistItem:i,playlist:t,playlistFolder:t,channel:t,channelDirectory:t,folder:n,friend:s,device:t,poster:e,art:i,banner:i};
return a}),define("plex/base/utils/cache/ImageCache",["underscore","plex/base/utils/capabilities","plex/base/utils/cache/Cache"],function(e,t,i){"use strict";var n=i.extend({maxCycles:3,maxSize:50,imageParamsRegex:/&?(width|height|minSize)=([^&]+)/g,_infoMemo:{},store:function(t,i){if(i||(i=this.getItemCacheKey(t)),i){var n=t.url,s=this.getImageInfo(n),a={url:n,blobUrl:t.blobUrl,size:s.size},r=this.get(i);if(r){if(!r.images.hasOwnProperty(n)){var o=r.sizes;r.images[n]=a;var l=e.sortedIndex(o,a,"size");
o.splice(l,0,a)}}else r={images:{},sizes:[a]},r.images[n]=a,this.startListening(),r._cacheKey=i,this._cache[i]=r,this.size++,t.persistInCache||this.setItemCycle(r,i,e.first(this.cycles))}},getItemCacheKey:function(e){var t=this.getImageInfo(e.url);return t.key},getImageInfo:function(e){if(this._infoMemo.hasOwnProperty(e))return this._infoMemo[e];var t={width:0,height:0,minSize:0},i=e.replace(this.imageParamsRegex,function(e,i,n){return t[i]=parseInt(n,10),""}),n={key:i,size:t.width*t.height+t.minSize};
return this._infoMemo[e]=n,n},removeImageInfo:function(e){this._infoMemo.hasOwnProperty(e)&&delete this._infoMemo[e]},getBlobUrl:function(e){var t=this.getImageInfo(e),i=this.get(t.key);if(i){var n=i.images[e];if(n)return n.blobUrl}},getPlaceholder:function(t){var i=this.getImageInfo(t),n=this.get(i.key);if(n){if(n.images[t])return;var s=e.last(n.sizes);return s.blobUrl}},remove:function(n){i.prototype.remove.apply(this,arguments),e.each(n.sizes,function(e){this.removeImageInfo(e.url),t.hasObjectUrl&&window.URL.revokeObjectURL(e.blobUrl)
},this)}});return n}),define("plex/base/views/images/BaseImage",["underscore","jquery","marionette","plex/base/utils/capabilities","plex/base/utils/transcoder","plex/base/utils/cache/ImageCache","plex/base/models/appModel"],function(e,t,i,n,s,a,r){"use strict";var o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",l=i.ItemView.extend({tagName:"img",background:!1,cache:new a,initialize:function(t){t||(t={}),e.bindAll(this,"onLoad","onError","loadImage"),this.pixelRatio=window.devicePixelRatio?window.devicePixelRatio:1,this.url=t.url,this.server=t.server,this.placeholder=t.placeholder,this.placeholderClass=t.placeholderClass,this.modelAttribute=t.modelAttribute,this.ignoreAttributeChanges=t.ignoreAttributeChanges,this.exposeUrl=t.exposeUrl,this.resetOnError=t.resetOnError,t.background&&(this.background=t.background),t.format&&(this.format=t.format),e.isFunction(t.getUrl)&&(this.getUrl=t.getUrl),this.setup(t)
},setup:function(e){this.setDimensions(e),this.setFilters(e.filters),this.setModel(e.model,e)},setDimensions:function(e){e.width&&e.height&&(this.transcode=!0,this.width=e.width*this.pixelRatio,this.height=e.height*this.pixelRatio)},setFilters:function(e){this.filters=e||void 0},hasFilters:function(){return void 0!==this.filters},setModel:function(e,t){t||(t={}),this.stopListening(),this.src=null,this.model=e,e&&(this.server||(this.server=e.server),t.url||this.modelAttribute&&(this.url=this.getUrl(e.get(this.modelAttribute)),this.ignoreAttributeChanges||this.listenTo(e,"change:"+this.modelAttribute,this.onChange)))
},setElement:function(){i.ItemView.prototype.setElement.apply(this,arguments),this.render({force:!0})},getUrl:function(e){return e},getTranscodeUrl:function(e){return this.server&&this.transcode?s.image(this.server,e,{fallbackServer:r.get("primaryServer"),width:this.width,height:this.height,minSize:this.minSize,filters:this.filters,format:this.format}):e},render:function(e){return e||(e={}),this.url||this.placeholder||this.placeholderClass?this.src?void(e.force&&this.showImage(this.src)):(this.isPlaceholderRendered&&this.url||this.showPlaceholder(),this.url&&this.load(this.url,this.transcode).then(this.onLoad,this.onError,this.onLoad),this):this
},showPlaceholder:function(){return this.isPlaceholderRendered=!0,this.placeholderClass?(this.$el.addClass(this.placeholderClass),void this.$el.css("background-image","")):this.placeholder?void this.showImage(this.placeholder):void(this.background?this.$el.css("background-image",""):this.showImage(o))},showImage:function(e){return this.background?void this.showBackgroundImage(e):void this.$el.attr("src",e).removeAttr("width").removeAttr("height")},showBackgroundImage:function(e){this.$el.css("background-image","url("+e+")")
},load:function(e){if(!e)return t.Deferred().reject().promise();if(e=this.getTranscodeUrl(e),this.exposeUrl&&this.$el.attr("data-image-url",e),n.hasBlob&&n.hasObjectUrl){var i=this.loadBlob(e);return i=i.then(this.loadImage,null,this.loadImage)}return this.loadImage(e)},loadBlob:function(i){var n=t.Deferred();this.cancel();var s=this.cache.getBlobUrl(i);if(s)return n.resolve(s),n.promise();var a=this.cache.getPlaceholder(i);a&&n.notify(a,!0);var r=new XMLHttpRequest;return r.open("GET",i,!0),r.responseType="arraybuffer",this.xhr=r,r.onreadystatechange=e.bind(function(){if(4===r.readyState)if(r.onreadystatechange=null,this.xhr=null,200===r.status){var e=new Blob([r.response],{type:"image/jpeg"}),t=window.URL.createObjectURL(e);
this.cache.store({url:i,blobUrl:t}),n.resolve(t)}else n.reject()},this),r.send(),n.promise()},loadImage:function(e,i){var n=t.Deferred(),s=new Image;return s.onload=function(){s.onload=s.onabort=s.onerror=null,i?n.notify(e):n.resolve(e)},s.onabort=s.onerror=function(){s.onload=s.onabort=s.onerror=null,n.reject()},s.src=e,n.promise()},cancel:function(){this.xhr&&(this.xhr.onreadystatechange=null,this.xhr.abort(),this.xhr=null)},onLoad:function(e){this.src=e,this.placeholderClass&&this.$el.removeClass(this.placeholderClass),this.showImage(e),this.trigger("load",e)
},onError:function(){this.resetOnError&&this.showPlaceholder(),this.trigger("error")},onClose:function(){this.cancel()},onChange:function(e,t){return t=this.getUrl(t),this.url===t?this:(this.url=t,this.src=null,void this.render())}});return l}),define("plex/base/views/images/MediaPosterImage",["plex/base/utils/posterSizes","plex/base/utils/posterPlaceholders","plex/base/views/images/BaseImage"],function(e,t,i){"use strict";var n=i.extend({background:!0,setup:function(e){this.minSize=!0,this.type=e.type,this.modelAttribute=e.modelAttribute||"thumb",this.model&&this.model.get("isFolder")?this.placeholderClass=t.folder:e.placeholderClass||(this.placeholderClass=t[this.type]),i.prototype.setup.apply(this,arguments)
},setDimensions:function(t){t.width?t.height=e.getPosterHeight(this.type,t.width):t.height&&(t.width=e.getPosterWidth(this.type,t.height)),i.prototype.setDimensions.call(this,t)},setModel:function(){i.prototype.setModel.apply(this,arguments),this.model&&this.model.get("isFolder")&&(this.placeholderClass=t.folder)}});return n}),define("plex/base/views/images/GravatarImage",["plex/base/views/images/MediaPosterImage"],function(e){"use strict";var t=e.extend({getUrl:function(e){var t;return e&&(t=e+(e.indexOf("?")>0?"&":"?"),t+="size="+this.width),t
}});return t}),define("plex/desktop/views/modals/user/UserSelectModalUserListItem",["hb!templates/desktop/modals/user/UserSelectModalUserListItem.tpl","marionette","plex/base/models/appModel","plex/base/views/images/GravatarImage"],function(e,t,i,n){"use strict";var s=t.ItemView.extend({tagName:"li",className:"user-select-list-item",template:e,ui:{container:".user-select-container",poster:".user-poster"},events:{"click a":"onClick"},initialize:function(e){this.disabled=e.disabled,this.posterImage=new n({model:this.model,type:"friend",width:80});
var t=i.get("primaryServer");t&&t.supports("imageFilters")&&(this.backgroundImage=new n({model:this.model,type:"friend",width:120,background:!0,filters:{blur:20,opacity:50,background:"000000"}}),this.backgroundImage.placeholderClass=!1)},serializeData:function(){return{disabled:this.disabled}},bindings:{".username":{modelAttribute:"title"},".protected-icon":{modelAttribute:"protected",autohide:!0,manual:!0},".admin-icon":{modelAttribute:"admin",autohide:!0,manual:!0}},onRender:function(){this.posterImage.setElement(this.ui.poster),this.backgroundImage&&this.backgroundImage.setElement(this.ui.container)
},onClose:function(){this.posterImage.close(),this.backgroundImage&&this.backgroundImage.close()},onClick:function(e){e.preventDefault(),this.trigger("selectUser",this.model)}});return s}),define("plex/desktop/views/modals/user/UserSelectModalUserList",["plex/desktop/views/lists/BaseList","plex/desktop/views/modals/user/UserSelectModalUserListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list user-select-list",itemView:t});return i}),define("plex/desktop/views/modals/user/UserSelectModalUsersPane",["hb!templates/desktop/modals/user/UserSelectModalUsersPane.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/server/serverStorageModel","plex/base/models/user/HomeUserCollection","plex/desktop/views/modals/user/UserSelectModalUserList"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=n.Layout.extend({className:"user-select-modal-users-container",template:e,ui:{loading:".loading"},regions:{body:".modal-body"},onlyAfterRender:["onUserPopulated","onHomeUsersPopulated","onError"],initialize:function(){this.user=r.get("user"),this.homeUsers=this.user.get("homeUsers"),this.user.server.populate().done(t.bind(this.onUserPopulated,this)).fail(t.bind(this.onError,this))},showList:function(e){this.ui.loading.addClass("hidden"),this.body.show(new c({collection:e})),this.listenTo(this.body.currentView,"itemview:selectUser",this.onUserSelect)
},selectUser:function(e){if(!this.user.get("signedIn")||e.id===this.user.id)return this.user.set("locked",!1),void this.trigger("resolve");this.ui.loading.removeClass("hidden");var i=a.execute("switchUser",{homeUser:e,switchUser:!0});i.done(t.bind(function(){this.trigger("resolve")},this)),i.always(t.bind(function(){this.ui.loading.addClass("hidden")},this))},onUserPopulated:function(){this.homeUsers.fetch().done(t.bind(this.onHomeUsersPopulated,this)).fail(t.bind(this.onError,this))},onHomeUsersPopulated:function(e){this.showList(e)
},onError:function(){var e=o.getCurrentUser();e=e.then(t.bind(function(e){if(!e.home)return i.Deferred().reject().promise();var t={id:e.id,title:e.title,"protected":!!e.pin};this.showList(new l([t],{server:this.user.server,parent:this.user}))},this)),e.fail(t.bind(function(){this.user.set("locked",!1),this.trigger("resolve")},this))},onUserSelect:function(e,t){var i=this.homeUsers.get(this.user.id),n=i&&i.get("admin"),s=!this.user.get("locked")&&n;!s&&t.get("protected")?this.trigger("change:pane","pin",{model:t,showBackButton:!0,focusDelay:0}):this.selectUser(t)
}});return d}),define("hb!templates/desktop/modals/user/UserSelectModalPINPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n      <a class="back-btn btn-gray" href="#"><i class="glyphicon chevron-left"></i></a>\n    '}function r(e,t){var n,s,a="";return a+='\n      <i class="modal-icon glyphicon pencil"></i>\n      ',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Edit PIN",s):b.call(e,"t","Edit PIN",s)))+"\n    "}function o(e,t){var n;return n=i["if"].call(e,e&&e.isEditConfirmation,{hash:{},inverse:x.program(8,c,t),fn:x.program(6,l,t),data:t}),n||0===n?n:""
}function l(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Confirm Current PIN",s):b.call(e,"t","Confirm Current PIN",s)))+"\n    "}function c(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Enter PIN",s):b.call(e,"t","Enter PIN",s)))+"\n    "}function d(){return"number"}function u(){return"password"}function h(e,t){var n,s,a="";return a+='\n      <p class="help-block">\n        ',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"You do not currently have a PIN. This will allow any users in this home to switch to your account.",s):b.call(e,"t","You do not currently have a PIN. This will allow any users in this home to switch to your account.",s)))+"\n      </p>\n    "
}function p(e,t){var n,s,a="";return a+='\n    <div class="modal-footer">\n      ',n=i["if"].call(e,e&&e.hasCurrentPIN,{hash:{},inverse:x.noop,fn:x.program(17,m,t),data:t}),(n||0===n)&&(a+=n),a+="\n\n      ",n=i["if"].call(e,e&&e.isEditWarning,{hash:{},inverse:x.program(21,g,t),fn:x.program(19,f,t),data:t}),(n||0===n)&&(a+=n),a+='\n\n      <button type="submit" class="save-btn btn-link">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Save",s):b.call(e,"t","Save",s)))+"</button>\n    </div>\n  "
}function m(e,t){var n,s,a="";return a+='\n        <button type="button" class="remove-btn btn-gray pull-left">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Remove",s):b.call(e,"t","Remove",s)))+"</button>\n      "}function f(e,t){var n,s,a="";return a+='\n        <button type="button" class="skip-btn btn-gray" data-dismiss="modal">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Skip",s):b.call(e,"t","Skip",s)))+"</button>\n      "}function g(e,t){var n,s,a="";return a+='\n        <button type="button" class="cancel-btn btn-gray" data-dismiss="modal">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Cancel",s):b.call(e,"t","Cancel",s)))+"</button>\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var v,y="",b=i.helperMissing,w=this.escapeExpression,x=this;return y+='<div class="modal-header">\n  <div class="home-user-dropdown-container pull-right"></div>\n\n  <h4 class="modal-title">\n    ',v=i["if"].call(t,t&&t.showBackButton,{hash:{},inverse:x.noop,fn:x.program(1,a,s),data:s}),(v||0===v)&&(y+=v),y+="\n\n    ",v=i["if"].call(t,t&&t.isEditing,{hash:{},inverse:x.program(5,o,s),fn:x.program(3,r,s),data:s}),(v||0===v)&&(y+=v),y+='\n\n    <span class="loading loading-sm hidden"></span>\n  </h4>\n</div>\n\n<form id="pin-form">\n  <div class="modal-body">\n    <ul class="tile-list user-select-list disabled"></ul>\n\n    <div class="pin-inputs-container">\n      <input type="',v=i["if"].call(t,t&&t.isEditing,{hash:{},inverse:x.program(12,u,s),fn:x.program(10,d,s),data:s}),(v||0===v)&&(y+=v),y+='" pattern="\\d*" class="form-control">\n      <input type="',v=i["if"].call(t,t&&t.isEditing,{hash:{},inverse:x.program(12,u,s),fn:x.program(10,d,s),data:s}),(v||0===v)&&(y+=v),y+='" pattern="\\d*" class="form-control">\n      <input type="',v=i["if"].call(t,t&&t.isEditing,{hash:{},inverse:x.program(12,u,s),fn:x.program(10,d,s),data:s}),(v||0===v)&&(y+=v),y+='" pattern="\\d*" class="form-control">\n      <input type="',v=i["if"].call(t,t&&t.isEditing,{hash:{},inverse:x.program(12,u,s),fn:x.program(10,d,s),data:s}),(v||0===v)&&(y+=v),y+='" pattern="\\d*" class="form-control">\n    </div>\n\n    ',v=i["if"].call(t,t&&t.isEditWarning,{hash:{},inverse:x.noop,fn:x.program(14,h,s),data:s}),(v||0===v)&&(y+=v),y+="\n  </div>\n\n  ",v=i["if"].call(t,t&&t.isEditing,{hash:{},inverse:x.noop,fn:x.program(16,p,s),data:s}),(v||0===v)&&(y+=v),y+="\n</form>\n"
})}),define("hb!templates/desktop/modals/user/HomeWarningModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-info"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Welcome to Plex Home",r):l.call(t,"t","Welcome to Plex Home",r)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <p>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"{1}, so we've made a few changes to help keep your media safe.",t&&t.intro,r):l.call(t,"t","{1}, so we've made a few changes to help keep your media safe.",t&&t.intro,r)))+"</p>\n\n      <ol>\n        <li>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"We've increased the security requirements on this server, so anything communicating with it will need to be signed in to a Plex account.",r):l.call(t,"t","We've increased the security requirements on this server, so anything communicating with it will need to be signed in to a Plex account.",r)))+"</li>\n\n        <li>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"We've disabled DLNA to prevent any DLNA-enabled device from browsing and playing media without a password or PIN. You can change this preference in your {1}server settings{2}.","<a class='server-settings-btn' href='#'>","</a>",r):l.call(t,"t","We've disabled DLNA to prevent any DLNA-enabled device from browsing and playing media without a password or PIN. You can change this preference in your {1}server settings{2}.","<a class='server-settings-btn' href='#'>","</a>",r)))+"</li>\n      </ol>\n\n      <p>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"For more information on Plex Home security settings, please see the {1}Plex Home section{2} on our support site.","<a href='https://support.plex.tv/hc/en-us/sections/200641063' target='_blank'>","</a>",r):l.call(t,"t","For more information on Plex Home security settings, please see the {1}Plex Home section{2} on our support site.","<a href='https://support.plex.tv/hc/en-us/sections/200641063' target='_blank'>","</a>",r)))+'</p>\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="btn btn-lg btn-primary" data-dismiss="modal">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"OK",r):l.call(t,"t","OK",r)))+"</button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/user/HomeWarningModal",["hb!templates/desktop/modals/user/HomeWarningModal.tpl","underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/BaseModal"],function(e,t,i,n,s){"use strict";var a=s.extend({name:"homeWarningModal",template:e,events:t.extend({"click .server-settings-btn":"onServerSettingsClick"},s.prototype.events),initialize:function(e){s.prototype.initialize.apply(this,arguments),this.type=e.type},serializeData:function(){var e;
return e=i("pin"===this.type?"You've added a PIN restriction":"You've joined a Plex Home"),{intro:e}},onServerSettingsClick:function(e){e.preventDefault(),this.hide(),n.trigger("navigate","serverSettings")}});return a}),define("plex/desktop/views/modals/user/UserSelectModalPINPane",["hb!templates/desktop/modals/user/UserSelectModalPINPane.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/modals/user/UserSelectModalUserListItem","plex/desktop/views/modals/user/HomeWarningModal"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=n.Layout.extend({className:"user-select-modal-pin-container",template:e,ui:{inputsContainer:".pin-inputs-container",inputs:"input",loading:".loading",removeBtn:".remove-btn",saveBtn:".save-btn"},regions:{userList:".user-select-list"},events:{"keydown input":"onKeyDown","animationend .pin-inputs-container":"onInputsAnimationEnd","webkitAnimationEnd .pin-inputs-container":"onInputsAnimationEnd","oAnimationEnd .pin-inputs-container":"onInputsAnimationEnd","click .back-btn":"onBackClick","click .remove-btn":"onRemoveClick","submit #pin-form":"onSubmit"},onlyAfterRender:["confirmUser"],initialize:function(e){this.isForced=e.isForced,this.isEditing=e.isEditing,this.isEditWarning=e.isEditWarning,this.showBackButton=e.showBackButton,this.focusDelay=e.focusDelay,this.user=o.get("user"),this.isEditConfirmation=this.isEditing&&this.model.get("protected")&&!this.model.get("restricted")
},serializeData:function(){return{isEditing:this.isEditing&&!this.isEditConfirmation,isEditWarning:this.isEditWarning,isEditConfirmation:this.isEditConfirmation,hasCurrentPIN:this.model.get("protected"),showBackButton:this.showBackButton}},focusInput:function(e){var t;t=e?e.next("input"):this.ui.inputs.first(),t.length?t.focus().select():!this.isEditing||this.isEditConfirmation?this.confirmUser(this.getPIN()):this.ui.saveBtn.focus()},clearInputs:function(){this.ui.inputs.val(""),this.focusInput()
},clearInput:function(e){e.length&&(e.val(""),e.focus().select())},getPIN:function(){var e="";return this.ui.inputs.each(function(){e+=this.value}),e},editPIN:function(e){if(!this.ui.saveBtn.isDisabled()){this.ui.saveBtn.addClass("disabled");var i=this.savePIN(e);i.fail(t.bind(function(){this.ui.saveBtn.removeClass("disabled"),a.trigger("show:alert",{type:"error",message:s("This PIN could not be saved.")})},this))}},removePIN:function(){if(!this.ui.removeBtn.isDisabled()){this.ui.removeBtn.addClass("disabled");
var e=this.savePIN("");e.fail(t.bind(function(){this.ui.removeBtn.removeClass("disabled"),a.trigger("show:alert",{type:"error",message:s("This PIN could not be removed.")})},this))}},savePIN:function(e){this.ui.loading.removeClass("hidden");var i={pin:e};this.currentPin&&(i.currentPin=this.currentPin);var n=this.model.save(i,{wait:!0});return n.done(t.bind(function(){this.model.unset("pin"),this.model.unset("currentPin"),this.model.set("protected",!!e),this.model.id===this.user.id&&(e?this.user.set("pin",this.user.hashPIN(e)):this.user.unset("pin"),this.user.set("home",this.user.hasHome())),this.trigger("resolve",e),e&&this.user.get("homeUsers").length<2&&a.trigger("show:modal",new c({type:"pin"}))
},this)),n.always(t.bind(function(){this.ui.loading.addClass("hidden")},this)),n},confirmUser:function(e){this.ui.loading.removeClass("hidden");var i=r.execute("switchUser",{homeUser:this.model,pin:e});i.done(t.bind(function(){this.isEditing?(this.isEditConfirmation=!1,this.currentPin=e,this.render()):this.trigger("resolve",e)},this)),i.fail(t.bind(function(){this.ui.inputsContainer.addClass("shake"),this.clearInputs()},this)),i.always(t.bind(function(){this.ui.loading.addClass("hidden")},this))},onRender:function(){this.userList.show(new l({model:this.model,disabled:!0})),setTimeout(t.bind(this.focusInput,this),this.focusDelay)
},onKeyDown:function(e){var t=e.which;if(13!==t){var n=i(e.currentTarget);if(8!==t&&46!==t){e.preventDefault();var s=t>=48&&57>=t,a=t>=96&&105>=t;(s||a)&&(a&&(t-=48),n.val(String.fromCharCode(t)),this.focusInput(n))}else if(!n.val().length){e.preventDefault();var r=8===t?n.prev():n.next();this.clearInput(r)}}},onInputsAnimationEnd:function(e){i(e.currentTarget).removeClass("shake")},onBackClick:function(e){e.preventDefault(),this.trigger("change:pane","users")},onRemoveClick:function(e){e.preventDefault(),this.removePIN()
},onSubmit:function(e){e.preventDefault();var t=this.getPIN();return 4!==t.length?void a.trigger("show:alert",{type:"error",message:s("Please enter a 4 digit PIN.")}):void(this.isEditing&&!this.isEditConfirmation?this.editPIN(t):this.confirmUser(t))}});return d}),define("plex/desktop/views/modals/user/UserSelectModal",["hb!templates/desktop/modals/user/UserSelectModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/models/appModel","plex/desktop/views/modals/BaseModal","plex/desktop/views/modals/user/UserSelectModalUsersPane","plex/desktop/views/modals/user/UserSelectModalPINPane"],function(e,t,i,n,s,a,r,o){"use strict";
var l=a.extend({name:"userSelectModal",className:"user-select-modal modal modal-transparent fade",template:e,transparent:!0,panes:{users:r,pin:o},regions:{content:".modal-content"},initialize:function(e){a.prototype.initialize.apply(this,arguments),this.options=e,this.isForced=e.isForced,this.user=s.get("user"),this.promise=i.Deferred(),this.isForced&&this.listenTo(this.user,"change:locked",this.onUserLockedChange)},showPane:function(e,i){this.currentPane&&this.stopListening(this.currentPane);var n=this.panes[e],s=new n(t.extend({},this.options,i));
return this.listenTo(s,{"change:pane":this.onChangePane,resolve:this.onResolve,reject:this.onReject}),this.currentPane=s,this.content.show(s),s},onRender:function(){a.prototype.onRender.apply(this,arguments),this.model?this.showPane("pin",{focusDelay:this.focusDelay}):this.showPane("users")},onHide:function(){a.prototype.onHide.apply(this,arguments),"pending"===this.promise.state()&&this.promise.reject()},onChangePane:function(e,t){this.showPane(e,t)},onUserLockedChange:function(e,t){t===!1&&("pending"===this.promise.state()&&this.promise.resolve(),this.hide())
},onResolve:function(e){this.promise.resolve(e),this.hide()},onReject:function(){this.promise.reject(),this.hide()}});return l}),define("plex/desktop/initializers/userInitializer",["underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/models/appModel","plex/base/models/server/serverStorageModel","plex/base/models/user/HomeUserModel","plex/desktop/views/modals/ConfirmModal","plex/desktop/views/modals/user/UserSelectModal"],function(e,t,i,n,s,a,r,o,l){"use strict";
function c(e,t){t&&(e.get("devices").populate({reset:!0}),e.get("homeUsers").populate({reset:!0}),e.get("friends").populate({reset:!0}),e.get("invites").populate({reset:!0}),e.get("socialNetworks").populate({reset:!0}))}function d(e,n){if(n){var s=new o({title:t("Invalid Credentials"),message:t("Your credentials have expired. Please sign in again."),confirmLabel:t("OK"),cancelLabel:t("Ignore")});s.promise.done(function(){i.trigger("navigate","login",{silent:!0})}),i.trigger("show:modal",s)}}function u(e,t){t&&i.trigger("show:modal",new l({isForced:!0}))
}function h(e){e.get("signedIn")&&a.updateUser(e)}function p(){i.trigger("navigate:refresh:dashboard")}var m={init:function(){var e=s.get("user");e.on({"change:signedIn":c,"change:hasInvalidToken":d,"change:locked":u,"change:home":h,"change:pin":h}),i.on("home:userswitched",p);var t=a.getCurrentUser();t.done(function(t){t.home&&!n.get("autoLogin")&&e.set("locked",!0)})}};return m}),define("plex/base/managers/ServerManager",["underscore","jquery","plex/base/utils/BaseClass","plex/base/utils/dispatcher","plex/base/adapters/loggerAdapter","plex/base/mixins/eventMixin","plex/base/models/appModel","plex/base/models/server/serverStorageModel","plex/base/models/server/ServerModel"],function(e,t,i,n,s,a,r,o,l){"use strict";
function c(t){var i=e.map(t,function(e){return e.get("friendlyName")});return i.join(", ")}var d=i.extend({mixins:a,initialize:function(t){this.servers=t.servers,this.savePrimaryOnly=t.savePrimaryOnly,this.pendingResources=[],this.listenTo(this.servers,{add:this.onServerAdd,remove:this.onServerRemove,"change:authorized":this.onServerAuthorizedChange,"change:sources":this.onServerSourcesChange});var i=this.servers.where({cloud:!0});e.each(i,function(e){this.listenTo(e,{"change:resources:add":this.onResourceAdd,"change:resources:remove":this.onResourceRemove,"change:resources:reset":this.onResourcesReset})
},this),this.listenTo(r,{"change:primaryServer":this.onPrimaryServerChange})},resolveServersPromise:function(){if(this.pendingResources.length)return s.log("Waiting to resolve servers promise, pending resources"),void this.servers.resetPopulatePromise(t.Deferred());var e=this.servers.filter(function(e){return(e.get("bundled")||e.get("cloud"))&&e.hasPendingPopulate()});if(e.length)return s.log("Waiting to resolve servers promise, pending initial servers = "+c(e)),void this.servers.resetPopulatePromise(t.Deferred());
var i=this.servers.where({available:!0});if(i.length)s.log("Resolving servers promise, available servers = "+c(i)),this.servers.updatePopulatePromise("resolved");else{var n=this.servers.filter(function(e){return"pending"===e.populatePromise.state()});if(n.length)return s.log("Waiting to resolve servers promise, pending servers = "+c(n)),void this.servers.resetPopulatePromise(t.Deferred());s.warn("Rejecting servers promise, no available servers"),this.servers.updatePopulatePromise("rejected")}},fetchResources:function(t){var i=t.get("resources");
if(e.contains(this.pendingResources,i.populatePromise))return void this.resolveServersPromise();s.log("Finding servers through "+t.get("friendlyName"));var n=i.fetch();return this.pendingResources.push(n),n.done(e.bind(function(){s.log("Found "+i.length+" resources through "+t.get("friendlyName")),o.pruneLiteServers(this.servers,i),this.pruneUnavailableServers()},this)),n.always(e.bind(function(){this.pendingResources.splice(e.indexOf(this.pendingResources,n),1),this.resolveServersPromise()},this)),n
},abortResources:function(e){var t=e.get("resources");t.abortPendingPopulate(),this.resolveServersPromise()},pruneUnavailableServers:function(){this.servers.set(this.servers.reject(function(e){return e.get("authorized")===!1&&!e.id}))},saveOnlyServer:function(t){var i;return this.savePrimaryOnly&&(i=o.removeAllServers(),t&&i.then(e.bind(o.updateConnections,o,t,t.connections))),i},onServerAdd:function(e){e.get("cloud")&&this.listenTo(e,{"change:resources:add":this.onResourceAdd,"change:resources:remove":this.onResourceRemove,"change:resources:reset":this.onResourcesReset})
},onServerRemove:function(e){s.log("Removed server "+e.get("friendlyName")),this.stopListening(e),e.cache.remove(e),n.trigger("clearWhere:cache",{server:e}),this.resolveServersPromise()},onServerAuthorizedChange:function(e,t){var i,s=this.servers.where({authorized:!0,cloud:!1});if(r.set("multiserver",s.length>1),t)r.set("authorized",!0);else if(t===!1){var a=this.servers.every(function(e){return e.get("authorized")===!1});a&&(r.set("authorized",!1),r.previous("authorized")&&(i=!0))}e.get("cloud")?t?this.fetchResources(e):this.abortResources(e):this.resolveServersPromise(),i&&n.trigger("navigate:refresh")
},onServerSourcesChange:function(e,t){return t.length?void o.updateLiteServer(e):(e.set("authorized",!1),e.trigger("destroy",e,e.collection),e.cache.remove(e),void o.removeLiteServer(e))},onPrimaryServerChange:function(e,t){this.saveOnlyServer(t)},onResourceAdd:function(t){if(e.contains(t.get("provides"),"server")){s.log("Found additional server "+t.get("name"));var i=new l({machineIdentifier:t.id,name:t.get("name"),sourceTitle:t.get("sourceTitle"),accessToken:t.get("accessToken"),version:t.get("productVersion"),owned:t.get("owned"),synced:t.get("synced"),updatedAt:t.get("lastSeenAt"),presence:t.get("presence")},{parse:!0,server:t.server,parent:t.server.parent});
i.addSource(t.server.id),this.servers.add(i);var n=[];if(i.get("bundled")){var a=e.findWhere(i.connections,{bundled:!0});a&&n.push(a)}e.each(t.get("Connection"),function(e){n.push(i.addConnection({scheme:e.protocol,address:e.address,port:e.port,accessToken:t.get("accessToken"),uri:e.uri}))}),this.savePrimaryOnly||o.updateConnections(i,n),this.resolveServersPromise()}},onResourceRemove:function(t){if(e.contains(t.get("provides"),"server")){var i=this.servers.get(t.id);i&&i.removeSource(t.server.id)
}},onResourcesReset:function(e){for(var t=this.servers.models,i=t.length-1;i>-1;i--){var n=t[i];e.contains(n.id)||n.removeSource(e.server.id)}}});return d}),define("plex/base/managers/PrimaryServerManager",["underscore","plex/base/utils/dispatcher","plex/base/utils/BaseClass","plex/base/mixins/eventMixin","plex/base/models/appModel","plex/base/models/config","plex/base/adapters/analyticsAdapter","plex/base/adapters/errorTrackerAdapter","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=i.extend({mixins:n,waitingForServers:!1,initialize:function(t){e.bindAll(this,"checkPendingServers"),t||(t={}),this.servers=t.servers,this.lastPrimaryServerID=t.lastPrimaryServerID,this.startListening()},startListening:function(){this.listenTo(this.servers,"add",this.checkPendingServers),this.listenTo(this.servers,"remove",this.onServerRemove),this.listenTo(this.servers,"change:connected",this.onServerConnectedChange),this.listenTo(s,"change:primaryServer",this.onPrimaryServerChange)},checkPendingServers:function(){if(this.servers.populatePromise){if("pending"===this.servers.populatePromise.state()){if(this.waitingForServers)return;
return this.waitingForServers=!0,l.log("Primary server is waiting for servers to populate"),s.get("primaryServer")===!1&&s.set("primaryServer",null),void this.servers.populate().always(this.checkPendingServers)}if(!s.get("primaryServer")){this.waitingForServers=!1;var t=this.servers.filter(function(e){return null==e.get("connected")}),i=e.filter(t,function(e){return!e.get("shared")&&!e.get("synced")});if(this.primaryCandidate){var n=this.servers.get(this.lastPrimaryServerID),a=this.primaryCandidate.get("shared")&&!!i.length,o=!1;
if(this.lastPrimaryServerID&&n&&(o="pending"===n.populatePromise.state()),!t.length||!o&&!a)return void this.setPrimaryServer(this.primaryCandidate)}t.length||(this.setPrimaryServer(!1),r.enable())}}},findBestPrimaryServer:function(){var t=this.servers.filter(function(e){return e.canBePrimary(a.get("minServerVersion"))});if(!t.length)return!1;var i=e.findWhere(t,{id:this.lastPrimaryServerID});if(this.lastPrimaryServerID&&i)return i;var n=e.sortBy(t,function(e){return e.get("shared")});return e.first(n)
},setPrimaryServer:function(e){s.set("primaryServer",e)},fetchRelatedCollections:function(e){var t=e.get("shared"),i=e.get("home"),n=e.get("activeConnection");if(!t){var r=e.get("sessions");r.fetch({reset:!0})}var o=n.isLocalAddress||!t||i;if(o&&a.get("playerDiscovery")){var l=s.get("players");l.server=e,l.fetch({reset:!0})}if(!t||e.supports("sharedSettings")){var c=e.get("settings");this.listenTo(c,"reset",this.onPrimaryServerSettingsReset),c.populate({reset:!0})}},onServerRemove:function(e){var t=s.get("primaryServer");
t&&t.id===e.id&&!e.get("isMerged")?this.setPrimaryServer(this.findBestPrimaryServer()):null==t&&this.checkPendingServers()},onServerConnectedChange:function(e){if(!s.get("primaryServer")){if(!e.canBePrimary(a.get("minServerVersion")))return void this.checkPendingServers();var t=e.id===this.lastPrimaryServerID,i=!this.lastPrimaryServerID&&!e.get("shared");if(t||i)return l.log("Setting primary server immediately to "+e.get("friendlyName")),void this.setPrimaryServer(e);(!this.primaryCandidate||this.primaryCandidate.get("shared")&&!e.get("shared"))&&(l.log("Setting primary server candidate to "+e.get("friendlyName")),this.primaryCandidate=e),this.checkPendingServers()
}},onPrimaryServerChange:function(e,t){this.stopListening(),this.startListening(),null==t?this.checkPendingServers():t?l.success("Setting primary server to "+t.get("friendlyName")):l.warn("No primary server"),t&&(this.primaryCandidate=null,this.listenTo(t,"change:connected",this.onPrimaryServerConnectedChange),this.listenTo(t,"destroy",this.onPrimaryServerDestroy),this.fetchRelatedCollections(t))},onPrimaryServerSettingsReset:function(e){var i=e.server.get("shared"),n=e.get("AcceptedEULA"),s=e.get("collectUsageData");
!i&&n&&n.get("value")===!1&&t.trigger("command","showTermsOfService",{collection:e}),s&&s.get("value")===!0?(o.enable(),r.enable()):(o.disable(),r.disable())},onPrimaryServerConnectedChange:function(e,t){t||(l.warn("The primary server lost its connection"),this.setPrimaryServer(this.findBestPrimaryServer()))}});return c}),define("plex/base/utils/workers/BaseServerRetryWorker",["plex/base/utils/workers/BaseWorker"],function(e){"use strict";var t=e.extend({initialize:function(t){e.prototype.initialize.apply(this,arguments),this.serverConnectionManager=t
},process:function(e){return this.serverConnectionManager.testAllConnections(e)},logRescheduledJob:function(t,i){e.prototype.logRescheduledJob.call(this,t,{jobName:"connection tests",subjectName:t.data.get("friendlyName"),delay:i.delay})}});return t}),define("plex/base/utils/workers/PessimisticServerRetryWorker",["plex/base/utils/workers/BaseServerRetryWorker"],function(e){"use strict";var t=e.extend({minDelay:3e3,maxDelay:6e5,schedule:function(e,t){return Math.max(Math.min(Math.floor(1.15*t),this.maxDelay),this.minDelay)
}});return t}),define("plex/base/utils/workers/OptimisticServerRetryWorker",["plex/base/utils/workers/BaseServerRetryWorker"],function(e){"use strict";var t=e.extend({minDelay:500,maxJobAge:12e4,schedule:function(){return 2e3},timeout:function(e){var t=e.get("update");t.set("state","error")}});return t}),define("plex/base/managers/ServerConnectionManager",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/BaseClass","plex/base/utils/parser","plex/base/mixins/eventMixin","plex/base/models/config","plex/base/utils/workers/PessimisticServerRetryWorker","plex/base/utils/workers/OptimisticServerRetryWorker","plex/base/adapters/loggerAdapter"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";
var u=s.extend({mixins:r,browserConnectionChangeDelay:2e3,initialize:function(i){e.bindAll(this,"onBrowserConnectionChange","onConnectionTestSuccess","onConnectionTestError"),this.servers=i.servers,this.listenTo(this.servers,{add:this.onServerAdd,remove:this.onServerRemove,reset:this.onServersReset,"error:connection":this.onServerConnectionError,"change:connections":this.onServerConnectionsChange,"change:accessToken":this.onServerAccessTokenChange,"change:connected":this.onServerConnectedChange}),this.listenTo(n,{"test:servers":this.testAllServers,"test:server":this.testAllConnections}),t(window).on("online",this.onBrowserConnectionChange),t(window).on("offline",this.onBrowserConnectionChange),this.pessimisticServerRetryWorker=new l(this),this.optimisticServerRetryWorker=new c(this),this.testAllPendingConnections()
},testAllServers:function(){this.servers.each(this.testAllConnections,this)},testAllConnections:function(t){return this.resetServerAvailability(t),e.each(t.connections,function(e){e.available=null,this.testConnection(t,e)},this),t.populatePromise},testAllPendingConnections:function(){this.servers.each(this.testPendingConnections,this)},testPendingConnections:function(t){var i=e.where(t.connections,{pending:!0});e.each(i,function(e){this.testConnection(t,e)},this)},testConnection:function(t,i){if(i.pending=!1,e.isFunction(t.testConnection))return void t.testConnection(i);
var s={server:t,connection:i};return!o.get("allowMixedContent")&&t.useHostedHttps&&"http"===i.scheme?void this.onConnectionTestError(t,i):void n.trigger("command","testServerConnection",s,e.bind(function(e){e.done(this.onConnectionTestSuccess),e.fail(this.onConnectionTestError)},this))},findBestConnection:function(t){var i=e.where(t.connections,{available:!0}),n=e.reduce(i,function(e,t){return e?!e.isSecure&&t.isSecure?t:!e.isLocalAddress&&t.isLocalAddress?t:!e.isLoopbackAddress&&t.isLoopbackAddress?t:e:t
});return n},resolveServer:function(t,i){i=e.extend({},i,{connected:!0,available:!0,authorized:!0}),t.populatePromise.resolveWith(t,[t,i]),t.set(i),this.removeUnavailableServer(t)},rejectServer:function(t,i,n){var s=t.get("friendlyName"),a=e.extend({connected:!1,available:!1,authorized:!1},n);a.available?(d.warn("Authorization for "+s+" failed"),this.removeUnavailableServer(t)):(d.warn("All connections for "+s+" failed"),this.addUnavailableServer(t)),t.populatePromise.rejectWith(t,[t,i]),t.set(a)
},resetServerAvailability:function(e){e.resetPopulatePromise(t.Deferred()),e.set({available:null,authorized:null})},addUnavailableServer:function(e){var t=e.get("update");t&&"installing"===t.get("state")?this.optimisticServerRetryWorker.add(e):this.pessimisticServerRetryWorker.add(e)},removeUnavailableServer:function(e){this.pessimisticServerRetryWorker.remove(e),this.optimisticServerRetryWorker.remove(e)},abortConnectionTests:function(t){var i=t.connections;e.each(i,function(e){e.test&&"pending"===e.test.state()&&(e.aborting=!0,e.test.abort(),e.aborting=!1)
})},onServerAdd:function(e){e.connections.length&&this.testPendingConnections(e)},onServerRemove:function(e){this.abortConnectionTests(e),this.removeUnavailableServer(e)},onServersReset:function(t,i){var n=i.previousModels;e.each(n,function(e){t.contains(e)||(this.abortConnectionTests(e),this.removeUnavailableServer(e))},this)},onServerConnectionError:function(e){this.testAllConnections(e)},onServerConnectionsChange:function(e){this.testPendingConnections(e)},onServerAccessTokenChange:function(e,t){!e.get("cloud")&&t&&this.testAllConnections(e)
},onServerConnectedChange:function(e,t){if(null!=t&&null!=e.previous("connected")&&!e.get("cloud")){var s;s=t?i("Found {1}",e.get("friendlyName")):i("{1} went away",e.get("friendlyName")),n.trigger("show:status",e,s)}},onBrowserConnectionChange:function(){d.info("Online status: "+window.navigator.onLine),clearTimeout(this.browserConnectionChangeTimeout),this.browserConnectionChangeTimeout=setTimeout(e.bind(this.testAllServers,this),this.browserConnectionChangeDelay)},onConnectionTestSuccess:function(e,t,i){t.available=!0;
var n=this.findBestConnection(e);d.success("Setting active connection for "+e.get("friendlyName")+" ("+e.url(n)+")"),e.set({activeConnection:n,relayed:!!n.relay}),this.resolveServer(e,i)},onConnectionTestError:function(i,n,s){if(!n.aborting&&(n.available=!1,!i.get("available")&&"pending"===i.populatePromise.state())){var r=!i.useHostedHttps||o.get("allowMixedContent");if(r&&"https"===n.scheme&&!i.get("cloud")&&!i.get("synced")){var l=e.pick(n,["accessToken","address","port"]);if(l.scheme="http",i.addConnection(l).pending)return
}var c=e.where(i.connections,{available:!1}),u=s&&(401===s.status||403===s.status||406===s.status),h=i.connections.length===c.length;if(u||h){if(i.id||!u)return void this.rejectServer(i,s,{available:u});var p=i.resolveUrl("/identity",{connection:n}),m=e.extend(i.getXHROptions(p),{timeout:5e3}),f=t.ajax(m);d.log("Requesting server identity at "+p),f=f.then(function(e){var i=a.parseXML(e),n=t.Deferred();return i&&i.machineIdentifier?n.resolve(i.machineIdentifier):n.reject(),n.promise()}),f.done(function(e){d.log("Server identity at "+p+" is "+e),i.set("machineIdentifier",e)
}),f.fail(function(){d.warn("Server identity is unavailable at "+p)}),f.always(e.bind(function(){this.rejectServer(i,s,{available:!0})},this))}}}});return u}),define("plex/base/initializers/serverInitializer",["underscore","jquery","plex/base/utils/dispatcher","plex/base/adapters/storageAdapter","plex/base/adapters/settingsAdapter","plex/base/managers/ServerManager","plex/base/managers/PrimaryServerManager","plex/base/managers/ServerConnectionManager","plex/base/models/appModel","plex/base/models/config","plex/base/models/server/serverStorageModel","plex/base/models/server/ServerModel"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=l.get("servers"),p=new r({servers:h}),m=(new o({servers:h}),new a({servers:h,savePrimaryOnly:c.get("serverSavePrimaryOnly")}),{init:function(){h.resetPopulatePromise(t.Deferred()),p.lastPrimaryServerID=d.get("lastPrimaryServerID"),p.checkPendingServers(),n.get("myPlexAccessToken").done(this.initPersistedServers),this.initCloudServer(),this.initBundledServer()},initPersistedServers:function(t){var i=d.get("users"),n=e.findWhere(i,{accessToken:t});if(n){var s=n.servers,a=[];e.each(s,function(t){var i=t.connections;
if(e.isEmpty(i))return void a.push(t);var n=l.get("user"),s=t.sources,r=e.difference(s,e.without(s,"bundle",n.server.id));if(e.isEmpty(r))return void a.push(t);var o=e.omit(t,"connections");o.sources=r;var c=new u(o,{parent:l});h.add(c),e.each(i,function(i){var n=e.clone(i);n.accessToken=t.accessToken,c.addConnection(n)})}),a.length&&(e.each(a,function(t){s.splice(e.indexOf(s,t),1)}),d.save())}},initCloudServer:function(){var e=h.findWhere({cloud:!0}),t=e.addConnection({scheme:c.get("myPlexScheme")||s.get("myPlexScheme")||"https",address:c.get("myPlexUrl")||s.get("myPlexUrl")||"plex.tv"});
e.set("activeConnection",t)},initBundledServer:function(){var t=c.get("primaryServer");if(t||c.get("bundled")){var i,n={parent:l,source:"bundle"},s={bundled:!0};if(t)n.parse=!0,e.extend(s,t);else{var a,r=window.location.protocol.replace(":",""),o=window.location.hostname;a="production"===c.get("env")?window.location.port:"32400",i={scheme:r,address:o,port:a,bundled:!0}}var d=new u(s,n);h.add(d),i&&d.addConnection(i)}}});return i.on("initialize:servers",e.bind(m.init,m)),m}),define("hb!templates/desktop/alerts/ServerUpdateAlertBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n  <a class="download-link link" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Download now",s):p.call(e,"t","Download now",s)))+"</a>\n"}function r(e,t){var n,s,a;return a={hash:{},inverse:g.program(6,l,t),fn:g.program(4,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.state,"downloaded",a):p.call(e,"if_eq",e&&e.state,"downloaded",a),s||0===s?s:""}function o(e,t){var n,s,a="";return a+='\n  <a class="install-link link" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Install now",s):p.call(e,"t","Install now",s)))+"</a>\n"
}function l(e,t){var n,s,a="";return a+='\n  <a class="link" href="',(n=i.downloadURL)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadURL,n=typeof n===f?n.call(e,{hash:{},data:t}):n),a+=m(n)+'" target="_blank">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Download now",s):p.call(e,"t","Download now",s)))+"</a>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p=i.helperMissing,m=this.escapeExpression,f="function",g=this;return h+='<button type="button" class="close-btn btn-link"><i class="glyphicon remove-2"></i></button>\n\n<span class="message">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"A Plex Media Server update is available!",u):p.call(t,"t","A Plex Media Server update is available!",u)))+"</span>\n\n",u={hash:{},inverse:g.program(3,r,s),fn:g.program(1,a,s),data:s},c=i.if_eq||t&&t.if_eq,d=c?c.call(t,t&&t.state,"available",u):p.call(t,"if_eq",t&&t.state,"available",u),(d||0===d)&&(h+=d),h+="\n"
})}),define("hb!templates/desktop/alerts/AlertBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<button type="button" class="close-btn btn-link"><i class="glyphicon remove-2"></i></button>\n\n<span class="message">',(a=i.message)?a=a.call(t,{hash:{},data:s}):(a=t&&t.message,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"</span>\n"})}),define("plex/desktop/views/alerts/AlertBarView",["hb!templates/desktop/alerts/AlertBarView.tpl","marionette","plex/base/utils/dispatcher"],function(e,t,i){"use strict";
var n=t.ItemView.extend({className:"alert-bar",template:e,events:{"click .close-btn":"onCloseClick"},initialize:function(e){this.alert=e.alert,this.alert&&this.$el.addClass(this.alert.type)},hide:function(){i.trigger("hide:bar","alertbar")},serializeData:function(){return this.alert},onCloseClick:function(e){e.preventDefault(),this.hide()}});return n}),define("plex/desktop/views/alerts/ServerUpdateAlertBarView",["hb!templates/desktop/alerts/ServerUpdateAlertBarView.tpl","underscore","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/alerts/AlertBarView"],function(e,t,i,n,s,a,r){"use strict";
var o=r.extend({className:"alert-bar notify",template:e,events:t.extend({"click .download-link":"onDownloadClick","click .install-link":"onInstallClick"},r.prototype.events),initialize:function(){this.server=this.model.server},serializeData:function(){var e=a.get("user").server;return{state:this.model.get("state"),downloadURL:this.model.get("downloadURL")||e.get("appsUrl")}},onDownloadClick:function(e){e.preventDefault(),s.execute("checkForServerUpdates",{server:this.server,download:!0,initialState:"downloading"}),i.trigger("navigate","serverSettings",{serverID:this.server.id})
},onInstallClick:function(e){e.preventDefault(),this.model.set("shouldInstall",!0),i.trigger("navigate","serverSettings",{serverID:this.server.id})},onCloseClick:function(){r.prototype.onCloseClick.apply(this,arguments);var e=this.model.get("version")||"unknown";n.save("serverUpdateDismissedVersion",e)}});return o}),define("hb!templates/desktop/alerts/WebUpdateAlertBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <a class="download-link link" href="#">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Download now",s):u.call(e,"t","Download now",s)))+"</a>\n"
}function r(e,t){var n,s,a="";return a+='\n  <a class="refresh-link link" href="#">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Refresh to apply",s):u.call(e,"t","Refresh to apply",s)))+"</a>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return d+='<button type="button" class="close-btn btn-link"><i class="glyphicon remove-2"></i></button>\n\n<span class="message">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"A web app update is available!",c):u.call(t,"t","A web app update is available!",c)))+"</span>\n\n",c={hash:{},inverse:p.program(3,r,s),fn:p.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.state,"available",c):u.call(t,"if_eq",t&&t.state,"available",c),(l||0===l)&&(d+=l),d+="\n"
})}),define("plex/desktop/views/alerts/WebUpdateAlertBarView",["hb!templates/desktop/alerts/WebUpdateAlertBarView.tpl","underscore","plex/base/commands/commands","plex/desktop/views/alerts/AlertBarView"],function(e,t,i,n){"use strict";var s=n.extend({className:"alert-bar notify",template:e,events:t.extend({"click .download-link":"onDownloadClick","click .refresh-link":"onRefreshClick"},n.prototype.events),serializeData:function(){return{state:this.options.state}},onDownloadClick:function(e){e.preventDefault(),i.execute("installBundleUpdates"),this.hide()
},onRefreshClick:function(e){e.preventDefault(),window.location.reload(!0)}});return s}),define("plex/desktop/managers/ServerUpdateManager",["underscore","plex/base/utils/BaseClass","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/mixins/eventMixin","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/config","plex/desktop/views/alerts/ServerUpdateAlertBarView","plex/desktop/views/alerts/WebUpdateAlertBarView"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=t.extend({mixins:s,bundleUpdatesDelay:36e5,initialize:function(){e.bindAll(this,"checkForBundleUpdates"),this.listenTo(r,{"change:primaryServer":this.onPrimaryServerChange,"change:updateState":this.onWebUpdateStateChange})},isLastHistoryEntry:function(){var t=r.get("history"),i=e.last(t);return!(!i||!i.indexOf("fragment"))},isLastDismissedVersion:function(e){var t=e.get("version")||"unknown";return t===n.get("serverUpdateDismissedVersion")},checkForServerUpdates:function(e){var t=e.get("update");
e.supports("updater")?t.fetch().then(function(){a.execute("checkForServerUpdates",{server:e,download:!1})}):this.isLastDismissedVersion(t)||i.trigger("show:bar","alertbar",new l({model:t}))},checkForBundleUpdates:function(){a.execute("checkForBundleUpdates"),this.bundleUpdatesTimeout=setTimeout(this.checkForBundleUpdates,this.bundleUpdatesDelay)},onPrimaryServerChange:function(e,t){var i=r.previous("primaryServer");return i&&this.stopListening(i.get("update")),!t||t.get("shared")?void clearTimeout(this.bundleUpdatesTimeout):(this.listenTo(t.get("update"),"change:state",this.onServerUpdateStateChange),this.checkForServerUpdates(t),void(o.get("bundled")&&!this.bundleUpdatesTimeout&&(this.bundleUpdatesTimeout=setTimeout(this.checkForBundleUpdates,this.bundleUpdatesDelay))))
},onWebUpdateStateChange:function(e,t){this.isLastHistoryEntry("/settings")||/^(available|downloaded)$/.test(t)&&i.trigger("show:bar","alertbar",new c({state:t}))},onServerUpdateStateChange:function(e,t){this.isLastDismissedVersion(e)||this.isLastHistoryEntry("/settings/server")||/^(available|downloaded|notify)$/.test(t)&&i.trigger("show:bar","alertbar",new l({model:e}))}});return d}),define("plex/desktop/initializers/desktopServerInitializer",["plex/base/initializers/serverInitializer","plex/desktop/managers/ServerUpdateManager","plex/base/models/appModel"],function(e,t,i){"use strict";
var n=i.get("servers"),s=(new t({servers:n}),{init:function(){e.init()}});return s}),define("plex/base/routes/BaseRouter",["underscore","backbone","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/adapters/analyticsAdapter"],function(e,t,i,n,s,a){"use strict";var r=i.AppRouter.extend({initialize:function(){this.uniqueRoutes=e.uniq(e.values(this.appRoutes)),this.fragments=e.invert(this.appRoutes),this.listenTo(this,"route",this.onRoute),this.listenTo(n,"navigate",this.onNavigate)
},resolveUrlFragment:function(t,i){var n=t.match(/:\w+/g);return n&&e.each(n,function(e){var n=e.slice(1),s=i[n];if(null==s){var a=new RegExp("\\([^\\)]*"+e+"[^\\)]*\\)","g");t=t.replace(a,"")}else t=t.replace(e,encodeURIComponent(s))}),t.replace(/\(|\)/g,"")},onRoute:function(i){var n=s.get("history"),r=s.get("forwardHistory"),o=t.history.getFragment();o===r[0]?n.push(r.shift()):o!==e.last(n)&&(n.push(o),r.splice(0)),a.trackView(i),s.trigger("change:history",s,n)},onNavigate:function(t,i){if(-1!==e.indexOf(this.uniqueRoutes,t)){i||(i={});
var n=!1;if(null!=i.silent&&(n=i.silent,delete i.silent),null==i.trigger&&(i.trigger=!0),n)this.controller[t].apply(this.controller,e.values(i));else{var s=this.resolveUrlFragment(this.fragments[t],i);this.navigate(s,{trigger:i.trigger,replace:i.replace})}}}});return r}),define("plex/base/routes/BaseAppRouter",["underscore","backbone","plex/base/utils/dispatcher","plex/base/routes/BaseRouter","plex/base/models/appModel"],function(e,t,i,n,s){"use strict";var a=n.extend({initialize:function(){n.prototype.initialize.apply(this,arguments),this.listenTo(i,{"navigate:back":this.onNavigateBack,"navigate:forward":this.onNavigateForward,"navigate:refresh":this.onNavigateRefresh})
},onNavigateBack:function(){var t=s.get("history"),i=s.get("forwardHistory");return t.length<2?this.navigate("",{trigger:!0}):(i.unshift(t.pop()),void this.navigate(e.last(t),{trigger:!0}))},onNavigateForward:function(){var e=s.get("forwardHistory");e.length&&this.navigate(e[0],{trigger:!0})},onNavigateRefresh:function(){t.history.loadUrl(t.history.getFragment())}});return a}),define("plex/base/models/channel/ChannelModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/library/MetadataCollection"],function(e,t,i,n){"use strict";
var s=i.extend({idAttribute:"key",subcollections:["Directory","Video","Track","Photo","Artist","Album","Playlist"],url:function(){return this.id?this.id:"/:/plugins/"+this.get("identifier")+"/root"},initialize:function(){this.set("items",new n([],{server:this.server,channel:this.channel||this,parent:this,skipCache:!0}))},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseBoolean(n,["installed","noCache","allowSync","hasPrefs","hasStoreServices","share"]),t.parseInteger(n,["size","lastAccessedAt"]),t.parseArray(n,"Metadata"),n
},parse:function(t){if(e.isString(t)){var i=this.subcollections.join("|"),n=new RegExp("<("+i+")","g"),s=new RegExp("</("+i+")>","g");t=t.replace(n,'<Metadata elementName="$1"'),t=t.replace(s,"</Metadata>")}var a=this.convert(t),r=this.toJSON();if(r&&(r.key&&(a.key=r.key),r.identifier&&(a.identifier=r.identifier)),"none"===a.key&&delete a.key,a.title2?(a.title=a.title2,delete a.title2):a.title1?(a.title=a.title1,delete a.title1):a.name&&(a.title=a.name,delete a.name),a.prefsKey&&(a.settingsKey=a.prefsKey,delete a.prefsKey),a.key){var o=/^\/(\w+)\//,l=a.key.match(o);
l&&(a.type=l[1])}for(var c=a.Metadata.length-1;c>-1;c--){var d=a.Metadata[c];d.isChannel=!0,d.allowSync=a.allowSync,a.identifier&&(d.identifier=a.identifier),a.mediaTagPrefix&&(d.mediaTagPrefix=a.mediaTagPrefix),a.mediaTagVersion&&(d.mediaTagVersion=a.mediaTagVersion),d.settings?(a.settingsKey=d.key,a.Metadata.splice(c,1)):d.search&&(a.searchKey=d.key,a.Metadata.splice(c,1))}var u=this.get("items");return u&&(u.reset({Metadata:a.Metadata},{parse:!0}),delete a.Metadata),a}});return s}),define("plex/base/models/library/HubCollection",["underscore","plex/base/utils/parser","plex/base/utils/formatters/stringUtil","plex/base/models/BaseCollection","plex/base/models/library/HubModel"],function(e,t,i,n,s){"use strict";
var a=n.extend({model:s,subcollections:["Playlist","Directory","Video","Track","Photo","Hub"],url:function(){var t="/hubs";if(this.section&&(t+="/sections/"+this.section.id),this.excludes&&this.excludes.length>0){var n=e.map(this.excludes,function(e){return"exclude"+i.upperCaseFirstLetter(e)+"=1"});t+="?"+n.join("&")}return t},initialize:function(e,t){this.excludes=t&&t.excludes},populate:function(){return this.populatePromise&&"pending"!==this.populatePromise.state()?this.fetch():n.prototype.populate.apply(this,arguments)
},fetch:function(t){t||(t={});var i=e.clone(t);if(this.populatePromise&&"resolved"===this.populatePromise.state()){i.remove=!1;var s=e.result(this,"url");s+=s.indexOf("?")>-1?"&":"?",s+="onlyTransient=1",i.url=s}return n.prototype.fetch.call(this,i)},parse:function(i){return e.isString(i)&&(i=t.replaceXMLElementNames(i,this.subcollections,"Metadata")),this.convert(i,"Metadata")}});return a}),define("plex/base/routes/BaseController",["underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/utils/xhrTracker","plex/base/models/appModel","plex/base/models/library/MetadataModel","plex/base/models/channel/ChannelModel","plex/base/models/library/HubCollection"],function(e,t,i,n,s,a,r,o){"use strict";
var l,c=!1,d=i.Controller.extend({populateView:function(e){e||(e={}),n.trigger("show:loading"),l&&"pending"===l.state()&&(c=!0),s.abortAll("page");var i={options:e},a=this.populateServer(e,i);return e.primaryServer&&(a=this.populatePrimaryServer(a,i)),e.sectionID&&(a=this.populateSection(e,a,i)),e.key&&(a=this.populateMetadata(e,a,i)),e.channelID&&(a=this.populateChannel(e,a,i)),e.channelKey&&(a=this.populateChannelMetadata(e,a,i)),a=a.then(function(){return t.Deferred().resolve(i)},function(){return c?c=!1:n.trigger("navigate","unauthorized",{result:i,silent:!0}),t.Deferred().reject(i)
}),l=a,a},populateServer:function(e,t){var i=e.serverID;if(!i)return this.findServers();var n=this.findServer(i);return n=n.then(function(e){return t.server=e,e.populate()})},findServers:function(){var i=t.Deferred(),n=a.get("servers");if(this.hasAuthorizedServer())return i.resolve().promise();var s=e.bind(function(e,t){t?i.resolve():this.hasAuthorizedServer()===!1&&i.reject()},this);return n.on("change:authorized",s),n.populate().always(e.bind(function(){"pending"===i.state()&&this.hasAuthorizedServer()===!1&&i.reject()
},this)),i.always(function(){n.off("change:authorized",s)}),i.promise()},hasAuthorizedServer:function(){var e=a.get("servers");if(e.findWhere({authorized:!0}))return!0;var t=e.every(function(e){return e.get("authorized")===!1});return t?!1:null},findServer:function(e){function i(t){t.id===e&&r.resolve(t)}function s(t,i){i===e&&r.resolve(t)}var r=t.Deferred(),o=a.get("servers"),l=o.get(e);if(!l&&0===e.indexOf("transient")){var c=a.get("transientServer");c&&c.id===e?l=c:n.trigger("navigate:refresh:dashboard")
}return l?r.resolve(l).promise():(o.on("add",i),o.on("change:machineIdentifier",s),o.populate().always(function(){"pending"===r.state()&&r.reject()}),r.always(function(){o.off("add",i),o.off("change:machineIdentifier",s)}),r.promise())},populatePrimaryServer:function(e,i){return e=e.then(function(){function e(t,s){a.off("change:primaryServer",e),s?(i.server=s,n.resolve()):n.reject()}var n=t.Deferred(),s=a.get("primaryServer");return s?(i.server=s,n.resolve().promise()):s===!1?n.reject().promise():(a.on("change:primaryServer",e),n.promise())
})},populateSection:function(e,i,n){return i=i.then(function(){return n.server.get("sections").populate()}),i=i.then(function(i){var s=n.item,a=e.sectionID;if(s&&(a=s.get("librarySectionID"),!a||n.server.get("synced")))return t.Deferred().resolve();var r=i.get(a);if(!r)return t.Deferred().reject();if(n.section=r,s){s.section=r;var o=function(e){e&&(e.section=r,e.each(function(e){e.section=r}))};o(s.get("children")),o(s.get("extras"))}return t.Deferred().resolve(r)})},populateMetadata:function(t,i,n){return i=i.then(function(){var i=new r({key:t.key},{server:n.server});
return n.item=i,i.fetch({scope:"page",data:e.extend({checkFiles:"1",includeExtras:"1",includeRelated:"1",includeRelatedCount:"0",includeOnDeck:"1"},t.populateData)})}),i=this.populateSection(t,i,n)},populateChannel:function(e,t,i){return t=t.then(function(){var t=e.channelID,n={};/^\/\w+\//.test(t)?n.key=t:n.identifier=t;var s=new o(n,{server:i.server});return i.channel=s,s.fetch({scope:"page"})})},populateChannelMetadata:function(e,t,i){return t=t.then(function(){var t=new o({key:e.channelKey},{server:i.server,channel:i.channel});
return i.channelItem=t,t.fetch({scope:"page"})})}});return d}),define("plex/base/routes/BaseAppController",["underscore","plex/base/models/appModel","plex/base/routes/BaseController","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";var s=i.extend({initialize:function(){e.bindAll(this,"viewFor")},viewFor:function(e,t){var i=this.viewsByType[e];if(i)return new i(t);throw new Error("No view defined for "+e)},login:function(){var e=this.viewFor,i=t.get("servers"),s=i.findWhere({cloud:!0});
n.trigger("show:loading"),s.populate().done(function(){n.trigger("navigate","dashboard")}).fail(function(){var t=s.get("available")?e("signIn"):e("unavailable",{model:s});n.trigger("show:view",t)})},error:function(){n.trigger("show:view",this.viewFor("notFound",{type:"404"}))},unauthorized:function(t){var i=e.some(this.getUnauthorizedHandlers(),function(e){return e.call(this,t)},this);i||n.trigger("show:view",this.viewFor("notFound",{type:"media"}))},getUnauthorizedHandlers:function(){return[this.handleAuthorized,this.handleServer,this.handleChannelError]
},handleAuthorized:function(){var e=!t.get("servers").findWhere({authorized:!0});return e&&this.populateServersThenRecover(),e},handleServer:function(e){var i,s,a=this.viewFor,r=e.options,o=e.server,l=t.get("servers").findWhere({cloud:!0});return r.primaryServer||r.serverID?(!o&&r.primaryServer?s=a("serverRequired"):o?o.get("available")?o.get("authorized")||"resolved"!==l.populatePromise.state()?o.get("authorized")||(i=this.populateServersThenRecover()):s=a("unauthorized"):s=a("unavailable",{model:o}):s=a("notFound",{type:"server"}),s&&n.trigger("show:view",s),!(!s&&!i)):!1
},handleChannelError:function(e){var t=!!e.options.channelID;return t&&n.trigger("show:view",this.viewFor("channelError")),t},populateServersThenRecover:function(){var e=t.get("servers"),i=e.findWhere({cloud:!0}),s=this.viewFor;return e.populate().done(function(){i.get("authorized")?n.trigger("navigate:refresh"):n.trigger("navigate","login",{silent:!0})}).fail(function(){n.trigger("show:view",s("unavailable",{model:i}))})}});return s}),define("hb!templates/desktop/DesktopAppView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div id="content" class="scroll-container dark-scrollbar"></div>\n<div class="scroll-shadow transition-out"></div>\n'
})}),define("hb!templates/desktop/LoadingView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a="";return a})}),define("plex/desktop/views/LoadingView",["hb!templates/desktop/LoadingView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({className:"loading",template:e});return i}),define("hb!templates/desktop/BackgroundView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="background transition-out"></div>\n'
})}),define("plex/desktop/views/BackgroundView",["hb!templates/desktop/BackgroundView.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/adapters/loggerAdapter","plex/base/views/images/BaseImage"],function(e,t,i,n,s,a){"use strict";var r=i.ItemView.extend({className:"background-container",template:e,ui:{background:".background"},onlyAfterRender:["onTransitionIn","onTransitionOut","onImageLoad"],initialize:function(){t.bindAll(this,"onImageLoad"),this.image=new a({width:1280,height:720}),this.listenTo(n,"show:background",this.onTransitionIn),this.listenTo(n,"hide:background",this.onTransitionOut)
},load:function(e){if(!this.model)return void s.warn("A background cannot be loaded without a model, current key: "+this.currentKey);if(this.currentBackground!==e||!t.isEmpty(this.imageFilters)||this.image.hasFilters()){if(this.currentBackground=e,!e)return void this.ui.background.addClass("transition-out");this.image.server=this.model.server,this.image.setFilters(this.imageFilters),this.image.load(e,!0).done(this.onImageLoad)}},onClose:function(){this.image.close()},onTransitionIn:function(e){return this.model&&this.model.id===e.model.id?void this.references++:(this.references=1,this.model=e.model,this.listenTo(this.model,"change:art",this.onArtChange),this.imageFilters=e.imageFilters||{},this.currentKey=this.model.get("key"),this.ui.background.toggleClass("dim",!!e.dim),void this.load(this.model.get("art")))
},onTransitionOut:function(e){if(this.model&&this.model.id===e.id){if(this.references>1)return void this.references--;this.image.cancel(),this.stopListening(this.model),this.model=null,this.currentBackground=null,this.ui.background.addClass("transition-out")}},onArtChange:function(e,t){this.load(t)},onImageLoad:function(e){this.currentBackground&&this.ui.background.css("background-image","url("+e+")").removeClass("transition-out")}});return r}),define("hb!templates/desktop/alerts/Alert",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"circle-ok"
}function r(){return"circle-exclamation-mark"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h=i.helperMissing,p="function";return d+='<button class="close-btn btn-link"><i class="glyphicon remove-2"></i></button>\n\n<i class="alert-icon glyphicon ',c={hash:{},inverse:u.program(3,r,s),fn:u.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.type,"success",c):h.call(t,"if_eq",t&&t.type,"success",c),(l||0===l)&&(d+=l),d+='"></i>\n<h4>',(l=i.message)?l=l.call(t,{hash:{},data:s}):(l=t&&t.message,l=typeof l===p?l.call(t,{hash:{},data:s}):l),(l||0===l)&&(d+=l),d+="</h4>\n"
})}),define("plex/desktop/views/alerts/Alert",["hb!templates/desktop/alerts/Alert.tpl","underscore","jquery","marionette"],function(e,t,i,n){"use strict";var s=n.ItemView.extend({className:"alert transition-in",template:e,alertDuration:2e3,transitionDuration:500,events:{mouseenter:"onMouseEnter",mouseleave:"onMouseLeave","click .close-btn":"onCloseClick"},initialize:function(e){t.isString(e)&&(e={message:e}),this.type=e.type,this.message=e.message,"success"===this.type?this.$el.addClass("has-success"):"error"===this.type&&this.$el.addClass("has-error")
},serializeData:function(){var e=t(this.message.split("\n")).compact().map(function(e){return i.trim(t.escape(e))}),n=e.length>1?"<p>"+e.join("</p><p>")+"</p>":e[0];return{type:this.type,message:n}},hide:function(){this.hiding=!0,this.$el.addClass("transition-out"),setTimeout(t.bind(function(){this.close()},this),500)},onAfterRender:function(){this.$el.triggerReflow(),this.$el.removeClass("transition-in"),this.hideTimeout=setTimeout(t.bind(this.hide,this),this.alertDuration)},onMouseEnter:function(){this.hiding||(this.hideTimeout=clearTimeout(this.hideTimeout))
},onMouseLeave:function(){this.hideTimeout=setTimeout(t.bind(this.hide,this),this.alertDuration/2)},onCloseClick:function(e){e.preventDefault(),this.hiding||this.close()}});return s}),define("hb!templates/desktop/alerts/StatusAlert",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<i class="alert-icon glyphicon cardio"></i>\n\n<span class="status"></span>\n'})}),define("plex/desktop/views/alerts/StatusAlert",["hb!templates/desktop/alerts/StatusAlert.tpl","underscore","marionette","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";
var s=i.ItemView.extend({className:"alert alert-status transition-out",template:e,coolDown:!1,alertDuration:5e3,coolDownDuration:5e3,ui:{status:".status"},events:{mouseover:"onMouseOver"},onlyAfterRender:["onShowStatus"],initialize:function(){t.bindAll(this,"hide"),this.listenTo(n,"show:status",this.onShowStatus)},hide:function(){this.$el.addClass("transition-out")},onShowStatus:function(e,t){this.coolDown||(this.server=e,this.ui.status.text(t),this.$el.removeClass("transition-out"),this.inactivityTimeout=clearTimeout(this.inactivityTimeout),this.inactivityTimeout=setTimeout(this.hide,this.alertDuration))
},onMouseOver:function(){this.inactivityTimeout=clearTimeout(this.inactivityTimeout),this.hide(),this.coolDown=!0,setTimeout(t.bind(function(){this.coolDown=!1},this),this.coolDownDuration)}});return s}),define("hb!templates/desktop/players/VideoPlayerView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="video-container">\n  <div class="video-controls-container"></div>\n  <div class="video-post-play-container"></div>\n  <div class="video-details-container"></div>\n</div>\n'
})}),define("plex/base/utils/types/extraTypes",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=t.extend({types:[{id:1,typeString:"trailer",title:"Trailer"},{id:2,typeString:"deletedScene",title:"Deleted Scene"},{id:3,typeString:"interview",title:"Interview"},{id:4,typeString:"musicVideo",title:"Music Video"},{id:5,typeString:"behindTheScenes",title:"Behind the Scenes"},{id:6,typeString:"scene",title:"Scene"},{id:7,typeString:"liveMusicVideo",title:"Live Music Video"},{id:8,typeString:"lyricMusicVideo",title:"Lyric Music Video"},{id:9,typeString:"concert",title:"Concert"}],initialize:function(){this.byID=e.reduce(this.types,function(e,t){return e[t.id]=t,e
},{}),this.byType=e.reduce(this.types,function(e,t){return e[t.typeString]=t,e},{})},getExtraType:function(e){return this.byID[e]},getExtraTypeByString:function(e){return this.byType[e]}});return new i}),define("plex/base/models/player/PlayerModel",["underscore","backbone","plex/base/utils/playerUtil"],function(e,t,i){"use strict";var n={item:null,media:null,part:null,url:null,subtitlesUrl:null,playQueue:null,transcodeServer:null,mediaIndex:-1,partIndex:-1,partCount:1,qualityIndex:null,videoStreamID:null,audioStreamID:null,subtitleStreamID:null,type:i.types.VIDEO},s={state:i.states.STOPPED,stopped:!0,paused:!1,playing:!1,buffering:!1,error:!1,errorMessage:null,ready:!1,loaded:!1,ended:!1,finished:!1,embedHtml:null,duration:0,position:0,offset:0,volume:100,startBuffer:0,endBuffer:0,percentBuffered:0,shuffle:!1,repeat:!1,directPlay:!1,videoDimensions:null,softSubtitlesFailed:!1},a={canPlayPause:!1,canStop:!1,canSeek:!1,canSetVolume:!1,canSetVideoStream:!1,canSetAudioStream:!1,canSetSubtitleStream:!1,canSetQuality:!1,canShuffle:!1,canRepeat:!1,canSkipPrevious:!1,canSkipNext:!1,showSeekBar:!1,showAudioStream:!1,showSubtitleStream:!1,showQuality:!1,showPlayQueue:!1,showMinimize:!1,showMaximize:!1,showEnterFullscreen:!1,showExitFullscreen:!1,forceWebkitVideoFullscreen:!1},r=t.Model.extend({itemDefaults:n,playerDefaults:s,controllerDefaults:a,defaults:e.extend({},n,s,a),initialize:function(){this.on("invalid",function(t,i){e.indexOf(i.keys,"duration")>-1&&(i.attrs.duration=Math.max(i.attrs.duration,0)),e.indexOf(i.keys,"position")>-1&&(i.attrs.position=Math.min(Math.max(i.attrs.position,0),i.attrs.duration)),e.indexOf(i.keys,"volume")>-1&&(i.attrs.volume=Math.min(Math.max(i.attrs.position,0),100)),t.set(i.attrs)
}),this.on("change:state",function(e,t){e.set({stopped:t===i.states.STOPPED,paused:t===i.states.PAUSED,playing:t===i.states.PLAYING,buffering:t===i.states.BUFFERING,error:t===i.states.ERROR}),t!==i.states.STOPPED&&e.set("ended",!1)}),this.on("change:position",function(e,t){var i=this.get("duration"),n=i?Math.min(Math.max(t/i*100,0),100):0;this.set("positionPercentage",n)})},validate:function(e){var t=[];return e.duration<0&&t.push("duration"),(e.position<0||e.position>e.duration)&&t.push("position"),(e.volume<0||e.volume>100)&&t.push("volume"),t.length?{keys:t,attrs:e}:void 0
}});return r}),function(e){"function"==typeof define&&define.amd?define("jquery.mousewheel",["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(e){function t(t){var r=t||window.event,o=l.call(arguments,1),c=0,u=0,h=0,p=0,m=0,f=0;if(t=e.event.fix(r),t.type="mousewheel","detail"in r&&(h=-1*r.detail),"wheelDelta"in r&&(h=r.wheelDelta),"wheelDeltaY"in r&&(h=r.wheelDeltaY),"wheelDeltaX"in r&&(u=-1*r.wheelDeltaX),"axis"in r&&r.axis===r.HORIZONTAL_AXIS&&(u=-1*h,h=0),c=0===h?u:h,"deltaY"in r&&(h=-1*r.deltaY,c=h),"deltaX"in r&&(u=r.deltaX,0===h&&(c=-1*u)),0!==h||0!==u){if(1===r.deltaMode){var g=e.data(this,"mousewheel-line-height");
c*=g,h*=g,u*=g}else if(2===r.deltaMode){var v=e.data(this,"mousewheel-page-height");c*=v,h*=v,u*=v}if(p=Math.max(Math.abs(h),Math.abs(u)),(!a||a>p)&&(a=p,n(r,p)&&(a/=40)),n(r,p)&&(c/=40,u/=40,h/=40),c=Math[c>=1?"floor":"ceil"](c/a),u=Math[u>=1?"floor":"ceil"](u/a),h=Math[h>=1?"floor":"ceil"](h/a),d.settings.normalizeOffset&&this.getBoundingClientRect){var y=this.getBoundingClientRect();m=t.clientX-y.left,f=t.clientY-y.top}return t.deltaX=u,t.deltaY=h,t.deltaFactor=a,t.offsetX=m,t.offsetY=f,t.deltaMode=0,o.unshift(t,c,u,h),s&&clearTimeout(s),s=setTimeout(i,200),(e.event.dispatch||e.event.handle).apply(this,o)
}}function i(){a=null}function n(e,t){return d.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120===0}var s,a,r=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],o="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],l=Array.prototype.slice;if(e.event.fixHooks)for(var c=r.length;c;)e.event.fixHooks[r[--c]]=e.event.mouseHooks;var d=e.event.special.mousewheel={version:"3.1.11",setup:function(){if(this.addEventListener)for(var i=o.length;i;)this.addEventListener(o[--i],t,!1);
else this.onmousewheel=t;e.data(this,"mousewheel-line-height",d.getLineHeight(this)),e.data(this,"mousewheel-page-height",d.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var i=o.length;i;)this.removeEventListener(o[--i],t,!1);else this.onmousewheel=null;e.removeData(this,"mousewheel-line-height"),e.removeData(this,"mousewheel-page-height")},getLineHeight:function(t){var i=e(t)["offsetParent"in e.fn?"offsetParent":"parent"]();return i.length||(i=e("body")),parseInt(i.css("fontSize"),10)
},getPageHeight:function(t){return e(t).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})}),define("plex/desktop/views/players/BasePlayerView",["underscore","jquery","backbone","marionette","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/utils/mediaUtil","plex/base/adapters/settingsAdapter","plex/base/adapters/playerControllerAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/player/PlayerModel","jquery.mousewheel"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=n.Layout.extend({events:{fullscreenchange:"onFullscreenChange",webkitfullscreenchange:"onFullscreenChange",mousewheel:"onMouseWheel"},shortcutListeners:function(){return{"shortcut:playPause":this.getListenerFor("playPause"),"shortcut:seekBackward":this.getListenerFor("seekBackward"),"shortcut:seekForward":this.getListenerFor("seekForward"),"shortcut:stepBackward":this.getListenerFor("stepBackward"),"shortcut:stepForward":this.getListenerFor("stepForward"),"shortcut:decreaseVolume":this.getListenerFor("decreaseVolume"),"shortcut:increaseVolume":this.getListenerFor("increaseVolume"),"shortcut:skipPrevious":this.getListenerFor("skipPrevious"),"shortcut:skipNext":this.getListenerFor("skipNext"),"shortcut:stop":this.getListenerFor("stop")}
},initialize:function(i){if(this.controller=i.controller,this.isNew=!i.controller,this.type=i.type,this.offset=i.offset,this.$el.addClass(this.type),this.isNew){var n=d.get("primaryPlayer");this.controller=l.getInstance(this.type),!this.model&&this.playQueue&&(this.model=this.playQueue.get("selectedItem")),this.playQueue=i.playQueue,this.playerModel=new u({item:this.model,playQueue:this.playQueue,volume:this.volumeSettingsKey?o.get(this.volumeSettingsKey):o.getInstance().defaults.volume,friendlyName:n?n.get("friendlyName"):null})
}else this.model=this.controller.model.get("item"),this.playQueue=this.controller.model.get("playQueue"),this.playerModel=this.controller.model;this.$document=t(document),this.$document.on("MSFullscreenChange",e.bind(this.onFullscreenChange,this)),this.$document.on("mozfullscreenchange",e.bind(this.onFullscreenChange,this))},addListeners:function(){this.listenTo(i.history,"route",this.onRouteChange),this.listenTo(d,"change:primaryPlayer",this.onPrimaryPlayerChange),this.listenTo(this.playerModel,{"change:item":this.onPlayerItemChange,"change:state":this.onPlayerStateChange,"change:volume":this.onPlayerVolumeChange,"change:finished":this.onPlayerFinishedChange}),this.controlsView&&this.listenTo(this.controlsView,{play:this.getListenerFor("play"),pause:this.getListenerFor("pause"),"change:position":this.getListenerFor("setPosition"),"change:volume":this.getListenerFor("setVolume"),enterFullscreen:this.enterFullscreen,exitFullscreen:this.exitFullscreen,previous:this.getListenerFor("skipPrevious"),next:this.getListenerFor("skipNext"),skip:this.getListenerFor("skipTo"),remove:this.getListenerFor("removeItem"),move:this.getListenerFor("moveItem"),minimize:this.getListenerFor("minimize"),maximize:this.getListenerFor("maximize"),stop:this.getListenerFor("stop"),"navigate:grandparent":this.getListenerFor("navigateToGrandparent"),"navigate:item":this.getListenerFor("navigateToItem")}),this.listenTo(s,e.result(this,"shortcutListeners"))
},startPlayback:function(e){e||(e={}),this.controller.load({model:this.playerModel,autoplay:e.autoplay,silent:this.isNowPlaying()})},continuePlayback:function(){},updatePageTitle:function(){var e=this.playerModel.get("state");if(e===a.states.STOPPED)return void(document.title="Plex");var t,i=this.playerModel.get("item"),n=i.get("type");if("episode"===n){var s=r.getSeasonEpisodeIndex({seasonIndex:i.get("parentIndex"),episodePrefix:" \xb7 E{1}",episodeIndex:i.get("index"),date:i.get("originallyAvailableAt"),noLeadingZero:!0});
t=i.get("grandparentTitle")+" - "+s}else if("track"===n){var o=i.get("originalTitle")||i.get("grandparentTitle");!o&&i.parent&&(o=i.parent.get("parentTitle")||i.parent.get("title")),t=o?o+" - "+i.get("title"):i.get("title")}else t=i.get("title");document.title=e===a.states.PLAYING||e===a.states.BUFFERING?"\u25b6 "+t:t},getListenerFor:function(t){return e.isFunction(this[t])?this[t]:e.bind(this.controller[t],this.controller)},minimize:function(){this.isSwitchingPlayers=!0,c.execute("playMedia",{item:this.model,controller:this.controller,useMiniPlayer:!0,isSwitchingPlayers:!0})
},maximize:function(){this.isSwitchingPlayers=!0,c.execute("playMedia",{item:this.model,controller:this.controller,isSwitchingPlayers:!0})},enterFullscreen:function(){var e=this.el.requestFullScreen||this.el.webkitRequestFullScreen||this.el.mozRequestFullScreen||this.el.msRequestFullscreen;e.call(this.el)},exitFullscreen:function(){var e=document.cancelFullScreen||document.webkitCancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen;e.call(document)},stop:function(){a.getElementByType(this.type);
this.controller.stop(),s.trigger("hide:player",this)},navigateToGrandparent:function(){var e=this.getNavigationGrandparentKey();this.navigateToLibraryItem(e)||this.navigateToChannelItem()},navigateToItem:function(){var e=this.getNavigationKey();this.navigateToLibraryItem(e)||this.navigateToChannelItem(e)},navigateToLibraryItem:function(e){return e&&this.model.isLibraryItem()?(s.trigger("navigate","details",{serverID:this.model.server.id,key:e}),!0):!1},navigateToChannelItem:function(e){var t=this.model.channel;
return t?(s.trigger("navigate","channel",{serverID:this.model.server.id,channelID:t.id?t.id:t.get("identifier"),key:e}),!0):!1},getNavigationGrandparentKey:function(){var e=this.model.get("grandparentKey");if(!e&&this.model.parent&&(e=this.model.parent.get("parentKey")),e)return e;var t=this.model.get("parentKey");return!t&&this.model.parent&&(t=this.model.parent.get("key")),t},getNavigationKey:function(){return this.model.get("key")},isNowPlaying:function(){var e=d.get("primaryPlayer");if(!e)return!1;
var t=e.get("nowPlaying");return!!t.get(this.model.get("ratingKey"))},canAutoplay:function(e){return e!==a.states.PAUSED},onRender:function(){this.isNew?this.startPlayback({autoplay:this.canAutoplay()}):this.continuePlayback()},onClose:function(){if(this.$document.off("MSFullscreenChange"),this.$document.off("mozfullscreenchange"),!this.isSwitchingPlayers&&(this.controller.stop(),!this.controller.model)){var e=this.model.server.get("playQueueManager"),t=e.getFor(this.model);t===this.playQueue&&e.remove(t.get("mediaType"))
}},onRouteChange:function(){this.isMini||s.trigger("hide:player",this)},onPrimaryPlayerChange:function(e,t){var i=this.playerModel.get("state"),n=this.playerModel.get("position"),s=this.controller.mediaElement;this.playerModel.set("ready",!1),this.playerModel.set("friendlyName",t?t.get("friendlyName"):null),this.controller.stop(),this.controller=l.getInstance(this.type),this.stopListening(),this.addListeners(),this.startPlayback({offset:n,autoplay:this.canAutoplay(i),mediaElement:s})},onPlayerItemChange:function(e,t){this.playQueue.set("selectedItem",t),this.model=this.playQueue.get("selectedItem"),this.updatePageTitle()
},onPlayerStateChange:function(){this.updatePageTitle()},onPlayerVolumeChange:function(e,t){this.volumeSettingsKey&&o.save(this.volumeSettingsKey,t)},onPlayerFinishedChange:function(e,t){if(t){var i=a.getElementByType(this.type);this.model.server.get("playQueueManager").remove(i),s.trigger("hide:player",this)}},onFullscreenChange:function(){var e=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);this.playerModel.set("showEnterFullscreen",!e),this.playerModel.set("showExitFullscreen",e)
},onMouseWheel:function(e){e.deltaY>0?s.trigger("shortcut:increaseVolume"):e.deltaY<0&&s.trigger("shortcut:decreaseVolume")}});return h}),define("hb!templates/desktop/modals/SelectMediaModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t,n){var s,a,c,d="";return d+='\n          <li class="striped-list-item select-list-item">\n            <a class="media" data-value="'+m((s=t,s=null==s||s===!1?s:s.index,typeof s===f?s.apply(e):s))+'" href="#">\n              ',c={hash:{},inverse:g.program(4,o,t),fn:g.program(2,r,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,n&&n.type,"videoResolution",c):p.call(e,"if_eq",n&&n.type,"videoResolution",c),(a||0===a)&&(d+=a),d+="\n\n              ",a=i["if"].call(e,e&&e.videoCodec,{hash:{},inverse:g.noop,fn:g.program(6,l,t),data:t}),(a||0===a)&&(d+=a),d+="\n            </a>\n          </li>\n        "
}function r(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=m((n=i.formatResolution||e&&e.formatResolution,n?n.call(e,e&&e.videoResolution,s):p.call(e,"formatResolution",e&&e.videoResolution,s)))+"\n              "}function o(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=m((n=i.formatBitrate||e&&e.formatBitrate,n?n.call(e,e&&e.bitrate,0,s):p.call(e,"formatBitrate",e&&e.bitrate,0,s)))+"\n              "}function l(e){var t,i="";return i+="\n                ("+m((t=e&&e.videoCodec,typeof t===f?t.apply(e):t))+")\n              "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p=i.helperMissing,m=this.escapeExpression,f="function",g=this;return h+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon adjust-alt"></i> ',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Select a Quality",u):p.call(t,"t","Select a Quality",u)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <ul class="list select-list">\n        ',d=i.each.call(t,t&&t.medias,{hash:{},inverse:g.noop,fn:g.programWithDepth(1,a,s,t),data:s}),(d||0===d)&&(h+=d),h+="\n      </ul>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/SelectModal",["underscore","jquery","plex/desktop/views/modals/BaseModal"],function(e,t,i){"use strict";var n=i.extend({className:"select-modal modal modal-sm fade",events:e.extend({"click a":"onClick"},i.prototype.events),initialize:function(){i.prototype.initialize.apply(this,arguments),this.promise=t.Deferred()},onRender:function(){i.prototype.onRender.apply(this,arguments)},onHide:function(){i.prototype.onHide.apply(this,arguments),this.promise.reject()},onClick:function(e){e.preventDefault(),this.promise.resolve(t(e.currentTarget).data("value")),this.hide()
}});return n}),define("plex/desktop/views/modals/SelectMediaModal",["hb!templates/desktop/modals/SelectMediaModal.tpl","underscore","plex/desktop/views/modals/SelectModal"],function(e,t,i){"use strict";var n=i.extend({name:"selectMediaModal",template:e,serializeData:function(){var e=this.model.get("Media"),i="videoResolution",n=t.uniq(t.pluck(e,i));return n.length<2&&(i="bitrate"),{medias:e,type:i}}});return n}),define("hb!templates/desktop/modals/SelectOffsetModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o,l="",c=i.helperMissing,d=this.escapeExpression,u="function";return l+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-arrow-right"></i> ',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Resume",o):c.call(t,"t","Resume",o)))+'</h4>\n    </div>\n\n    <div class="modal-body">\n      <ul class="list select-list">\n        <li class="striped-list-item select-list-item"><a class="offset" data-value="',(r=i.offset)?r=r.call(t,{hash:{},data:s}):(r=t&&t.offset,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+'" href="#">',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Resume from {1}",t&&t.formattedOffset,o):c.call(t,"t","Resume from {1}",t&&t.formattedOffset,o)))+'</a></li>\n        <li class="striped-list-item select-list-item"><a class="offset" data-value="0" href="#">',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Start from beginning",o):c.call(t,"t","Start from beginning",o)))+"</a></li>\n      </ul>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/SelectOffsetModal",["hb!templates/desktop/modals/SelectOffsetModal.tpl","plex/base/utils/formatters/dateTimeUtil","plex/desktop/views/modals/SelectModal"],function(e,t,i){"use strict";var n=i.extend({name:"selectOffsetModal",template:e,initialize:function(e){i.prototype.initialize.apply(this,arguments),this.offset=e.offset},serializeData:function(){return{offset:this.offset,formattedOffset:t.formatDuration(this.offset)}}});return n}),define("hb!templates/desktop/players/controls/VideoPlayerControlsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="video-background"></div>\n\n<video id="html-video" class="html-video"></video>\n<div class="video-subtitles-container"></div>\n\n<div class="flash-video">\n  <div id="flash-video-placeholder"></div>\n</div>\n\n<div class="video-image-overlays-region"></div>\n<div class="video-loading loading loading-inline"></div>\n\n<div class="alert-player alert-paused"><i class="glyphicon play"></i></div>\n<button class="video-overlay-btn"></button>\n<button class="player-close-btn btn-gray"><i class="glyphicon remove-2"></i></button>\n\n<div class="video-error-message-container">\n  <div class="video-error-message-center">\n    <div class="video-error-message"></div>\n    <div class="video-error-skip-message btn-link"></div>\n  </div>\n</div>\n\n<div class="video-controls-overlay video-controls-overlay-top">\n  <div class="video-controls-left">\n    <span class="video-title"></span>\n  </div>\n\n  <div class="player-dropdowns-container video-controls-right">\n    <button class="player-close-btn btn-link"><i class="glyphicon remove-2"></i></button>\n    <button class="btn-link share-btn pull-left"><i class="glyphicon share"></i></button>\n    <button class="btn-link recommend-btn pull-left"><i class="glyphicon share-alt"></i></button>\n  </div>\n</div>\n\n<div class="player-primary-player-name-container">\n  <span class="primary-player-name"></span>\n</div>\n\n<div class="player-scrub-preview-container"></div>\n<div class="video-controls-overlay video-controls-overlay-bottom">\n  <div class="video-controls-left">\n    <button class="previous-btn btn-link hidden"><i class="glyphicon fast-backward"></i></button>\n    <button class="play-btn btn-link hidden"><i class="glyphicon play"></i></button>\n    <button class="pause-btn btn-link hidden"><i class="glyphicon pause"></i></button>\n    <button class="next-btn btn-link hidden"><i class="glyphicon fast-forward"></i></button>\n  </div>\n\n  <div class="player-dropups-container video-controls-right">\n    <button class="enter-fullscreen-btn fullscreen-btn btn-link hidden"><i class="glyphicon resize-full"></i></button>\n    <button class="exit-fullscreen-btn fullscreen-btn btn-link hidden"><i class="glyphicon resize-small"></i></button>\n    <button class="minimize-btn btn-link"><i class="glyphicon chevron-down"></i></button>\n    <button class="volume-btn btn-link btn-link-lg hidden">\n      <i class="glyphicon volume-up"></i>\n      <i class="glyphicon volume-down"></i>\n      <i class="glyphicon mute"></i>\n    </button>\n    <div class="player-volume-slider-container"></div>\n  </div>\n\n  <div class="video-controls-center-wrapper">\n    <div class="video-controls-center">\n      <div class="seek-bar-container">\n        <span class="player-position"></span>\n        <span class="player-duration"></span>\n      </div>\n    </div>\n  </div>\n</div>\n\n<div class="video-player-poster media-poster"></div>\n'
})}),define("plex/base/models/player/UpNextCollection",["plex/base/utils/types/mediaTypes","plex/base/models/BaseCollection","plex/base/models/library/PlayQueueItemModel"],function(e,t,i){"use strict";var n=t.extend({model:i,windowSize:{audio:13,video:8},initialize:function(e){if(e)throw new Error("Models cannot be passed directly to an UpNextCollection.");this.collection=this.parent.get("playQueue").get("collection"),this.listenTo(this.collection,"reset sync",this._filter),this.listenTo(this.parent,"change:item",this._filter),this._filter()
},_filter:function(){var t=this.parent.get("item"),i=this.collection.indexOf(t),n=e.getChildMediaType(t.get("type")).element,s=this.collection.slice(i+1,i+this.windowSize[n]);this.set(s)}});return n}),define("hb!plex/base/views/components/player/ASSRendererView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a="";return a})}),function(e,t){var i=this;"object"==typeof exports&&"object"==typeof module?module.exports=t(i):"function"==typeof define&&define.amd?define("libjass",[],function(){return t(i)
}):"object"==typeof exports?exports.libjass=t(i):e.libjass=t(i)}(this,function(e){"use strict";return function(e){function t(n){if(i[n])return i[n].exports;var s=i[n]={exports:Object.create(null),id:n,loaded:!1};return e[n](s.exports,t),s.loaded=!0,s.exports}var i=Object.create(null);return t(0)}([function(e,t){var i=t(21),n=t(21);e.debugMode=n.debugMode,e.verboseMode=n.verboseMode;var s=t(30),a=t(30);e.Set=a.Set;var r=t(27),o=t(27);e.Map=o.Map;var l=t(29),c=t(29);e.Promise=c.Promise,e.DeferredPromise=c.DeferredPromise;
var d=t(33);e.webworker=d;var u=t(6);e.parts=u;var h=t(1);e.parser=h;var p=t(12);e.renderers=p;var m=t(22);e.ASS=m.ASS;var f=t(23);e.Dialogue=f.Dialogue;var g=t(25);e.ScriptProperties=g.ScriptProperties;var v=t(26);e.Style=v.Style;var y=t(24);e.BorderStyle=y.BorderStyle,e.Format=y.Format,e.WrappingStyle=y.WrappingStyle,Object.defineProperties(e,{debugMode:{get:function(){return i.debugMode},set:i.setDebugMode},verboseMode:{get:function(){return i.verboseMode},set:i.setVerboseMode},Set:{get:function(){return s.Set
},set:s.setImplementation},Map:{get:function(){return r.Map},set:r.setImplementation},Promise:{get:function(){return l.Promise},set:l.setImplementation}})},function(e,t){var i=t(3);e.parse=i.parse;var n=t(4);e.StreamParser=n.StreamParser,e.SrtStreamParser=n.SrtStreamParser,e.StringStream=n.StringStream,e.XhrStream=n.XhrStream},function(e,t){function i(e){var t=e.indexOf(":");if(-1===t)return null;var i=e.substr(0,t),n=e.substr(t+1).replace(/^\s+/,"");return{name:i,value:n}}function n(e,t){var n=i(e);
if(null===n)return null;var a=n.value.split(",");a.length>t.length&&(a[t.length-1]=a.slice(t.length-1).join(","));var r=new s.Map;return t.forEach(function(e,t){r.set(e,a[t])}),{type:n.name,template:r}}var s=t(27);e.parseLineIntoProperty=i,e.parseLineIntoTypedTemplate=n},function(e,t){function i(e,t){var i=new o(e,t);if(null===i.result||i.result.end!==e.length)throw a.debugMode&&console.error("Parse failed. %s %s %o",t,e,i.result),new Error("Parse failed.");return i.result.value}function n(e,t,i,n){o.prototype["parse_tag_"+e]=function(s){var a=this,r=new h(s);
if(null===a.read(r,e))return s.pop(),null;var o=i.call(a,r);if(null!==o)r.value=new t(o.value);else{if(n)return s.pop(),null;r.value=new t(null)}return r}}var s=t(6),a=t(21),r=t(27);e.parse=i;var o=function(){function e(e,t){this._input=e,this._parseTree=new h(null),this._result=l.get(t).call(this,this._parseTree)}return Object.defineProperty(e.prototype,"result",{get:function(){return this._result},enumerable:!0,configurable:!0}),e.prototype.parse_dialogueParts=function(e){var t=new h(e);for(t.value=[];this._haveMore();){var n=this.parse_enclosedTags(t);
if(null!==n)t.value.push.apply(t.value,n.value);else{var a=this.parse_newline(t)||this.parse_hardspace(t)||this.parse_text(t);if(null===a)return e.pop(),null;if(a.value instanceof s.Text&&t.value[t.value.length-1]instanceof s.Text){var r=t.value[t.value.length-1];t.value[t.value.length-1]=new s.Text(r.value+a.value.value)}else t.value.push(a.value)}}var o=!1;return t.value.forEach(function(e,n){e instanceof s.DrawingMode?o=0!==e.scale:e instanceof s.Text&&o&&(t.value[n]=new s.DrawingInstructions(i(e.value,"drawingInstructions")))
}),t},e.prototype.parse_enclosedTags=function(e){var t=new h(e);if(t.value=[],null===this.read(t,"{"))return e.pop(),null;for(var i=this._peek();this._haveMore()&&"}"!==i;i=this._peek()){var n=null;if(null!==this.read(t,"\\")&&(n=this.parse_tag_alpha(t)||this.parse_tag_iclip(t)||this.parse_tag_xbord(t)||this.parse_tag_ybord(t)||this.parse_tag_xshad(t)||this.parse_tag_yshad(t)||this.parse_tag_blur(t)||this.parse_tag_bord(t)||this.parse_tag_clip(t)||this.parse_tag_fade(t)||this.parse_tag_fscx(t)||this.parse_tag_fscy(t)||this.parse_tag_move(t)||this.parse_tag_shad(t)||this.parse_tag_fad(t)||this.parse_tag_fax(t)||this.parse_tag_fay(t)||this.parse_tag_frx(t)||this.parse_tag_fry(t)||this.parse_tag_frz(t)||this.parse_tag_fsp(t)||this.parse_tag_fsplus(t)||this.parse_tag_fsminus(t)||this.parse_tag_org(t)||this.parse_tag_pbo(t)||this.parse_tag_pos(t)||this.parse_tag_an(t)||this.parse_tag_be(t)||this.parse_tag_fn(t)||this.parse_tag_fr(t)||this.parse_tag_fs(t)||this.parse_tag_kf(t)||this.parse_tag_ko(t)||this.parse_tag_1a(t)||this.parse_tag_1c(t)||this.parse_tag_2a(t)||this.parse_tag_2c(t)||this.parse_tag_3a(t)||this.parse_tag_3c(t)||this.parse_tag_4a(t)||this.parse_tag_4c(t)||this.parse_tag_a(t)||this.parse_tag_b(t)||this.parse_tag_c(t)||this.parse_tag_i(t)||this.parse_tag_k(t)||this.parse_tag_K(t)||this.parse_tag_p(t)||this.parse_tag_q(t)||this.parse_tag_r(t)||this.parse_tag_s(t)||this.parse_tag_t(t)||this.parse_tag_u(t),null===n&&t.pop()),null===n&&(n=this.parse_comment(t)),null===n)return e.pop(),null;
n.value instanceof s.Comment&&t.value[t.value.length-1]instanceof s.Comment?t.value[t.value.length-1]=new s.Comment(t.value[t.value.length-1].value+n.value.value):t.value.push(n.value)}return null===this.read(t,"}")?(e.pop(),null):t},e.prototype.parse_newline=function(e){var t=new h(e);return null===this.read(t,"\\N")?(e.pop(),null):(t.value=new s.NewLine,t)},e.prototype.parse_hardspace=function(e){var t=new h(e);return null===this.read(t,"\\h")?(e.pop(),null):(t.value=new s.Text("\xa0"),t)},e.prototype.parse_text=function(e){var t=this._peek(),i=new h(e),n=new h(i,t);
return i.value=new s.Text(n.value),i},e.prototype.parse_comment=function(e){var t=this._peek(),i=new h(e),n=new h(i,t);return i.value=new s.Comment(n.value),i},e.prototype.parse_tag_a=function(e){var t=new h(e);if(null===this.read(t,"a"))return e.pop(),null;var i=this._peek();switch(i){case"1":var n=this._peek(2);switch(n){case"10":case"11":i=n}break;case"2":case"3":case"5":case"6":case"7":case"9":break;default:return e.pop(),null}var a=new h(t,i),r=null;switch(a.value){case"1":r=1;break;case"2":r=2;
break;case"3":r=3;break;case"5":r=7;break;case"6":r=8;break;case"7":r=9;break;case"9":r=4;break;case"10":r=5;break;case"11":r=6}return t.value=new s.Alignment(r),t},e.prototype.parse_tag_alpha=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_an=function(e){var t=new h(e);if(null===this.read(t,"an"))return e.pop(),null;var i=this._peek();if("1">i||i>"9")return e.pop(),null;var n=new h(t,i);return t.value=new s.Alignment(parseInt(n.value)),t},e.prototype.parse_tag_b=function(e){var t=new h(e);
if(null===this.read(t,"b"))return e.pop(),null;var i=null,n=this._peek();return n>="1"&&"9">=n&&(n=this._peek(3),"00"===n.substr(1)&&(i=new h(t,n),i.value=parseInt(i.value))),null===i&&(i=this.parse_enableDisable(t)),t.value=new s.Bold(null!==i?i.value:null),t},e.prototype.parse_tag_be=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_blur=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_bord=function(){throw new Error("Method not implemented.")
},e.prototype.parse_tag_c=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_clip=function(e){return this._parse_tag_clip_or_iclip("clip",e)},e.prototype.parse_tag_fad=function(e){var t=new h(e);if(null===this.read(t,"fad"))return e.pop(),null;if(null===this.read(t,"("))return e.pop(),null;var i=this.parse_decimal(t);if(null===i)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var n=this.parse_decimal(t);return null===n?(e.pop(),null):null===this.read(t,")")?(e.pop(),null):(t.value=new s.Fade(i.value/1e3,n.value/1e3),t)
},e.prototype.parse_tag_fade=function(e){var t=new h(e);if(null===this.read(t,"fade"))return e.pop(),null;if(null===this.read(t,"("))return e.pop(),null;var i=this.parse_decimal(t);if(null===i)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var n=this.parse_decimal(t);if(null===n)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var a=this.parse_decimal(t);if(null===a)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var r=this.parse_decimal(t);
if(null===r)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var o=this.parse_decimal(t);if(null===o)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var l=this.parse_decimal(t);if(null===l)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var c=this.parse_decimal(t);return null===c?(e.pop(),null):null===this.read(t,")")?(e.pop(),null):(t.value=new s.ComplexFade(1-i.value/255,1-n.value/255,1-a.value/255,r.value/1e3,o.value/1e3,l.value/1e3,c.value/1e3),t)
},e.prototype.parse_tag_fax=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_fay=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_fn=function(e){var t=new h(e);if(null===this.read(t,"fn"))return e.pop(),null;for(var i=new h(t,""),n=this._peek();this._haveMore()&&"\\"!==n&&"}"!==n;n=this._peek())i.value+=n;return t.value=new s.FontName(i.value.length>0?i.value:null),t},e.prototype.parse_tag_fr=function(){throw new Error("Method not implemented.")
},e.prototype.parse_tag_frx=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_fry=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_frz=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_fs=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_fsplus=function(e){var t=new h(e);if(null===this.read(t,"fs+"))return e.pop(),null;var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.FontSizePlus(i.value),t)
},e.prototype.parse_tag_fsminus=function(e){var t=new h(e);if(null===this.read(t,"fs-"))return e.pop(),null;var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.FontSizeMinus(i.value),t)},e.prototype.parse_tag_fscx=function(e){var t=new h(e);if(null===this.read(t,"fscx"))return e.pop(),null;var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.FontScaleX(i.value/100),t)},e.prototype.parse_tag_fscy=function(e){var t=new h(e);if(null===this.read(t,"fscy"))return e.pop(),null;
var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.FontScaleY(i.value/100),t)},e.prototype.parse_tag_fsp=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_i=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_iclip=function(e){return this._parse_tag_clip_or_iclip("iclip",e)},e.prototype.parse_tag_k=function(e){var t=new h(e);if(null===this.read(t,"k"))return e.pop(),null;var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.ColorKaraoke(i.value/100),t)
},e.prototype.parse_tag_K=function(e){var t=new h(e);if(null===this.read(t,"K"))return e.pop(),null;var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.SweepingColorKaraoke(i.value/100),t)},e.prototype.parse_tag_kf=function(e){var t=new h(e);if(null===this.read(t,"kf"))return e.pop(),null;var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.SweepingColorKaraoke(i.value/100),t)},e.prototype.parse_tag_ko=function(e){var t=new h(e);if(null===this.read(t,"ko"))return e.pop(),null;
var i=this.parse_decimal(t);return null===i?(e.pop(),null):(t.value=new s.OutlineKaraoke(i.value/100),t)},e.prototype.parse_tag_move=function(e){var t=new h(e);if(null===this.read(t,"move"))return e.pop(),null;if(null===this.read(t,"("))return e.pop(),null;var i=this.parse_decimal(t);if(null===i)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var n=this.parse_decimal(t);if(null===n)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var a=this.parse_decimal(t);if(null===a)return e.pop(),null;
if(null===this.read(t,","))return e.pop(),null;var r=this.parse_decimal(t);if(null===r)return e.pop(),null;var o=null,l=null;if(null!==this.read(t,",")){if(o=this.parse_decimal(t),null===o)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;if(l=this.parse_decimal(t),null===l)return e.pop(),null}return null===this.read(t,")")?(e.pop(),null):(t.value=new s.Move(i.value,n.value,a.value,r.value,null!==o?o.value/1e3:null,null!==l?l.value/1e3:null),t)},e.prototype.parse_tag_org=function(e){var t=new h(e);
if(null===this.read(t,"org"))return e.pop(),null;if(null===this.read(t,"("))return e.pop(),null;var i=this.parse_decimal(t);if(null===i)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var n=this.parse_decimal(t);return null===n?(e.pop(),null):null===this.read(t,")")?(e.pop(),null):(t.value=new s.RotationOrigin(i.value,n.value),t)},e.prototype.parse_tag_p=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_pbo=function(){throw new Error("Method not implemented.")
},e.prototype.parse_tag_pos=function(e){var t=new h(e);if(null===this.read(t,"pos"))return e.pop(),null;if(null===this.read(t,"("))return e.pop(),null;var i=this.parse_decimal(t);if(null===i)return e.pop(),null;if(null===this.read(t,","))return e.pop(),null;var n=this.parse_decimal(t);return null===n?(e.pop(),null):null===this.read(t,")")?(e.pop(),null):(t.value=new s.Position(i.value,n.value),t)},e.prototype.parse_tag_q=function(e){var t=new h(e);if(null===this.read(t,"q"))return e.pop(),null;var i=this._peek();
if("0">i||i>"3")return e.pop(),null;var n=new h(t,i);return t.value=new s.WrappingStyle(parseInt(n.value)),t},e.prototype.parse_tag_r=function(e){var t=new h(e);if(null===this.read(t,"r"))return e.pop(),null;for(var i=new h(t,""),n=this._peek();this._haveMore()&&"\\"!==n&&"}"!==n;n=this._peek())i.value+=n;return t.value=new s.Reset(i.value.length>0?i.value:null),t},e.prototype.parse_tag_s=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_shad=function(){throw new Error("Method not implemented.")
},e.prototype.parse_tag_t=function(e){var t=new h(e);if(null===this.read(t,"t"))return e.pop(),null;if(null===this.read(t,"("))return e.pop(),null;var i=null,n=null,a=null,r=this.parse_decimal(t);if(null!==r){if(null===this.read(t,","))return e.pop(),null;var o=this.parse_decimal(t);if(null!==o){if(i=r,n=o,null===this.read(t,","))return e.pop(),null;var l=this.parse_decimal(t);if(null!==l&&(a=l,null===this.read(t,",")))return e.pop(),null}else if(a=r,null===this.read(t,","))return e.pop(),null}for(var c=[],d=this._peek();this._haveMore()&&")"!==d&&"}"!==d;d=this._peek()){var u=null;
if(null!==this.read(t,"\\")&&(u=this.parse_tag_alpha(t)||this.parse_tag_iclip(t)||this.parse_tag_xbord(t)||this.parse_tag_ybord(t)||this.parse_tag_xshad(t)||this.parse_tag_yshad(t)||this.parse_tag_blur(t)||this.parse_tag_bord(t)||this.parse_tag_clip(t)||this.parse_tag_fscx(t)||this.parse_tag_fscy(t)||this.parse_tag_shad(t)||this.parse_tag_fax(t)||this.parse_tag_fay(t)||this.parse_tag_frx(t)||this.parse_tag_fry(t)||this.parse_tag_frz(t)||this.parse_tag_fsp(t)||this.parse_tag_fsplus(t)||this.parse_tag_fsminus(t)||this.parse_tag_be(t)||this.parse_tag_fr(t)||this.parse_tag_fs(t)||this.parse_tag_1a(t)||this.parse_tag_1c(t)||this.parse_tag_2a(t)||this.parse_tag_2c(t)||this.parse_tag_3a(t)||this.parse_tag_3c(t)||this.parse_tag_4a(t)||this.parse_tag_4c(t)||this.parse_tag_c(t),null===u&&t.pop()),null===u&&(u=this.parse_comment(t)),null===u)return e.pop(),null;
u.value instanceof s.Comment&&c[c.length-1]instanceof s.Comment?c[c.length-1]=new s.Comment(c[c.length-1].value+u.value.value):c.push(u.value)}return this.read(t,")"),t.value=new s.Transform(null!==i?i.value/1e3:null,null!==n?n.value/1e3:null,null!==a?a.value/1e3:null,c),t},e.prototype.parse_tag_u=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_xbord=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_xshad=function(){throw new Error("Method not implemented.")
},e.prototype.parse_tag_ybord=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_yshad=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_1a=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_1c=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_2a=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_2c=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_3a=function(){throw new Error("Method not implemented.")
},e.prototype.parse_tag_3c=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_4a=function(){throw new Error("Method not implemented.")},e.prototype.parse_tag_4c=function(){throw new Error("Method not implemented.")},e.prototype.parse_drawingInstructions=function(e){var t=new h(e),i=null;for(t.value=[];this._haveMore();){for(;null!==this.read(t," "););if(!this._haveMore())break;var n=null,s=this.parse_text(t);if(null===s)return e.pop(),null;switch(n=s.value.value){case"m":case"l":case"b":i=n;
break;default:if(null===i)return e.pop(),null;n=i,t.pop()}switch(n){case"m":var a=this.parse_drawingInstructionMove(t);if(null===a)return e.pop(),null;t.value.push(a.value);break;case"l":var r=this.parse_drawingInstructionLine(t);if(null===r)return e.pop(),null;t.value.push(r.value);break;case"b":var o=this.parse_drawingInstructionCubicBezierCurve(t);if(null===o)return e.pop(),null;t.value.push(o.value)}}for(;null!==this.read(t," "););return t},e.prototype.parse_drawingInstructionMove=function(e){for(var t=new h(e);null!==this.read(t," "););var i=this.parse_decimal(t);
if(null===i)return e.pop(),null;for(;null!==this.read(t," "););var n=this.parse_decimal(t);return null===n?(e.pop(),null):(t.value=new s.drawing.MoveInstruction(i.value,n.value),t)},e.prototype.parse_drawingInstructionLine=function(e){for(var t=new h(e);null!==this.read(t," "););var i=this.parse_decimal(t);if(null===i)return e.pop(),null;for(;null!==this.read(t," "););var n=this.parse_decimal(t);return null===n?(e.pop(),null):(t.value=new s.drawing.LineInstruction(i.value,n.value),t)},e.prototype.parse_drawingInstructionCubicBezierCurve=function(e){for(var t=new h(e);null!==this.read(t," "););var i=this.parse_decimal(t);
if(null===i)return e.pop(),null;for(;null!==this.read(t," "););var n=this.parse_decimal(t);if(null===n)return e.pop(),null;for(;null!==this.read(t," "););var a=this.parse_decimal(t);if(null===a)return e.pop(),null;for(;null!==this.read(t," "););var r=this.parse_decimal(t);if(null===r)return e.pop(),null;for(;null!==this.read(t," "););var o=this.parse_decimal(t);if(null===o)return e.pop(),null;for(;null!==this.read(t," "););var l=this.parse_decimal(t);return null===l?(e.pop(),null):(t.value=new s.drawing.CubicBezierCurveInstruction(i.value,n.value,a.value,r.value,o.value,l.value),t)
},e.prototype.parse_decimalInt32=function(e){for(var t=new h(e),i=null!==this.read(t,"-"),n=new h(t,""),s=this._peek();this._haveMore()&&s>="0"&&"9">=s;s=this._peek())n.value+=s;if(0===n.value.length)return e.pop(),null;var a=parseInt(n.value);return a>=4294967295?a=4294967295:i&&(a=-a),t.value=a,t},e.prototype.parse_hexInt32=function(e){for(var t=new h(e),i=null!==this.read(t,"-"),n=new h(t,""),s=this._peek();this._haveMore()&&(s>="0"&&"9">=s||s>="a"&&"f">=s||s>="A"&&"F">=s);s=this._peek())n.value+=s;
if(0===n.value.length)return e.pop(),null;var a=parseInt(n.value,16);return a>=4294967295?a=4294967295:i&&(a=-a),t.value=a,t},e.prototype.parse_decimalOrHexInt32=function(e){var t=new h(e),i=null;return i=null!==this.read(t,"&H")||null!==this.read(t,"&h")?this.parse_hexInt32(t):this.parse_decimalInt32(t),null===i?(e.pop(),null):(t.value=i.value,t)},e.prototype.parse_decimal=function(e){var t=new h(e),i=null!==this.read(t,"-"),n=this.parse_unsignedDecimal(t);return null===n?(e.pop(),null):(t.value=n.value,i&&(t.value=-t.value),t)
},e.prototype.parse_unsignedDecimal=function(e){var t,i=new h(e),n=new h(i,""),s=null;for(t=this._peek();this._haveMore()&&t>="0"&&"9">=t;t=this._peek())n.value+=t;if(0===n.value.length)return e.pop(),null;if(null!==this.read(i,".")){for(s=new h(i,""),t=this._peek();this._haveMore()&&t>="0"&&"9">=t;t=this._peek())s.value+=t;if(0===s.value.length)return e.pop(),null}return i.value=parseFloat(n.value+(null!==s?"."+s.value:"")),i},e.prototype.parse_enableDisable=function(e){var t=this._peek();if("0"===t||"1"===t){var i=new h(e,t);
return i.value="1"===i.value,i}return null},e.prototype.parse_color=function(e){for(var t=new h(e);null!==this.read(t,"&")||null!==this.read(t,"H"););var i=this.parse_hexInt32(t);if(null===i)return e.pop(),null;var n=i.value;for(t.value=new s.Color(255&n,n>>8&255,n>>16&255);null!==this.read(t,"&")||null!==this.read(t,"H"););return t},e.prototype.parse_alpha=function(e){for(var t=new h(e);null!==this.read(t,"&")||null!==this.read(t,"H"););var i=this.parse_hexInt32(t);if(null===i)return e.pop(),null;
var n=i.value;for(t.value=1-(255&n)/255;null!==this.read(t,"&")||null!==this.read(t,"H"););return t},e.prototype.parse_colorWithAlpha=function(e){var t=new h(e),i=this.parse_decimalOrHexInt32(t);if(null===i)return e.pop(),null;var n=i.value;return t.value=new s.Color(255&n,n>>8&255,n>>16&255,1-(n>>24&255)/255),t},e.prototype.read=function(e,t){return this._peek(t.length)!==t?null:new h(e,t)},e.prototype._peek=function(e){return void 0===e&&(e=1),1===e?this._input[this._parseTree.end]:this._input.substr(this._parseTree.end,e)
},e.prototype._haveMore=function(){return this._parseTree.end<this._input.length},e.prototype._parse_tag_clip_or_iclip=function(e,t){var n=new h(t);if(null===this.read(n,e))return t.pop(),null;if(null===this.read(n,"("))return t.pop(),null;var a=null,r=null,o=null,l=null,c=null,d=null,u=this.parse_decimal(n);if(null!==u){if(null===this.read(n,","))return t.pop(),null;var p=this.parse_decimal(n);null!==p?(a=u,o=p):c=u}if(null!==a&&null!==o){if(null===this.read(n,","))return t.pop(),null;if(r=this.parse_decimal(n),null===this.read(n,","))return t.pop(),null;
l=this.parse_decimal(n),n.value=new s.RectangularClip(a.value,o.value,r.value,l.value,"clip"===e)}else{d=new h(n,"");for(var m=this._peek();this._haveMore()&&")"!==m&&"}"!==m;m=this._peek())d.value+=m;n.value=new s.VectorClip(null!==c?c.value:1,i(d.value,"drawingInstructions"),"clip"===e)}return null===this.read(n,")")?(t.pop(),null):n},e}();n("alpha",s.Alpha,o.prototype.parse_alpha,!1),n("be",s.Blur,o.prototype.parse_decimal,!1),n("blur",s.GaussianBlur,o.prototype.parse_decimal,!1),n("bord",s.Border,o.prototype.parse_decimal,!1),n("c",s.PrimaryColor,o.prototype.parse_color,!1),n("fax",s.SkewX,o.prototype.parse_decimal,!1),n("fay",s.SkewY,o.prototype.parse_decimal,!1),n("fr",s.RotateZ,o.prototype.parse_decimal,!1),n("frx",s.RotateX,o.prototype.parse_decimal,!1),n("fry",s.RotateY,o.prototype.parse_decimal,!1),n("frz",s.RotateZ,o.prototype.parse_decimal,!1),n("fs",s.FontSize,o.prototype.parse_decimal,!1),n("fsp",s.LetterSpacing,o.prototype.parse_decimal,!1),n("i",s.Italic,o.prototype.parse_enableDisable,!1),n("p",s.DrawingMode,o.prototype.parse_decimal,!0),n("pbo",s.DrawingBaselineOffset,o.prototype.parse_decimal,!0),n("s",s.StrikeThrough,o.prototype.parse_enableDisable,!1),n("shad",s.Shadow,o.prototype.parse_decimal,!1),n("u",s.Underline,o.prototype.parse_enableDisable,!1),n("xbord",s.BorderX,o.prototype.parse_decimal,!1),n("xshad",s.ShadowX,o.prototype.parse_decimal,!1),n("ybord",s.BorderY,o.prototype.parse_decimal,!1),n("yshad",s.ShadowY,o.prototype.parse_decimal,!1),n("1a",s.PrimaryAlpha,o.prototype.parse_alpha,!1),n("1c",s.PrimaryColor,o.prototype.parse_color,!1),n("2a",s.SecondaryAlpha,o.prototype.parse_alpha,!1),n("2c",s.SecondaryColor,o.prototype.parse_color,!1),n("3a",s.OutlineAlpha,o.prototype.parse_alpha,!1),n("3c",s.OutlineColor,o.prototype.parse_color,!1),n("4a",s.ShadowAlpha,o.prototype.parse_alpha,!1),n("4c",s.ShadowColor,o.prototype.parse_color,!1);
for(var l=new r.Map,c=0,d=Object.keys(o.prototype);c<d.length;c++){var u=d[c];0===u.indexOf("parse_")&&"function"==typeof o.prototype[u]&&l.set(u.substr("parse_".length),o.prototype[u])}var h=function(){function e(e,t){void 0===t&&(t=null),this._parent=e,this._children=[],null!==e&&e.children.push(this),this._start=null!==e?e.end:0,this._end=this._start,this.value=t}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this._value=e,null!==this._value&&this._value.constructor===String&&0===this._children.length&&this._setEnd(this._start+this._value.length)},enumerable:!0,configurable:!0}),e.prototype.pop=function(){this._children.splice(this._children.length-1,1),this._setEnd(this._children.length>0?this._children[this._children.length-1].end:this.start)
},e.prototype._setEnd=function(e){this._end=e,null!==this._parent&&this._parent.end!==this._end&&this._parent._setEnd(this._end)},e}(),p=t(29),m=t(32),f=t(34);f.registerWorkerCommand(m.WorkerCommands.Parse,function(e){return new p.Promise(function(t){t(i(e.input,e.rule))})})},function(e,t){var i=t(22),n=t(26),s=t(23),a=t(27),r=t(29),o=t(2),l=function(){function e(e){this._str=e,this._readTill=0}return e.prototype.nextLine=function(){var e=null;if(this._readTill<this._str.length){var t=this._str.indexOf("\n",this._readTill);
-1!==t?(e=r.Promise.resolve(this._str.substring(this._readTill,t)),this._readTill=t+1):(e=r.Promise.resolve(this._str.substr(this._readTill)),this._readTill=this._str.length)}else e=r.Promise.resolve(null);return e},e}();e.StringStream=l;var c=function(){function e(e){var t=this;this._xhr=e,this._readTill=0,this._pendingDeferred=null,e.addEventListener("progress",function(e){return t._onXhrProgress(e)},!1),e.addEventListener("loadend",function(e){return t._onXhrLoadEnd(e)},!1)}return e.prototype.nextLine=function(){if(null!==this._pendingDeferred)throw new Error("XhrStream only supports one pending unfulfilled read at a time.");
var e=this._pendingDeferred=new r.DeferredPromise;return this._tryResolveNextLine(),e.promise},e.prototype._onXhrProgress=function(){null!==this._pendingDeferred&&this._tryResolveNextLine()},e.prototype._onXhrLoadEnd=function(){null!==this._pendingDeferred&&this._tryResolveNextLine()},e.prototype._tryResolveNextLine=function(){var e=this._xhr.responseText,t=e.indexOf("\n",this._readTill);-1!==t?(this._pendingDeferred.resolve(e.substring(this._readTill,t)),this._readTill=t+1,this._pendingDeferred=null):this._xhr.readyState===XMLHttpRequest.DONE&&(this._readTill<e.length?(this._pendingDeferred.resolve(e.substr(this._readTill)),this._readTill=e.length):this._pendingDeferred.resolve(null),this._pendingDeferred=null)
},e}();e.XhrStream=c;var d=function(){function e(e){var t=this;this._stream=e,this._ass=new i.ASS,this._minimalDeferred=new r.DeferredPromise,this._deferred=new r.DeferredPromise,this._currentSectionName=null,this._stream.nextLine().then(function(e){return t._onNextLine(e)})}return Object.defineProperty(e.prototype,"minimalASS",{get:function(){return this._minimalDeferred.promise},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ass",{get:function(){return this._deferred.promise
},enumerable:!0,configurable:!0}),e.prototype._onNextLine=function(e){var t=this;if(null===e)return this._minimalDeferred.resolve(this._ass),void this._deferred.resolve(this._ass);if("\r"===e[e.length-1]&&(e=e.substr(0,e.length-1)),""===e||";"===e[0]);else if("["===e[0]&&"]"===e[e.length-1])"Script Info"===this._currentSectionName&&this._minimalDeferred.resolve(this._ass),this._currentSectionName=e.substring(1,e.length-1);else switch(this._currentSectionName){case"Script Info":var i=o.parseLineIntoProperty(e);
if(null!==i)switch(i.name){case"PlayResX":this._ass.properties.resolutionX=parseInt(i.value);break;case"PlayResY":this._ass.properties.resolutionY=parseInt(i.value);break;case"WrapStyle":this._ass.properties.wrappingStyle=parseInt(i.value);break;case"ScaledBorderAndShadow":this._ass.properties.scaleBorderAndShadow="yes"===i.value}break;case"V4+ Styles":if(null===this._ass.stylesFormatSpecifier){var i=o.parseLineIntoProperty(e);null!==i&&"Format"===i.name&&(this._ass.stylesFormatSpecifier=i.value.split(",").map(function(e){return e.trim()
}))}else this._ass.addStyle(e);break;case"Events":if(null===this._ass.dialoguesFormatSpecifier){var i=o.parseLineIntoProperty(e);null!==i&&"Format"===i.name&&(this._ass.dialoguesFormatSpecifier=i.value.split(",").map(function(e){return e.trim()}))}else this._ass.addEvent(e)}this._stream.nextLine().then(function(e){return t._onNextLine(e)})},e}();e.StreamParser=d;var u=function(){function e(e){var t=this;this._stream=e,this._ass=new i.ASS,this._deferred=new r.DeferredPromise,this._currentDialogueNumber=null,this._currentDialogueStart=null,this._currentDialogueEnd=null,this._currentDialogueText=null,this._stream.nextLine().then(function(e){return t._onNextLine(e)
}),this._ass.properties.resolutionX=1280,this._ass.properties.resolutionY=720,this._ass.properties.wrappingStyle=1,this._ass.properties.scaleBorderAndShadow=!0;var s=new n.Style(new a.Map([["Name","Default"]]));this._ass.styles.set(s.name,s)}return Object.defineProperty(e.prototype,"ass",{get:function(){return this._deferred.promise},enumerable:!0,configurable:!0}),e.prototype._onNextLine=function(e){var t=this;if(null===e)return null!==this._currentDialogueNumber&&null!==this._currentDialogueStart&&null!==this._currentDialogueEnd&&null!==this._currentDialogueText&&this._ass.dialogues.push(new s.Dialogue(new a.Map([["Style","Default"],["Start",this._currentDialogueStart],["End",this._currentDialogueEnd],["Text",this._currentDialogueText]]),this._ass)),void this._deferred.resolve(this._ass);
if("\r"===e[e.length-1]&&(e=e.substr(0,e.length-1)),""===e)null!==this._currentDialogueNumber&&null!==this._currentDialogueStart&&null!==this._currentDialogueEnd&&null!==this._currentDialogueText&&this._ass.dialogues.push(new s.Dialogue(new a.Map([["Style","Default"],["Start",this._currentDialogueStart],["End",this._currentDialogueEnd],["Text",this._currentDialogueText]]),this._ass)),this._currentDialogueNumber=this._currentDialogueStart=this._currentDialogueEnd=this._currentDialogueText=null;else if(null===this._currentDialogueNumber)/^\d+$/.test(e)&&(this._currentDialogueNumber=e);
else if(null===this._currentDialogueStart&&null===this._currentDialogueEnd){var i=/^(\d\d:\d\d:\d\d,\d\d\d) --> (\d\d:\d\d:\d\d,\d\d\d)/.exec(e);null!==i&&(this._currentDialogueStart=i[1].replace(",","."),this._currentDialogueEnd=i[2].replace(",","."))}else e=e.replace(/<b>/g,"{\\b1}").replace(/\{b\}/g,"{\\b1}").replace(/<\/b>/g,"{\\b0}").replace(/\{\/b\}/g,"{\\b0}").replace(/<i>/g,"{\\i1}").replace(/\{i\}/g,"{\\i1}").replace(/<\/i>/g,"{\\i0}").replace(/\{\/i\}/g,"{\\i0}").replace(/<u>/g,"{\\u1}").replace(/\{u\}/g,"{\\u1}").replace(/<\/u>/g,"{\\u0}").replace(/\{\/u\}/g,"{\\u0}").replace(/<font color="#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})">/g,function(e,t,i,n){return"{c&H"+n+i+t+"&}"
}).replace(/<\/font>/g,"{\\c}"),null!==this._currentDialogueText?this._currentDialogueText+="\\N"+e:this._currentDialogueText=e;this._stream.nextLine().then(function(e){return t._onNextLine(e)})},e}();e.SrtStreamParser=u},function(e){var t=function(){function e(e,t){this._x=e,this._y=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),e}();
e.MoveInstruction=t;var i=function(){function e(e,t){this._x=e,this._y=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),e}();e.LineInstruction=i;var n=function(){function e(e,t,i,n,s,a){this._x1=e,this._y1=t,this._x2=i,this._y2=n,this._x3=s,this._y3=a}return Object.defineProperty(e.prototype,"x1",{get:function(){return this._x1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._y1
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"x2",{get:function(){return this._x2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y2",{get:function(){return this._y2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"x3",{get:function(){return this._x3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y3",{get:function(){return this._y3},enumerable:!0,configurable:!0}),e}();e.CubicBezierCurveInstruction=n},function(e,t){var i=t(5);
e.drawing=i;var n=function(){function e(e,t,i,n){void 0===n&&(n=1),this._red=e,this._green=t,this._blue=i,this._alpha=n}return Object.defineProperty(e.prototype,"red",{get:function(){return this._red},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"green",{get:function(){return this._green},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blue",{get:function(){return this._blue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha
},enumerable:!0,configurable:!0}),e.prototype.withAlpha=function(t){return null!==t?new e(this._red,this._green,this._blue,t):this},e.prototype.toString=function(){return"rgba("+this._red+", "+this._green+", "+this._blue+", "+this._alpha.toFixed(3)+")"},e}();e.Color=n;var s=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.Comment=s;var a=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"Text { value: "+this._value.replace(/\u00A0/g,"\\h")+" }"},e}();e.Text=a;var r=function(){function e(){}return e}();e.NewLine=r;var o=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.Italic=o;var l=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.Bold=l;var c=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.Underline=c;var d=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.StrikeThrough=d;var u=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.Border=u;var h=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.BorderX=h;var p=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.BorderY=p;var m=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.Shadow=m;var f=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.ShadowX=f;var g=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.ShadowY=g;var v=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.Blur=v;var y=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.GaussianBlur=y;var b=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.FontName=b;var w=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.FontSize=w;var x=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.FontSizePlus=x;var k=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.FontSizeMinus=k;var S=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.FontScaleX=S;var C=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.FontScaleY=C;var P=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.LetterSpacing=P;var A=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.RotateX=A;var _=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.RotateY=_;var I=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.RotateZ=I;var T=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.SkewX=T;var M=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.SkewY=M;var D=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.PrimaryColor=D;var E=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.SecondaryColor=E;var L=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.OutlineColor=L;var R=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.ShadowColor=R;var O=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.Alpha=O;var N=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.PrimaryAlpha=N;var F=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.SecondaryAlpha=F;var B=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.OutlineAlpha=B;var U=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.ShadowAlpha=U;var V=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.Alignment=V;var z=function(){function e(e){this._duration=e}return Object.defineProperty(e.prototype,"duration",{get:function(){return this._duration
},enumerable:!0,configurable:!0}),e}();e.ColorKaraoke=z;var j=function(){function e(e){this._duration=e}return Object.defineProperty(e.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),e}();e.SweepingColorKaraoke=j;var q=function(){function e(e){this._duration=e}return Object.defineProperty(e.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),e}();e.OutlineKaraoke=q;var H=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value
},enumerable:!0,configurable:!0}),e}();e.WrappingStyle=H;var W=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e}();e.Reset=W;var $=function(){function e(e,t){this._x=e,this._y=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),e}();
e.Position=$;var Y=function(){function e(e,t,i,n,s,a){this._x1=e,this._y1=t,this._x2=i,this._y2=n,this._t1=s,this._t2=a}return Object.defineProperty(e.prototype,"x1",{get:function(){return this._x1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._y1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"x2",{get:function(){return this._x2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y2",{get:function(){return this._y2
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"t1",{get:function(){return this._t1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"t2",{get:function(){return this._t2},enumerable:!0,configurable:!0}),e}();e.Move=Y;var Q=function(){function e(e,t){this._x=e,this._y=t}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),e
}();e.RotationOrigin=Q;var K=function(){function e(e,t){this._start=e,this._end=t}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),e}();e.Fade=K;var X=function(){function e(e,t,i,n,s,a,r){this._a1=e,this._a2=t,this._a3=i,this._t1=n,this._t2=s,this._t3=a,this._t4=r}return Object.defineProperty(e.prototype,"a1",{get:function(){return this._a1
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a2",{get:function(){return this._a2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a3",{get:function(){return this._a3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"t1",{get:function(){return this._t1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"t2",{get:function(){return this._t2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"t3",{get:function(){return this._t3
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"t4",{get:function(){return this._t4},enumerable:!0,configurable:!0}),e}();e.ComplexFade=X;var G=function(){function e(e,t,i,n){this._start=e,this._end=t,this._accel=i,this._tags=n}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"accel",{get:function(){return this._accel
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tags",{get:function(){return this._tags},enumerable:!0,configurable:!0}),e}();e.Transform=G;var J=function(){function e(e,t,i,n,s){this._x1=e,this._y1=t,this._x2=i,this._y2=n,this._inside=s}return Object.defineProperty(e.prototype,"x1",{get:function(){return this._x1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._y1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"x2",{get:function(){return this._x2
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y2",{get:function(){return this._y2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inside",{get:function(){return this._inside},enumerable:!0,configurable:!0}),e}();e.RectangularClip=J;var Z=function(){function e(e,t,i){this._scale=e,this._instructions=t,this._inside=i}return Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"instructions",{get:function(){return this._instructions
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inside",{get:function(){return this._inside},enumerable:!0,configurable:!0}),e}();e.VectorClip=Z;var et=function(){function e(e){this._scale=e}return Object.defineProperty(e.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),e}();e.DrawingMode=et;var tt=function(){function e(e){this._value=e}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},enumerable:!0,configurable:!0}),e
}();e.DrawingBaselineOffset=tt;var it=function(){function e(e){this._instructions=e}return Object.defineProperty(e.prototype,"instructions",{get:function(){return this._instructions},enumerable:!0,configurable:!0}),e}();e.DrawingInstructions=it;for(var nt=function(e,t){if(!e.prototype.hasOwnProperty("toString")){var i=Object.getOwnPropertyNames(e.prototype).filter(function(e){return"constructor"!==e});e.prototype.toString=function(){var e=this;return t+" { "+i.map(function(t){return t+": "+e[t]}).join(", ")+(i.length>0?" ":"")+"}"
}}},st=t(34),at=0,rt=Object.keys(e);at<rt.length;at++){var ot=rt[at],lt=e[ot];lt instanceof Function&&(nt(lt,ot),st.registerClassPrototype(lt.prototype))}for(var ct=0,dt=Object.keys(i);ct<dt.length;ct++){var ot=dt[ct],lt=i[ot];lt instanceof Function&&(nt(lt,"Drawing"+ot),st.registerClassPrototype(lt.prototype))}},function(e,t){var i=t(21),n=t(9),s=function(){function e(e,t){this._getCurrentTime=e,this._currentTimeUpdateMaxDelay=t,this._manualClock=new n.ManualClock,this._nextAnimationFrameRequestId=null,this._lastKnownExternalTime=null,this._lastKnownExternalTimeObtainedAt=null
}return e.prototype.play=function(){this._manualClock.enabled&&(this._startTicking(),this._manualClock.play())},e.prototype.pause=function(){if(this._manualClock.enabled){if(null===this._nextAnimationFrameRequestId)return void(i.debugMode&&console.warn("AutoClock.pause: Abnormal state detected. AutoClock._nextAnimationFrameRequestId should not have been null."));this._stopTicking(),this._manualClock.pause()}},e.prototype.seeking=function(){this._manualClock.seek(this._getCurrentTime())},Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._manualClock.currentTime
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._manualClock.enabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){return this._manualClock.paused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rate",{get:function(){return this._manualClock.rate},enumerable:!0,configurable:!0}),e.prototype.setRate=function(e){this._manualClock.setRate(e)},e.prototype.enable=function(){return this._manualClock.enable()?(this._startTicking(),!0):!1
},e.prototype.disable=function(){return this._manualClock.disable()?(this._stopTicking(),!0):!1},e.prototype.toggle=function(){this._manualClock.toggle()},e.prototype.setEnabled=function(e){return this._manualClock.setEnabled(e)},e.prototype.addEventListener=function(e,t){this._manualClock.addEventListener(e,t)},e.prototype._onTimerTick=function(e){var t=this;if(!this._manualClock.enabled)return void(i.debugMode&&console.warn("AutoClock._onTimerTick: Called when disabled."));var n=this._manualClock.currentTime,s=this._getCurrentTime();
this._manualClock.paused?n!==s&&(this._lastKnownExternalTime=s,this._lastKnownExternalTimeObtainedAt=e,this._manualClock.tick(s)):null!==this._lastKnownExternalTime&&s===this._lastKnownExternalTime?e-this._lastKnownExternalTimeObtainedAt>this._currentTimeUpdateMaxDelay?(this._lastKnownExternalTimeObtainedAt=null,this._manualClock.pause()):this._manualClock.tick((e-this._lastKnownExternalTimeObtainedAt)/1e3*this._manualClock.rate+this._lastKnownExternalTime):(this._lastKnownExternalTime=s,this._lastKnownExternalTimeObtainedAt=e,this._manualClock.tick(s)),this._nextAnimationFrameRequestId=requestAnimationFrame(function(e){return t._onTimerTick(e)
})},e.prototype._startTicking=function(){var e=this;null===this._nextAnimationFrameRequestId&&(this._nextAnimationFrameRequestId=requestAnimationFrame(function(t){return e._onTimerTick(t)}))},e.prototype._stopTicking=function(){null!==this._nextAnimationFrameRequestId&&(cancelAnimationFrame(this._nextAnimationFrameRequestId),this._nextAnimationFrameRequestId=null)},e}();e.AutoClock=s},function(e){var t=function(){function e(){}return e.prototype.addEventListener=function(e,t){var i=this._eventListeners.get(e);
void 0===i&&this._eventListeners.set(e,i=[]),i.push(t)},e.prototype._dispatchEvent=function(e,t){var i=this._eventListeners.get(e);if(void 0!==i)for(var n=0;n<i.length;n++){var s=i[n];s.apply(this,t)}},e}();e.EventSource=t,function(e){e[e.Play=0]="Play",e[e.Tick=1]="Tick",e[e.Pause=2]="Pause",e[e.Stop=3]="Stop",e[e.RateChange=4]="RateChange"}(e.ClockEvent||(e.ClockEvent={}))},function(e,t){var i=t(28),n=t(27),s=t(8),a=function(){function e(){this._currentTime=-1,this._rate=1,this._enabled=!0,this._paused=!0,this._eventListeners=new n.Map
}return e.prototype.play=function(){this._enabled&&this._paused&&(this._paused=!1,this._dispatchEvent(s.ClockEvent.Play,[]))},e.prototype.tick=function(e){this._enabled&&(this._currentTime!==e&&this.play(),this._currentTime=e,this._dispatchEvent(s.ClockEvent.Tick,[]))},e.prototype.seek=function(e){this._enabled&&(this.pause(),this._currentTime!==e&&(this.stop(),this.tick(e),this.pause()))},e.prototype.pause=function(){this._enabled&&(this._paused||(this._paused=!0,this._dispatchEvent(s.ClockEvent.Pause,[])))
},e.prototype.stop=function(){this._dispatchEvent(s.ClockEvent.Stop,[])},Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._currentTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){return this._paused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rate",{get:function(){return this._rate},enumerable:!0,configurable:!0}),e.prototype.setRate=function(e){this._rate!==e&&(this._rate=e,this._dispatchEvent(s.ClockEvent.RateChange,[]))
},e.prototype.enable=function(){return this._enabled?!1:(this._enabled=!0,!0)},e.prototype.disable=function(){return this._enabled?(this._enabled=!1,this.pause(),this.stop(),!0):!1},e.prototype.toggle=function(){this._enabled?this.disable():this.enable()},e.prototype.setEnabled=function(e){return e?this.enable():this.disable()},e}();e.ManualClock=a,i.mixin(a,[s.EventSource])},function(e,t){var i=t(7),n=function(){function e(e){var t=this;this._autoClock=new i.AutoClock(function(){return e.currentTime
},100),e.addEventListener("playing",function(){return t._autoClock.play()},!1),e.addEventListener("pause",function(){return t._autoClock.pause()},!1),e.addEventListener("seeking",function(){return t._autoClock.seeking()},!1),e.addEventListener("ratechange",function(){return t._autoClock.setRate(e.playbackRate)},!1)}return Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._autoClock.currentTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._autoClock.enabled
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){return this._autoClock.paused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rate",{get:function(){return this._autoClock.rate},enumerable:!0,configurable:!0}),e.prototype.enable=function(){return this._autoClock.enable()},e.prototype.disable=function(){return this._autoClock.disable()},e.prototype.toggle=function(){this._autoClock.toggle()},e.prototype.setEnabled=function(e){return this._autoClock.setEnabled(e)
},e.prototype.addEventListener=function(e,t){this._autoClock.addEventListener(e,t)},e}();e.VideoClock=n},function(e,t){var i=this.__extends||function(e,t){function i(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);i.prototype=t.prototype,e.prototype=new i},n=t(10),s=t(19),a=function(e){function t(t,i,s){e.call(this,i,new n.VideoClock(t),document.createElement("div"),s),this._video=t,this._videoIsFullScreen=!1,this._video.parentElement.replaceChild(this.libjassSubsWrapper,this._video),this.libjassSubsWrapper.insertBefore(this._video,this.libjassSubsWrapper.firstElementChild)
}return i(t,e),t.prototype.resizeVideo=function(e,t){console.warn("`DefaultRenderer.resizeVideo(width, height)` has been deprecated. Use `DefaultRenderer.resize(width, height)` instead."),this.resize(e,t)},t.prototype._ready=function(){var t=this;document.addEventListener("mozfullscreenchange",function(){return t._onFullScreenChange(document.mozFullScreenElement)},!1),document.addEventListener("webkitfullscreenchange",function(){return t._onFullScreenChange(document.webkitFullscreenElement)},!1),document.addEventListener("fullscreenchange",function(){return t._onFullScreenChange(document.fullscreenElement)
},!1),this.resize(this._video.offsetWidth,this._video.offsetHeight),e.prototype._ready.call(this)},t.prototype._onFullScreenChange=function(e){void 0===e&&(e=document.msFullscreenElement),e===this._video?(this.libjassSubsWrapper.classList.add("libjass-full-screen"),this.resize(screen.width,screen.height),this._videoIsFullScreen=!0,this._dispatchEvent("fullScreenChange",[this._videoIsFullScreen])):null===e&&this._videoIsFullScreen&&(this.libjassSubsWrapper.classList.remove("libjass-full-screen"),this._videoIsFullScreen=!1,this._dispatchEvent("fullScreenChange",[this._videoIsFullScreen]))
},t}(s.WebRenderer);e.DefaultRenderer=a},function(e,t){var i=t(8);e.ClockEvent=i.ClockEvent,e.EventSource=i.EventSource;var n=t(7);e.AutoClock=n.AutoClock;var s=t(9);e.ManualClock=s.ManualClock;var a=t(10);e.VideoClock=a.VideoClock;var r=t(11);e.DefaultRenderer=r.DefaultRenderer;var o=t(13);e.NullRenderer=o.NullRenderer;var l=t(19);e.WebRenderer=l.WebRenderer;var c=t(14);e.RendererSettings=c.RendererSettings},function(e,t){var i=t(8),n=t(14),s=t(21),a=function(){function e(t,s,a){var r=this;this._ass=t,this._clock=s,this._id=++e._lastRendererId,this._settings=n.RendererSettings.from(a),this._clock.addEventListener(i.ClockEvent.Play,function(){return r._onClockPlay()
}),this._clock.addEventListener(i.ClockEvent.Tick,function(){return r._onClockTick()}),this._clock.addEventListener(i.ClockEvent.Pause,function(){return r._onClockPause()}),this._clock.addEventListener(i.ClockEvent.Stop,function(){return r._onClockStop()}),this._clock.addEventListener(i.ClockEvent.RateChange,function(){return r._onClockRateChange()})}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ass",{get:function(){return this._ass
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clock",{get:function(){return this._clock},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"settings",{get:function(){return this._settings},enumerable:!0,configurable:!0}),e.prototype.preRender=function(){},e.prototype.draw=function(){},e.prototype.enable=function(){return this._clock.enable()},e.prototype.disable=function(){return this._clock.disable()},e.prototype.toggle=function(){this._clock.toggle()},e.prototype.setEnabled=function(e){return this._clock.setEnabled(e)
},Object.defineProperty(e.prototype,"enabled",{get:function(){return this._clock.enabled},enumerable:!0,configurable:!0}),e.prototype._onClockPlay=function(){s.verboseMode&&console.log("NullRenderer._onClockPlay")},e.prototype._onClockTick=function(){var e=this._clock.currentTime;s.verboseMode&&console.log("NullRenderer._onClockTick: currentTime = "+e);for(var t=0,i=this._ass.dialogues;t<i.length;t++){var n=i[t];n.end>e&&(n.start<=e?this.draw(n):n.start<=e+this._settings.preRenderTime&&this.preRender(n))
}},e.prototype._onClockPause=function(){s.verboseMode&&console.log("NullRenderer._onClockPause")},e.prototype._onClockStop=function(){s.verboseMode&&console.log("NullRenderer._onClockStop")},e.prototype._onClockRateChange=function(){s.verboseMode&&console.log("NullRenderer._onClockRateChange")},e._lastRendererId=-1,e}();e.NullRenderer=a},function(e,t){var i=t(27),n=function(){function e(){}return e.makeFontMapFromStyleElement=function(t){for(var n=new i.Map,s=t.sheet,a=Array.prototype.filter.call(s.cssRules,function(e){return e.type===CSSRule.FONT_FACE_RULE
}),r=0;r<a.length;r++){var o=a[r],l=o.style.getPropertyValue("src");l||(l=o.cssText.split("\n").map(function(e){return e.match(/src: ([^;]+);/)}).filter(function(e){return null!==e}).map(function(e){return e[1]})[0]);var c=l.split(/,\s*/).map(function(t){return e._stripQuotes(t.match(/^url\((.+)\)$/)[1])});if(c.length>0){var d=e._stripQuotes(o.style.getPropertyValue("font-family")),u=n.get(d);void 0===u&&(u=[],n.set(d,u)),u.unshift.apply(u,c)}}return n},e.from=function(t){(void 0===t||null===t)&&(t={});
var i=t,n=i.fontMap,s=void 0===n?null:n,a=i.preRenderTime,r=void 0===a?5:a,o=i.preciseOutlines,l=void 0===o?!1:o,c=i.enableSvg,d=void 0===c?!0:c,u=new e;return u.fontMap=s,u.preRenderTime=r,u.preciseOutlines=l,u.enableSvg=d,u},e._stripQuotes=function(e){return e.match(/^["']?(.*?)["']?$/)[1]},e}();e.RendererSettings=n},function(e,t){var i=t(27),n=function(){function e(t){this._cssText="",this._animationStyle="",this._animationDelays=new i.Map,this._numAnimations=0,this._id=t.id+"-"+e._nextId++,this._rate=t.clock.rate
}return Object.defineProperty(e.prototype,"cssText",{get:function(){return this._cssText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationStyle",{get:function(){return this._animationStyle},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationDelays",{get:function(){return this._animationDelays},enumerable:!0,configurable:!0}),e.prototype.add=function(e,t){for(var i=null,n=null,s=0;s<t.length;s++){var a=t[s];null===i&&(i=a.time),n=a.time}for(var r="",o=0;o<t.length;o++){var a=t[o];
r+="	"+(100*(n-i===0?1:(a.time-i)/(n-i))).toFixed(3)+"% {\n",a.properties.forEach(function(e,t){r+="		"+t+": "+e+";\n"}),r+="	}\n"}var l="animation-"+this._id+"-"+this._numAnimations++;this._cssText+="@-webkit-keyframes "+l+" {\n"+r+"\n}\n\n@keyframes "+l+" {\n"+r+"\n}\n\n",""!==this._animationStyle&&(this._animationStyle+=","),this._animationStyle+=l+" "+((n-i)/this._rate).toFixed(3)+"s "+e,this._animationDelays.set(l,i)},e._nextId=0,e}();e.AnimationCollection=n},function(e){e.domParser=null,"undefined"!=typeof DOMParser&&(e.domParser=new DOMParser)
},function(e,t){var i=t(16),n=t(6),s=function(){function e(e,t){this._outputScaleX=e,this._outputScaleY=t,this._scale=1,this._baselineOffset=0}return Object.defineProperty(e.prototype,"scale",{set:function(e){this._scale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baselineOffset",{set:function(e){this._baselineOffset=e},enumerable:!0,configurable:!0}),e.prototype.toSVG=function(e,t){for(var s=Math.pow(2,this._scale-1),a=this._outputScaleX/s,r=this._outputScaleY/s,o="",l=0,c=0,d=0,u=e.instructions;d<u.length;d++){var h=u[d];
h instanceof n.drawing.MoveInstruction?(o+=" M "+h.x+" "+(h.y+this._baselineOffset),l=Math.max(l,h.x),c=Math.max(c,h.y+this._baselineOffset)):h instanceof n.drawing.LineInstruction?(o+=" L "+h.x+" "+(h.y+this._baselineOffset),l=Math.max(l,h.x),c=Math.max(c,h.y+this._baselineOffset)):h instanceof n.drawing.CubicBezierCurveInstruction&&(o+=" C "+h.x1+" "+(h.y1+this._baselineOffset)+", "+h.x2+" "+(h.y2+this._baselineOffset)+", "+h.x3+" "+(h.y3+this._baselineOffset),l=Math.max(l,h.x1,h.x2,h.x3),c=Math.max(c,h.y1+this._baselineOffset,h.y2+this._baselineOffset,h.y3+this._baselineOffset))
}var p='<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'+(l*a).toFixed(3)+'px" height="'+(c*r).toFixed(3)+'px">\n<g transform="scale('+a.toFixed(3)+" "+r.toFixed(3)+')">\n	<path d="'+o+'" fill="'+t.toString()+'" />\n</g>\n</svg>';return i.domParser.parseFromString(p,"image/svg+xml").childNodes[0]},e}();e.DrawingStyles=s},function(e){var t=function(){function e(e,t){this._time=e,this._properties=t}return Object.defineProperty(e.prototype,"time",{get:function(){return this._time},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this._properties
},enumerable:!0,configurable:!0}),e}();e.Keyframe=t},function(e,t){var i=this.__extends||function(e,t){function i(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);i.prototype=t.prototype,e.prototype=new i},n=t(15),s=t(17),a=t(18),r=t(20),o=t(8),l=t(13),c=t(6),d=t(21),u=t(24),h=t(28),p=t(27),m=t(30),f=t(29),g=function(e){function t(t,i,n,s){var a=this;e.call(this,t,i,function(){if(!(n instanceof HTMLDivElement)){var e=s;s=n,n=e,console.warn("WebRenderer's constructor now takes libjassSubsWrapper as the third parameter and settings as the fourth parameter. Please update the caller.")
}return s}()),this._libjassSubsWrapper=n,this._layerWrappers=[],this._layerAlignmentWrappers=[],this._currentSubs=new p.Map,this._preRenderedSubs=new p.Map,this._eventListeners=new p.Map,this._libjassSubsWrapper.classList.add("libjass-wrapper"),this._subsWrapper=document.createElement("div"),this._libjassSubsWrapper.appendChild(this._subsWrapper),this._subsWrapper.className="libjass-subs",this._fontSizeElement=document.createElement("div"),this._libjassSubsWrapper.appendChild(this._fontSizeElement),this._fontSizeElement.className="libjass-font-measure",this._fontSizeElement.appendChild(document.createTextNode("M")),this._animationStyleElement=document.createElement("style"),this._animationStyleElement.id="libjass-animation-styles-"+this.id,this._animationStyleElement.type="text/css",document.querySelector("head").appendChild(this._animationStyleElement);
var r=document.createElementNS("http://www.w3.org/2000/svg","svg");this._libjassSubsWrapper.appendChild(r),r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("version","1.1"),r.setAttribute("class","libjass-filters"),r.setAttribute("width","0"),r.setAttribute("height","0"),this._svgDefsElement=document.createElementNS("http://www.w3.org/2000/svg","defs"),r.appendChild(this._svgDefsElement);var o=new m.Set;null!==this.settings.fontMap&&this.settings.fontMap.forEach(function(e){for(var t=0;t<e.length;t++){var i=e[t];
o.add(i)}}),d.debugMode&&console.log("Preloading "+o.size+" fonts...");var l=[];o.forEach(function(e){l.push(new f.Promise(function(t){var i=new XMLHttpRequest;i.addEventListener("load",function(){d.debugMode&&console.log("Preloaded "+e+"."),t(null)}),i.open("GET",e,!0),i.send()}))}),f.Promise.all(l).then(function(){d.debugMode&&console.log("All fonts have been preloaded."),a._ready()})}return i(t,e),Object.defineProperty(t.prototype,"libjassSubsWrapper",{get:function(){return this._libjassSubsWrapper
},enumerable:!0,configurable:!0}),t.prototype.resize=function(e,t){this._removeAllSubs();var i=Math.min(e/this.ass.properties.resolutionX,t/this.ass.properties.resolutionY),n=this.ass.properties.resolutionX*i,s=this.ass.properties.resolutionY*i;if(this._subsWrapper.style.width=n.toFixed(3)+"px",this._subsWrapper.style.height=s.toFixed(3)+"px",this._subsWrapper.style.left=((e-n)/2).toFixed(3)+"px",this._subsWrapper.style.top=((t-s)/2).toFixed(3)+"px",this._scaleX=n/this.ass.properties.resolutionX,this._scaleY=s/this.ass.properties.resolutionY,this._preRenderedSubs.clear(),null!==this._animationStyleElement)for(;null!==this._animationStyleElement.firstChild;)this._animationStyleElement.removeChild(this._animationStyleElement.firstChild);
for(;null!==this._svgDefsElement.firstChild;)this._svgDefsElement.removeChild(this._svgDefsElement.firstChild);-1!==this.clock.currentTime&&this._onClockTick()},t.prototype.preRender=function(e){var i=this;if(!this._preRenderedSubs.has(e.id)){var o=document.createElement("div");o.style.marginLeft=(this._scaleX*e.style.marginLeft).toFixed(3)+"px",o.style.marginRight=(this._scaleX*e.style.marginRight).toFixed(3)+"px",o.style.marginTop=o.style.marginBottom=(this._scaleY*e.style.marginVertical).toFixed(3)+"px",o.style.minWidth=(this._subsWrapper.offsetWidth-this._scaleX*(e.style.marginLeft+e.style.marginRight)).toFixed(3)+"px";
var l=new n.AnimationCollection(this),h=null,m=new r.SpanStyles(this,e,this._scaleX,this._scaleY,this.settings,this._fontSizeElement,this._svgDefsElement),f=null,g=!1,v=function(e){null!==h&&""!==h.textContent&&o.appendChild(m.setStylesOnSpan(h,f,i._animationStyleElement)),null!==f&&f.animationDelays.forEach(function(e,t){return l.animationDelays.set(t,e)}),e&&o.appendChild(g?m.makeNewLine():document.createElement("br")),h=document.createElement("span"),f=new n.AnimationCollection(i),g=e};v(!1);for(var y=new s.DrawingStyles(this._scaleX,this._scaleY),b=this.ass.properties.wrappingStyle,w=0,x=0,k=e.parts;x<k.length;x++){var S=k[x];
S instanceof c.Italic?m.italic=S.value:S instanceof c.Bold?m.bold=S.value:S instanceof c.Underline?m.underline=S.value:S instanceof c.StrikeThrough?m.strikeThrough=S.value:S instanceof c.Border?(m.outlineWidth=S.value,m.outlineHeight=S.value):S instanceof c.BorderX?m.outlineWidth=S.value:S instanceof c.BorderY?m.outlineHeight=S.value:S instanceof c.Shadow?(m.shadowDepthX=S.value,m.shadowDepthY=S.value):S instanceof c.ShadowX?m.shadowDepthX=S.value:S instanceof c.ShadowY?m.shadowDepthY=S.value:S instanceof c.Blur?m.blur=S.value:S instanceof c.GaussianBlur?m.gaussianBlur=S.value:S instanceof c.FontName?m.fontName=S.value:S instanceof c.FontSize?m.fontSize=S.value:S instanceof c.FontSizePlus?m.fontSize+=S.value:S instanceof c.FontSizeMinus?m.fontSize-=S.value:S instanceof c.FontScaleX?m.fontScaleX=S.value:S instanceof c.FontScaleY?m.fontScaleY=S.value:S instanceof c.LetterSpacing?m.letterSpacing=S.value:S instanceof c.RotateX?m.rotationX=S.value:S instanceof c.RotateY?m.rotationY=S.value:S instanceof c.RotateZ?m.rotationZ=S.value:S instanceof c.SkewX?m.skewX=S.value:S instanceof c.SkewY?m.skewY=S.value:S instanceof c.PrimaryColor?m.primaryColor=S.value:S instanceof c.SecondaryColor?m.secondaryColor=S.value:S instanceof c.OutlineColor?m.outlineColor=S.value:S instanceof c.ShadowColor?m.shadowColor=S.value:S instanceof c.Alpha?(m.primaryAlpha=S.value,m.secondaryAlpha=S.value,m.outlineAlpha=S.value,m.shadowAlpha=S.value):S instanceof c.PrimaryAlpha?m.primaryAlpha=S.value:S instanceof c.SecondaryAlpha?m.secondaryAlpha=S.value:S instanceof c.OutlineAlpha?m.outlineAlpha=S.value:S instanceof c.ShadowAlpha?m.shadowAlpha=S.value:S instanceof c.Alignment||(S instanceof c.ColorKaraoke?(v(!1),f.add("step-end",[new a.Keyframe(0,new p.Map([["color",m.secondaryColor.withAlpha(m.secondaryAlpha).toString()]])),new a.Keyframe(w,new p.Map([["color",m.primaryColor.withAlpha(m.primaryAlpha).toString()]]))]),w+=S.duration):S instanceof c.WrappingStyle?b=S.value:S instanceof c.Reset?m.reset(this.ass.styles.get(S.value)):S instanceof c.Position?(o.style.position="absolute",o.style.left=(this._scaleX*S.x).toFixed(3)+"px",o.style.top=(this._scaleY*S.y).toFixed(3)+"px"):S instanceof c.Move?(o.style.position="absolute",l.add("linear",[new a.Keyframe(0,new p.Map([["left",(this._scaleX*S.x1).toFixed(3)+"px"],["top",(this._scaleY*S.y1).toFixed(3)+"px"]])),new a.Keyframe(S.t1,new p.Map([["left",(this._scaleX*S.x1).toFixed(3)+"px"],["top",(this._scaleY*S.y1).toFixed(3)+"px"]])),new a.Keyframe(S.t2,new p.Map([["left",(this._scaleX*S.x2).toFixed(3)+"px"],["top",(this._scaleY*S.y2).toFixed(3)+"px"]])),new a.Keyframe(e.end-e.start,new p.Map([["left",(this._scaleX*S.x2).toFixed(3)+"px"],["top",(this._scaleY*S.y2).toFixed(3)+"px"]]))])):S instanceof c.Fade?l.add("linear",[new a.Keyframe(0,new p.Map([["opacity","0"]])),new a.Keyframe(S.start,new p.Map([["opacity","1"]])),new a.Keyframe(e.end-e.start-S.end,new p.Map([["opacity","1"]])),new a.Keyframe(e.end-e.start,new p.Map([["opacity","0"]]))]):S instanceof c.ComplexFade?l.add("linear",[new a.Keyframe(0,new p.Map([["opacity",S.a1.toFixed(3)]])),new a.Keyframe(S.t1,new p.Map([["opacity",S.a1.toFixed(3)]])),new a.Keyframe(S.t2,new p.Map([["opacity",S.a2.toFixed(3)]])),new a.Keyframe(S.t3,new p.Map([["opacity",S.a2.toFixed(3)]])),new a.Keyframe(S.t4,new p.Map([["opacity",S.a3.toFixed(3)]])),new a.Keyframe(e.end-e.start,new p.Map([["opacity",S.a3.toFixed(3)]]))]):S instanceof c.DrawingMode?0!==S.scale&&(y.scale=S.scale):S instanceof c.DrawingBaselineOffset?y.baselineOffset=S.value:S instanceof c.DrawingInstructions?(h.appendChild(y.toSVG(S,m.primaryColor.withAlpha(m.primaryAlpha))),v(!1)):S instanceof c.Text?(h.appendChild(document.createTextNode(S.value)),v(!1)):d.debugMode&&S instanceof c.Comment?(h.appendChild(document.createTextNode(S.value)),v(!1)):S instanceof c.NewLine&&v(!0))
}for(var C=0,P=e.parts;C<P.length;C++){var S=P[C];if(S instanceof c.Position||S instanceof c.Move){var A=t._transformOrigins[e.alignment],_="translate("+-A[0]+"%, "+-A[1]+"%) translate(-"+o.style.marginLeft+", -"+o.style.marginTop+")",I=A[0]+"% "+A[1]+"%";o.style.webkitTransform=_,o.style.webkitTransformOrigin=I,o.style.transform=_,o.style.transformOrigin=I;break}}switch(b){case u.WrappingStyle.EndOfLineWrapping:o.style.whiteSpace="pre-wrap";break;case u.WrappingStyle.NoLineWrapping:o.style.whiteSpace="pre";
break;case u.WrappingStyle.SmartWrappingWithWiderTopLine:case u.WrappingStyle.SmartWrappingWithWiderBottomLine:o.style.whiteSpace="pre-wrap"}if(""!==o.style.position)switch(e.alignment){case 1:case 4:case 7:o.style.textAlign="left";break;case 2:case 5:case 8:o.style.textAlign="center";break;case 3:case 6:case 9:o.style.textAlign="right"}this._animationStyleElement.appendChild(document.createTextNode(l.cssText)),o.style.webkitAnimation=l.animationStyle,o.style.animation=l.animationStyle,o.setAttribute("data-dialogue-id",this.id+"-"+e.id),this._preRenderedSubs.set(e.id,{sub:o,animationDelays:l.animationDelays})
}},t.prototype.draw=function(e){var t=this;if(!this._currentSubs.has(e)){d.debugMode&&console.log(e.toString());var i=this._preRenderedSubs.get(e.id);void 0===i&&(d.debugMode&&console.warn("This dialogue was not pre-rendered. Call preRender() before calling draw() so that draw() is faster."),this.preRender(e),i=this._preRenderedSubs.get(e.id),d.debugMode&&console.log(e.toString()));var n=i.sub.cloneNode(!0),s=function(n){var a=n.style.animationName||n.style.webkitAnimationName;if(void 0!==a&&""!==a){var r=a.split(",").map(function(n){n=n.trim();
var s=i.animationDelays.get(n);return((s+e.start-t.clock.currentTime)/t.clock.rate).toFixed(3)+"s"}).join(", ");n.style.webkitAnimationDelay=r,n.style.animationDelay=r}for(var o=0;o<n.children.length;o++)s(n.children[o])};s(n);var a=e.layer,r="absolute"===n.style.position?0:e.alignment;if(void 0===this._layerWrappers[a]){var o=document.createElement("div");o.className="layer layer"+a;for(var l=null,c=a+1;c<this._layerWrappers.length&&null===l;c++)void 0!==this._layerWrappers[c]&&(l=this._layerWrappers[c]);
this._subsWrapper.insertBefore(o,l),this._layerWrappers[a]=o,this._layerAlignmentWrappers[a]=[]}if(void 0===this._layerAlignmentWrappers[a][r]){var u=document.createElement("div");u.className="an an"+r;for(var o=this._layerWrappers[a],l=null,h=r+1;h<this._layerAlignmentWrappers[a].length&&null===l;h++)void 0!==this._layerAlignmentWrappers[a][h]&&(l=this._layerAlignmentWrappers[a][h]);o.insertBefore(u,l),this._layerAlignmentWrappers[a][r]=u}this._layerAlignmentWrappers[a][r].appendChild(n),this._currentSubs.set(e,n)
}},t.prototype._onClockPlay=function(){e.prototype._onClockPlay.call(this),this._removeAllSubs(),this._subsWrapper.style.display="",this._subsWrapper.classList.remove("paused")},t.prototype._onClockTick=function(){var t=this,i=this.clock.currentTime;this._currentSubs.forEach(function(e,n){(n.start>i||n.end<i)&&(t._currentSubs["delete"](n),t._removeSub(e))}),e.prototype._onClockTick.call(this)},t.prototype._onClockPause=function(){e.prototype._onClockPause.call(this),this._subsWrapper.classList.add("paused")
},t.prototype._onClockStop=function(){e.prototype._onClockStop.call(this),this._subsWrapper.style.display="none"},t.prototype._onClockRateChange=function(){if(e.prototype._onClockRateChange.call(this),this._preRenderedSubs.clear(),null!==this._animationStyleElement)for(;null!==this._animationStyleElement.firstChild;)this._animationStyleElement.removeChild(this._animationStyleElement.firstChild);for(;null!==this._svgDefsElement.firstChild;)this._svgDefsElement.removeChild(this._svgDefsElement.firstChild)
},t.prototype._ready=function(){this._dispatchEvent("ready",[])},t.prototype._removeSub=function(e){e.parentNode.removeChild(e)},t.prototype._removeAllSubs=function(){var e=this;this._currentSubs.forEach(function(t){return e._removeSub(t)}),this._currentSubs.clear()},t._transformOrigins=[null,[0,100],[50,100],[100,100],[0,50],[50,50],[100,50],[0,0],[50,0],[100,0]],t}(l.NullRenderer);e.WebRenderer=g,h.mixin(g,[o.EventSource])},function(e,t){var i=t(16),n=t(27),s=function(){function e(e,t,i,n,s,a,r){this._scaleX=i,this._scaleY=n,this._settings=s,this._fontSizeElement=a,this._svgDefsElement=r,this._nextFilterId=0,this._id=e.id+"-"+t.id,this._defaultStyle=t.style,this.reset(null)
}return e.prototype.reset=function(e){(void 0===e||null===e)&&(e=this._defaultStyle),this.italic=e.italic,this.bold=e.bold,this.underline=e.underline,this.strikeThrough=e.strikeThrough,this.outlineWidth=e.outlineThickness,this.outlineHeight=e.outlineThickness,this.shadowDepthX=e.shadowDepth,this.shadowDepthY=e.shadowDepth,this.fontName=e.fontName,this.fontSize=e.fontSize,this.fontScaleX=e.fontScaleX,this.fontScaleY=e.fontScaleY,this.letterSpacing=e.letterSpacing,this._rotationX=null,this._rotationY=null,this._rotationZ=e.rotationZ,this._skewX=null,this._skewY=null,this.primaryColor=e.primaryColor,this.secondaryColor=e.secondaryColor,this.outlineColor=e.outlineColor,this.shadowColor=e.shadowColor,this.primaryAlpha=null,this.secondaryAlpha=null,this.outlineAlpha=null,this.shadowAlpha=null,this.blur=null,this.gaussianBlur=null
},e.prototype.setStylesOnSpan=function(t,n,s){var a=this,r=t.childNodes[0]instanceof Text,o="";this._italic&&(o+="italic "),this._bold===!0?o+="bold ":this._bold!==!1&&(o+=this._bold+" ");var l;l=r?(this._scaleY*e._getFontSize(this._fontName,this._fontSize*this._fontScaleY,this._fontSizeElement)).toFixed(3):(this._scaleY*e._getFontSize(this._fontName,this._fontSize,this._fontSizeElement)).toFixed(3);var c=(this._scaleY*this._fontSize).toFixed(3);t.style.font=""+o+l+"px/"+c+'px "'+this._fontName+'"';
var d="";this._underline&&(d="underline"),this._strikeThrough&&(d+=" line-through"),t.style.textDecoration=d.trim();var u="";if(r?this._fontScaleY!==this._fontScaleX&&(u+="scaleY("+(this._fontScaleY/this._fontScaleX).toFixed(3)+") "):(1!==this._fontScaleX&&(u+="scaleX("+this._fontScaleX+") "),1!==this._fontScaleY&&(u+="scaleY("+this._fontScaleY+") ")),null!==this._rotationY&&(u+="rotateY("+this._rotationY+"deg) "),null!==this._rotationX&&(u+="rotateX("+this._rotationX+"deg) "),0!==this._rotationZ&&(u+="rotateZ("+-1*this._rotationZ+"deg) "),null!==this._skewX||null!==this._skewY){var h=e._valueOrDefault(this._skewX,0),p=e._valueOrDefault(this._skewY,0);
u+="matrix(1, "+p+", "+h+", 1, 0, 0) "}""!==u&&(t.style.webkitTransform=u,t.style.webkitTransformOrigin="50% 50%",t.style.transform=u,t.style.transformOrigin="50% 50%",t.style.display="inline-block"),t.style.letterSpacing=(this._scaleX*this._letterSpacing).toFixed(3)+"px";var m=this._primaryColor.withAlpha(this._primaryAlpha);t.style.color=m.toString();var f=this._outlineColor.withAlpha(this._outlineAlpha),g=this._scaleX*this._outlineWidth,v=this._scaleY*this._outlineHeight,y="",b="";if(this._settings.enableSvg){var w="svg-filter-"+this._id+"-"+this._nextFilterId++;
if(g>0||v>0){var x="",k=0,S=!this._settings.preciseOutlines&&this._gaussianBlur>0?this._gaussianBlur:1;!function(e){if(v>=g)if(g>0){for(var t=0;g>=t;t+=S)e(t,v/g*Math.sqrt(g*g-t*t));t!==g+S&&e(g,0)}else e(0,v);else if(v>0){for(var i=0;v>=i;i+=S)e(g/v*Math.sqrt(v*v-i*i),i);i!==v+S&&e(0,v)}else e(g,0)}(function(e,t){y+='	<feMorphology in="SourceAlpha" operator="dilate" radius="'+e.toFixed(3)+" "+t.toFixed(3)+'" result="outline'+k+'" />\n',x+='		<feMergeNode in="outline'+k+'" />\n',k++}),y+='	<feMerge result="outline">\n'+x+'\n</feMerge>\n<feFlood flood-color="'+f.toString()+'" />\n<feComposite operator="in" in2="outline" />\n'
}this._gaussianBlur>0&&(b+='	<feGaussianBlur stdDeviation="'+this._gaussianBlur+'" />\n');for(var C=0;C<this._blur;C++)b+='	<feConvolveMatrix kernelMatrix="1 2 1 2 4 2 1 2 1" edgeMode="none" />\n'}else if(g>0||v>0){var P="";!function(e){for(var t=0;g>=t;t++)for(var i=0===g?v:v*Math.sqrt(1-t*t/(g*g)),n=0;i>=n;n++)e(t,n),0!==t&&e(-t,n),0!==n&&e(t,-n),0!==t&&0!==n&&e(-t,-n)}(function(e,t){P+=", "+f.toString()+" "+e+"px "+t+"px "+a._gaussianBlur.toFixed(3)+"px"}),t.style.textShadow=P.substr(", ".length)
}var A=document.createElement("span");if(A.appendChild(t),""!==y||""!==b){var _='<filter xmlns="http://www.w3.org/2000/svg" id="'+w+'" x="-50%" width="200%" y="-50%" height="200%">\n'+y+"\n"+b+'\n<feMerge>\n	<feMergeNode />\n	<feMergeNode in="SourceGraphic" />\n</feMerge>\n</filter>\n',I=i.domParser.parseFromString(_,"image/svg+xml").childNodes[0];this._svgDefsElement.appendChild(I),A.style.webkitFilter='url("#'+w+'")',A.style.filter='url("#'+w+'")'}if(0!==this._shadowDepthX||0!==this._shadowDepthY){var T=this._shadowColor.withAlpha(this._shadowAlpha),M=T.toString()+" "+(this._shadowDepthX*this._scaleX/this._fontScaleX).toFixed(3)+"px "+(this._shadowDepthY*this._scaleY/this._fontScaleY).toFixed(3)+"px 0px";
""===t.style.textShadow?t.style.textShadow=M:t.style.textShadow+=", "+M}return(0!==this._rotationX||0!==this._rotationY)&&(A.style.display="inline-block"),s.appendChild(document.createTextNode(n.cssText)),t.style.webkitAnimation=n.animationStyle,t.style.animation=n.animationStyle,A},e.prototype.makeNewLine=function(){var e=document.createElement("br");return e.style.lineHeight=(this._scaleY*this._fontSize).toFixed(3)+"px",e},Object.defineProperty(e.prototype,"italic",{set:function(t){this._italic=e._valueOrDefault(t,this._defaultStyle.italic)
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bold",{set:function(t){this._bold=e._valueOrDefault(t,this._defaultStyle.bold)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"underline",{set:function(t){this._underline=e._valueOrDefault(t,this._defaultStyle.underline)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strikeThrough",{set:function(t){this._strikeThrough=e._valueOrDefault(t,this._defaultStyle.strikeThrough)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineWidth",{set:function(t){this._outlineWidth=e._valueOrDefault(t,this._defaultStyle.outlineThickness)
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineHeight",{set:function(t){this._outlineHeight=e._valueOrDefault(t,this._defaultStyle.outlineThickness)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowDepthX",{set:function(t){this._shadowDepthX=e._valueOrDefault(t,this._defaultStyle.shadowDepth)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowDepthY",{set:function(t){this._shadowDepthY=e._valueOrDefault(t,this._defaultStyle.shadowDepth)
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blur",{set:function(t){this._blur=e._valueOrDefault(t,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gaussianBlur",{set:function(t){this._gaussianBlur=e._valueOrDefault(t,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontName",{set:function(t){this._fontName=e._valueOrDefault(t,this._defaultStyle.fontName)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{set:function(t){this._fontSize=e._valueOrDefault(t,this._defaultStyle.fontSize)
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontScaleX",{set:function(t){this._fontScaleX=e._valueOrDefault(t,this._defaultStyle.fontScaleX)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontScaleY",{set:function(t){this._fontScaleY=e._valueOrDefault(t,this._defaultStyle.fontScaleY)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"letterSpacing",{set:function(t){this._letterSpacing=e._valueOrDefault(t,this._defaultStyle.letterSpacing)
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationX",{set:function(e){this._rotationX=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationY",{set:function(e){this._rotationY=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationZ",{set:function(t){this._rotationZ=e._valueOrDefault(t,this._defaultStyle.rotationZ)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skewX",{set:function(e){this._skewX=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skewY",{set:function(e){this._skewY=e
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"primaryColor",{get:function(){return this._primaryColor},set:function(t){this._primaryColor=e._valueOrDefault(t,this._defaultStyle.primaryColor)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secondaryColor",{get:function(){return this._secondaryColor},set:function(t){this._secondaryColor=e._valueOrDefault(t,this._defaultStyle.secondaryColor)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineColor",{set:function(t){this._outlineColor=e._valueOrDefault(t,this._defaultStyle.outlineColor)
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowColor",{set:function(t){this._shadowColor=e._valueOrDefault(t,this._defaultStyle.shadowColor)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"primaryAlpha",{get:function(){return this._primaryAlpha},set:function(e){this._primaryAlpha=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secondaryAlpha",{get:function(){return this._secondaryAlpha},set:function(e){this._secondaryAlpha=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineAlpha",{set:function(e){this._outlineAlpha=e
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowAlpha",{set:function(e){this._shadowAlpha=e},enumerable:!0,configurable:!0}),e._getFontSize=function(t,i,s){var a=e._fontSizeCache.get(t);void 0===a&&e._fontSizeCache.set(t,a=new n.Map);var r=a.get(i);return void 0===r&&(s.style.fontFamily=t,s.style.fontSize=i+"px",a.set(i,r=i*i/s.offsetHeight)),r},e._fontSizeCache=new n.Map,e._valueOrDefault=function(e,t){return null!==e?e:t},e}();e.SpanStyles=s},function(e){function t(t){e.debugMode=t
}function i(t){e.verboseMode=t}e.debugMode=!1,e.verboseMode=!1,e.setDebugMode=t,e.setVerboseMode=i},function(e,t){var i=t(23),n=t(26),s=t(25),a=t(24),r=t(21),o=t(1),l=t(2),c=t(27),d=function(){function e(){if(this._properties=new s.ScriptProperties,this._styles=new c.Map,this._dialogues=[],this._stylesFormatSpecifier=null,this._dialoguesFormatSpecifier=null,1===arguments.length)throw new Error("Constructor `new ASS(rawASS)` has been deprecated. Use `ASS.fromString(rawASS)` instead.")}return Object.defineProperty(e.prototype,"properties",{get:function(){return this._properties
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"styles",{get:function(){return this._styles},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dialogues",{get:function(){return this._dialogues},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stylesFormatSpecifier",{get:function(){return this._stylesFormatSpecifier},set:function(e){this._stylesFormatSpecifier=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dialoguesFormatSpecifier",{get:function(){return this._dialoguesFormatSpecifier
},set:function(e){this._dialoguesFormatSpecifier=e},enumerable:!0,configurable:!0}),e.prototype.addStyle=function(e){var t=l.parseLineIntoTypedTemplate(e,this._stylesFormatSpecifier);if(null!==t&&"Style"===t.type){var i=t.template;if(r.verboseMode){var s="";i.forEach(function(e,t){return s+=t+" = "+e+", "}),console.log("Read style: "+s)}var a=new n.Style(i);this._styles.set(a.name,a)}},e.prototype.addEvent=function(e){var t=l.parseLineIntoTypedTemplate(e,this._dialoguesFormatSpecifier);if(null!==t&&"Dialogue"===t.type){var n=t.template;
if(r.verboseMode){var s="";n.forEach(function(e,t){return s+=t+" = "+e+", "}),console.log("Read dialogue: "+s)}this.dialogues.push(new i.Dialogue(n,this))}},e.fromString=function(t,i){return void 0===i&&(i=a.Format.ASS),e.fromStream(new o.StringStream(t),i)},e.fromStream=function(e,t){switch(void 0===t&&(t=a.Format.ASS),t){case a.Format.ASS:return new o.StreamParser(e).ass;case a.Format.SRT:return new o.SrtStreamParser(e).ass;default:throw new Error("Illegal value of type: "+t)}},e.fromUrl=function(t,i){void 0===i&&(i=a.Format.ASS);
var n=new XMLHttpRequest,s=e.fromStream(new o.XhrStream(n),i);return n.open("GET",t,!0),n.send(),s},e}();e.ASS=d},function(e,t){var i=t(24),n=t(3),s=t(6),a=t(21),r=function(){function e(t,n){this._parts=null,this._sub=null,this._id=++e._lastDialogueId;var s=t.get("Style");if(this._style=n.styles.get(s),void 0===this._style)throw new Error("Unrecognized style "+s);if(this._start=e._toTime(t.get("Start")),this._end=e._toTime(t.get("End")),this._layer=Math.max(i.valueOrDefault(t,"Layer",parseInt,function(e){return!isNaN(e)
},"0"),0),this._rawPartsString=t.get("Text"),void 0===this._rawPartsString||null===this._rawPartsString||this._rawPartsString.constructor!==String)throw new Error("Dialogue doesn't have any text.")}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"style",{get:function(){return this._style
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alignment",{get:function(){return null===this._parts&&this._parsePartsString(),this._alignment},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"layer",{get:function(){return this._layer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parts",{get:function(){return null===this._parts&&this._parsePartsString(),this._parts},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"#"+this._id+" ["+this._start.toFixed(3)+"-"+this._end.toFixed(3)+"] "+(null!==this._parts?this._parts.join(", "):this._rawPartsString)
},e.prototype._parsePartsString=function(){var e=this;if(this._parts=n.parse(this._rawPartsString,"dialogueParts"),this._alignment=this._style.alignment,this._parts.forEach(function(t,i){t instanceof s.Alignment?e._alignment=t.value:t instanceof s.Move?(null===t.t1||null===t.t2)&&(e._parts[i]=new s.Move(t.x1,t.y1,t.x2,t.y2,0,e._end-e._start)):t instanceof s.Transform&&(null===t.start||null===t.end||null===t.accel)&&(e._parts[i]=new s.Transform(null===t.start?0:t.start,null===t.end?e._end-e._start:t.end,null===t.accel?1:t.accel,t.tags))
}),a.debugMode){var t=this._parts.filter(function(e){return e instanceof s.Comment&&-1!==e.value.indexOf("\\")});t.length>0&&console.warn("Possible incorrect parse:\n"+this._rawPartsString+"\nwas parsed as\n"+this.toString()+"\nThe possibly incorrect parses are:\n"+t.join("\n"))}},e._toTime=function(e){return e.split(":").reduce(function(e,t){return 60*e+parseFloat(t)},0)},e._lastDialogueId=-1,e}();e.Dialogue=r},function(e){function t(e,t,i,n,s){var a=e.get(t);if(void 0===a)return i(s);try{var r=i(a);
if(null!==n&&!n(r))throw new Error("Validation failed.");return r}catch(o){throw new Error("Property "+t+" has invalid value "+a+" - "+o.stack)}}!function(e){e[e.ASS=0]="ASS",e[e.SRT=1]="SRT"}(e.Format||(e.Format={})),function(e){e[e.SmartWrappingWithWiderTopLine=0]="SmartWrappingWithWiderTopLine",e[e.SmartWrappingWithWiderBottomLine=3]="SmartWrappingWithWiderBottomLine",e[e.EndOfLineWrapping=1]="EndOfLineWrapping",e[e.NoLineWrapping=2]="NoLineWrapping"}(e.WrappingStyle||(e.WrappingStyle={})),function(e){e[e.Outline=1]="Outline",e[e.OpaqueBox=3]="OpaqueBox"
}(e.BorderStyle||(e.BorderStyle={})),e.valueOrDefault=t},function(e){var t=function(){function e(){}return Object.defineProperty(e.prototype,"resolutionX",{get:function(){return this._resolutionX},set:function(e){this._resolutionX=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"resolutionY",{get:function(){return this._resolutionY},set:function(e){this._resolutionY=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wrappingStyle",{get:function(){return this._wrappingStyle
},set:function(e){this._wrappingStyle=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleBorderAndShadow",{get:function(){return this._scaleBorderAndShadow},set:function(e){this._scaleBorderAndShadow=e},enumerable:!0,configurable:!0}),e}();e.ScriptProperties=t},function(e,t){var i=t(24),n=t(3),s=function(){function e(e){if(this._name=e.get("Name"),void 0===this._name||null===this._name||this._name.constructor!==String)throw new Error("Style doesn't have a name.");this._italic="-1"===e.get("Italic"),this._bold="-1"===e.get("Bold"),this._underline="-1"===e.get("Underline"),this._strikeThrough="-1"===e.get("StrikeOut"),this._fontName=e.get("Fontname"),this._fontSize=i.valueOrDefault(e,"Fontsize",parseFloat,function(e){return!isNaN(e)
},"50"),this._fontScaleX=i.valueOrDefault(e,"ScaleX",parseFloat,function(e){return!isNaN(e)},"100")/100,this._fontScaleY=i.valueOrDefault(e,"ScaleY",parseFloat,function(e){return!isNaN(e)},"100")/100,this._letterSpacing=i.valueOrDefault(e,"Spacing",parseFloat,function(e){return!isNaN(e)},"0"),this._rotationZ=i.valueOrDefault(e,"Angle",parseFloat,function(e){return!isNaN(e)},"0"),this._primaryColor=i.valueOrDefault(e,"PrimaryColour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H0000FFFF"),this._secondaryColor=i.valueOrDefault(e,"SecondaryColour",function(e){return n.parse(e,"colorWithAlpha")
},null,"&H00000000"),this._outlineColor=i.valueOrDefault(e,"OutlineColour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H00000000"),this._shadowColor=i.valueOrDefault(e,"BackColour",function(e){return n.parse(e,"colorWithAlpha")},null,"&H00000000"),this._outlineThickness=i.valueOrDefault(e,"Outline",parseFloat,function(e){return!isNaN(e)},"1"),this._borderStyle=i.valueOrDefault(e,"BorderStyle",parseInt,function(e){return!isNaN(e)},"1"),this._shadowDepth=i.valueOrDefault(e,"Shadow",parseFloat,function(e){return!isNaN(e)
},"1"),this._alignment=i.valueOrDefault(e,"Alignment",parseInt,function(e){return!isNaN(e)},"2"),this._marginLeft=i.valueOrDefault(e,"MarginL",parseFloat,function(e){return!isNaN(e)},"80"),this._marginRight=i.valueOrDefault(e,"MarginR",parseFloat,function(e){return!isNaN(e)},"80"),this._marginVertical=i.valueOrDefault(e,"MarginV",parseFloat,function(e){return!isNaN(e)},"35")}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"italic",{get:function(){return this._italic
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bold",{get:function(){return this._bold},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"underline",{get:function(){return this._underline},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strikeThrough",{get:function(){return this._strikeThrough},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontName",{get:function(){return this._fontName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{get:function(){return this._fontSize
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontScaleX",{get:function(){return this._fontScaleX},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontScaleY",{get:function(){return this._fontScaleY},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"letterSpacing",{get:function(){return this._letterSpacing},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationZ",{get:function(){return this._rotationZ},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"primaryColor",{get:function(){return this._primaryColor
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secondaryColor",{get:function(){return this._secondaryColor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineColor",{get:function(){return this._outlineColor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowColor",{get:function(){return this._shadowColor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"outlineThickness",{get:function(){return this._outlineThickness
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"borderStyle",{get:function(){return this._borderStyle},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowDepth",{get:function(){return this._shadowDepth},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alignment",{get:function(){return this._alignment},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"marginLeft",{get:function(){return this._marginLeft},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"marginRight",{get:function(){return this._marginRight
},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"marginVertical",{get:function(){return this._marginVertical},enumerable:!0,configurable:!0}),e}();e.Style=s},function(t){function i(e){t.Map=null!==e?e:n}var n=function(){function e(e){if(this.clear(),void 0!==e){if(!Array.isArray(e))throw new Error("Non-array iterables are not supported by the SimpleMap constructor.");for(var t=0;t<e.length;t++){var i=e[t];this.set(i[0],i[1])}}}return e.prototype.get=function(e){var t=this._keyToProperty(e);
return null===t?void 0:this._values[t]},e.prototype.has=function(e){var t=this._keyToProperty(e);return null===t?!1:t in this._keys},e.prototype.set=function(e,t){var i=this._keyToProperty(e);if(null===i)throw new Error("This Map implementation only supports Number and String keys, or keys with an id property.");return i in this._keys||this._size++,this._keys[i]=e,this._values[i]=t,this},e.prototype["delete"]=function(e){var t=this._keyToProperty(e);if(null===t)return!1;var i=t in this._keys;return i&&(delete this._keys[t],delete this._values[t],this._size--),i
},e.prototype.clear=function(){this._keys=Object.create(null),this._values=Object.create(null),this._size=0},e.prototype.forEach=function(e,t){for(var i=0,n=Object.keys(this._keys);i<n.length;i++){var s=n[i];e.call(t,this._values[s],this._keys[s],this)}},Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype._keyToProperty=function(e){return"number"==typeof e?"#"+e:"string"==typeof e?"'"+e:void 0!==e.id?"!"+e.id:null},e}();t.Map=e.Map,(void 0===t.Map||"function"!=typeof t.Map.prototype.forEach||function(){try{return 2!==new t.Map([[1,"foo"],[2,"bar"]]).size
}catch(e){return!0}}())&&(t.Map=n),t.setImplementation=i},function(e){function t(e,t){for(var i=0;i<t.length;i++)for(var n=t[i],s=0,a=Object.getOwnPropertyNames(n.prototype);s<a.length;s++){var r=a[s];e.prototype[r]=n.prototype[r]}}e.mixin=t},function(t){function i(e){t.Promise=null!==e?e:s}var n,s=function(){function i(e){var t=this;this._resolver=e,this._state=n.PENDING,this._thens=[],this._propagateIsPending=!1,this._alreadyFulfilledValue=null,this._alreadyRejectedReason=null;try{e(function(e){return t._resolve(e)
},function(e){return t._reject(e)})}catch(i){this._reject(i)}}return i.prototype.then=function(e,i){var n=this;if(e="function"==typeof e?e:null,i="function"==typeof i?i:null,null===e&&null===i)return this;null===e&&(e=function(e){return e}),null===i&&(i=function(e){throw e});var s=new t.Promise(function(t,s){n._thens.push({propagateFulfilling:function(i){try{t(e(i))}catch(n){s(n)}},propagateRejection:function(e){try{t(i(e))}catch(n){s(n)}}})});return this._propagateResolution(),s},i.prototype["catch"]=function(e){return this.then(null,e)
},i.prototype.isFulfilled=function(){return this._state===n.FULFILLED},i.prototype.isRejected=function(){return this._state===n.REJECTED},i.prototype.isPending=function(){return this._state===n.PENDING},i.prototype.value=function(){if(this._state!==n.FULFILLED)throw new Error("This promise is not in FULFILLED state.");return this._alreadyFulfilledValue},i.prototype.reason=function(){if(this._state!==n.REJECTED)throw new Error("This promise is not in FULFILLED state.");return this._alreadyRejectedReason
},i.resolve=function(e){return e instanceof i?e:new t.Promise(function(t){return t(e)})},i.all=function(e){return new t.Promise(function(i,n){var s=[],a=e.length;return 0===a?void i(s):void e.forEach(function(e,n){return t.Promise.resolve(e).then(function(e){s[n]=e,a--,0===a&&i(s)})},n)})},i.prototype._resolve=function(e){var t=this,n=!1;try{if(e===this)throw new TypeError("2.3.1");var s=i._getThenMethod(e);if(null===s)return void this._fulfill(e);s.call(e,function(e){n||(n=!0,t._resolve(e))},function(e){n||(n=!0,t._reject(e))
})}catch(a){if(n)return;this._reject(a)}},i.prototype._fulfill=function(e){this._state===n.PENDING&&(this._state=n.FULFILLED,this._alreadyFulfilledValue=e,this._propagateResolution())},i.prototype._reject=function(e){this._state===n.PENDING&&(this._state=n.REJECTED,this._alreadyRejectedReason=e,this._propagateResolution())},i._getThenMethod=function(e){if("object"!=typeof e&&"function"!=typeof e)return null;if(null===e||void 0===e)return null;var t=e.then;return"function"!=typeof t?null:t},i.prototype._propagateResolution=function(){var e=this;
this._state!==n.PENDING&&(this._propagateIsPending||(this._propagateIsPending=!0,i._nextTick(function(){if(e._propagateIsPending=!1,e._state===n.FULFILLED)for(;e._thens.length>0;){var t=e._thens.shift();t.propagateFulfilling(e._alreadyFulfilledValue)}else if(e._state===n.REJECTED)for(;e._thens.length>0;){var t=e._thens.shift();t.propagateRejection(e._alreadyRejectedReason)}})))},i._nextTick=function(){var t=e.MutationObserver||e.WebkitMutationObserver;if(void 0!==e.process&&"function"==typeof e.process.nextTick)return function(t){e.process.nextTick(t)
};if(void 0!==t){var i=[],n=!1,s=document.createElement("div"),a=new t(function(){var e=i;i=[];for(var t=0;t<e.length;t++){var a=e[t];a()}n=!1,i.length>0&&(s.classList.toggle("foo"),n=!0)});return a.observe(s,{attributes:!0}),function(e){i.push(e),n||(s.classList.toggle("foo"),n=!0)}}return function(e){return setTimeout(e,0)}}(),i}();!function(e){e[e.PENDING=0]="PENDING",e[e.FULFILLED=1]="FULFILLED",e[e.REJECTED=2]="REJECTED"}(n||(n={})),t.Promise=e.Promise,void 0===t.Promise&&(t.Promise=s),t.setImplementation=i;
var a=function(){function e(){var e=this;this._promise=new t.Promise(function(t,i){e._resolve=t,e._reject=i})}return Object.defineProperty(e.prototype,"promise",{get:function(){return this._promise},enumerable:!0,configurable:!0}),e.prototype.resolve=function(e){this._resolve(e)},e.prototype.reject=function(e){this._reject(e)},e}();t.DeferredPromise=a},function(t){function i(e){t.Set=null!==e?e:n}var n=function(){function e(e){if(this.clear(),void 0!==e){if(!Array.isArray(e))throw new Error("Non-array iterables are not supported by the SimpleSet constructor.");
for(var t=0;t<e.length;t++){var i=e[t];this.add(i)}}}return e.prototype.add=function(e){var t=this._toProperty(e);if(null===t)throw new Error("This Set implementation only supports Number and String values.");return t in this._elements||this._size++,this._elements[t]=e,this},e.prototype.clear=function(){this._elements=Object.create(null),this._size=0},e.prototype.has=function(e){var t=this._toProperty(e);return null===t?!1:t in this._elements},e.prototype.forEach=function(e,t){for(var i=0,n=Object.keys(this._elements);i<n.length;i++){var s=n[i],a=this._elements[s];
e.call(t,a,a,this)}},Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype._toProperty=function(e){return"number"==typeof e?"#"+e:"string"==typeof e?"'"+e:null},e}();t.Set=e.Set,(void 0===t.Set||"function"!=typeof t.Set.prototype.forEach||function(){try{return 2!==new t.Set([1,2]).size}catch(e){return!0}}())&&(t.Set=n),t.setImplementation=i},function(e,t){var i=t(27),n=t(29),s=t(32),a=t(34),r=function(){function e(e){var t=this;this._comm=e,this._pendingRequests=new i.Map,this._comm.addEventListener("message",function(e){return t._onMessage(e.data)
},!1)}return e.prototype.request=function(t,i){var s=new n.DeferredPromise,r=++e._lastRequestId;this._pendingRequests.set(r,s);var o={requestId:r,command:t,parameters:i};return this._comm.postMessage(a.serialize(o)),s.promise},e.prototype.cancelRequest=function(e){var t=this._pendingRequests.get(e);void 0!==t&&(this._pendingRequests["delete"](e),t.reject(new Error("Cancelled.")))},e.prototype._respond=function(e){var t=e.requestId,i=e.error,n=e.result;i instanceof Error&&(i={message:i.message,stack:i.stack}),this._comm.postMessage(a.serialize({command:s.WorkerCommands.Response,requestId:t,error:i,result:n}))
},e.prototype._onMessage=function(e){var t=this,i=a.deserialize(e);if(i.command===s.WorkerCommands.Response){var n=i,r=this._pendingRequests.get(n.requestId);void 0!==r&&(this._pendingRequests["delete"](n.requestId),null===n.error?r.resolve(n.result):r.reject(n.error))}else{var o=i,l=o.requestId,c=a.getWorkerCommandHandler(o.command);if(void 0===c)return void this._respond({requestId:l,error:new Error("No handler registered for command "+o.command),result:null});c(o.parameters).then(function(e){return{requestId:l,error:null,result:e}
},function(e){return{requestId:l,error:e,result:null}}).then(function(e){return t._respond(e)})}},e._lastRequestId=-1,e}();e.WorkerChannelImpl=r},function(e){!function(e){e[e.Response=0]="Response",e[e.Parse=1]="Parse"}(e.WorkerCommands||(e.WorkerCommands={}))},function(t,i){function n(e){return void 0===e&&(e=r.src),new s.WorkerChannelImpl(new Worker(e))}var s=i(31),a=i(32);t.WorkerCommands=a.WorkerCommands,t.supported="undefined"!=typeof Worker,t.createWorker=n;var r=null;"undefined"!=typeof document&&void 0!==document.currentScript&&(r=document.currentScript),"undefined"!=typeof WorkerGlobalScope&&e instanceof WorkerGlobalScope&&new s.WorkerChannelImpl(e)
},function(e,t){function i(e,t){l.set(e,t)}function n(e){return l.get(e)}function s(e){e._classTag=c.size,c.set(e._classTag,e)}function a(e){return JSON.stringify(e,function(e,t){return t&&void 0!==t._classTag&&(t._classTag=t._classTag),t})}function r(e){return JSON.parse(e,function(e,t){if(t&&void 0!==t._classTag){for(var i=Object.create(c.get(t._classTag)),n=0,s=Object.keys(t);n<s.length;n++){var a=s[n];"_classTag"!==a&&(i[a]=t[a])}t=i}return t})}var o=t(27),l=new o.Map,c=new o.Map;e.registerWorkerCommand=i,e.getWorkerCommandHandler=n,e.registerClassPrototype=s,e.serialize=a,e.deserialize=r
}])}),define("plex/base/views/components/player/ASSRendererView",["hb!./ASSRendererView","underscore","jquery","marionette","libjass"],function(e,t,i,n,s){"use strict";var a=n.ItemView.extend({className:"video-subtitles-renderer",template:e,delay:0,subtitleSize:100,modelEvents:{"change:playing":"onPlayingChange","change:paused":"onPausedChange","change:buffering":"onPausedChange","change:stopped":"onStoppedChange","change:error":"onStoppedChange","change:showFullScreen":"onShowFullScreenChange"},initialize:function(e){this.bindAllWhenRendered("renderSubtitles","onSubtitleFailure"),this.delay=e.delay||this.delay,this.rendererOptions=e.rendererOptions||this.rendererOptions||{},this.subtitleSize=e.subtitleSize||this.subtitleSize,this.clock=new s.renderers.AutoClock(t.bind(this.getPosition,this),500),this.debouncedResize=t.debounce(this.whenRendered(this.resizeSubtitles),200)
},loadThenRenderSubtitles:function(){this.loadSubtitles().then(this.renderSubtitles,this.onSubtitleFailure)},loadSubtitles:function(){this.xhr=new XMLHttpRequest;var e=new s.parser.XhrStream(this.xhr),i=new s.parser.StreamParser(e);return this.xhr.open("GET",this.model.get("subtitlesUrl"),!0),this.xhr.send(),this.xhr.onreadystatechange=t.bind(function(){4===this.xhr.readyState&&200!=this.xhr.status&&this.onSubtitleFailure()},this),i.minimalASS},renderSubtitles:function(e){var n=t.defaults(this.rendererOptions,{enableSvg:!0,preciseOutlines:!1});
this.renderer=new s.renderers.WebRenderer(e,this.clock,this.el,n),this.setSubtitleSize(),this.resizeSubtitles(),i(window).on("resize",this.debouncedResize)},setSubtitleSize:function(){var e=this.renderer._ass._properties,t=this.subtitleSize/100;e._resolutionX/=t,e._resolutionY/=t},resizeSubtitles:function(){this.renderer.resize(this.$el.width(),this.$el.height())},getPosition:function(){var e=this.model.get("position"),t=this.model.get("offset")||0,i=(e-t+this.delay)/1e3;return i},onRender:function(){this.loadThenRenderSubtitles()
},onClose:function(){i(window).off("resize",this.debouncedResize),this.clock.disable(),this.xhr&&(this.xhr.onreadystatechange=null)},onPlayingChange:function(e,t){t&&this.clock.play()},onPausedChange:function(e,t){t&&this.clock.pause()},onStoppedChange:function(e,t){t&&this.clock.disable()},onShowFullScreenChange:function(){this.resizeSubtitles()},onSubtitleFailure:function(){this.model.set("softSubtitlesFailed",!0)}});return a}),define("hb!templates/desktop/players/controls/SeekBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="player-slider-track">\n  <div class="player-slider-buffer"></div>\n  <div class="player-slider-progress"></div>\n</div>\n\n<div class="player-slider-thumb"></div>\n'
})}),define("hb!templates/desktop/players/controls/SliderView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="player-slider-track">\n  <div class="player-slider-progress"></div>\n</div>\n\n<div class="player-slider-thumb"></div>\n'})}),define("plex/desktop/views/players/controls/SliderView",["hb!templates/desktop/players/controls/SliderView.tpl","underscore","jquery","marionette"],function(e,t,i,n){"use strict";
var s=n.ItemView.extend({className:"player-slider",template:e,dragging:!1,ui:{thumb:".player-slider-thumb",track:".player-slider-track",progress:".player-slider-progress"},events:{mousedown:"onMouseDown",touchstart:"onTouchStart"},onlyAfterRender:["displayValue"],initialize:function(e){t.bindAll(this,"onMouseMove","onMouseUp","onTouchMove","onTouchEnd"),this.$document=i(document),this.currentValue=e.value||0},startDragging:function(){this.dragging=!0,this.$el.addClass("active")},stopDragging:function(){this.dragging=!1,this.$el.removeClass("active"),this.triggerMethod("dragComplete")
},updateForPosition:function(e,t){var i=this.getValueForPosition(e);this.setValue(i),this.displayValue(i,t)},getValueForPosition:function(e){var t=this.ui.track,i=e-t.offset().left,n=i/t.width();return n=Math.min(Math.max(n,0),1),n=Math.round(100*n)},setValue:function(e){this.currentValue=e,this.trigger("change:value",e)},displayValue:function(e){this.ui.thumb.css("left",e+"%"),this.ui.progress.css("width",e+"%"),this.$el.data("value",e)},onRender:function(){this.displayValue(this.currentValue)},onClose:function(){this.$document.off("mousemove",this.onMouseMove),this.$document.off("mouseup",this.onMouseUp),this.$document.off("touchmove",this.onTouchMove),this.$document.off("touchend",this.onTouchEnd)
},onMouseDown:function(e){e.preventDefault(),this.$document.on("mousemove",this.onMouseMove),this.$document.on("mouseup",this.onMouseUp),this.startDragging(),this.setValue(this.getValueForPosition(e.pageX))},onTouchStart:function(e){this.$document.on("touchmove",this.onTouchMove),this.$document.on("touchend",this.onTouchEnd),this.startDragging();var t=e.originalEvent.touches[0];t&&this.updateForPosition(t.pageX)},onMouseMove:function(e){e.preventDefault(),this.updateForPosition(e.pageX)},onTouchMove:function(e){e.preventDefault();
var t=e.originalEvent.touches[0];t&&this.updateForPosition(t.pageX)},onMouseUp:function(e){e.preventDefault(),this.$document.off("mousemove",this.onMouseMove),this.$document.off("mouseup",this.onMouseUp),this.updateForPosition(e.pageX),this.stopDragging()},onTouchEnd:function(e){this.$document.off("touchmove",this.onTouchMove),this.$document.off("touchend",this.onTouchEnd);var t=e.originalEvent.touches[0];t&&this.updateForPosition(t.pageX),this.stopDragging()}});return s}),define("plex/desktop/views/players/controls/SeekBarView",["hb!templates/desktop/players/controls/SeekBarView.tpl","underscore","plex/desktop/views/players/controls/SliderView"],function(e,t,i){"use strict";
var n=i.extend({className:"player-seek-bar player-slider",template:e,ui:{thumb:".player-slider-thumb",track:".player-slider-track",progress:".player-slider-progress",buffer:".player-slider-buffer"},modelEvents:{"change:position":"onPositionChange","change:startBuffer":"onBufferChange","change:endBuffer":"onBufferChange"},events:t.extend({mouseenter:"onMouseMove",mousemove:"onMouseMove",mouseleave:"onMouseLeave"},i.prototype.events),normalizeValue:function(e){var t=this.model.get("duration");return e=t?e/t*100:0,e=Math.min(Math.max(e,0),100)
},getValueForPosition:function(e){var t=this.model.get("duration"),i=this.ui.track,n=e-i.offset().left,s=n/i.width();return s=Math.min(Math.max(s,0),1),s*=t,Math.round(s)},setValue:function(){this.model.get("canSeek")&&i.prototype.setValue.apply(this,arguments)},displayValue:function(e){e=this.normalizeValue(e),this.dragging&&(e>=100||!this.model.get("canSeek"))||i.prototype.displayValue.call(this,e)},onRender:function(){this.displayValue(this.model.get("position"))},onPositionChange:function(e,t){this.displayValue(t)
},onBufferChange:function(){var e=this.model.get("endBuffer"),t=this.normalizeValue(e);this.ui.buffer.css("width",t+"%")},onMouseMove:function(e){var t=e.pageX,i=this.getValueForPosition(t);this.trigger("hover",{position:t,time:i})},onMouseLeave:function(){this.trigger("hover",!1)}});return n}),define("hb!templates/desktop/players/controls/VideoPlayerQualityDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"selected"}function r(e,t){var n,s,r="";return r+='\n    <li>\n      <a class="',n=i["if"].call(e,e&&e.selected,{hash:{},inverse:u.noop,fn:u.program(1,a,t),data:t}),(n||0===n)&&(r+=n),r+='" data-index="',(n=i.index)?n=n.call(e,{hash:{},data:t}):(n=e&&e.index,n=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=p(n)+'" href="#">\n        ',s={hash:{},data:t},r+=p((n=i.formatVideoQuality||e&&e.formatVideoQuality,n?n.call(e,e,s):m.call(e,"formatVideoQuality",e,s)))+' <i class="player-dropdown-selected-icon dropdown-selected-icon glyphicon ok-2"></i>\n      </a>\n    </li>\n  '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h="function",p=this.escapeExpression,m=i.helperMissing;return d+='<button class="btn-link dropdown-toggle" href="#player-quality-dropdown" data-toggle="dropdown">\n  <i class="glyphicon adjust-alt"></i>\n</button>\n\n<ul class="dropdown-menu pull-right">\n  <li>\n    <a class="',o=i.unless.call(t,t&&t.hasSelectedQuality,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(d+=o),d+='" data-index="-1" href="#">\n      ',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Original",c):m.call(t,"t","Original",c)))+' <i class="player-dropdown-selected-icon selected-icon glyphicon ok-2"></i>\n    </a>\n  </li>\n\n  ',l=i.each.call(t,t&&t.availableQualities,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+="\n</ul>\n"
})}),define("plex/desktop/views/players/controls/VideoPlayerQualityDropdown",["hb!templates/desktop/players/controls/VideoPlayerQualityDropdown.tpl","underscore","jquery","marionette","plex/base/utils/playerQualities","plex/base/adapters/settingsAdapter"],function(e,t,i,n,s,a){"use strict";var r=n.ItemView.extend({id:"player-quality-dropdown",tagName:"span",className:"dropdown hidden",template:e,modelEvents:{"change:transcodeServer":"render","change:qualityIndex":"render","change:media":"render"},events:{"click .dropdown-menu a":"onQualityClick"},serializeData:function(){var e=this.model.get("transcodeServer"),i=this.model.get("media"),n=s.getAvailableQualitiesFor(i,e);
if(!n.length||!this.model.get("canSetQuality"))return void this.model.set("showQuality",!1);this.model.set("showQuality",!0);var a=this.model.get("qualityIndex"),r=t.findWhere(n,{index:a});return r&&(r.selected=!0),{availableQualities:n.reverse(),hasSelectedQuality:!!r}},onQualityClick:function(e){e.preventDefault();var t=i(e.currentTarget);if(!t.hasClass("selected")){var n=s.getQualityAttribute(this.model.get("item")),r=parseInt(t.data("index"),10);a.save(n,r),this.model.set("qualityIndex",r)}}});
return r}),define("hb!templates/desktop/players/controls/VideoPlayerStreamDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"audio"}function r(){return"subtitles-alt"}function o(e,t,n){var s,a,r,o="";return o+='\n    <li><a class="',s=i["if"].call(e,e&&e.selected,{hash:{},inverse:S.noop,fn:S.program(6,l,t),data:t}),(s||0===s)&&(o+=s),o+='"  data-id="',(s=i.id)?s=s.call(e,{hash:{},data:t}):(s=e&&e.id,s=typeof s===w?s.call(e,{hash:{},data:t}):s),o+=x(s)+'" href="#">',s=i["if"].call(e,e&&e.language,{hash:{},inverse:S.program(10,d,t),fn:S.program(8,c,t),data:t}),(s||0===s)&&(o+=s),r={hash:{},inverse:S.noop,fn:S.program(12,u,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,n&&n.type,"subtitles",r):k.call(e,"if_eq",n&&n.type,"subtitles",r),(a||0===a)&&(o+=a),r={hash:{},inverse:S.noop,fn:S.program(16,m,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,n&&n.type,"audio",r):k.call(e,"if_eq",n&&n.type,"audio",r),(a||0===a)&&(o+=a),o+=' <i class="player-dropdown-selected-icon dropdown-selected-icon glyphicon ok-2"></i></a></li>\n  '
}function l(){return"selected"}function c(e,t){var n;return(n=i.language)?n=n.call(e,{hash:{},data:t}):(n=e&&e.language,n=typeof n===w?n.call(e,{hash:{},data:t}):n),x(n)}function d(e,t){var n,s;return s={hash:{},data:t},x((n=i.t||e&&e.t,n?n.call(e,"Unknown",s):k.call(e,"t","Unknown",s)))}function u(e,t){var n;return n=i["if"].call(e,e&&e.format,{hash:{},inverse:S.noop,fn:S.program(13,h,t),data:t}),n||0===n?n:""}function h(e,t){var n,s,a,r="";return r+=" (",a={hash:{},data:t},r+=x((n=i.upperCase||e&&e.upperCase,n?n.call(e,e&&e.format,a):k.call(e,"upperCase",e&&e.format,a))),s=i["if"].call(e,e&&e.forced,{hash:{},inverse:S.noop,fn:S.program(14,p,t),data:t}),(s||0===s)&&(r+=s),r+=")"
}function p(e,t){var n,s,a="";return a+=" ",s={hash:{},data:t},a+=x((n=i.t||e&&e.t,n?n.call(e,"Forced",s):k.call(e,"t","Forced",s)))}function m(e,t){var n;return n=i["if"].call(e,e&&e.codec,{hash:{},inverse:S.noop,fn:S.program(17,f,t),data:t}),n||0===n?n:""}function f(e,t){var n,s,a="";return a+=" (",s={hash:{},data:t},a+=x((n=i.formatAudioCodec||e&&e.formatAudioCodec,n?n.call(e,e&&e.codec,s):k.call(e,"formatAudioCodec",e&&e.codec,s)))+" ",s={hash:{},data:t},a+=x((n=i.formatAudioChannels||e&&e.formatAudioChannels,n?n.call(e,e&&e.channels,s):k.call(e,"formatAudioChannels",e&&e.channels,s)))+")"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var g,v,y,b="",w="function",x=this.escapeExpression,k=i.helperMissing,S=this;return b+='<button class="btn-link dropdown-toggle" href="#player-',(g=i.type)?g=g.call(t,{hash:{},data:s}):(g=t&&t.type,g=typeof g===w?g.call(t,{hash:{},data:s}):g),b+=x(g)+'-dropdown" data-toggle="dropdown">\n  <i class="plex-icon ',y={hash:{},inverse:S.program(3,r,s),fn:S.program(1,a,s),data:s},g=i.if_eq||t&&t.if_eq,v=g?g.call(t,t&&t.type,"audio",y):k.call(t,"if_eq",t&&t.type,"audio",y),(v||0===v)&&(b+=v),b+='"></i>\n</button>\n\n<ul class="dropdown-menu pull-right">\n  ',v=i.each.call(t,t&&t.streams,{hash:{},inverse:S.noop,fn:S.programWithDepth(5,o,s,t),data:s}),(v||0===v)&&(b+=v),b+="\n</ul>\n"
})}),define("plex/desktop/views/players/controls/VideoPlayerStreamDropdown",["hb!templates/desktop/players/controls/VideoPlayerStreamDropdown.tpl","underscore","jquery","marionette","plex/base/utils/mediaUtil","plex/base/utils/types/streamTypes","plex/base/models/appModel","plex/base/commands/commands"],function(e,t,i,n,s,a,r,o){"use strict";var l=n.ItemView.extend({id:"player-quality-dropdown",tagName:"span",className:"dropdown hidden",template:e,modelEvents:{"change:media":"render"},events:{"click .dropdown-menu a":"onStreamClick"},initialize:function(e){this.streamType=a.getStreamTypeByString(e.type);
var t=this.streamType.typeString;this.capabilityAttr="audio"===t?"canSetAudioStream":"canSetSubtitleStream",this.visibilityAttr="audio"===t?"showAudioStream":"showSubtitleStream",this.$el.attr("id",t+"-dropdown-list"),this.listenTo(this.model,"change:"+this.capabilityAttr,this.render),this.listenTo(this.model,"change:"+this.streamType.key,this.render)},serializeData:function(){var e=this.model.get("media"),t=this.streamType.typeString;if(!e||!this.model.get(this.capabilityAttr))return this.model.set(this.visibilityAttr,!1),{type:t};
this.model.get(this.visibilityAttr)&&this.$el.hasClass("hidden")&&this.$el.removeClass("hidden");var i=s.getStreams(e,{streamType:this.streamType.id});if(i.length<2)return this.model.set(this.visibilityAttr,!1),{type:t};this.model.set(this.visibilityAttr,!0);var n,a=s.getStreams(e,{streamType:this.streamType.id,selected:!0});return a.length&&(n=a[0]),{type:t,streams:i,selectedStream:n}},onStreamClick:function(e){e.preventDefault();var n=i(e.currentTarget),a=n.data("id");if(r.has("primaryPlayer"))s.selectStream(this.model.get("media"),this.streamType,a),this.model.set(this.streamType.key,a);
else{var l=o.execute("selectStream",{item:this.model.get("item"),media:this.model.get("media"),part:this.model.get("part"),streamType:this.streamType,streamID:a});l.done(t.bind(function(){this.model.set(this.streamType.key,a)},this))}}});return l}),define("hb!templates/desktop/players/controls/VideoPlayerPrimaryPlayerDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n  <button class="btn-link dropdown-toggle ',n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.noop,fn:h.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+='" href="#player-primary-player-dropdown" data-toggle="dropdown">\n    <i class="plex-icon ',n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.program(6,l,t),fn:h.program(4,o,t),data:t}),(n||0===n)&&(s+=n),s+='"></i>\n  </button>\n'
}function r(){return"active"}function o(){return"companion-cast-active"}function l(){return"companion-cast"}function c(e,t){var n,s="";return s+='\n  <button class="btn-link cast-btn ',n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.noop,fn:h.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\" href='#'>\n    <i class=\"plex-icon ",n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.program(6,l,t),fn:h.program(4,o,t),data:t}),(n||0===n)&&(s+=n),s+='"></i>\n  </button>\n'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var d,u="",h=this;return d=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:h.program(8,c,s),fn:h.program(1,a,s),data:s}),(d||0===d)&&(u+=d),u+="\n"})}),define("hb!templates/desktop/dropdowns/PrimaryPlayerDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n  <a class="dropdown-toggle ',n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.noop,fn:h.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+='" href="#primary-player-dropdown" data-toggle="dropdown">\n    <i class="plex-icon ',n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.program(6,l,t),fn:h.program(4,o,t),data:t}),(n||0===n)&&(s+=n),s+='"></i><i class="caret-icon"></i>\n  </a>\n'
}function r(){return"active"}function o(){return"companion-cast-active"}function l(){return"companion-cast"}function c(e,t){var n,s="";return s+='\n  <a class="cast-btn ',n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.noop,fn:h.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\" href='#'>\n    <i class=\"plex-icon ",n=i["if"].call(e,e&&e.primaryPlayer,{hash:{},inverse:h.program(6,l,t),fn:h.program(4,o,t),data:t}),(n||0===n)&&(s+=n),s+='"></i>\n  </a>\n'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var d,u="",h=this;return d=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:h.program(8,c,s),fn:h.program(1,a,s),data:s}),(d||0===d)&&(u+=d),u+="\n"})}),define("hb!templates/desktop/dropdowns/PrimaryPlayerDropdownList",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,l="";return l+='\n  <li class="dropdown-header"><span class="dropdown-truncated-label">',n=i["if"].call(e,e&&e.nowPlaying,{hash:{},inverse:v.noop,fn:v.program(2,r,t),data:t}),(n||0===n)&&(l+=n),l+=f((n=e&&e.primaryPlayer,n=null==n||n===!1?n:n.name,typeof n===g?n.apply(e):n))+"</span></li>\n\n  ",s=i["if"].call(e,e&&e.showNowPlaying,{hash:{},inverse:v.noop,fn:v.program(4,o,t),data:t}),(s||0===s)&&(l+=s),l+='\n\n  <li>\n    <a class="local-player-btn" href="#">\n      <i class="glyphicon ban"></i> ',a={hash:{},data:t},l+=f((n=i.t||e&&e.t,n?n.call(e,"Disconnect",a):m.call(e,"t","Disconnect",a)))+"\n    </a>\n  </li>\n"
}function r(e,t){var n,s,a="";return s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"Casting on",s):m.call(e,"t","Casting on",s)))+" "}function o(e,t){var n,s="";return s+="\n    ",n=i.each.call(e,e&&e.nowPlaying,{hash:{},inverse:v.noop,fn:v.program(5,l,t),data:t}),(n||0===n)&&(s+=n),s+="\n  "}function l(e,t){var n,s="";return s+='\n      <li>\n        <a class="now-playing-btn" data-id="',(n=i.ratingKey)?n=n.call(e,{hash:{},data:t}):(n=e&&e.ratingKey,n=typeof n===g?n.call(e,{hash:{},data:t}):n),s+=f(n)+'" href="#">\n          <i class="glyphicon play"></i> <span class="dropdown-truncated-label">',(n=i.title)?n=n.call(e,{hash:{},data:t}):(n=e&&e.title,n=typeof n===g?n.call(e,{hash:{},data:t}):n),s+=f(n)+"</span>\n        </a>\n      </li>\n    "
}function c(e,t){var n,s="";return s+="\n  ",n=i.each.call(e,e&&e.players,{hash:{},inverse:v.noop,fn:v.program(8,d,t),data:t}),(n||0===n)&&(s+=n),s+="\n"}function d(e,t){var n,s="";return s+='\n    <li>\n      <a class="plex-player-btn" data-id="',(n=i.machineIdentifier)?n=n.call(e,{hash:{},data:t}):(n=e&&e.machineIdentifier,n=typeof n===g?n.call(e,{hash:{},data:t}):n),s+=f(n)+'" href="#">\n        <i class="dropdown-item-icon plex-icon companion-plex"></i> <span class="dropdown-truncated-label">',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===g?n.call(e,{hash:{},data:t}):n),s+=f(n)+"</span>\n        ",n=i["if"].call(e,e&&e.selected,{hash:{},inverse:v.noop,fn:v.program(9,u,t),data:t}),(n||0===n)&&(s+=n),s+="\n      </a>\n    </li>\n  "
}function u(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var h,p="",m=i.helperMissing,f=this.escapeExpression,g="function",v=this;return h=i["if"].call(t,t&&t.primaryPlayer,{hash:{},inverse:v.program(7,c,s),fn:v.program(1,a,s),data:s}),(h||0===h)&&(p+=h),p+="\n"})}),define("plex/desktop/views/dropdowns/PrimaryPlayerDropdownList",["hb!templates/desktop/dropdowns/PrimaryPlayerDropdownList.tpl","jquery","marionette","plex/base/commands/commands","plex/base/models/appModel"],function(e,t,i,n,s){"use strict";
var a=i.ItemView.extend({tagName:"ul",className:"dropdown-menu pull-right",template:e,events:{"click .local-player-btn":"onLocalPlayerClick","click .plex-player-btn":"onPlexPlayerClick","click .now-playing-btn":"onNowPlayingClick"},initialize:function(e){e||(e={}),this.showNowPlaying=e.showNowPlaying,this.players=s.get("players")},serializeData:function(){var e=s.get("primaryPlayer");return{showNowPlaying:this.showNowPlaying,primaryPlayer:e?e.toJSON():null,nowPlaying:e?e.get("nowPlaying").toJSON():null,players:this.players.toJSON()}
},onLocalPlayerClick:function(e){e.preventDefault(),s.set("primaryPlayer",null)},onPlexPlayerClick:function(e){e.preventDefault();var i=t(e.currentTarget).data("id"),n=this.players.get(i);s.set("primaryPlayer",n)},onNowPlayingClick:function(e){e.preventDefault();var i=s.get("primaryPlayer"),a=i.get("nowPlaying"),r=t(e.currentTarget).data("id"),o=a.get(r);n.execute("playMedia",{item:o})}});return a}),define("plex/desktop/views/dropdowns/PrimaryPlayerDropdown",["hb!templates/desktop/dropdowns/PrimaryPlayerDropdown.tpl","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/dropdowns/PrimaryPlayerDropdownList"],function(e,t,i,n,s,a){"use strict";
var r=t.Layout.extend({id:"primary-player-dropdown",tagName:"li",className:"nav-dropdown dropdown",template:e,regions:{list:".dropdown-menu"},events:{"click .cast-btn":"onCastClick"},initialize:function(e){e||(e={}),this.showNowPlaying=e.showNowPlaying,this.players=s.get("players"),this.listenTo(s,{"change:primaryPlayer":this.onPrimaryPlayerChange,"change:isCastApiAvailable":this.render,"change:isCastDeviceAvailable":this.render}),this.listenTo(this.players,"reset",this.render),this.setup()},setup:function(){var e=s.get("primaryPlayer");
if(e){var t=e.get("nowPlaying");this.listenTo(t,{reset:this.render,add:this.render,remove:this.render})}},serializeData:function(){return{primaryPlayer:!!s.get("primaryPlayer"),showDropdown:!s.get("isCastApiAvailable")}},onRender:function(){var e=s.get("isCastDeviceAvailable")||!!this.players.length,t=!s.get("isCastApiAvailable")&&e;this.$el.toggleClass("hidden",!e),t&&this.list.append(new a({showNowPlaying:this.showNowPlaying}),this.$el)},onPrimaryPlayerChange:function(){var e=s.previous("primaryPlayer");
e&&this.stopListening(e.get("nowPlaying")),this.setup(),this.render()},onCastClick:function(e){e.preventDefault(),i.trigger("cast:launch")}});return r}),define("plex/desktop/views/players/controls/VideoPlayerPrimaryPlayerDropdown",["hb!templates/desktop/players/controls/VideoPlayerPrimaryPlayerDropdown.tpl","plex/desktop/views/dropdowns/PrimaryPlayerDropdown"],function(e,t){"use strict";var i=t.extend({id:"player-primary-player-dropdown",tagName:"span",className:"dropdown",template:e});return i}),define("hb!templates/desktop/players/controls/VideoPlayerControlsScrubView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<img class="player-scrub-preview-thumbnail hidden">\n<div class="tooltip top player-scrub-preview-tooltip">\n  <div class="tooltip-inner player-scrub-preview-time"></div>\n  <div class="tooltip-arrow"></div>\n</div>'
})}),define("plex/desktop/views/players/controls/VideoPlayerControlsScrubView",["hb!templates/desktop/players/controls/VideoPlayerControlsScrubView.tpl","underscore","marionette","plex/base/utils/mediaUtil","plex/base/utils/posterSizes","plex/base/utils/formatters/dateTimeUtil","plex/base/views/images/BaseImage"],function(e,t,i,n,s,a,r){"use strict";var o=i.ItemView.extend({className:"player-scrub-preview",template:e,areThumbnailsAvailable:null,thumbnailPreferredIndex:"sd",thumbnailWidth:240,ui:{scrubPreviewThumbnail:".player-scrub-preview-thumbnail",scrubPreviewTooltip:".player-scrub-preview-tooltip",scrubPreviewTime:".player-scrub-preview-time"},modelEvents:{"change:item":"onItemChange"},initialize:function(){this.throttledShowThumbnail=t.throttle(this.whenRendered(this.showThumbnail),200),this.thumbnailImage=new r({model:this.model.get("item"),width:this.thumbnailWidth,height:s.getPosterHeight("art",this.thumbnailWidth)})
},show:function(){this.$el.removeClass("hidden")},hide:function(){this.$el.addClass("hidden"),this.ui.scrubPreviewThumbnail.addClass("hidden")},positionContainer:function(){this.$el.css("left",this.position-this.$el.width()/2+"px")},updatePreview:function(e){this.position=e.position,this.ui.scrubPreviewTime.text(a.formatDuration(e.time)),this.positionContainer(),this.areThumbnailsAvailable!==!1&&this.throttledShowThumbnail(e.time)},showThumbnail:function(e){if(this.model.get("media")){var t=this.getScreenshotUrl(e);
t?(this.areThumbnailsAvailable=!0,this.thumbnailImage.load(t).done(this.whenRendered(function(e){this.$el.hasClass("hidden")||(this.thumbnailImage.showImage(e),this.ui.scrubPreviewThumbnail.removeClass("hidden"),this.positionContainer())}))):this.areThumbnailsAvailable=!1}},getScreenshotUrl:function(e){var t=e+6e3;return n.getScreenshotUrl(this.model.get("media"),t,this.thumbnailPreferredIndex)},onRender:function(){this.thumbnailImage.setElement(this.ui.scrubPreviewThumbnail)},onClose:function(){this.thumbnailImage.close()
},onItemChange:function(e,t){this.ui.scrubPreviewThumbnail.addClass("hidden"),this.areThumbnailsAvailable=null,this.thumbnailImage.setModel(t),this.thumbnailImage.src=null}});return o}),define("hb!templates/desktop/players/controls/VideoPlayerImageOverlaysView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="video-player-image-overlays"></div>\n'})}),define("hb!templates/desktop/players/controls/VideoPlayerImageOverlayView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("plex/desktop/views/players/controls/VideoPlayerImageOverlayView",["hb!templates/desktop/players/controls/VideoPlayerImageOverlayView.tpl","underscore","jquery","marionette","plex/base/views/images/BaseImage"],function(e,t,i,n,s){"use strict";var a=n.ItemView.extend({className:"video-image-overlay",template:e,initialize:function(e){this.videoAspectRatio=e.videoAspectRatio,this.throttledSetStyles=t.throttle(this.whenRendered(this.setStyles),100),this.image=new s({model:this.model,modelAttribute:"key",width:this.model.get("width"),height:this.model.get("height"),background:!0}),this.setStyles(),"video"===this.model.get("relative")&&i(window).on("resize",this.throttledSetStyles)
},setStyles:function(){if("video"===this.model.get("relative")&&!this.videoAspectRatio)return void this.$el.addClass("hidden");var e=this.model.get("alignHorizontal"),t=this.model.get("alignVertical"),i=this.model.get("width"),n=this.model.get("height"),s=0,a=0,r=this.getOffset(),o={position:"absolute",top:"auto",right:"auto",bottom:"auto",left:"auto",backgroundSize:i+"px "+n+"px",backgroundRepeat:"no-repeat",width:i,height:n};"center"===e?(o.left="50%",s="-50%"):"left"===e?o.left=r.x:"right"===e&&(o.right=r.x),"middle"===t?(o.top="50%",a="-50%"):"top"===t?o.top=r.y:"bottom"===t&&(o.bottom=r.y),o.transform="translate("+s+", "+a+")",o.marginTop=this.model.get("marginTop")||0,o.marginRight=this.model.get("marginRight")||0,o.marginBottom=this.model.get("marginBottom")||0,o.marginLeft=this.model.get("marginLeft")||0,this.$el.css(o),this.$el.removeClass("hidden")
},getOffset:function(){if("player"===this.model.get("relative"))return{x:0,y:0};var e=i(window).width(),t=i(window).height(),n=e/t,s={};if(this.videoAspectRatio>n){var a=e/this.videoAspectRatio;s.x=0,s.y=(t-a)/2}else{var r=t*this.videoAspectRatio;s.x=(e-r)/2,s.y=0}return s},onRender:function(){this.image.setElement(this.$el)},onClose:function(){i(window).off("resize",this.throttledSetStyles),this.image.close()}});return a}),define("plex/desktop/views/players/controls/VideoPlayerImageOverlaysView",["hb!templates/desktop/players/controls/VideoPlayerImageOverlaysView.tpl","underscore","jquery","marionette","plex/base/models/library/OverlayCollection","plex/desktop/views/players/controls/VideoPlayerImageOverlayView"],function(e,t,i,n,s,a){"use strict";
var r=n.CompositeView.extend({className:"video-image-overlays-container",template:e,itemView:a,itemViewContainer:".video-player-image-overlays",itemViewOptions:function(){return{videoAspectRatio:this.getVideoAspectRatio()}},modelEvents:{"change:media":"onMediaChange","change:videoDimensions":"onVideoDimensionsChange"},initialize:function(){this.collection=new s,this.populateCollection()},populateCollection:function(){var e=this.model.get("item"),t=e&&e.get("overlays");t?this.collection.reset(t.models):this.collection.reset()
},getVideoAspectRatio:function(){var e=this.model.get("videoDimensions");return e?e.width/e.height:void 0},onMediaChange:function(){this.populateCollection()},onVideoDimensionsChange:function(){var e=this.getVideoAspectRatio();e&&this.children.each(function(t){var i=t.model;"video"===i.get("relative")&&(t.videoAspectRatio=e,t.setStyles())})}});return r}),define("hb!templates/desktop/dropdowns/PlayQueueDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"
}function r(){return"readonly"}function o(){return'\n      <button class="btn-gray save-btn" href="#">\n        <i class="plex-icon add-to-playlist"></i>\n      </button>\n    '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d="",u=this,h=i.helperMissing,p=this.escapeExpression;return d+='<button class="btn-link dropdown-toggle ',l=i.unless.call(t,t&&t.canEdit,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='" href="#play-queue-dropdown" data-toggle="dropdown">\n  <i class="glyphicon show-thumbnails-with-lines"></i>\n</button>\n\n<ol class="play-queue-list dropdown-menu pull-right ',l=i.unless.call(t,t&&t.canEdit,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='">\n  <li class="dropdown-header play-queue-header">\n    ',l=i["if"].call(t,t&&t.canPlaylist,{hash:{},inverse:u.noop,fn:u.program(5,o,s),data:s}),(l||0===l)&&(d+=l),d+='\n\n    <i class="glyphicon show-thumbnails-with-lines"></i> ',c={hash:{},data:s},d+=p((l=i.t||t&&t.t,l?l.call(t,"Up Next",c):h.call(t,"t","Up Next",c)))+"\n  </li>\n</ol>\n"
})}),function(e){"use strict";"function"==typeof define&&define.amd?define("sortable",e):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=e():window.Sortable=e()}(function(){"use strict";function e(e,i){this.el=e,this.options=i=i||{},i.group=i.group||Math.random(),i.handle=i.handle||null,i.draggable=i.draggable||e.children[0]&&e.children[0].nodeName||(/[uo]l/i.test(e.nodeName)?"li":"*"),i.ghostClass=i.ghostClass||"sortable-ghost",i.ignore=i.ignore||"a, img",i.onAdd=t(this,i.onAdd||T),i.onUpdate=t(this,i.onUpdate||T),i.onRemove=t(this,i.onRemove||T),i.onStart=t(this,i.onStart||T),i.onEnd=t(this,i.onEnd||T),e[k]=i.group;
for(var n in this)"_"===n.charAt(0)&&(this[n]=t(this,this[n]));s(e,"add",i.onAdd),s(e,"update",i.onUpdate),s(e,"remove",i.onRemove),s(e,"start",i.onStart),s(e,"stop",i.onEnd),s(e,"mousedown",this._onTapStart),s(e,"touchstart",this._onTapStart),A&&s(e,"selectstart",this._onTapStart),s(e,"dragover",this._onDragOver),s(e,"dragenter",this._onDragOver),D.push(this._onDragOver)}function t(e,t){var i=M.call(arguments,2);return t.bind?t.bind.apply(t,[e].concat(i)):function(){return t.apply(e,i.concat(M.call(arguments)))
}}function i(e,t,i){if("*"===t)return e;if(e){i=i||C,t=t.split(".");var n=t.shift().toUpperCase(),s=new RegExp("\\s("+t.join("|")+")\\s","g");do if(!(""!==n&&e.nodeName!=n||t.length&&((" "+e.className+" ").match(s)||[]).length!=t.length))return e;while(e!==i&&(e=e.parentNode))}return null}function n(e){e.dataTransfer.dropEffect="move",e.preventDefault()}function s(e,t,i){e.addEventListener(t,i,!1)}function a(e,t,i){e.removeEventListener(t,i,!1)}function r(e,t,i){if(e)if(e.classList)e.classList[i?"add":"remove"](t);
else{var n=(" "+e.className+" ").replace(/\s+/g," ").replace(" "+t+" ","");e.className=n+(i?" "+t:"")}}function o(e,t,i){if(e&&e.style){if(void 0===i)return C.defaultView&&C.defaultView.getComputedStyle?i=C.defaultView.getComputedStyle(e,""):e.currentStyle&&(i=e.currentStyle),void 0===t?i:i[t];e.style[t]=i+("string"==typeof i?"":"px")}}function l(e,t,i){if(e){var n=e.getElementsByTagName(t),s=0,a=n.length;if(i)for(;a>s;s++)i(n[s],s);return n}return[]}function c(e){return e.draggable=!1}function d(){_=!1
}function u(e,t){var i=e.lastElementChild.getBoundingClientRect();return t.clientY-(i.top+i.height)>5}var h,p,m,f,g,v,y,b,w,x,k="Sortable"+(new Date).getTime(),S=window,C=S.document,P=S.parseInt,A=!!C.createElement("div").dragDrop,_=!1,I=function(e,t){var i=C.createEvent("Event");return i.initEvent(e,!0,!0),i.item=t,i},T=function(){},M=[].slice,D=[];return e.prototype={constructor:e,_applyEffects:function(){r(h,this.options.ghostClass,!0)},_onTapStart:function(e){var t=e.touches&&e.touches[0],a=(t||e).target,r=this.options,o=this.el;
if(r.handle&&(a=i(a,r.handle,o)),a=i(a,r.draggable,o),a&&"selectstart"==e.type&&"A"!=a.tagName&&"IMG"!=a.tagName&&a.dragDrop(),a&&!h&&a.parentNode===o){w=e,a.draggable=!0,Array.prototype.forEach.call(r.ignore.split(","),function(e){l(a,e.trim(),c)}),t&&(w={target:a,clientX:t.clientX,clientY:t.clientY},this._onDragStart(w,!0),e.preventDefault()),s(this.el,"dragstart",this._onDragStart),s(this.el,"dragend",this._onDrop),s(C,"dragover",n);try{C.selection?C.selection.empty():window.getSelection().removeAllRanges()
}catch(d){}}},_emulateDragOver:function(){if(x){o(p,"display","none");var e=C.elementFromPoint(x.clientX,x.clientY),t=e,i=this.options.group,n=D.length;if(t)do{if(t[k]===i){for(;n--;)D[n]({clientX:x.clientX,clientY:x.clientY,target:e,rootEl:t});break}e=t}while(t=t.parentNode);o(p,"display","")}},_onTouchMove:function(e){if(w){var t=e.touches[0],i=t.clientX-w.clientX,n=t.clientY-w.clientY,s="translate3d("+i+"px,"+n+"px,0)";x=t,o(p,"webkitTransform",s),o(p,"mozTransform",s),o(p,"msTransform",s),o(p,"transform",s),e.preventDefault()
}},_onDragStart:function(e,t){var i=e.target,n=e.dataTransfer;if(m=this.el,h=i,f=i.nextSibling,b=this.options.group,t){var a,r=i.getBoundingClientRect(),l=o(i);p=i.cloneNode(!0),o(p,"top",r.top-P(l.marginTop,10)),o(p,"left",r.left-P(l.marginLeft,10)),o(p,"width",r.width),o(p,"height",r.height),o(p,"opacity","0.8"),o(p,"position","fixed"),o(p,"zIndex","100000"),m.appendChild(p),a=p.getBoundingClientRect(),o(p,"width",2*r.width-a.width),o(p,"height",2*r.height-a.height),s(C,"touchmove",this._onTouchMove),s(C,"touchend",this._onDrop),s(C,"touchcancel",this._onDrop),this._loopId=setInterval(this._emulateDragOver,150)
}else n.effectAllowed="move",n.setData("Text",i.textContent),s(C,"drop",this._onDrop);h.dispatchEvent(I("start",h)),setTimeout(this._applyEffects)},_onDragOver:function(e){if(!_&&b===this.options.group&&(void 0===e.rootEl||e.rootEl===this.el)){var t=this.el,n=i(e.target,this.options.draggable,t);if(0===t.children.length||t.children[0]===p||t===e.target&&u(t,e))t.appendChild(h);else if(n&&n!==h&&void 0!==n.parentNode[k]){g!==n&&(g=n,v=o(n),y=n.getBoundingClientRect());var s,a=y,r=a.right-a.left,l=a.bottom-a.top,c=/left|right|inline/.test(v.cssFloat+v.display),m=(c?(e.clientX-a.left)/r:(e.clientY-a.top)/l)>.5,f=n.offsetWidth>h.offsetWidth,w=n.offsetHeight>h.offsetHeight,x=n.nextSibling;
_=!0,setTimeout(d,30),s=c?n.previousElementSibling===h&&!f||m>.5&&f:n.nextElementSibling!==h&&!w||m>.5&&w,s&&!x?t.appendChild(h):n.parentNode.insertBefore(h,s?x:n)}}},_onDrop:function(e){clearInterval(this._loopId),a(C,"drop",this._onDrop),a(C,"dragover",n),a(this.el,"dragend",this._onDrop),a(this.el,"dragstart",this._onDragStart),a(this.el,"selectstart",this._onTapStart),a(C,"touchmove",this._onTouchMove),a(C,"touchend",this._onDrop),a(C,"touchcancel",this._onDrop),e&&(e.preventDefault(),e.stopPropagation(),p&&p.parentNode.removeChild(p),h&&(c(h),r(h,this.options.ghostClass,!1),m.contains(h)?h.nextSibling!==f&&h.dispatchEvent(I("update",h)):(m.dispatchEvent(I("remove",h)),h.dispatchEvent(I("add",h))),h.dispatchEvent(I("stop",h))),m=h=p=f=w=x=g=v=b=null)
},destroy:function(){var e=this.el,t=this.options;a(e,"add",t.onAdd),a(e,"update",t.onUpdate),a(e,"remove",t.onRemove),a(e,"start",t.onStart),a(e,"stop",t.onEnd),a(e,"mousedown",this._onTapStart),a(e,"touchstart",this._onTapStart),a(e,"selectstart",this._onTapStart),a(e,"dragover",this._onDragOver),a(e,"dragenter",this._onDragOver),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),D.splice(D.indexOf(this._onDragOver),1),this._onDrop(),this.el=null
}},e.utils={on:s,off:a,css:o,find:l,bind:t,closest:i,toggleClass:r},e.version="0.3.0",e}),define("hb!templates/desktop/dropdowns/PlayQueueListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<a href="#">\n  <div class="media-poster ',(a=i.type)?a=a.call(t,{hash:{},data:s}):(a=t&&t.type,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'"></div>\n\n  <div class="media-item">\n    <div class="media-title"></div>\n    <div class="media-subtitle-1"><span class="media-primary-subtitle"></span><span class="media-secondary-subtitle"></span></div>\n  </div>\n\n  <button class="delete-btn btn-link btn-danger" tabindex="-1"><i class="glyphicon remove-2"></i></button>\n</a>\n'
})}),define("plex/desktop/views/lists/library/BasePlayListItem",["marionette","plex/base/utils/posterPlaceholders","plex/base/utils/types/mediaTypes","plex/base/views/images/MediaPosterImage"],function(e,t,i,n){"use strict";var s=e.ItemView.extend({tagName:"li",ui:{poster:".media-poster"},bindings:{".media-title":{modelAttribute:"title"}},initialize:function(){this.type=this.model.get("type");var e=i.getMediaTypeByString(this.type).element,s=this.posterWidth[e]||40,a="movie"===this.type?"art":"thumb",r=t[this.type];
"movie"===this.type&&(r=t.art),this.image=new n({model:this.model,type:"art",getUrl:this.getPosterUrl,placeholderClass:r,width:s,modelAttribute:a})},getPosterUrl:function(e){return e=e||this.model.get("parentThumb")||this.model.get("grandparentThumb"),e||(this.model.parent?e=this.model.parent.get("thumb"):this.model.channel&&(e=this.model.channel.get("thumb"))),e},onRender:function(){this.image.setElement(this.ui.poster)}});return s}),define("plex/desktop/views/lists/library/PlayQueueListItem",["hb!templates/desktop/dropdowns/PlayQueueListItem.tpl","underscore","plex/base/utils/mediaUtil","plex/base/utils/formatters/dateTimeUtil","plex/desktop/views/lists/library/BasePlayListItem"],function(e,t,i,n,s){"use strict";
var a=s.extend({template:e,className:"play-queue-list-item",attributes:function(){return{"data-play-queue-id":this.model.get("playQueueItemID")||this.model.get("ratingKey")}},events:{"click a":"onPlayClick","click .delete-btn":"onDeleteClick"},posterWidth:{video:70},bindings:t.extend({".media-primary-subtitle":{modelAttribute:"grandparentTitle",modelListeners:["grandparentTitle","duration"],formatter:function(e){var t=e;this.model.parent&&(t=t||this.model.parent.get("parentTitle"),this.model.parent.parent&&(t=this.model.parent.parent.get("title")));
var i=this.model.get("duration");return"movie"===this.type&&i&&(t=n.formatHoursMinutes(i)),t||""}},".media-secondary-subtitle":{modelAttribute:"parentTitle",modelListeners:["parentTitle","index"],formatter:function(e){var t=e;return this.model.parent&&(t=t||this.model.parent.get("title")),"episode"===this.type&&(t=i.getSeasonEpisodeIndex({seasonIndex:this.model.get("parentIndex"),episodeIndex:this.model.get("index"),date:this.model.get("originallyAvailableAt")})),t&&(t=" - "+t),t||""}}},s.prototype.bindings),serializeData:function(){return{type:this.type}
},onPlayClick:function(e){e.preventDefault(),this.trigger("skip",this.model.get("key"))},onDeleteClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.trigger("remove",this.model)}});return a}),define("hb!templates/desktop/dropdowns/NoPlayQueueItems",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="play-queue-empty-message">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Nothing queued",r):l.call(t,"t","Nothing queued",r)))+"</div>\n"
})}),define("plex/desktop/views/dropdowns/NoPlayQueueItems",["hb!templates/desktop/dropdowns/NoPlayQueueItems.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({tagName:"li",className:"play-queue-list-item",template:e});return i}),define("hb!templates/desktop/modals/AddToPlaylistModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s;return s={hash:{},data:t},v((n=i.t||e&&e.t,n?n.call(e,"Select a Playlist",s):g.call(e,"t","Select a Playlist",s)))
}function r(e,t){var n,s;return s={hash:{},data:t},v((n=i.t||e&&e.t,n?n.call(e,"Create Playlist",s):g.call(e,"t","Create Playlist",s)))}function o(e,t){var n,s="";return s+="\n        ",n=i["if"].call(e,e&&e.hasPlaylists,{hash:{},inverse:y.program(8,c,t),fn:y.program(6,l,t),data:t}),(n||0===n)&&(s+=n),s+="\n      "}function l(){return'\n          <div class="playlists-container"></div>\n        '}function c(e,t){var n,s="";return s+="\n          ",n=i["if"].call(e,e&&e.loading,{hash:{},inverse:y.program(11,u,t),fn:y.program(9,d,t),data:t}),(n||0===n)&&(s+=n),s+="\n        "
}function d(){return'\n            <div class="loading-container">\n              <div class="loading loading-inline"></div>\n            </div>\n          '}function u(e,t){var n,s,a="";return a+='\n            <div class="empty-message">',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"There are no playlists on this server.",s):g.call(e,"t","There are no playlists on this server.",s)))+"</div>\n          "}function h(){return"only-control"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var p,m,f="",g=i.helperMissing,v=this.escapeExpression,y=this;return f+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon plex-icon add-to-playlist"></i> ',p=i["if"].call(t,t&&t.showExisting,{hash:{},inverse:y.program(3,r,s),fn:y.program(1,a,s),data:s}),(p||0===p)&&(f+=p),f+='\n      </h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll minimal-scroll">\n      ',p=i["if"].call(t,t&&t.showExisting,{hash:{},inverse:y.noop,fn:y.program(5,o,s),data:s}),(p||0===p)&&(f+=p),f+='\n      <div class="message-container ',p=i.unless.call(t,t&&t.showExisting,{hash:{},inverse:y.noop,fn:y.program(13,h,s),data:s}),(p||0===p)&&(f+=p),f+='">\n        <input class="message form-control" placeholder="',m={hash:{},data:s},f+=v((p=i.t||t&&t.t,p?p.call(t,"New playlist...",m):g.call(t,"t","New playlist...",m)))+'">\n      </div>\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="add-btn btn btn-primary btn-loading disabled">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',m={hash:{},data:s},f+=v((p=i.t||t&&t.t,p?p.call(t,"Add",m):g.call(t,"t","Add",m)))+"</span>\n      </button>\n    </div>\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/lists/library/SelectPlaylistListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<a class="playlist" data-id="',(a=i.ratingKey)?a=a.call(t,{hash:{},data:s}):(a=t&&t.ratingKey,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'" href="#">\n  <span class="media-poster playlist-poster"></span> ',(a=i.title)?a=a.call(t,{hash:{},data:s}):(a=t&&t.title,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"\n</a>"
})}),define("plex/desktop/views/images/CompositeImage",["jquery","plex/base/views/images/BaseImage","plex/base/utils/posterPlaceholders"],function(e,t,i){"use strict";var n=t.extend({background:!0,setup:function(t){this.model=t.model,t.noPlaceholder||(this.placeholderClass=i.playlist);var n={width:t.width||t.height||256,height:t.height||t.width||256,rows:t.rows||2,cols:t.columns||2,border:t.border||0,media:t.media||"thumb",repeat:t.unique?0:1},s=this.model.get("composite")+"?"+e.param(n,!0);this.url=this.model.server.resolveUrl(s,{appendToken:!0})
}});return n}),define("plex/desktop/views/lists/library/SelectPlaylistListItem",["hb!templates/desktop/lists/library/SelectPlaylistListItem.tpl","marionette","plex/desktop/views/images/CompositeImage"],function(e,t,i){"use strict";var n=t.ItemView.extend({tagName:"li",className:"striped-list-item select-list-item",template:e,ui:{poster:".playlist-poster"},initialize:function(){this.image=new i({model:this.model,width:40})},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()
}});return n}),define("plex/desktop/views/lists/library/SelectPlaylistList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/SelectPlaylistListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list select-list select-playlist-list minimal-scroll",itemView:t});return i}),define("plex/desktop/views/modals/AddToPlaylistModal",["hb!templates/desktop/modals/AddToPlaylistModal.tpl","underscore","jquery","backbone","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/base/models/library/PlaylistCollection","plex/base/models/library/PlaylistModel","plex/desktop/views/lists/library/SelectPlaylistList","plex/desktop/views/modals/SelectModal"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";
var u=d.extend({name:"addToPlaylistModal",className:"add-to-playlist-modal select-modal modal modal-sm fade",template:e,ui:{addBtn:".add-btn",newPlaylist:".message"},regions:{list:".playlists-container"},events:t.extend({"click .playlist":"onPlaylistClick","keyup .message":"onNewPlaylistKeyUp","click .message":"onNewPlaylistClick","click .add-btn":"onAddClick"},d.prototype.events),initialize:function(e){d.prototype.initialize.apply(this,arguments),this.items=e.items,(!this.items||1===this.items.length&&this.items[0]===this.model)&&(this.ignoreTargets=!0),this.leafType=this.model.get("playQueueID")?this.model.get("mediaType"):r.getChildMediaType(this.model.get("type")).element,this.smart=this.model.get("isSection")&&this.ignoreTargets,this.playlists=new o([],{filterOptions:new n.Model({currentType:this.leafType,onlyDumb:!0}),server:this.model.server,allowInCache:!0}),this.loading=!0,this.playlists.populate().always(this.whenRendered(this.onPopulated))
},serializeData:function(){return{loading:this.loading,showExisting:!this.smart,hasPlaylists:this.playlists.length>0}},toggleAddButton:function(){var e=this.ui.newPlaylist.val().trim();this.ui.addBtn.toggleClass("disabled",!e)},suggestTitleIfEmpty:function(){""===this.ui.newPlaylist.val()&&(this.ui.newPlaylist.val(this.items[0].get("title")),this.ui.newPlaylist.select(),this.toggleAddButton())},_addToPlaylist:function(e){this.ui.addBtn.addClass("active");var i,n=this.model.server;this.ignoreTargets||(i=n.supports("playItemsBatchAdd")?this.items:t.first(this.items));
var r=e.addContent(this.model,{items:i});return r.done(this.whenRendered(this.hide)),r.fail(this.whenRendered(function(){this.ui.addBtn.removeClass("active"),a.trigger("show:alert",{type:"error",message:s("There was a problem adding to the playlist.")})})),r},_createPlaylist:function(){var e=this.ui.newPlaylist.val().trim();if(e){var i=new l({title:e,playlistType:this.leafType,smart:this.smart},{server:this.model.server}),n=this._addToPlaylist(i);n.then(t.bind(function(){a.trigger("navigate","playlist",{serverID:i.server.id,key:i.get("ratingKey")}),this.playlists.clear()
},this))}},onRender:function(){d.prototype.onRender.apply(this,arguments),this.smart&&setTimeout(this.whenRendered(function(){this.ui.newPlaylist.focus(),this.suggestTitleIfEmpty()}),this.focusDelay)},onPopulated:function(){this.loading=!1,this.render(),this.list.show(new c({collection:this.playlists}))},onNewPlaylistKeyUp:function(e){this.toggleAddButton(),13===e.keyCode&&this._createPlaylist()},onNewPlaylistClick:function(){this.suggestTitleIfEmpty()},onPlaylistClick:function(e){e.preventDefault();
var t=i(e.currentTarget),n=t.data("id"),s=this.playlists.get(n);this._addToPlaylist(s)},onAddClick:function(e){e.preventDefault(),this.ui.addBtn.isDisabled()||this._createPlaylist()}});return u}),define("plex/desktop/views/dropdowns/PlayQueueDropdown",["hb!templates/desktop/dropdowns/PlayQueueDropdown.tpl","underscore","jquery","marionette","sortable","plex/base/utils/dispatcher","plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/PlayQueueListItem","plex/desktop/views/dropdowns/NoPlayQueueItems","plex/desktop/views/modals/AddToPlaylistModal"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=n.CompositeView.extend({id:"player-play-queue-dropdown",tagName:"span",className:"dropup",itemView:o,emptyView:l,itemViewContainer:"ol",template:e,modelEvents:{"change:showPlayQueue":"onShowPlayQueueChange"},events:{"click .save-btn":"onSaveClick"},serializeData:function(){var e=this.model.get("playQueue"),t=e.server&&e.server.supports("playlists"),i=e.supports({playlists:!0});return{canEdit:this.model.get("showPlayQueue"),canPlaylist:i&&t}},appendHtml:function(e,t,i){return r.prototype.sortedAppendHtml.apply(this,[e,t,i+1])
},onRender:function(){var e=function(e){var t=i(e.item).data("play-queue-id"),n=i(e.item).prev(".play-queue-list-item").data("play-queue-id");this.trigger("move",t,n)};if(this.model.get("showPlayQueue")){var n=this.$el.children(".dropdown-menu")[0];this.sortable=new s(n,{draggable:"li.play-queue-list-item",onUpdate:t.bind(e,this)})}},onShowPlayQueueChange:function(){this.render()},onSaveClick:function(){a.trigger("show:modal",new c({model:this.model.get("playQueue")}))}});return d}),define("hb!templates/desktop/modals/ShareModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n        <ul class="list select-list select-networks-list dark-scrollbar">\n          ',n=i.each.call(e,e&&e.networks,{hash:{},inverse:y.noop,fn:y.programWithDepth(2,r,t,e),data:t}),(n||0===n)&&(a+=n),a+='\n        </ul>\n\n        <div class="message-container ',n=i.unless.call(e,e&&e.autoSelect,{hash:{},inverse:y.noop,fn:y.program(10,u,t),data:t}),(n||0===n)&&(a+=n),a+='">\n          <textarea class="message form-control" placeholder="',s={hash:{},data:t},a+=x((n=i.t||e&&e.t,n?n.call(e,"Say something about this...",s):b.call(e,"t","Say something about this...",s)))+'"></textarea>\n        </div>\n      '
}function r(e,t,n){var s,a,r,d="";return d+='\n            <li class="striped-list-item select-list-item">\n              <a class="network ',s=i["if"].call(e,n&&n.autoSelect,{hash:{},inverse:y.noop,fn:y.program(3,o,t),data:t}),(s||0===s)&&(d+=s),d+='" data-id="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===w?s.call(e,{hash:{},data:t}):s),d+=x(s)+'" href="#">\n                ',r={hash:{},inverse:y.program(7,c,t),fn:y.program(5,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.key,"facebook",r):b.call(e,"if_eq",e&&e.key,"facebook",r),(a||0===a)&&(d+=a),d+="\n                ",(a=i.title)?a=a.call(e,{hash:{},data:t}):(a=e&&e.title,a=typeof a===w?a.call(e,{hash:{},data:t}):a),d+=x(a)+"\n              </a>\n            </li>\n          "
}function o(){return"selected"}function l(){return'\n                  <i class="network-icon glyphicon glyphicon-social facebook"></i>\n                '}function c(e,t){var n,s,a,r="";return r+="\n                  ",a={hash:{},inverse:y.noop,fn:y.program(8,d,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.key,"twitter",a):b.call(e,"if_eq",e&&e.key,"twitter",a),(s||0===s)&&(r+=s),r+="\n                "}function d(){return'\n                    <i class="network-icon glyphicon glyphicon-social twitter"></i>\n                  '
}function u(){return"invisible"}function h(e,t){var n,s,a="";return a+='\n        <div class="empty-message">\n          ',s={hash:{},data:t},a+=x((n=i.t||e&&e.t,n?n.call(e,"You need to {1}link your account{2}.",'<a href="{3}" target="_blank">',"</a>",e&&e.accountUrl,s):b.call(e,"t","You need to {1}link your account{2}.",'<a href="{3}" target="_blank">',"</a>",e&&e.accountUrl,s)))+"\n        </div>\n      "}function p(){return"disabled"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var m,f,g,v="",y=this,b=i.helperMissing,w="function",x=this.escapeExpression;return v+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon share"></i> ',g={hash:{},data:s},v+=x((m=i.t||t&&t.t,m?m.call(t,"Share",g):b.call(t,"t","Share",g)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      ',f=i["if"].call(t,t&&t.networks,{hash:{},inverse:y.program(12,h,s),fn:y.program(1,a,s),data:s}),(f||0===f)&&(v+=f),v+='\n    </div>\n\n    <div class="modal-footer">\n      <span class="characters-remaining"></span>\n      <button type="button" class="share-btn btn btn-primary btn-loading ',f=i.unless.call(t,t&&t.autoSelect,{hash:{},inverse:y.noop,fn:y.program(14,p,s),data:s}),(f||0===f)&&(v+=f),v+='">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',g={hash:{},data:s},v+=x((m=i.t||t&&t.t,m?m.call(t,"Share",g):b.call(t,"t","Share",g)))+"</span>\n      </button>\n    </div>\n  </div>\n</div>\n\n"
})}),define("plex/desktop/views/modals/ShareModal",["hb!templates/desktop/modals/ShareModal.tpl","jquery","underscore","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/modals/BaseModal","plex/desktop/views/modals/SelectModal"],function(e,t,i,n,s,a,r){"use strict";var o=r.extend({name:"shareModal",className:"share-modal select-modal modal modal-sm fade",template:e,linkedNetworks:null,networkIDs:null,maxLength:null,ui:{shareBtn:".share-btn",messageContainer:".message-container",charactersRemaining:".characters-remaining",message:".message"},events:i.extend({"click .network":"onNetworkClick","keyup .message":"onMessageKeyUp","click .share-btn":"onShareClick"},a.prototype.events),initialize:function(){r.prototype.initialize.apply(this,arguments),this.user=s.get("user"),this.socialNetworks=this.user.get("socialNetworks"),this.linkedNetworks=this.socialNetworks.where({linked:!0}),this.autoSelect=1===this.linkedNetworks.length,this.networkIDs=[]
},serializeData:function(){for(var e=[],t=0,i=this.linkedNetworks.length;i>t;t++)e.push(this.linkedNetworks[t].toJSON());return{networks:e,accountUrl:this.user.server.get("accountUrl"),autoSelect:this.autoSelect}},calculateMaxLength:function(){var e=null,t=this.socialNetworks;i.each(this.networkIDs,function(i){var n=t.get(i),s=n.get("maxLength")||null;(null===e||e>s)&&(e=s)}),this.maxLength=e,this.calculateCharactersRemaining()},calculateCharactersRemaining:function(){var e=this.ui.message.val(),t=this.maxLength-e.length;
return null===this.maxLength?void this.ui.charactersRemaining.addClass("hidden"):(0>t?(this.ui.charactersRemaining.addClass("error").removeClass("hidden"),this.ui.shareBtn.addClass("disabled")):(this.ui.charactersRemaining.removeClass("error hidden"),this.ui.shareBtn.removeClass("disabled")),void this.ui.charactersRemaining.text(this.maxLength-e.length))},onRender:function(){r.prototype.onRender.apply(this,arguments),this.autoSelect&&(this.networkIDs.push(this.linkedNetworks[0].id),this.calculateMaxLength())
},onNetworkClick:function(e){e.preventDefault();var n=t(e.currentTarget),s=n.data("id");n.hasClass("selected")?this.networkIDs.splice(i.indexOf(this.networkIDs,s),1):this.networkIDs.push(s),n.toggleClass("selected"),this.networkIDs.length?(this.ui.shareBtn.removeClass("disabled"),this.ui.messageContainer.removeClass("invisible")):(this.ui.shareBtn.addClass("disabled"),this.ui.messageContainer.addClass("invisible")),this.calculateMaxLength()},onMessageKeyUp:function(){this.calculateCharactersRemaining()
},onShareClick:function(e){e.preventDefault();var t=this.ui.shareBtn;if(!t.isDisabled()){t.addClass("active");var s={item:this.model,networkIDs:this.networkIDs,message:this.ui.message.val()},a=n.execute("share",s);a.done(i.bind(this.onShareSuccess,this)),a.fail(i.bind(this.onShareError,this))}},onShareSuccess:function(){this.hide()},onShareError:function(){this.ui.shareBtn.removeClass("active")}});return o}),define("hb!templates/desktop/modals/RecommendModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n        <div class="friends-container"></div>\n\n        <div class="message-container invisible">\n          <textarea class="message form-control" placeholder="',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Say something about this...",s):u.call(e,"t","Say something about this...",s)))+'"></textarea>\n        </div>\n      '}function r(e,t){var n,s,a="";return a+='\n        <div class="empty-message">\n          ',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"You need {1}friends{2} to recommend media.",'<a class="friends-btn" href="#!/friends">',"</a>",s):u.call(e,"t","You need {1}friends{2} to recommend media.",'<a class="friends-btn" href="#!/friends">',"</a>",s)))+"\n        </div>\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return d+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon share-alt"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Select Friends",c):u.call(t,"t","Select Friends",c)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      ',l=i["if"].call(t,t&&t.hasFriends,{hash:{},inverse:p.program(3,r,s),fn:p.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='\n    </div>\n\n    <div class="modal-footer">\n      <span class="characters-remaining"></span>\n      <button type="button" class="send-btn btn btn-primary btn-loading disabled">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Send",c):u.call(t,"t","Send",c)))+"</span>\n      </button>\n    </div>\n  </div>\n</div>\n\n"
})}),define("hb!templates/desktop/lists/user/SelectFriendListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l="function",c=this.escapeExpression,d=i.helperMissing;return o+='<a class="friend" data-id="',(a=i.recommendationsPlaylistId)?a=a.call(t,{hash:{},data:s}):(a=t&&t.recommendationsPlaylistId,a=typeof a===l?a.call(t,{hash:{},data:s}):a),o+=c(a)+'" href="#">\n  <span class="media-poster user-poster"></span> ',r={hash:{},data:s},o+=c((a=i.truncate||t&&t.truncate,a?a.call(t,t&&t.title,20,r):d.call(t,"truncate",t&&t.title,20,r)))+"\n</a>\n"
})}),define("plex/desktop/views/lists/user/SelectFriendListItem",["hb!templates/desktop/lists/user/SelectFriendListItem.tpl","marionette","plex/base/views/images/GravatarImage"],function(e,t,i){"use strict";var n=t.ItemView.extend({tagName:"li",className:"striped-list-item select-list-item",template:e,ui:{poster:".user-poster"},initialize:function(){this.image=new i({model:this.model,type:"friend",width:80})},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()
}});return n}),define("plex/desktop/views/lists/user/SelectFriendList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/user/SelectFriendListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list select-list select-friends-list dark-scrollbar",itemView:t});return i}),define("plex/desktop/views/modals/RecommendModal",["hb!templates/desktop/modals/RecommendModal.tpl","jquery","underscore","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/modals/BaseModal","plex/desktop/views/modals/SelectModal","plex/desktop/views/lists/user/SelectFriendList"],function(e,t,i,n,s,a,r,o){"use strict";
var l=r.extend({name:"recommendModal",className:"recommend-modal select-modal modal modal-sm fade",template:e,playlistIDs:null,ui:{sendBtn:".send-btn",messageContainer:".message-container",message:".message"},regions:{list:".friends-container"},events:i.extend({"click .friend":"onFriendClick","click .friends-btn":"onFriendsClick","click .send-btn":"onSendClick"},a.prototype.events),initialize:function(){r.prototype.initialize.apply(this,arguments);var e=s.get("user");this.collection=e.get("friends").filterByUnrestricted(),this.playlistIDs=[]
},serializeData:function(){return{hasFriends:!!this.collection.length}},onRender:function(){r.prototype.onRender.apply(this,arguments),this.list.show(new o({collection:this.collection}))},onClose:function(){this.collection.destroy()},onFriendClick:function(e){e.preventDefault();var n=t(e.currentTarget),s=n.data("id");n.hasClass("selected")?this.playlistIDs.splice(i.indexOf(this.playlistIDs,s),1):this.playlistIDs.push(s),n.toggleClass("selected"),this.playlistIDs.length?(this.ui.sendBtn.removeClass("disabled"),this.ui.messageContainer.removeClass("invisible")):(this.ui.sendBtn.addClass("disabled"),this.ui.messageContainer.addClass("invisible"))
},onFriendsClick:function(){this.hide()},onSendClick:function(e){e.preventDefault();var t=this.ui.sendBtn;if(!t.isDisabled()){t.addClass("active");var s={item:this.model,playlistIDs:this.playlistIDs,message:this.ui.message.val()},a=n.execute("recommend",s);a.done(i.bind(this.onSendSuccess,this)),a.fail(i.bind(this.onSendError,this))}},onSendSuccess:function(){this.hide()},onSendError:function(){this.ui.sendBtn.removeClass("active")}});return l}),define("plex/desktop/views/players/controls/VideoPlayerControlsView",["hb!templates/desktop/players/controls/VideoPlayerControlsView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/browser","plex/base/utils/dispatcher","plex/base/utils/capabilities","plex/base/utils/formatters/dateTimeUtil","plex/base/adapters/settingsAdapter","plex/base/models/appModel","plex/base/models/player/UpNextCollection","plex/base/views/images/BaseImage","plex/base/views/images/MediaPosterImage","plex/base/views/components/player/ASSRendererView","plex/desktop/views/players/controls/SeekBarView","plex/desktop/views/players/controls/SliderView","plex/desktop/views/players/controls/VideoPlayerQualityDropdown","plex/desktop/views/players/controls/VideoPlayerStreamDropdown","plex/desktop/views/players/controls/VideoPlayerPrimaryPlayerDropdown","plex/desktop/views/players/controls/VideoPlayerControlsScrubView","plex/desktop/views/players/controls/VideoPlayerImageOverlaysView","plex/desktop/views/dropdowns/PlayQueueDropdown","plex/desktop/views/modals/ShareModal","plex/desktop/views/modals/RecommendModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y,b,w,x,k,S,C){"use strict";
var P=n.Layout.extend({className:"video-controls transition-out",template:e,visible:!1,muted:!1,mutedVolume:0,ui:{video:"#html-video",poster:".media-poster",background:".video-background",volumeBtn:".volume-btn",errorMessage:".video-error-message",errorSkipMessage:".video-error-skip-message",dropdowns:".player-dropdowns-container",dropups:".player-dropups-container"},regions:{subtitles:".video-subtitles-container",seekBar:".seek-bar-container",volume:".player-volume-slider-container",playQueueDropdown:"#player-play-queue-dropdown",qualityDropdown:"#player-quality-dropdown",audioDropdown:"#player-subtitles-dropdown",subtitlesDropdown:"#player-audio-dropdown",playerDropdown:"#player-primary-player-dropdown",scrubPreview:".player-scrub-preview-container",imageOverlays:".video-image-overlays-region"},modelEvents:{"change:item":"onItemChange","change:subtitlesUrl":"onPlayerSubtitlesUrlChange","change:volume":"onVolumeChange","change:errorMessage":"onErrorMessageChange","change:showQuality":"onShowQualityChange","change:showAudioStream":"onShowAudioStreamChange","change:showSubtitleStream":"onShowSubtitleStreamChange"},events:{"click .volume-btn":"onVolumeClick","click .enter-fullscreen-btn":"onEnterFullscreenClick","click .exit-fullscreen-btn":"onExitFullscreenClick","click .video-overlay-btn":"onOverlayClick","click .share-btn":"onShareClick","click .recommend-btn":"onRecommendClick","click .video-error-message-center":"onErrorMessageClick"},triggers:{"click .play-btn":"play","click .pause-btn":"pause","click .previous-btn":"previous","click .next-btn":"next","click .minimize-btn":"minimize"},onlyAfterRender:["onVolumeChange","onErrorMessageChange"],initialize:function(){t.bindAll(this,"onMobileVideoClose"),this.bindAllWhenRendered("transitionIn","transitionOut"),this.item=this.model.get("item"),this.upNextCollection=new u(null,{parent:this.model}),this.posterImage=new p({model:this.item,type:"movie",getUrl:this.getPosterUrl,width:100}),this.backgroundImage=new h({server:this.item.server,width:1280,height:720}),this.seekBarView=new f({model:this.model}),this.playQueueDropdownView=new k({model:this.model,collection:this.upNextCollection}),this.volumeSlider=new g({className:"player-volume-slider player-slider",value:this.model.get("volume")}),this.listenTo(this.seekBarView,"change:value",this.onSeekBarValueChange),this.listenTo(this.seekBarView,"hover",this.onSeekBarHover),this.listenTo(this.volumeSlider,"change:value",this.onVolumeSliderValueChange),this.listenTo(this.playQueueDropdownView,"itemview:skip",this.onSkip),this.listenTo(this.playQueueDropdownView,"itemview:remove",this.onRemove),this.listenTo(this.playQueueDropdownView,"move",this.onMove)
},getPosterUrl:function(e){return this.model.get("parentThumb")||this.model.get("grandparentThumb")||e},transitionIn:function(){this.visible=!0,this.$el.removeClass("transition-out")},transitionOut:function(){this.$(".dropdown.open, .dropup.open").length||(this.visible=!1,this.$el.addClass("transition-out"),this.scrubPreview.currentView.hide())},updateVolumeBtn:function(e){var t=this.ui.volumeBtn;e>50?(this.muted=!1,t.addClass("high"),t.removeClass("low mute")):50>=e&&e>0?(this.muted=!1,t.addClass("low"),t.removeClass("high mute")):(this.muted=!0,t.addClass("mute"),t.removeClass("high low"))
},replaceVideo:function(e){var t=i(e);this.ui.video.off("webkitendfullscreen",this.onMobileVideoClose),t.attr("id",this.ui.video.attr("id")),t.attr("class",this.ui.video.attr("class")),this.ui.video.replaceWith(t),this.ui.video=t,t.on("webkitendfullscreen",this.onMobileVideoClose)},createErrorSkipInterval:function(){this.errorSkipInterval=clearInterval(this.errorSkipInterval),this.errorSkipCounter=5,this.updateErrorSkipMessage(this.errorSkipCounter),this.errorSkipInterval=setInterval(t.bind(this.onErrorSkipInterval,this),1e3)
},updateErrorSkipMessage:function(e){this.ui.errorSkipMessage.text(s("Skipping in {1} seconds...",e))},bindings:{".video-title":{modelAttribute:"item",autohide:!0,formatter:function(e){return e.get("title")}},".video-background":{modelAttribute:"item",manual:!0,formatter:function(e,i){var n=e.get("art")||e.channel&&e.channel.get("art");if(i.css("background-image","none"),i.addClass("transition-out"),!n)return this.currentArt=null,void(this.currentArtSrc=null);var s=t.bind(function(e){this.currentArt=n,this.currentArtSrc=e,i.css("background-image","url("+e+")"),i.removeClass("transition-out")
},this);this.currentArt===n?s(this.currentArtSrc):this.backgroundImage.load(n,!0).done(s)}},".play-btn":{modelAttribute:"paused",modelListeners:["paused","canPlayPause"],manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.model.get("canPlayPause")),e}},".pause-btn":{modelAttribute:"paused",modelListeners:["paused","canPlayPause"],manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.model.get("canPlayPause")),!e}},".previous-btn":{modelAttribute:"canSkipPrevious",manual:!0,autohide:function(){var e=this.model.get("playQueue");
return e&&e.get("collection").length>1},formatter:function(e,t){t.toggleClass("disabled",!e)}},".next-btn":{modelAttribute:"canSkipNext",manual:!0,autohide:function(){var e=this.model.get("playQueue");return e&&e.get("collection").length>1},formatter:function(e,t){t.toggleClass("disabled",!e)}},".player-position":{modelAttribute:"position",formatter:function(e){return l.formatDuration(e)}},".player-duration":{modelAttribute:"duration",formatter:function(e){return l.formatDuration(e)}},".volume-btn":{modelAttribute:"canSetVolume",manual:!0,autohide:!0,formatter:function(e){return this.$el.toggleClass("show-volume",e),e
}},".minimize-btn":{modelAttribute:"showMinimize",manual:!0,autohide:!0},".enter-fullscreen-btn":{modelAttribute:"showEnterFullscreen",manual:!0,autohide:!0},".exit-fullscreen-btn":{modelAttribute:"showExitFullscreen",manual:!0,autohide:!0},".share-btn, .recommend-btn":{modelAttribute:"item",manual:!0,autohide:function(e){var i=d.get("user"),n=t.contains(["clip","userPlaylistItem"],e.get("type"));return e.get("url")&&i.get("signedIn")&&n}},".primary-player-name":{modelAttribute:"friendlyName",autohide:!0,formatter:function(e){return e?s("Casting to {1}",e):void 0
}}},onRender:function(){this.ui.video.on("webkitendfullscreen",this.onMobileVideoClose),this.posterImage.setElement(this.ui.poster),this.seekBar.append(this.seekBarView),this.volume.show(this.volumeSlider);var e=this.model.get("playQueue");e&&e.get("collection").length>1&&this.playQueueDropdown.append(this.playQueueDropdownView,this.ui.dropups),this.updateVolumeBtn(this.model.get("volume")),this.scrubPreview.append(new w({model:this.model})),this.qualityDropdown.append(new v({model:this.model}),this.ui.dropdowns),this.audioDropdown.append(new y({model:this.model,type:"audio"}),this.ui.dropdowns),this.subtitlesDropdown.append(new y({model:this.model,type:"subtitles"}),this.ui.dropdowns),this.playerDropdown.append(new b,this.ui.dropdowns),this.imageOverlays.show(new x({model:this.model}))
},onClose:function(){this.ui.video.off("webkitendfullscreen",this.onMobileVideoClose),this.errorSkipInterval=clearInterval(this.errorSkipInterval),this.posterImage.close(),this.backgroundImage.close()},onItemChange:function(e,t){this.errorSkipInterval=clearInterval(this.errorSkipInterval),this.posterImage.src=null,this.posterImage.setModel(t),this.posterImage.render(),this.backgroundImage.src=null},onPlayerSubtitlesUrlChange:function(e,t){t?this.subtitles.show(new m({model:e,subtitleSize:c.get("subtitleSize"),rendererOptions:{enableSvg:"safari"!==a.id}})):this.subtitles.close()
},onVolumeChange:function(e,t){this.volumeSlider.displayValue(t),this.updateVolumeBtn(t)},onErrorMessageChange:function(e,t){var i=d.has("primaryPlayer");if(this.ui.errorMessage.text(t),this.ui.errorSkipMessage.text(""),t&&!i){var n=e.get("playQueue").get("collection");if(n.length>1){var s=e.get("item"),a=n.at(n.length-1);s.id!==a.id&&this.createErrorSkipInterval()}}},onErrorSkipInterval:function(){this.errorSkipCounter--,this.updateErrorSkipMessage(this.errorSkipCounter),0===this.errorSkipCounter&&(this.errorSkipInterval=clearInterval(this.errorSkipInterval),this.trigger("next"))
},onShowQualityChange:function(e,t){var i=this.qualityDropdown.currentView;i&&i.$el.toggleClass("hidden",!t)},onShowAudioStreamChange:function(e,t){var i=this.audioDropdown.currentView;i&&i.$el.toggleClass("hidden",!t)},onShowSubtitleStreamChange:function(e,t){var i=this.subtitlesDropdown.currentView;i&&i.$el.toggleClass("hidden",!t)},onSeekBarValueChange:function(e){this.trigger("change:position",e)},onSeekBarHover:function(e){e?(this.scrubPreview.currentView.updatePreview(e),this.scrubPreview.currentView.show()):this.scrubPreview.currentView.hide()
},onVolumeSliderValueChange:function(e){this.trigger("change:volume",e)},onVolumeClick:function(e){e.preventDefault(),this.muted?(this.mutedVolume>0?this.trigger("change:volume",this.mutedVolume):this.trigger("change:volume",100),this.muted=!1,this.mutedVolume=0):(this.muted=!0,this.mutedVolume=this.model.get("volume"),this.trigger("change:volume",0))},onEnterFullscreenClick:function(e){e.preventDefault(),this.model.get("forceWebkitVideoFullscreen")?this.ui.video[0].webkitEnterFullscreen():this.trigger("enterFullscreen")
},onExitFullscreenClick:function(e){e.preventDefault(),this.trigger("exitFullscreen")},onMobileVideoClose:function(){r.trigger("hide:player")},onOverlayClick:function(e){e.preventDefault();var t=this.model.get("playing"),i=t?"pause":"play";return"pause"===i&&o.hasTouchScreen&&!this.visible?void this.trigger("toggleControls",{autohide:!0}):void this.trigger(i)},onShareClick:function(e){e.preventDefault(),r.trigger("show:modal",new S({model:this.item}))},onRecommendClick:function(e){e.preventDefault(),r.trigger("show:modal",new C({model:this.item}))
},onErrorMessageClick:function(e){e.preventDefault(),this.errorSkipInterval?this.trigger("next"):r.trigger("hide:player")},onSkip:function(e,t){this.trigger("skip",t)},onRemove:function(e,t){this.trigger("remove",t)},onMove:function(e,t){this.trigger("move",e,t)}});return P}),define("hb!templates/desktop/players/PostPlayView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o,l="",c=i.helperMissing,d=this.escapeExpression,u="function";
return l+='<div class="post-play-background background"></div>\n\n<div class="post-play-footer">\n  <div class="item-previous">\n    <div class="item-poster">\n      <h1>',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Previous",o):c.call(t,"t","Previous",o)))+'</h1>\n      <a class="media-poster-container replay-btn play-btn" href="#">\n        <div class="media-poster">\n          <div class="media-poster-overlay"></div>\n          <div class="media-poster-overlay-icons">\n            <i class="media-poster-overlay-icon glyphicon refresh"></i>\n          </div>\n        </div>\n      </a>\n    </div>\n    <div class="item-summary">\n      <h1 class="media-title">'+d((a=t&&t.previous,a=null==a||a===!1?a:a.title,typeof a===u?a.apply(t):a))+'</h1>\n      <h2 class="media-subtitle-1">',a=t&&t.previous,a=null==a||a===!1?a:a.subtitle,r=typeof a===u?a.apply(t):a,(r||0===r)&&(l+=r),l+='</h2>\n    </div>\n  </div>\n\n  <div class="item-next">\n    <div class="item-poster">\n      <h1>',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Playing Next",o):c.call(t,"t","Playing Next",o)))+'</h1>\n      <a class="media-poster-container next-btn play-btn" href="#">\n        <div class="media-poster">\n          <div class="media-poster-overlay"></div>\n\n          <div class="countdown"></div>\n\n          <div class="media-poster-overlay-icons">\n            <i class="media-poster-overlay-icon glyphicon play"></i>\n          </div>\n        </div>\n      </a>\n    </div>\n\n    <div class="item-summary">\n      <h1 class="media-title">'+d((a=t&&t.next,a=null==a||a===!1?a:a.title,typeof a===u?a.apply(t):a))+'</h1>\n      <h2 class="media-subtitle-1">'+d((a=t&&t.next,a=null==a||a===!1?a:a.subtitle,typeof a===u?a.apply(t):a))+'</h2>\n      <h3 class="media-subtitle-2">',a=t&&t.next,a=null==a||a===!1?a:a.index,r=typeof a===u?a.apply(t):a,(r||0===r)&&(l+=r),l+="</h3>\n      <p>"+d((a=t&&t.next,a=null==a||a===!1?a:a.summary,typeof a===u?a.apply(t):a))+"</p>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/base/mixins/player/postPlayMixin",["underscore","backbone","plex/base/utils/mediaUtil"],function(e,t,i){"use strict";var n={ui:{background:".post-play-background",previousPoster:".item-previous .media-poster",nextPoster:".item-next .media-poster",nextTitle:".next-title",nextSubtitle:".next-subtitle",nextIndex:".next-index",countdown:".countdown"},createCountdown:function(e){this.totalSeconds=e,this.secondsLeft=this.totalSeconds,this.progressModel=new t.Model({text:this.secondsLeft}),this.updateCountdown()
},serializeData:function(){var e=this.nextItem.get("title"),t=this.nextItem.get("grandparentTitle"),i={previous:{title:this.previousItem.get("title")||this.previousItem.get("grandparentTitle"),subtitle:this.episodeIndexFor(this.previousItem)||this.previousItem.get("year")},next:{title:t||e,summary:this.nextItem.get("summary")}};return t?(i.next.subtitle=e,i.next.index=this.episodeIndexFor(this.nextItem)):i.next.subtitle=this.nextItem.get("year"),i},episodeIndexFor:function(e){var t="";return"episode"===e.get("type")&&(t=i.getSeasonEpisodeIndex({seasonIndex:e.get("parentIndex"),episodePrefix:" \xb7 E{1}",episodeIndex:e.get("index"),date:e.get("originallyAvailableAt"),noLeadingZero:!0})),t
},updateCountdown:function(){var t=(new Date).getTime(),i=t-(this.startTime||t);this.startTime=t,this.secondsLeft-=i/1e3,this.secondsLeft>0?(this.progressModel.set("fraction",1-this.secondsLeft/this.totalSeconds),this.progressModel.set("text",Math.ceil(this.secondsLeft)),this.countdownAnimator=window.requestAnimationFrame(e.bind(this.updateCountdown,this))):this.trigger("next")},onClose:function(){window.cancelAnimationFrame(this.countdownAnimator)}};return n}),define("hb!templates/desktop/progressbar/CircleProgressBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<canvas class="circle-progress-bar"></canvas>\n<div class="circle-progress-text"></div>'
})}),define("plex/base/mixins/views/circleProgressBarMixin",["plex/base/utils/capabilities"],function(e){"use strict";var t={className:"circle-progress",ui:{canvas:".circle-progress-bar"},bindings:{".circle-progress-text":{modelAttribute:"text"}},initialize:function(){e.hasCanvas&&this.listenTo(this.model,"change:fraction",this.onFractionChange)},onRender:function(){e.hasCanvas&&(this.progressCanvas=this.ui.canvas[0])},onFractionChange:function(){if(this.$el.width()>0&&(this.progressCanvas.width=this.$el.width(),this.progressCanvas.height=this.$el.height(),this.progressContext=this.progressCanvas.getContext("2d")),this.progressContext){var e=this.model.get("fraction");
this.progressContext.lineWidth=5,this.progressContext.strokeStyle="#cc7b19";var t=this.progressCanvas.width/2,i=this.progressCanvas.height/2,n=t-5,s=-Math.PI/2,a=s+e*Math.PI*2;this.progressContext.clearRect(0,0,this.progressCanvas.width,this.progressCanvas.height),this.progressContext.beginPath(),this.progressContext.arc(t,i,n,s,a,!1),this.progressContext.stroke(),this.progressContext.closePath()}}};return t}),define("plex/desktop/views/progressbar/CircleProgressBarView",["hb!templates/desktop/progressbar/CircleProgressBarView.tpl","marionette","plex/base/mixins/views/circleProgressBarMixin"],function(e,t,i){"use strict";
var n=t.ItemView.extend({mixins:i,template:e});return n}),function(){for(var e=0,t=["ms","moz","webkit","o"],i=0;i<t.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[t[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[t[i]+"CancelAnimationFrame"]||window[t[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t){var i=(new Date).getTime(),n=Math.max(0,16-(i-e)),s=window.setTimeout(function(){t(i+n)},n);return e=i+n,s
}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)})}(),define("requestanimframe",function(){}),define("plex/desktop/views/players/PostPlayView",["hb!templates/desktop/players/PostPlayView.tpl","underscore","marionette","plex/base/mixins/player/postPlayMixin","plex/base/views/images/BaseImage","plex/base/views/images/MediaPosterImage","plex/desktop/views/progressbar/CircleProgressBarView","requestanimframe"],function(e,t,i,n,s,a,r){"use strict";var o=i.Layout.extend({mixins:n,className:"video-post-play",template:e,regions:{countdown:".countdown"},events:{"click .next-btn":"onNextClick","click .replay-btn":"onReplayClick",mousemove:"onMouseMove"},initialize:function(e){e||(e={}),e.countdown&&this.createCountdown(e.countdown),this.previousItem=this.model;
var t=this.collection.indexOf(this.model)+1;this.nextItem=this.collection.at(t);var i="movie"===this.previousItem.get("type")?"art":"thumb";this.previousPoster=new a({model:this.previousItem,modelAttribute:i,type:this.previousItem.get("type"),height:140}),this.nextPoster=new a({model:this.nextItem,modelAttribute:i,type:this.nextItem.get("type"),height:190}),this.backgroundImage=new s({model:this.nextItem,modelAttribute:"art",width:1280,height:720,background:!0})},onRender:function(){this.previousPoster.setElement(this.ui.previousPoster),this.nextPoster.setElement(this.ui.nextPoster),this.backgroundImage.setElement(this.ui.background),this.totalSeconds&&this.countdown.append(new r({model:this.progressModel}))
},onNextClick:function(e){e.preventDefault(),this.trigger("next",{manual:!0})},onReplayClick:function(e){e.preventDefault(),this.trigger("replay")},onMouseMove:function(e){(this.lastX!==e.clientX||this.lastY!==e.clientY)&&this.totalSeconds&&(this.startTime=0,this.lastX=e.clientX,this.lastY=e.clientY,window.cancelAnimationFrame(this.countdownAnimator),clearInterval(this.idleTimer),this.idleTimer=setTimeout(t.bind(this.updateCountdown,this),1e3))},onClose:function(){n.onClose.apply(this,arguments),clearInterval(this.idleTimer)
}});return o}),define("plex/desktop/views/players/VideoPlayerView",["hb!templates/desktop/players/VideoPlayerView.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/capabilities","plex/base/utils/xhrTracker","plex/base/utils/playerUtil","plex/base/utils/types/extraTypes","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/players/BasePlayerView","plex/desktop/views/modals/ConfirmModal","plex/desktop/views/modals/SelectMediaModal","plex/desktop/views/modals/SelectOffsetModal","plex/desktop/views/players/controls/VideoPlayerControlsView","plex/desktop/views/players/PostPlayView"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v){"use strict";
var y=h.extend({className:"video-player dark-scrollbar buffering",template:e,volumeSettingsKey:"videoPlayerVolume",controlsDelay:a.hasTouchScreen?4e3:2e3,ui:{container:".video-container"},regions:{controls:".video-controls-container",postPlay:".video-post-play-container"},events:t.extend({"click .player-close-btn":"onCloseClick",mousemove:"onMouseMove"},h.prototype.events),postPlayDuration:10,awakeTime:72e5,maximumDurationForAutoadvance:12e5,minimumDurationForPostPlay:3e5,initialize:function(e){this.playQueue=e.playQueue,h.prototype.initialize.apply(this,arguments),this.controlsView=new g({model:this.playerModel}),d.execute("playSound",{stop:!0,background:!0}),this.startSleepProtection(),this.addListeners()
},addListeners:function(){h.prototype.addListeners.apply(this,arguments),this.listenTo(this.playerModel,{"change:ready":this.onPlayerReadyChange,"change:embedHtml":this.onPlayerEmbedHtmlChange}),this.listenTo(this.controlsView,"toggleControls",this.toggleControls)},startPlayback:function(e){e||(e={});var i,n,s=!1,a=this.whenRendered(function(){this.controller.load({model:this.playerModel,media:i,offset:n,autoplay:e.autoplay,postplay:u.get("primaryPlayer")?!1:!0,silent:s,mediaElement:e.mediaElement||this.controls.currentView.ui.video[0]})
});if(this.isNowPlaying())return s=!0,void a();var r=this.resolveMedia();r=r.then(t.bind(function(t){return i=t,e.offset?e.offset:this.resolveOffset()},this)),r.done(function(e){n=e,a()}),r.fail(this.stop)},continuePlayback:function(){this.controlsView.replaceVideo(this.controller.mediaElement),this.playerModel.get("ready")&&(this.onPlayerReadyChange(this.playerModel,!0),this.onPlayerStateChange(this.playerModel,this.playerModel.get("state")))},resolveMedia:function(){var e=i.Deferred(),t=this.model.get("Media");
if(c.get("autoResolution")||t.length<2)return e.resolve().promise();var n=new m({model:this.model}),a=n.promise;return a.done(function(i){var n=t[i];e.resolve(n)}),a.fail(function(){e.reject()}),s.trigger("show:modal",n),e.promise()},resolveOffset:function(){var e=i.Deferred(),n=this.model.get("viewOffset");if(t.isNumber(this.offset)&&(n=this.offset),!n)return e.resolve(0).promise();var a=new f({offset:n}),r=a.promise;return r.done(function(t){e.resolve(t)}),r.fail(function(){e.reject()}),s.trigger("show:modal",a),e.promise()
},stop:function(){var e,t,a=i.Deferred().resolve().promise(),r=!u.get("primaryPlayer");if(this.model&&r&&(e=this.model.server.get("playQueueManager"),t=e.getFor(this.model)),t&&t.get("hasUserAdditions")){var o=new p({title:n("Finish Watching Queue"),message:n("This will clear the contents of your play queue.")});a=o.promise,s.trigger("show:modal",o)}return a.then(function(){s.trigger("hide:player")}),a},canAutoplay:function(e){return!a.hasTouchScreen&&(null==e||e!==o.states.PAUSED)},showVideo:function(e){this.$el.toggleClass("show-html-video","html"===e),this.$el.toggleClass("show-flash-video","flash"===e),this.$el.toggleClass("show-placeholder-video",!e)
},hideVideo:function(){this.$el.removeClass("show-html-video show-flash-video show-placeholder-video")},toggleControls:function(e){this.controller.model&&this.controller.model.get("ready")&&"flash"!==this.controller.playerType&&(e||(e={}),this.controlsView.visible||this.controlsView.transitionIn(),this.controlsTimeout=clearTimeout(this.controlsTimeout),e.autohide&&(this.controlsTimeout=setTimeout(this.controlsView.transitionOut,this.controlsDelay)))},startSleepProtection:function(){clearTimeout(this.sleepTimeout),this.isDefinitelyAwake||(this.isPotentiallyAsleep?this.isDefinitelyAwake=!0:this.sleepTimeout=setTimeout(t.bind(this.onSleep,this),this.awakeTime))
},onRender:function(){this.controls.show(this.controlsView),h.prototype.onRender.apply(this,arguments)},onClose:function(){h.prototype.onClose.apply(this,arguments),this.controlsTimeout=clearTimeout(this.controlsTimeout),this.sleepTimeout=clearTimeout(this.sleepTimeout),this.controller.model&&!this.isContinuing&&r.abortAll("player")},onPlayerReadyChange:function(e,t){t?(this.showVideo(this.controller.playerType),this.controller.companion?this.toggleControls():this.toggleControls({autohide:!0})):this.hideVideo()
},onPlayerStateChange:function(e,t){h.prototype.onPlayerStateChange.apply(this,arguments),this.controller.companion||(t===o.states.ERROR&&this.hideVideo(),clearTimeout(this.controlsTimeout),this.controlsTimeout=setTimeout(this.controlsView.transitionOut,this.controlsDelay)),this.$el.toggleClass("stopped",e.get("stopped")),this.$el.toggleClass("paused",e.get("paused")),this.$el.toggleClass("playing",e.get("playing")),this.$el.toggleClass("buffering",e.get("buffering")),this.$el.toggleClass("error",e.get("error"))
},onPlayerEmbedHtmlChange:function(e,t){this.ui.container.html(t)},onPlayerFinishedChange:function(e,t){if(t){var i=this.model.get("duration")<this.minimumDurationForPostPlay,n=this.model.get("extraType")===l.getExtraTypeByString("trailer").id;if(this.model===this.playQueue.get("collection").last())this.model.server.get("playQueueManager").remove("video"),s.trigger("hide:player");else if(i||n)this.controller.skipNext();else{this.hideVideo();var a={model:this.model,collection:this.playQueue.get("collection")},r=this.model.get("duration")<this.maximumDurationForAutoadvance;
(!this.isPotentiallyAsleep||this.isDefinitelyAwake||r)&&(a.countdown=this.postPlayDuration);var o=new v(a);this.listenTo(o,{replay:this.onPostPlayReplay,next:this.onPostPlayNext}),this.postPlay.show(o)}}},onPostPlayReplay:function(){this.startSleepProtection(),this.stopListening(this.postPlay.currentView),this.postPlay.close(),this.controller.setPosition(0,{autoplay:!0}),this.showVideo(this.controller.playerType)},onPostPlayNext:function(e){e&&e.manual&&this.startSleepProtection(),this.stopListening(this.postPlay.currentView),this.postPlay.close(),this.controller.skipNext()
},onSleep:function(){this.isPotentiallyAsleep=!0},onCloseClick:function(e){e.preventDefault(),this.stop()},onMouseMove:function(e){(this.lastX!==e.clientX||this.lastY!==e.clientY)&&(this.lastX=e.clientX,this.lastY=e.clientY,this.controller.companion||this.playerModel.get("finished")||this.toggleControls({autohide:!0}))}});return y}),define("hb!templates/desktop/players/VideoMiniPlayerView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("plex/desktop/views/players/MiniPlayerView",["underscore","plex/desktop/views/players/BasePlayerView"],function(e,t){"use strict";var i=t.extend({className:"player mini-player",isMini:!0,regions:{controls:".mini-player-controls"},shortcutListeners:function(){var i=t.prototype.shortcutListeners.apply(this,arguments);return e.omit(i,"shortcut:stop")}});return i}),define("hb!templates/desktop/players/controls/MiniPlayerControlsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="mini-controls-left">\n  <a class="media-poster-container" href="#"><div class="media-poster"></div></a>\n  <div class="media-title">\n    <div class="grandparent-title-container">\n      <button class="grandparent-title btn-link btn-metadata-link"></button>\n    </div>\n    <div class="title-container">\n      <button class="item-title btn-link btn-metadata-link"></button>\n    </div>\n    <div class="rating-container"></div>\n  </div>\n</div>\n\n<div class="mini-player-scrub-preview hidden"></div>\n<div class="mini-controls-center">\n  <div class="mini-controls-center-buttons">\n    <button class="previous-btn btn-link"><i class="glyphicon fast-backward"></i></button>\n    <button class="play-btn btn-link btn-link-lg hidden"><i class="glyphicon play"></i></button>\n    <button class="pause-btn btn-link btn-link-lg hidden"><i class="glyphicon pause"></i></button>\n    <button class="stop-btn btn-link btn-link-lg hidden"><i class="glyphicon stop"></i></button>\n    <button class="next-btn btn-link"><i class="glyphicon fast-forward"></i></button>\n\n    <span id="player-actions-dropdown" class="dropup">\n      <button class="more-btn btn-link dropdown-toggle" href="#player-actions-dropdown" data-toggle="dropdown"><i class="glyphicon more"></i></button>\n    </span>\n  </div>\n\n  <div class="seek-bar-container">\n    <span class="player-position"></span>\n    <span class="player-duration"></span>\n  </div>\n</div>\n\n<div class="mini-controls-right">\n  <button class="maximize-btn btn-link"><i class="glyphicon chevron-up"></i></button>\n  <span class="player-play-queue-container"></span>\n  <span class="player-volume-slider-container"></span>\n  <button class="volume-btn btn-link btn-link-lg hidden">\n    <i class="glyphicon volume-up"></i>\n    <i class="glyphicon volume-down"></i>\n    <i class="glyphicon mute"></i>\n  </button>\n</div>\n'
})}),define("hb!templates/desktop/RatingView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='<span class="star"><i class="star-icon glyphicon ',n=i["if"].call(e,e,{hash:{},inverse:d.program(4,o,t),fn:d.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+='"></i><span class="empty-icon"></span></span>'}function r(){return"star"}function o(){return"dislikes"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c="",d=this;return l=i.each.call(t,t&&t.stars,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(l||0===l)&&(c+=l),c+="\n"
})}),define("plex/desktop/views/RatingView",["hb!templates/desktop/RatingView.tpl","jquery","underscore","plex/desktop/views/players/controls/SliderView","plex/base/commands/commands"],function(e,t,i,n,s){"use strict";var a=n.extend({tagName:"span",className:"rating",template:e,disabled:!0,modelEvents:{"change:rating":"onRatingChange","change:userRating":"onRatingChange"},events:i.extend({mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousemove:"onMouseMove"},n.prototype.events),initialize:function(e){n.prototype.initialize.apply(this,arguments),this.disabled=e.disabled||this.model.server.get("shared"),this.passive=e.passive,this.updateRating()
},updateRating:function(){this.metadataRating=this.model.get("rating")||0,this.userRating=this.model.get("userRating"),this.setValue(this.userRating>0?this.userRating:this.metadataRating)},serializeData:function(){var e=Math.round(this.currentValue/2);return{stars:[e>0,e>1,e>2,e>3,e>4]}},getValueForPosition:function(e){var t=this.$el,i=e-t.offset().left,n=i/t.width();return n=Math.min(Math.max(n,0),1),n=2*Math.ceil(5*n)},persistValue:function(){var e=this.currentValue||-1;s.execute("rate",{item:this.model,rating:e,passive:this.passive}),this.updateRating(),this.render()
},displayValue:function(e){this.$el.data("value",e);var i=e/2-1,n=this.$(".star-icon");n.each(function(e){var n=i>=e;t(this).toggleClass("star",n).toggleClass("dislikes",!n)}),this.$el.toggleClass("unrated",!e)},onRender:function(){n.prototype.onRender.apply(this,arguments),this.$el.toggleClass("unrated",!this.currentValue),this.$el.toggleClass("user-rating",this.userRating>0),this.$el.toggleClass("disabled",this.disabled)},onRatingChange:function(){this.updateRating(),this.render()},onMouseEnter:function(){this.disabled||(this.$el.addClass("user-rating"),this.$el.removeClass("unrated"))
},onMouseLeave:function(){this.disabled||this.render()},onMouseMove:function(e){if(!this.disabled)if(this.dragging)this.updateForPosition(e.pageX);else{var t=this.getValueForPosition(e.pageX);this.displayValue(t)}},onDragComplete:function(){this.disabled||this.persistValue()}});return a}),define("hb!templates/desktop/dropdowns/PlayerActionsDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='<li><a class="download-btn" href="',(n=i.downloadUrl)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadUrl,n=typeof n===d?n.call(e,{hash:{},data:t}):n),a+=u(n)+'" download="',(n=i.downloadName)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadName,n=typeof n===d?n.call(e,{hash:{},data:t}):n),a+=u(n)+'" tabindex="-1">',s={hash:{},data:t},a+=u((n=i.t||e&&e.t,n?n.call(e,"Download",s):h.call(e,"t","Download",s)))+"</a></li>"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<li><a class="play-mix-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Play Plex Mix",l):h.call(t,"t","Play Plex Mix",l)))+'</a></li>\n<li><a class="add-to-playlist-btn btn-link" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Add to Playlist...",l):h.call(t,"t","Add to Playlist...",l)))+'</a></li>\n\n<li class="divider"></li>\n\n<li><a class="sync-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sync...",l):h.call(t,"t","Sync...",l)))+"</a></li>\n",o=i["if"].call(t,t&&t.downloadUrl,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n<li><a class="share-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Share...",l):h.call(t,"t","Share...",l)))+'</a></li>\n<li><a class="recommend-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Recommend...",l):h.call(t,"t","Recommend...",l)))+'</a></li>\n<li><a class="info-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Info",l):h.call(t,"t","Info",l)))+"</a></li>\n"
})}),define("plex/desktop/models/MediaActionsModel",["underscore","plex/base/utils/t","plex/base/utils/contentUtil","plex/base/utils/types/mediaTypes","plex/base/models/BaseModel","plex/base/models/appModel"],function(e,t,i,n,s,a){"use strict";function r(e){return e.get("unviewedLeafCount")>0}function o(e){var t=e.get("viewCount"),i=e.get("viewOffset");return!(t&&!i)}function l(e){return!e||e.get("isFolder")?!1:!n.getMediaTypeByString(e.get("type")).child}function c(e){return!r(e)}function d(e){return!o(e)
}var u={movie:{showAddToPlaylist:!0,showAnalyze:!0,showDelete:!0,showDownload:!0,showEdit:!0,showFixMatch:!0,showInfo:!0,showMarkUnwatched:!0,showMarkWatched:!0,showMatch:!0,showPlay:!0,showPlayTrailer:!0,showQueue:!0,showRefresh:!0,showSplitApart:!0,showSync:!0,showUnmatch:!0},show:{showAddToPlaylist:!0,showEdit:!0,showDelete:!0,showFixMatch:!0,showMarkUnwatched:!0,showMarkWatched:!0,showMatch:!0,showPlayAll:!0,showPlayUnwatched:!0,showQueue:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSplitApart:!0,showSync:!0,showUnmatch:!0},season:{showAddToPlaylist:!0,showEdit:!0,showDelete:!0,showMarkUnwatched:!0,showMarkWatched:!0,showPlay:!0,showQueue:!0,showSelect:!0,showShuffle:!0,showSync:!0},episode:{showAddToPlaylist:!0,showAnalyze:!0,showDelete:!0,showDownload:!0,showEdit:!0,showInfo:!0,showMarkUnwatched:!0,showMarkWatched:!0,showPlay:!0,showQueue:!0,showRefresh:!0,showSync:!0},artist:{showAddToPlaylist:!0,showEdit:!0,showDelete:!0,showFixMatch:!0,showMatch:!0,showPlay:!0,showQueue:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSplitApart:!0,showSync:!0,showUnmatch:!0},album:{showAddToPlaylist:!0,showEdit:!0,showDelete:!0,showFixMatch:!0,showMatch:!0,showPlay:!0,showQueue:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSplitApart:!0,showSync:!0,showUnmatch:!0},track:{showAddToPlaylist:!0,showAnalyze:!0,showDelete:!0,showDownload:!0,showEdit:!0,showInfo:!0,showPlayMix:!0,showPlayMusicVideo:!0,showQueue:!0,showSelect:!0,showSync:!0},photoAlbum:{showEdit:!0,showPlay:!0,showShuffle:!0,showSync:!0},photo:{showAnalyze:!0,showDelete:!0,showDownload:!0,showEdit:!0,showInfo:!0,showSync:!0},clip:{showInfo:!0,showPlay:!0,showShare:!0,showWatchLater:!0},userPlaylistItem:{showDeleteFromUserPlaylist:!0,showInfo:!0,showMarkUnwatched:!0,showMarkWatched:!0,showPlay:!0,showShare:!0,showSync:!0,showWatchLater:!0},playlist:{showDelete:!0,showEdit:!0,showPlay:!0,showShuffle:!0},movieSection:{showAddToCollection:!0,showAddToPlaylist:!0,showAnalyze:!0,showEdit:!0,showMarkUnwatched:!0,showMarkWatched:!0,showMerge:!0,showPlay:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},showSection:{showAddToCollection:!0,showAddToPlaylist:!0,showEdit:!0,showMarkUnwatched:!0,showMarkWatched:!0,showMerge:!0,showPlay:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},seasonSection:{showAddToPlaylist:!0,showEdit:!0,showMarkUnwatched:!0,showMarkWatched:!0,showMerge:!0,showPlay:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},episodeSection:{showAddToPlaylist:!0,showAnalyze:!0,showMarkUnwatched:!0,showMarkWatched:!0,showPlay:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},artistSection:{showAddToCollection:!0,showAddToPlaylist:!0,showEdit:!0,showMerge:!0,showPlay:!0,showQueue:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},albumSection:{showAddToPlaylist:!0,showEdit:!0,showMerge:!0,showPlay:!0,showQueue:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},trackSection:{showAddToPlaylist:!0,showEdit:!0,showPlay:!0,showQueue:!0,showRefresh:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0},photoSection:{showAnalyze:!0,showPlay:!0,showSelect:!0,showShuffle:!0,showSync:!0,showDelete:!0}},h={showListDropdown:["showShuffle","showQueue","showRefresh","showSync","showDownload","showWatchLater","showShare","showInfo"]},p=s.extend({initialize:function(e,t){t||(t={}),this.item=t.item,this.parent=this.item||this.section,this.showAdvanced=t.showAdvanced,this.user=a.get("user"),this.signedIn=this.user.get("signedIn"),this.devices=this.user.get("devices"),this.setDefaults(t.type),this.listenToParent(),this.listenTo(a,"change:primaryPlayer",this.onPrimaryPlayerChange),this.listenTo(this.user,"change:signedIn",this.onSignedInChange),this.listenTo(this.devices,"reset",this.onDevicesChange),this.listenTo(this,{"change:selecting":this.onSelectingChange,"change:selectedItems":this.onSelectedItemsChange})
},setDefaults:function(t){t&&t!==this.type&&(this.type=t,this.section&&(t+="Section"),this.defaults=e.clone(u[t]||{}),this.defaults.selecting=!1,this.defaults.selectedItems=[],this.clear().set(this.defaults))},setParent:function(e){this.parent&&this.stopListening(this.parent),this.server&&this.stopListening(this.server),this.playQueues&&this.stopListening(this.playQueues),this.item=e.item,this.section=e.section,this.parent=this.item||this.section,this.listenToParent()},listenToParent:function(){if(this.section){var e=this.parent.get("currentType");
this.setDefaults(e.get("typeString")),this.listenTo(this.parent,{"change:currentType":this.onCurrentTypeChange,"change:allowSync":this.onAllowSyncChange})}else this.item&&(this.setDefaults(this.item.get("type")),this.listenTo(this.parent,{"change:primaryExtraKey":this.onPrimaryExtraChange,"change:unviewedLeafCount":this.onViewStateChange,"change:viewOffset":this.onViewStateChange,"change:viewCount":this.onViewStateChange}),this.showAdvanced&&this.listenTo(this.parent,"change:guid",this.onGuidChange));
this.parent&&(this.server=this.parent.server,this.shared=this.server.get("shared"),this.synced=this.server.get("synced"),this.multiuser=this.server.get("multiuser"),this.playQueues=this.server.get("playQueueManager"),this.listenTo(this.server,"change:shared",this.onServerSharedChange),this.listenTo(this.playQueues,"change",this.onPlayQueuesChange)),this.updateAll()},updateAll:function(){this.updateAction("showPlay",this.canPlay),this.updateAction("showPlayAll",this.canPlay),this.updateAction("showPlayUnwatched",this.canPlay),this.updateAction("showPlayMix",this.canPlayMix),this.updateAction("showPlayTrailer",this.canPlayPrimaryExtra),this.updateAction("showPlayMusicVideo",this.canPlayPrimaryExtra),this.updateAction("showShuffle",this.canPlay,{shuffle:!0}),this.updateAction("showQueue",this.isMedia),this.updateAction("showEdit",this.canEdit),this.updateAction("showRefresh",this.canRefresh),this.updateAction("showSync",this.canSync),this.updateAction("showDownload",this.canRefresh),this.updateAction("showAddToPlaylist",this.canAddToPlaylist),this.updateAction("showWatchLater",this.canWatchLater),this.updateAction("showShare",this.canShare),this.updateAction("showDelete",this.canDelete),this.updateAction("showInfo",this.isMedia),this.updateAction("showMarkWatched",this.canMarkWatched),this.updateAction("showMarkUnwatched",this.canMarkUnwatched),this.showAdvanced&&(this.updateAction("showSelect",this.canMultiSelect),this.updateAction("showAnalyze",this.canMultiAction),this.updateAction("showMerge",this.canMultiAction),this.updateAction("showAddToCollection",this.canMultiAction),this.updateAction("showMatch",this.canShowMatch),this.updateAction("showFixMatch",this.canShowFixMatch),this.updateAction("showUnmatch",this.canUnmatch),this.updateAction("showSplitApart",this.canSplitApart)),this.updateCanQueue(),this.updateDropdown("showListDropdown")
},updateAction:function(e,t,i){var n=this.defaults?this.defaults[e]:!1;this.set(e,t.call(this,n,i))},updateCanQueue:function(){var t=this.parent&&this.playQueues.getFor(this.parent),i=!0,n=a.get("primaryPlayer");if(n){var s=n.get("protocolCapabilities");i=e(s).contains("playqueues")}this.set("canQueue",!(!t||!i))},updateDropdown:function(t){var i=h[t],n=e.map(i,function(e){return this.get(e)},this);this.set(t,e.some(n))},canPlay:function(e,t){return e?this.parent&&!this.playQueues.canCreateFor(this.parent,t)?!1:!this.item||!this.item.get("isFolder")&&!this.item.get("hasInvalidKey"):!1
},canPlayMix:function(e){if(!e||!this.item)return!1;var t=this.item.get("related");return!(!t||!t.findWhere({browse:!1}))},canPlayPrimaryExtra:function(e){return e&&this.item?!!this.item.get("primaryExtraKey"):!1},canAddToPlaylist:function(e){if(!e||!this.server)return!1;var t,i=this.server.supports("playlists"),n=this.parent&&this.parent.get("currentSubset");if(n){var s=this.get("selectedItems");t="all"===n.id||s.length>0}else t=this.item&&this.item.isLibraryItem();return i&&t},canRefresh:function(t){if(!t||this.synced)return!1;
var i=this.getActionTargets(),n=e.every(i,function(e){var t=this.shared&&e.get("isPlaylist"),i=e.get("isSection"),n=!this.shared&&(i||e.isLibraryItem()&&!e.get("isFolder"));return t||n},this);return n},canEdit:function(e){if(!e||!this.canRefresh(e))return!1;var t=this.getActionTargets();return t&&t.length>1&&!t[0].server.supports("batchEdit")?!1:!0},canMultiSelect:function(){return(!this.shared||this.multiuser)&&this.get("showSelect")},canMultiAction:function(e){return e?this.item?this.canEdit(e):!this.shared&&!this.synced&&this.section:!1
},canMarkWatched:function(e){if(!e)return!1;if(!this.item&&!this.section)return!1;if(!this.canMultiSelect()&&!l(this.item))return!1;var t=this.getActionTargets();if(!t)return!1;var i=t[0];return i.get("isSection")||i.get("isFolder")?!1:this.hasUnwatched()},canMarkUnwatched:function(e){if(!e)return!1;if(!this.canMultiSelect()&&!l(this.item))return!1;var t=this.getActionTargets();if(!t)return!1;var i=t[0];return i.get("isSection")||i.get("isFolder")?!1:this.hasWatched()},canShowMatch:function(e){return this.canEdit(e)&&!this.canUnmatch(e)
},canShowFixMatch:function(e){return this.canEdit(e)&&this.canUnmatch(e)},canUnmatch:function(e){if(!e||!this.item||this.shared||this.synced)return!1;var t=this.item.get("guid");return!(!t||/(local|none)\:\/\//.test(t))},canSplitApart:function(e){if(!e||!this.item||this.shared||this.synced)return!1;var t;return t=this.item.get("show"===this.type||"artist"===this.type||"album"===this.type?"Location":"Media"),t.length>1&&this.server.supports("splitApart")},canSync:function(e){if(!e||!this.parent||this.shared||this.synced)return!1;
var t=this.devices.filterSyncDevices(this.item);if(!t.length)return!1;var i=this.server.supports("sync"),n=this.parent.get("allowSync")||this.parent.collection&&this.parent.collection.allowSync;return!(!i||!n||this.parent.get("isFolder"))},canWatchLater:function(e){if(!e||!this.item)return!1;var t="video"===n.getChildMediaType(this.type).element,i=!!this.item.get("url"),s=!this.item.get("playlist")||"queue"!==this.item.get("playlist");return this.signedIn&&this.user.get("queueUid")&&t&&i&&s},canShare:function(e){return e&&this.signedIn&&!this.user.get("restricted")
},canDelete:function(t){if(!t)return!1;if(this.item&&!this.item.get("isSection"))return this.canDeleteSingleItem(this.item);if(!this.canMultiSelect())return!1;var i=this.getActionTargets();return i?e.every(i,this.canDeleteSingleItem,this):!1},canDeleteSingleItem:function(e){if(!e||this.synced||e.get("isSection"))return!1;if(!l(e)&&!e.server.supports("compositeDelete"))return!1;var t=!(!e.isLibraryItem()||!this.server.get("allowMediaDeletion")||this.shared),i=e.get("playlistType");return t||i},isMedia:function(e){if(!e)return!1;
if(!this.item)return!0;var t="photo"===this.type&&!this.item.isLibraryItem();return!t&&!this.item.get("isFolder")},shouldStartTrackingSelecting:function(e){return this.canMultiSelect()&&(e.metaKey||e.ctrlKey||e.shiftKey||this.get("selecting"))},selectItems:function(t,i){if(0!==t.length){var n=this.get("selectedItems"),s=e.bind(this.updateAll,this),a=e.filter(t,function(t){return!e.contains(n,t)});e.each(a,function(e){e.selected=!0,n.push(e),this.listenTo(e,{"change:viewCount":s,"change:viewOffset":s,"change:unviewedLeafCount":s,"change:viewedLeafCount":s})
},this);var r=this.sortSelectedItems(n,i);this.set("selectedItems",r),this.trigger("change:selectedItems",this,r)}},sortSelectedItems:function(t,i){var n=i&&i.superset;return n?e.sortBy(t,function(e){return n.indexOf(e)}):e.clone(t)},deselectItems:function(t){if(0!==t.length){var i=this.get("selectedItems");e.each(t,function(t){var n=e.indexOf(i,t);-1!==n&&(t.selected=!1,i.splice(n,1),this.stopListening(t))},this),i.length||this.set("selecting",!1),this.trigger("change:selectedItems",this,i)}},selectItem:function(e,t){this.selectItems([e],t)
},deselectItem:function(e,t){this.deselectItems([e],t)},deselectAll:function(){var t=this.get("selectedItems");t&&0!==t.length&&(e.each(t,function(e){e.selected=!1}),t.length=0,this.trigger("change:selectedItems",this,t))},getActionTargets:function(){var e=this.get("selectedItems");return e&&e.length>0?e:this.parent?[this.parent]:void 0},getActionTargetsTitle:function(){var e=this.getActionTargets();if(1===e.length){var i=e[0];return i.get("isSection")?i.getSyncTitle():i.get("title")}return t("{1} Items",e.length)
},contentUri:function(e){return i.uri(this.getActionTargets(),e)},hasWatched:function(){var t=this.getActionTargets(),i=t[0].get("type"),n="show"===i||"season"===i;return e.some(t,n?c:d)},hasUnwatched:function(){var t=this.getActionTargets(),i=t[0].get("type"),n="show"===i||"season"===i;return e.some(t,n?r:o)},hasSelectedItems:function(){var e=this.get("selectedItems");return e&&e.length},onPrimaryPlayerChange:function(){this.updateCanQueue()},onSignedInChange:function(e,t){this.signedIn=t,this.updateAction("showWatchLater",this.canWatchLater),this.updateAction("showShare",this.canShare),this.updateDropdown("showListDropdown")
},onCurrentTypeChange:function(e,t){this.setDefaults(t.get("typeString")),this.updateAll()},onAllowSyncChange:function(){this.updateAction("showSync",this.canSync)},onPrimaryExtraChange:function(){this.updateAction("showPlayTrailer",this.canPlayPrimaryExtra),this.updateAction("showPlayMusicVideo",this.canPlayPrimaryExtra)},onViewStateChange:function(){this.updateAction("showMarkWatched",this.canMarkWatched),this.updateAction("showMarkUnwatched",this.canMarkUnwatched)},onGuidChange:function(){this.updateAction("showUnmatch",this.canUnmatch),this.updateAction("showMatch",this.canShowMatch),this.updateAction("showFixMatch",this.canShowFixMatch)
},onServerSharedChange:function(e,t){this.shared=t,this.updateAll()},onPlayQueuesChange:function(){this.updateCanQueue()},onDevicesChange:function(){this.updateAction("showSync",this.canSync)},onSelectingChange:function(e,t){t||this.deselectAll()},onSelectedItemsChange:function(e,t){this.set("selecting",!(!t||!t.length)),this.updateAll()}});return p}),define("hb!templates/desktop/modals/MediaInfoModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hide-streams-column"
}function r(e,t){var n,s,a,r="";return r+='\n          <div class="files">\n            <h4>',a={hash:{},data:t},r+=N((n=i.t||e&&e.t,n?n.call(e,"Files",a):O.call(e,"t","Files",a)))+"</h4>\n            ",s=i.each.call(e,e&&e.media,{hash:{},inverse:B.noop,fn:B.programWithDepth(4,o,t,e),data:t}),(s||0===s)&&(r+=s),r+="\n          </div>\n        "}function o(e,t,n){var s,a="";return a+='\n              <ul class="media-info-file-list well">\n                ',s=i["if"].call(e,n&&n.showDeleteFile,{hash:{},inverse:B.noop,fn:B.program(5,l,t),data:t}),(s||0===s)&&(a+=s),a+="\n                ",s=i.each.call(e,e&&e.Part,{hash:{},inverse:B.noop,fn:B.programWithDepth(10,u,t,n),data:t}),(s||0===s)&&(a+=s),a+="\n              </ul>\n            "
}function l(e,t){var n,s,a,r="";return r+='\n                  <a href="#" data-media-item="'+N((n=t,n=null==n||n===!1?n:n.index,typeof n===F?n.apply(e):n))+'" class="delete-btn text-danger pull-right">\n                    <i class="glyphicon bin"></i>\n                    ',a={hash:{},inverse:B.program(8,d,t),fn:B.program(6,c,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.Part,null==n||n===!1?n:n.length),"1",a):O.call(e,"if_eq",(n=e&&e.Part,null==n||n===!1?n:n.length),"1",a),(s||0===s)&&(r+=s),r+="\n                  </a>\n                "
}function c(e,t){var n,s,a="";return a+="\n                      ",s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Delete File",s):O.call(e,"t","Delete File",s)))+"\n                    "}function d(e,t){var n,s,a="";return a+="\n                      ",s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Delete Files",s):O.call(e,"t","Delete Files",s)))+"\n                    "}function u(e,t,n){var s,a,r,o="";return o+="\n                  <li>\n                    ",s=i["if"].call(e,n&&n.showFilepath,{hash:{},inverse:B.program(13,p,t),fn:B.program(11,h,t),data:t}),(s||0===s)&&(o+=s),o+="\n\n                    ",r={hash:{},inverse:B.noop,fn:B.program(15,m,t),data:t},s=i.if_neq||e&&e.if_neq,a=s?s.call(e,e&&e.accessible,"1",r):O.call(e,"if_neq",e&&e.accessible,"1",r),(a||0===a)&&(o+=a),o+="\n                  </li>\n                "
}function h(e,t){var n,s="";return s+="\n                      ",(n=i.file)?n=n.call(e,{hash:{},data:t}):(n=e&&e.file,n=typeof n===F?n.call(e,{hash:{},data:t}):n),s+=N(n)+"\n                    "}function p(e,t){var n,s,a="";return a+="\n                      ",s={hash:{},data:t},a+=N((n=i.getLastSegment||e&&e.getLastSegment,n?n.call(e,e&&e.file,s):O.call(e,"getLastSegment",e&&e.file,s)))+"\n                    "}function m(e,t){var n,s,a,r="";return r+="\n                      ",a={hash:{},inverse:B.program(18,g,t),fn:B.program(16,f,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.exists,"1",a):O.call(e,"if_eq",e&&e.exists,"1",a),(s||0===s)&&(r+=s),r+="\n                    "
}function f(e,t){var n,s,a="";return a+='\n                        <span class="label label-danger" data-toggle="tooltip" title="',s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Please check the permissions for this file.",s):O.call(e,"t","Please check the permissions for this file.",s)))+'">',s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Inaccessible",s):O.call(e,"t","Inaccessible",s)))+"</span>\n                      "}function g(e,t){var n,s,a="";return a+='\n                        <span class="label label-danger" data-toggle="tooltip" title="',s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Please check that this file exists and the necessary drive is mounted.",s):O.call(e,"t","Please check that this file exists and the necessary drive is mounted.",s)))+'">',s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Unavailable",s):O.call(e,"t","Unavailable",s)))+"</span>\n                      "
}function v(e,t,n){var s,a,r,o="";return o+='\n          <div class="media">\n            <div class="props">\n              <h4>',r={hash:{},data:t},o+=N((s=i.t||e&&e.t,s?s.call(e,"Media",r):O.call(e,"t","Media",r)))+"</h4>\n              <ul>\n                ",a=i.each.call(e,e&&e.properties,{hash:{},inverse:B.noop,fn:B.program(21,y,t),data:t}),(a||0===a)&&(o+=a),o+="\n              </ul>\n            </div>\n\n            ",a=i.each.call(e,e&&e.Part,{hash:{},inverse:B.noop,fn:B.programWithDepth(23,b,t,n),data:t}),(a||0===a)&&(o+=a),o+="\n          </div>\n        "
}function y(e,t){var n,s,a,r="";return r+='\n                  <li>\n                    <span class="detail-label">',a={hash:{},data:t},r+=N((n=i.t||e&&e.t,n?n.call(e,e&&e.name,a):O.call(e,"t",e&&e.name,a)))+'</span>\n                    <span class="detail">',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===F?s.call(e,{hash:{},data:t}):s),r+=N(s)+"</span>\n                  </li>\n                "}function b(e,t,n){var s,a,r,o="";return o+='\n              <div class="part">\n                <div class="props">\n                  <h4>',r={hash:{},data:t},o+=N((s=i.t||e&&e.t,s?s.call(e,"Part",r):O.call(e,"t","Part",r)))+"</h4>\n                  <ul>\n                    ",a=i.each.call(e,e&&e.properties,{hash:{},inverse:B.noop,fn:B.program(24,w,t),data:t}),(a||0===a)&&(o+=a),o+='\n                  </ul>\n                </div>\n\n                <div class="streams">\n                  ',a=i.each.call(e,e&&e.Stream,{hash:{},inverse:B.noop,fn:B.program(26,x,t),data:t}),(a||0===a)&&(o+=a),o+="\n                  ",a=i["if"].call(e,n&&n.loading,{hash:{},inverse:B.noop,fn:B.program(37,I,t),data:t}),(a||0===a)&&(o+=a),o+="\n                </div>\n              </div>\n            "
}function w(e,t){var n,s,a,r="";return r+='\n                      <li>\n                        <span class="detail-label">',a={hash:{},data:t},r+=N((n=i.t||e&&e.t,n?n.call(e,e&&e.name,a):O.call(e,"t",e&&e.name,a)))+'</span>\n                        <span class="detail">',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===F?s.call(e,{hash:{},data:t}):s),r+=N(s)+"</span>\n                      </li>\n                    "}function x(e,t){var n,s,a,r="";return r+='\n                    <div class="props">\n                      ',a={hash:{},inverse:B.program(29,S,t),fn:B.program(27,k,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.streamType,"1",a):O.call(e,"if_eq",e&&e.streamType,"1",a),(s||0===s)&&(r+=s),r+="\n\n                      <ul>\n                        ",s=i.each.call(e,e&&e.properties,{hash:{},inverse:B.noop,fn:B.program(35,_,t),data:t}),(s||0===s)&&(r+=s),r+="\n                      </ul>\n                    </div>\n                  "
}function k(e,t){var n,s,a="";return a+="\n                        <h4>",s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Video",s):O.call(e,"t","Video",s)))+"</h4>\n                      "}function S(e,t){var n,s,a;return a={hash:{},inverse:B.program(32,P,t),fn:B.program(30,C,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.streamType,"2",a):O.call(e,"if_eq",e&&e.streamType,"2",a),s||0===s?s:""}function C(e,t){var n,s,a="";return a+="\n                        <h4>",s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Audio",s):O.call(e,"t","Audio",s)))+"</h4>\n                      "
}function P(e,t){var n,s,a;return a={hash:{},inverse:B.noop,fn:B.program(33,A,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.streamType,"3",a):O.call(e,"if_eq",e&&e.streamType,"3",a),s||0===s?s:""}function A(e,t){var n,s,a="";return a+="\n                        <h4>",s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Subtitles",s):O.call(e,"t","Subtitles",s)))+"</h4>\n                      "}function _(e,t){var n,s,a,r="";return r+='\n                          <li>\n                            <span class="detail-label">',a={hash:{},data:t},r+=N((n=i.t||e&&e.t,n?n.call(e,e&&e.name,a):O.call(e,"t",e&&e.name,a)))+'</span>\n                            <span class="detail">',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===F?s.call(e,{hash:{},data:t}):s),r+=N(s)+"</span>\n                          </li>\n                        "
}function I(e,t){var n,s,a="";return a+='\n                    <div class="props">\n                      <h4>',s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"Loading",s):O.call(e,"t","Loading",s)))+"...</h4>\n                    </div>\n                  "}function T(e,t,n){var s;return s=i["if"].call(e,n&&n.showFilepath,{hash:{},inverse:B.noop,fn:B.program(40,M,t),data:t}),s||0===s?s:""}function M(e,t){var n,s,a="";return a+='\n      <div class="modal-footer">\n        <div class="pull-left">\n          <a href="',(n=i.url)?n=n.call(e,{hash:{},data:t}):(n=e&&e.url,n=typeof n===F?n.call(e,{hash:{},data:t}):n),a+=N(n)+'" target="_blank">',s={hash:{},data:t},a+=N((n=i.t||e&&e.t,n?n.call(e,"View XML",s):O.call(e,"t","View XML",s)))+"</a>\n        </div>\n      </div>\n    "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var D,E,L,R="",O=i.helperMissing,N=this.escapeExpression,F="function",B=this;return R+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-info"></i> ',L={hash:{},data:s},R+=N((D=i.t||t&&t.t,D?D.call(t,"Media Info",L):O.call(t,"t","Media Info",L)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <div class="position-ref ',E=i.unless.call(t,t&&t.hasStreams,{hash:{},inverse:B.noop,fn:B.program(1,a,s),data:s}),(E||0===E)&&(R+=E),R+='">\n        ',E=i["if"].call(t,t&&t.hasFiles,{hash:{},inverse:B.noop,fn:B.program(3,r,s),data:s}),(E||0===E)&&(R+=E),R+="\n\n        ",E=i.each.call(t,t&&t.media,{hash:{},inverse:B.noop,fn:B.programWithDepth(20,v,s,t),data:s}),(E||0===E)&&(R+=E),R+="\n      </div>\n    </div>\n\n    ",E=i["if"].call(t,t&&t.key,{hash:{},inverse:B.noop,fn:B.programWithDepth(39,T,s,t),data:s}),(E||0===E)&&(R+=E),R+="\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/MediaInfoModal",["hb!templates/desktop/modals/MediaInfoModal.tpl","underscore","jquery","plex/base/utils/formatters/stringUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/utils/formatters/metadataUtil","plex/base/models/appModel","plex/desktop/views/modals/BaseModal","plex/base/commands/commands","plex/desktop/models/MediaActionsModel"],function(e,t,i,n,s,a,r,o,l,c){"use strict";function d(e){var i=t.reject(e,function(e){return 0===e.id}),n=t.sortBy(i,"streamType");
return t.map(n,function(e){return g(e,"streamType")})}function u(e){return t.map(e.get("Media"),function(e){return t.extend(g(e,"Part"),{Part:t.map(e.Part,function(e){return t.extend(g(e,"Stream"),{file:e.file,exists:e.exists,accessible:e.accessible,Stream:d(e.Stream)})})})})}var h=["id","key","index","videoCodec","audioCodec","audioChannels","default","selected","languageCode","codecID","accessible","exists"],p={size:a.formatBytes,duration:s.formatDuration,codec:n.upperCase,format:n.upperCase,container:n.upperCase,videoResolution:a.formatResolution,channels:a.formatAudioChannels,level:a.formatVideoLevel,bitrateMode:n.upperCase,accessible:n.formatBoolean,exists:n.formatBoolean,optimizedForStreaming:n.formatBoolean,file:n.getLastSegment},m={optimizedForStreaming:"Web Optimized",has64bitOffsets:"Has 64bit Offsets",cabac:"CABAC",postURL:"URL"},f={frameRate:" fps",dialogNorm:" dB",bitrate:" kbps",samplingRate:" Hz"},g=function(e,i){var s={properties:[]};
for(var a in e)if(a!==i&&-1===t.indexOf(h,a)){var r=m[a],o=e[a];p[a]&&(o=p[a](o)),o&&(f[a]&&(o+=f[a]),r||(r=n.formatLabel.call(this,a)),s.properties.push({name:r,value:o}))}return i&&e&&(s[i]=e[i]),s},v=o.extend({name:"mediaInfoModal",className:"media-info-modal modal modal-lg fade",template:e,ui:{scroller:".modal-body-scroll",files:".files > ul",stickyProps:".media > .props, .part > .props"},events:t.extend({"click .delete-btn":"onDeleteClick"},o.prototype.events),modelEvents:{"change:Media":"onMediaChange"},initialize:function(){o.prototype.initialize.apply(this,arguments),this.bindAllWhenRendered("onMediaChange","onScroll"),this.loading=!1,this.media=u(this.model),this.mediaActions=new c({},{item:this.model}),this.hasStreams()||(this.loading=!0,this.model.fetch().always(this.whenRendered(function(){this.model.changed.hasOwnProperty("Media")||this.updateMedia()
})))},serializeData:function(){var e=this.model.get("key"),t=r.get("user"),i=this.model.server;return this.model.isLibraryItem()&&(e+=e.indexOf("?")>0?"&":"?",e+="checkFiles=1&includeExtras=1"),{key:e,url:this.model.server.resolveUrl(e,{appendToken:!0}),media:this.media,hasFiles:this.hasFiles(),hasStreams:this.hasStreams()||this.loading,showDeleteFile:i.supports("specificMediaDeletion"),showFilepath:!i.get("shared")||t.isNinja(),loading:this.loading}},updateMedia:function(){this.loading=!1,this.rerender=!0,this.ui.scroller.off("scroll",this.onScroll),this.media=u(this.model),this.render()
},hasFiles:function(){return!!t.chain(this.media).pluck("Part").flatten().pluck("file").compact().size().value()},hasStreams:function(){return!!t.chain(this.media).pluck("Part").flatten().pluck("Stream").flatten().size().value()},bindingsModel:"mediaActions",bindings:{".delete-btn":{modelAttribute:"showDelete",manual:!0,autohide:!0}},onRender:function(){o.prototype.onRender.apply(this,arguments),this.ui.scroller.on("scroll",this.onScroll),this.$el.tooltip({selector:".files .label",placement:"bottom"})
},onClose:function(){this.ui.scroller.off("scroll",this.onScroll)},onMediaChange:function(){return this.isHidden?void 0:this.model.get("Media").length?void this.updateMedia():void this.hide()},onDeleteClick:function(e){e.preventDefault(),l.execute("deleteMediaItem",{item:this.model,index:i(e.currentTarget).data("media-item")})},onScroll:function(){var e=this.ui.scroller.scrollTop(),t=this.ui.scroller.offset().top;return this.ui.files.length&&(t+=parseInt(this.ui.files.css("margin-bottom"),10)),0>t?void setTimeout(this.onScroll,500):void this.ui.stickyProps.each(function(){var n=i(this),s=n.parent().height()-n.height(),a=e-this.parentNode.offsetTop,r=Math.min(Math.max(a,0),s);
r&&r===a?(n.addClass("sticky"),n.css("top",t)):(n.removeClass("sticky"),n.css("top",r))})}});return v}),define("plex/desktop/views/dropdowns/PlayerActionsDropdown",["hb!templates/desktop/dropdowns/PlayerActionsDropdown.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/formatters/stringUtil","plex/base/utils/types/mediaTypes","plex/base/commands/commands","plex/desktop/models/MediaActionsModel","plex/desktop/views/modals/AddToPlaylistModal","plex/desktop/views/modals/ShareModal","plex/desktop/views/modals/MediaInfoModal","plex/desktop/views/modals/RecommendModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p){"use strict";
var m=n.ItemView.extend({tagName:"ul",className:"dropdown-menu",template:e,ui:{divider:".divider"},events:{"click .play-mix-btn":"onPlayMixClick","click .add-to-playlist-btn":"onAddToPlaylistClick","click .sync-btn":"onSyncClick","click .share-btn":"onShareClick","click .recommend-btn":"onRecommendClick","click .info-btn":"onInfoClick"},initialize:function(){this.mediaType=o.getMediaTypeByString(this.model.get("type")),this.mediaActions=new c({},{item:this.model}),i(".dropdown.open .dropdown-toggle").dropdown("toggle")
},serializeData:function(){var e,t;if(this.mediaActions.get("showDownload")){e=this.model.getDownloadUrl();var i=this.model.getFilepath();i&&(t=r.getLastSegment(i))}return{downloadUrl:e,downloadName:t}},bindingsModel:"mediaActions",bindings:{".play-mix-btn":{modelAttribute:"showPlayMix",manual:!0,autohide:!0,formatter:function(e,t){if(e){var i=this.model.get("related"),n=i.findWhere({browse:!1}),a=n.get("title");a&&t.text(s("Queue {1}",a))}return e}},".add-to-playlist-btn":{modelAttribute:"showAddToPlaylist",manual:!0,autohide:!0},".sync-btn":{modelAttribute:"showSync",manual:!0,autohide:!0},".download-btn":{modelAttribute:"showDownload",manual:!0,autohide:!0},".share-btn, .recommend-btn":{modelAttribute:"showShare",manual:!0,autohide:!0},".info-btn":{modelAttribute:"showInfo",manual:!0,autohide:!0}},onRender:function(){var e=this.ui.divider,t=e.prevAll(":not(:has(.hidden))").length,i=e.nextAll(":not(:has(.hidden))").length;
e.toggleClass("hidden",!t||!i)},onClose:function(){this.mediaActions.stopListening()},onPlayMixClick:function(e){e.preventDefault();var t=this.model.get("related"),i=t.findWhere({browse:!1});i.set("type","track"),l.execute("queueMedia",{item:i,excludeSeedItem:!0,next:!0})},onAddToPlaylistClick:function(e){return e.preventDefault(),i(e.currentTarget).isDisabled()?void e.stopImmediatePropagation():void a.trigger("show:modal",new d({model:this.model}))},onSyncClick:function(e){e.preventDefault();var t={model:this.model,type:this.mediaType,isNew:!0,isSection:!1};
l.execute("showSyncModal",t)},onShareClick:function(e){e.preventDefault(),a.trigger("show:modal",new u({model:this.model}))},onRecommendClick:function(e){e.preventDefault(),a.trigger("show:modal",new p({model:this.model}))},onInfoClick:function(e){e.preventDefault(),a.trigger("show:modal",new h({model:this.model}))}});return m}),define("plex/desktop/views/players/controls/MiniPlayerControlsView",["hb!templates/desktop/players/controls/MiniPlayerControlsView.tpl","marionette","plex/base/utils/formatters/dateTimeUtil","plex/base/views/images/MediaPosterImage","plex/desktop/views/RatingView","plex/desktop/views/players/controls/SeekBarView","plex/desktop/views/players/controls/SliderView","plex/desktop/views/dropdowns/PlayerActionsDropdown","plex/desktop/views/dropdowns/PlayQueueDropdown"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=t.Layout.extend({className:"mini-controls",template:e,muted:!1,mutedVolume:0,ui:{poster:".media-poster",previousBtn:".previous-btn",nextBtn:".next-btn",volumeBtn:".volume-btn",scrubPreview:".mini-player-scrub-preview"},regions:{rating:".rating-container",dropdown:"#player-actions-dropdown",seekBar:".seek-bar-container",volume:".player-volume-slider-container",playQueue:".player-play-queue-container"},modelEvents:{"change:item":"onItemChange","change:volume":"onVolumeChange"},events:{"click .volume-btn":"onVolumeClick"},triggers:{"click .play-btn":{event:"play",preventDefault:!0},"click .pause-btn":{event:"pause",preventDefault:!0},"click .previous-btn":{event:"previous",preventDefault:!0},"click .next-btn":{event:"next",preventDefault:!0},"click .maximize-btn":{event:"maximize",preventDefault:!0},"click .stop-btn":{event:"stop",preventDefault:!0},"click .media-poster-container":{event:"navigate:item",preventDefault:!0},"click .grandparent-title":{event:"navigate:grandparent",preventDefault:!0},"click .item-title":{event:"navigate:item",preventDefault:!0}},onlyAfterRender:["onVolumeChange"],initialize:function(e){var t=this.model.get("item");
this.image=new n({model:t,type:t.get("type"),getUrl:this.getPosterUrl,height:80,exposeUrl:!0}),this.seekBarView=new a({model:this.model}),this.playQueueDropdown=new l({model:this.model,collection:e.upNextCollection}),this.volumeSlider=new r({className:"player-volume-slider player-slider",value:this.model.get("volume")}),this.listenTo(this.image,"load",this.onPosterLoad),this.listenTo(this.seekBarView,"change:value",this.onSeekBarValueChange),this.listenTo(this.seekBarView,"hover",this.onSeekBarHover),this.listenTo(this.volumeSlider,"change:value",this.onVolumeSliderValueChange),this.listenTo(this.playQueueDropdown,"itemview:skip",this.onSkip),this.listenTo(this.playQueueDropdown,"itemview:remove",this.onRemove),this.listenTo(this.playQueueDropdown,"move",this.onMove)
},getPosterUrl:function(e){return e=e||this.model.get("parentThumb")||this.model.get("grandparentThumb"),e||(this.model.parent?e=this.model.parent.get("thumb"):this.model.channel&&(e=this.model.channel.get("thumb"))),e},updatePosterTitle:function(e){var t=e.get("parentTitle")||e.get("title");this.ui.poster.attr({"data-image-title":t,"data-title":e.get("title"),"data-parent-title":e.get("parentTitle"),"data-grandparent-title":e.get("originalTitle")||e.get("grandparentTitle")})},updateVolumeBtn:function(e){var t=this.ui.volumeBtn;
e>50?(this.muted=!1,t.addClass("high"),t.removeClass("low mute")):50>=e&&e>0?(this.muted=!1,t.addClass("low"),t.removeClass("high mute")):(this.muted=!0,t.addClass("mute"),t.removeClass("high low"))},bindings:{".grandparent-title":{modelAttribute:"item",autohide:!0,formatter:function(e){var t=e.get("originalTitle")||e.get("grandparentTitle");return t?t:(e.channel?t=e.channel.get("title"):e.parent&&(t=e.parent.get("parentTitle")||e.parent.get("title")),t)}},".item-title":{modelAttribute:"item",autohide:!0,formatter:function(e){return e.get("title")
}},".previous-btn":{modelAttribute:"canSkipPrevious",manual:!0,formatter:function(e,t){t.toggleClass("disabled",!e)}},".play-btn":{modelAttribute:"paused",modelListeners:["paused","canPlayPause"],manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.model.get("canPlayPause")),e}},".pause-btn":{modelAttribute:"paused",modelListeners:["paused","canPlayPause"],manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.model.get("canPlayPause")),!e
}},".stop-btn":{modelAttribute:"canStop",manual:!0,autohide:!0},".next-btn":{modelAttribute:"canSkipNext",manual:!0,formatter:function(e,t){t.toggleClass("disabled",!e)}},".seek-bar-container":{modelAttribute:"showSeekBar",manual:!0,autohide:!0},".player-position":{modelAttribute:"position",formatter:function(e){return i.formatDuration(e)}},".player-duration":{modelAttribute:"duration",formatter:function(e){return e?i.formatDuration(e):!1}},".volume-btn":{modelAttribute:"canSetVolume",manual:!0,autohide:!0,formatter:function(e){return this.$el.toggleClass("show-volume",e),e
}},".maximize-btn":{modelAttribute:"showMaximize",manual:!0,autohide:!0}},onRender:function(){var e=this.model.get("item");this.updatePosterTitle(e),this.image.setElement(this.ui.poster),"track"===e.get("type")&&e.isLibraryItem()&&this.rating.show(new s({model:e})),this.dropdown.append(new o({model:e})),this.seekBar.append(this.seekBarView),this.volume.show(this.volumeSlider),this.playQueue.show(this.playQueueDropdown),this.updateVolumeBtn(this.model.get("volume"))},onClose:function(){this.image.close()
},onItemChange:function(e,t){this.image.src=null,this.image.setModel(t),this.image.render(),this.updatePosterTitle(t),"track"===t.get("type")&&t.isLibraryItem()&&this.rating.show(new s({model:t})),this.dropdown.append(new o({model:t}))},onVolumeChange:function(e,t){this.volumeSlider.displayValue(t),this.updateVolumeBtn(t)},onPosterLoad:function(e){this.trigger("load:poster",e)},onSeekBarValueChange:function(e){this.trigger("change:position",e)},onSeekBarHover:function(e){e?(this.ui.scrubPreview.removeClass("hidden"),this.ui.scrubPreview.text(i.formatDuration(e.time)),this.ui.scrubPreview.css("left",e.position-this.ui.scrubPreview.width()/2+"px")):this.ui.scrubPreview.addClass("hidden")
},onVolumeSliderValueChange:function(e){this.trigger("change:volume",e)},onVolumeClick:function(e){e.preventDefault(),this.muted?(this.mutedVolume>0?this.trigger("change:volume",this.mutedVolume):this.trigger("change:volume",100),this.muted=!1,this.mutedVolume=0):(this.muted=!0,this.mutedVolume=this.model.get("volume"),this.trigger("change:volume",0))},onSkip:function(e,t){this.trigger("skip",t)},onRemove:function(e,t){this.trigger("remove",t)},onMove:function(e,t){this.trigger("move",e,t)}});return c
}),define("plex/desktop/views/players/VideoMiniPlayerView",["hb!templates/desktop/players/VideoMiniPlayerView.tpl","plex/base/models/player/UpNextCollection","plex/desktop/views/players/MiniPlayerView","plex/desktop/views/players/controls/MiniPlayerControlsView"],function(e,t,i,n){"use strict";var s=i.extend({template:e,initialize:function(){i.prototype.initialize.apply(this,arguments),this.controlsView=new n({model:this.playerModel,upNextCollection:new t(null,{parent:this.playerModel})}),this.addListeners()
},startPlayback:function(e){e||(e={}),this.controller.load({model:this.playerModel,offset:e.offset,autoplay:e.autoplay,silent:this.isNowPlaying(),mediaElement:e.mediaElement})},continuePlayback:function(){},onRender:function(){this.controls.append(this.controlsView,this.$el),i.prototype.onRender.apply(this,arguments)},onPrimaryPlayerChange:function(){i.prototype.onPrimaryPlayerChange.apply(this,arguments),this.maximize()}});return s}),define("hb!templates/desktop/players/MusicMiniPlayerView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("plex/desktop/views/players/MusicMiniPlayerView",["hb!templates/desktop/players/MusicMiniPlayerView.tpl","plex/base/models/appModel","plex/base/models/player/UpNextCollection","plex/desktop/views/players/MiniPlayerView","plex/desktop/views/players/controls/MiniPlayerControlsView"],function(e,t,i,n,s){"use strict";var a=n.extend({template:e,volumeSettingsKey:"musicPlayerVolume",initialize:function(){n.prototype.initialize.apply(this,arguments),this.controlsView=new s({model:this.playerModel,upNextCollection:new i(null,{parent:this.playerModel})}),this.addListeners()
},startPlayback:function(e){e||(e={}),this.controller.load({model:this.playerModel,offset:e.offset,autoplay:e.autoplay,fallbackServer:t.get("primaryServer"),silent:this.isNowPlaying()})},getNavigationKey:function(){var e=this.model.get("parentKey");return e?e:this.model.parent&&this.model.parent.get("key")},onRender:function(){this.controls.append(this.controlsView,this.$el),n.prototype.onRender.apply(this,arguments)}});return a}),define("hb!templates/desktop/players/PhotoPlayerView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<a class="player-close-btn btn-gray" href="#">\n  <i class="glyphicon remove-2"></i>\n</a>\n\n<div class="loading loading-inline"></div>\n\n<div class="photo-player-controls">\n  <a class="previous-btn btn-gray hidden" href="#">\n    <i class="previous-icon glyphicon chevron-left"></i>\n  </a>\n\n  <a class="next-btn btn-gray hidden" href="#">\n    <i class="next-icon glyphicon chevron-right"></i>\n  </a>\n</div>\n'
})}),define("hb!templates/desktop/players/PhotoPlayerDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=this,u=i.helperMissing,h=this.escapeExpression;return c+='<div class="photo-details-container">\n  <div class="photo-details">\n    <div class="photo-loading-overlay"></div>\n\n    <div class="photo-details-info">\n      <div class="media-actions">\n        <button class="play-btn media-action-btn btn-link ',o=i.unless.call(t,(r=t&&t.player,null==r||r===!1?r:r.paused),{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+=" ",o=i.unless.call(t,(r=t&&t.player,null==r||r===!1?r:r.canPlayPause),{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='"><i class="glyphicon play"></i></button>\n        <button class="pause-btn media-action-btn btn-link ',o=i["if"].call(t,(r=t&&t.player,null==r||r===!1?r:r.paused),{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+=" ",o=i.unless.call(t,(r=t&&t.player,null==r||r===!1?r:r.canPlayPause),{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='"><i class="glyphicon pause"></i></button>\n        <button class="edit-btn media-action-btn btn-link hidden"><i class="glyphicon pencil"></i></button>\n        <button class="more-btn media-action-btn btn-link hidden"><i class="glyphicon more"></i></button>\n        <button class="minimize-btn media-action-btn btn-link hidden"><i class="glyphicon chevron-down"></i></button>\n        <button class="enter-fullscreen-btn media-action-btn btn-link hidden"><i class="glyphicon resize-full"></i></button>\n        <button class="exit-fullscreen-btn media-action-btn btn-link hidden"><i class="glyphicon resize-small"></i></button>\n\n        <div class="photo-actions-dropdown media-actions-dropdown dropup pull-right">\n          <div class="dropdown-toggle" data-toggle="dropdown"></div>\n        </div>\n      </div>\n\n      <h4 class="photo-title"></h4>\n      <span class="photo-subtitle">',l={hash:{},data:s},c+=h((r=i.t||t&&t.t,r?r.call(t,"{1} of {2}",t&&t.index,t&&t.total,l):u.call(t,"t","{1} of {2}",t&&t.index,t&&t.total,l)))+'</span>\n      <div class="photo-summary"></div>\n    </div>\n  </div>\n</div>\n'
})}),define("hb!templates/desktop/modals/EditMetadataModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn general-btn" data-pane="general" href="#">\n            <i class="modal-nav-icon glyphicon align-center"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"General",s):g.call(e,"t","General",s)))+"\n          </a></li>\n          "}function r(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn tags-btn" data-pane="tags" href="#">\n            <i class="modal-nav-icon glyphicon tags"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Tags",s):g.call(e,"t","Tags",s)))+"\n          </a></li>\n          "
}function o(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn sharing-btn" data-pane="sharing" href="#">\n            <i class="modal-nav-icon glyphicon parents"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Sharing",s):g.call(e,"t","Sharing",s)))+"\n          </a></li>\n          "}function l(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn poster-btn" data-pane="poster" href="#">\n            <i class="modal-nav-icon glyphicon picture"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Poster",s):g.call(e,"t","Poster",s)))+"\n          </a></li>\n          "
}function c(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn banner-btn" data-pane="banner" href="#">\n            <i class="modal-nav-icon glyphicon picture"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Banner",s):g.call(e,"t","Banner",s)))+"\n          </a></li>\n          "}function d(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn art-btn" data-pane="art" href="#">\n            <i class="modal-nav-icon glyphicon picture"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Background",s):g.call(e,"t","Background",s)))+"\n          </a></li>\n          "
}function u(e,t){var n,s,a="";return a+='\n          <li><a class="btn-gray change-pane-btn info-btn" data-pane="info" href="#">\n            <i class="modal-nav-icon glyphicon circle-info"></i>\n            ',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Info",s):g.call(e,"t","Info",s)))+"\n          </a></li>\n          "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var h,p,m,f="",g=i.helperMissing,v=this.escapeExpression,y="function",b=this;return f+='<div class="modal-dialog">\n\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon pencil"></i> ',(h=i.paneTitle)?h=h.call(t,{hash:{},data:s}):(h=t&&t.paneTitle,h=typeof h===y?h.call(t,{hash:{},data:s}):h),(h||0===h)&&(f+=h),f+='</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll modal-body-with-panes">\n      <div class="modal-nav-pane dark-scrollbar hidden">\n        <ul class="list modal-nav-list">\n          ',p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.general),{hash:{},inverse:b.noop,fn:b.program(1,a,s),data:s}),(p||0===p)&&(f+=p),f+="\n          ",p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.tags),{hash:{},inverse:b.noop,fn:b.program(3,r,s),data:s}),(p||0===p)&&(f+=p),f+="\n          ",p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.sharing),{hash:{},inverse:b.noop,fn:b.program(5,o,s),data:s}),(p||0===p)&&(f+=p),f+="\n          ",p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.poster),{hash:{},inverse:b.noop,fn:b.program(7,l,s),data:s}),(p||0===p)&&(f+=p),f+="\n          ",p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.banner),{hash:{},inverse:b.noop,fn:b.program(9,c,s),data:s}),(p||0===p)&&(f+=p),f+="\n          ",p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.art),{hash:{},inverse:b.noop,fn:b.program(11,d,s),data:s}),(p||0===p)&&(f+=p),f+="\n          ",p=i["if"].call(t,(h=t&&t.panes,null==h||h===!1?h:h.info),{hash:{},inverse:b.noop,fn:b.program(13,u,s),data:s}),(p||0===p)&&(f+=p),f+='\n        </ul>\n      </div>\n\n      <div class="modal-body-pane pane-region dark-scrollbar">\n        <div class="loading loading-inline"></div>\n      </div>\n    </div>\n\n    <div class="modal-footer">\n      <span class="form-message"></span>\n\n      <button type="button" class="cancel-btn btn btn-default" data-dismiss="modal">',m={hash:{},data:s},f+=v((h=i.t||t&&t.t,h?h.call(t,"Cancel",m):g.call(t,"t","Cancel",m)))+'</button>\n      <button type="button" class="save-btn btn btn-primary btn-loading">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',m={hash:{},data:s},f+=v((h=i.t||t&&t.t,h?h.call(t,"Save Changes",m):g.call(t,"t","Save Changes",m)))+"</span>\n      </button>\n    </div>\n  </div>\n\n</div>\n"
})}),define("plex/base/models/library/MultiMetadataModel",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser","plex/base/utils/formatters/stringUtil","plex/base/utils/types/mediaTypes","plex/base/models/library/MetadataModel"],function(e,t,i,n,s,a,r,o){"use strict";var l={album:{parentRatingKey:"artist.id",parentTitle:"artist.title"},track:{parentRatingKey:"album.id",parentTitle:"album.title",grandparentRatingKey:"artist.id",grandparentTitle:"artist.title"}},c=o.extend({cacheKey:null,omittedSaveAttrs:o.prototype.omittedSaveAttrs.concat(["key"]),initialize:function(t,i){var n=i.mediaActions;
this.mediaActions=n;var s=e.clone(n.getActionTargets());this.defaults=e.extend({type:s[0].get("type")},s[0].defaults),this.set(this.defaults),this.set(t),this.section=this.getSection(),this.server=s[0].server,this.channel=s[0].channel,this.parent=s[0].parent,this.models=s,this.set("aggregateTitle",this.mediaActions.getActionTargetsTitle())},sync:function(e,t,i){return i.url=i.url||this.commonUrl(),o.prototype.sync.call(this,e,t,i)},save:function(t){var i=o.prototype.save.apply(this,arguments);return i=i.done(e.bind(function(){e.invoke(this.models,"set",t)
},this))},firstItemUrl:function(){return e.result(this.models[0],"url")},commonUrl:function(){return this.sectionUrl()+"/common?"+this.mediaActionsParams()},saveUrl:function(){return this.sectionUrl()+"/all?"+this.mediaActionsParams()},sectionUrl:function(){var e=this.getSection();return e.url()},mediaActionsParams:function(){var t=this.mediaActions.getActionTargets(),i=t[0],n=r.getMediaTypeByString(i.get("type")),s=e.pluck(t,"id");return"type="+n.id+"&id="+s.join(",")},getSection:function(){var e=this.mediaActions.getActionTargets(),t=e[0];
return t.server.getSectionForItem(t)},isNew:function(){return!1},getQueryAttr:function(e){var t=this.get("type"),i=l[t];return i?i[e]||e:e},getQueryAttrSibling:function(e){var t=this.getQueryAttr(e).match(/(^.*\.)(.*$)/);return t?t[1]+("id"===t[2]?"title":"id"):e},changedAttributes:function(){var t=o.prototype.changedAttributes.apply(this,arguments);t=e.reduce(t,function(t,i,n){var s=n.match(/^manualChange\.(.*)/);if(s){if(!i)return t;var a=this.getQueryAttr(s[1]);return e.has(t,a)||(t[a]=this.get(s[1])),t
}return-1!==this.omittedSaveAttrs.indexOf(n)?t:(t[n]=i,t)},{},this);var i=l[this.get("type")];if(i){var n;e.each(i,function(i,s){e.has(t,s)&&(t[s]&&(t[i]=t[s]),delete t[s],n=!0)},this),n&&e.each(i,function(i,n){var s=this.getQueryAttrSibling(i);if(e.has(t,i))delete t[s];else{if(e.has(t,s))return;var a=this.get(n);a&&(t[i]=a)}},this)}return t},getSaveParams:function(t){var i={};return e.reduce(t.Field,function(e,t){return e[t.name+".locked"]=t.locked,e},i),delete t.Field,e.each(this.tagAttrs,function(n){if(n in t){for(var s=a.lowerCaseFirstLetter(n),r=e.pluck(this.get(n),"tag"),o=e.pluck(t[n],"tag"),l=Math.max(r.length,o.length),c=0;l>c;c++)void 0!==o[c]&&(i[s+"["+c+"].tag.tag"]=o[c]);
var d=e.filter(r,function(e){return-1===o.indexOf(e)});d.length>0&&(i[s+"[].tag.tag-"]=e.map(d,encodeURIComponent).join(",")),delete t[n]}},this),e.reduce(t,function(e,t,i){return e[i+".value"]=t,e},i,this),i},convert:function(t){var i=e.isObject(t)?t:s.parseXML(t);return o.prototype.convert.call(this,e.omit(i.Common,"type"))},parse:function(t){var n=this.convert(t),s=(n.mixedFields||"").split(",");return e.each(s,function(e){e&&(n[e+"Placeholder"]=i("MIXED"))}),n},clone:function(){return new c(this.attributes,{mediaActions:this.mediaActions,section:this.getSection()})
},singleMetadataModel:function(){var e=this.mediaActions.getActionTargets();return 1===e.length?e[0]:void 0},isSingleMetadataModel:function(){return!!this.singleMetadataModel()}});return c}),define("hb!templates/desktop/editmetadata/EditMetadataAlbumGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <div class="row">\n    <div class="col-md-12 selectize">\n      ',s={hash:{label:"Artist",name:"parentTitle",placeholder:(n=e&&e.item,null==n||n===!1?n:n.parentTitlePlaceholder),ratingKey:(n=e&&e.item,null==n||n===!1?n:n.parentRatingKey),title:(n=e&&e.item,null==n||n===!1?n:n.parentTitle)},data:t},a+=d((n=i.partial||e&&e.partial,n?n.call(e,"autocompleteTextInput",s):c.call(e,"partial","autocompleteTextInput",s)))+"\n    </div>\n  </div>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;return l+='<form class="edit-metadata-form">\n\n',r=i["if"].call(t,t&&t.canReparent,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',o={hash:{label:"Album",name:"title",value:(r=t&&t.item,null==r||r===!1?r:r.title),placeholder:(r=t&&t.item,null==r||r===!1?r:r.titlePlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.title),ratingKey:(r=t&&t.item,null==r||r===!1?r:r.ratingKey),scopeToAttr:"parentRatingKey",scopeToParam:"artist.id"},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',o={hash:{label:"Sort Album",name:"titleSort",value:(r=t&&t.item,null==r||r===!1?r:r.titleSort),placeholder:(r=t&&t.item,null==r||r===!1?r:r.titleSortPlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.titleSort),ratingKey:(r=t&&t.item,null==r||r===!1?r:r.ratingKey)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-3">\n    <label>',o={hash:{},data:s},l+=d((r=i.t||t&&t.t,r?r.call(t,"Rating",o):c.call(t,"t","Rating",o)))+'</label>\n    <div class="rating-region"></div>\n  </div>\n\n  <div class="col-md-4">\n    ',o={hash:{label:"Year",name:"year",value:(r=t&&t.item,null==r||r===!1?r:r.year),placeholder:(r=t&&t.item,null==r||r===!1?r:r.yearPlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.year),ratingKey:(r=t&&t.item,null==r||r===!1?r:r.ratingKey)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+'\n  </div>\n\n  <div class="col-md-5">\n    ',o={hash:{label:"Originally Available",name:"originallyAvailableAt",value:(r=t&&t.item,null==r||r===!1?r:r.originallyAvailableAt),placeholder:(r=t&&t.item,null==r||r===!1?r:r.originallyAvailableAtPlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.originallyAvailableAt)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',o={hash:{label:"Record Label",name:"studio",value:(r=t&&t.item,null==r||r===!1?r:r.studio),placeholder:(r=t&&t.item,null==r||r===!1?r:r.studioPlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.studio),ratingKey:(r=t&&t.item,null==r||r===!1?r:r.ratingKey)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',o={hash:{label:"Review",name:"summary",value:(r=t&&t.item,null==r||r===!1?r:r.summary),placeholder:(r=t&&t.item,null==r||r===!1?r:r.summaryPlaceholder),type:"textarea",rows:"5",locked:(r=t&&t.locked,null==r||r===!1?r:r.summary),ratingKey:(r=t&&t.item,null==r||r===!1?r:r.ratingKey)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataArtistGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Artist",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.title),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Sort Artist",name:"titleSort",value:(a=t&&t.item,null==a||a===!1?a:a.titleSort),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titleSortPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.titleSort),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Biography",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataEpisodeGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Title",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.title)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Sort Title",name:"titleSort",value:(a=t&&t.item,null==a||a===!1?a:a.titleSort),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titleSortPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.titleSort)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-4">\n    ',r={hash:{label:"Rating",name:"rating",value:(a=t&&t.item,null==a||a===!1?a:a.rating),placeholder:(a=t&&t.item,null==a||a===!1?a:a.ratingPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.rating)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableNumericInput",r):l.call(t,"partial","lockableNumericInput",r)))+'\n  </div>\n\n  <div class="col-md-4">\n    ',r={hash:{label:"Content Rating",name:"contentRating",value:(a=t&&t.item,null==a||a===!1?a:a.contentRating),placeholder:(a=t&&t.item,null==a||a===!1?a:a.contentRatingPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.contentRating)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-4">\n    ',r={hash:{label:"Originally Available",name:"originallyAvailableAt",value:(a=t&&t.item,null==a||a===!1?a:a.originallyAvailableAt),placeholder:(a=t&&t.item,null==a||a===!1?a:a.originallyAvailableAtPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.originallyAvailableAt)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataMovieGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Title",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.title),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Sort Title",name:"titleSort",value:(a=t&&t.item,null==a||a===!1?a:a.titleSort),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titleSortPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.titleSort),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Original Title",name:"originalTitle",value:(a=t&&t.item,null==a||a===!1?a:a.originalTitle),placeholder:(a=t&&t.item,null==a||a===!1?a:a.originalTitlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.originalTitle),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-4">\n    ',r={hash:{label:"Year",name:"year",value:(a=t&&t.item,null==a||a===!1?a:a.year),placeholder:(a=t&&t.item,null==a||a===!1?a:a.yearPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.year)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-4">\n    ',r={hash:{label:"Rating",name:"rating",value:(a=t&&t.item,null==a||a===!1?a:a.rating),placeholder:(a=t&&t.item,null==a||a===!1?a:a.ratingPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.rating)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableNumericInput",r):l.call(t,"partial","lockableNumericInput",r)))+'\n  </div>\n\n  <div class="col-md-4 selectize">\n    ',r={hash:{label:"Content Rating",name:"contentRating",value:(a=t&&t.item,null==a||a===!1?a:a.contentRating),placeholder:(a=t&&t.item,null==a||a===!1?a:a.contentRatingPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.contentRating),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-6 selectize">\n    ',r={hash:{label:"Studio",name:"studio",value:(a=t&&t.item,null==a||a===!1?a:a.studio),placeholder:(a=t&&t.item,null==a||a===!1?a:a.studioPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.studio),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-6">\n    ',r={hash:{label:"Originally Available",name:"originallyAvailableAt",value:(a=t&&t.item,null==a||a===!1?a:a.originallyAvailableAt),placeholder:(a=t&&t.item,null==a||a===!1?a:a.originallyAvailableAtPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.originallyAvailableAt)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Tagline",name:"tagline",value:(a=t&&t.item,null==a||a===!1?a:a.tagline),placeholder:(a=t&&t.item,null==a||a===!1?a:a.taglinePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.tagline)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataPhotoAlbumGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-6">\n    ',r={hash:{label:"Title",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.title)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-6">\n    ',r={hash:{label:"Sort Title",name:"titleSort",value:(a=t&&t.item,null==a||a===!1?a:a.titleSort),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titleSortPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.titleSort)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataPhotoGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-9">\n    ',r={hash:{label:"Title",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.title)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-3">\n    ',r={hash:{label:"Year",name:"year",value:(a=t&&t.item,null==a||a===!1?a:a.year),placeholder:(a=t&&t.item,null==a||a===!1?a:a.yearPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.year)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Sort Title",name:"titleSort",value:(a=t&&t.item,null==a||a===!1?a:a.titleSort),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titleSortPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.titleSort)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataSeasonGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataShowGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Title",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.title),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Sort Title",name:"titleSort",value:(a=t&&t.item,null==a||a===!1?a:a.titleSort),placeholder:(a=t&&t.item,null==a||a===!1?a:a.titleSortPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.titleSort),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-4">\n    ',r={hash:{label:"Year",name:"year",value:(a=t&&t.item,null==a||a===!1?a:a.year),placeholder:(a=t&&t.item,null==a||a===!1?a:a.yearPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.year)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-4">\n    ',r={hash:{label:"Rating",name:"rating",value:(a=t&&t.item,null==a||a===!1?a:a.rating),placeholder:(a=t&&t.item,null==a||a===!1?a:a.ratingPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.rating)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableNumericInput",r):l.call(t,"partial","lockableNumericInput",r)))+'\n  </div>\n\n  <div class="col-md-4 selectize">\n    ',r={hash:{label:"Content Rating",name:"contentRating",value:(a=t&&t.item,null==a||a===!1?a:a.contentRating),placeholder:(a=t&&t.item,null==a||a===!1?a:a.contentRatingPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.contentRating),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',r={hash:{label:"Original Title",name:"originalTitle",value:(a=t&&t.item,null==a||a===!1?a:a.originalTitle),placeholder:(a=t&&t.item,null==a||a===!1?a:a.originalTitlePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.originalTitle),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-6 selectize">\n    ',r={hash:{label:"Studio",name:"studio",value:(a=t&&t.item,null==a||a===!1?a:a.studio),placeholder:(a=t&&t.item,null==a||a===!1?a:a.studioPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.studio),ratingKey:(a=t&&t.item,null==a||a===!1?a:a.ratingKey)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n\n  <div class="col-md-6">\n    ',r={hash:{label:"Originally Available",name:"originallyAvailableAt",value:(a=t&&t.item,null==a||a===!1?a:a.originallyAvailableAt),placeholder:(a=t&&t.item,null==a||a===!1?a:a.originallyAvailableAtPlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.originallyAvailableAt)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Tagline",name:"tagline",value:(a=t&&t.item,null==a||a===!1?a:a.tagline),placeholder:(a=t&&t.item,null==a||a===!1?a:a.taglinePlaceholder),locked:(a=t&&t.locked,null==a||a===!1?a:a.tagline)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5",locked:(a=t&&t.locked,null==a||a===!1?a:a.summary)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTextInput",r):l.call(t,"partial","lockableTextInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataTrackGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <div class="row">\n    <div class="col-md-12 selectize">\n      ',s={hash:{label:"Artist",name:"grandparentTitle",placeholder:(n=e&&e.item,null==n||n===!1?n:n.grandparentTitlePlaceholder),ratingKey:(n=e&&e.item,null==n||n===!1?n:n.grandparentRatingKey),title:(n=e&&e.item,null==n||n===!1?n:n.grandparentTitle)},data:t},a+=d((n=i.partial||e&&e.partial,n?n.call(e,"autocompleteTextInput",s):c.call(e,"partial","autocompleteTextInput",s)))+'\n    </div>\n  </div>\n\n  <div class="row">\n    <div class="col-md-12 selectize">\n      ',s={hash:{label:"Album",name:"parentTitle",placeholder:(n=e&&e.item,null==n||n===!1?n:n.parentTitlePlaceholder),ratingKey:(n=e&&e.item,null==n||n===!1?n:n.parentRatingKey),title:(n=e&&e.item,null==n||n===!1?n:n.parentTitle),scopeToAttr:"grandparentRatingKey",scopeToParam:"artist.id"},data:t},a+=d((n=i.partial||e&&e.partial,n?n.call(e,"autocompleteTextInput",s):c.call(e,"partial","autocompleteTextInput",s)))+"\n    </div>\n  </div>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;return l+='<form class="edit-metadata-form">\n\n',r=i["if"].call(t,t&&t.canReparent,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='\n\n<div class="row">\n  <div class="col-md-12">\n    ',o={hash:{label:"Title",name:"title",value:(r=t&&t.item,null==r||r===!1?r:r.title),placeholder:(r=t&&t.item,null==r||r===!1?r:r.titlePlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.title)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-4">\n    <label>',o={hash:{},data:s},l+=d((r=i.t||t&&t.t,r?r.call(t,"Rating",o):c.call(t,"t","Rating",o)))+'</label>\n    <div class="rating-region"></div>\n </div>\n\n  <div class="col-md-4">\n    ',o={hash:{label:"Track",name:"index",value:(r=t&&t.item,null==r||r===!1?r:r.index),placeholder:(r=t&&t.item,null==r||r===!1?r:r.indexPlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.index),disabled:t&&t.disableIndices},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableNumericInput",o):c.call(t,"partial","lockableNumericInput",o)))+'\n  </div>\n\n  <div class="col-md-4">\n    ',o={hash:{label:"Disc",name:"parentIndex",value:(r=t&&t.item,null==r||r===!1?r:r.parentIndex),placeholder:(r=t&&t.item,null==r||r===!1?r:r.parentIndexPlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.parentIndex),disabled:t&&t.disableIndices},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableNumericInput",o):c.call(t,"partial","lockableNumericInput",o)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12 selectize">\n    ',o={hash:{label:"Track Artist",name:"originalTitle",value:(r=t&&t.item,null==r||r===!1?r:r.originalTitle),placeholder:(r=t&&t.item,null==r||r===!1?r:r.originalTitlePlaceholder),locked:(r=t&&t.locked,null==r||r===!1?r:r.originalTitle),ratingKey:(r=t&&t.item,null==r||r===!1?r:r.ratingKey)},data:s},l+=d((r=i.partial||t&&t.partial,r?r.call(t,"lockableTextInput",o):c.call(t,"partial","lockableTextInput",o)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataPlaylistGeneralView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Title",name:"title",value:(a=t&&t.item,null==a||a===!1?a:a.title)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"textInput",r):l.call(t,"partial","textInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Summary",name:"summary",value:(a=t&&t.item,null==a||a===!1?a:a.summary),placeholder:(a=t&&t.item,null==a||a===!1?a:a.summaryPlaceholder),type:"textarea",rows:"5"},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"textInput",r):l.call(t,"partial","textInput",r)))+"\n  </div>\n</div>\n\n</form>"
})}),define("plex/desktop/views/editmetadata/EditMetadataBaseView",["underscore","jquery","marionette"],function(e,t,i){"use strict";var n=i.Layout.extend({events:{"click .edit-lock-addon":"onLockClick","keyup .lockable-field:not(.selectized)":"onLockableFieldChange","change .lockable-field:not(.selectized)":"onLockableFieldChange"},ui:{form:".edit-metadata-form"},serializeData:function(){var t=this.model.get("Field"),i=e.reduce(t,function(e,t){return e[t.name]=t.locked,e},{});return{item:this.model.toJSON(),locked:i,canReparent:this.canReparent,disableIndices:!this.canReparent}
},flushChanges:function(){},getLockedFieldsArray:function(){var i=this.ui.form,n=e.reduce(this.model.get("Field"),function(e,t){return e[t.name]=t.locked,e},{});return i.find(".edit-lock-addon").each(function(e,i){var s=t(i),a=s.data("field");s.hasClass("locked")?n[a]="1":a in n&&(n[a]="0")}),e.map(n,function(e,t){return{name:t,locked:e}})},onLockClick:function(e){e.preventDefault();var i=t(e.currentTarget);i.hasClass("disabled")||t(e.currentTarget).toggleClass("locked")},onLockableFieldChange:function(e){var i=e instanceof t?e:t(e.currentTarget);
if(!e.force){var n=i.data("original-value");if(void 0===n&&(n=i.attr("value")||i.val()),i.data("original-value",n),i.val()===n)return}i.siblings(".edit-lock-addon").addClass("locked")}});return n}),define("plex/base/models/library/MultiMetadataAutocompleteResultCollection",["underscore","jquery","plex/base/utils/parser","plex/base/utils/types/mediaTypes","plex/base/models/BaseCollection","plex/base/models/library/MetadataCollection"],function(e,t,i,n,s,a){"use strict";function r(e,t,i){var s=/!$/.test(i),a=/\.id$/.test(i);
if(s||a)return e[i]=t,e;var r=i.match(/^(.+)\.(.+)/);return r&&(e.type=n.getMediaTypeByString(r[1]).id,i=r[2]),e[i+".query"]=t,e}var o=a.extend({initialize:function(e,t){return this.query=t.query,this.multiMetadataModel=t.multiMetadataModel,a.prototype.initialize.apply(this,arguments)},url:function(){var i=this.multiMetadataModel,s={type:n.getMediaTypeByString(i.get("type")).id,limit:10};return s=e.reduce(this.query,r,s),i.sectionUrl()+"/autocomplete?"+t.param(s)}});return o}),define("plex/desktop/views/editmetadata/EditMetadataGeneralView",["hb!templates/desktop/editmetadata/EditMetadataAlbumGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataArtistGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataEpisodeGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataMovieGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataPhotoAlbumGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataPhotoGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataSeasonGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataShowGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataTrackGeneralView.tpl","hb!templates/desktop/editmetadata/EditMetadataPlaylistGeneralView.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/types/mediaTypes","plex/desktop/views/editmetadata/EditMetadataBaseView","plex/desktop/views/RatingView","plex/base/models/library/MultiMetadataModel","plex/base/models/library/MultiMetadataAutocompleteResultCollection"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v){"use strict";
function y(e){return d.reduce(e,function(e,t){return e[t]=!0,e},{})}var b={movie:n,show:o,season:r,episode:i,artist:t,album:e,track:l,photoAlbum:s,photo:a,playlist:c},w=m.extend({regions:{ratingRegion:".rating-region"},ui:d.extend({selectizeInputs:".selectize input[type=text]"},m.prototype.ui),initialize:function(){var e=this.model.get("type");this.template=b[e]||b.movie;var t=p.getMediaTypeByString(e);this.canSelectize=this.model.server.supports("batchEdit")&&t,this.canReparent=this.model.server.supports("batchEdit")
},flushChanges:function(){var e=this.ui.form,t=e.find(".selectize input[tabindex=-1]"),i=y(d.pluck(t,"name")),n=y(d.pluck(e.find("[type=number]"),"name")),s=d(e.serializeArray()).reject(function(e){return i[e.name]},this),a=d.reduce(s,function(e,t){if(n[t.name]){var i=u.trim(t.value);if(i)return e[t.name]=parseFloat(i,10),e;if(!this.model.get(t.name))return e}return e[t.name]=t.value,e},{},this);a.Field=this.getLockedFieldsArray(),d.each(t,function(e){var t=u(e),i=t.data("updateAttr"),n=t.data("altUpdateAttr"),s=t.data("isText"),r=e.selectize.getValue();
if(n)if(s)a[i]=r,a[n]=null;else{var o=e.selectize.options[r];if(o){var l=o[t.data("autocompleteAttr")];a[i]=l,a[n]=r}}else a[i]=r}),this.model.set(a)},markInvalid:function(e){this.$(".form-group").removeClass("has-error"),d(e).each(function(e){var t=this.$('.form-group[data-attr="'+e+'"]');t.addClass("has-error"),t.find(".control-error").text(h("Required"))},this)},onRender:function(){if(this.$(".rating-region").length>0&&this.ratingRegion.show(new f({model:this.model,passive:!0})),this.canSelectize){var e=this;
this.ui.selectizeInputs.each(d.bind(function(t,i){var n=u(i),s=n.attr("name"),a=s.replace(/parentTitle$/,"parentRatingKey");a===s&&(a=null);var r=e.model.getQueryAttr(s),o=e.model.getQueryAttrSibling(s),l=r!==s,c=l?"title":s,p=l?"ratingKey":c,m=this.model.get("type"),f=l?r.match(/(^.*)\./)[1]:"title"===c?m:null,g=n.data("scopeToAttr"),y=n.data("scopeToParam"),b=n.data("ratingKey"),w=!b;b&&(b=b.toString());var x=!l,k={};y&&e.listenTo(e,"reset_selectize:"+y,function(){D.loadedSearches={}});var S,C,P=this.model.get("original.updateValues."+s);
P?(S=P.updateAttr,C=P.altUpdateAttr):(S=this.model.get(s),a&&(C=parseInt(this.model.get(a),10)),this.model.set("original.updateValues."+s,{updateAttr:S,altUpdateAttr:C}));var A=this.model.get("original.general."+s);if(!A){A=[];var _={};_[c]=S,_.ratingKey=b,A=[_],this.model.set("original.general."+s,A)}var I=[this.model.get(a)||this.model.get(s)],T=function(){var e=D.$dropdown_content.children();D.$dropdown.toggleClass("hidden",e.length<=1)},M=function(){d.defer(T)};n.data("autocompleteAttr",c),n.data("updateAttr",s),a&&n.data("altUpdateAttr",a);
var D=n.selectize({options:A,items:I,plugins:["restore_on_focus"],delimiter:null,create:!0,maxItems:1,labelField:c,valueField:p,sortField:c,searchField:[c],selectOnTab:!0,hideSelected:!1,highlight:!1,openOnFocus:!0,selectOnBlur:!0,createOnBlur:!0,persist:!0,addPrecedence:!0,allowEmptyOption:!0,allowCreateEmpty:x,manualInputWidth:!0,loadingClass:"",onFocus:function(){D.preloaded||(D.preloaded=!0,D.onSearchChange(D.$control_input.val()))},createFilter:function(e){k[c]=e;var t=d(this.options).findWhere(k);
return!t},load:function(t,i){if(!t.length)return void i();var n={};if(n[r]=t,g){var s=e.model.get(g);if(!s)return void i();n[y]=s}var a=new v([],{multiMetadataModel:e.model,query:n,server:e.model.server});a.fetch().done(function(e){i(e.map(function(e){return e.attributes})),T()})},render:{option:function(e,t){var i,n=a?e.ratingKey==C:e[c]===S;return i=n?'<small class="autocomplete-annotate pull-right">('+h(f&&!w?"this "+f:"original value")+")</small>":"","<div>"+t(e[c])+i+"</div>"},option_create:function(e,t){return e.input?'<div class="create">'+t(e.input)+"</div>":'<div class="create hidden"></div>'
}},onDropdownClose:function(){D.$dropdown.addClass("hidden")},onDropdownOpen:function(){D.$dropdown.addClass("hidden"),M()},onType:d.bind(function(e){if(D.canCreate(e)){var t=u(D.$dropdown_content[0].childNodes[0]);D.setActiveOption(t)}M(),this.onLockableFieldChange({currentTarget:D.$input,force:!0})},e),onOptionAdd:function(e,t){var i=d.pick(t,c,"ratingKey"),n=d.findWhere(A,i);n||A.splice(A.length,0,t)},onChange:function(t){var i=this.options[t];if(i){if(l){var u=i.ratingKey===i[c];n.data("isText",u),e.model.set("manualChange."+a,!u),e.model.set("manualChange."+s,u)
}else e.model.set("manualChange."+s,!0);e.flushChanges();var h=e.model.changedAttributes();d.has(h,r)||d.has(h,o)?e.trigger("focusSubmit"):d.defer(function(){D.onBlur()}),e.trigger("reset_selectize:"+s),T()}}})[0].selectize;D.$dropdown.addClass("hidden")},this))}}});return w}),define("hb!templates/desktop/editmetadata/EditMetadataMovieTagsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;
return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-6">\n    ',r={hash:{label:"Directors",name:"director",value:(a=t&&t.item,null==a||a===!1?a:a.Director),locked:(a=t&&t.locked,null==a||a===!1?a:a.director)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n\n  <div class="col-md-6">\n    ',r={hash:{label:"Country",name:"country",value:(a=t&&t.item,null==a||a===!1?a:a.Country),locked:(a=t&&t.locked,null==a||a===!1?a:a.country)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Genres",name:"genre",value:(a=t&&t.item,null==a||a===!1?a:a.Genre),locked:(a=t&&t.locked,null==a||a===!1?a:a.genre)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Writers",name:"writer",value:(a=t&&t.item,null==a||a===!1?a:a.Writer),locked:(a=t&&t.locked,null==a||a===!1?a:a.writer)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Collections",name:"collection",value:(a=t&&t.item,null==a||a===!1?a:a.Collection),locked:(a=t&&t.locked,null==a||a===!1?a:a.collection)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataShowTagsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Genres",name:"genre",value:(a=t&&t.item,null==a||a===!1?a:a.Genre),locked:(a=t&&t.locked,null==a||a===!1?a:a.genre)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Collections",name:"collection",value:(a=t&&t.item,null==a||a===!1?a:a.Collection),locked:(a=t&&t.locked,null==a||a===!1?a:a.collection)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataEpisodeTagsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Writers",name:"writer",value:(a=t&&t.item,null==a||a===!1?a:a.Writer),locked:(a=t&&t.locked,null==a||a===!1?a:a.writer)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Directors",name:"director",value:(a=t&&t.item,null==a||a===!1?a:a.Director),locked:(a=t&&t.locked,null==a||a===!1?a:a.director)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataArtistTagsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Genres",name:"genre",locked:(a=t&&t.locked,null==a||a===!1?a:a.genre)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+'\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Collections",name:"collection",locked:(a=t&&t.locked,null==a||a===!1?a:a.collection)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataAlbumTagsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Genres",name:"genre",value:(a=t&&t.item,null==a||a===!1?a:a.Genre),locked:(a=t&&t.locked,null==a||a===!1?a:a.genre)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),define("hb!templates/desktop/editmetadata/EditMetadataTrackTagsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-metadata-form">\n\n<div class="row">\n  <div class="col-md-12">\n    ',r={hash:{label:"Mood",name:"genre",value:(a=t&&t.item,null==a||a===!1?a:a.genre),locked:(a=t&&t.locked,null==a||a===!1?a:a.genre)},data:s},o+=c((a=i.partial||t&&t.partial,a?a.call(t,"lockableTagInput",r):l.call(t,"partial","lockableTagInput",r)))+"\n  </div>\n</div>\n\n</form>\n"
})}),function(e,t){"function"==typeof define&&define.amd?define("sifter",t):"object"==typeof exports?module.exports=t():e.Sifter=t()}(this,function(){var e=function(e,t){this.items=e,this.settings=t||{diacritics:!0}};e.prototype.tokenize=function(e){if(e=n(String(e||"").toLowerCase()),!e||!e.length)return[];var t,i,a,o,l=[],c=e.split(/ +/);for(t=0,i=c.length;i>t;t++){if(a=s(c[t]),this.settings.diacritics)for(o in r)r.hasOwnProperty(o)&&(a=a.replace(new RegExp(o,"g"),r[o]));l.push({string:c[t],regex:new RegExp(a,"i")})
}return l},e.prototype.iterator=function(e,t){var i;i=a(e)?Array.prototype.forEach||function(e){for(var t=0,i=this.length;i>t;t++)e(this[t],t,this)}:function(e){for(var t in this)this.hasOwnProperty(t)&&e(this[t],t,this)},i.apply(e,[t])},e.prototype.getScoreFunction=function(e,t){var i,n,s,a;i=this,e=i.prepareSearch(e,t),s=e.tokens,n=e.options.fields,a=s.length;var r=function(e,t){var i,n;return e?(e=String(e||""),n=e.search(t.regex),-1===n?0:(i=t.string.length/e.length,0===n&&(i+=.5),i)):0},o=function(){var e=n.length;
return e?1===e?function(e,t){return r(t[n[0]],e)}:function(t,i){for(var s=0,a=0;e>s;s++)a+=r(i[n[s]],t);return a/e}:function(){return 0}}();return a?1===a?function(e){return o(s[0],e)}:"and"===e.options.conjunction?function(e){for(var t,i=0,n=0;a>i;i++){if(t=o(s[i],e),0>=t)return 0;n+=t}return n/a}:function(e){for(var t=0,i=0;a>t;t++)i+=o(s[t],e);return i/a}:function(){return 0}},e.prototype.getSortFunction=function(e,i){var n,s,a,r,o,l,c,d,u,h,p;if(a=this,e=a.prepareSearch(e,i),p=!e.query&&i.sort_empty||i.sort,u=function(e,t){return"$score"===e?t.score:a.items[t.id][e]
},o=[],p)for(n=0,s=p.length;s>n;n++)(e.query||"$score"!==p[n].field)&&o.push(p[n]);if(e.query){for(h=!0,n=0,s=o.length;s>n;n++)if("$score"===o[n].field){h=!1;break}h&&o.unshift({field:"$score",direction:"desc"})}else for(n=0,s=o.length;s>n;n++)if("$score"===o[n].field){o.splice(n,1);break}for(d=[],n=0,s=o.length;s>n;n++)d.push("desc"===o[n].direction?-1:1);return l=o.length,l?1===l?(r=o[0].field,c=d[0],function(e,i){return c*t(u(r,e),u(r,i))}):function(e,i){var n,s,a;for(n=0;l>n;n++)if(a=o[n].field,s=d[n]*t(u(a,e),u(a,i)))return s;
return 0}:null},e.prototype.prepareSearch=function(e,t){if("object"==typeof e)return e;t=i({},t);var n=t.fields,s=t.sort,r=t.sort_empty;return n&&!a(n)&&(t.fields=[n]),s&&!a(s)&&(t.sort=[s]),r&&!a(r)&&(t.sort_empty=[r]),{options:t,query:String(e||"").toLowerCase(),tokens:this.tokenize(e),total:0,items:[]}},e.prototype.search=function(e,t){var i,n,s,a,r=this;return n=this.prepareSearch(e,t),t=n.options,e=n.query,a=t.score||r.getScoreFunction(n),e.length?r.iterator(r.items,function(e,s){i=a(e),(t.filter===!1||i>0)&&n.items.push({score:i,id:s})
}):r.iterator(r.items,function(e,t){n.items.push({score:1,id:t})}),s=r.getSortFunction(n,t),s&&n.items.sort(s),n.total=n.items.length,"number"==typeof t.limit&&(n.items=n.items.slice(0,t.limit)),n};var t=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t?1:t>e?-1:0:(e=o(String(e||"")),t=o(String(t||"")),e>t?1:t>e?-1:0)},i=function(e){var t,i,n,s;for(t=1,i=arguments.length;i>t;t++)if(s=arguments[t])for(n in s)s.hasOwnProperty(n)&&(e[n]=s[n]);return e},n=function(e){return(e+"").replace(/^\s+|\s+$|/g,"")
},s=function(e){return(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},a=Array.isArray||$&&$.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},r={a:"[a\xc0\xc1\xc2\xc3\xc4\xc5\xe0\xe1\xe2\xe3\xe4\xe5\u0100\u0101\u0105\u0104]",c:"[c\xc7\xe7\u0107\u0106\u010d\u010c]",d:"[d\u0111\u0110\u010f\u010e]",e:"[e\xc8\xc9\xca\xcb\xe8\xe9\xea\xeb\u011b\u011a\u0112\u0113\u0119\u0118]",i:"[i\xcc\xcd\xce\xcf\xec\xed\xee\xef\u012a\u012b]",l:"[l\u0142\u0141]",n:"[n\xd1\xf1\u0148\u0147\u0144\u0143]",o:"[o\xd2\xd3\xd4\xd5\xd5\xd6\xd8\xf2\xf3\xf4\xf5\xf6\xf8\u014c\u014d]",r:"[r\u0159\u0158]",s:"[s\u0160\u0161\u015b\u015a]",t:"[t\u0165\u0164]",u:"[u\xd9\xda\xdb\xdc\xf9\xfa\xfb\xfc\u016f\u016e\u016a\u016b]",y:"[y\u0178\xff\xfd\xdd]",z:"[z\u017d\u017e\u017c\u017b\u017a\u0179]"},o=function(){var e,t,i,n,s="",a={};
for(i in r)if(r.hasOwnProperty(i))for(n=r[i].substring(2,r[i].length-1),s+=n,e=0,t=n.length;t>e;e++)a[n.charAt(e)]=i;var o=new RegExp("["+s+"]","g");return function(e){return e.replace(o,function(e){return a[e]}).toLowerCase()}}();return e}),function(e,t){"function"==typeof define&&define.amd?define("microplugin",t):"object"==typeof exports?module.exports=t():e.MicroPlugin=t()}(this,function(){var e={};e.mixin=function(e){e.plugins={},e.prototype.initializePlugins=function(e){var i,n,s,a=this,r=[];
if(a.plugins={names:[],settings:{},requested:{},loaded:{}},t.isArray(e))for(i=0,n=e.length;n>i;i++)"string"==typeof e[i]?r.push(e[i]):(a.plugins.settings[e[i].name]=e[i].options,r.push(e[i].name));else if(e)for(s in e)e.hasOwnProperty(s)&&(a.plugins.settings[s]=e[s],r.push(s));for(;r.length;)a.require(r.shift())},e.prototype.loadPlugin=function(t){var i=this,n=i.plugins,s=e.plugins[t];if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');n.requested[t]=!0,n.loaded[t]=s.fn.apply(i,[i.plugins.settings[t]||{}]),n.names.push(t)
},e.prototype.require=function(e){var t=this,i=t.plugins;if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');t.loadPlugin(e)}return i.loaded[e]},e.define=function(t,i){e.plugins[t]={name:t,fn:i}}};var t={isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}};return e}),function(e,t){"function"==typeof define&&define.amd?define("selectize",["jquery","sifter","microplugin"],t):"object"==typeof exports?module.exports=t(require("jquery"),require("sifter"),require("microplugin")):e.Selectize=t(e.jQuery,e.Sifter,e.MicroPlugin)
}(this,function(e,t,i){"use strict";var n=function(e,t){if("string"!=typeof t||t.length){var i="string"==typeof t?new RegExp(t,"i"):t,n=function(e){var t=0;if(3===e.nodeType){var s=e.data.search(i);if(s>=0&&e.data.length>0){var a=e.data.match(i),r=document.createElement("span");r.className="highlight";var o=e.splitText(s),l=(o.splitText(a[0].length),o.cloneNode(!0));r.appendChild(l),o.parentNode.replaceChild(r,o),t=1}}else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName))for(var c=0;c<e.childNodes.length;++c)c+=n(e.childNodes[c]);
return t};return e.each(function(){n(this)})}},s=function(){};s.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){var i=arguments.length;return 0===i?delete this._events:1===i?delete this._events[e]:(this._events=this._events||{},void(e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(t),1)))},trigger:function(e){if(this._events=this._events||{},e in this._events!=!1)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))
}},s.mixin=function(e){for(var t=["on","off","trigger"],i=0;i<t.length;i++)e.prototype[t[i]]=s.prototype[t[i]]};var a=/Mac/.test(navigator.userAgent),r=65,o=13,l=27,c=37,d=38,u=80,h=39,p=40,m=78,f=8,g=46,v=16,y=a?91:17,b=a?18:17,w=9,x=1,k=2,S=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("form").validity,C=function(e){return"undefined"!=typeof e},P=function(e){return"undefined"==typeof e||null===e?null:"boolean"==typeof e?e?"1":"0":e+""},A=function(e){return(e+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")
},_=function(e){return(e+"").replace(/\$/g,"$$$$")},I={};I.before=function(e,t,i){var n=e[t];e[t]=function(){return i.apply(e,arguments),n.apply(e,arguments)}},I.after=function(e,t,i){var n=e[t];e[t]=function(){var t=n.apply(e,arguments);return i.apply(e,arguments),t}};var T=function(e){var t=!1;return function(){t||(t=!0,e.apply(this,arguments))}},M=function(e,t){var i;return function(){var n=this,s=arguments;window.clearTimeout(i),i=window.setTimeout(function(){e.apply(n,s)},t)}},D=function(e,t,i){var n,s=e.trigger,a={};
e.trigger=function(){var i=arguments[0];return-1===t.indexOf(i)?s.apply(e,arguments):void(a[i]=arguments)},i.apply(e,[]),e.trigger=s;for(n in a)a.hasOwnProperty(n)&&s.apply(e,a[n])},E=function(e,t,i,n){e.on(t,i,function(t){for(var i=t.target;i&&i.parentNode!==e[0];)i=i.parentNode;return t.currentTarget=i,n.apply(this,[t])})},L=function(e){var t={};if("selectionStart"in e)t.start=e.selectionStart,t.length=e.selectionEnd-t.start;else if(document.selection){e.focus();var i=document.selection.createRange(),n=document.selection.createRange().text.length;
i.moveStart("character",-e.value.length),t.start=i.text.length-n,t.length=n}return t},R=function(e,t,i){var n,s,a={};if(i)for(n=0,s=i.length;s>n;n++)a[i[n]]=e.css(i[n]);else a=e.css();t.css(a)},O=function(t,i){if(!t)return 0;var n=e("<test>").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).text(t).appendTo("body");R(i,n,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]);var s=n.width();return n.remove(),s},N=function(e){var t=null,i=function(i,n){var s,a,r,o,l,c,d,u;
i=i||window.event||{},n=n||{},i.metaKey||i.altKey||(n.force||e.data("grow")!==!1)&&(s=e.val(),i.type&&"keydown"===i.type.toLowerCase()&&(a=i.keyCode,r=a>=97&&122>=a||a>=65&&90>=a||a>=48&&57>=a||32===a,a===g||a===f?(u=L(e[0]),u.length?s=s.substring(0,u.start)+s.substring(u.start+u.length):a===f&&u.start?s=s.substring(0,u.start-1)+s.substring(u.start+1):a===g&&"undefined"!=typeof u.start&&(s=s.substring(0,u.start)+s.substring(u.start+1))):r&&(c=i.shiftKey,d=String.fromCharCode(i.keyCode),d=c?d.toUpperCase():d.toLowerCase(),s+=d)),o=e.attr("placeholder"),!s&&o&&(s=o),l=O(s,e)+4,l!==t&&(t=l,e.width(l),e.triggerHandler("resize")))
};e.on("keydown keyup update blur",i),i()},F=function(i,n){var s,a,r,o,l=this;o=i[0],o.selectize=l;var c=window.getComputedStyle&&window.getComputedStyle(o,null);if(r=c?c.getPropertyValue("direction"):o.currentStyle&&o.currentStyle.direction,r=r||i.parents("[dir]:first").attr("dir")||"",e.extend(l,{order:0,settings:n,$input:i,tabIndex:i.attr("tabindex")||"",tagType:"select"===o.tagName.toLowerCase()?x:k,rtl:/rtl/i.test(r),eventNS:".selectize"+ ++F.count,highlightedValue:null,isOpen:!1,isDisabled:!1,isRequired:i.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===n.loadThrottle?l.onSearchChange:M(l.onSearchChange,n.loadThrottle)}),l.sifter=new t(this.options,{diacritics:n.diacritics}),l.settings.options){for(s=0,a=l.settings.options.length;a>s;s++)l.registerOption(l.settings.options[s]);
delete l.settings.options}if(l.settings.optgroups){for(s=0,a=l.settings.optgroups.length;a>s;s++)l.registerOptionGroup(l.settings.optgroups[s]);delete l.settings.optgroups}l.settings.mode=l.settings.mode||(1===l.settings.maxItems?"single":"multi"),"boolean"!=typeof l.settings.hideSelected&&(l.settings.hideSelected="multi"===l.settings.mode),l.initializePlugins(l.settings.plugins),l.setupCallbacks(),l.setupTemplates(),l.setup()};return s.mixin(F),i.mixin(F),e.extend(F.prototype,{setup:function(){var t,i,n,s,r,o,l,c,d,u=this,h=u.settings,p=u.eventNS,m=e(window),f=e(document),g=u.$input;
if(l=u.settings.mode,c=g.attr("class")||"",t=e("<div>").addClass(h.wrapperClass).addClass(c).addClass(l),i=e("<div>").addClass(h.inputClass).addClass("items").appendTo(t),n=e('<input type="text" autocomplete="off" />').appendTo(i).attr("tabindex",g.is(":disabled")?"-1":u.tabIndex),o=e(h.dropdownParent||t),s=e("<div>").addClass(h.dropdownClass).addClass(l).hide().appendTo(o),r=e("<div>").addClass(h.dropdownContentClass).appendTo(s),u.settings.copyClassesToDropdown&&s.addClass(c),t.css({width:g[0].style.width}),u.plugins.names.length&&(d="plugin-"+u.plugins.names.join(" plugin-"),t.addClass(d),s.addClass(d)),(null===h.maxItems||h.maxItems>1)&&u.tagType===x&&g.attr("multiple","multiple"),u.settings.placeholder&&n.attr("placeholder",h.placeholder),!u.settings.splitOn&&u.settings.delimiter){var w=u.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");
u.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}g.attr("autocorrect")&&n.attr("autocorrect",g.attr("autocorrect")),g.attr("autocapitalize")&&n.attr("autocapitalize",g.attr("autocapitalize")),u.$wrapper=t,u.$control=i,u.$control_input=n,u.$dropdown=s,u.$dropdown_content=r,s.on("mouseenter","[data-selectable]",function(){return u.onOptionHover.apply(u,arguments)}),s.on("mousedown click","[data-selectable]",function(){return u.onOptionSelect.apply(u,arguments)}),E(i,"mousedown","*:not(input)",function(){return u.onItemSelect.apply(u,arguments)
}),u.settings.manualInputWidth||N(n),i.on({mousedown:function(){return u.onMouseDown.apply(u,arguments)},click:function(){return u.onClick.apply(u,arguments)}}),n.on({mousedown:function(e){e.stopPropagation()},keydown:function(){return u.onKeyDown.apply(u,arguments)},keyup:function(){return u.onKeyUp.apply(u,arguments)},keypress:function(){return u.onKeyPress.apply(u,arguments)},resize:function(){u.positionDropdown.apply(u,[])},blur:function(){return u.onBlur.apply(u,arguments)},focus:function(){return u.ignoreBlur=!1,u.onFocus.apply(u,arguments)
},paste:function(){return u.onPaste.apply(u,arguments)}}),g.parents().last().find('label[for="'+g.attr("id")+'"]').on("click",function(){u.onClick.apply(u,arguments)}),f.on("keydown"+p,function(e){u.isCmdDown=e[a?"metaKey":"ctrlKey"],u.isCtrlDown=e[a?"altKey":"ctrlKey"],u.isShiftDown=e.shiftKey}),f.on("keyup"+p,function(e){e.keyCode===b&&(u.isCtrlDown=!1),e.keyCode===v&&(u.isShiftDown=!1),e.keyCode===y&&(u.isCmdDown=!1)}),f.on("mousedown"+p,function(e){if(u.isFocused){if(e.target===u.$dropdown[0]||e.target.parentNode===u.$dropdown[0])return!1;
u.$control.has(e.target).length||e.target===u.$control[0]||u.blur(e.target)}}),m.on(["scroll"+p,"resize"+p].join(" "),function(){u.isOpen&&u.positionDropdown.apply(u,arguments)}),m.on("mousemove"+p,function(){u.ignoreHover=!1}),this.revertSettings={$children:g.children().detach(),tabindex:g.attr("tabindex")},g.attr("tabindex",-1).hide().after(u.$wrapper),e.isArray(h.items)&&(u.setValue(h.items),delete h.items),S&&g.on("invalid"+p,function(e){e.preventDefault(),u.isInvalid=!0,u.refreshState()}),u.updateOriginalInput(),u.refreshItems(),u.refreshState(),u.updatePlaceholder(),u.isSetup=!0,g.is(":disabled")&&u.disable(),u.on("change",this.onChange),g.data("selectize",u),g.addClass("selectized"),u.trigger("initialize"),h.preload===!0&&u.onSearchChange("")
},setupTemplates:function(){var t=this,i=t.settings.labelField,n=t.settings.optgroupLabelField,s={optgroup:function(e){return'<div class="optgroup">'+e.html+"</div>"},optgroup_header:function(e,t){return'<div class="optgroup-header">'+t(e[n])+"</div>"},option:function(e,t){return'<div class="option">'+t(e[i])+"</div>"},item:function(e,t){return'<div class="item">'+t(e[i])+"</div>"},option_create:function(e,t){return'<div class="create">Add <strong>'+t(e.input)+"</strong>&hellip;</div>"}};t.settings.render=e.extend({},s,t.settings.render)
},setupCallbacks:function(){var e,t,i={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(e in i)i.hasOwnProperty(e)&&(t=this.settings[i[e]],t&&this.on(e,t))
},onClick:function(e){var t=this;t.isFocused||(t.focus(),e.preventDefault())},onMouseDown:function(t){{var i=this,n=t.isDefaultPrevented();e(t.target)}if(i.isFocused){if(t.target!==i.$control_input[0])return"single"===i.settings.mode&&t.target!==i.$control[0]?i.isOpen?i.close():i.open():n||i.setActiveItem(null),!1}else n||window.setTimeout(function(){i.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(t){var i=this;i.isFull()||i.isInputHidden||i.isLocked?t.preventDefault():i.settings.splitOn&&setTimeout(function(){for(var t=e.trim(i.$control_input.val()||"").split(i.settings.splitOn),n=0,s=t.length;s>n;n++)i.createItem(t[n])
},0)},onKeyPress:function(e){if(this.isLocked)return e&&e.preventDefault();var t=String.fromCharCode(e.keyCode||e.which);return this.settings.create&&"multi"===this.settings.mode&&t===this.settings.delimiter?(this.createItem(),e.preventDefault(),!1):void 0},onKeyDown:function(e){var t=(e.target===this.$control_input[0],this);if(t.isLocked)return void(e.keyCode!==w&&e.preventDefault());switch(e.keyCode){case r:if(t.isCmdDown)return void t.selectAll();break;case l:return void(t.isOpen&&(e.preventDefault(),e.stopPropagation(),t.close()));
case m:if(!e.ctrlKey||e.altKey)break;case p:if(!t.isOpen&&t.hasOptions)t.open();else if(t.$activeOption){t.ignoreHover=!0;var i=t.getAdjacentOption(t.$activeOption,1);i.length&&t.setActiveOption(i,!0,!0)}return void e.preventDefault();case u:if(!e.ctrlKey||e.altKey)break;case d:if(t.$activeOption){t.ignoreHover=!0;var n=t.getAdjacentOption(t.$activeOption,-1);n.length&&t.setActiveOption(n,!0,!0)}return void e.preventDefault();case o:return void(t.isOpen&&t.$activeOption&&(t.onOptionSelect({currentTarget:t.$activeOption}),e.preventDefault()));
case c:return void t.advanceSelection(-1,e);case h:return void t.advanceSelection(1,e);case w:return void(t.settings.selectOnTab&&t.isOpen&&t.$activeOption?(t.onOptionSelect({currentTarget:t.$activeOption}),t.settings.allowCreateEmpty&&1===t.settings.maxItems||t.isFull()||e.preventDefault()):t.settings.create&&t.createItem()&&e.preventDefault());case f:return void t.deleteSelection(e,!0);case g:return void t.deleteSelection(e)}return!t.isFull()&&!t.isInputHidden||(a?e.metaKey:e.ctrlKey)?void 0:void e.preventDefault()
},onKeyUp:function(e){var t=this;if(t.isLocked)return e&&e.preventDefault();var i=t.$control_input.val()||"";t.lastValue!==i&&(t.lastValue=i,t.onSearchChange(i),t.refreshOptions(),t.trigger("type",i))},onSearchChange:function(e){var t=this,i=t.settings.load;i&&(t.loadedSearches.hasOwnProperty(e)||(t.loadedSearches[e]=!0,t.load(function(n){i.apply(t,[e,n])})))},onFocus:function(e){var t=this,i=t.isFocused;return t.isDisabled?(t.blur(),e&&e.preventDefault(),!1):void(t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.onSearchChange(""),i||t.trigger("focus"),t.$activeItems.length||(t.showInput(),t.setActiveItem(null),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState()))
},onBlur:function(e,t){var i=this;if(i.isFocused&&(i.isFocused=!1,!i.ignoreFocus))return i.ignoreBlur||document.activeElement!==i.$dropdown_content[0]?void setTimeout(function(){var e=function(){i.close(),i.setTextboxValue(""),i.setActiveItem(null),i.setActiveOption(null),i.setCaret(i.items.length),i.refreshState(),(t||document.body).focus(),i.ignoreFocus=!1,i.trigger("blur")};i.ignoreFocus=!0,i.settings.selectOnBlur&&i.$activeOption&&1===i.$activeOption.not(".create").length?(i.addItem(i.$activeOption.not(".create").data("value")),e()):i.settings.create&&i.settings.createOnBlur?i.createItem(null,!1,e):e()
}):(i.ignoreBlur=!0,void i.onFocus(e))},onOptionHover:function(e){this.ignoreHover||this.setActiveOption(e.currentTarget,!1)},onOptionSelect:function(t){var i,n,s=this;t.preventDefault&&(t.preventDefault(),t.stopPropagation()),n=e(t.currentTarget),n.hasClass("create")?s.createItem(null,function(){s.settings.closeAfterSelect&&s.close()}):(i=n.attr("data-value"),"undefined"!=typeof i&&(s.lastQuery=null,s.setTextboxValue(""),s.addItem(i),s.settings.closeAfterSelect?s.close():!s.settings.hideSelected&&t.type&&/mouse/.test(t.type)&&s.setActiveOption(s.getOption(i))))
},onItemSelect:function(e){var t=this;t.isLocked||"multi"===t.settings.mode&&(e.preventDefault(),t.setActiveItem(e.currentTarget,e))},load:function(e){var t=this,i=t.$wrapper.addClass(t.settings.loadingClass);t.loading++,e.apply(t,[function(e){t.loading=Math.max(t.loading-1,0),e&&e.length&&(t.addOption(e),t.refreshOptions(t.isFocused&&!t.isInputHidden)),t.loading||i.removeClass(t.settings.loadingClass),t.trigger("load",e)}])},setTextboxValue:function(e){var t=this.$control_input,i=t.val()!==e;i&&(t.val(e).triggerHandler("update"),this.lastValue=e)
},getValue:function(){return this.tagType===x&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(e,t){var i=t?[]:["change"];D(this,i,function(){this.clear(t),this.addItems(e,t)})},setActiveItem:function(t,i){var n,s,a,r,o,l,c,d,u=this;if("single"!==u.settings.mode){if(t=e(t),!t.length)return e(u.$activeItems).removeClass("active"),u.$activeItems=[],void(u.isFocused&&u.showInput());if(n=i&&i.type.toLowerCase(),"mousedown"===n&&u.isShiftDown&&u.$activeItems.length){for(d=u.$control.children(".active:last"),r=Array.prototype.indexOf.apply(u.$control[0].childNodes,[d[0]]),o=Array.prototype.indexOf.apply(u.$control[0].childNodes,[t[0]]),r>o&&(c=r,r=o,o=c),s=r;o>=s;s++)l=u.$control[0].childNodes[s],-1===u.$activeItems.indexOf(l)&&(e(l).addClass("active"),u.$activeItems.push(l));
i.preventDefault()}else"mousedown"===n&&u.isCtrlDown||"keydown"===n&&this.isShiftDown?t.hasClass("active")?(a=u.$activeItems.indexOf(t[0]),u.$activeItems.splice(a,1),t.removeClass("active")):u.$activeItems.push(t.addClass("active")[0]):(e(u.$activeItems).removeClass("active"),u.$activeItems=[t.addClass("active")[0]]);u.hideInput(),this.isFocused||u.focus()}},setActiveOption:function(t,i,n){var s,a,r,o,l,c=this;c.$activeOption&&c.$activeOption.removeClass("active"),c.$activeOption=null,t=e(t),t.length&&(c.$activeOption=t.addClass("active"),(i||!C(i))&&(s=c.$dropdown_content.height(),a=c.$activeOption.outerHeight(!0),i=c.$dropdown_content.scrollTop()||0,r=c.$activeOption.offset().top-c.$dropdown_content.offset().top+i,o=r,l=r-s+a,r+a>s+i?c.$dropdown_content.stop().animate({scrollTop:l},n?c.settings.scrollDuration:0):i>r&&c.$dropdown_content.stop().animate({scrollTop:o},n?c.settings.scrollDuration:0)))
},selectAll:function(){var e=this;"single"!==e.settings.mode&&(e.$activeItems=Array.prototype.slice.apply(e.$control.children(":not(input)").addClass("active")),e.$activeItems.length&&(e.hideInput(),e.close()),e.focus())},hideInput:function(){this.setTextboxValue(""),this.$control_input.css({opacity:0}),this.settings.manualInputWidth||this.$control_input.css({position:"absolute",left:this.rtl?1e4:-1e4}),this.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1}),this.settings.manualInputWidth||this.$control_input.css({position:"relative",left:0}),this.isInputHidden=!1
},focus:function(){var e=this;e.isDisabled||(e.ignoreFocus=!0,e.$control_input[0].focus(),window.setTimeout(function(){e.ignoreFocus=!1,e.onFocus()},0))},blur:function(e){this.$control_input[0].blur(),this.onBlur(null,e)},getScoreFunction:function(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())},getSearchOptions:function(){var e=this.settings,t=e.sortField;return"string"==typeof t&&(t=[{field:t}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t}},search:function(t){var i,n,s,a=this,r=a.settings,o=this.getSearchOptions();
if(r.score&&(s=a.settings.score.apply(this,[t]),"function"!=typeof s))throw new Error('Selectize "score" setting must be a function that returns a function');if(t!==a.lastQuery?(a.lastQuery=t,n=a.sifter.search(t,e.extend(o,{score:s})),a.currentResults=n):n=e.extend(!0,{},a.currentResults),r.hideSelected)for(i=n.items.length-1;i>=0;i--)-1!==a.items.indexOf(P(n.items[i].id))&&n.items.splice(i,1);return n},refreshOptions:function(t){var i,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y;"undefined"==typeof t&&(t=!0);var b=this,w=e.trim(b.$control_input.val()),x=b.search(w),k=b.$dropdown_content,S=b.$activeOption&&P(b.$activeOption.attr("data-value"));
for(r=x.items.length,"number"==typeof b.settings.maxOptions&&(r=Math.min(r,b.settings.maxOptions)),o={},l=[],i=0;r>i;i++)for(c=b.options[x.items[i].id],d=b.render("option",c),u=c[b.settings.optgroupField]||"",h=e.isArray(u)?u:[u],s=0,a=h&&h.length;a>s;s++)u=h[s],b.optgroups.hasOwnProperty(u)||(u=""),o.hasOwnProperty(u)||(o[u]=[],l.push(u)),o[u].push(d);for(this.settings.lockOptgroupOrder&&l.sort(function(e,t){var i=b.optgroups[e].$order||0,n=b.optgroups[t].$order||0;return i-n}),p=[],i=0,r=l.length;r>i;i++)u=l[i],b.optgroups.hasOwnProperty(u)&&o[u].length?(m=b.render("optgroup_header",b.optgroups[u])||"",m+=o[u].join(""),p.push(b.render("optgroup",e.extend({},b.optgroups[u],{html:m})))):p.push(o[u].join(""));
if(k.html(p.join("")),b.settings.highlight&&x.query.length&&x.tokens.length)for(i=0,r=x.tokens.length;r>i;i++)n(k,x.tokens[i].regex);if(!b.settings.hideSelected)for(i=0,r=b.items.length;r>i;i++)b.getOption(b.items[i]).addClass("selected");f=b.canCreate(w),f&&(k.prepend(b.render("option_create",{input:w})),y=e(k[0].childNodes[0])),b.hasOptions=x.items.length>0||f,b.hasOptions?(x.items.length>0?(v=S&&b.getOption(S),v&&v.length?g=v:"single"===b.settings.mode&&b.items.length&&(g=b.getOption(b.items[0])),g&&g.length||(g=y&&!b.settings.addPrecedence?b.getAdjacentOption(y,1):k.find("[data-selectable]:first"))):g=y,b.setActiveOption(g),t&&!b.isOpen&&b.open()):(b.setActiveOption(null),t&&b.isOpen&&b.close())
},addOption:function(t){var i,n,s,a=this;if(e.isArray(t))for(i=0,n=t.length;n>i;i++)a.addOption(t[i]);else(s=a.registerOption(t))&&(a.userOptions[s]=!0,a.lastQuery=null,a.trigger("option_add",s,t))},registerOption:function(e){var t=P(e[this.settings.valueField]);return!t||this.options.hasOwnProperty(t)?!1:(e.$order=e.$order||++this.order,this.options[t]=e,t)},registerOptionGroup:function(e){var t=P(e[this.settings.optgroupValueField]);return t?(e.$order=e.$order||++this.order,this.optgroups[t]=e,t):!1
},addOptionGroup:function(e,t){t[this.settings.optgroupValueField]=e,(e=this.registerOptionGroup(t))&&this.trigger("optgroup_add",e,t)},removeOptionGroup:function(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.renderCache={},this.trigger("optgroup_remove",e))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(t,i){var n,s,a,r,o,l,c,d=this;if(t=P(t),a=P(i[d.settings.valueField]),null!==t&&d.options.hasOwnProperty(t)){if("string"!=typeof a)throw new Error("Value must be set in option data");
c=d.options[t].$order,a!==t&&(delete d.options[t],r=d.items.indexOf(t),-1!==r&&d.items.splice(r,1,a)),i.$order=i.$order||c,d.options[a]=i,o=d.renderCache.item,l=d.renderCache.option,o&&(delete o[t],delete o[a]),l&&(delete l[t],delete l[a]),-1!==d.items.indexOf(a)&&(n=d.getItem(t),s=e(d.render("item",i)),n.hasClass("active")&&s.addClass("active"),n.replaceWith(s)),d.lastQuery=null,d.isOpen&&d.refreshOptions(!1)}},removeOption:function(e,t){var i=this;e=P(e);var n=i.renderCache.item,s=i.renderCache.option;
n&&delete n[e],s&&delete s[e],delete i.userOptions[e],delete i.options[e],i.lastQuery=null,i.trigger("option_remove",e),i.removeItem(e,t)},clearOptions:function(){var e=this;e.loadedSearches={},e.userOptions={},e.renderCache={},e.options=e.sifter.items={},e.lastQuery=null,e.trigger("option_clear"),e.clear()},getOption:function(e){return this.getElementWithValue(e,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(t,i){var n=this.$dropdown.find("[data-selectable]"),s=n.index(t)+i;
return s>=0&&s<n.length?n.eq(s):e()},getElementWithValue:function(t,i){if(t=P(t),"undefined"!=typeof t&&null!==t)for(var n=0,s=i.length;s>n;n++)if(i[n].getAttribute("data-value")===t)return e(i[n]);return e()},getItem:function(e){return this.getElementWithValue(e,this.$control.children())},addItems:function(t,i){for(var n=e.isArray(t)?t:[t],s=0,a=n.length;a>s;s++)this.isPending=a-1>s,this.addItem(n[s],i)},addItem:function(t,i){var n=i?[]:["change"];D(this,n,function(){var n,s,a,r,o,l=this,c=l.settings.mode;
return t=P(t),-1!==l.items.indexOf(t)?void("single"===c&&l.close()):void(l.options.hasOwnProperty(t)&&("single"===c&&l.clear(i),"multi"===c&&l.isFull()||(n=e(l.render("item",l.options[t])),o=l.isFull(),l.items.splice(l.caretPos,0,t),l.insertAtCaret(n),(!l.isPending||!o&&l.isFull())&&l.refreshState(),l.isSetup&&(a=l.$dropdown_content.find("[data-selectable]"),l.isPending||(s=l.getOption(t),r=l.getAdjacentOption(s,1).attr("data-value"),l.refreshOptions(l.isFocused&&"single"!==c),r&&l.setActiveOption(l.getOption(r))),!a.length||l.isFull()?l.close():l.positionDropdown(),l.updatePlaceholder(),l.trigger("item_add",t,n),l.updateOriginalInput({silent:i})))))
})},removeItem:function(e,t){var i,n,s,a=this;i="object"==typeof e?e:a.getItem(e),e=P(i.attr("data-value")),n=a.items.indexOf(e),-1!==n&&(i.remove(),i.hasClass("active")&&(s=a.$activeItems.indexOf(i[0]),a.$activeItems.splice(s,1)),a.items.splice(n,1),a.lastQuery=null,!a.settings.persist&&a.userOptions.hasOwnProperty(e)&&a.removeOption(e,t),n<a.caretPos&&a.setCaret(a.caretPos-1),a.refreshState(),a.updatePlaceholder(),a.updateOriginalInput({silent:t}),a.positionDropdown(),a.trigger("item_remove",e,i))
},createItem:function(t,i){var n=this,s=n.caretPos;t=t||e.trim(n.$control_input.val()||"");var a=arguments[arguments.length-1];if("function"!=typeof a&&(a=function(){}),"boolean"!=typeof i&&(i=!0),!n.canCreate(t))return a(),!1;n.lock();var r="function"==typeof n.settings.create?this.settings.create:function(e){var t={};return t[n.settings.labelField]=e,t[n.settings.valueField]=e,t},o=T(function(e){if(n.unlock(),!e||"object"!=typeof e)return a();var t=P(e[n.settings.valueField]);return"string"!=typeof t?a():(n.setTextboxValue(""),n.addOption(e),n.setCaret(s),n.addItem(t),n.refreshOptions(i&&"single"!==n.settings.mode),void a(e))
}),l=r.apply(this,[t,o]);return"undefined"!=typeof l&&o(l),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){var e,t=this;t.isRequired&&(t.items.length&&(t.isInvalid=!1),t.$control_input.prop("required",e)),t.refreshClasses()},refreshClasses:function(){var t=this,i=t.isFull(),n=t.isLocked;t.$wrapper.toggleClass("rtl",t.rtl),t.$control.toggleClass("focus",t.isFocused).toggleClass("disabled",t.isDisabled).toggleClass("required",t.isRequired).toggleClass("invalid",t.isInvalid).toggleClass("locked",n).toggleClass("full",i).toggleClass("not-full",!i).toggleClass("input-active",t.isFocused&&!t.isInputHidden).toggleClass("dropdown-active",t.isOpen).toggleClass("has-options",!e.isEmptyObject(t.options)).toggleClass("has-items",t.items.length>0),t.$control_input.data("grow",!i&&!n)
},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(e){var t,i,n,s,a=this;if(e=e||{},a.tagType===x){for(n=[],t=0,i=a.items.length;i>t;t++)s=a.options[a.items[t]][a.settings.labelField]||"",n.push('<option value="'+A(a.items[t])+'" selected="selected">'+A(s)+"</option>");n.length||this.$input.attr("multiple")||n.push('<option value="" selected="selected"></option>'),a.$input.html(n.join(""))}else a.$input.val(a.getValue()),a.$input.attr("value",a.$input.val());
a.isSetup&&(e.silent||a.trigger("change",a.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var e=this.$control_input;this.items.length?e.removeAttr("placeholder"):e.attr("placeholder",this.settings.placeholder),e.triggerHandler("update",{force:!0})}},open:function(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.focus(),e.isOpen=!0,e.refreshState(),e.$dropdown.css({visibility:"hidden",display:"block"}),e.positionDropdown(),e.$dropdown.css({visibility:"visible"}),e.trigger("dropdown_open",e.$dropdown))
},close:function(){var e=this,t=e.isOpen;"single"===e.settings.mode&&e.items.length&&e.hideInput(),e.isOpen=!1,e.$dropdown.hide(),e.setActiveOption(null),e.refreshState(),t&&e.trigger("dropdown_close",e.$dropdown)},positionDropdown:function(){var e=this.$control,t="body"===this.settings.dropdownParent?e.offset():e.position();t.top+=e.outerHeight(!0),this.$dropdown.css({width:e.outerWidth(),top:t.top,left:t.left})},clear:function(e){var t=this;t.items.length&&(t.$control.children(":not(input)").remove(),t.items=[],t.lastQuery=null,t.setCaret(0),t.setActiveItem(null),t.updatePlaceholder(),t.updateOriginalInput({silent:e}),t.refreshState(),t.showInput(),t.trigger("clear"))
},insertAtCaret:function(t){var i=Math.min(this.caretPos,this.items.length);0===i?this.$control.prepend(t):e(this.$control[0].childNodes[i]).before(t),this.setCaret(i+1)},deleteSelection:function(t,i){var n,s,a,r,o,l,c,d,u,h=this;if(a=i||void 0===i&&t&&t.keyCode===f?-1:1,r=L(h.$control_input[0]),h.$activeOption&&!h.settings.hideSelected&&(c=h.getAdjacentOption(h.$activeOption,-1).attr("data-value")),o=[],h.$activeItems.length){for(u=h.$control.children(".active:"+(a>0?"last":"first")),l=h.$control.children(":not(input)").index(u),a>0&&l++,n=0,s=h.$activeItems.length;s>n;n++)o.push(e(h.$activeItems[n]).attr("data-value"));
t&&(t.preventDefault(),t.stopPropagation())}else(h.isFocused||"single"===h.settings.mode)&&h.items.length&&(0>a&&0===r.start&&0===r.length?o.push(h.items[h.caretPos-1]):a>0&&r.start===h.$control_input.val().length&&o.push(h.items[h.caretPos]));if(!o.length||"function"==typeof h.settings.onDelete&&h.settings.onDelete.apply(h,[o])===!1)return!1;for("undefined"!=typeof l&&h.setCaret(l);o.length;)h.removeItem(o.pop());return h.showInput(),h.positionDropdown(),h.refreshOptions(!0),c&&(d=h.getOption(c),d.length&&h.setActiveOption(d)),!0
},advanceSelection:function(e,t){var i,n,s,a,r,o,l=this;0!==e&&(l.rtl&&(e*=-1),i=e>0?"last":"first",n=L(l.$control_input[0]),l.isFocused&&!l.isInputHidden?(a=l.$control_input.val().length,r=0>e?0===n.start&&0===n.length:n.start===a,r&&!a&&l.advanceCaret(e,t)):(o=l.$control.children(".active:"+i),o.length&&(s=l.$control.children(":not(input)").index(o),l.setActiveItem(null),l.setCaret(e>0?s+1:s))))},advanceCaret:function(e,t){var i,n,s=this;0!==e&&(i=e>0?"next":"prev",s.isShiftDown?(n=s.$control_input[i](),n.length&&(s.hideInput(),s.setActiveItem(n),t&&t.preventDefault())):s.setCaret(s.caretPos+e))
},setCaret:function(t){var i=this;if(t="single"===i.settings.mode?i.items.length:Math.max(0,Math.min(i.items.length,t)),!i.isPending){var n,s,a,r;for(a=i.$control.children(":not(input)"),n=0,s=a.length;s>n;n++)r=e(a[n]).detach(),t>n?i.$control_input.before(r):i.$control.append(r)}i.caretPos=t},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){var e=this;e.$input.prop("disabled",!0),e.$control_input.prop("disabled",!0).prop("tabindex",-1),e.isDisabled=!0,e.lock()
},enable:function(){var e=this;e.$input.prop("disabled",!1),e.$control_input.prop("disabled",!1).prop("tabindex",e.tabIndex),e.isDisabled=!1,e.unlock()},destroy:function(){var t=this,i=t.eventNS,n=t.revertSettings;t.trigger("destroy"),t.off(),t.$wrapper.remove(),t.$dropdown.remove(),t.$input.html("").append(n.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:n.tabindex}).show(),t.$control_input.removeData("grow"),t.$input.removeData("selectize"),e(window).off(i),e(document).off(i),e(document.body).off(i),delete t.$input[0].selectize
},render:function(e,t){var i,n,s="",a=!1,r=this,o=/^[\t \r\n]*<([a-z][a-z0-9\-_]*(?:\:[a-z][a-z0-9\-_]*)?)/i;return("option"===e||"item"===e)&&(i=P(t[r.settings.valueField]),a=!!i),a&&(C(r.renderCache[e])||(r.renderCache[e]={}),r.renderCache[e].hasOwnProperty(i))?r.renderCache[e][i]:(s=r.settings.render[e].apply(this,[t,A]),("option"===e||"option_create"===e)&&(s=s.replace(o,"<$1 data-selectable")),"optgroup"===e&&(n=t[r.settings.optgroupValueField]||"",s=s.replace(o,'<$1 data-group="'+_(A(n))+'"')),("option"===e||"item"===e)&&(s=s.replace(o,'<$1 data-value="'+_(A(i||""))+'"')),a&&(r.renderCache[e][i]=s),s)
},clearCache:function(e){var t=this;"undefined"==typeof e?t.renderCache={}:delete t.renderCache[e]},canCreate:function(e){var t=this;if(!t.settings.create)return!1;var i=t.settings.createFilter;return!(!e.length&&!t.settings.allowCreateEmpty||"function"==typeof i&&!i.apply(t,[e])||"string"==typeof i&&!new RegExp(i).test(e)||i instanceof RegExp&&!i.test(e))}}),F.count=0,F.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,createOnBlur:!1,selectOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,allowCreateEmpty:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",manualInputWidth:!1,dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:!0,render:{}},e.fn.selectize=function(t){var i=e.fn.selectize.defaults,n=e.extend({},i,t),s=n.dataAttr,a=n.labelField,r=n.valueField,o=n.optgroupField,l=n.optgroupLabelField,c=n.optgroupValueField,d=function(t,i){var o,l,c,d,u=t.attr(s);
if(u)for(i.options=JSON.parse(u),o=0,l=i.options.length;l>o;o++)i.items.push(i.options[o][r]);else{var h=e.trim(t.val()||"");if(!n.allowEmptyOption&&!h.length)return;for(c=h.split(n.delimiter),o=0,l=c.length;l>o;o++)d={},d[a]=c[o],d[r]=c[o],i.options.push(d);i.items=c}},u=function(t,i){var d,u,h,p,m=i.options,f={},g=function(e){var t=s&&e.attr(s);return"string"==typeof t&&t.length?JSON.parse(t):null},v=function(t,s){t=e(t);var l=P(t.attr("value"));if(l||n.allowEmptyOption)if(f.hasOwnProperty(l)){if(s){var c=f[l][o];
c?e.isArray(c)?c.push(s):f[l][o]=[c,s]:f[l][o]=s}}else{var d=g(t)||{};d[a]=d[a]||t.text(),d[r]=d[r]||l,d[o]=d[o]||s,f[l]=d,m.push(d),t.is(":selected")&&i.items.push(l)}},y=function(t){var n,s,a,r,o;for(t=e(t),a=t.attr("label"),a&&(r=g(t)||{},r[l]=a,r[c]=a,i.optgroups.push(r)),o=e("option",t),n=0,s=o.length;s>n;n++)v(o[n],a)};for(i.maxItems=t.attr("multiple")?null:1,p=t.children(),d=0,u=p.length;u>d;d++)h=p[d].tagName.toLowerCase(),"optgroup"===h?y(p[d]):"option"===h&&v(p[d])};return this.each(function(){if(!this.selectize){var s,a=e(this),r=this.tagName.toLowerCase(),o=a.attr("placeholder")||a.attr("data-placeholder");
o||n.allowEmptyOption||(o=a.children('option[value=""]').text());var l={placeholder:o,options:[],optgroups:[],items:[]};"select"===r?u(a,l):d(a,l),s=new F(a,e.extend(!0,{},i,l,t))}})},e.fn.selectize.defaults=F.defaults,e.fn.selectize.support={validity:S},F.define("remove_button",function(t){if("single"!==this.settings.mode){t=e.extend({label:"&times;",title:"Remove",className:"remove",append:!0},t);var i=this,n='<a href="javascript:void(0)" class="'+t.className+'" tabindex="-1" title="'+A(t.title)+'">'+t.label+"</a>",s=function(e,t){var i=e.search(/(<\/[^>]+>\s*)$/);
return e.substring(0,i)+t+e.substring(i)};this.setup=function(){var a=i.setup;return function(){if(t.append){var r=i.settings.render.item;i.settings.render.item=function(){return s(r.apply(this,arguments),n)}}a.apply(this,arguments),this.$control.on("click","."+t.className,function(t){if(t.preventDefault(),!i.isLocked){var n=e(t.currentTarget).parent();i.setActiveItem(n),i.deleteSelection()&&i.setCaret(i.items.length)}})}}()}}),F.define("restore_on_backspace",function(e){var t=this;e.text=e.text||function(e){return e[this.settings.labelField]
},this.onKeyDown=function(){var i=t.onKeyDown;return function(t){var n,s;return t.keyCode===f&&""===this.$control_input.val()&&!this.$activeItems.length&&(n=this.caretPos-1,n>=0&&n<this.items.length)?(s=this.options[this.items[n]],this.deleteSelection(t,!0)&&(this.setTextboxValue(e.text.apply(this,[s])),this.refreshOptions(!0)),void t.preventDefault()):i.apply(this,arguments)}}()}),F.define("restore_on_focus",function(e){var t=this;e.text=e.text||function(e){return e[this.settings.labelField]};var i=t.onFocus;
this.onFocus=function(){return function(){var t=this.caretPos-1;if(t>=0&&t<this.items.length){var n=this.options[this.items[t]],s=e.text.call(this,n);this.removeItem(n[this.settings.valueField]),this.setTextboxValue(s),this.refreshOptions(!0)}return i.apply(this,arguments)}}()}),F}),define("plex/desktop/views/editmetadata/EditMetadataTagsView",["hb!templates/desktop/editmetadata/EditMetadataMovieTagsView.tpl","hb!templates/desktop/editmetadata/EditMetadataShowTagsView.tpl","hb!templates/desktop/editmetadata/EditMetadataEpisodeTagsView.tpl","hb!templates/desktop/editmetadata/EditMetadataArtistTagsView.tpl","hb!templates/desktop/editmetadata/EditMetadataAlbumTagsView.tpl","hb!templates/desktop/editmetadata/EditMetadataTrackTagsView.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/formatters/stringUtil","plex/base/utils/types/mediaTypes","plex/base/models/library/section/SectionModel","plex/base/models/library/section/FilterModel","plex/base/models/library/MultiMetadataAutocompleteResultCollection","plex/desktop/views/editmetadata/EditMetadataBaseView","selectize"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f=m.extend({templatesByType:{movie:e,show:t,episode:i,artist:n,album:s,track:a},ui:r.extend({tagInputs:".tag-input-hidden"},m.prototype.ui),events:r.extend({"change .lockable-field":"onLockableFieldChange"},m.prototype.events),initialize:function(){this.template=this.templatesByType[this.model.get("type")]||this.templatesByType.movie,this.canAutocomplete=this.model.server.supports("batchEdit"),this.getSection()},getSection:function(){var e=this.model.section;if(!e){var t=this.model.get("librarySectionID");
e=new u({key:t},{server:this.model.server})}this.section=e},flushChanges:function(){var e=this.ui.form,t=r.reduce(e.serializeArray(),function(e,t){return e[t.name]=t.value,e},{});t.Field=this.getLockedFieldsArray();var i=r.reduce(this.ui.tagInputs,function(e,t){var i=t.selectize,n=o(t).data("name");return e[n]=r.map(i.items,function(e){var t=i.options[e];return{tag:t.tag,id:t.id}}),this.model.set("original.tag."+n,r.toArray(i.options)),e},{},this);r.each(i,function(e,i){var n=c.upperCaseFirstLetter(i),s=r.pluck(this.model.get(n),"tag"),a=r.pluck(e,"tag");
r.isEqual(s,a)||(t[n]=e)},this),this.model.set(t)},selectizeTagInput:function(e,t){var i=o(t),n=i.data("name"),s=c.upperCaseFirstLetter(n),a=this,u=this.model.get(s),m=r.map(u,function(e){return e.id||e.tag}),f=this.model.get("original.tag."+n);f||(f=r.clone(u),this.model.set("original.tag."+n,f));var g=r.difference(m,r.pluck(f,"id"));if(g.length){var v=r.map(g,function(e){return{id:e,tag:e}});v.unshift(f.length,0),f.splice.apply(f,v)}var y=i.data("name"),b=function(e){this.model.set("original.allTagsRequested."+n,!0);
var t=new h({filter:n,filterType:"string"},{server:this.model.server,section:this.section,type:d.byType[this.model.get("type")].id}),i=t.get("options");i.populate().then(r.bind(function(t){this.model.set("original.allTagsAvailable."+n,!0),e(t.map(function(e){return{tag:e.attributes.title,id:e.attributes.key}}))},this))};i.data("original-value",i.val()),i.selectize({options:f,items:m,plugins:["remove_button"],create:!0,labelField:"tag",valueField:"id",sortField:"tag",searchField:["tag"],highlight:!1,createFilter:function(e){var t=r(this.options).findWhere({tag:e});
return!t},onChange:function(){a.onLockableFieldChange(i)},onFocus:function(){this.onSearchChange("")},loadingClass:"",load:function(e,t){if(!e.length||!a.canAutocomplete)return void(a.model.get("original.allTagsRequested."+n)?t():b.call(a,t));if(a.model.get("original.allTagsAvailable."+n))return void t();var i={};i[y]=e;var s=new p([],{multiMetadataModel:a.model,query:i,server:a.model.server});s.fetch().done(function(e){var i=e.map(function(e){return e.attributes});t(i)}).fail(function(){t()})},render:{item:function(e,t){var i=e.tag?t(e.tag):'<span class="autocomplete-annotate">('+l("blank")+")</span>";
return'<div class="item">'+i+"</div>"},option:function(e,t){var i;return i=e.tag?t(e.tag):'<small class="autocomplete-annotate">('+l("blank")+")</small>",'<div class="item">'+i+"</div>"}}})},onRender:function(){this.ui.tagInputs.each(r.bind(this.selectizeTagInput,this))}});return f}),define("hb!templates/desktop/editmetadata/EditMetadataSharingView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n  <form class="edit-metadata-form">\n\n  <div class="row">\n    <div class="col-md-12">\n      ',n=i["if"].call(e,e&&e.showLabels,{hash:{},inverse:p.program(4,o,t),fn:p.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\n    </div>\n  </div>\n\n  </form>\n"
}function r(e,t){var n,s,a="";return a+="\n          ",s={hash:{label:"Labels",name:"label",value:(n=e&&e.item,null==n||n===!1?n:n.Label),locked:(n=e&&e.locked,null==n||n===!1?n:n.label)},data:t},a+=h((n=i.partial||e&&e.partial,n?n.call(e,"lockableTagInput",s):u.call(e,"partial","lockableTagInput",s)))+"\n      "}function o(e,t){var n,s,a="";return a+='\n        <div class="form-group">\n          <label>',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Labels",s):u.call(e,"t","Labels",s)))+"</label>\n          <p>",s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Labels require Plex Media Server {1} or later.",e&&e.labelsMinVersion,s):u.call(e,"t","Labels require Plex Media Server {1} or later.",e&&e.labelsMinVersion,s)))+"</p>\n        </div>\n      "
}function l(e,t){var n,s,a,r="";return r+='\n  <div class="row row-padded">\n    <h4 class="text-muted text-center">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"You need a Plex Pass to use restrictions.",a):u.call(e,"t","You need a Plex Pass to use restrictions.",a)))+'</h4>\n\n    <p class="text-center">\n      <a class="btn btn-sm btn-primary" href="',(s=i.plexPassUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.plexPassUrl,s=typeof s===m?s.call(e,{hash:{},data:t}):s),r+=h(s)+'" target="_blank">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Learn More",a):u.call(e,"t","Learn More",a)))+"</a>\n    </p>\n  </div>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d="",u=i.helperMissing,h=this.escapeExpression,p=this,m="function";return c=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:p.program(6,l,s),fn:p.program(1,a,s),data:s}),(c||0===c)&&(d+=c),d+="\n"})}),define("plex/desktop/views/editmetadata/EditMetadataSharingView",["hb!templates/desktop/editmetadata/EditMetadataSharingView.tpl","underscore","plex/base/models/appModel","plex/desktop/views/editmetadata/EditMetadataTagsView"],function(e,t,i,n){"use strict";
var s=n.extend({templatesByType:{movie:e,show:e,album:e,photo:e},serializeData:function(){var e=i.get("user"),s=n.prototype.serializeData.apply(this,arguments);return t.extend(s,{showLabels:this.model.server.supports("labels"),labelsMinVersion:this.model.server.features.labels,hasPlexPass:e.hasPlexPass(),plexPassUrl:e.server.get("plexPassUrl")}),s}});return s}),define("hb!templates/desktop/editmetadata/EditMetadataArtworkView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n  <div class="upload-artwork-container">\n    <div class="upload-prompt">\n      ',n=i["if"].call(e,e&&e.showFileUpload,{hash:{},inverse:u.noop,fn:u.program(2,r,t),data:t}),(n||0===n)&&(a+=n),a+='\n\n      <a class="upload-url-btn" href="#">',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"enter a url",s):c.call(e,"t","enter a url",s)))+'</a>\n    </div>\n\n    <div class="upload-progress">\n      ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"Uploading artwork...",s):c.call(e,"t","Uploading artwork...",s)))+'\n    </div>\n\n    <div class="upload-success">\n      ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"this artwork was uploaded successfully",s):c.call(e,"t","this artwork was uploaded successfully",s)))+'\n      <span class="upload-prompt-divider">&middot;</span>\n      ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"{1}upload another{2}","<a class='upload-back-btn' href='#'>","</a>",s):c.call(e,"t","{1}upload another{2}","<a class='upload-back-btn' href='#'>","</a>",s)))+'\n    </div>\n\n    <div class="upload-error">\n      ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"there was an error uploading this artwork",s):c.call(e,"t","there was an error uploading this artwork",s)))+'\n      <span class="upload-prompt-divider">&middot;</span>\n      ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"{1}try again{2}","<a class='upload-back-btn' href='#'>","</a>",s):c.call(e,"t","{1}try again{2}","<a class='upload-back-btn' href='#'>","</a>",s)))+'\n    </div>\n\n    <form id="upload-form" class="upload-form">\n      <input type="text" class="form-control" name="url" placeholder="',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"Enter a url to upload an image from the web",s):c.call(e,"t","Enter a url to upload an image from the web",s)))+'">\n\n      <div class="upload-form-help">\n        <div class="pull-right">',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"enter to {1}upload{2}","<a class='submit-url-btn' href='#'>","</a>",s):c.call(e,"t","enter to {1}upload{2}","<a class='submit-url-btn' href='#'>","</a>",s)))+'</div>\n        <div class="pull-left">',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"esc to {1}cancel{2}","<a class='cancel-url-btn' href='#'>","</a>",s):c.call(e,"t","esc to {1}cancel{2}","<a class='cancel-url-btn' href='#'>","</a>",s)))+"</div>\n      </div>\n    </form>\n  </div>\n"
}function r(e,t){var n,s,a="";return a+='\n        <span class="artwork-file-container">\n          <input type="file" class="artwork-file-control" multiple>\n          <a href="#">',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"choose an image",s):c.call(e,"t","choose an image",s)))+'</a>\n        </span>\n\n        <span class="upload-prompt-divider">&middot;</span>\n        ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"drag and drop",s):c.call(e,"t","drag and drop",s)))+'\n        <span class="upload-prompt-divider">&middot;</span>\n      '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;return o=i["if"].call(t,t&&t.showUpload,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='\n\n<div class="artwork-list-container"></div>\n'})}),define("plex/base/models/library/ArtworkCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/MetadataModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){var t=e.result(this.parent,"firstItemUrl");
return t+"/"+this.artworkType+"s"},initialize:function(e,t){this.artworkType=t.artworkType},parse:function(e){return this.convert(e,"Photo")}});return n}),define("hb!templates/desktop/lists/library/ArtworkListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<a class="artwork-option media-poster-container" data-rating-key="',(a=i.ratingKey)?a=a.call(t,{hash:{},data:s}):(a=t&&t.ratingKey,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'" href="#">\n  <div class="media-poster"></div>\n</a>\n'
})}),define("plex/desktop/views/lists/library/ArtworkListItem",["hb!templates/desktop/lists/library/ArtworkListItem.tpl","marionette","plex/base/utils/posterSizes","plex/base/utils/posterPlaceholders","plex/base/views/images/BaseImage"],function(e,t,i,n,s){"use strict";var a=t.Layout.extend({tagName:"span",template:e,regions:{poster:".media-poster"},initialize:function(e){var t=e.artworkType,a=150;"art"===t?a=240:"banner"===t&&(a=520),this.$el.addClass(t),this.image=new s({className:"media-poster-image",model:this.model,modelAttribute:"thumb",placeholderClass:n[t],width:a,height:i.getPosterHeight(t,a)})
},bindings:{".artwork-option":{modelAttribute:"selected",manual:!0,formatter:function(e,t){t.toggleClass("selected",e)}}},onRender:function(){this.poster.show(this.image)}});return a}),define("plex/desktop/views/lists/library/ArtworkList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/ArtworkListItem"],function(e,t){"use strict";var i=e.extend({className:"artwork-options-list",itemView:t});return i}),define("plex/desktop/views/editmetadata/EditMetadataArtworkView",["hb!templates/desktop/editmetadata/EditMetadataArtworkView.tpl","underscore","jquery","marionette","plex/base/utils/capabilities","plex/base/models/library/MetadataModel","plex/base/models/library/ArtworkCollection","plex/desktop/views/lists/library/ArtworkList"],function(e,t,i,n,s,a,r,o){"use strict";
var l=n.Layout.extend({template:e,dragStatus:0,ui:{upload:".upload-artwork-container",urlInput:"input[name=url]"},regions:{list:".artwork-list-container"},events:{dragenter:"onDragEnter",dragleave:"onDragLeave",dragover:"onDragOver",drop:"onDrop",keydown:"onKeyDown","change .artwork-file-control":"onFileChange","click .upload-url-btn":"onUploadUrlClick","click .cancel-url-btn":"onCancelUrlClick","click .submit-url-btn":"onUrlSubmit","submit #upload-form":"onUrlSubmit","click .upload-back-btn":"onUploadBackClick","click .artwork-option":"onArtworkOptionClick"},initialize:function(e){this.type=e.type,this.changes={},this.collection=new r([],{server:this.model.server,section:this.model.section,parent:this.model,artworkType:this.type}),this.collection.fetch()
},serializeData:function(){return{showUpload:this.model.server.supports("artworkUpload"),showFileUpload:s.hasFileUpload}},flushChanges:function(){this.model.set(this.changes)},uploadFiles:function(e){if(e&&e.length){this.changes={},this.ui.upload.removeClass("show-success show-error");var n=this.collection.url(),s=t.extend(this.model.server.getXHROptions(n),{type:"POST",processData:!1}),a=[],r=t.bind(function(e){/image\//.test(e.type)&&(s.data=e,a.push(i.ajax(s)))},this);if(t.each(e,r),!a.length)return void this.ui.upload.addClass("show-error");
this.ui.upload.addClass("show-progress"),this.monitorUpload(i.when.apply(i,a))}},uploadUrl:function(e){this.changes={},this.ui.upload.removeClass("show-form"),this.ui.upload.addClass("show-progress"),this.ui.urlInput.val(""),e=this.collection.url()+"?url="+encodeURIComponent(e);var n=t.extend(this.model.server.getXHROptions(e),{type:"POST"});this.monitorUpload(i.ajax(n))},monitorUpload:function(e){e.done(t.bind(function(){this.ui.upload.addClass("show-success");var e={server:this.model.server,onlyIfCached:!0},i=new a({key:this.model.get("key")},e);
t.isEmpty(i)||i.fetch(),this.collection.fetch()},this)),e.fail(t.bind(function(){this.ui.upload&&this.ui.upload.addClass("show-error")},this)),e.always(t.bind(function(){this.ui.upload&&this.ui.upload.removeClass("show-progress")},this))},onRender:function(){this.list.show(new o({collection:this.collection,itemViewOptions:{artworkType:this.type}}))},onDragEnter:function(){this.dragStatus++,this.ui.upload.addClass("drag-hover")},onDragLeave:function(){this.dragStatus--,0===this.dragStatus&&this.ui.upload.removeClass("drag-hover")
},onDragOver:function(e){e.preventDefault()},onDrop:function(e){e.preventDefault(),e.stopPropagation(),this.dragStatus=0,this.ui.upload.removeClass("drag-hover"),this.uploadFiles(e.originalEvent.dataTransfer.files)},onKeyDown:function(e){27===e.which&&this.ui.upload.hasClass("show-form")&&(e.preventDefault(),this.ui.upload.removeClass("show-form"))},onFileChange:function(e){this.uploadFiles(e.target.files)},onUploadUrlClick:function(e){e.preventDefault(),this.ui.upload.addClass("show-form"),this.ui.urlInput.focus()
},onCancelUrlClick:function(e){e.preventDefault(),this.ui.upload.removeClass("show-form")},onUrlSubmit:function(e){e.preventDefault();var t=this.ui.urlInput.val();t?this.uploadUrl(t):this.ui.upload.removeClass("show-form")},onUploadBackClick:function(e){e.preventDefault(),this.ui.upload.removeClass("show-success show-error")},onArtworkOptionClick:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.data("ratingKey");this.$(".artwork-option.selected").removeClass("selected"),t.addClass("selected"),this.changes["artwork:"+this.type]=n
}});return l}),define("hb!templates/desktop/editmetadata/EditMetadataInfoView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+="<h4>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Files",r):l.call(t,"t","Files",r)))+'</h4>\n<ul class="media-info-file-list"></ul>\n<div class="loading-container"><div class="loading"></div></div>\n'})}),define("hb!templates/desktop/editmetadata/EditMetadataMediaPartView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r="",o="function",l=this.escapeExpression;return(a=i.file)?a=a.call(t,{hash:{},data:s}):(a=t&&t.file,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"\n"})}),define("plex/desktop/views/editmetadata/EditMetadataMediaPartView",["hb!templates/desktop/editmetadata/EditMetadataMediaPartView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({template:e,tagName:"li",className:"well",serializeData:function(){var e={file:this.model.get("file")};return e}});return i}),define("plex/desktop/views/editmetadata/EditMetadataInfoView",["hb!templates/desktop/editmetadata/EditMetadataInfoView.tpl","underscore","jquery","marionette","plex/base/models/library/MetadataModel","plex/base/models/BaseCollection","plex/desktop/views/editmetadata/EditMetadataMediaPartView"],function(e,t,i,n,s,a,r){"use strict";
var o=n.CompositeView.extend({template:e,className:"files",itemView:r,itemViewContainer:"ul",initialize:function(){this.collection=new a,this.populateParts().always(this.whenRendered(function(){this.$(".loading").addClass("hidden")}))},populateParts:function(){function e(e){var i=e.get("Media");return i&&i.length?(t.each(i,n),i):void 0}function n(e){t.each(e.Part,a)}function a(e){r.push(e)}var r=this.collection,o=new s(this.model.pick("ratingKey","key"),{server:this.model.server});if(e(o))return i.Deferred().resolve();
var l=o.populate().then(function(){if(!e(o)){var t=o.get("children");if(t){if(!t.length)return t.populate().then(function(){t.each(e)});t.each(e)}}});return l},flushChanges:function(){}});return o}),define("plex/desktop/mixins/views/modals/paneModalMixin",["underscore"],function(e){"use strict";function t(e,t){var i=t.constructor.prototype.validate;return i?i.call(null,e):[]}function i(e){var i=this.panes[e],n=a.call(this,i);return 0===t.call(this,n,i).length}function n(e,t){return e.concat(this.panes[t].dependentPanes||[])
}function s(){var t=this.$(".change-pane-btn");t.addClass("disabled").removeClass("selected"),e.each(this.getReachablePanes(),function(e){t.filter("."+e+"-btn").removeClass("disabled")},this),t.filter("."+this.selectedPane+"-btn").addClass("selected")}function a(e){return this[e.model]||this[this.panesModel]||this.model}var r={showPane:function(t){if(t!==this.selectedPane){var i=this.paneRegion.currentView;i&&(this.stopListening(i,"valid",s),this.stopListening(i,"invalid",s),this.$el.removeClass("pane-"+this.selectedPane),this.onPaneHide&&this.onPaneHide(this.selectedPane,i)),this.selectedPane=t;
var n=this.panes[t],r=n.constructor,o=this.paneConstructorArg?this.paneConstructorArg():{},l=new r(e.extend(o,{model:a.call(this,n)}));if(l.onModalClose){this._paneOnModalCloseCallbacks||this.listenToOnce(this,"close",function(){e.each(this._paneOnModalCloseCallbacks,function(e){e[1].call(e[0])},this),this._paneOnModalCloseCallbacks=null});var c=this._paneOnModalCloseCallbacks||[];c.push([l,l.onModalClose]),this._paneOnModalCloseCallbacks=e.uniq(c,function(e){return e[1]})}this.listenTo(l,"valid",s),this.listenTo(l,"invalid",s),s.call(this),this.onPaneShow&&this.onPaneShow(t,l),this.$el.addClass("pane-"+t),this.paneRegion.show(l),s.call(this)
}},getReachablePanes:function(){for(var t,s,a=e.reduce(this.panes,function(t,i){return e.union(t,i.dependentPanes||[])},[]),r=e.filter(e.keys(this.panes),function(t){return!e.contains(a,t)}),o=r;o.length;)t=e.filter(o,i,this),s=s||t.length!==o.length,o=e.reduce(t,n,[],this),r=r.concat(o);return r.isAnyInvalid=s,r},onChangePaneClick:function(e){e.preventDefault();var t=this.$(e.currentTarget);t.isDisabled()||this.showPane(t.data("pane"))}};return r}),define("plex/desktop/views/modals/EditMetadataModal",["hb!templates/desktop/modals/EditMetadataModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/library/MultiMetadataModel","plex/desktop/views/editmetadata/EditMetadataGeneralView","plex/desktop/views/editmetadata/EditMetadataTagsView","plex/desktop/views/editmetadata/EditMetadataSharingView","plex/desktop/views/editmetadata/EditMetadataArtworkView","plex/desktop/views/editmetadata/EditMetadataInfoView","plex/desktop/views/modals/BaseModal","plex/desktop/mixins/views/modals/paneModalMixin"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p){"use strict";
var m={movie:["general","tags","sharing","poster","art","info"],show:["general","tags","sharing","poster","banner","art"],season:["general","poster","art","info"],episode:["general","tags","poster","art","info"],artist:["general","tags","poster","art"],album:["general","tags","sharing","poster","art","info"],track:["general","tags","info"],photoAlbum:["general","poster","art"],photo:["general","sharing","info"],playlist:["general"]},f=["poster","art","banner","info"],g=h.extend({mixins:[p],name:"editMetadataModal",className:"edit-metadata-modal modal modal-lg fade",template:e,panes:{general:{constructor:o},tags:{constructor:l},poster:{constructor:d},art:{constructor:d},banner:{constructor:d},sharing:{constructor:c},info:{constructor:u}},panesModel:"tempModel",events:t.extend({"click .change-pane-btn":"onChangePaneClick","click .save-btn":"onSaveClick"},h.prototype.events),ui:{saveBtn:".save-btn",message:".form-message",navPane:".modal-nav-pane",loadingIndicator:".modal-body-pane .loading-inline"},regions:{paneRegion:".pane-region"},onlyAfterRender:["saveChanges","showPane","showNav"],initialize:function(e){h.prototype.initialize.apply(this,arguments);
var a,o,l,c=e.mediaActions;if(c?(l=c.getActionTargets(),l[0].get("isPlaylist")||!c.server.supports("batchEdit")?a=l[0]:(a=new r(1===l.length?l[0].attributes:{},{mediaActions:c}),o=a.populate())):(a=e.model,l=[a]),this.model=a,this.tempModel=a.clone(),!o){var d=i.Deferred();d.resolve(),o=d.promise()}o=o.done(t.bind(function(){this.tempModel.set(a.attributes),1===l.length&&this.tempModel.set("key",l[0].get("key")),this.showNav(),this.showPane(e.selectedPane||"general"),this.listenTo(s,"shortcut:save",this.saveChanges)
},this)),o.fail(t.bind(function(){this.ui.message.text(n("There was an error editing this item")),this.ui.loadingIndicator.addClass("hidden")},this))},serializeData:function(){var e=m[this.model.get("type")]||m.movie;this.model.isSingleMetadataModel&&!this.model.isSingleMetadataModel()&&(e=t.difference(e,f));var i=t.reduce(e,function(e,t){return e[t]=!0,e},{}),s=t.escape(n("Edit {1}",this.model.get("aggregateTitle")||this.model.get("title"))),a={item:this.model.toJSON(),panes:i,selectedPane:this.selectedPane,paneTitle:s};
return a},paneConstructorArg:function(){return{type:this.selectedPane}},invalidChangedAttrs:function(e){var i=[];if("track"===this.tempModel.get("type")){var n=t(e),s=n.has("artist.id")||n.has("artist.title")||n.has("album.id")||n.has("album.title"),a=e["album.id"]||e["album.title"],r=e["artist.id"]||e["artist.title"],o=!s||r&&a;o||(r||i.push("grandparentTitle"),a||i.push("parentTitle"))}return i},markInvalid:function(e){this.paneRegion.currentView.markInvalid(e)},showNav:function(){this.ui.navPane.removeClass("hidden")
},saveChanges:function(){var e=this.ui.saveBtn,s=this.ui.message;if(!e.isDisabled()){s.text(""),this.paneRegion.currentView.flushChanges();var r=t.reduce(this.model.changedAttributes(this.tempModel.attributes),function(e,t,i){return/^original\./.test(i)?e:(e[i]=t,e)},{}),o=this.invalidChangedAttrs(r);if(o.length)return void this.markInvalid(o);e.addClass("active");var l=[];t.isEmpty(r)||(t.each(["artwork:poster","artwork:banner","artwork:art"],function(e){var t=r[e];t&&(l.push(a.execute("changeArtwork",{item:this.model.singleMetadataModel(),artworkType:e.replace("artwork:",""),artworkRatingKey:t})),delete r[e])
},this),l.push(this.model.save(r)));var c=i.when.apply(i,l);c.done(t.bind(function(){this.hide()},this)),c.fail(function(){s.text(n("Your changes could not be saved."))}),c.always(function(){e.removeClass("active")})}},onPaneShow:function(e,t){this.listenTo(t,"focusSubmit",function(){this.ui.saveBtn.focus()})},onPaneHide:function(e,t){t.flushChanges(),this.stopListening(t)},onSaveClick:function(e){e.preventDefault(),this.saveChanges()}});return g}),define("hb!templates/desktop/dropdowns/MediaActionsDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='<li><a class="download-btn" href="',(n=i.downloadUrl)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadUrl,n=typeof n===d?n.call(e,{hash:{},data:t}):n),a+=u(n)+'" download="',(n=i.downloadName)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadName,n=typeof n===d?n.call(e,{hash:{},data:t}):n),a+=u(n)+'" tabindex="-1">',s={hash:{},data:t},a+=u((n=i.t||e&&e.t,n?n.call(e,"Download",s):h.call(e,"t","Download",s)))+"</a></li>"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;
return c+='<li><a class="play-all-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Play All",l):h.call(t,"t","Play All",l)))+'</a></li>\n<li><a class="play-shuffled-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Shuffle",l):h.call(t,"t","Shuffle",l)))+'</a></li>\n<li><a class="play-next-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Play Next",l):h.call(t,"t","Play Next",l)))+'</a></li>\n<li><a class="add-to-up-next-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Add to Up Next",l):h.call(t,"t","Add to Up Next",l)))+'</a></li>\n<li><a class="play-mix-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Play Plex Mix",l):h.call(t,"t","Play Plex Mix",l)))+'</a></li>\n<li><a class="play-trailer-btn play-primary-extra-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Play Trailer",l):h.call(t,"t","Play Trailer",l)))+'</a></li>\n<li><a class="play-music-video-btn play-primary-extra-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Play Music Video",l):h.call(t,"t","Play Music Video",l)))+'</a></li>\n<li><a class="add-to-playlist-btn btn-link" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Add to Playlist...",l):h.call(t,"t","Add to Playlist...",l)))+'</a></li>\n\n<li class="divider"></li>\n\n<li><a class="refresh-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Refresh",l):h.call(t,"t","Refresh",l)))+'</a></li>\n<li><a class="mark-watched-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Mark as Watched",l):h.call(t,"t","Mark as Watched",l)))+'</a></li>\n<li><a class="mark-unwatched-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Mark as Unwatched",l):h.call(t,"t","Mark as Unwatched",l)))+'</a></li>\n<li><a class="sync-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sync...",l):h.call(t,"t","Sync...",l)))+"</a></li>\n",o=i["if"].call(t,t&&t.downloadUrl,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n<li><a class="watch-later-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Watch Later",l):h.call(t,"t","Watch Later",l)))+'</a></li>\n<li><a class="share-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Share...",l):h.call(t,"t","Share...",l)))+'</a></li>\n<li><a class="recommend-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Recommend...",l):h.call(t,"t","Recommend...",l)))+'</a></li>\n<li><a class="delete-btn has-danger" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Delete",l):h.call(t,"t","Delete",l)))+'</a></li>\n<li><a class="info-btn" href="#" tabindex="-1">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Info",l):h.call(t,"t","Info",l)))+"</a></li>\n"
})}),define("plex/desktop/views/dropdowns/MediaActionsDropdown",["hb!templates/desktop/dropdowns/MediaActionsDropdown.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/formatters/stringUtil","plex/base/utils/types/mediaTypes","plex/base/commands/commands","plex/base/models/library/MetadataModel","plex/desktop/models/MediaActionsModel","plex/desktop/views/modals/AddToPlaylistModal","plex/desktop/views/modals/ShareModal","plex/desktop/views/modals/MediaInfoModal","plex/desktop/views/modals/RecommendModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f=n.ItemView.extend({tagName:"ul",className:"dropdown-menu",template:e,ui:{divider:".divider"},events:{"click .play-all-btn":"onPlayAllClick","click .play-shuffled-btn":"onPlayShuffledClick","click .play-next-btn":"onPlayNextClick","click .add-to-up-next-btn":"onAddToUpNextClick","click .play-mix-btn":"onPlayMixClick","click .play-primary-extra-btn":"onPlayPrimaryExtraClick","click .add-to-playlist-btn":"onAddToPlaylistClick","click .refresh-btn":"onRefreshClick","click .sync-btn":"onSyncClick","click .mark-watched-btn":"onMarkWatchedClick","click .mark-unwatched-btn":"onMarkUnwatchedClick","click .watch-later-btn":"onWatchLaterClick","click .share-btn":"onShareClick","click .recommend-btn":"onRecommendClick","click .delete-btn":"onDeleteClick","click .info-btn":"onInfoClick"},initialize:function(e){this.mediaType=o.getMediaTypeByString(this.model.get("type")),this.parentMediaActions=e.mediaActions,this.mediaActions=new d({},{item:this.model}),i(".dropdown.open .dropdown-toggle").dropdown("toggle")
},serializeData:function(){var e,t;if(this.mediaActions.get("showDownload")){e=this.model.getDownloadUrl();var i=this.model.getFilepath();i&&(t=r.getLastSegment(i))}return{downloadUrl:e,downloadName:t}},getPosition:function(e,t,i){var n=e.position().left;return e.offset().top+this.$el.outerHeight()>t.offset.top+t.outerHeight&&(i-=this.$el.height()-e.height()),e.offset().left+this.$el.outerWidth()>t.offset.left+t.width&&(n-=this.$el.width()-e.outerWidth()),{top:i,left:n}},bindingsModel:"mediaActions",bindings:{".play-all-btn":{modelAttribute:"showPlayAll",manual:!0,autohide:!0},".play-shuffled-btn":{modelAttribute:"showShuffle",manual:!0,autohide:!0},".play-next-btn, .add-to-up-next-btn":{modelAttribute:"showQueue",modelListeners:["showQueue","canQueue"],manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.mediaActions.get("canQueue")),e
}},".play-mix-btn":{modelAttribute:"showPlayMix",manual:!0,autohide:!0,formatter:function(e,t){if(e){var i=this.model.get("related"),n=i.findWhere({browse:!1}),a=n.get("title");a&&t.text(s("Play {1}",a))}return e}},".play-trailer-btn":{modelAttribute:"showPlayTrailer",manual:!0,autohide:!0},".play-music-video-btn":{modelAttribute:"showPlayMusicVideo",manual:!0,autohide:!0},".add-to-playlist-btn":{modelAttribute:"showAddToPlaylist",manual:!0,autohide:!0},".refresh-btn":{modelAttribute:"showRefresh",manual:!0,autohide:!0},".mark-watched-btn":{modelAttribute:"showMarkWatched",manual:!0,autohide:!0},".mark-unwatched-btn":{modelAttribute:"showMarkUnwatched",manual:!0,autohide:!0},".sync-btn":{modelAttribute:"showSync",manual:!0,autohide:!0},".download-btn":{modelAttribute:"showDownload",manual:!0,autohide:!0},".watch-later-btn":{modelAttribute:"showWatchLater",manual:!0,autohide:!0},".share-btn, .recommend-btn":{modelAttribute:"showShare",manual:!0,autohide:!0},".delete-btn":{modelAttribute:"showDelete",manual:!0,autohide:!0},".info-btn":{modelAttribute:"showInfo",manual:!0,autohide:!0}},onRender:function(){var e=this.ui.divider,t=e.prevAll(":not(:has(.hidden))").length,i=e.nextAll(":not(:has(.hidden))").length;
e.toggleClass("hidden",!t||!i)},onClose:function(){this.mediaActions.stopListening()},onPlayAllClick:function(e){e.preventDefault(),l.execute("playMedia",{item:this.model})},onPlayShuffledClick:function(e){e.preventDefault(),l.execute("playMedia",{item:this.model,shuffle:!0})},onPlayPrimaryExtraClick:function(e){e.preventDefault();var i=this.model.server.getSectionForItem(this.model);if(!t.isEmpty(i)){var n=new c({key:this.model.get("primaryExtraKey"),type:"clip",librarySectionUUID:i.get("uuid")},{server:this.model.server,section:this.model.section});
l.execute("playMedia",{item:n})}},onPlayNextClick:function(e){return e.preventDefault(),i(e.currentTarget).isDisabled()?void e.stopImmediatePropagation():void l.execute("queueMedia",{item:this.model,next:!0})},onAddToUpNextClick:function(e){return e.preventDefault(),i(e.currentTarget).isDisabled()?void e.stopImmediatePropagation():void l.execute("queueMedia",{item:this.model,next:!1})},onPlayMixClick:function(e){e.preventDefault();var t=this.model.get("related"),i=t.findWhere({browse:!1});i.set("type","track"),l.execute("playMedia",{item:i})
},onAddToPlaylistClick:function(e){return e.preventDefault(),i(e.currentTarget).isDisabled()?void e.stopImmediatePropagation():void a.trigger("show:modal",new u({model:this.model,items:this.parentMediaActions&&this.parentMediaActions.getActionTargets()}))},onRefreshClick:function(e){e.preventDefault(),l.execute("refreshMetadata",{items:this.mediaActions.getActionTargets()})},onMarkWatchedClick:function(e){e.preventDefault(),l.execute("markWatched",{item:this.model})},onMarkUnwatchedClick:function(e){e.preventDefault(),l.execute("markUnwatched",{item:this.model})
},onSyncClick:function(e){e.preventDefault();var t={model:this.model,type:this.mediaType,isNew:!0,isSection:!1};l.execute("showSyncModal",t)},onWatchLaterClick:function(e){e.preventDefault(),l.execute("watchLater",{item:this.model})},onShareClick:function(e){e.preventDefault(),a.trigger("show:modal",new h({model:this.model}))},onRecommendClick:function(e){e.preventDefault(),a.trigger("show:modal",new m({model:this.model}))},onDeleteClick:function(e){e.preventDefault(),this.model.get("playlistType")?l.execute("deletePlaylist",{item:this.model}):l.execute("deleteItems",{item:this.model,skipRedirect:!0})
},onInfoClick:function(e){e.preventDefault(),a.trigger("show:modal",new p({model:this.model}))}});return f}),define("plex/desktop/views/players/PhotoPlayerDetailsView",["hb!templates/desktop/players/PhotoPlayerDetailsView.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/desktop/models/MediaActionsModel","plex/base/views/images/BaseImage","plex/desktop/views/modals/EditMetadataModal","plex/desktop/views/dropdowns/MediaActionsDropdown"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=n.Layout.extend({className:"photo-player-container",template:e,ui:{details:".photo-details",playBtn:".play-btn",pauseBtn:".pause-btn",dropdown:".photo-actions-dropdown"},regions:{photo:".photo-details"},events:{"click .edit-btn":"onEditClick","click .more-btn":"onMoreClick","hide.bs.dropdown .photo-actions-dropdown":"onDropdownHide"},onlyAfterRender:["onPausedChange"],initialize:function(e){this.playerModel=e.playerModel,this.transition=e.transition,this.mediaActions=new r({},{item:this.model});
var t=this.getImageSize();this.imageWidth=t.width,this.imageHeight=t.height,this.photoImage=new o({model:this.model,url:this.model.getMediaKey(),width:this.imageWidth,height:this.imageHeight}),this.updateImageSize(t),this.transition&&(this.$el.addClass(this.transition.type),this.transition.direction&&(this.$el.addClass(this.transition.direction),"left"===this.transition.direction?this.$el.css("left",-1*this.windowWidth):this.$el.css("left",this.windowWidth))),this.listenTo(s,"resize",this.onResize),this.listenTo(this.photoImage,"load",this.onLoad),this.listenTo(this.playerModel,"change:paused",this.onPausedChange),this.listenTo(this.playerModel,"change:showEnterFullscreen",this.onResize),this.model.isLibraryItem()&&this.model.populate()
},serializeData:function(){var e=this.collection.availableRange,t=e?e.start:0,i=t+this.collection.indexOf(this.model)+1,n=this.collection.totalSize||this.collection.length;return{player:this.playerModel.toJSON(),index:i,total:n}},getImageSize:function(){return this.windowWidth=i(window).width(),this.windowHeight=i(window).height(),{width:Math.round(.8*this.windowWidth),height:Math.round(.7*this.windowHeight)}},updateImageSize:function(e){this.photoImage.$el.css({"max-width":e.width,"max-height":e.height}),e.width>=this.imageWidth&&e.height>=this.imageHeight&&(this.imageWidth=e.width,this.imageHeight=e.height,this.photoImage.src=null,this.photoImage.width=this.imageWidth,this.photoImage.height=this.imageHeight,this.photoImage.render())
},transitionIn:function(){this.transition&&(this.$el.triggerReflow(),this.$el.removeClass(this.transition.type),this.transition.direction&&this.$el.removeClass(this.transition.direction).css("left",0))},transitionOut:function(e){return e?(this.$el.addClass(e.type),e.direction&&("right"===e.direction?this.$el.addClass("left").css("left",-1*this.windowWidth):this.$el.addClass("right").css("left",this.windowWidth)),void t.delay(t.bind(this.close,this),1e3)):void this.close()},bindings:{".photo-title":{modelAttribute:"title"},".photo-summary":{modelAttribute:"summary",autohide:!0},".edit-btn":{model:"mediaActions",modelAttribute:"showEdit",manual:!0,autohide:!0},".more-btn":{model:"mediaActions",modelAttribute:"showListDropdown",manual:!0,autohide:!0},".minimize-btn":{model:"playerModel",modelAttribute:"showMinimize",manual:!0,autohide:!0},".enter-fullscreen-btn":{model:"playerModel",modelAttribute:"showEnterFullscreen",manual:!0,autohide:!0},".exit-fullscreen-btn":{model:"playerModel",modelAttribute:"showExitFullscreen",manual:!0,autohide:!0}},onRender:function(){this.photo.prepend(this.photoImage)
},onLoad:function(){this.playerModel.set("loaded",!0)},onPausedChange:function(e,t){this.ui.playBtn.toggleClass("hidden",!t),this.ui.pauseBtn.toggleClass("hidden",t)},onResize:function(){var e=this.getImageSize();this.updateImageSize(e)},onEditClick:function(e){e.preventDefault(),s.trigger("show:modal",new l({mediaActions:this.mediaActions}))},onMoreClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.dropdown=new c({model:this.model}),this.ui.dropdown.append(this.dropdown.render().el),this.ui.dropdown.addClass("open"),this.ui.details.addClass("force-hover")
},onDropdownHide:function(){this.dropdown&&(this.dropdown.close(),this.dropdown=null,this.ui.details.removeClass("force-hover"))}});return d}),define("plex/desktop/views/players/PhotoPlayerView",["hb!templates/desktop/players/PhotoPlayerView.tpl","underscore","plex/base/commands/commands","plex/desktop/views/players/BasePlayerView","plex/desktop/views/players/PhotoPlayerDetailsView"],function(e,t,i,n,s){"use strict";var a=n.extend({className:"photo-player dark-scrollbar",template:e,defaultTransition:{type:"fade"},ui:{loading:".loading",previousBtn:".previous-btn",nextBtn:".next-btn"},regions:{details:".photo-player-container"},events:t.extend({"click .player-close-btn":"onCloseClick","click .play-btn":"onPlayClick","click .pause-btn":"onPauseClick","click .previous-btn":"onPreviousClick","click .next-btn":"onNextClick","click .minimize-btn":"onMinimizeClick","click .enter-fullscreen-btn":"onEnterFullscreenClick","click .exit-fullscreen-btn":"onExitFullscreenClick"},n.prototype.events),collectionEvents:{destroy:"onItemDestroy"},onlyAfterRender:["onPlayerCanSkipPreviousChange","onPlayerCanSkipNextChange"],initialize:function(){n.prototype.initialize.apply(this,arguments),this.addListeners()
},addListeners:function(){n.prototype.addListeners.apply(this,arguments),this.listenTo(this.playerModel,{"change:loaded":this.onPlayerLoadedChange,"change:paused":this.onPlayerPausedChange,"change:canSkipPrevious":this.onPlayerCanSkipPreviousChange,"change:canSkipNext":this.onPlayerCanSkipNextChange})},startPlayback:function(){this.controller.load({model:this.playerModel}),this.transition()},continuePlayback:function(){this.playerModel.set("loaded",!1),this.transition()},transition:function(e){e||(e=this.defaultTransition),this.loading=!0,this.nextDetails=new s({model:this.model,collection:this.playQueue.get("collection"),playerModel:this.playerModel,transition:e}),this.ui.loading.removeClass("hidden"),this.$el.addClass("show-photo-loading"),this.$el.append(this.nextDetails.render().el),this.currentTransition=this.defaultTransition
},skipPrevious:function(){this.loading||(this.currentTransition={type:"slide",direction:"left"},this.controller.skipPrevious())},skipNext:function(){this.loading||(this.currentTransition={type:"slide",direction:"right"},this.controller.skipNext())},onClose:function(){n.prototype.onClose.apply(this,arguments),this.currentDetails&&this.currentDetails.close(),this.nextDetails&&this.nextDetails.close()},onPlayerItemChange:function(e,t){this.model=t,this.transition(this.currentTransition),this.updatePageTitle()
},onPlayerLoadedChange:function(e,t){t&&(this.loading=!1,this.ui.loading.addClass("hidden"),this.$el.removeClass("show-photo-loading"),this.nextDetails.transitionIn(),this.currentDetails&&this.currentDetails.transitionOut(this.nextDetails.transition),this.currentDetails=this.nextDetails)},onPlayerCanSkipPreviousChange:function(e,t){this.ui.previousBtn.toggleClass("hidden",!t)},onPlayerCanSkipNextChange:function(e,t){this.ui.nextBtn.toggleClass("hidden",!t)},onItemDestroy:function(e){this.playerModel.get("item")===e&&(this.playQueue.get("collection").length?this.skipNext():this.stop())
},onCloseClick:function(e){e.preventDefault(),this.stop()},onPlayClick:function(e){e.preventDefault(),this.controller.play()},onPauseClick:function(e){e.preventDefault(),this.controller.pause()},onPreviousClick:function(e){e.preventDefault(),this.skipPrevious()},onNextClick:function(e){e.preventDefault(),this.skipNext()},onMinimizeClick:function(e){e.preventDefault(),this.minimize()},onEnterFullscreenClick:function(e){e.preventDefault(),this.enterFullscreen()},onExitFullscreenClick:function(e){e.preventDefault(),this.exitFullscreen()
}});return a}),define("hb!templates/desktop/players/PhotoMiniPlayerView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a="";return a})}),define("plex/desktop/views/players/PhotoMiniPlayerView",["hb!templates/desktop/players/PhotoMiniPlayerView.tpl","plex/desktop/views/players/MiniPlayerView","plex/desktop/views/players/controls/MiniPlayerControlsView"],function(e,t,i){"use strict";var n=t.extend({template:e,initialize:function(){t.prototype.initialize.apply(this,arguments),this.controlsView=new i({model:this.playerModel}),this.addListeners()
},addListeners:function(){t.prototype.addListeners.apply(this,arguments),this.listenTo(this.controlsView,"load:poster",this.onPosterLoad)},getNavigationKey:function(){var e=this.model.get("parentKey");return e?e:this.model.parent&&this.model.parent.get("key")},onRender:function(){this.controls.append(this.controlsView,this.$el),t.prototype.onRender.apply(this,arguments)},onPrimaryPlayerChange:function(){t.prototype.onPrimaryPlayerChange.apply(this,arguments),this.maximize()},onPosterLoad:function(){this.playerModel.set("loaded",!0)
}});return n}),define("hb!templates/desktop/navbar/NavBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}function r(){return"active"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h="function",p=this.escapeExpression,m=i.helperMissing;return d+='<ul class="nav nav-bar-nav">\n  <li><a class="back-btn ',o=i.unless.call(t,t&&t.hasHistory,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(d+=o),d+='" href="#"><i class="glyphicon chevron-left"></i></a></li>\n  <li><a class="home-btn" href="#"><i class="glyphicon home"></i></a></li>\n</ul>\n\n<div class="nav-bar-search-container"></div>\n\n<ul class="nav nav-bar-nav nav-bar-right">\n  <li><a class="plex-pass-btn ',o=i.unless.call(t,t&&t.canGoPremium,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(d+=o),d+='" href="',(o=i.plexPassUrl)?o=o.call(t,{hash:{},data:s}):(o=t&&t.plexPassUrl,o=typeof o===h?o.call(t,{hash:{},data:s}):o),d+=p(o)+'" target="_blank" data-toggle="tooltip-holiday"><span class="plex-pass-label label label-primary">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Go Premium",c):m.call(t,"t","Go Premium",c)))+'</span></a></li>\n\n  <li class="',l=i["if"].call(t,t&&t.activityCount,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='"><a class="activity-btn ',l=i.unless.call(t,t&&t.showActivity,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='" href="#!/activity" title="',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Activity",c):m.call(t,"t","Activity",c)))+'" data-toggle="tooltip"><span class="activity-badge badge badge-transparent ',l=i.unless.call(t,t&&t.activityCount,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='">',(l=i.activityCount)?l=l.call(t,{hash:{},data:s}):(l=t&&t.activityCount,l=typeof l===h?l.call(t,{hash:{},data:s}):l),d+=p(l)+'</span><i class="glyphicon cardio"></i></a></li>\n\n  <li><a class="settings-btn" href="#!/settings" title="',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Settings",c):m.call(t,"t","Settings",c)))+'" data-toggle="tooltip"><i class="glyphicon settings"></i></a></li>\n</ul>\n'
})}),define("hb!templates/desktop/tooltips/PlexPassTooltip",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<i class="plex-image plex-pass-sm"></i>\n<h1>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Upgrade to the Best Experience!",r):l.call(t,"t","Upgrade to the Best Experience!",r)))+"</h1>\n<p>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Upgrade to a Plex Pass and get exclusive access to the complete Plex experience! Awesomeness includes:",r):l.call(t,"t","Upgrade to a Plex Pass and get exclusive access to the complete Plex experience! Awesomeness includes:",r)))+'</p>\n<ul class="list">\n  <li>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Parental controls and fast switching to users in your Plex Home",r):l.call(t,"t","Parental controls and fast switching to users in your Plex Home",r)))+"</li>\n  <li>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sync your media and enjoy it anywhere",r):l.call(t,"t","Sync your media and enjoy it anywhere",r)))+"</li>\n  <li>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Free Apps for Android, Roku, and new platforms like Xbox, PlayStation, and VIZIO smart TVs",r):l.call(t,"t","Free Apps for Android, Roku, and new platforms like Xbox, PlayStation, and VIZIO smart TVs",r)))+"</li>\n  <li>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Enhance your movie experience with integrated trailers and extras",r):l.call(t,"t","Enhance your movie experience with integrated trailers and extras",r)))+"</li>\n</ul>\n"
})}),define("hb!templates/desktop/navbar/NavBarSearchView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}function r(e,t){var n,s;return s={hash:{},data:t},u((n=i.t||e&&e.t,n?n.call(e,"Search {1}",e&&e.searchPlaceholder,s):d.call(e,"t","Search {1}",e&&e.searchPlaceholder,s)))}function o(e,t){var n;return(n=i.searchValue)?n=n.call(e,{hash:{},data:t}):(n=e&&e.searchValue,n=typeof n===h?n.call(e,{hash:{},data:t}):n),u(n)}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var l,c="",d=i.helperMissing,u=this.escapeExpression,h="function",p=this;return c+='<div class="form-group form-group-search">\n  <label class="control-label-search" for="nav-bar-search">\n    <i class="glyphicon search"></i>\n    <a class="clear-search-btn ',l=i.unless.call(t,t&&t.searchValue,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(l||0===l)&&(c+=l),c+='" href="#"><i class="glyphicon circle-remove"></i></a>\n  </label>\n\n  <input type="search" id="nav-bar-search" class="form-control form-control-search" placeholder="',l=i["if"].call(t,t&&t.searchPlaceholder,{hash:{},inverse:p.noop,fn:p.program(3,r,s),data:s}),(l||0===l)&&(c+=l),c+='" value="',l=i["if"].call(t,t&&t.searchValue,{hash:{},inverse:p.noop,fn:p.program(5,o,s),data:s}),(l||0===l)&&(c+=l),c+='">\n</div>\n'
})}),define("plex/desktop/views/navbar/NavBarSearchView",["hb!templates/desktop/navbar/NavBarSearchView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t,i,n,s,a){"use strict";var r=n.ItemView.extend({id:"#nav-bar-search-form",tagName:"form",className:"nav-bar-form nav-bar-left hidden-xs",template:e,minSearchLength:2,sectionSearchDelay:500,ui:{searchInput:"#nav-bar-search",searchLabel:".control-label-search",clearSearchBtn:".clear-search-btn"},events:{"focus #nav-bar-search":"onSearchFocus","blur #nav-bar-search":"onSearchBlur","keyup #nav-bar-search":"onSearchKeyUp",submit:"onSearchSubmit","mousedown .clear-search-btn":"onClearSearchClick"},modelEvents:{"change:searchPlaceholder":"onSearchPlaceholderChange","change:searchValue":"onSearchValueChange"},onlyAfterRender:["focusSearch","onSearchPlaceholderChange","onSearchValueChange"],initialize:function(){this.debouncedSearch=t.debounce(this.search,this.sectionSearchDelay),this.listenTo(a,"shortcut:search",this.focusSearch)
},focusSearch:function(){this.ui.searchInput.focus()},search:function(){var e=i.trim(this.ui.searchInput.val()),t=this.model.get("searchType");return e.length<this.minSearchLength?void(e.length||this.clearSearch()):void(t?a.trigger("search:"+t,e):a.trigger("navigate","search",{query:e}))},clearSearch:function(){var e=this.model.get("searchType");e&&a.trigger("search:"+e,"")},onSearchPlaceholderChange:function(e,t){var i=t?s("Search {1}",t):"";this.ui.searchInput.attr("placeholder",i)},onSearchValueChange:function(e,t){this.ui.searchInput.is(document.activeElement)||(this.ui.clearSearchBtn.toggleClass("hidden",!t),this.ui.searchInput.val(t))
},onSearchFocus:function(){this.ui.searchLabel.addClass("selected")},onSearchBlur:function(){this.ui.searchLabel.removeClass("selected")},onSearchKeyUp:function(e){13!==e.which&&(this.ui.clearSearchBtn.toggleClass("hidden",0===this.ui.searchInput.val().length),"section"===this.model.get("searchType")&&this.debouncedSearch())},onSearchSubmit:function(e){e.preventDefault(),this.sectionSearchTimeout=clearTimeout(this.sectionSearchTimeout),this.search(),this.ui.searchInput.blur()},onClearSearchClick:function(e){e.preventDefault();
var t=this.ui.searchInput.val();this.ui.clearSearchBtn.addClass("hidden"),this.ui.searchInput.val(""),t.length>=this.minSearchLength&&this.search()}});return r}),define("hb!templates/desktop/navbar/NavDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}function r(){return"signed-in"}function o(){return"full-user"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h=this,p="function",m=this.escapeExpression,f=i.helperMissing;
return u+='<a class="dropdown-toggle dropdown-poster-toggle" href="#nav-dropdown" data-toggle="dropdown">\n  <div class="dropdown-poster-container">\n    <div class="media-poster img-circle"></div>\n    <i class="caret-icon"></i>\n  </div>\n  <span class="total-badge badge ',l=i.unless.call(t,t&&t.totalCount,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(l||0===l)&&(u+=l),u+='">',(l=i.totalCount)?l=l.call(t,{hash:{},data:s}):(l=t&&t.totalCount,l=typeof l===p?l.call(t,{hash:{},data:s}):l),u+=m(l)+'</span>\n</a>\n\n<ul class="dropdown-menu ',l=i["if"].call(t,t&&t.signedIn,{hash:{},inverse:h.noop,fn:h.program(3,r,s),data:s}),(l||0===l)&&(u+=l),u+=" ",l=i["if"].call(t,t&&t.isFullUser,{hash:{},inverse:h.noop,fn:h.program(5,o,s),data:s}),(l||0===l)&&(u+=l),u+='">\n  <li class="signed-in-item dropdown-header username-header"></li>\n  <li class="signed-in-item"><a class="users-btn" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Users",d):f.call(t,"t","Users",d)))+' <span class="invites-badge badge ',c=i.unless.call(t,t&&t.invitesCount,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(c||0===c)&&(u+=c),u+='">',(c=i.invitesCount)?c=c.call(t,{hash:{},data:s}):(c=t&&t.invitesCount,c=typeof c===p?c.call(t,{hash:{},data:s}):c),u+=m(c)+'</span></a></li>\n\n  <li class="signed-in-item full-user-item divider"></li>\n\n  <li class="signed-in-item full-user-item"><a href="#!/playlist/queue">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Watch Later",d):f.call(t,"t","Watch Later",d)))+'</a></li>\n  <li class="signed-in-item full-user-item"><a href="#!/playlist/recommendations">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Recommended",d):f.call(t,"t","Recommended",d)))+'</a></li>\n\n  <li class="signed-in-item divider"></li>\n\n  <li><a href="#!/announcements">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Announcements",d):f.call(t,"t","Announcements",d)))+' <span class="announcements-badge badge ',c=i.unless.call(t,t&&t.unreadAnnouncementsCount,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(c||0===c)&&(u+=c),u+='">',(c=i.unreadAnnouncementsCount)?c=c.call(t,{hash:{},data:s}):(c=t&&t.unreadAnnouncementsCount,c=typeof c===p?c.call(t,{hash:{},data:s}):c),u+=m(c)+'</span></a></li>\n  <li><a href="',(c=i.appsUrl)?c=c.call(t,{hash:{},data:s}):(c=t&&t.appsUrl,c=typeof c===p?c.call(t,{hash:{},data:s}):c),u+=m(c)+'" target="_blank">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Apps",d):f.call(t,"t","Apps",d)))+'</a></li>\n  <li><a href="',(c=i.helpUrl)?c=c.call(t,{hash:{},data:s}):(c=t&&t.helpUrl,c=typeof c===p?c.call(t,{hash:{},data:s}):c),u+=m(c)+'" target="_blank">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Help",d):f.call(t,"t","Help",d)))+'</a></li>\n\n  <li class="divider"></li>\n\n  <li class="signed-in-item switch-user-item ',c=i.unless.call(t,t&&t.home,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(c||0===c)&&(u+=c),u+='"><a class="switch-user-btn" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Switch User...",d):f.call(t,"t","Switch User...",d)))+'</a></li>\n  <li class="signed-out-item"><a class="sign-in-btn" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Sign In",d):f.call(t,"t","Sign In",d)))+'</a></li>\n  <li class="signed-in-item full-user-item"><a class="sign-out-btn" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Sign Out",d):f.call(t,"t","Sign Out",d)))+"</a></li>\n</ul>\n"
})}),define("plex/desktop/views/navbar/NavDropdown",["hb!templates/desktop/navbar/NavDropdown.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/config","plex/base/views/images/GravatarImage","plex/desktop/views/modals/user/UserSelectModal"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=i.ItemView.extend({id:"nav-dropdown",tagName:"li",className:"nav-dropdown dropdown",template:e,ui:{poster:".dropdown-poster-toggle .media-poster",dropdownMenu:".dropdown-menu",switchUserItem:".switch-user-item",totalBadge:".total-badge",invitesBadge:".invites-badge",announcementsBadge:".announcements-badge"},events:{"click .switch-user-btn":"onSwitchUserClick","click .users-btn":"onUsersClick","click .sign-in-btn":"onSignInClick","click .sign-out-btn":"onSignOutClick"},onlyAfterRender:["onSignedInChange","updateBadges"],bindings:{".username-header":{model:"user",modelAttribute:"title"}},initialize:function(){this.user=this.model.get("user"),this.invites=this.user.get("invites"),this.announcements=this.model.get("announcements"),this.image=new o({model:this.user,type:"friend",width:34}),this.listenTo(this.user,"change:signedIn",this.onSignedInChange),this.listenTo(this.user,"change:username",this.onUsernameChange),this.listenTo(this.user,"change:home",this.onHomeChange),this.listenTo(this.invites,"reset add remove",this.updateBadges),this.listenTo(this.announcements,"reset add remove change:isUnread",this.updateBadges),this.announcements.populate({reset:!0})
},serializeData:function(){var e=this.invites.length,t=this.getUnreadAnnouncementsCount();return{signedIn:this.user.get("signedIn"),home:this.user.get("home"),isFullUser:this.user.isFullUser(),invitesCount:e,unreadAnnouncementsCount:t,totalCount:e+t,appsUrl:this.user.server.get("appsUrl"),helpUrl:this.user.server.get("helpUrl"),defaultTarget:r.get("defaultTarget")}},getUnreadAnnouncementsCount:function(){var e=this.announcements.where({isUnread:!0});return this.user.hasPlexPass()&&(e=t.reject(e,function(e){return"PlexPass"===e.get("promo")
})),e.length},updateBadges:function(){var e=this.invites.length,t=this.getUnreadAnnouncementsCount(),i=e+t;this.ui.totalBadge.toggleClass("hidden",!i),this.ui.totalBadge.text(i),this.ui.invitesBadge.toggleClass("hidden",!e),this.ui.invitesBadge.text(e),this.ui.announcementsBadge.toggleClass("hidden",!t),this.ui.announcementsBadge.text(t)},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()},onSignedInChange:function(e,t){this.ui.dropdownMenu.toggleClass("signed-in",!!t)
},onUsernameChange:function(e,t){this.ui.dropdownMenu.toggleClass("full-user",!!t)},onHomeChange:function(e){this.ui.switchUserItem.toggleClass("hidden",!e.get("home"))},onSwitchUserClick:function(e){e.preventDefault(),s.trigger("show:modal",new l)},onUsersClick:function(e){e.preventDefault(),s.trigger("navigate","users")},onSignInClick:function(e){e.preventDefault(),s.trigger("navigate","login")},onSignOutClick:function(e){e.preventDefault(),a.execute("signOut").done(t.bind(function(){s.trigger("navigate:refresh:dashboard")
},this))}});return c}),define("plex/desktop/views/navbar/NavBarView",["hb!templates/desktop/navbar/NavBarView.tpl","hb!templates/desktop/tooltips/PlexPassTooltip.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/desktop/views/navbar/NavBarSearchView","plex/desktop/views/navbar/NavDropdown","plex/desktop/views/dropdowns/PrimaryPlayerDropdown"],function(e,t,i,n,s,a,r,o,l,c){"use strict";var d=n.Layout.extend({className:"nav-bar",template:e,sectionSearchDelay:500,ui:{backBtn:".back-btn",plexPassBtn:".plex-pass-btn",activityBtn:".activity-btn",activityBadge:".activity-badge"},regions:{search:".nav-bar-search-container",navDropdown:".nav-bar-right",playerDropdown:".nav-bar-right"},events:{"click .back-btn":"onBackClick","click .activity-btn":"onActivityClick"},modelEvents:{"change:history":"onHistoryChange","change:primaryServer":"onPrimaryServerChange"},onlyAfterRender:["onSignedInChange","onHistoryChange","onPrimaryServerChange","onNowPlayingChange"],initialize:function(){this.listenTo(this.model.get("user"),"change:signedIn",this.onSignedInChange),this.listenTo(s,"change:language",this.render),this.setupServerListeners()
},setupServerListeners:function(){if(this.primaryServer&&(this.stopListening(this.primaryServer),this.stopListening(this.primaryServer.get("sessions"))),this.primaryServer=this.model.get("primaryServer"),this.primaryServer){var e=this.primaryServer.get("sessions");this.listenTo(this.primaryServer,"change:shared",this.onPrimaryServerSharedChange),this.listenTo(e,{reset:this.onNowPlayingChange,add:this.onNowPlayingChange,remove:this.onNowPlayingChange})}},serializeData:function(){var e=this.model.get("user"),t=this.primaryServer&&this.primaryServer.get("sessions");
return{plexPassUrl:e.server.get("plexPassUrl"),hasHistory:this.hasHistory(),canGoPremium:this.canGoPremium(),showActivity:!(!this.primaryServer||this.primaryServer.get("shared")),activityCount:t&&t.length}},hasHistory:function(){var e=this.model.get("history");return e.length>1},canGoPremium:function(){var e=this.model.get("user");return e.get("signedIn")&&!e.get("restricted")&&!e.hasPlexPass()},showPlexPassTooltip:function(){this.canGoPremium()&&!a.get("hasSeenHolidayTooltip")&&i.defer(i.bind(function(){this.isClosed||(a.save("hasSeenHolidayTooltip",!0),this.ui.plexPassBtn.focus())
},this))},onRender:function(){this.search.append(new o({model:this.model})),this.playerDropdown.append(new c({showNowPlaying:!0})),this.navDropdown.append(new l({model:this.model})),this.$el.tooltip({selector:'[data-toggle="tooltip"]',container:"body",placement:"bottom"}),this.ui.plexPassBtn.tooltip({container:"body",placement:"bottom",template:'<div class="tooltip tooltip-plex-pass" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:t(),html:!0,trigger:"hover focus"}),this.showPlexPassTooltip()
},onSignedInChange:function(){this.ui.plexPassBtn.toggleClass("hidden",!this.canGoPremium()),this.showPlexPassTooltip()},onHistoryChange:function(){this.ui.backBtn.toggleClass("hidden",!this.hasHistory())},onPrimaryServerChange:function(e,t){this.setupServerListeners();var i=t&&!t.get("shared");this.ui.activityBtn.toggleClass("hidden",!i)},onPrimaryServerSharedChange:function(e,t){this.ui.activityBtn.toggleClass("hidden",!!t)},onNowPlayingChange:function(){var e=this.primaryServer.get("sessions"),t=e.length;
this.ui.activityBtn.parent("li").toggleClass("active",!!t),this.ui.activityBadge.toggleClass("hidden",!t),this.ui.activityBadge.text(t)},onBackClick:function(e){e.preventDefault(),s.trigger("navigate:back")},onActivityClick:function(e){e.preventDefault();var t=this.primaryServer&&this.primaryServer.get("sessions");t&&t.length?s.trigger("navigate","nowPlaying"):s.trigger("navigate","activity")}});return d}),define("plex/desktop/regions/ScrollableRegion",["underscore","jquery","marionette","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";
var s=i.Region.extend({resizeSubscribersCallbacks:[],scrollSubscribersCallbacks:[],sidebarDelay:200,scrollDelay:100,initialize:function(i){e.bindAll(this,"onResize","onScroll","onScrollEvent","onSidebarChange"),this.$el=t(this.el),this.channelName=i.channelName;var s={};s[this.channelName+".subscribe:resize"]=this.onResizeSubscribe,s[this.channelName+".unsubscribe:resize"]=this.onResizeUnsubscribe,s[this.channelName+".subscribe:scroll"]=this.onScrollSubscribe,s[this.channelName+".unsubscribe:scroll"]=this.onScrollUnsubscribe,this.listenTo(n,s)
},updateSize:function(){this.size={width:this.$el.width(),height:this.$el.height(),innerWidth:this.$el.innerWidth(),innerHeight:this.$el.innerHeight(),outerWidth:this.$el.outerWidth(),outerHeight:this.$el.outerHeight(),offset:this.$el.offset()}},updateScrollPosition:function(){this.scrollPosition={scrollHeight:this.$el[0].scrollHeight,scrollTop:this.$el[0].scrollTop}},onShow:function(){this.updateSize(),this.updateScrollPosition()},onResizeSubscribe:function(e){this.resizeSubscribersCallbacks.push(e),1===this.resizeSubscribersCallbacks.length&&(this.updateSize(),this.listenTo(n,{resize:this.onResize,"show:bar hide:bar":this.onSidebarChange})),e(this.size)
},onResizeUnsubscribe:function(t){this.resizeSubscribersCallbacks.splice(e.indexOf(this.resizeSubscribersCallbacks,t),1),0===this.resizeSubscribersCallbacks.length&&this.stopListening(n,"resize show:bar hide:bar")},onScrollSubscribe:function(e){this.scrollSubscribersCallbacks.push(e),1===this.scrollSubscribersCallbacks.length&&(this.updateScrollPosition(),this.$el.on("scroll",this.onScroll)),e(this.scrollPosition)},onScrollUnsubscribe:function(t){this.scrollSubscribersCallbacks.splice(e.indexOf(this.scrollSubscribersCallbacks,t),1),0===this.scrollSubscribersCallbacks.length&&this.$el.off("scroll",this.onScroll)
},onResize:function(){this.updateSize(),e.each(this.resizeSubscribersCallbacks,function(e){e(this.size)},this)},onScroll:function(){this.scrollTimeout=clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(this.onScrollEvent,this.scrollDelay)},onScrollEvent:function(){this.updateScrollPosition(),e.each(this.scrollSubscribersCallbacks,function(e){e(this.scrollPosition)},this)},onSidebarChange:function(t){"sidebar"===t&&e.delay(this.onResize,this.sidebarDelay)}});return s}),define("plex/desktop/views/DesktopAppView",["hb!templates/desktop/DesktopAppView.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/config","plex/desktop/views/LoadingView","plex/desktop/views/BackgroundView","plex/desktop/views/alerts/Alert","plex/desktop/views/alerts/StatusAlert","plex/desktop/views/players/VideoPlayerView","plex/desktop/views/players/VideoMiniPlayerView","plex/desktop/views/players/MusicMiniPlayerView","plex/desktop/views/players/PhotoPlayerView","plex/desktop/views/players/PhotoMiniPlayerView","plex/desktop/views/navbar/NavBarView","plex/desktop/views/alerts/AlertBarView","plex/desktop/regions/ScrollableRegion"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y,b,w){"use strict";
var x=n.Layout.extend({el:"#plex",template:e,resizeDelay:200,ui:{content:"#content",shadow:".scroll-shadow"},customRegions:{background:{prepend:!0,global:!0},content:{selector:"#content",global:!0,scrollable:!0,channelName:"content"},status:{prepend:!0,global:!0},player:{append:!0,global:!0},miniPlayer:{append:!0,global:!0},navbar:{modifier:"show-nav-bar",prepend:!0,global:!0},sidebar:{modifier:"show-side-bar",append:!0},actionbar:{modifier:"show-action-bar",append:!0},breadcrumbbar:{modifier:"show-breadcrumb-bar",append:!0},filterbar:{modifier:"show-filter-bar",append:!0},alphabar:{modifier:"show-alpha-bar",append:!0},alertbar:{modifier:"show-alert-bar",append:!0,global:!0}},openAlerts:{},initialize:function(){t.bindAll(this,"triggerResizeEvent","onResize","onScroll"),this.user=o.get("user"),this.modals=[],this.playerConstructors={full:{},mini:{}},this.playerConstructors.full[a.types.VIDEO]=p,this.playerConstructors.full[a.types.PHOTO]=g,this.playerConstructors.mini[a.types.VIDEO]=m,this.playerConstructors.mini[a.types.MUSIC]=f,this.playerConstructors.mini[a.types.PHOTO]=v,t.each(t.keys(this.customRegions),function(e){var i=this.customRegions[e],n=i.selector||t.uniqueId("r");
i.scrollable?this.addRegion(e,new w({el:n,channelName:i.channelName})):this.addRegion(e,n)},this),this.listenTo(o,{"change:authorized":this.onAuthorizedChange,"change:multiserver":this.onMultiserverChange}),this.listenTo(this.user,{"change:locked":this.onUserLockedChange}),this.listenTo(s,{"show:loading":this.showLoading,"show:view":this.showView,"show:alert":this.showAlert,"show:bar":this.showBar,"hide:bar":this.hideBar,"show:modal":this.showModal,"hide:modal":this.hideModal,"show:player":this.showPlayer,"hide:player":this.hidePlayer,"start:scrollListener":this.onStartScrollListener,"stop:scrollListener":this.onStopScrollListener,"update:scrollPosition":this.onUpdateScrollPosition}),i(window).on("resize",this.onResize)
},showCustomRegion:function(e,t){var i=this.customRegions[e],n=this[e];return this.user.get("locked")?(n.lockedView=t,void t.close()):void(i.append?n.append(t,this.$el):i.prepend?n.prepend(t,this.$el):n.show(t))},showLoading:function(){this.hideBar("alertbar"),this.user.get("locked")&&this.resetContentLockedRegions(),this.showCustomRegion("content",new c)},showView:function(e){i(".tooltip").remove(),this.hideBackground(),s.trigger("cycle:cache"),this.currentView=e,this.showCustomRegion("content",e),this.ui.content.scrollTop(0)
},showAlert:function(e){var t=e.message;if(!this.openAlerts[t]){var i=new u(e);this.openAlerts[t]=!0,this.listenToOnce(i,"close",function(){delete this.openAlerts[t]}),this.$el.append(i.render().el),i.triggerMethod("after:render",i)}},showBar:function(e,t){var i=this.customRegions[e],n=i.modifier;n&&this.$el.addClass(this.customRegions[e].modifier),t&&this.showCustomRegion(e,t)},hideBar:function(e,t){t||(t={});var i=this.customRegions[e],n=i.modifier;n&&this.$el.removeClass(n),t.preserve||(this[e].lockedView=null,this[e].close())
},showModal:function(e){this.modals.push(e);var t=i("body");e.transparent&&t.addClass("show-modal-transparent"),t.append(e.render().el)},hideModal:function(e){var n=t.indexOf(this.modals,e);n>-1&&this.modals.splice(n,1)[0].close(),e.transparent&&!t.findWhere(this.modals,{transparent:!0})&&i("body").removeClass("show-modal-transparent")},showPlayer:function(e){i(".tooltip").remove();var t=this.player.currentView,n=!!t&&t.playQueue===e.playQueue;if(e.controller||!n){var s,r=e.useMiniPlayer||e.type===a.types.MUSIC,l=o.get("primaryPlayer"),c=l&&"cast"===l.get("protocol"),d=c||e.type===a.types.VIDEO;
(d||e.isSwitchingPlayers)&&this.hidePlayer(),r?(s=this.playerConstructors.mini[e.type],this.showCustomRegion("miniPlayer",new s(e)),this.$el.addClass("show-mini-player")):(s=this.playerConstructors.full[e.type],this.showCustomRegion("player",new s(e)))}},hidePlayer:function(e){e?(this.miniPlayer.currentView===e&&(this.miniPlayer.close(),this.$el.removeClass("show-mini-player")),this.player.currentView===e&&this.player.close()):(this.miniPlayer.close(),this.$el.removeClass("show-mini-player"),this.player.close())
},hideBackground:function(){if(this.currentView&&this.currentView.model){var e=this.currentView.model;s.trigger("hide:background",e),r.execute("playSound",{key:e.get("key"),stop:!0,background:!0})}},lockAll:function(){var e=t.map(t.keys(this.customRegions),function(e){return this[e]},this);t.each(e,function(e){e.lockedView=e.currentView,e.close()},this)},resetContentLockedRegions:function(){t.each(t.keys(this.customRegions),function(e){var t=this.customRegions[e];if(!t.global){var i=this[e];i.lockedView&&(i.lockedView=null)
}},this)},restoreAll:function(){t.each(t.keys(this.customRegions),function(e){var t=this[e],i=t.lockedView;i&&(this.showCustomRegion(e,new i.constructor(i.options)),t.lockedView=null)},this)},triggerResizeEvent:function(){s.trigger("resize")},onRender:function(){this.showCustomRegion("background",new d),this.showCustomRegion("status",new h)},onAuthorizedChange:function(e,i){if(i){this.showBar("navbar",new y({model:o}),{prepend:!0});var n=l.get("alerts");n&&n.length&&(l.set("alerts",null),this.showBar("alertbar",new b({alert:t.first(n)})))
}else this.hideBar("navbar"),this.hidePlayer()},onMultiserverChange:function(e,t){this.$el.toggleClass("show-multiserver",t)},onUserLockedChange:function(e,t){t?this.lockAll():(t===!1||null===t)&&this.restoreAll()},onResize:function(){this.resizeTimeout=clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(this.triggerResizeEvent,this.resizeDelay)},onStartScrollListener:function(){this.ui.content.on("scroll",this.onScroll)},onStopScrollListener:function(){this.ui.content.off("scroll",this.onScroll),this.ui.shadow.addClass("transition-out")
},onScroll:function(){var e=this.ui.content.scrollTop();this.ui.shadow.toggleClass("transition-out",10>e)},onUpdateScrollPosition:function(e){this.ui.content[0].scrollTop=e}});return x}),define("hb!templates/desktop/dashboard/DashboardView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="priority-1-container"></div>\n<div class="priority-2-container"></div>\n<div class="priority-3-container"></div>\n<div class="priority-4-container"></div>\n<div class="priority-5-container"></div>\n'
})}),define("hb!templates/desktop/sidebar/DashboardSideBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="dashboard-empty-servers-container"></div>\n<div class="dashboard-servers-container"></div>\n'})}),define("hb!templates/desktop/dashboard/DashboardEmptyServersView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"None of your shared libraries are available.",s):p.call(e,"t","None of your shared libraries are available.",s)))+"</p>\n"
}function r(e,t){var n;return n=i["if"].call(e,e&&e.isManagedUser,{hash:{},inverse:f.program(6,l,t),fn:f.program(4,o,t),data:t}),n||0===n?n:""}function o(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"No one in your home has shared a library with you.",s):p.call(e,"t","No one in your home has shared a library with you.",s)))+"</p>\n"}function l(e,t){var n;return n=i["if"].call(e,e&&e.bundled,{hash:{},inverse:f.program(9,d,t),fn:f.program(7,c,t),data:t}),n||0===n?n:""
}function c(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"You do not have permission to access this server.",s):p.call(e,"t","You do not have permission to access this server.",s)))+"</p>\n"}function d(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"We couldn't find any media servers for you. {1}Download and install{2} one, be sure to {3}sign the server in{4}, and it'll appear here.","<a href='https://plex.tv/downloads' target='_blank'>","</a>","<a href='https://support.plex.tv/hc/en-us/articles/200878643-Sign-in-to-Your-Plex-Account' target='_blank'>","</a>",s):p.call(e,"t","We couldn't find any media servers for you. {1}Download and install{2} one, be sure to {3}sign the server in{4}, and it'll appear here.","<a href='https://plex.tv/downloads' target='_blank'>","</a>","<a href='https://support.plex.tv/hc/en-us/articles/200878643-Sign-in-to-Your-Plex-Account' target='_blank'>","</a>",s)))+"</p>\n  <p class=\"text-muted\"><a class='local-server-test-link' href='#'>",s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Already running a media server?",s):p.call(e,"t","Already running a media server?",s)))+"</a></p>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var u,h="",p=i.helperMissing,m=this.escapeExpression,f=this;return h+='<i class="plex-image server-sm"></i>\n\n',u=i["if"].call(t,t&&t.hasSharedServers,{hash:{},inverse:f.program(3,r,s),fn:f.program(1,a,s),data:s}),(u||0===u)&&(h+=u),h+="\n"})}),define("hb!templates/desktop/modals/LocalServerTestModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-info"></i> <span id="title">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Media Server Detection",r):l.call(t,"t","Media Server Detection",r)))+'</span></h4>\n    </div>\n\n    <div class="modal-body">\n      <div class="loading loading-inline"></div>\n\n      <div class="server-found hidden">\n        ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"We've detected a Plex Media Server running on this computer, but we can't connect to it. {1}Sign in to your account{2} on the server so that you can access it.","<a href='http://127.0.0.1:32400/web/index.html#!/settings/server' target='_blank'>","</a>",r):l.call(t,"t","We've detected a Plex Media Server running on this computer, but we can't connect to it. {1}Sign in to your account{2} on the server so that you can access it.","<a href='http://127.0.0.1:32400/web/index.html#!/settings/server' target='_blank'>","</a>",r)))+'\n      </div>\n\n      <div class="server-not-found hidden">\n        <p>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"We were unable to find a Plex Media Server running on this computer. If you have one on this or another computer, make sure it's running and signed in to your account.",r):l.call(t,"t","We were unable to find a Plex Media Server running on this computer. If you have one on this or another computer, make sure it's running and signed in to your account.",r)))+"</p>\n        <p>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"For more information, please see {1}this support article{2}.","<a href='http://help.plex.tv/noserver' target='_blank'>","</a>",r):l.call(t,"t","For more information, please see {1}this support article{2}.","<a href='http://help.plex.tv/noserver' target='_blank'>","</a>",r)))+'</p>\n      </div>\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="confirm-btn btn btn-lg btn-primary">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"OK",r):l.call(t,"t","OK",r)))+"</button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/LocalServerTestModal",["hb!templates/desktop/modals/LocalServerTestModal.tpl","underscore","jquery","plex/base/commands/commands","plex/base/models/server/ServerModel","plex/desktop/views/modals/BaseModal"],function(e,t,i,n,s,a){"use strict";var r=a.extend({name:"localServerTestModal",className:"local-server-test-modal modal modal-sm fade",template:e,ui:{loadingIcon:".loading",serverFound:".server-found",serverNotFound:".server-not-found"},events:t.extend({"click .confirm-btn":"onConfirm"},a.prototype.events),initialize:function(){this.bindAllWhenRendered("onConnectionTestSuccess","onConnectionTestFailure");
var e=new s,t=e.addConnection({address:"127.0.0.1",port:32400}),i=n.execute("testServerImage",{server:e,connection:t});i.done(this.onConnectionTestSuccess),i.fail(this.onConnectionTestFailure),i.always(this.whenRendered(function(){this.ui.loadingIcon.addClass("hidden")}))},onConnectionTestSuccess:function(){this.ui.serverFound.removeClass("hidden")},onConnectionTestFailure:function(){this.ui.serverNotFound.removeClass("hidden")},onConfirm:function(){this.hide()}});return r}),define("plex/desktop/views/dashboard/DashboardEmptyServersView",["hb!templates/desktop/dashboard/DashboardEmptyServersView.tpl","marionette","plex/base/models/config","plex/base/utils/dispatcher","plex/desktop/views/modals/LocalServerTestModal"],function(e,t,i,n,s){"use strict";
var a=t.ItemView.extend({className:"dashboard-empty-servers-message",template:e,events:{"click .local-server-test-link":"onLocalServerTestClick"},serializeData:function(){return{hasSharedServers:this.options.hasSharedServers,isManagedUser:this.options.isManagedUser,bundled:i.get("bundled")}},onLocalServerTestClick:function(e){e.preventDefault(),n.trigger("show:modal",new s)}});return a}),define("hb!templates/desktop/lists/dashboard/DashboardServerListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n  <div class="side-bar-actions pull-right ',n=i["if"].call(e,e&&e.signedIn,{hash:{},inverse:_.noop,fn:_.program(2,r,t),data:t}),(n||0===n)&&(a+=n),a+='">\n    ',s=i["if"].call(e,(n=e&&e.server,null==n||n===!1?n:n.connected),{hash:{},inverse:_.noop,fn:_.program(4,o,t),data:t}),(s||0===s)&&(a+=s),a+='\n\n    <span id="'+A((n=e&&e.server,n=null==n||n===!1?n:n.machineIdentifier,typeof n===I?n.apply(e):n))+'-dropdown" class="dropdown">\n      <a class="btn-gray dropdown-toggle" href="#'+A((n=e&&e.server,n=null==n||n===!1?n:n.machineIdentifier,typeof n===I?n.apply(e):n))+'-dropdown" data-toggle="dropdown"><i class="glyphicon cogwheel"></i> <i class="caret-icon caret-icon-sm"></i></a>\n\n      <ul class="dropdown-menu pull-right">\n        ',s=i["if"].call(e,(n=e&&e.server,null==n||n===!1?n:n.connected),{hash:{},inverse:_.program(11,u,t),fn:_.program(6,l,t),data:t}),(s||0===s)&&(a+=s),a+="\n      </ul>\n    </span>\n  </div>\n"
}function r(){return"signed-in"}function o(){return'\n      <a class="add-library-btn btn-gray" href="#"><i class="glyphicon plus"></i></a>\n    '}function l(e,t){var n,s,a,r="";return r+='\n          <li><a class="settings-btn" href="#"><span class="dropdown-truncated-label">',a={hash:{},data:t},r+=A((n=i.t||e&&e.t,n?n.call(e,"Settings",a):P.call(e,"t","Settings",a)))+'</span></a></li>\n          <li class="signed-in-item"><a class="share-btn" href="#"><span class="dropdown-truncated-label">',a={hash:{},data:t},r+=A((n=i.t||e&&e.t,n?n.call(e,"Share...",a):P.call(e,"t","Share...",a)))+'</span></a></li>\n          <li><a class="update-btn" href="#"><span class="dropdown-truncated-label">',s=i["if"].call(e,e&&e.hasRefreshingSection,{hash:{},inverse:_.program(9,d,t),fn:_.program(7,c,t),data:t}),(s||0===s)&&(r+=s),r+='</span></a></li>\n          <li><a class="optimize-btn" href="#"><span class="dropdown-truncated-label">',a={hash:{},data:t},r+=A((n=i.t||e&&e.t,n?n.call(e,"Optimize",a):P.call(e,"t","Optimize",a)))+'</span></a></li>\n          <li><a class="clean-bundles-btn" href="#"><span class="dropdown-truncated-label">',a={hash:{},data:t},r+=A((n=i.t||e&&e.t,n?n.call(e,"Clean Bundles",a):P.call(e,"t","Clean Bundles",a)))+'</span></a></li>\n          <li><a class="empty-trash-btn" href="#"><span class="dropdown-truncated-label">',a={hash:{},data:t},r+=A((n=i.t||e&&e.t,n?n.call(e,"Empty Trash",a):P.call(e,"t","Empty Trash",a)))+"</span></a></li>\n        "
}function c(e,t){var n,s;return s={hash:{},data:t},A((n=i.t||e&&e.t,n?n.call(e,"Cancel Update",s):P.call(e,"t","Cancel Update",s)))}function d(e,t){var n,s;return s={hash:{},data:t},A((n=i.t||e&&e.t,n?n.call(e,"Update Libraries",s):P.call(e,"t","Update Libraries",s)))}function u(e,t){var n,s,a="";return a+='\n          <li class="signed-in-item"><a class="share-btn" href="#"><span class="dropdown-truncated-label">',s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"Share...",s):P.call(e,"t","Share...",s)))+'</span></a></li>\n          <li><a class="remove-btn has-danger" href="#"><span class="dropdown-truncated-label">',s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"Remove",s):P.call(e,"t","Remove",s)))+"</span></a></li>\n        "
}function h(){return"selected"}function p(){return"disabled"}function m(){return"show-actions"}function f(){return'<i class="cloud-sync-icon glyphicon cloud"></i>'}function g(){return"hidden"}function v(e,t){var n,s,a="";return a+='\n  <span class="mixed-content-error">',s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"We're sorry, but we can't reach this server.",s):P.call(e,"t","We're sorry, but we can't reach this server.",s)))+"</span>\n"}function y(e,t){var n;return n=i["if"].call(e,e&&e.showMixedContentMessage,{hash:{},inverse:_.noop,fn:_.program(26,b,t),data:t}),n||0===n?n:""
}function b(e,t){var n,s,a="";return a+='\n  <span class="mixed-content-error">',s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"We're sorry, but we can't reach this server securely. {1}Click here{2} to reload the app using insecure connections.","<a class='mixed-content-btn' href='#' target='_blank'>","</a>",s):P.call(e,"t","We're sorry, but we can't reach this server securely. {1}Click here{2} to reload the app using insecure connections.","<a class='mixed-content-btn' href='#' target='_blank'>","</a>",s)))+" <a href='https://support.plex.tv/hc/en-us/articles/206225077'>",s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"More Info",s):P.call(e,"t","More Info",s)))+"</a></span>\n"
}function w(e,t){var n,s,a="";return a+='\n    <li>\n      <a class="btn-gray" href="#!/server/',s={hash:{},data:t},a+=A((n=i.encodeUrl||e&&e.encodeUrl,n?n.call(e,(n=e&&e.server,null==n||n===!1?n:n.machineIdentifier),s):P.call(e,"encodeUrl",(n=e&&e.server,null==n||n===!1?n:n.machineIdentifier),s)))+'/channels">\n        <i class="section-icon glyphicon show-big-thumbnails"></i> ',s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"Channels",s):P.call(e,"t","Channels",s)))+"\n      </a>\n    </li>\n  "
}function x(e,t){var n,s,a="";return a+='\n    <li>\n      <a class="btn-gray" href="#!/server/',s={hash:{},data:t},a+=A((n=i.encodeUrl||e&&e.encodeUrl,n?n.call(e,(n=e&&e.server,null==n||n===!1?n:n.machineIdentifier),s):P.call(e,"encodeUrl",(n=e&&e.server,null==n||n===!1?n:n.machineIdentifier),s)))+'/playlists">\n        <i class="section-icon plex-icon playlist-alt"></i> ',s={hash:{},data:t},a+=A((n=i.t||e&&e.t,n?n.call(e,"Playlists",s):P.call(e,"t","Playlists",s)))+"\n      </a>\n    </li>\n  "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var k,S,C="",P=i.helperMissing,A=this.escapeExpression,_=this,I="function";return k=i["if"].call(t,t&&t.showActions,{hash:{},inverse:_.noop,fn:_.program(1,a,s),data:s}),(k||0===k)&&(C+=k),C+='\n\n<h5>\n  <a class="select-server-btn ',k=i["if"].call(t,t&&t.selected,{hash:{},inverse:_.noop,fn:_.program(13,h,s),data:s}),(k||0===k)&&(C+=k),C+=" ",k=i.unless.call(t,t&&t.canBePrimary,{hash:{},inverse:_.noop,fn:_.program(15,p,s),data:s}),(k||0===k)&&(C+=k),C+='" href="#">\n    <span class="server-title ',k=i["if"].call(t,t&&t.showActions,{hash:{},inverse:_.noop,fn:_.program(17,m,s),data:s}),(k||0===k)&&(C+=k),C+='">'+A((k=t&&t.server,k=null==k||k===!1?k:k.friendlyName,typeof k===I?k.apply(t):k))+"</span>\n  </a>\n  ",S=i["if"].call(t,(k=t&&t.server,null==k||k===!1?k:k.isCloudSync),{hash:{},inverse:_.noop,fn:_.program(19,f,s),data:s}),(S||0===S)&&(C+=S),C+='\n  <i class="secure-connection-icon plex-icon padlock-round ',S=i.unless.call(t,t&&t.hasSecureConnection,{hash:{},inverse:_.noop,fn:_.program(21,g,s),data:s}),(S||0===S)&&(C+=S),C+=" ",S=i.unless.call(t,(k=t&&t.server,null==k||k===!1?k:k.connected),{hash:{},inverse:_.noop,fn:_.program(21,g,s),data:s}),(S||0===S)&&(C+=S),C+='"></i>\n</h5>\n\n',S=i["if"].call(t,t&&t.showUnavailableMessage,{hash:{},inverse:_.program(25,y,s),fn:_.program(23,v,s),data:s}),(S||0===S)&&(C+=S),C+='\n\n<ul class="list side-bar-list dashboard-section-list ',S=i.unless.call(t,(k=t&&t.server,null==k||k===!1?k:k.connected),{hash:{},inverse:_.noop,fn:_.program(21,g,s),data:s}),(S||0===S)&&(C+=S),C+='">\n  ',S=i["if"].call(t,t&&t.showChannels,{hash:{},inverse:_.noop,fn:_.program(28,w,s),data:s}),(S||0===S)&&(C+=S),C+="\n\n  ",S=i["if"].call(t,t&&t.showPlaylists,{hash:{},inverse:_.noop,fn:_.program(30,x,s),data:s}),(S||0===S)&&(C+=S),C+="\n</ul>\n"
})}),define("hb!templates/desktop/lists/dashboard/DashboardSectionListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"active"}function r(){return'\n    <div class="section-actions pull-right">\n      <button class="edit-section-btn btn-gray" href="#"><i class="glyphicon pencil"></i></button>\n    </div>\n  '}function o(){return"show-actions"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h=this,p=i.helperMissing,m=this.escapeExpression,f="function";
return u+='<a class="btn-gray btn-loading btn-loading-static ',l=i["if"].call(t,t&&t.refreshing,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(l||0===l)&&(u+=l),u+='" href="#!/server/',d={hash:{},data:s},u+=m((l=i.encodeUrl||t&&t.encodeUrl,l?l.call(t,t&&t.serverID,d):p.call(t,"encodeUrl",t&&t.serverID,d)))+"/section/",d={hash:{},data:s},u+=m((l=i.encodeUrl||t&&t.encodeUrl,l?l.call(t,(l=t&&t.section,null==l||l===!1?l:l.key),d):p.call(t,"encodeUrl",(l=t&&t.section,null==l||l===!1?l:l.key),d)))+'">\n  ',c=i["if"].call(t,t&&t.showActions,{hash:{},inverse:h.noop,fn:h.program(3,r,s),data:s}),(c||0===c)&&(u+=c),u+='\n  <div class="loading loading-xs"></div>\n  <i class="btn-label section-icon glyphicon ',(c=i.icon)?c=c.call(t,{hash:{},data:s}):(c=t&&t.icon,c=typeof c===f?c.call(t,{hash:{},data:s}):c),u+=m(c)+'"></i> <span class="section-title ',c=i["if"].call(t,t&&t.showActions,{hash:{},inverse:h.noop,fn:h.program(5,o,s),data:s}),(c||0===c)&&(u+=c),u+='"></span>\n</a>\n'
})}),define("hb!templates/desktop/modals/EditSectionModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n          <i class="modal-icon glyphicon plus"></i> ',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Add {1} Library",'<span class="section-type-title"></span>',s):b.call(e,"t","Add {1} Library",'<span class="section-type-title"></span>',s)))+"\n        "}function r(e,t){var n,s,a="";return a+='\n          <i class="modal-icon glyphicon pencil"></i> ',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Edit Library",s):b.call(e,"t","Edit Library",s)))+"\n        "
}function o(){return" selected"}function l(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Select type",s):b.call(e,"t","Select type",s)))+"\n              "}function c(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"General",s):b.call(e,"t","General",s)))+"\n              "}function d(){return"disabled"}function u(e,t){var n,s,a,r="";return r+='\n            <li>\n              <a class="btn-gray change-pane-btn create-btn',a={hash:{},inverse:x.noop,fn:x.program(5,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.selectedPane,"create",a):b.call(e,"if_eq",e&&e.selectedPane,"create",a),(s||0===s)&&(r+=s),r+=" ",s=i["if"].call(e,e&&e.add,{hash:{},inverse:x.noop,fn:x.program(11,d,t),data:t}),(s||0===s)&&(r+=s),r+=' hidden" data-pane="create" href="#">\n                <i class="modal-nav-icon glyphicon magic"></i>\n                ',a={hash:{},data:t},r+=w((n=i.t||e&&e.t,n?n.call(e,"Create",a):b.call(e,"t","Create",a)))+"\n              </a>\n            </li>\n          "
}function h(e,t){var n,s,a="";return a+='\n        <button type="button" class="delete-btn btn btn-danger pull-left" data-dismiss="modal">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Delete Library",s):b.call(e,"t","Delete Library",s)))+"</button>\n      "}function p(e,t){var n,s,a="";return a+="\n              ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Add Library",s):b.call(e,"t","Add Library",s)))+"\n            "}function m(e,t){var n,s,a="";return a+="\n              ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Save Changes",s):b.call(e,"t","Save Changes",s)))+"\n            "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var f,g,v,y="",b=i.helperMissing,w=this.escapeExpression,x=this;return y+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        ',f=i["if"].call(t,t&&t.add,{hash:{},inverse:x.program(3,r,s),fn:x.program(1,a,s),data:s}),(f||0===f)&&(y+=f),y+='\n      </h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll modal-body-with-panes">\n      <div class="modal-nav-pane dark-scrollbar">\n        <ul class="list modal-nav-list">\n          <li>\n            <a class="btn-gray change-pane-btn type-btn',v={hash:{},inverse:x.noop,fn:x.program(5,o,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedPane,"type",v):b.call(t,"if_eq",t&&t.selectedPane,"type",v),(g||0===g)&&(y+=g),y+='" data-pane="type" href="#">\n              <i class="modal-nav-icon glyphicon align-center"></i>\n              ',g=i["if"].call(t,t&&t.add,{hash:{},inverse:x.program(9,c,s),fn:x.program(7,l,s),data:s}),(g||0===g)&&(y+=g),y+='\n            </a>\n          </li>\n\n          <li>\n            <a class="btn-gray change-pane-btn folders-btn',v={hash:{},inverse:x.noop,fn:x.program(5,o,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedPane,"folders",v):b.call(t,"if_eq",t&&t.selectedPane,"folders",v),(g||0===g)&&(y+=g),y+=" ",g=i["if"].call(t,t&&t.add,{hash:{},inverse:x.noop,fn:x.program(11,d,s),data:s}),(g||0===g)&&(y+=g),y+='" data-pane="folders" href="#">\n              <i class="modal-nav-icon glyphicon folder-open"></i>\n              ',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Add folders",v):b.call(t,"t","Add folders",v)))+"\n            </a>\n          </li>\n\n          ",g=i["if"].call(t,t&&t.add,{hash:{},inverse:x.noop,fn:x.program(13,u,s),data:s}),(g||0===g)&&(y+=g),y+='\n\n          <li>\n            <a class="btn-gray change-pane-btn advanced-btn',v={hash:{},inverse:x.noop,fn:x.program(5,o,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedPane,"advanced",v):b.call(t,"if_eq",t&&t.selectedPane,"advanced",v),(g||0===g)&&(y+=g),y+=" ",g=i["if"].call(t,t&&t.add,{hash:{},inverse:x.noop,fn:x.program(11,d,s),data:s}),(g||0===g)&&(y+=g),y+='" data-pane="advanced" href="#">\n              <i class="modal-nav-icon glyphicon cogwheel"></i>\n              ',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Advanced",v):b.call(t,"t","Advanced",v)))+'\n            </a>\n          </li>\n        </ul>\n      </div>\n\n      <div class="modal-body-pane pane-region dark-scrollbar">\n      </div>\n    </div>\n\n    <div class="modal-footer">\n      ',g=i["if"].call(t,t&&t.edit,{hash:{},inverse:x.noop,fn:x.program(15,h,s),data:s}),(g||0===g)&&(y+=g),y+='\n\n      <span class="form-message"></span>\n\n      <button type="button" class="cancel-btn btn btn-default" data-dismiss="modal">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Cancel",v):b.call(t,"t","Cancel",v)))+'</button>\n      <button type="button" class="save-btn btn btn-primary btn-loading ',g=i["if"].call(t,t&&t.add,{hash:{},inverse:x.noop,fn:x.program(11,d,s),data:s}),(g||0===g)&&(y+=g),y+='">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">\n          <span class="save-btn-label-next">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Next",v):b.call(t,"t","Next",v)))+'</span>\n          <span class="save-btn-label-save">\n            ',g=i["if"].call(t,t&&t.add,{hash:{},inverse:x.program(19,m,s),fn:x.program(17,p,s),data:s}),(g||0===g)&&(y+=g),y+="\n          </span>\n        </span>\n      </button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/base/models/library/AgentModel",["underscore","jquery","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i,n){"use strict";var s=n.extend({idAttribute:"identifier",whitelistedAttrs:["identifier","name","enabled","hasPrefs","language"],convert:function(t){var n=e.isObject(t)?t:i.parseXML(t);return i.parseBoolean(n,["enabled","hasPrefs"]),i.parseArray(n,["Language"]),n},parse:function(t){var i=this.convert(t);return i.language=e.pluck(i.Language,"code"),i=e.pick(i,this.whitelistedAttrs)
},fetchAttribution:function(){var i=this.server.getXHROptions("/system/agents/attribution?identifier="+this.id),n=t.ajax(i);return n.done(e.bind(function(e){this.set("attribution",e)},this)),n}});return s}),define("plex/base/models/library/AgentCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/AgentModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){return this.primaryAgent?"system/agents/contributors?mediaType="+this.mediaTypeID+"&primaryAgent="+this.primaryAgent:this.relatedAgent?"system/agents/"+this.relatedAgent+"/config/"+this.mediaTypeID:this.mediaTypeID?"system/agents?mediaType="+this.mediaTypeID:"system/agents"
},initialize:function(e,t){this.primaryAgent=t.primaryAgent,this.relatedAgent=t.relatedAgent,this.sectionType=t.sectionType,this.mediaTypeID=this.sectionType?this.sectionType.typeID:t.mediaTypeID},parse:function(e){return this.convert(e,"Agent")},hasExclusiveAgent:function(t){var i=this.map(function(e){return e.get("identifier")});return!!e.intersection(i,t).length}});return n}),define("plex/base/models/library/ScannerModel",["plex/base/models/BaseModel"],function(e){"use strict";var t=e.extend({idAttribute:"name"});
return t}),define("plex/base/models/library/ScannerCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/library/ScannerModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){return"system/scanners/"+this.sectionType.typeID},initialize:function(e,t){this.sectionType=t.sectionType},parse:function(e){return this.convert(e,"Scanner")},hasExclusiveScanner:function(t){var i=this.map(function(e){return e.get("name")});return!!e.intersection(i,t).length}});return n
}),define("plex/base/models/library/ExclusiveAgentProxy",["underscore","backbone.obscura"],function(e,t){"use strict";var i=t.extend({constructor:function(i,n,s,a){this.exclusiveAgents=n,this.agentIdentifier=s,t.call(this,i,a),this.filterBy(e.bind(this.filterExclusiveAgent,this))},filterExclusiveAgent:function(e){var t=e.get("identifier"),i=this.exclusiveAgents;if(!i)return!0;var n=this.agentIdentifier,s=-1!==i.indexOf(n),a=-1!==i.indexOf(t),r=s?t==n:!a;return r}});return i}),define("hb!templates/desktop/section/edit/EditSectionAdvancedView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l="function",c=this.escapeExpression,d=i.helperMissing;return o+='<form class="edit-section-advanced-form settings-container">\n  <div class="language-group">\n    <input type="hidden" name="language" value="'+c((a=t&&t.section,a=null==a||a===!1?a:a.language,typeof a===l?a.apply(t):a))+'">\n  </div>\n\n  <div class="row">\n    <div class="col-md-12">\n      <div class="form-group scanner-group hidden">\n        <label for="edit-section-scanner" class="control-label">\n          ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Scanner",r):d.call(t,"t","Scanner",r)))+'\n          <span class="control-error">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"A scanner is required.",r):d.call(t,"t","A scanner is required.",r)))+'</span>\n        </label>\n        <select id="edit-section-scanner" name="scanner"></select>\n      </div>\n    </div>\n  </div>\n\n  <div class="row">\n    <div class="col-md-12">\n      <div class="form-group agent-group hidden">\n        <label for="edit-section-agent" class="control-label">\n          ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Agent",r):d.call(t,"t","Agent",r)))+'\n          <span class="control-error">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"An agent is required.",r):d.call(t,"t","An agent is required.",r)))+'</span>\n        </label>\n        <select id="edit-section-agent" name="agent"></select>\n      </div>\n    </div>\n  </div>\n\n  <div class="row">\n    <div class="col-md-12 section-settings-region"></div>\n  </div>\n\n  <div class="row">\n    <div class="col-md-12 section-agent-settings-region"></div>\n  </div>\n</form>\n'
})}),define("plex/base/models/library/ExclusiveScannerProxy",["underscore","backbone.obscura"],function(e,t){"use strict";var i=t.extend({constructor:function(i,n,s,a){this.exclusiveScanners=n,this.scannerName=s,t.call(this,i,a),this.filterBy(e.bind(this.filterExclusiveScanner,this))},filterExclusiveScanner:function(e){var t=e.get("name"),i=(this.sectionType,this.exclusiveScanners);if(!i)return!0;var n=this.scannerName,s=-1!==i.indexOf(n),a=-1!==i.indexOf(t),r=s?t==n:!a;return r}});return i}),define("plex/desktop/views/editsection/EditSectionBaseView",["underscore","jquery","marionette","plex/base/utils/types/sectionTypes","plex/base/models/library/AgentCollection","plex/base/models/library/ScannerCollection","plex/base/models/library/ExclusiveAgentProxy","plex/base/models/library/ExclusiveScannerProxy","plex/base/models/server/ServerSettingCollection"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=i.Layout.extend({ui:{formGroup:".form-group"},onlyAfterRender:["showValidationResult"],serializeData:function(){var e={};return this.model.isNew()?e.add=!0:e.edit=!0,e.section=this.model.toJSON(),e},showValidationResult:function(t){var i=this.ui.formGroup;i.removeClass("has-error"),e.each(t,function(e){i.filter("."+e+"-group").addClass("has-error")}),this.trigger(t.length?"invalid":"valid")},createMenuOptions:function(t,i){return e.map(t,function(e){return'<option value="'+e.value+'"'+(e.value===i?" selected":"")+">"+e.label+"</option>"
}).join("\n")},getSectionType:function(){if(this.model.sectionType)return this.model.sectionType;var e=this.model.get("type"),t=n.getSectionType(e)||n.getSectionTypeByString(e);return this.model.sectionType=t,t},setSectionType:function(e){this.model.sectionType=e},populateAgents:function(){var e=this.getSectionType();if(!e)return t.Deferred().reject().promise();var i={server:this.model.server,sectionType:e};return this.model.agents||(this.model.agents=new s([],i)),this.model.agents.populate().then(function(e){return e
})},populateScanners:function(){var e=this.getSectionType();return e?(this.model.scanners||(this.model.scanners=new a([],{server:this.model.server,sectionType:e})),this.model.scanners.populate().then(function(e){return e})):t.Deferred().reject().promise()},populateAgentsProxy:function(){var e=this.getSectionType().exclusiveAgents,i=new r(this.model.agents,e,this.model.get("agent"));return this.model.agentsProxy=i,t.Deferred().resolve(i).promise()},populateScannersProxy:function(){var e=this.getSectionType().exclusiveScanners,i=new o(this.model.scanners,e,this.model.get("scanner"));
return this.model.scannersProxy=i,t.Deferred().resolve(i).promise()},populateSectionSettings:function(){if(!this.model.server.supports("sectionSettings"))return t.Deferred().resolve().promise();if(!this.model.settings){var e=new l([],{server:this.model.server});if(this.model.isNew()){var i={type:this.getSectionType().typeID,agent:this.model.get("agent")};e.url="/library/sections/prefs?"+t.param(i,!0)}else e.url="/library/sections/"+this.model.id+"/prefs";this.model.settings=e}var n=this.model.settings.populate();
return n},populateSectionAgentSettings:function(){if(!this.model.agentSettings){var e=new l([],{server:this.model.server,url:"/:/plugins/"+this.model.get("agent")+"/prefs"});this.model.agentSettings=e}var t=this.model.agentSettings.populate();return t},onModalClose:function(){this.model.scanners=null,this.model.scannersProxy=null,this.model.agents=null,this.model.agentsProxy=null,this.model.settings=null}});return c}),define("hb!templates/desktop/section/edit/EditSectionSettingView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n  <div class="form-group">\n    <label class="control-label" for="input_importFromItunes_c">\n      <input type="checkbox" id="input_importFromItunes_c" name="importFromiTunes" value="1" ',n=i["if"].call(e,e&&e.value,{hash:{},inverse:h.noop,fn:h.program(2,r,t),data:t}),(n||0===n)&&(a+=n),a+="> ",s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Import from iTunes",s):p.call(e,"t","Import from iTunes",s)))+'\n    </label>\n\n    <p class="help-block">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Importing from iTunes will import your music playlists. It will also import your ratings, the date you added the music, as well as play and skip counts for tracks in your library.",s):p.call(e,"t","Importing from iTunes will import your music playlists. It will also import your ratings, the date you added the music, as well as play and skip counts for tracks in your library.",s)))+"</p>\n  </div>\n"
}function r(){return"checked"}function o(e,t,n){var s,a,r,o="";return o+="\n  ",r={hash:{idSuffix:"_c"},data:t},o+=m((s=i.partial||e&&e.partial,s?s.call(e,"setting",r):p.call(e,"partial","setting",r)))+"\n\n  ",a=i["if"].call(e,n&&n.edit,{hash:{},inverse:h.noop,fn:h.program(5,l,t),data:t}),(a||0===a)&&(o+=a),o+="\n"}function l(e,t){var n,s,a,r="";return r+="\n    ",a={hash:{},inverse:h.noop,fn:h.program(6,c,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.id,"enableBIFGeneration",a):p.call(e,"if_eq",e&&e.id,"enableBIFGeneration",a),(s||0===s)&&(r+=s),r+="\n  "
}function c(e,t){var n,s,a="";return a+='\n      <div class="form-group">\n        <button type="button" class="delete-thumbnails-btn btn btn-danger">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Delete Preview Thumbnails",s):p.call(e,"t","Delete Preview Thumbnails",s)))+"</button>\n      </div>\n    "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var d,u="",h=this,p=i.helperMissing,m=this.escapeExpression;return d=i["if"].call(t,t&&t.isNewMusicSection,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(d||0===d)&&(u+=d),u+="\n\n",d=i.each.call(t,t&&t.settings,{hash:{},inverse:h.noop,fn:h.programWithDepth(4,o,s,t),data:s}),(d||0===d)&&(u+=d),u+="\n"
})}),define("plex/desktop/views/editsection/EditSectionSettingView",["hb!templates/desktop/section/edit/EditSectionSettingView.tpl","jquery","marionette"],function(e,t,i){"use strict";var n=i.ItemView.extend({template:e,events:{"change [name]":"onEditSectionSettingInputChange"},serializeData:function(){var e=this.model.isNew(),t="music"===this.model.get("type"),i={settings:this.collection.toJSON(),edit:!e,isNewMusicSection:e&&t&&this.model.server.supports("premiumMusic")};return i},onEditSectionSettingInputChange:function(e){var i=t(e.currentTarget),n=i.attr("name");
if("importFromiTunes"===n)return void this.model.set(n,1);var s=i.is(":checkbox")?i.prop("checked"):i.val(),a=this.collection.findWhere({id:n});a.set("value",s)}});return n}),define("hb!templates/desktop/editsection/EditSectionAgentSettingsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n  ",s={hash:{idSuffix:"_c"},data:t},a+=c((n=i.partial||e&&e.partial,n?n.call(e,"setting",s):l.call(e,"partial","setting",s)))+"\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var r,o="",l=i.helperMissing,c=this.escapeExpression,d=this;return r=i.each.call(t,t&&t.settings,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+="\n"})}),define("plex/desktop/views/editsection/EditSectionAgentSettingsView",["hb!templates/desktop/editsection/EditSectionAgentSettingsView.tpl","underscore","jquery","marionette"],function(e,t,i,n){"use strict";var s=n.ItemView.extend({template:e,events:{"change input[name]":"onInputChange","change select[name]":"onInputChange"},initialize:function(){this.changes={}
},serializeData:function(){return{settings:this.collection.toJSON()}},onInputChange:function(e){var t=i(e.currentTarget),n=t.is(":checkbox")?t.prop("checked"):t.val(),s=this.collection.findWhere({id:t.attr("name")});s.set("value",n)}});return s}),define("plex/desktop/views/editsection/EditSectionAdvancedView",["hb!templates/desktop/section/edit/EditSectionAdvancedView.tpl","underscore","jquery","plex/base/commands/commands","plex/base/utils/languageUtil","plex/base/utils/types/sectionTypes","plex/base/models/library/AgentCollection","plex/base/models/library/ScannerCollection","plex/desktop/views/editsection/EditSectionBaseView","plex/desktop/views/editsection/EditSectionSettingView","plex/desktop/views/editsection/EditSectionAgentSettingsView"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";
var u=l.extend({template:e,ui:t.extend({sectionAgent:"#edit-section-agent",sectionScanner:"#edit-section-scanner",thumbnailsCheckbox:'input[name="enableBIFGeneration"]',agentGroup:".agent-group",scannerGroup:".scanner-group"},l.prototype.ui),events:{"change #edit-section-agent":"onEditSectionAgentChange","change #edit-section-scanner":"onEditSectionScannerChange","click .delete-thumbnails-btn":"onThumbnailsDeleteClick"},regions:{sectionSettingsRegion:".section-settings-region",agentSettingsRegion:".section-agent-settings-region"},onlyAfterRender:["renderSectionAgent","renderSectionScanner","renderSectionSettings","renderSectionAgentSettings"].concat(l.prototype.onlyAfterRender),initialize:function(){this.populateCollections()
},onRender:function(){this.model.agents.populate(),this.model.scanners.populate()},validate:function(e){var t=[];return e.get("agent")||t.push("agent"),e.get("scanner")||t.push("scanner"),t},renderSectionSettings:function(){var e=new c({model:this.model,collection:this.model.settings});this.sectionSettingsRegion.show(e)},renderSectionAgentSettings:function(){var e=new d({model:this.model,collection:this.model.agentSettings});this.agentSettingsRegion.show(e)},populateCollections:function(){var e=this.populateAgents(),n=this.populateScanners(),s=this.populateSectionSettings(),a=this.populateSectionAgentSettings();
return this.populateAgentsProxy(),this.populateScannersProxy(),e.then(t.bind(this.onAgentsPopulate,this)),n.then(t.bind(this.onScannersPopulate,this)),s.then(t.bind(this.renderSectionSettings,this)),a.then(t.bind(this.renderSectionAgentSettings,this)),i.when(e,n,s,a).then(t.bind(this.validate,this,this.model))},renderSectionAgent:function(){var e=this.model.agentsProxy,t=this.createMenuOptions(e.map(function(e){return{label:e.get("name"),value:e.get("identifier")}}),this.model.get("agent"));this.ui.sectionAgent.html(t),e.length>1&&this.ui.agentGroup.removeClass("hidden")
},renderSectionScanner:function(){var e=this.model.scannersProxy,t=this.createMenuOptions(e.map(function(e){return{label:e.get("name"),value:e.get("name")}}),this.model.get("scanner"));this.ui.sectionScanner.html(t),e.length>1&&this.ui.scannerGroup.removeClass("hidden")},onEditSectionAgentChange:function(e){var n=i(e.currentTarget),s=n.val();this.model.set("agent",s),this.agentSettingsRegion.close();var a=this.model.agents.get(s);if(a){var r=a.get("language"),o=this.model.get("language");-1===r.indexOf(o)&&this.model.set("language",r[0]),this.model.agentSettings=null,this.populateSectionAgentSettings().then(t.bind(this.renderSectionAgentSettings,this))
}this.showValidationResult(this.validate(this.model))},onEditSectionScannerChange:function(e){var t=i(e.currentTarget);this.model.set("scanner",t.val()),this.showValidationResult(this.validate(this.model))},onAgentsPopulate:function(){this.renderSectionAgent()},onScannersPopulate:function(){this.renderSectionScanner()},onThumbnailsDeleteClick:function(e){e.preventDefault();var t=n.execute("deleteSectionThumbnails",{section:this.model});t.done(this.whenRendered(function(){this.ui.thumbnailsCheckbox.prop("checked",!1)
}))}});return u}),define("hb!templates/desktop/section/edit/EditSectionFoldersView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-section-folders-form settings-container">\n  <label>\n    ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Add folders to your library",r):l.call(t,"t","Add folders to your library",r)))+'\n  </label>\n\n  <div class="form-group Location-group">\n    <div class="paths-region"></div>\n\n    <p class="add-folder-container">\n      <button type="button" class="add-folder-btn btn btn-icon-label btn-default"><i class="glyphicon folder-plus"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Browse for media folder",r):l.call(t,"t","Browse for media folder",r)))+'</button>\n    </p>\n\n    <p class="control-error">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"At least one folder is required.",r):l.call(t,"t","At least one folder is required.",r)))+'</p>\n  </div>\n\n  <p class="help-block">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Help us out by following {1}our guide{2} to naming and organizing your media.",'<a href="http://support.plex.tv/hc/en-us/categories/200028098-Media-Preparation" target="_blank">',"</a>",r):l.call(t,"t","Help us out by following {1}our guide{2} to naming and organizing your media.",'<a href="http://support.plex.tv/hc/en-us/categories/200028098-Media-Preparation" target="_blank">',"</a>",r)))+"</p>\n\n</form>\n"
})}),define("hb!templates/desktop/section/edit/EditSectionPathItemView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<div class="col-md-12">\n  <div class="form-group path-group">\n    <input type="text" name="path" class="form-control" value="',(a=i.path)?a=a.call(t,{hash:{},data:s}):(a=t&&t.path,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'">\n    <div class="path-actions">\n      <a href="#" class="remove-path-btn btn-link btn-gray"><i class="glyphicon remove-2"></i></a>\n    </div>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/editsection/EditSectionPathItemView",["hb!templates/desktop/section/edit/EditSectionPathItemView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({template:e,className:"row",events:{"click .remove-path-btn":"onRemovePathClick"},onRemovePathClick:function(e){e.preventDefault(),this.model.destroy()}});return i}),define("plex/desktop/views/editsection/EditSectionPathsListView",["marionette","plex/desktop/views/editsection/EditSectionPathItemView"],function(e,t){"use strict";
var i=e.CollectionView.extend({itemView:t});return i}),define("hb!templates/desktop/modals/AddFolderModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="modal-dialog">\n  <div class="modal-content">\n    <form name="add-folder-form">\n      <div class="modal-header">\n        <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n        <h4 class="modal-title"><i class="modal-icon glyphicon folder-plus"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Add Folder",r):l.call(t,"t","Add Folder",r)))+'</h4>\n      </div>\n\n      <div class="modal-body modal-body-scroll dark-scrollbar">\n        <div class="row">\n          <div class="col-md-12">\n            <input type="text" name="path" class="form-control" value="">\n          </div>\n        </div>\n\n        <div class="row directory-container-row">\n          <div class="home-directory-container col-md-5"></div>\n          <div class="path-container col-md-7"></div>\n        </div>\n      </div>\n\n      <div class="modal-footer">\n        <button type="button" class="cancel-btn btn btn-default" data-dismiss="modal">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Cancel",r):l.call(t,"t","Cancel",r)))+'</button>\n        <button type="submit" class="add-btn btn btn-primary">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Add",r):l.call(t,"t","Add",r)))+"</button>\n      </div>\n    </form>\n  </div>\n</div>\n"
})}),define("plex/base/models/server/BrowseDirectoryModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",defaults:{key:"/services/browse",title:"Root",path:""},whitelistedAttrs:["key","title","path","home","network"],url:function(){return this.server.resolveUrl(this.id)},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseBoolean(n,["home","network"]),n}});return n}),define("plex/base/models/server/BrowseDirectoryCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/server/BrowseDirectoryModel"],function(e,t,i){"use strict";
var n=t.extend({model:i,url:function(){return this.parent?this.parent.url():this.server.resolveUrl("/services/browse")},initialize:function(t){var i=e.bind(function(e){e.set("parent",this.parent),e.set("children",new n([],{parent:e,server:this.server}))},this);e.each(t,i),this.on("reset",function(){this.each(i)},this),this.on("add",i)},parse:function(e){return this.convert(e,"Path")}});return n}),define("hb!templates/desktop/lists/server/BrowseDirectoryListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"left-arrow"
}function r(e,t){var n;return n=i["if"].call(e,e&&e.home,{hash:{},inverse:f.program(6,l,t),fn:f.program(4,o,t),data:t}),n||0===n?n:""}function o(){return"home"}function l(e,t){var n;return n=i["if"].call(e,e&&e.network,{hash:{},inverse:f.program(9,d,t),fn:f.program(7,c,t),data:t}),n||0===n?n:""}function c(){return"globe"}function d(e,t){var n;return n=i.unless.call(e,e&&e.parent,{hash:{},inverse:f.program(12,h,t),fn:f.program(10,u,t),data:t}),n||0===n?n:""}function u(){return"hdd"}function h(){return"folder-open"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var p,m="",f=this,g="function",v=this.escapeExpression;return m+='<a class="striped-list-item" href="#" data-key="',(p=i.key)?p=p.call(t,{hash:{},data:s}):(p=t&&t.key,p=typeof p===g?p.call(t,{hash:{},data:s}):p),m+=v(p)+'">\n  <i class="folder-icon glyphicon ',p=i["if"].call(t,t&&t.back,{hash:{},inverse:f.program(3,r,s),fn:f.program(1,a,s),data:s}),(p||0===p)&&(m+=p),m+='"></i> ',(p=i.title)?p=p.call(t,{hash:{},data:s}):(p=t&&t.title,p=typeof p===g?p.call(t,{hash:{},data:s}):p),m+=v(p)+' <div class="loading loading-sm loading-inline hidden"></div>\n</a>\n'
})}),define("plex/desktop/views/lists/server/BrowseDirectoryListItem",["hb!templates/desktop/lists/server/BrowseDirectoryListItem.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({tagName:"li",className:"striped-list-item browse-directory-list-item",template:e,ui:{link:"a",spinner:".loading"},events:{"click a":"onDirectoryClick"},markAsSelected:function(e){this.ui.link.addClass("selected"),this.ui.spinner.toggleClass("hidden",!e)},removeSelection:function(){this.ui.link.removeClass("selected"),this.ui.spinner.addClass("hidden")
},onDirectoryClick:function(e){e.preventDefault(),this.markAsSelected(!0)}});return i}),define("plex/desktop/views/lists/server/BrowseDirectoryList",["marionette","jquery","plex/desktop/views/lists/server/BrowseDirectoryListItem"],function(e,t,i){"use strict";var n=e.CollectionView.extend({tagName:"ul",className:"list browse-directory-list",itemView:i,events:{"click a":"onDirectoryClick"},collectionEvents:{reset:"onReset"},initialize:function(e){this.root=e.root},loadDirectory:function(e){this.$("a").removeClass("selected");
var t=this.children.findByModel(e);t&&t.markAsSelected(!0)},unloadDirectory:function(e){var t=this.children.findByModel(e);t&&t.markAsSelected(!1)},unselectDirectory:function(e){var t=this.children.findByModel(e);t&&t.removeSelection()},onReset:function(){this.parentItem&&this.collection.add(this.parentItem,{at:0,silent:!0})},onDirectoryClick:function(e){e.preventDefault(),this.collection.hasPendingPopulate()&&(this.collection.abortPendingPopulate(),this.unselectDirectory(this.collection.parent));
var i=t(e.currentTarget),n=i.data("key"),s=this.collection.get(n)||this.parentItem;this.trigger("change:path",s),this.root||(this.collection.parent=s,s.get("parent")?(this.parentItem=s.get("parent").clone(),this.parentItem.set("back",!0),this.parentItem.set("title",".. [Back]")):this.parentItem=null,this.collection.fetch({reset:!0}))}});return n}),define("plex/desktop/views/modals/AddFolderModal",["hb!templates/desktop/modals/AddFolderModal.tpl","underscore","plex/base/models/server/BrowseDirectoryCollection","plex/desktop/views/modals/BaseModal","plex/desktop/views/lists/server/BrowseDirectoryList"],function(e,t,i,n,s){"use strict";
var a=n.extend({name:"addFolderModal",className:"add-folder-modal modal fade",template:e,events:t.extend({"submit form":"onSubmitForm"},n.prototype.events),ui:{path:'input[name="path"]'},regions:{home:".home-directory-container",path:".path-container"},initialize:function(e){n.prototype.initialize.apply(this,arguments),this.server=e.server,this.homeCollection=new i([],{server:this.server}),this.pathCollection=new i([],{server:this.server}),this.listenTo(this.homeCollection,"reset",this.onHomeReset),this.listenTo(this.pathCollection,"reset",this.onPathReset),this.homeCollection.fetch({reset:!0})
},onRender:function(){n.prototype.onRender.apply(this,arguments);var e=new s({root:!0,collection:this.homeCollection});this.listenTo(e,"change:path",this.onHomeChange),this.home.show(e);var t=new s({collection:this.pathCollection});this.listenTo(t,"change:path",this.onPathChange),this.path.show(t)},onSubmitForm:function(e){e.preventDefault(),this.trigger("add:folder",this.ui.path.val()),this.hide()},onHomeReset:function(e){var i=e.where({home:!0});i=i.length?t.first(i):e.first(),this.onHomeChange(i)
},onPathReset:function(){this.home.currentView.unloadDirectory(this.pathCollection.parent)},onHomeChange:function(e){this.home.currentView.loadDirectory(e),this.ui.path.val(e.get("path")),this.path.currentView.parentItem=null,this.pathCollection.hasPendingPopulate()&&(this.pathCollection.abortPendingPopulate(),this.home.currentView.unselectDirectory(this.pathCollection.parent)),this.pathCollection.parent=e,this.pathCollection.fetch({reset:!0})},onPathChange:function(e){this.ui.path.val(e.get("path"))
}});return a}),define("plex/desktop/views/editsection/EditSectionFoldersView",["hb!templates/desktop/section/edit/EditSectionFoldersView.tpl","underscore","jquery","backbone","plex/base/utils/dispatcher","plex/base/adapters/localizerAdapter","plex/desktop/views/editsection/EditSectionBaseView","plex/desktop/views/editsection/EditSectionPathsListView","plex/desktop/views/modals/AddFolderModal"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=r.extend({template:e,fieldNames:["Location"],regions:{pathsRegion:".paths-region"},events:{"click .add-folder-btn":"onAddFolderClick","change input[name=path]":"onFolderChange"},onlyAfterRender:["renderSectionLocation"].concat(r.prototype.onlyAfterRender),initialize:function(){if(!this.model.paths){var e=this.model.get("Location")||[],i=t.map(e,function(e){return{path:e.path}
});this.model.paths=new n.Collection(i)}this.listenTo(this.model.paths,{add:this.onCollectionChange,remove:this.onCollectionChange}),this.renderSectionLocation(),this.showValidationResult(this.validate(this.model))},validate:function(e){var t=[],i=e.get("Location")||[];return i.length||t.push("Location"),t},renderSectionLocation:function(){var e=new o({collection:this.model.paths});this.pathsRegion.show(e)},onCollectionChange:function(){this.model.set("Location",this.model.paths.toJSON()),this.showValidationResult(this.validate(this.model))
},onAddFolderClick:function(e){e.preventDefault();var t=new l({server:this.model.server});this.listenToOnce(t,"add:folder",this.onAddFolder),s.trigger("show:modal",t)},onAddFolder:function(e){if(e){var t={path:e};this.model.paths.findWhere(t)||this.model.paths.add(t)}},onFolderChange:function(e){var t=i(e.currentTarget),n=t.prop("defaultValue"),s=t.val();if(!s)return void t.val(n);var a=this.model.paths.findWhere({path:n});a.set("path",s),this.model.set("Location",this.model.paths.toJSON()),t.prop("defaultValue",s)
}});return c}),define("hb!templates/desktop/section/edit/EditSectionSelectPremiumMusicView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n            <p class="help-block">\n              ',s={hash:{},data:t},a+=u((n=i.t||e&&e.t,n?n.call(e,"Note: An active Plex Pass is required for this service. Don't have a Plex Pass? {1}Subscribe here{2}",'<a href="{3}" target="_blank">',"</a>",e&&e.plexPassUrl,s):d.call(e,"t","Note: An active Plex Pass is required for this service. Don't have a Plex Pass? {1}Subscribe here{2}",'<a href="{3}" target="_blank">',"</a>",e&&e.plexPassUrl,s)))+"\n            </p>\n          "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h=this;return c+='<div class="choose-agent use-premium-agent" data-agent="com.plexapp.agents.plexmusic" data-scanner="Plex Premium Music Scanner">\n  <div class="row">\n    <div class="col-xs-12">\n\n      <div class="row use-agent-header use-premium-agent-header">\n        <div class="col-xs-12">\n          <input type="radio">\n          <span class="header-text">\n            ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Create a premium Plex music library!",l):d.call(t,"t","Create a premium Plex music library!",l)))+'\n          </span>\n        </div>\n      </div>\n\n      <div class="row use-premium-agent-body">\n\n        <div class="col-xs-8">\n          <ul>\n            <li>',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Access to the best artwork, artist bios, album reviews, and more",l):d.call(t,"t","Access to the best artwork, artist bios, album reviews, and more",l)))+"</li>\n            <li>",l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Smart mixes based on track or mood",l):d.call(t,"t","Smart mixes based on track or mood",l)))+"</li>\n            <li>",l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Improved music recognition and matching",l):d.call(t,"t","Improved music recognition and matching",l)))+"</li>\n            <li>",l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Ad-free music videos",l):d.call(t,"t","Ad-free music videos",l)))+"</li>\n          </ul>\n\n          ",o=i.unless.call(t,t&&t.hasPlexPass,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n        </div>\n\n        <div class="col-xs-4 vendor-logos">\n          <div class="vendor-logo vendor-logo-gracenote"></div>\n          <div class="vendor-logo vendor-logo-vevo"></div>\n          <div class="vendor-logo vendor-logo-plex-pass"></div>\n        </div>\n\n      </div>\n\n    </div>\n  </div>\n</div>\n\n<div class="choose-agent use-basic-agent">\n  <div class="row use-agent-header">\n    <div class="col-xs-12">\n      <input type="radio">\n      ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Create a basic music library",l):d.call(t,"t","Create a basic music library",l)))+"\n    </div>\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/modals/PlexPassModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,r="";return r+='\n        <h4 class="text-center">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"This feature requires a Plex Pass subscription.",a):u.call(e,"t","This feature requires a Plex Pass subscription.",a)))+'</h4>\n\n        <p class="text-muted">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Everything you need to experience the best of Plex. Your subscription gives you premium features and exclusive access to new ones.",a):u.call(e,"t","Everything you need to experience the best of Plex. Your subscription gives you premium features and exclusive access to new ones.",a)))+'</p>\n\n        <p class="text-center">\n          <a class="btn btn-sm btn-primary" href="',(s=i.plexPassUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.plexPassUrl,s=typeof s===p?s.call(e,{hash:{},data:t}):s),r+=h(s)+'" target="_blank">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Learn More",a):u.call(e,"t","Learn More",a)))+"</a>\n        </p>\n      "
}function r(e,t){var n,s,a="";return a+='\n        <h4 class="text-center">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"{1}Sign in{2} to a Plex account with a Plex Pass subscription.","<a class='sign-in-btn' href='#'>","</a>",s):u.call(e,"t","{1}Sign in{2} to a Plex account with a Plex Pass subscription.","<a class='sign-in-btn' href='#'>","</a>",s)))+"</h4>\n      "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p="function",m=this;
return d+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon glyphicon circle-arrow-right"></i>\n        ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Go Premium",c):u.call(t,"t","Go Premium",c)))+'\n      </h4>\n    </div>\n\n    <div class="modal-body">\n      <p class="text-center"><i class="plex-image plex-pass"></i></p>\n\n      ',l=i["if"].call(t,t&&t.signedIn,{hash:{},inverse:m.program(3,r,s),fn:m.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+="\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/PlexPassModal",["hb!templates/desktop/modals/PlexPassModal.tpl","underscore","plex/base/utils/dispatcher","plex/desktop/views/modals/BaseModal"],function(e,t,i,n){"use strict";var s=n.extend({name:"plexPassModal",template:e,events:t.extend({"click .sign-in-btn":"onSignInClick"},n.prototype.events),serializeData:function(){return{signedIn:this.model.get("signedIn"),plexPassUrl:this.model.server.get("plexPassUrl")}},onSignInClick:function(e){e.preventDefault(),this.hide(),i.trigger("navigate","login",{silent:!0})
}});return s}),define("plex/desktop/views/editsection/EditSectionSelectPremiumMusicView",["hb!templates/desktop/section/edit/EditSectionSelectPremiumMusicView.tpl","jquery","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/editsection/EditSectionBaseView","plex/desktop/views/modals/PlexPassModal"],function(e,t,i,n,s,a){"use strict";var r=s.extend({template:e,ui:{chooseAgent:".choose-agent"},events:{"click .choose-agent":"onChooseAgentClick"},modelEvents:{"change:agent":"onSectionAgentChange","change:scanner":"onSectionScannerChange"},onlyAfterRender:["updateSelectedOffering"],initialize:function(){this.hasPlexPass=this.model.server.get("myPlexSubscription"),this.updateSelectedOffering()
},serializeData:function(){var e=n.get("user"),t={hasPlexPass:this.hasPlexPass,plexPassUrl:e.server.get("plexPassUrl")};return t},updateSelectedOffering:function(){var e=this.model.get("agent"),t=this.model.get("scanner");this.ui.chooseAgent.find("input").prop("checked",!1);var i=this.ui.chooseAgent.filter('[data-agent="'+e+'"][data-scanner="'+t+'"]').find("input");i.length||(i=this.ui.chooseAgent.not("[data-agent][data-scanner]").find("input")),i.prop("checked",!0)},onChooseAgentClick:function(e){var s=t(e.currentTarget),r=s.data("agent"),o=s.data("scanner");
if((r||o)&&!this.hasPlexPass){var l=n.get("user");return void i.trigger("show:modal",new a({model:l}))}this.model.agentSettings=null,this.model.set({agent:r||this.getSectionType().defaultAgent,scanner:o||this.getSectionType().defaultScanner})},onSectionAgentChange:function(){this.updateSelectedOffering()},onSectionScannerChange:function(){this.updateSelectedOffering()}});return r}),define("hb!templates/desktop/section/edit/EditSectionTypeView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"section-type-chosen"
}function r(e,t){var n,s,a="";return a+='\n    <p class="prompt">',s={hash:{},data:t},a+=b((n=i.t||e&&e.t,n?n.call(e,"Select your library type",s):y.call(e,"t","Select your library type",s)))+"</p>\n  "}function o(e,t){var n,s,a="";return a+="\n    <label>",s={hash:{},data:t},a+=b((n=i.t||e&&e.t,n?n.call(e,"Library type",s):y.call(e,"t","Library type",s)))+"</label>\n  "}function l(e,t,n){var s,a,r,o="";return o+='\n      <a class="wizard-block section-type ',s=i["if"].call(e,n&&n.add,{hash:{},inverse:w.noop,fn:w.program(8,c,t),data:t}),(s||0===s)&&(o+=s),o+=" ",r={hash:{},inverse:w.noop,fn:w.program(10,d,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,n&&n.currentSectionKey,e&&e.key,r):y.call(e,"if_eq",n&&n.currentSectionKey,e&&e.key,r),(a||0===a)&&(o+=a),o+='" data-key="',(a=i.key)?a=a.call(e,{hash:{},data:t}):(a=e&&e.key,a=typeof a===x?a.call(e,{hash:{},data:t}):a),o+=b(a)+'" href="#">\n        <i class="wizard-block-icon plex-icon ',(a=i.sectionTypeIcon)?a=a.call(e,{hash:{},data:t}):(a=e&&e.sectionTypeIcon,a=typeof a===x?a.call(e,{hash:{},data:t}):a),o+=b(a)+'"></i> ',r={hash:{},data:t},o+=b((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):y.call(e,"t",e&&e.title,r)))+"\n      </a>\n    "
}function c(){return"selectable"}function d(){return"selected"}function u(e,t){var n,s,a="";return a+='\n      <div class="row">\n        <div class="col-xs-12">\n          <p class="prompt">',s={hash:{},data:t},a+=b((n=i.t||e&&e.t,n?n.call(e,"Name your library and choose language.",s):y.call(e,"t","Name your library and choose language.",s)))+"</p>\n        </div>\n      </div>\n    "}function h(e,t){var n,s,a="";return a+="\n            ",s={hash:{},data:t},a+=b((n=i.t||e&&e.t,n?n.call(e,"Last updated {1}",e&&e.updatedAt,s):y.call(e,"t","Last updated {1}",e&&e.updatedAt,s)))+"\n          "
}function p(e,t){var n,s,a="";return a+="\n            ",s={hash:{},data:t},a+=b((n=i.t||e&&e.t,n?n.call(e,"Each library should only contain one type of media.",s):y.call(e,"t","Each library should only contain one type of media.",s)))+"\n          "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var m,f,g,v="",y=i.helperMissing,b=this.escapeExpression,w=this,x="function";return v+='<form class="edit-section-type-form settings-container ',f=i["if"].call(t,(m=t&&t.section,null==m||m===!1?m:m.type),{hash:{},inverse:w.noop,fn:w.program(1,a,s),data:s}),(f||0===f)&&(v+=f),v+='">\n  ',f=i["if"].call(t,t&&t.add,{hash:{},inverse:w.program(5,o,s),fn:w.program(3,r,s),data:s}),(f||0===f)&&(v+=f),v+='\n\n  <div class="wizard-blocks-group form-group type-group">\n    ',f=i.each.call(t,t&&t.sectionTypes,{hash:{},inverse:w.noop,fn:w.programWithDepth(7,l,s,t),data:s}),(f||0===f)&&(v+=f),v+='\n\n    <label class="control-label">\n      <span class="control-error">',g={hash:{},data:s},v+=b((m=i.t||t&&t.t,m?m.call(t,"You must select a media type.",g):y.call(t,"t","You must select a media type.",g)))+'</span>\n    </label>\n  </div>\n\n  <div class="visible-once-section-type-chosen">\n    ',f=i["if"].call(t,t&&t.add,{hash:{},inverse:w.noop,fn:w.program(12,u,s),data:s}),(f||0===f)&&(v+=f),v+='\n\n    <div class="row">\n      <div class="col-md-7">\n        <div class="form-group title-group">\n          <div>\n            <label for="edit-section-title" class="control-label">\n              ',g={hash:{},data:s},v+=b((m=i.t||t&&t.t,m?m.call(t,"Name",g):y.call(t,"t","Name",g)))+'\n              <span class="control-error">',g={hash:{},data:s},v+=b((m=i.t||t&&t.t,m?m.call(t,"A library name is required.",g):y.call(t,"t","A library name is required.",g)))+'</span>\n            </label>\n          </div>\n          <input type="text" id="edit-section-title" name="title" class="form-control" value="'+b((m=t&&t.section,m=null==m||m===!1?m:m.title,typeof m===x?m.apply(t):m))+'">\n        </div>\n      </div>\n\n      <div class="col-md-5">\n        <div class="form-group language-group">\n          <div>\n            <label for="edit-section-language" class="control-label">\n              ',g={hash:{},data:s},v+=b((m=i.t||t&&t.t,m?m.call(t,"Language",g):y.call(t,"t","Language",g)))+'\n              <span class="control-error">',g={hash:{},data:s},v+=b((m=i.t||t&&t.t,m?m.call(t,"A language is required.",g):y.call(t,"t","A language is required.",g)))+'</span>\n            </label>\n          </div>\n          <select id="edit-section-language" name="language"></select>\n        </div>\n      </div>\n    </div>\n\n    <div class="row">\n      <div class="col-md-12">\n        <span class="text-muted">\n          ',f=i["if"].call(t,t&&t.updatedAt,{hash:{},inverse:w.program(16,p,s),fn:w.program(14,h,s),data:s}),(f||0===f)&&(v+=f),v+="\n        </span>\n      </div>\n    </div>\n  </div>\n\n</form>\n"
})}),define("plex/desktop/views/editsection/EditSectionTypeView",["hb!templates/desktop/section/edit/EditSectionTypeView.tpl","underscore","jquery","moment","plex/base/utils/languageUtil","plex/base/utils/types/sectionTypes","plex/base/models/appModel","plex/desktop/views/editsection/EditSectionBaseView"],function(e,t,i,n,s,a,r,o){"use strict";var l=o.extend({template:e,ui:t.extend({sectionTypes:".wizard-block",sectionTitle:"#edit-section-title",sectionLanguage:"#edit-section-language"},o.prototype.ui),modelEvents:{"change:type":"onSectionTypeChange","change:title":"onSectionTitleChange","change:language":"onSectionLanguageChange"},events:{"click .section-type":"onSectionTypeClick","keyup #edit-section-title":"onEditSectionTitleChange","change #edit-section-title":"onEditSectionTitleChange","change #edit-section-language":"onEditSectionLanguageChange"},onlyAfterRender:["renderSectionLanguage","updateSectionTypesWizardBlocks","updateSectionLanguage","updateSectionTitle"].concat(o.prototype.onlyAfterRender),initialize:function(){this.populateCollections()
},serializeData:function(){var e=o.prototype.serializeData.apply(this,arguments);e.sectionTypes=a.getSectionTypes();var t=this.getSectionType();t&&(e.currentSectionKey=t.key);var i=this.model.get("updatedAt");return i&&(e.updatedAt=n.unix(i).fromNow()),e},validate:function(e){var t=[];return e.get("type")||t.push("type"),e.get("title")||t.push("title"),e.get("language")||t.push("language"),t},populateCollections:function(){var e=this.populateAgents(),n=this.populateScanners(),s=this.getSectionType(),a=i.when(s,e,n,this.model.server.get("myPlexSubscription")&&this.model.server.supports("premiumMusic"));
return this.model.isNew()&&(a=a.then(t.bind(this.model.setAgentAndScanner,this.model))),a=a.then(e).then(t.bind(this.onAgentsPopulate,this)).then(t.bind(function(){this.showValidationResult(this.validate(this.model))},this))},renderSectionLanguage:function(){var e=this.model.agents.get(this.model.get("agent")),i=e.get("language"),n=this.model.get("language");if(!t.contains(i,n)){var r=a.getSectionType(this.model.get("type")),o=r.defaultLanguage;this.model.set("language",o,{silent:!0}),n=o}this.updateSectionLanguage(),this.ui.sectionLanguage.html(this.createMenuOptions(t.map(i,function(e){return{label:s.getLanguageName(e),value:e}
}),n))},updateSectionTypesWizardBlocks:function(){this.ui.sectionTypes.removeClass("selected"),this.ui.sectionTypes.filter('[data-key="'+this.model.get("type")+'"]').addClass("selected"),this.$el.addClass("section-type-chosen")},updateSectionLanguage:function(){this.ui.sectionLanguage.val(this.model.get("language"))},updateSectionTitle:function(){var e=this.ui.sectionTitle.val(),t=this.model.get("title");e!==t&&this.ui.sectionTitle.val(t)},onSectionTypeClick:function(e){e.preventDefault();var t=i(e.currentTarget);
if(t.hasClass("selectable")){var n=t.data("key"),s={type:n},r=a.getSectionType(n);this.model.get("title")||(s.title=r.title),this.model.set(s)}},onEditSectionTitleChange:function(e){var t=i(e.currentTarget);this.model.set("title",t.val()),this.showValidationResult(this.validate(this.model))},onEditSectionLanguageChange:function(e){var t=i(e.currentTarget);this.model.set("language",t.val()),this.showValidationResult(this.validate(this.model))},onSectionTypeChange:function(e,t){this.updateSectionTypesWizardBlocks();
var i=a.getSectionType(t);if(!this.model.get("language")){var n=i.defaultLanguage;this.model.set("language",n)}var s=this.model.get("title"),r=this.model.previous("type"),o=a.getSectionType(r),l=o&&o.title;s&&s!==l||this.model.set("title",i.title),this.setSectionType(i),this.model.agents=null,this.model.scanners=null,this.model.settings=null,this.populateCollections()},onSectionTitleChange:function(){this.updateSectionTitle(),this.showValidationResult(this.validate(this.model))},onSectionLanguageChange:function(){this.updateSectionLanguage()
},onAgentsPopulate:function(){this.renderSectionLanguage()}});return l}),define("hb!templates/desktop/editsection/EditSectionErrorView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<form class="edit-section-type-form settings-container">\n  <p>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"There was an error adding this library.",r):l.call(t,"t","There was an error adding this library.",r)))+"</p>\n  <p>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"You need to {1}follow these instructions{2} to troubleshoot the Plex Media Server.","<a href='https://support.plex.tv/hc/en-us/articles/201119258-Resetting-System-and-Framework-bundles' target='_blank'>","</a>",r):l.call(t,"t","You need to {1}follow these instructions{2} to troubleshoot the Plex Media Server.","<a href='https://support.plex.tv/hc/en-us/articles/201119258-Resetting-System-and-Framework-bundles' target='_blank'>","</a>",r)))+"</p>\n</form>"
})}),define("plex/desktop/views/editsection/EditSectionErrorView",["hb!templates/desktop/editsection/EditSectionErrorView.tpl","plex/desktop/views/editsection/EditSectionBaseView"],function(e,t){"use strict";var i=t.extend({template:e});return i}),define("hb!templates/desktop/modals/LibraryFailureModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n          ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Internet Required",s):v.call(e,"t","Internet Required",s)))+"\n        "
}function r(e,t){var n,s,a="";return a+="\n          ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Plex Pass Required",s):v.call(e,"t","Plex Pass Required",s)))+"\n        "}function o(e,t){var n,s,a="";return a+="\n          ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"This server cannot reach the Internet. Please verify connectivity and try again.",s):v.call(e,"t","This server cannot reach the Internet. Please verify connectivity and try again.",s)))+"\n        "}function l(e,t){var n,s,a="";
return a+="\n          ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"This library requires your server be signed in to a Plex Pass account.",s):v.call(e,"t","This library requires your server be signed in to a Plex Pass account.",s)))+"\n        "}function c(e,t){var n,s,a="";return a+='\n        <button type="button" class="confirm-btn btn btn-lg btn-primary">',s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"OK",s):v.call(e,"t","OK",s)))+"</button>\n      "}function d(e,t){var n,s="";return s+='\n        <a class="confirm-btn btn btn-lg btn-primary" href="#!/settings/server/',(n=i.serverID)?n=n.call(e,{hash:{},data:t}):(n=e&&e.serverID,n=typeof n===b?n.call(e,{hash:{},data:t}):n),s+=y(n)+'">\n          ',n=i["if"].call(e,e&&e.isSignedIn,{hash:{},inverse:w.program(14,h,t),fn:w.program(12,u,t),data:t}),(n||0===n)&&(s+=n),s+="\n        </a>\n      "
}function u(e,t){var n,s,a="";return a+="\n            ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Settings",s):v.call(e,"t","Settings",s)))+"\n          "}function h(e,t){var n,s,a="";return a+="\n            ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Sign In",s):v.call(e,"t","Sign In",s)))+"\n          "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var p,m,f,g="",v=i.helperMissing,y=this.escapeExpression,b="function",w=this;return g+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon glyphicon circle-exclamation-mark"></i>\n        ',p=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:w.program(3,r,s),fn:w.program(1,a,s),data:s}),(p||0===p)&&(g+=p),g+='\n      </h4>\n    </div>\n\n    <div class="modal-body">\n      <p class="confirm-message">\n        ',p=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:w.program(7,l,s),fn:w.program(5,o,s),data:s}),(p||0===p)&&(g+=p),g+='\n      </p>\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="cancel-btn btn btn-lg btn-default" data-dismiss="modal">',f={hash:{},data:s},g+=y((p=i.t||t&&t.t,p?p.call(t,"Ignore",f):v.call(t,"t","Ignore",f)))+"</button>\n      ",m=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:w.program(11,d,s),fn:w.program(9,c,s),data:s}),(m||0===m)&&(g+=m),g+="\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/LibraryFailureModal",["hb!templates/desktop/modals/LibraryFailureModal.tpl","underscore","plex/desktop/views/modals/BaseModal"],function(e,t,i){"use strict";var n=i.extend({name:"libraryFailureModal",className:"confirm-modal modal modal-sm fade",template:e,events:t.extend({"click .confirm-btn":"hide"},i.prototype.events),serializeData:function(){return{serverID:this.model.id,isSignedIn:"ok"===this.model.get("myPlexSigninState"),hasPlexPass:this.model.get("myPlexSubscription")}
}});return n}),define("plex/desktop/views/modals/EditSectionModal",["hb!templates/desktop/modals/EditSectionModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser","plex/base/utils/types/sectionTypes","plex/base/utils/types/mediaTypes","plex/base/commands/commands","plex/base/models/server/ServerSettingCollection","plex/base/models/library/AgentCollection","plex/base/models/library/ScannerCollection","plex/base/models/library/section/SectionModel","plex/base/models/library/section/SortModel","plex/base/models/library/ExclusiveAgentProxy","plex/desktop/views/editsection/EditSectionAdvancedView","plex/desktop/views/editsection/EditSectionFoldersView","plex/desktop/views/editsection/EditSectionSelectPremiumMusicView","plex/desktop/views/editsection/EditSectionTypeView","plex/desktop/views/editsection/EditSectionErrorView","plex/desktop/views/modals/BaseModal","plex/desktop/views/modals/LibraryFailureModal","plex/desktop/mixins/views/modals/paneModalMixin"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y,b,w,x,k){"use strict";
var S=w.extend({mixins:[k],name:"editSectionModal",className:"edit-section-modal modal modal-lg fade",template:e,panes:{type:{constructor:y,nextPane:"folders",dependentPanes:["folders"]},folders:{constructor:g,nextPane:"create",dependentPanes:["create","advanced"]},create:{constructor:v,nextPane:"advanced"},advanced:{constructor:f},error:{constructor:b}},panesModel:"tempModel",ui:{sidebar:".modal-nav-list",createBtn:".create-btn",saveBtn:".save-btn",message:".form-message",headerSectionType:".section-type-title"},regions:{paneRegion:".pane-region"},events:t.extend({"click .change-pane-btn":"onChangePaneClick","click .save-btn":"onSaveClick","click .delete-btn":"onDeleteClick","submit .edit-section-type-form":"onGeneralFormSubmit"},w.prototype.events),onlyAfterRender:["showPane","updateMessage","updateSectionTitle","updateSectionTitleDestabilized","updateSaveBtn"],initialize:function(e){w.prototype.initialize.apply(this,arguments),this.server=e.server,this.redirect=e.redirect,this.tempModel=this.model?this.model.clone():new h({},{server:this.server,collection:this.server.get("sections")}),this.listenTo(this.tempModel,"change:type",this.onSectionTypeChange),this.showPane(e.selectedPane||"type"),this.tempModel.isNew()&&e.seedAttrs&&this.tempModel.set(e.seedAttrs)
},serializeData:function(){var e=this.tempModel,t=e.isNew(),i={add:t,edit:!t,section:e&&e.toJSON(),selectedPane:this.selectedPane};return i},updateMessage:function(e){this.ui.message.text(e||"")},updateSaveBtn:function(){var e=this.ui.saveBtn,i=this.panes[this.selectedPane],n=t.bind(function(t){var n=i.nextPane,s=this.tempModel.isNew(),a=!i.constructor.prototype.validate||0===i.constructor.prototype.validate(this.tempModel).length,r=!this.getReachablePanes().isAnyInvalid;this.ui.createBtn.toggleClass("hidden",!t);
var o,l=r||s&&a;o=n,t||"create"!==n||(o=!1),r&&(o=!1),t&&"create"===n&&(o=!0),t&&"advanced"===n&&(o=!0),e.toggleClass("save",!o).toggleClass("next",!!o).toggleClass("disabled",!l)},this),s="music"===this.tempModel.get("type")&&this.tempModel.server.supports("premiumMusic");s?this.paneRegion.currentView.populateAgents().then(function(e){var t=e.findWhere({identifier:"com.plexapp.agents.plexmusic"});n(t)}):n(!1)},updateSectionTitle:function(){var e=r.getSectionType(this.tempModel.get("type"));if(e){this.updateSectionTitleDestabilized();
var t=n(e.title,{escape:!0});this.ui.headerSectionType.html(t)}},updateSectionTitleDestabilized:function(){this.ui.headerSectionType.addClass("section-type-title-unstable"),this.ui.headerSectionType.triggerReflow(),this.ui.headerSectionType.removeClass("section-type-title-unstable")},save:function(){var e=this.ui.saveBtn;this.updateMessage(""),e.addClass("active");var i=this.saveModel();i.always(function(){e.removeClass("active")}),i.fail(t.bind(function(e){503===e.status?s.trigger("show:modal",new x({model:this.server})):this.updateMessage(n("Your changes could not be saved."))
},this)),i.then(t.bind(function(e){if(!this.redirect)return void this.hide();var i={serverID:e.server.id,sectionID:e.id};if("artist"!==e.get("type"))return s.trigger("navigate","section",i),void this.hide();var n=o.getMediaTypeByString("artist"),a=o.getRelatedMediaTypes(n.typeString),r=e.get("types");r.reset(a,{parse:!0});var l=r.findWhere({typeString:"album"});l.set("selected",!0),e.set("currentType",l),e.get("sorts").populate().then(t.bind(function(t){var n=t.findWhere({key:"addedAt"});n&&(n.set({selected:!0,direction:"desc"}),e.set("currentSort",n)),this.hide(),s.trigger("navigate","section",i)
},this))},this))},saveModel:function(){var e;return this.tempModel.isNew()?(e=this.tempModel.save(),e=e.then(t.bind(function(e,t,i){var n=a.parseXML(e);if(201===i.status){if(n.Directory&&(n=n.Directory),!n.key){var s=i.getResponseHeader("Location");s&&(n.key=s.substring(s.lastIndexOf("/")+1))}var r=this.server;r.supports("advancedFilters")&&(n.filters=!0);var o=new h(n,{parse:!0,server:this.server});return r.get("sections").add(o),o}},this))):e=this.model.save(this.model.changedAttributes(this.tempModel.attributes)),e=e.then(t.bind(this.saveSettings,this)),e=e.then(t.bind(this.saveAgentSettings,this))
},saveSettings:function(e){var n=i.Deferred().resolve(e).promise();if(!this.server.supports("sectionSettings"))return n;var s=this.tempModel.settings;if(!s)return n;var a=this.getSettingsChanges(s);if(t.isEmpty(a))return n;var r=s.first(),o=r.getSaveParams(a),l="/library/sections/"+e.id+"/prefs?"+i.param(o,!0),c=t.extend(this.server.getXHROptions(l),{type:"PUT"});return i.ajax(c).promise().then(function(){return n})},saveAgentSettings:function(e){var n=i.Deferred().resolve(e).promise(),s=this.tempModel.agentSettings;
if(!this.tempModel.agentSettings)return n;var a=this.getSettingsChanges(s);if(t.isEmpty(a))return n;var r=s.first(),o=r.getSaveParams(a),l=t.result(s,"url"),c=l+"/set?"+i.param(o,!0),d=r.server.getXHROptions(c);return i.ajax(d).promise().then(function(){return n})},getSettingsChanges:function(e){var t=e.filter(function(e){return e.changedAttributes()}).reduce(function(e,t){var i=t.get("value");return"bool"===t.get("type")&&(i=i?"1":"0"),e[t.get("id")]=i,e},{});return t},onPaneShow:function(e,t){this.listenTo(t,"valid",this.updateSaveBtn),this.listenTo(t,"invalid",this.updateSaveBtn),this.updateSaveBtn()
},onPaneHide:function(e,t){this.stopListening(t,"valid",this.updateSaveBtn),this.stopListening(t,"invalid",this.updateSaveBtn)},onChangePaneClick:function(e){e.preventDefault();var t=this.$(e.currentTarget);t.isDisabled()||this.showPane(t.data("pane"))},onSaveClick:function(e){e.preventDefault();var t=this.ui.saveBtn;if(!t.isDisabled())if(t.hasClass("next")){var i=this.panes[this.selectedPane].nextPane;i&&!this.ui.sidebar.find("."+i+"-btn").isDisabled()&&this.showPane(i)}else this.save()},onDeleteClick:function(e){e.preventDefault();
var t=l.execute("deleteSection",{section:this.model});t.done(function(){s.trigger("navigate","dashboard")})},onGeneralFormSubmit:function(e){this.onSaveClick(e)},onSectionTypeChange:function(){this.updateSaveBtn()}});return S}),define("plex/desktop/views/lists/dashboard/DashboardSectionListItem",["hb!templates/desktop/lists/dashboard/DashboardSectionListItem.tpl","marionette","plex/base/utils/dispatcher","plex/desktop/views/modals/EditSectionModal"],function(e,t,i,n){"use strict";var s={artist:"music",movie:"film",photo:"picture",show:"display"},a=t.ItemView.extend({tagName:"li",className:"dashboard-section-list-item",template:e,ui:{loadingBtn:".btn-loading"},events:{"click .edit-section-btn":"onEditClick"},initialize:function(e){this.showActions=e.showActions,this.showActions&&(this.listenTo(this.model,"change:refreshing",this.onRefreshingChange),this.refreshing=this.model.get("refreshing"))
},serializeData:function(){var e=this.model.server,t=this.model.toJSON();return{section:t,serverID:e.id,icon:s[t.type],showActions:this.showActions,refreshing:this.refreshing}},bindings:{".section-title":{modelAttribute:"title"}},onEditClick:function(e){e.preventDefault(),i.trigger("show:modal",new n({server:this.model.server,model:this.model}))},onRefreshingChange:function(e,t){this.ui.loadingBtn.toggleClass("active",t)}});return a}),define("hb!templates/desktop/modals/user/EditFriendModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";
return s+="\n          ",(n=i.title)?n=n.call(e,{hash:{},data:t}):(n=e&&e.title,n=typeof n===v?n.call(e,{hash:{},data:t}):n),s+=y(n)+"\n        "}function r(e,t){var n,s,a,r="";return r+="\n          ",a={hash:{},inverse:w.program(6,l,t),fn:w.program(4,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.type,"home",a):b.call(e,"if_eq",e&&e.type,"home",a),(s||0===s)&&(r+=s),r+="\n        "}function o(e,t){var n,s,a="";return a+="\n            ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Add User",s):b.call(e,"t","Add User",s)))+"\n          "
}function l(e,t){var n,s,a="";return a+="\n            ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Invite Friend",s):b.call(e,"t","Invite Friend",s)))+"\n          "}function c(e,t){var n,s,a="";return a+="\n              ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Save Changes",s):b.call(e,"t","Save Changes",s)))+"\n            "}function d(e,t){var n,s,a,r="";return r+="\n              ",a={hash:{},inverse:w.program(13,h,t),fn:w.program(11,u,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.type,"home",a):b.call(e,"if_eq",e&&e.type,"home",a),(s||0===s)&&(r+=s),r+="\n            "
}function u(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Add",s):b.call(e,"t","Add",s)))+"\n              "}function h(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=y((n=i.t||e&&e.t,n?n.call(e,"Invite",s):b.call(e,"t","Invite",s)))+"\n              "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var p,m,f,g="",v="function",y=this.escapeExpression,b=i.helperMissing,w=this;return g+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <div class="modal-poster media-poster img-circle placeholder-friend"></div>\n      <h4 class="modal-title">\n        ',p=i["if"].call(t,t&&t.title,{hash:{},inverse:w.program(3,r,s),fn:w.program(1,a,s),data:s}),(p||0===p)&&(g+=p),g+='\n      </h4>\n    </div>\n\n    <form id="share-server-form">\n      <div class="modal-body modal-body-scroll modal-body-with-panes">\n        <div class="modal-nav-pane dark-scrollbar"></div>\n        <div class="modal-body-pane dark-scrollbar"></div>\n      </div>\n\n      <div class="modal-footer">\n        <span class="form-message"></span>\n\n        <button type="button" class="cancel-btn btn btn-lg btn-default" data-dismiss="modal">',f={hash:{},data:s},g+=y((p=i.t||t&&t.t,p?p.call(t,"Cancel",f):b.call(t,"t","Cancel",f)))+'</button>\n        <button type="submit" class="next-btn btn btn-lg btn-primary disabled">',f={hash:{},data:s},g+=y((p=i.t||t&&t.t,p?p.call(t,"Next",f):b.call(t,"t","Next",f)))+'</button>\n        <button type="submit" class="submit-btn btn btn-lg btn-primary btn-loading hidden">\n          <div class="loading loading-sm"></div>\n          <span class="btn-label">\n            ',m=i["if"].call(t,t&&t.title,{hash:{},inverse:w.program(10,d,s),fn:w.program(8,c,s),data:s}),(m||0===m)&&(g+=m),g+="\n          </span>\n        </button>\n      </div>\n    </form>\n  </div>\n</div>\n"
})}),define("plex/base/models/library/section/SectionOverviewModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({whitelistedAttrs:["id","key","type","title"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseInteger(n,"id"),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return n}),define("plex/base/models/library/section/SectionOverviewCollection",["plex/base/models/BaseCollection","plex/base/models/library/section/SectionOverviewModel"],function(e,t){"use strict";
var i=e.extend({model:t});return i}),define("plex/base/models/server/ServerOverviewModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/library/section/SectionOverviewCollection"],function(e,t,i,n){"use strict";var s=i.extend({idAttribute:"machineIdentifier",urlRoot:"/api/servers",whitelistedAttrs:["machineIdentifier","name","address","port","version","createdAt","updatedAt"],defaults:function(){return{sections:new n([],{server:this.server,parent:this})}},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);
return n.Server&&(n=n.Server),t.parseInteger(n,["createdAt","updatedAt"]),t.parseArray(n,"Section"),n},parse:function(t){var i=this.convert(t);return this.parseSections(i),i=e.pick(i,this.whitelistedAttrs)},parseSections:function(e){var t=this.get("sections"),i=e.Section;t.set(i,{parse:!0})}});return s}),define("plex/base/models/server/ServerOverviewCollection",["plex/base/models/BaseCollection","plex/base/models/server/ServerOverviewModel"],function(e,t){"use strict";var i=e.extend({model:t});return i
}),define("hb!templates/desktop/modals/user/EditFriendModalNavList",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<li>\n  <a class="btn-gray change-pane-btn disabled" data-pane="general" data-pane-id="general" href="#">\n    <i class="modal-nav-icon glyphicon user"></i>\n    ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"General",r):l.call(t,"t","General",r)))+'\n  </a>\n</li>\n<li class="owned-list-header modal-nav-list-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"My Servers",r):l.call(t,"t","My Servers",r)))+'</li>\n<li class="owned-servers-container"></li>\n<li>\n  <a class="btn-gray change-pane-btn disabled" data-pane="restrictions" data-pane-id="restrictions" href="#">\n    <i class="modal-nav-icon glyphicon ban"></i>\n    ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Restrictions",r):l.call(t,"t","Restrictions",r)))+'\n  </a>\n</li>\n<li class="shared-list-header modal-nav-list-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Shared With Me",r):l.call(t,"t","Shared With Me",r)))+'</li>\n<li class="shared-servers-container"></li>\n'
})}),define("hb!templates/desktop/modals/user/EditFriendModalNavServerListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<span class="modal-nav-icon friend-server-status ',(a=i.status)?a=a.call(t,{hash:{},data:s}):(a=t&&t.status,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'">\n  <i class="friend-server-status-icon unknown glyphicon circle-question-mark"></i>\n  <i class="friend-server-status-icon available glyphicon circle-ok"></i>\n  <i class="friend-server-status-icon unavailable glyphicon circle-exclamation-mark"></i>\n</span>\n\n'+l((a=t&&t.server,a=null==a||a===!1?a:a.name,typeof a===o?a.apply(t):a))+"\n"
})}),define("plex/desktop/views/modals/user/EditFriendModalNavServerListItem",["hb!templates/desktop/modals/user/EditFriendModalNavServerListItem.tpl","marionette","plex/base/models/appModel"],function(e,t,i){"use strict";var n=t.ItemView.extend({tagName:"a",className:"btn-gray change-pane-btn disabled",template:e,initialize:function(e){this.$el.attr({href:"#","data-pane":e.paneType,"data-pane-id":this.model.id});var t=i.get("servers"),n=t.get(this.model.get("machineIdentifier"));n?this.attachServer(n):this.listenTo(t,"add",this.onServerAdd)
},serializeData:function(){var e;return e=this.server&&null!=this.server.get("connected")?this.server.get("connected")?"available":"unavailable":"unknown",{server:this.model.toJSON(),status:e}},attachServer:function(e){this.server=e,this.listenTo(e,"change:connected",this.render)},onServerAdd:function(e){e.id===this.model.get("machineIdentifier")&&(this.attachServer(e),this.render())}});return n}),define("plex/desktop/views/modals/user/EditFriendModalNavServerList",["plex/desktop/views/lists/BaseList","plex/desktop/views/modals/user/EditFriendModalNavServerListItem"],function(e,t){"use strict";
var i=e.extend({className:"server-nav-list",itemView:t});return i}),define("plex/desktop/views/modals/user/EditFriendModalNavList",["hb!templates/desktop/modals/user/EditFriendModalNavList.tpl","jquery","marionette","plex/desktop/views/modals/user/EditFriendModalNavServerList"],function(e,t,i,n){"use strict";var s=i.Layout.extend({tagName:"ul",className:"list modal-nav-list",template:e,ui:{sharedHeader:".shared-list-header"},regions:{ownedServerList:".owned-servers-container",sharedServerList:".shared-servers-container"},events:{"click .change-pane-btn":"onChangePaneClick"},onlyAfterRender:["selectItem","toggleDisabled"],initialize:function(){this.serverOverviews=this.model.get("serverOverviews"),this.sharedServerShares=this.model.get("serverShares").filterByShared(),this.listenTo(this.sharedServerShares,"reset add remove",this.updateHeaders)
},setModel:function(e){this.stopListening(),this.model=e,this.initialize(),this.render()},selectItem:function(e){this.$(".change-pane-btn").removeClass("selected"),this.$('[data-pane-id="'+e+'"]').addClass("selected")},toggleDisabled:function(e){this.$(".change-pane-btn").toggleClass("disabled",e),this.$(".modal-nav-list-header").toggleClass("disabled",e)},updateHeaders:function(){this.ui.sharedHeader.toggleClass("hidden",!this.sharedServerShares.length)},onRender:function(){this.updateHeaders(),this.ownedServerList.show(new n({collection:this.serverOverviews,itemViewOptions:{paneType:"ownedServer"}})),this.sharedServerList.show(new n({collection:this.sharedServerShares,itemViewOptions:{paneType:"sharedServer"}}))
},onChangePaneClick:function(e){e.preventDefault();var i=t(e.currentTarget);if(!i.isDisabled()){var n=i.data("pane"),s=i.data("pane-id"),a={};"ownedServer"===n?a.serverOverview=this.model.get("serverOverviews").get(s):"sharedServer"===n&&(a.serverShare=this.model.get("serverShares").get(s)),this.trigger("change:pane",n,s,a)}}});return s}),define("hb!templates/desktop/modals/user/EditFriendModalUsernamePane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n  <div class="existing-user-group username-group">\n    <div class="media-poster img-circle placeholder-square"></div>\n\n    <div class="username-group-input-container">\n      <i class="validation-success-icon glyphicon circle-ok"></i>\n      <i class="validation-error-icon glyphicon circle-exclamation-mark"></i>\n\n      <input type="text" class="form-control hidden" name="username" placeholder="',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Username or email",s):u.call(e,"t","Username or email",s)))+'" autocorrect="off" autocapitalize="off">\n\n      <button type="button" class="add-existing-user-btn btn btn-primary">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Add an Existing Plex User",s):u.call(e,"t","Add an Existing Plex User",s)))+'</button>\n      <p class="help-block">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Adding a Plex user to your home will allow you to quickly switch accounts. The invited user will be asked to confirm home membership.",s):u.call(e,"t","Adding a Plex user to your home will allow you to quickly switch accounts. The invited user will be asked to confirm home membership.",s)))+'</p>\n    </div>\n  </div>\n\n  <div class="restricted-user-group username-group">\n    <div class="media-poster img-circle placeholder-friend"></div>\n\n    <div class="username-group-input-container">\n      <input type="text" class="form-control hidden" name="title" placeholder="',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Name",s):u.call(e,"t","Name",s)))+'" autocorrect="off" autocapitalize="off">\n\n      <button type="button" class="add-restricted-user-btn btn btn-primary">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Create a Managed User",s):u.call(e,"t","Create a Managed User",s)))+'</button>\n      <p class="help-block">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Managed users are only available when signed in with an account in your home. You can choose any name you like and you'll be able to set restrictions on accessible media.",s):u.call(e,"t","Managed users are only available when signed in with an account in your home. You can choose any name you like and you'll be able to set restrictions on accessible media.",s)))+"</p>\n    </div>\n  </div>\n"
}function r(e,t){var n,s,a="";return a+='\n  <div class="friend-group username-group">\n    <div class="media-poster img-circle placeholder-friend"></div>\n\n    <div class="username-group-input-container">\n      <i class="validation-success-icon glyphicon circle-ok"></i>\n      <i class="validation-error-icon glyphicon circle-exclamation-mark"></i>\n\n      <input type="text" class="form-control" name="username" placeholder="',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Username or email",s):u.call(e,"t","Username or email",s)))+'" autocorrect="off" autocapitalize="off">\n\n      <p class="help-block">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"The invited user will be asked to confirm friendship. If libraries are shared with the user, you'll be able to set restrictions on accessible media.",s):u.call(e,"t","The invited user will be asked to confirm friendship. If libraries are shared with the user, you'll be able to set restrictions on accessible media.",s)))+"</p>\n    </div>\n  </div>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return c={hash:{},inverse:p.program(3,r,s),fn:p.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.type,"home",c):u.call(t,"if_eq",t&&t.type,"home",c),(l||0===l)&&(d+=l),d+="\n"})}),define("plex/desktop/views/modals/user/EditFriendModalUsernamePane",["hb!templates/desktop/modals/user/EditFriendModalUsernamePane.tpl","underscore","jquery","marionette","plex/base/commands/commands"],function(e,t,i,n,s){"use strict";
var a=n.ItemView.extend({template:e,focusDelay:200,validationDelay:500,ui:{existingGroup:".existing-user-group",existingBtn:".add-existing-user-btn",restrictedGroup:".restricted-user-group",restrictedBtn:".add-restricted-user-btn"},events:{"keyup input":"onInputKeyUp","click .add-existing-user-btn":"onAddExistingUserClick","click .add-restricted-user-btn":"onAddRestrictedUserClick"},initialize:function(e){this.paneID=e.paneID,this.type=e.type,this.homeUser=e.homeUser,this.changes={},this.validate=t.debounce(this.validate,500)
},serializeData:function(){return{type:this.type}},flushChanges:function(){this.model.set(this.changes),this.homeUser&&this.homeUser.set(this.changes)},focusInput:function(){var e;e=this.$(this.changes.restricted?"[name=title]":"[name=username]"),e.removeClass("hidden"),e.focus()},validate:function(e){if(e){var i=s.execute("validateUsername",{username:e,server:this.model.server});i.done(t.bind(function(){this.$el.addClass("is-valid-username"),this.$el.removeClass("is-invalid-username")},this)),i.fail(t.bind(function(e,t){this.$el.removeClass("is-valid-username"),this.$el.addClass("is-invalid-username"),this.trigger("change:errorMessage",t)
},this))}},onRender:function(){"friend"===this.type&&setTimeout(t.bind(this.focusInput,this),this.focusDelay)},onInputKeyUp:function(e){var t=e.currentTarget,i=t.name,n=t.value;n!==this.changes[i]&&(this.changes[i]=n,this.trigger("change:errorMessage",""),this.trigger("enable:submit",!!n),"username"===i&&this.validate(n))},onAddExistingUserClick:function(e){e.preventDefault();var t=i(e.currentTarget);t.isDisabled()||(t.addClass("hidden"),this.ui.restrictedGroup.addClass("disabled"),this.ui.restrictedBtn.addClass("disabled"),this.focusInput())
},onAddRestrictedUserClick:function(e){e.preventDefault();var t=i(e.currentTarget);t.isDisabled()||(this.changes.restricted=!0,t.addClass("hidden"),this.ui.existingGroup.addClass("disabled"),this.ui.existingBtn.addClass("disabled"),this.focusInput())}});return a}),define("hb!templates/desktop/modals/user/EditFriendModalGeneralPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n    <div class="restricted-name-group form-group">\n      <input type="text" id="restricted-title" name="title" class="form-control" placeholder="',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Name",s):b.call(e,"t","Name",s)))+'" value="'+w((n=e&&e.homeUser,n=null==n||n===!1?n:n.title,typeof n===x?n.apply(e):n))+'">\n    </div>\n  '
}function r(e,t){var n,s,a="";return a+='\n    <h3 class="friend-title">\n      ',s=i["if"].call(e,(n=e&&e.friend,null==n||n===!1?n:n.title),{hash:{},inverse:k.program(6,l,t),fn:k.program(4,o,t),data:t}),(s||0===s)&&(a+=s),a+='\n    </h3>\n\n    <p class="text-muted">\n      ',s=i["if"].call(e,(n=e&&e.friend,null==n||n===!1?n:n.email),{hash:{},inverse:k.program(10,d,t),fn:k.program(8,c,t),data:t}),(s||0===s)&&(a+=s),a+="\n    </p>\n  "}function o(e){var t,i="";return i+="\n        "+w((t=e&&e.friend,t=null==t||t===!1?t:t.title,typeof t===x?t.apply(e):t))+"\n      "
}function l(e){var t,i="";return i+="\n        "+w((t=e&&e.friend,t=null==t||t===!1?t:t.username,typeof t===x?t.apply(e):t))+"\n      "}function c(e){var t,i="";return i+="\n        "+w((t=e&&e.friend,t=null==t||t===!1?t:t.email,typeof t===x?t.apply(e):t))+"\n      "}function d(e,t){var n,s,a="";return a+="\n        ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"An invite will be sent to this user.",s):b.call(e,"t","An invite will be sent to this user.",s)))+"\n      "}function u(e,t){var n,s,a="";
return a+='\n  <div class="edit-friend-footer">\n    ',s=i["if"].call(e,(n=e&&e.homeUser,null==n||n===!1?n:n.restricted),{hash:{},inverse:k.program(15,p,t),fn:k.program(13,h,t),data:t}),(s||0===s)&&(a+=s),a+="\n  </div>\n"}function h(e,t){var n,s,a="";return a+='\n      <button type="button" class="remove-home-btn btn btn-sm btn-danger">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Delete user",s):b.call(e,"t","Delete user",s)))+"</button>\n    "}function p(e,t){var n,s="";return s+="\n      ",n=i["if"].call(e,e&&e.canRemoveFriend,{hash:{},inverse:k.noop,fn:k.program(16,m,t),data:t}),(n||0===n)&&(s+=n),s+="\n\n      ",n=i["if"].call(e,e&&e.canRemoveHomeUser,{hash:{},inverse:k.noop,fn:k.program(18,f,t),data:t}),(n||0===n)&&(s+=n),s+="\n    "
}function m(e,t){var n,s,a="";return a+='\n        <button type="button" class="remove-friend-btn btn btn-sm btn-danger">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Remove this friend",s):b.call(e,"t","Remove this friend",s)))+"</button>\n      "}function f(e,t){var n,s,a="";return a+='\n        <button type="button" class="remove-home-btn btn btn-sm btn-danger">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Remove from home",s):b.call(e,"t","Remove from home",s)))+"</button>\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var g,v,y="",b=i.helperMissing,w=this.escapeExpression,x="function",k=this;return y+='<div class="edit-friend-header">\n  <div class="media-poster img-circle placeholder-friend"></div>\n\n  ',v=i["if"].call(t,(g=t&&t.homeUser,null==g||g===!1?g:g.restricted),{hash:{},inverse:k.program(3,r,s),fn:k.program(1,a,s),data:s}),(v||0===v)&&(y+=v),y+="\n</div>\n\n",v=i["if"].call(t,t&&t.showActions,{hash:{},inverse:k.noop,fn:k.program(12,u,s),data:s}),(v||0===v)&&(y+=v),y+="\n"
})}),define("plex/desktop/views/modals/user/EditFriendModalGeneralPane",["hb!templates/desktop/modals/user/EditFriendModalGeneralPane.tpl","marionette","plex/base/views/images/GravatarImage"],function(e,t,i){"use strict";var n=t.ItemView.extend({template:e,ui:{poster:".media-poster"},events:{"change input":"onInputChange","click .remove-home-btn":"onRemoveHomeClick","click .remove-friend-btn":"onRemoveFriendClick"},initialize:function(e){this.paneID=e.paneID,this.homeUser=e.homeUser,this.type=e.type,this.isAdmin=e.isAdmin,this.changes={},this.image=new i({model:this.model,type:"friend",width:60})
},serializeData:function(){var e=!this.model.isNew(),t=this.homeUser&&!this.homeUser.isNew();return{friend:this.model.toJSON(),homeUser:this.homeUser&&this.homeUser.toJSON(),canRemoveFriend:e,canRemoveHomeUser:t&&this.isAdmin,showActions:e||t}},flushChanges:function(){this.homeUser&&this.homeUser.set(this.changes)},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()},onInputChange:function(e){var t=e.currentTarget,i=t.value;"checkbox"===t.type&&(i=t.checked),this.changes[t.name]=i
},onRemoveHomeClick:function(e){e.preventDefault(),this.trigger("destroy:homeUser")},onRemoveFriendClick:function(e){e.preventDefault(),this.trigger("destroy:friend")}});return n}),define("hb!templates/desktop/modals/user/EditFriendModalOwnedServerPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="server-header">\n  <i class="plex-image server-xs"></i>\n\n  <h3 class="server-title"></h3>\n  <a class="server-status-btn unknown" href="#">\n    <span class="server-status-label available">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Available",r):l.call(t,"t","Available",r)))+'</span>\n    <span class="server-status-label unavailable">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unavailable",r):l.call(t,"t","Unavailable",r)))+'</span>\n    <span class="server-status-label unauthorized">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unauthorized",r):l.call(t,"t","Unauthorized",r)))+'</span>\n    <span class="server-status-label unknown">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unknown",r):l.call(t,"t","Unknown",r)))+'</span>\n\n    <i class="server-details-open-icon glyphicon chevron-down"></i>\n    <i class="server-details-close-icon glyphicon chevron-up"></i>\n  </a>\n</div>\n\n<div class="server-details transition-out">\n  <h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Info",r):l.call(t,"t","Info",r)))+'</h4>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Version",r):l.call(t,"t","Version",r)))+'</div>\n    <div class="server-detail-value server-detail-version"></div>\n  </div>\n\n  <div class="server-detail-row server-detail-last-seen-row hidden">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Last Seen",r):l.call(t,"t","Last Seen",r)))+'</div>\n    <div class="server-detail-value server-detail-last-seen"></div>\n  </div>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Address",r):l.call(t,"t","Address",r)))+'</div>\n    <div class="server-detail-value server-detail-address"></div>\n  </div>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Port",r):l.call(t,"t","Port",r)))+'</div>\n    <div class="server-detail-value server-detail-port"></div>\n  </div>\n</div>\n\n<div class="share-details">\n  <h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Share",r):l.call(t,"t","Share",r)))+"</h4>\n</div>\n"
})}),define("hb!templates/desktop/modals/user/EditFriendModalShareServerView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"show-libraries"}function r(e,t){var n,s,a,r="";return r+='\n    <li class="share-section-list-item">\n      <div class="checkbox">\n        <label for="share-all-libraries-'+v((n=e&&e.server,n=null==n||n===!1?n:n.machineIdentifier,typeof n===g?n.apply(e):n))+'-cb">\n          <input type="checkbox" id="share-all-libraries-'+v((n=e&&e.server,n=null==n||n===!1?n:n.machineIdentifier,typeof n===g?n.apply(e):n))+'-cb" name="share-all-libraries-cb" value="all" ',s=i["if"].call(e,e&&e.allLibraries,{hash:{},inverse:y.noop,fn:y.program(4,o,t),data:t}),(s||0===s)&&(r+=s),r+="> ",a={hash:{},data:t},r+=v((n=i.t||e&&e.t,n?n.call(e,"All Libraries",a):b.call(e,"t","All Libraries",a)))+"\n        </label>\n      </div>\n    </li>\n  "
}function o(){return"checked"}function l(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"Loading...",s):b.call(e,"t","Loading...",s)))+"</p>\n"}function c(e,t){var n;return n=i["if"].call(e,e&&e.hasFailed,{hash:{},inverse:y.program(11,u,t),fn:y.program(9,d,t),data:t}),n||0===n?n:""}function d(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"We were unable to retrieve libraries for {1}. Please ensure the server is signed in to your Plex account.",(n=e&&e.server,null==n||n===!1?n:n.name),s):b.call(e,"t","We were unable to retrieve libraries for {1}. Please ensure the server is signed in to your Plex account.",(n=e&&e.server,null==n||n===!1?n:n.name),s)))+"</p>\n"
}function u(e,t){var n;return n=i.unless.call(e,e&&e.hasSections,{hash:{},inverse:y.noop,fn:y.program(12,h,t),data:t}),n||0===n?n:""}function h(e,t){var n,s,a="";return a+='\n  <p class="text-muted">',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"No libraries",s):b.call(e,"t","No libraries",s)))+"</p>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var p,m,f="",g="function",v=this.escapeExpression,y=this,b=i.helperMissing;return f+='<ul id="'+v((p=t&&t.server,p=null==p||p===!1?p:p.machineIdentifier,typeof p===g?p.apply(t):p))+'-section-list" class="list share-section-list ',m=i.unless.call(t,t&&t.allLibraries,{hash:{},inverse:y.noop,fn:y.program(1,a,s),data:s}),(m||0===m)&&(f+=m),f+='">\n  ',m=i["if"].call(t,t&&t.hasSections,{hash:{},inverse:y.noop,fn:y.program(3,r,s),data:s}),(m||0===m)&&(f+=m),f+="\n</ul>\n\n",m=i["if"].call(t,t&&t.isPending,{hash:{},inverse:y.program(8,c,s),fn:y.program(6,l,s),data:s}),(m||0===m)&&(f+=m),f+="\n"
})}),define("hb!templates/desktop/modals/user/EditFriendModalShareSectionListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"checked"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c="function",d=this.escapeExpression,u=this;return l+='<div class="checkbox">\n  <label for="share-section-'+d((r=t&&t.section,r=null==r||r===!1?r:r.id,typeof r===c?r.apply(t):r))+'-cb">\n    <input type="checkbox" id="share-section-'+d((r=t&&t.section,r=null==r||r===!1?r:r.id,typeof r===c?r.apply(t):r))+'-cb" value="'+d((r=t&&t.section,r=null==r||r===!1?r:r.id,typeof r===c?r.apply(t):r))+'" ',o=i["if"].call(t,t&&t.isChecked,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='> <i class="section-type-icon glyphicon ',(o=i.typeIcon)?o=o.call(t,{hash:{},data:s}):(o=t&&t.typeIcon,o=typeof o===c?o.call(t,{hash:{},data:s}):o),l+=d(o)+'"></i> '+d((r=t&&t.section,r=null==r||r===!1?r:r.title,typeof r===c?r.apply(t):r))+"\n  </label>\n</div>\n"
})}),define("plex/desktop/views/modals/user/EditFriendModalShareSectionListItem",["hb!templates/desktop/modals/user/EditFriendModalShareSectionListItem.tpl","underscore","marionette","plex/base/utils/types/sectionTypes"],function(e,t,i,n){"use strict";var s=i.ItemView.extend({tagName:"li",className:"share-section-list-item",template:e,initialize:function(e){this.serverShare=e.serverShare},serializeData:function(){var e={section:this.model.toJSON(),typeIcon:n.getSectionTypeByString(this.model.get("type")).sectionTypeIcon,isChecked:!1};
if(this.serverShare&&!this.serverShare.get("allLibraries")){var i=this.serverShare.get("Section");e.isChecked=!!t.findWhere(i,{id:this.model.id,shared:!0})}return e}});return s}),define("plex/desktop/views/modals/user/EditFriendModalShareServerView",["hb!templates/desktop/modals/user/EditFriendModalShareServerView.tpl","underscore","jquery","marionette","plex/desktop/views/modals/user/EditFriendModalShareSectionListItem"],function(e,t,i,n,s){"use strict";var a=n.CompositeView.extend({className:"share-server-container",template:e,itemView:s,itemViewContainer:".share-section-list",ui:{list:".share-section-list"},events:{"change input[name=share-all-libraries-cb]":"onAllLibrariesChange"},initialize:function(e){t.bindAll(this,"render"),this.serverOverview=e.serverOverview,this.collection=this.serverOverview.get("sections");
var n=this.model.get("serverShares");this.serverShare=n.findWhere({machineIdentifier:this.serverOverview.id});var s=[];s.push(this.serverOverview.populate()),this.serverShare&&(this.itemViewOptions={serverShare:this.serverShare},this.serverShare.isNew()||s.push(this.serverShare.populate())),this.listPromise=i.when.apply(i,s),"pending"===this.listPromise.state()&&this.listPromise.always(this.render)},serializeData:function(){var e=this.listPromise.state(),t=!this.serverShare&&this.model.isNew(),i=this.serverShare&&this.serverShare.get("allLibraries");
return{server:this.serverOverview.toJSON(),isPending:"pending"===e,hasFailed:"rejected"===e,hasSections:!!this.serverOverview.get("sections").length,allLibraries:t||i}},onAllLibrariesChange:function(e){this.ui.list.toggleClass("show-libraries",!e.currentTarget.checked)}});return a}),define("plex/desktop/views/modals/user/EditFriendModalOwnedServerPane",["hb!templates/desktop/modals/user/EditFriendModalOwnedServerPane.tpl","underscore","jquery","marionette","plex/base/utils/formatters/dateTimeUtil","plex/base/models/appModel","plex/desktop/views/modals/user/EditFriendModalShareServerView"],function(e,t,i,n,s,a,r){"use strict";
var o=n.Layout.extend({template:e,ui:{details:".server-details",lastSeenRow:".server-detail-last-seen-row"},regions:{share:".share-details"},events:{"click .server-status-btn":"onServerStatusClick"},initialize:function(e){this.paneID=e.paneID,this.serverOverview=e.serverOverview,this.server=a.get("servers").get(this.serverOverview.id);var t=this.model.get("serverShares");this.serverShare=t.findWhere({machineIdentifier:this.serverOverview.id}),this.changes={}},serializeData:function(){return{server:this.serverOverview.toJSON()}
},flushChanges:function(){var e=this.model.get("serverShares"),t=e.findWhere({machineIdentifier:this.serverOverview.id}),i=this.getServerShareAttributes(this.serverOverview);t?t.set(i):e.add(i)},getServerShareAttributes:function(e){var i=e.get("sections"),n=this.$("#"+e.id+"-section-list"),s=n.find(":checked:visible"),a=[],r={machineIdentifier:e.id,owned:!0,allLibraries:!1};return s.each(function(){return"all"===this.value?(r.allLibraries=!0,!1):void a.push(parseInt(this.value,10))}),r.numLibraries=r.allLibraries?i.length:a.length,r.Section=i.map(function(e){var i=e.toJSON();
return i.shared=r.allLibraries||t.contains(a,i.id),i}),r},bindings:{".server-title":{model:"serverOverview",modelAttribute:"name"},".server-status-btn":{model:"server",modelAttribute:"connected",manual:!0,formatter:function(e,t){t.removeClass("unknown available unauthorized unavailable"),t.addClass(null==e?"unknown":e?"available":this.server.get("unauthorized")?"unauthorized":"unavailable")}},".server-detail-version":{model:"server",modelAttribute:"version"},".server-detail-last-seen":{model:"serverShare",modelAttribute:"lastSeenAt",formatter:function(e){var t=s.formatTimeAgo(e);
return this.ui.lastSeenRow.toggleClass("hidden",!t),t}},".server-detail-address":{model:"serverOverview",modelAttribute:"address",formatter:function(e){if(e)return e;var t=this.server.get("activeConnection");return t?t.address:void 0}},".server-detail-port":{model:"serverOverview",modelAttribute:"port",formatter:function(e){if(e)return e;var t=this.server.get("activeConnection");return t?t.port:void 0}}},onRender:function(){this.share.append(new r({model:this.model,serverOverview:this.serverOverview,itemViewOptions:this.itemViewOptions}))
},onServerStatusClick:function(e){e.preventDefault();var t=i(e.currentTarget);t.toggleClass("active"),this.ui.details.toggleClass("transition-out",!t.hasClass("active"))}});return o}),define("hb!templates/desktop/modals/user/EditFriendModalSharedServerPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="server-header">\n  <i class="plex-image server-xs"></i>\n\n  <h3 class="server-title"></h3>\n  <a class="server-status-btn unknown" href="#">\n    <span class="server-status-label available">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Available",r):l.call(t,"t","Available",r)))+'</span>\n    <span class="server-status-label unavailable">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unavailable",r):l.call(t,"t","Unavailable",r)))+'</span>\n    <span class="server-status-label unauthorized">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unauthorized",r):l.call(t,"t","Unauthorized",r)))+'</span>\n    <span class="server-status-label unknown">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unknown",r):l.call(t,"t","Unknown",r)))+'</span>\n\n    <i class="server-details-open-icon glyphicon chevron-down"></i>\n    <i class="server-details-close-icon glyphicon chevron-up"></i>\n  </a>\n</div>\n\n<div class="server-details transition-out">\n  <h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Info",r):l.call(t,"t","Info",r)))+'</h4>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Version",r):l.call(t,"t","Version",r)))+'</div>\n    <div class="server-detail-value server-detail-version"></div>\n  </div>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Last Seen",r):l.call(t,"t","Last Seen",r)))+'</div>\n    <div class="server-detail-value server-detail-last-seen"></div>\n  </div>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Address",r):l.call(t,"t","Address",r)))+'</div>\n    <div class="server-detail-value server-detail-address"></div>\n  </div>\n\n  <div class="server-detail-row">\n    <div class="server-detail-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Port",r):l.call(t,"t","Port",r)))+'</div>\n    <div class="server-detail-value server-detail-port"></div>\n  </div>\n</div>\n\n<div class="share-details">\n  <h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sharing",r):l.call(t,"t","Sharing",r)))+'</h4>\n\n  <div class="share-server-container">\n    <div class="server-restriction-allow-sync share-section-list-item no-checkbox">\n      <i class="section-type-icon glyphicon ok-2"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sync Allowed",r):l.call(t,"t","Sync Allowed",r)))+'\n    </div>\n\n    <ul class="list share-section-list show-libraries"></ul>\n  </div>\n</div>\n\n<div class="share-details-footer">\n  <button type="button" class="leave-server-btn btn btn-sm btn-danger">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Leave Server",r):l.call(t,"t","Leave Server",r)))+"</button>\n</div>\n"
})}),define("hb!templates/desktop/modals/user/EditFriendModalSharedServerSectionListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<li class="share-section-list-item no-checkbox">\n  <i class="section-type-icon glyphicon ',(a=i.typeIcon)?a=a.call(t,{hash:{},data:s}):(a=t&&t.typeIcon,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'"></i> '+l((a=t&&t.section,a=null==a||a===!1?a:a.title,typeof a===o?a.apply(t):a))+"\n</li>\n"
})}),define("plex/desktop/views/modals/user/EditFriendModalSharedServerPane",["hb!templates/desktop/modals/user/EditFriendModalSharedServerPane.tpl","hb!templates/desktop/modals/user/EditFriendModalSharedServerSectionListItem.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/formatters/dateTimeUtil","plex/base/utils/types/sectionTypes","plex/base/models/appModel"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=s.ItemView.extend({template:e,ui:{details:".server-details"},events:{"click .server-status-btn":"onServerStatusClick","click .leave-server-btn":"onLeaveServerClick"},initialize:function(e){this.paneID=e.paneID,this.serverShare=e.serverShare,this.serverShare.populate();
var t=l.get("servers"),i=t.get(this.serverShare.get("machineIdentifier"));i?this.attachServer(i):this.listenTo(t,"add",this.onServerAdd)},flushChanges:function(){},attachServer:function(e){this.server=e,this.listenTo(e,"change:connected",this.render)},bindings:{".server-title":{model:"serverShare",modelAttribute:"name"},".server-status-btn":{model:"server",modelAttribute:"connected",manual:!0,formatter:function(e,t){t.removeClass("unknown available unauthorized unavailable"),t.addClass(null==e?"unknown":e?"available":this.server.get("unauthorized")?"unauthorized":"unavailable")
}},".server-detail-version":{model:"server",modelAttribute:"version"},".server-detail-last-seen":{model:"serverShare",modelAttribute:"lastSeenAt",formatter:function(e){return r.formatTimeAgo(e)}},".server-detail-address":{model:"server",modelAttribute:"activeConnection",formatter:function(e){return e&&e.address}},".server-detail-port":{model:"server",modelAttribute:"activeConnection",formatter:function(e){return e&&e.port}},".server-restriction-allow-sync":{model:"serverShare",modelAttribute:"allowSync",manual:!0,autohide:!0},".share-section-list":{model:"serverShare",modelAttribute:"Section",isHtml:!0,formatter:function(e){var n;
return e.length||"pending"!==this.serverShare.populatePromise.state()?(n="",i.each(i.where(e,{shared:!0}),function(e){var i={section:e,typeIcon:o.getSectionTypeByString(e.type).sectionTypeIcon};n+=t(i)})):n=t({section:{title:a("Loading...")},typeIcon:"hidden"}),n}}},onServerAdd:function(e){e.id===this.serverShare.get("machineIdentifier")&&(this.attachServer(e),this.unbindFromModel(),this.bindToModel())},onServerStatusClick:function(e){e.preventDefault();var t=n(e.currentTarget);t.toggleClass("active"),this.ui.details.toggleClass("transition-out",!t.hasClass("active"))
},onLeaveServerClick:function(e){e.preventDefault(),this.trigger("destroy:serverShare",this.serverShare)}});return c}),define("hb!templates/desktop/modals/user/EditFriendModalRestrictionsPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,o="";return o+='\n  <div class="form-group">\n    <div class="col-sm-offset-3 col-sm-9">\n      <div class="checkbox">\n        <label for="allow-sync-cb">\n          <input type="checkbox" id="allow-sync-cb" name="allowSync" ',s=i["if"].call(e,(n=e&&e.user,null==n||n===!1?n:n.allowSync),{hash:{},inverse:d.noop,fn:d.program(2,r,t),data:t}),(s||0===s)&&(o+=s),o+=">\n          ",a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow Sync",a):u.call(e,"t","Allow Sync",a)))+'\n        </label>\n      </div>\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label class="col-sm-3 control-label section-control-label">\n      <i class="section-type-icon glyphicon ',(s=i.moviesIcon)?s=s.call(e,{hash:{},data:t}):(s=e&&e.moviesIcon,s=typeof s===p?s.call(e,{hash:{},data:t}):s),o+=h(s)+'"></i> ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Movies",a):u.call(e,"t","Movies",a)))+'\n    </label>\n\n    <div class="col-sm-9 help-block section-help-block">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Restrict movies to any of the filters below.",a):u.call(e,"t","Restrict movies to any of the filters below.",a)))+'\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label for="filter-movie-contentRating" class="col-sm-3 control-label">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Ratings",a):u.call(e,"t","Ratings",a)))+'\n    </label>\n\n    <div class="col-sm-9">\n      <input type="text" id="filter-movie-contentRating" class="form-control tag-input-hidden" name="filterMovies" data-filter="contentRating" data-section-type="movie" placeholder="',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow all ratings",a):u.call(e,"t","Allow all ratings",a)))+'" value="'+h((n=e&&e.user,n=null==n||n===!1?n:n.filterMovies,n=null==n||n===!1?n:n.contentRating,typeof n===p?n.apply(e):n))+'">\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label for="filter-movie-label" class="col-sm-3 control-label">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Labels",a):u.call(e,"t","Labels",a)))+'\n    </label>\n\n    <div class="col-sm-9">\n      <input type="text" id="filter-movie-label" class="form-control tag-input-hidden" name="filterMovies" data-filter="label" data-section-type="movie" placeholder="',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow all labels",a):u.call(e,"t","Allow all labels",a)))+'" value="'+h((n=e&&e.user,n=null==n||n===!1?n:n.filterMovies,n=null==n||n===!1?n:n.label,typeof n===p?n.apply(e):n))+'">\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label class="col-sm-3 control-label section-control-label">\n      <i class="section-type-icon glyphicon ',(s=i.showsIcon)?s=s.call(e,{hash:{},data:t}):(s=e&&e.showsIcon,s=typeof s===p?s.call(e,{hash:{},data:t}):s),o+=h(s)+'"></i> ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"TV Shows",a):u.call(e,"t","TV Shows",a)))+'\n    </label>\n\n    <div class="col-sm-9 help-block section-help-block">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Restrict TV shows to any of the filters below.",a):u.call(e,"t","Restrict TV shows to any of the filters below.",a)))+'\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label for="filter-show-contentRating" class="col-sm-3 control-label">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Ratings",a):u.call(e,"t","Ratings",a)))+'\n    </label>\n\n    <div class="col-sm-9">\n      <input type="text" id="filter-show-contentRating" class="form-control tag-input-hidden" name="filterTelevision" data-filter="contentRating" data-section-type="show" placeholder="',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow all ratings",a):u.call(e,"t","Allow all ratings",a)))+'" value="'+h((n=e&&e.user,n=null==n||n===!1?n:n.filterTelevision,n=null==n||n===!1?n:n.contentRating,typeof n===p?n.apply(e):n))+'">\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label for="filter-show-label" class="col-sm-3 control-label">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Labels",a):u.call(e,"t","Labels",a)))+'\n    </label>\n\n    <div class="col-sm-9">\n      <input type="text" id="filter-show-label" class="form-control tag-input-hidden" name="filterTelevision" data-filter="label" data-section-type="show" placeholder="',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow all labels",a):u.call(e,"t","Allow all labels",a)))+'" value="'+h((n=e&&e.user,n=null==n||n===!1?n:n.filterTelevision,n=null==n||n===!1?n:n.label,typeof n===p?n.apply(e):n))+'">\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label class="col-sm-3 control-label section-control-label">\n      <i class="section-type-icon glyphicon ',(s=i.musicIcon)?s=s.call(e,{hash:{},data:t}):(s=e&&e.musicIcon,s=typeof s===p?s.call(e,{hash:{},data:t}):s),o+=h(s)+'"></i> ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Albums",a):u.call(e,"t","Albums",a)))+'\n    </label>\n  </div>\n\n  <div class="form-group">\n    <label for="filter-artist-label" class="col-sm-3 control-label">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Labels",a):u.call(e,"t","Labels",a)))+'\n    </label>\n\n    <div class="col-sm-9">\n      <input type="text" id="filter-artist-label" class="form-control tag-input-hidden" name="filterMusic" data-filter="label" data-section-type="artist" placeholder="',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow all labels",a):u.call(e,"t","Allow all labels",a)))+'" value="'+h((n=e&&e.user,n=null==n||n===!1?n:n.filterMusic,n=null==n||n===!1?n:n.label,typeof n===p?n.apply(e):n))+'">\n    </div>\n  </div>\n\n  <div class="form-group">\n    <label class="col-sm-3 control-label section-control-label">\n      <i class="section-type-icon glyphicon ',(s=i.photosIcon)?s=s.call(e,{hash:{},data:t}):(s=e&&e.photosIcon,s=typeof s===p?s.call(e,{hash:{},data:t}):s),o+=h(s)+'"></i> ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Photos",a):u.call(e,"t","Photos",a)))+'\n    </label>\n  </div>\n\n  <div class="form-group">\n    <label for="filter-photo-label" class="col-sm-3 control-label">\n      ',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Labels",a):u.call(e,"t","Labels",a)))+'\n    </label>\n\n    <div class="col-sm-9">\n      <input type="text" id="filter-photo-label" class="form-control tag-input-hidden" name="filterPhotos" data-filter="label" data-section-type="photo" placeholder="',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"Allow all labels",a):u.call(e,"t","Allow all labels",a)))+'" value="'+h((n=e&&e.user,n=null==n||n===!1?n:n.filterPhotos,n=null==n||n===!1?n:n.label,typeof n===p?n.apply(e):n))+'">\n    </div>\n  </div>\n'
}function r(){return"checked"}function o(e,t){var n,s,a,r="";return r+='\n  <div class="row row-padded">\n    <h4 class="text-muted text-center">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"You need a Plex Pass to use restrictions.",a):u.call(e,"t","You need a Plex Pass to use restrictions.",a)))+'</h4>\n\n    <p class="text-center">\n      <a class="btn btn-sm btn-primary" href="',(s=i.plexPassUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.plexPassUrl,s=typeof s===p?s.call(e,{hash:{},data:t}):s),r+=h(s)+'" target="_blank">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Learn More",a):u.call(e,"t","Learn More",a)))+"</a>\n    </p>\n  </div>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c="",d=this,u=i.helperMissing,h=this.escapeExpression,p="function";return l=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:d.program(4,o,s),fn:d.program(1,a,s),data:s}),(l||0===l)&&(c+=l),c+="\n"})}),define("plex/desktop/views/modals/user/EditFriendModalRestrictionsPane",["hb!templates/desktop/modals/user/EditFriendModalRestrictionsPane.tpl","underscore","jquery","marionette","plex/base/utils/types/sectionTypes","plex/base/models/appModel","plex/base/models/library/section/FilterModel","selectize"],function(e,t,i,n,s,a,r){"use strict";
var o=n.ItemView.extend({className:"form-horizontal",template:e,filters:{contentRating:{sectionTypes:["movie","show"],presets:{movie:["G","PG","PG-13","R","NC-17","None"],show:["TV-Y","TV-Y7","TV-G","TV-PG","TV-14","TV-MA","None"]}},label:{sectionTypes:["movie","show","artist","photo"]}},filterByType:{movie:"filterMovies",show:"filterTelevision",artist:"filterMusic",photo:"filterPhotos"},ui:{tagInputs:".tag-input-hidden"},events:{"change input":"onInputChange"},initialize:function(e){this.paneID=e.paneID,this.type=e.type;
var t=a.get("user");this.hasPlexPass=t.hasPlexPass(),this.plexPassUrl=t.server.get("plexPassUrl"),this.changes={}},serializeData:function(){return{user:this.model.toJSON(),hasPlexPass:this.hasPlexPass,plexPassUrl:this.plexPassUrl,moviesIcon:s.getSectionType("movies").sectionTypeIcon,showsIcon:s.getSectionType("tv").sectionTypeIcon,musicIcon:s.getSectionType("music").sectionTypeIcon,photosIcon:s.getSectionType("photos").sectionTypeIcon}},loadPresets:function(){t.each(this.filters,function(e,i){t.isEmpty(e.presets)||t.each(e.presets,function(e,n){var s=this.getSelectizeInputByFilterName(i,n),a=t.map(e,function(e){return{title:e,key:e}
});s.addOption(a)},this)},this)},loadSections:function(){var e=a.get("servers"),i=this.model.get("serverShares"),n=i.filter(function(e){return e.isActive()&&e.get("owned")}),s=t.compact(t.map(n,function(t){return e.get(t.get("machineIdentifier"))}));t.each(s,function(e){if(e.get("connected")){var i=e.get("sections");i.populate().done(t.bind(function(){this.loadFilters(i)},this))}},this)},loadFilters:function(e){e.each(function(e){var i=e.get("type");t.each(this.filters,function(n,s){t.contains(n.sectionTypes,i)&&this.loadFilterOptions(e,s)
},this)},this)},loadFilterOptions:function(e,i){var n=new r({filter:i,filterType:"string"},{server:e.server,section:e}),s=n.get("options");s.populate().done(t.bind(function(){var t=this.getSelectizeInputByFilterName(i,e.get("type"));t.addOption(s.toJSON())},this))},getSelectizeInputByFilterName:function(e,t){var i="#filter-"+t+"-"+e;return this.$(i)[0].selectize},resetAllPlaceholders:function(){var e=[];t.each(this.filters,function(i){e=t.union(e,i.sectionTypes)}),t.each(e,function(e){var i=this.model.get(this.filterByType[e]);
this.resetPlaceholders(e,{restore:t.isEmpty(i)})},this)},resetPlaceholders:function(e,t){t||(t={});var i=this.$("input[data-section-type="+e+"]");i.each(function(){var e=t.restore?this.placeholder:"";e?(this.selectize.settings.placeholder=e,this.selectize.updatePlaceholder()):this.selectize.$control_input.attr("placeholder","")})},flushChanges:function(){this.model.set(this.changes)},onRender:function(){this.hasPlexPass&&(this.ui.tagInputs.selectize({plugins:["remove_button"],create:!0,labelField:"title",valueField:"title",sortField:"title",searchField:["title"]}),this.resetAllPlaceholders(),this.loadSections(),this.loadPresets())
},onInputChange:function(e){var n=e.currentTarget,s=i(n),a=n.value,r=s.data("filter"),o=s.data("sectionType");if(r){var l=this.changes[n.name]||this.model.get(n.name)||{};a?l[r]=a:l.hasOwnProperty(r)&&delete l[r],this.resetPlaceholders(o,{restore:t.isEmpty(l)}),a=l}else"checkbox"===n.type&&(a=n.checked);this.changes[n.name]=a}});return o}),define("plex/desktop/views/modals/user/EditFriendModal",["hb!templates/desktop/modals/user/EditFriendModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/user/FriendModel","plex/base/models/user/HomeUserModel","plex/base/models/server/ServerOverviewCollection","plex/desktop/views/modals/BaseModal","plex/desktop/views/modals/user/EditFriendModalNavList","plex/desktop/views/modals/user/EditFriendModalUsernamePane","plex/desktop/views/modals/user/EditFriendModalGeneralPane","plex/desktop/views/modals/user/EditFriendModalOwnedServerPane","plex/desktop/views/modals/user/EditFriendModalSharedServerPane","plex/desktop/views/modals/user/EditFriendModalRestrictionsPane","plex/base/views/images/GravatarImage","plex/desktop/views/modals/user/UserSelectModal","plex/desktop/views/modals/user/HomeWarningModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y,b,w){"use strict";
var x=u.extend({name:"editFriendModal",className:"edit-friend-modal modal modal-lg fade",template:e,panes:{username:p,general:m,ownedServer:f,sharedServer:g,restrictions:v},ui:{poster:".modal-poster",title:".modal-title",message:".form-message",nextBtn:".next-btn",submitBtn:".submit-btn"},regions:{nav:".modal-nav-pane",body:".modal-body-pane"},events:t.extend({"submit #share-server-form":"onSubmit"},u.prototype.events),initialize:function(e){u.prototype.initialize.apply(this,arguments),e||(e={}),this.type=e.type||"friend",this.isAdmin=e.isAdmin,this.defaultPaneType=e.defaultPaneType,this.defaultPaneID=e.defaultPaneID,"home"===this.type&&this.initHomeUser(e),this.initModel(e),this.initServerOverviews(e),this.initServerShares(e),this.image=new y({model:this.model,type:"friend",width:40}),this.listenTo(this.body,"show",this.onShowPane)
},initHomeUser:function(e){if(this.homeUser=e.homeUser,this.homeUser){var t=o.get("user"),i=t.get("friends");this.model=i.findWhere({id:e.homeUser.id}),this.tempHomeUser=this.homeUser.clone()}else this.tempHomeUser=new c({admin:!1},{server:o.get("user").server})},initModel:function(){this.model?this.tempModel=this.model.cloneDeep():(this.tempModel=new l({},{server:o.get("user").server}),this.tempModel.parseServers({Server:[]}))},initServerOverviews:function(){var e=o.get("servers"),i=o.get("user"),n=this.tempModel.get("serverOverviews");
n||(n=new d([],{server:i.server,parent:this.tempModel}),this.tempModel.set("serverOverviews",n));var s=e.filter(function(e){var t=!e.get("shared")&&!e.get("cloud"),i=!e.get("synced")||e.get("isCloudSync");return e.id&&t&&i});t.each(s,function(e){var t=n.add({machineIdentifier:e.id,name:e.get("friendlyName")});t.populate()})},initServerShares:function(){var e=this.tempModel.get("serverShares");e.each(function(e){e.populate()})},serializeData:function(){return{type:this.type,title:this.tempModel.get("title")}
},showNextPane:function(e){var t,i={};if(e||(e=this.tempModel.isNew()?"username":this.defaultPaneType||"general"),"ownedServer"===e||"sharedServer"===e){var n,s;if("ownedServer"===e?(n=this.tempModel.get("serverOverviews"),s="serverOverview"):(n=this.tempModel.get("serverShares"),s="serverShare"),n.length){var a;this.defaultPaneID&&(a=n.findWhere({machineIdentifier:this.defaultPaneID})),a||(a=n.first()),t=a.id,i[s]=a}else e="general"}t||(t=e),this.showPane(e,t,i)},showPane:function(e,i,n){this.currentPane&&(this.currentPane.flushChanges(),this.stopListening(this.currentPane),"username"===this.currentPane.paneID&&(this.ui.title.text(this.tempModel.get("username")||this.tempModel.get("title")),this.findExistingFriend()));
var s=this.panes[e],a=new s(t.extend({paneID:i,model:this.tempModel,homeUser:this.tempHomeUser,type:this.type,isAdmin:this.isAdmin},n));return this.listenTo(a,{"change:pane":this.onChangePane,"change:errorMessage":this.onErrorMessageChange,"enable:submit":this.onEnableSubmit,"destroy:homeUser":this.onHomeUserDestroy,"destroy:friend":this.onFriendDestroy,"destroy:serverShare":this.onServerShareDestroy}),this.currentPane=a,this.nav.currentView.selectItem(i),this.body.show(a),a},getSubmitBtn:function(){return this.currentPane&&"username"===this.currentPane.paneID?this.ui.nextBtn:this.ui.submitBtn
},findExistingFriend:function(){var e,t=o.get("user"),i=t.get("friends"),n=this.tempModel.get("username");if(this.tempModel.get("restricted")?e=i.findWhere({restricted:!0,title:n}):(e=i.findWhere({username:n}),e||(e=i.findWhere({email:n}))),e){var s=this.tempModel.get("serverOverviews");this.model=e,this.tempModel=e.cloneDeep(),this.tempModel.set("serverOverviews",s),this.initServerShares(),this.image.setModel(this.model),this.image.render(),this.nav.currentView.setModel(this.tempModel)}},sendRequests:function(){var e=this.tempHomeUser&&this.tempHomeUser.isNew(),r=!e&&this.tempModel.isNew(),l=[];
l.push(this.sendFriendInvite()),l.push(this.sendHomeInvite());var c=i.when.apply(i,l);return c=c.then(t.bind(function(){return Array.prototype.push.apply(l,this.sendServerShareInvites()),this.tempModel.isNew()||l.push(this.tempModel.save({},{parse:!1})),this.tempHomeUser&&!e&&l.push(this.tempHomeUser.save()),i.when.apply(i,l)},this)),c.done(t.bind(function(){var e=o.get("user");e.get("friends").fetch(),"home"===this.type&&e.get("homeUsers").fetch(),this.tempModel.get("restricted")||e.get("sentInvites").fetch(),this.hide()
},this)),c.fail(t.bind(function(i){var o=a.parseXML(i.responseText),l=o&&o.status;t.isString(l)||(l=n(e?"This user could not be added to your home.":r?"An invite could not be sent to this user.":"Your changes could not be saved.")),s.trigger("show:alert",{type:"error",message:l})},this)),c},sendFriendInvite:function(){if("friend"===this.type){var e=this.tempModel.get("serverShares").getActiveCount();return this.tempModel.isNew()&&!e?this.tempModel.save({user:this.tempModel.get("username")}):void 0
}},sendHomeInvite:function(){if("home"===this.type&&this.tempHomeUser.isNew()){var e=this.tempHomeUser.save();return e.done(t.bind(function(){if(this.tempHomeUser.get("restricted")){this.tempModel.set("id",this.tempHomeUser.id);var e=o.get("user");e.set("home",!0)}this.showHomeWarnings()},this)),e}},showHomeWarnings:function(){var e=o.get("user"),t=e.get("homeUsers"),i=t.get(e.id);if(!(i.get("protected")||t.length>1)){var n=new b({model:i,isEditing:!0,isEditWarning:!0});n.promise.always(function(){s.trigger("show:modal",new w({type:"home"}))
}),s.trigger("show:modal",n)}},sendServerShareInvites:function(){var e=this.model&&this.model.get("serverShares").filterByOwned(),i=this.tempModel.get("serverShares").filterByOwned(),n=e?e.pluck("machineIdentifier"):[],s=i?i.pluck("machineIdentifier"):[],a=t.union(n,s),o=[];return t.each(a,function(t){var n=e&&e.findWhere({machineIdentifier:t}),s=i&&i.findWhere({machineIdentifier:t}),a=n&&n.isActive(),l=s&&s.isActive();l?o.push(r.execute("shareServer",{user:this.tempModel,serverShare:s})):a&&o.push(n.destroy({wait:!0}))
},this),o},onRender:function(){u.prototype.onRender.apply(this,arguments),this.image.setElement(this.ui.poster);var e=new h({model:this.tempModel});this.listenTo(e,"change:pane",this.onChangePane),this.nav.show(e),this.showNextPane()},onClose:function(){this.image.close()},onChangePane:function(e,t,i){t||(t=e),this.showPane(e,t,i)},onShowPane:function(){var e="username"===this.currentPane.paneID;this.nav.currentView.toggleDisabled(e),this.ui.nextBtn.toggleClass("hidden",!e),this.ui.submitBtn.toggleClass("hidden",e)
},onErrorMessageChange:function(e){this.ui.message.text(e)},onEnableSubmit:function(e){this.getSubmitBtn().toggleClass("disabled",!e)},onHomeUserDestroy:function(){if(this.homeUser){var e=r.execute("removeHomeUser",{homeUser:this.homeUser});e.done(t.bind(this.hide,this))}},onFriendDestroy:function(){if(this.model){var e=r.execute("removeFriend",{friend:this.model});e.done(t.bind(this.hide,this))}},onServerShareDestroy:function(e){var i=r.execute("removeServerShare",{serverShare:e});i.done(t.bind(function(){var t=this.model.get("serverShares");
t.remove(e.id),this.showNextPane("general")},this))},onSubmit:function(e){e.preventDefault();var i=this.getSubmitBtn();if(!i.isDisabled()){if("username"===this.currentPane.paneID)return void this.showNextPane("ownedServer");i.addClass("active"),this.currentPane.flushChanges(),this.sendRequests().fail(t.bind(function(){this.ui.submitBtn.removeClass("active")},this))}}});return x}),define("hb!templates/desktop/alerts/PremiumMusicAlertBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<button type="button" class="close-btn btn-link"><i class="glyphicon remove-2"></i></button>\n\n<span class="message">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Experience new music features with a premium music library.",r):l.call(t,"t","Experience new music features with a premium music library.",r)))+'</span>\n<a class="create-link link" href="#">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Create a library",r):l.call(t,"t","Create a library",r)))+'</a>\n<span class="message message-separator">&middot;</span>\n<a class="learn-more-link link" href="https://plex.tv/music" target="_blank">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Learn more",r):l.call(t,"t","Learn more",r)))+"</a>\n"
})}),define("plex/desktop/views/alerts/PremiumMusicAlertBarView",["hb!templates/desktop/alerts/PremiumMusicAlertBarView.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/desktop/views/alerts/AlertBarView","plex/desktop/views/modals/EditSectionModal"],function(e,t,i,n,s,a,r,o){"use strict";var l=r.extend({className:"premium-music-alert-bar alert-bar notify",template:e,events:t.extend({"click .create-link":"onCreateClick"},r.prototype.events),onCreateClick:function(e){e.preventDefault();
var a=this.options.seed,r=i.extend(!0,[],a.get("Location")),l=t.extend({type:"music",title:n("Premium {1}",a.get("title")),language:a.get("language"),Location:r});s.trigger("show:modal",new o({server:this.model,seedAttrs:l,redirect:!0})),this.hide()},onCloseClick:function(){r.prototype.onCloseClick.apply(this,arguments),a.save("hasDismissedPremiumMusicAlert",!0)}});return l}),define("plex/desktop/views/lists/dashboard/DashboardServerListItem",["hb!templates/desktop/lists/dashboard/DashboardServerListItem.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/server/serverStorageModel","plex/desktop/views/lists/dashboard/DashboardSectionListItem","plex/desktop/views/modals/EditSectionModal","plex/desktop/views/modals/user/EditFriendModal","plex/desktop/views/alerts/PremiumMusicAlertBarView"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=i.CompositeView.extend({tagName:"li",className:"dashboard-server-list-item",template:e,itemView:c,itemViewContainer:".dashboard-section-list",itemViewOptions:function(){return{showActions:this.showActions}},ui:{actions:".side-bar-actions",selectServerBtn:".select-server-btn",updateBtnLabel:".update-btn .dropdown-truncated-label",secureConnectionIcon:".secure-connection-icon"},modelEvents:{"change:connected":"onConnectedChange","change:shared":"onSharedChange","change:activeConnection":"onActiveConnectionChange"},events:{"click .select-server-btn":"onSelectServerClick","click .add-library-btn":"onAddLibraryClick","click .settings-btn":"onSettingsClick","click .share-btn":"onShareClick","click .update-btn":"onUpdateClick","click .optimize-btn":"onOptimizeClick","click .clean-bundles-btn":"onCleanBundlesClick","click .empty-trash-btn":"onEmptyTrashClick","click .mixed-content-btn":"onMixedContentClick","click .remove-btn":"onRemoveClick"},onlyAfterRender:["onPrimaryServerChange","onSectionsChange","onSectionRefreshingChange"],initialize:function(){this.collection=this.model.get("sections"),this.user=o.get("user"),this.listenTo(o,"change:primaryServer",this.onPrimaryServerChange),this.listenTo(this.user,"change:signedIn",this.onSignedInChange),this.setup()
},setup:function(){var e=this.model.get("shared")||this.model.get("synced");if(this.allowCancel=this.model.supports("cancelAllUpdates")&&!e,this.showActions=!e,this.model.get("connected")){this.allowCancel&&this.collection.length&&this.updateRefreshingStatus();var i=!this.collection.populatePromise,n=i?"reset":"add remove",s=this.collection.fetch({reset:i}),r=this.model===o.get("primaryServer"),l=a.get("hasDismissedPremiumMusicAlert");e||!r||l||s.done(t.bind(this.checkForPremiumMusic,this)),this.allowCancel&&(this.listenTo(this.collection,n,this.onSectionsChange),this.listenTo(this.collection,"change:refreshing",this.onSectionRefreshingChange))
}},serializeData:function(){var e=o.get("primaryServer"),t=this.model.toJSON(),i=this.model.useHostedHttps&&t.presence&&!t.available;return{server:t,selected:e&&this.model.id===e.id,signedIn:this.user.get("signedIn"),canBePrimary:this.model.canBePrimary(),showActions:this.showActions,showChannels:this.showActions&&a.get("dashboardChannelsEnabled"),showPlaylists:this.model.supports("playlists")&&!this.model.get("synced"),showUnavailableMessage:!i&&!t.available,showMixedContentMessage:i,hasRefreshingSection:this.hasRefreshingSection,hasSecureConnection:this.model.hasSecureConnection()}
},updateRefreshingStatus:function(){this.hasRefreshingSection=this.collection.some(function(e){return e.get("refreshing")})},getUpdateLabel:function(){return n(this.hasRefreshingSection?"Cancel Update":"Update Libraries")},checkForPremiumMusic:function(){if(!this.user.get("signedIn"))return void this.listenToOnce(this.user,"change:signedIn",this.checkForPremiumMusic);if(this.user.hasPlexPass()&&this.model.supports("premiumMusic")){var e=this.collection.findWhere({agent:"com.plexapp.agents.lastfm"}),t=this.collection.findWhere({agent:"com.plexapp.agents.plexmusic"});
e&&!t&&s.trigger("show:bar","alertbar",new h({model:this.model,seed:e}))}},onPrimaryServerChange:function(e,t){this.ui.selectServerBtn.toggleClass("selected",t&&t.id===this.model.id)},onSignedInChange:function(e,t){this.ui.actions.toggleClass("signed-in",!!t)},onSectionsChange:function(){this.updateRefreshingStatus(),this.ui.updateBtnLabel.text(this.getUpdateLabel())},onSectionRefreshingChange:function(e,t){this.hasRefreshingSection=t,this.ui.updateBtnLabel.text(this.getUpdateLabel())},onConnectedChange:function(){this.setup(),this.render()
},onSharedChange:function(){this.render()},onActiveConnectionChange:function(e){this.ui.secureConnectionIcon.toggleClass("hidden",!e.hasSecureConnection())},onSelectServerClick:function(e){e.preventDefault();var t=this.ui.selectServerBtn;t.hasClass("disabled")||t.hasClass("selected")||(o.set("primaryServer",this.model),l.save("lastPrimaryServerID",this.model.id))},onAddLibraryClick:function(e){e.preventDefault(),s.trigger("show:modal",new d({server:this.model,redirect:!0}))},onSettingsClick:function(e){e.preventDefault(),s.trigger("navigate","serverSettings",{serverID:this.model.id})
},onShareClick:function(e){e.preventDefault(),s.trigger("show:modal",new u({defaultPaneType:"ownedServer",defaultPaneID:this.model.id}))},onUpdateClick:function(e){e.preventDefault();var t=this.allowCancel?this.hasRefreshingSection:!1;r.execute("updateLibrary",{server:this.model,cancel:t})},onOptimizeClick:function(e){e.preventDefault(),r.execute("optimize",{server:this.model})},onCleanBundlesClick:function(e){e.preventDefault(),r.execute("cleanBundles",{server:this.model})},onEmptyTrashClick:function(e){e.preventDefault(),r.execute("emptyTrash",{server:this.model})
},onMixedContentClick:function(e){e.preventDefault(),r.execute("redirectToHttp")},onRemoveClick:function(e){e.preventDefault(),r.execute("removeServer",{server:this.model})}});return p}),define("plex/desktop/views/lists/dashboard/DashboardServerList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/dashboard/DashboardServerListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list dashboard-server-list",itemView:t,sorted:!0});return i}),define("plex/desktop/views/sidebar/DashboardSideBarView",["hb!templates/desktop/sidebar/DashboardSideBarView.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/models/server/ServerCollection","plex/base/commands/commands","plex/desktop/views/dashboard/DashboardEmptyServersView","plex/desktop/views/lists/dashboard/DashboardServerList"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=i.Layout.extend({className:"side-bar dark-scrollbar",template:e,regions:{empty:".dashboard-empty-servers-container",servers:".dashboard-servers-container"},initialize:function(){var e=s.get("servers"),t=e.filter(this.isAuthorized),i=e.filter(this.isUnavailableOwned),n=e.filter(this.isSharedSecurePresentAndUnavailable),r=t.concat(i,n);this.collection=new a(r),this.listenTo(s,"change:primaryServer",this.onPrimaryServerChange),this.listenTo(e,"remove",this.onServerRemove),this.listenTo(e,"change:connected",this.onServerConnectedChange),this.listenTo(e,"change:presence",this.onServerPresenceChange)
},showEmptyView:function(){if(!this.collection.length&&s.get("primaryServer")===!1){var e=s.get("servers"),t=!!e.where({cloud:!1,shared:!0}).length,i=!s.get("user").isFullUser();this.empty.show(new o({hasSharedServers:t,isManagedUser:i}))}},isAuthorized:function(e){return e.id&&!e.get("cloud")&&e.get("authorized")},isUnavailableOwned:function(e){var t=e.get("shared")||e.get("synced");return e.id&&!e.get("cloud")&&!t&&!e.get("available")},isSharedSecurePresentAndUnavailable:function(e){return e.get("shared")&&e.get("presence")&&e.useHostedHttps&&!e.get("available")
},onRender:function(){this.showEmptyView(),this.servers.show(new l({collection:this.collection}))},onPrimaryServerChange:function(){this.showEmptyView()},onServerRemove:function(e){this.collection.remove(e.cid),this.showEmptyView()},onServerConnectedChange:function(e){this.isAuthorized(e)||this.isUnavailableOwned(e)||this.isSharedSecurePresentAndUnavailable(e)?this.collection.add(e):this.collection.remove(e)},onServerPresenceChange:function(e){this.isSharedSecurePresentAndUnavailable(e)&&this.collection.add(e)
}});return c}),define("hb!templates/desktop/dashboard/DashboardMediaView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<ul class="nav nav-header nav-dashboard pull-right">\n  <li><a class="previous-btn btn-gray" href="#"><i class="glyphicon chevron-left"></i></a></li>\n  <li><a class="next-btn btn-gray" href="#"><i class="glyphicon chevron-right"></i></a></li>\n</ul>\n\n<h2>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,t&&t.label,r):l.call(t,"t",t&&t.label,r)))+'</h2>\n\n<div class="dashboard-list-container"></div>\n'
})}),define("plex/desktop/views/lists/HorizontalTileList",["plex/desktop/views/lists/BaseList"],function(e){"use strict";var t=e.extend({measure:!0,page:1,pagesPadding:1,itemViewOptions:{skipFirstRender:!0},initialize:function(e){this.$container=e.$container},scroll:function(){var e=(this.page-1)*this.pageWidth,t=(this.page-1)*this.itemsPerPage,i=t+this.itemsPerPage;t-=this.itemsPadding,i+=this.itemsPadding;for(var n=0,s=this.children.length;s>n;n++){var a=this.children.findByIndex(n);n>=t&&i>n?a.show():a.hide()
}this.trigger("scroll",this,this.page,-1*e)},previous:function(){this.page=Math.max(this.page-1,1),this.scroll()},next:function(){this.page=Math.min(this.page+1,this.pages),this.scroll()},onMeasure:function(){this.containerWidth=this.$container.width(),this.listWidth=this.itemWidth*this.children.length,this.itemsPerPage=Math.floor((this.containerWidth+this.itemMarginRight)/this.itemWidth),this.itemsPadding=this.pagesPadding*this.itemsPerPage,this.pageWidth=this.itemWidth*this.itemsPerPage,this.pages=Math.ceil(this.listWidth/this.pageWidth),this.$el.width(this.listWidth),this.$el.removeClass("hidden"),this.page=1,this.scroll()
},onCollectionBeforeClose:function(){this.isClosing=!0},onCollectionClosed:function(){this.isClosing=!1},onItemRemoved:function(){this.isClosing||this.measureList()}});return t}),define("hb!templates/desktop/lists/library/MediaTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hide-actions"}function r(){return"selected"}function o(){return"hidden"}function l(){return'\n      <span class="media-added-at"></span>\n    '}function c(e,t){var n,s,a;return a={hash:{},inverse:x.program(12,u,t),fn:x.program(10,d,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"originallyAvailableAt",a):k.call(e,"if_eq",e&&e.sort,"originallyAvailableAt",a),s||0===s?s:""
}function d(){return'\n      <span class="media-available-at"></span>\n    '}function u(e,t){var n,s,a;return a={hash:{},inverse:x.program(15,p,t),fn:x.program(13,h,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"rating",a):k.call(e,"if_eq",e&&e.sort,"rating",a),s||0===s?s:""}function h(){return'\n      <span class="media-rating"></span>\n    '}function p(e,t){var n,s,a;return a={hash:{},inverse:x.program(18,f,t),fn:x.program(16,m,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"mediaHeight",a):k.call(e,"if_eq",e&&e.sort,"mediaHeight",a),s||0===s?s:""
}function m(){return'\n      <span class="media-resolution"></span>\n    '}function f(e,t){var n,s,a;return a={hash:{},inverse:x.noop,fn:x.program(19,g,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"duration",a):k.call(e,"if_eq",e&&e.sort,"duration",a),s||0===s?s:""}function g(){return'\n      <span class="media-duration"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var v,y,b,w="",x=this,k=i.helperMissing,S="function",C=this.escapeExpression;return w+='<a class="media-poster-container ',v=i.unless.call(t,t&&t.showActions,{hash:{},inverse:x.noop,fn:x.program(1,a,s),data:s}),(v||0===v)&&(w+=v),w+=" ",v=i["if"].call(t,t&&t.selected,{hash:{},inverse:x.noop,fn:x.program(3,r,s),data:s}),(v||0===v)&&(w+=v),w+='" href="',(v=i.url)?v=v.call(t,{hash:{},data:s}):(v=t&&t.url,v=typeof v===S?v.call(t,{hash:{},data:s}):v),w+=C(v)+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="media-poster-overlay-icons with-actions">\n      <i class="analyzing-icon media-poster-overlay-icon glyphicon magic hidden"></i>\n      <i class="matching-icon media-poster-overlay-icon glyphicon search hidden"></i>\n      <i class="metadata-icon media-poster-overlay-icon glyphicon tags hidden"></i>\n      <i class="trash-icon media-poster-overlay-icon glyphicon bin warning hidden"></i>\n    </div>\n\n    <div class="media-poster-actions ',v=i.unless.call(t,t&&t.showActions,{hash:{},inverse:x.noop,fn:x.program(5,o,s),data:s}),(v||0===v)&&(w+=v),w+='">\n      <button class="play-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="play-unwatched-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="more-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n\n    <span class="media-count-badge badge badge-lg hidden"></span>\n    <span class="unwatched-count-badge badge badge-lg hidden"></span>\n\n    <div class="media-progress"></div>\n    <div class="loading loading-inline"></div>\n  </div>\n\n  <span class="unwatched-icon"></span>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n  <div class="media-subtitle-2 media-heading secondary"></div>\n  <div class="media-context media-heading secondary"></div>\n\n  <div class="media-sort media-heading secondary">\n    ',b={hash:{},inverse:x.program(9,c,s),fn:x.program(7,l,s),data:s},v=i.if_eq||t&&t.if_eq,y=v?v.call(t,t&&t.sort,"addedAt",b):k.call(t,"if_eq",t&&t.sort,"addedAt",b),(y||0===y)&&(w+=y),w+='\n  </div>\n\n  <div class="media-subtitle-1-fill media-heading hidden"></div>\n  <div class="media-subtitle-2-fill media-heading hidden"></div>\n</a>\n\n<div class="media-actions-dropdown dropdown">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("hb!templates/desktop/lists/library/MediaListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"show-actions"}function r(){return"selected"}function o(){return"hidden"}function l(){return'\n      <span class="media-added-at"></span>\n    '}function c(e,t){var n,s,a;return a={hash:{},inverse:x.program(12,u,t),fn:x.program(10,d,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"originallyAvailableAt",a):k.call(e,"if_eq",e&&e.sort,"originallyAvailableAt",a),s||0===s?s:""
}function d(){return'\n      <span class="media-available-at"></span>\n    '}function u(e,t){var n,s,a;return a={hash:{},inverse:x.program(15,p,t),fn:x.program(13,h,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"rating",a):k.call(e,"if_eq",e&&e.sort,"rating",a),s||0===s?s:""}function h(){return'\n      <span class="media-rating"></span>\n    '}function p(e,t){var n,s,a;return a={hash:{},inverse:x.program(18,f,t),fn:x.program(16,m,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"mediaHeight",a):k.call(e,"if_eq",e&&e.sort,"mediaHeight",a),s||0===s?s:""
}function m(){return'\n      <span class="media-resolution"></span>\n    '}function f(e,t){var n,s,a;return a={hash:{},inverse:x.noop,fn:x.program(19,g,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"duration",a):k.call(e,"if_eq",e&&e.sort,"duration",a),s||0===s?s:""}function g(){return'\n      <span class="media-duration"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var v,y,b,w="",x=this,k=i.helperMissing,S="function",C=this.escapeExpression;return w+='<a class="media-list-inner-item ',v=i["if"].call(t,t&&t.showActions,{hash:{},inverse:x.noop,fn:x.program(1,a,s),data:s}),(v||0===v)&&(w+=v),w+=" ",v=i["if"].call(t,t&&t.selected,{hash:{},inverse:x.noop,fn:x.program(3,r,s),data:s}),(v||0===v)&&(w+=v),w+='" href="',(v=i.url)?v=v.call(t,{hash:{},data:s}):(v=t&&t.url,v=typeof v===S?v.call(t,{hash:{},data:s}):v),w+=C(v)+'">\n  <div class="media-actions ',v=i.unless.call(t,t&&t.showActions,{hash:{},inverse:x.noop,fn:x.program(5,o,s),data:s}),(v||0===v)&&(w+=v),w+='">\n    <button class="play-btn media-action-btn" tabindex="-1"><i class="glyphicon play"></i></button>\n    <button class="play-unwatched-btn media-action-btn" tabindex="-1"><i class="glyphicon play"></i></button>\n    <button class="edit-btn media-action-btn btn-link btn-loading btn-loading-static" tabindex="-1">\n      <i class="btn-label glyphicon pencil"></i>\n      <div class="loading loading-sm"></div>\n    </button>\n    <button class="more-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n  </div>\n\n  <span class="media-title media-heading"></span>\n  <span class="media-subtitle-2 media-heading secondary"></span>\n  <span class="media-subtitle-1 media-heading secondary"></span>\n  <span class="unwatched-icon"></span>\n  <span class="media-context media-heading secondary"></span>\n\n  <span class="media-sort media-heading secondary">\n    ',b={hash:{},inverse:x.program(9,c,s),fn:x.program(7,l,s),data:s},v=i.if_eq||t&&t.if_eq,y=v?v.call(t,t&&t.sort,"addedAt",b):k.call(t,"if_eq",t&&t.sort,"addedAt",b),(y||0===y)&&(w+=y),w+='\n  </span>\n</a>\n\n<div class="media-actions-dropdown dropdown pull-right">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/mixins/multiselectListItemMixin",["underscore"],function(e){"use strict";var t={triggerAutoselect:function(e){this.trigger("autoselect",{shiftKey:e.shiftKey})},stopTrackingSelecting:function(e,t){return this.isTrackingSelecting?(e.preventDefault(),void(this.isTrackingSelecting=!1)):void(t&&t.call(this,e))},onMouseEnter:function(e){this.parentMediaActions&&this.parentMediaActions.get("selecting")&&this.triggerAutoselect(e)},onMouseLeave:function(e){this.stopTrackingSelecting(e)
},onMouseDown:function(t){if(this.parentMediaActions&&this.parentMediaActions.shouldStartTrackingSelecting(t)){var i=e.bind(function(){this.ignoreOnClick=!0},this);this.listenToOnce(this.parentMediaActions,"change:selectedItems",i),this.isTrackingSelecting=!0,this.trigger("select",{multiSelect:t.shiftKey}),this.stopListening(this.parentMediaActions,"change:selectedItems",i)}},onClick:function(e){this.ignoreOnClick&&(this.ignoreOnClick=!1,e.preventDefault())}};return t}),define("hb!templates/desktop/lists/library/MediaProgressView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="media-progress-track"></div>\n<div class="media-progress-pct"></div>\n'
})}),define("plex/desktop/views/lists/library/MediaProgressView",["hb!templates/desktop/lists/library/MediaProgressView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({className:"hidden",template:e,bindings:{".media-progress-pct":{modelAttribute:"viewOffset",manual:!0,formatter:function(e,t){var i=!!e&&"track"!==this.model.get("type");if(i){var n=Math.round(e/this.model.get("duration")*100);t.css("width",n+"%")}this.$el.toggleClass("hidden",!i)}}}});return i}),define("plex/desktop/views/lists/library/MediaListItem",["hb!templates/desktop/lists/library/MediaListItem.tpl","jquery","underscore","moment","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/mediaUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/utils/formatters/metadataUtil","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/desktop/mixins/multiselectListItemMixin","plex/desktop/models/MediaActionsModel","plex/desktop/views/lists/library/MediaProgressView","plex/desktop/views/RatingView","plex/desktop/views/dropdowns/MediaActionsDropdown","plex/desktop/views/modals/EditMetadataModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v){"use strict";
var y=s.Layout.extend({mixins:[h],tagName:"li",className:"striped-list-item media-list-item",template:e,visible:!1,ui:{container:".media-list-inner-item",actions:".media-actions",dropdown:".media-actions-dropdown"},regions:{rating:".media-rating",progress:".media-progress"},events:{"mouseenter > a":"onMouseEnter","mouseleave > a":"onMouseLeave","mousedown > a":"onMouseDown","click > a":"onClick","click .play-btn":"onPlayClick","click .play-unwatched-btn":"onPlayUnwatchedClick","click .edit-btn":"onEditClick","click .more-btn":"onMoreClick","click .media-title-link":"onTitleClick","hide.bs.dropdown .media-actions-dropdown":"onDropdownHide"},onlyAfterRender:["select","deselect"],initialize:function(e){i.bindAll(this,"onResize"),this.skipFirstRender=e.skipFirstRender,this.continuousPlay=e.continuousPlay;
var t;this.model&&(t=this.model.get("type")),t||(t=e.type),this.type=t,this.sort=e.sort,this.$el.addClass(t),this.sort&&/^(?:addedAt|originallyAvailableAt|rating|mediaHeight|duration)$/.test(this.sort)&&this.$el.addClass("show-sort"),this.parentMediaActions=e.mediaActions;var n=this.model&&this.model.server||this.parentMediaActions&&this.parentMediaActions.server;this.mediaActions=new p({},{item:this.model,type:t,server:n}),this.listenTo(this.mediaActions,{"change:showPlay":this.onActionsChange,"change:showEdit":this.onActionsChange,"change:showListDropdown":this.onActionsChange}),r.trigger("content.subscribe:resize",this.onResize)
},serializeData:function(){this.shared=this.model.server.get("shared"),this.synced=this.model.server.get("synced"),this.multiuser=this.model.server.get("multiuser");var e=this.model.toJSON(),t="#!/server/"+encodeURIComponent(this.model.server.id);if(e.isFolder)t+="/section/"+encodeURIComponent(this.model.section.id)+"/folder/"+encodeURIComponent(e.key);else if(e.isChannel){var i=this.model.channel,n=i.id?i.id:i.get("identifier");t+="/channel/"+encodeURIComponent(n),t+="clip"===e.type?"/details/"+encodeURIComponent(e.key):"/"+encodeURIComponent(e.key)
}else"userPlaylistItem"===e.type?t="#!/playlist/"+e.playlist+"/details/"+e.id:t+="/details/"+encodeURIComponent(e.key);return{item:e,url:t,selected:this.model.selected,showActions:this.showActions(),sort:this.sort}},render:function(){return this.model?this.skipFirstRender?(this.skipFirstRender=!1,this):(this.visible=!0,void s.Layout.prototype.render.apply(this,arguments)):this},show:function(){this.model&&!this.visible&&(this.image&&this.image.setModel(this.model),this.mediaActions&&this.mediaActions.setParent({item:this.model}),this.visible=!0,this.render())
},hide:function(){this.model&&this.visible&&(this.image&&this.image.cancel(),this.visible=!1,this.stopListening(this.model),this.$el.empty())},select:function(){this.ui.container.addClass("selected")},deselect:function(){this.ui.container.removeClass("selected")},getPosterUrl:function(e){return"show"===this.type?this.model.get("grandparentThumb")||this.model.get("parentThumb")||e:e||this.model.get("parentThumb")||this.model.get("grandparentThumb")},showActions:function(){return this.mediaActions&&(this.mediaActions.get("showPlay")||this.mediaActions.get("showEdit")||this.mediaActions.get("showListDropdown"))
},canPlaySiblings:function(){return this.model.get("isExtra")?!1:/^(track|photo|clip|userPlaylistItem)$/.test(this.type)},bindings:{".play-btn":{model:"mediaActions",modelAttribute:"showPlay",manual:!0,autohide:!0},".play-unwatched-btn":{model:"mediaActions",modelAttribute:"showPlayUnwatched",manual:!0,autohide:!0},".edit-btn":{model:"mediaActions",modelAttribute:"showEdit",manual:!0,autohide:!0},".more-btn":{model:"mediaActions",modelAttribute:"showListDropdown",manual:!0,autohide:!0},".unwatched-icon":{modelAttribute:"viewCount",modelListeners:["viewCount","viewOffset"],manual:!0,autohide:function(){if(!this.bypassShowUnwatchedIconsSetting&&!d.get("showUnwatchedIcons"))return!1;
if(!/^(movie|episode|userPlaylistItem)$/.test(this.model.get("type")))return!1;if(this.model.get("isFolder"))return!1;if(this.shared&&!this.multiuser)return!1;var e=this.model.get("viewCount"),t=this.model.get("viewOffset");return e?t:!0},formatter:function(e,t){var i=this.model.get("viewOffset");i&&t.toggleClass("unwatched-icon-partial",!0)}},".media-title":{modelAttribute:"title",modelListeners:["title","parentTitle","grandparentTitle"],isHtml:!0,formatter:function(e){var t=this.model.get("grandparentTitle")||this.model.get("parentTitle")||e,i=this.model.get("type");
return/^(season|episode|album|track)$/.test(i)&&!this.model.get("isChannel")?'<span class="btn-metadata-link media-title-link">'+t+"</span>":t}},".media-subtitle-1":{modelAttribute:"year",modelListeners:["title","parentTitle","grandparentTitle","year"],autohide:!0,formatter:function(e){var t;if("userPlaylistItem"===this.model.get("type"))this.model.get("recommender")&&(t=a("from {1}",this.model.get("recommender")));else{var i=this.model.get("grandparentTitle")||this.model.get("parentTitle");t=i?this.model.get("title"):e
}return this.$el.toggleClass("show-subtitle",!!t),t}},".media-subtitle-2":{modelAttribute:"index",modelListeners:["index","message"],autohide:!0,formatter:function(e){var t=this.model.get("type");return"userPlaylistItem"===t?this.model.get("message"):"episode"===t?o.getSeasonEpisodeIndex({seasonIndex:this.model.get("parentIndex"),episodePrefix:" \xb7 E{1}",episodeIndex:e,date:this.model.get("originallyAvailableAt"),noLeadingZero:!0}):void 0}},".media-context":{modelAttribute:"sourceTitle",manual:!0,formatter:function(e,t){var i=!!this.model.get("librarySectionID"),n=i?this.model.server.get("friendlyName"):e;
t.toggleClass("multiserver-only",i),t.text(n)}},".media-added-at":{modelAttribute:"addedAt",autohide:!0,formatter:function(e){var t=Math.min(e,n().unix());return n.unix(t).fromNow()}},".media-available-at":{modelAttribute:"originallyAvailableAt",autohide:!0,formatter:function(e){return l.formatDate(e)}},".media-resolution":{modelAttribute:"Media",autohide:!0,formatter:function(e){return e&&e.length?c.formatResolution(e[0].videoResolution):""}},".media-duration":{modelAttribute:"duration",autohide:!0,formatter:function(e){return l.formatHoursMinutes(e)
}}},onRender:function(){this.image&&this.image.setElement(this.ui.poster),("rating"===this.sort||this.showRating)&&this.rating.show(new f({model:this.model,disabled:!0})),this.progress&&this.progress.show(new m({model:this.model}))},onClose:function(){this.image&&this.image.close(),this.dropdown&&this.dropdown.close(),r.trigger("content.unsubscribe:resize",this.onResize)},onResize:function(e){this.containerSize=e,this.mediaActions&&this.mediaActions.stopListening()},onActionsChange:function(){if(this.isRendered){var e=!this.showActions();
this.ui.container.toggleClass("hide-actions",e),this.ui.actions.toggleClass("hidden",e)}},onClick:function(e){this.stopTrackingSelecting(e,function(){/^(track|photo)$/.test(this.model.get("type"))&&(e.preventDefault(),u.execute("playMedia",{item:this.model,siblings:this.canPlaySiblings()}))})},onPlayClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),u.execute("playMedia",{item:this.model,continuous:this.continuousPlay,siblings:this.canPlaySiblings()})},onPlayUnwatchedClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),u.execute("playMedia",{item:this.model,unwatched:!0,siblings:this.canPlaySiblings()})
},onEditClick:function(e){e.preventDefault(),e.stopImmediatePropagation();var n=t(e.currentTarget),s=n.hasClass("btn-loading")?n:this.$el;if(!s.hasClass("active")){s.addClass("active");var a=this.model.fetch();a.done(i.bind(function(){r.trigger("show:modal",new v({mediaActions:this.mediaActions}))},this)),a.always(i.bind(function(){s.removeClass("active")},this))}},onMoreClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),t(".media-actions-dropdown").trigger("hide.bs.dropdown"),this.dropdown=new g({model:this.model,mediaActions:this.mediaActions}),this.ui.dropdown.append(this.dropdown.render().el),this.ui.dropdown.addClass("open"),this.$el.addClass("force-hover on-top");
var i=t(e.currentTarget),n=this.ui.actions.position().top,s=this.dropdown.getPosition(i,this.containerSize,n);this.ui.dropdown.css(s)},onTitleClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),r.trigger("navigate","details",{serverID:this.model.server.id,key:this.model.get("grandparentKey")||this.model.get("parentKey")})},onDropdownHide:function(){this.dropdown&&(this.dropdown.close(),this.dropdown=null,this.$el.removeClass("force-hover on-top"))}});return y}),define("plex/desktop/views/lists/library/MediaTileListItem",["hb!templates/desktop/lists/library/MediaTileListItem.tpl","underscore","jquery","plex/desktop/views/lists/library/MediaListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s){"use strict";
var a=n.extend({className:"poster-item media-tile-list-item",template:e,ui:{container:".media-poster-container",poster:".media-poster",actions:".media-poster-actions",dropdown:".media-actions-dropdown",subtitle1Fill:".media-subtitle-1-fill",subtitle2Fill:".media-subtitle-2-fill"},initialize:function(){n.prototype.initialize.apply(this,arguments),this.model&&this.createImageView()},createImageView:function(){var e=this.type,t=150;"episode"===e?e="show":("clip"===e||"userPlaylistItem"===e)&&(t=250),this.image=new s({model:this.model,type:e,getUrl:this.getPosterUrl,width:t})
},updateDim:function(){var e=this.model.get("mediaState"),t=this.model.get("metadataState"),i=t&&"created"!==t||e,n=!!this.model.get("deletedAt");i||n?this.$el.addClass("dim"):this.$el.removeClass("dim")},bindings:t.extend({},n.prototype.bindings,{".media-subtitle-1":{modelAttribute:"year",modelListeners:["title","year"],autohide:!0,formatter:function(){var e=n.prototype.bindings[".media-subtitle-1"].formatter.apply(this,arguments);return"userPlaylistItem"!==this.model.get("type")&&this.ui.subtitle1Fill.toggleClass("hidden",!!e),e
}},".media-subtitle-2":{modelAttribute:"index",modelListeners:["index","message"],autohide:!0,formatter:function(){var e=n.prototype.bindings[".media-subtitle-2"].formatter.apply(this,arguments);return"episode"===this.model.get("type")&&this.ui.subtitle2Fill.toggleClass("hidden",!!e),e}},".media-count-badge":{modelAttribute:"Media",formatter:function(e){return e.length},autohide:function(e){return/^(clip|userPlaylistItem)$/.test(this.model.get("type"))?!1:e>1}},".unwatched-count-badge":{modelAttribute:"unviewedLeafCount",autohide:function(e){return this.shared&&!this.multiuser?!1:/^(artist|album)$/.test(this.model.get("type"))?!1:!!e
}},".analyzing-icon":{modelAttribute:"mediaState",manual:!0,autohide:!0,formatter:function(e){return this.updateDim(),e}},".matching-icon":{modelAttribute:"metadataState",manual:!0,autohide:!0,formatter:function(e){return this.updateDim(),"matching"===e}},".metadata-icon":{modelAttribute:"metadataState",manual:!0,autohide:!0,formatter:function(e){return this.updateDim(),"processing"===e||"loading"===e}},".trash-icon":{modelAttribute:"deletedAt",manual:!0,autohide:!0,formatter:function(e){return this.updateDim(),e
}}})});return a}),define("plex/desktop/views/lists/library/HorizontalMediaTileList",["plex/desktop/views/lists/HorizontalTileList","plex/desktop/views/lists/library/MediaTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list horizontal-media-tile-list hidden",itemView:t,initialize:function(t){e.prototype.initialize.apply(this,arguments),this.itemViewOptions.continuousPlay=t.continuousPlay===!0}});return i}),define("plex/desktop/views/dashboard/DashboardMediaView",["hb!templates/desktop/dashboard/DashboardMediaView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/models/library/MetadataCollection","plex/desktop/views/lists/library/HorizontalMediaTileList"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=n.Layout.extend({className:"dashboard-container hidden",template:e,ui:{previousBtn:".previous-btn",nextBtn:".next-btn",list:".dashboard-list-container"},regions:{list:".dashboard-list-container"},events:{"click .previous-btn":"onPreviousClick","click .next-btn":"onNextClick"},onlyAfterRender:["onResize"],initialize:function(e){this.key=e.key,this.label=s("onDeck"===e.key?"On Deck":"Recently Added"),this.listenTo(a,"resize",this.onResize),this.listenTo(r,"change:primaryServer",this.setup),this.setup()
},setup:function(){var e=r.get("primaryServer");this.$el.addClass("hidden"),this.list.close(),!e||e.get("shared")&&!e.get("multiuser")||(this.collection=new o([],{server:e,url:"/library/"+this.key}),this.listenToOnce(this.collection,"reset",this.onReset),this.collection.fetch({reset:!0,scope:"page"}))},serializeData:function(){return{label:this.label}},onResize:function(){this.list.currentView&&this.list.currentView.measureList&&this.list.currentView.measureList()},onReset:function(e){if(e.length){this.$el.removeClass("hidden");
var t=new l({collection:e,$container:this.$el,continuousPlay:!0});this.listenTo(t,"scroll",this.onListScroll),this.list.show(t)}},onListScroll:function(e,t,i){this.ui.previousBtn.toggleClass("disabled",1>=t),this.ui.nextBtn.toggleClass("disabled",t>=e.pages),this.ui.list.css("transform","translate("+i+"px, 0)")},onPreviousClick:function(e){e.preventDefault(),this.ui.previousBtn.isDisabled()||this.list.currentView.previous()},onNextClick:function(e){e.preventDefault(),this.ui.nextBtn.isDisabled()||this.list.currentView.next()
}});return c}),define("hb!templates/desktop/dashboard/DashboardChannelsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<ul class="nav nav-header nav-dashboard pull-right">\n  <li><a class="previous-btn btn-gray" href="#"><i class="glyphicon chevron-left"></i></a></li>\n  <li><a class="next-btn btn-gray" href="#"><i class="glyphicon chevron-right"></i></a></li>\n</ul>\n\n<h2>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Channels",r):l.call(t,"t","Channels",r)))+'</h2>\n\n<div class="dashboard-list-container"></div>\n'
})}),define("plex/base/models/channel/ChannelCollection",["underscore","plex/base/models/BaseCollection","plex/base/models/channel/ChannelModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){return"/channels/"+this.subset},initialize:function(e,t){this.subset=t.subset||"all"},parse:function(t){e.isString(t)&&(t=t.replace(/<(\/?)(Directory|Video|Track|Photo)/g,"<$1Channel"));var i=this.convert(t);return this.viewGroup=i.viewGroup,i.Channel},sortByTitle:function(e){return e.get("title").toLowerCase()
},filterByType:function(e){var t=this.filter(function(t){return t.get("type")===e});return this.clone(t)}});return n}),define("hb!templates/desktop/lists/channel/ChannelTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n        <button class="settings-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon cogwheel"></i></button>\n      '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h=this;
return c+='<a class="media-poster-container" href="#!/server/',l={hash:{},data:s},c+=u((r=i.encodeUrl||t&&t.encodeUrl,r?r.call(t,t&&t.serverID,l):d.call(t,"encodeUrl",t&&t.serverID,l)))+"/channel/",l={hash:{},data:s},c+=u((r=i.encodeUrl||t&&t.encodeUrl,r?r.call(t,(r=t&&t.item,null==r||r===!1?r:r.key),l):d.call(t,"encodeUrl",(r=t&&t.item,null==r||r===!1?r:r.key),l)))+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="media-poster-actions">\n      ',o=i["if"].call(t,(r=t&&t.item,null==r||r===!1?r:r.hasPrefs),{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n      <button class="uninstall-btn media-poster-btn btn-link btn-danger" tabindex="-1"><i class="glyphicon remove-2"></i></button>\n    </div>\n\n    <div class="loading loading-inline"></div>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n'
})}),define("hb!templates/desktop/modals/ChannelSettingsModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n          ",s={hash:{},data:t},a+=p((n=i.t||e&&e.t,n?n.call(e,"Directory Settings",s):h.call(e,"t","Directory Settings",s)))+"\n        "}function r(e,t){var n,s,a="";return a+="\n          ",s={hash:{},data:t},a+=p((n=i.t||e&&e.t,n?n.call(e,"{1} Settings",e&&e.title,s):h.call(e,"t","{1} Settings",e&&e.title,s)))+"\n        "}function o(e,t){var n,s,a="";
return a+="\n          ",s={hash:{idSuffix:"_c"},data:t},a+=p((n=i.partial||e&&e.partial,n?n.call(e,"setting",s):h.call(e,"partial","setting",s)))+"\n        "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h=i.helperMissing,p=this.escapeExpression,m=this;return u+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon glyphicon cogwheel"></i>\n\n        ',d={hash:{},inverse:m.program(3,r,s),fn:m.program(1,a,s),data:s},l=i.if_eq||t&&t.if_eq,c=l?l.call(t,t&&t.title,"Preferences...",d):h.call(t,"if_eq",t&&t.title,"Preferences...",d),(c||0===c)&&(u+=c),u+='\n      </h4>\n    </div>\n\n    <form id="channel-settings-form">\n      <div class="modal-body settings-container">\n        ',c=i.each.call(t,t&&t.settings,{hash:{},inverse:m.noop,fn:m.program(5,o,s),data:s}),(c||0===c)&&(u+=c),u+='\n      </div>\n\n      <div class="modal-footer">\n        <button type="button" class="cancel-btn btn btn-lg btn-default" data-dismiss="modal">',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Cancel",d):h.call(t,"t","Cancel",d)))+'</button>\n        <button type="submit" class="submit-btn btn btn-lg btn-primary btn-loading">\n          <div class="loading loading-sm"></div>\n          <span class="btn-label">',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Save",d):h.call(t,"t","Save",d)))+"</span>\n        </button>\n      </div>\n    </form>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/ChannelSettingsModal",["hb!templates/desktop/modals/ChannelSettingsModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/BaseModal"],function(e,t,i,n,s,a){"use strict";var r=a.extend({name:"channelSettingsModal",className:"channel-settings-modal modal fade",template:e,ui:{submitBtn:".submit-btn"},events:t.extend({"change input[name]":"onInputChange","change select[name]":"onInputChange","submit #channel-settings-form":"onSubmit"},a.prototype.events),initialize:function(){a.prototype.initialize.apply(this,arguments),this.changes={}
},serializeData:function(){var e=this.model.get("title")||this.model.get("name");return{title:e?e:"Preferences...",settings:this.collection.toJSON()}},onInputChange:function(e){var t=e.currentTarget,i=t.value;"checkbox"==t.type&&(i=t.checked),this.changes[t.name]=i},onSubmit:function(e){if(e.preventDefault(),t.isEmpty(this.changes))return void this.hide();var a=this.ui.submitBtn;if(!a.hasClass("active")){a.addClass("active");var r=this.collection.first(),o=r.getSaveParams(this.changes),l=t.result(this.collection,"url"),c=l+"/set?"+i.param(o,!0),d=i.ajax(r.server.getXHROptions(c));
d.done(t.bind(function(){this.hide()},this)),d.fail(t.bind(function(){s.trigger("show:alert",{type:"error",message:n("There was a problem saving these settings.")})},this)),d.always(function(){a.removeClass("active")})}}});return r}),define("plex/desktop/views/lists/channel/ChannelTileListItem",["hb!templates/desktop/lists/channel/ChannelTileListItem.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/server/ServerSettingCollection","plex/base/views/images/MediaPosterImage","plex/desktop/views/modals/ChannelSettingsModal"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=i.ItemView.extend({tagName:"li",className:"poster-item media-tile-list-item channel",template:e,ui:{poster:".media-poster"},events:{"click .settings-btn":"onSettingsClick","click .uninstall-btn":"onUninstallClick"},initialize:function(e){this.skipFirstRender=e.skipFirstRender,this.image=new o({model:this.model,type:"channel",width:150})},serializeData:function(){return{item:this.model.toJSON(),serverID:this.model.server.id}},render:function(){return this.skipFirstRender?(this.skipFirstRender=!1,this):(this.visible=!0,void i.ItemView.prototype.render.apply(this,arguments))
},show:function(){this.visible||(this.visible=!0,this.render())},hide:function(){this.visible&&(this.image.cancel(),this.visible=!1,this.stopListening(this.model),this.$el.empty())},bindings:{".media-title":{modelAttribute:"title"},".media-subtitle-1":{modelAttribute:"type",autohide:!0,formatter:function(e){return"video"===e?n("Video"):"music"===e?n("Music"):"photos"===e?n("Photo"):""}}},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()},onSettingsClick:function(e){if(e.preventDefault(),!this.$el.hasClass("active")){this.$el.addClass("active");
var i=new r([],{server:this.model.server,url:this.model.id+"/:/prefs"}),n=i.fetch();n.done(t.bind(function(){s.trigger("show:modal",new l({model:this.model,collection:i}))},this)),n.always(t.bind(function(){this.$el.removeClass("active")},this))}},onUninstallClick:function(e){if(e.preventDefault(),!this.$el.hasClass("active")){this.$el.addClass("active");var i=a.execute("uninstallChannel",{channel:this.model});i.done(t.bind(function(){this.model.trigger("destroy",this.model,this.model.collection)
},this)),i.always(t.bind(function(){this.$el.removeClass("active")},this))}}});return c}),define("plex/desktop/views/lists/channel/HorizontalChannelTileList",["plex/desktop/views/lists/HorizontalTileList","plex/desktop/views/lists/channel/ChannelTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list horizontal-media-tile-list channel-tile-list hidden",itemView:t});return i}),define("plex/desktop/views/dashboard/DashboardChannelsView",["hb!templates/desktop/dashboard/DashboardChannelsView.tpl","underscore","jquery","plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/models/channel/ChannelCollection","plex/desktop/views/dashboard/DashboardMediaView","plex/desktop/views/lists/channel/HorizontalChannelTileList"],function(e,t,i,n,s,a,r,o){"use strict";
var l=r.extend({template:e,initialize:function(){this.listenTo(n,"resize",this.onResize),this.listenTo(s,"change:primaryServer",this.setup),this.setup()},setup:function(){var e=s.get("primaryServer");this.$el.addClass("hidden"),e&&!e.get("shared")&&(this.collection=new a([],{server:e,subset:"recentlyViewed",pageSize:50}),this.listenToOnce(this.collection,"reset",this.onReset),this.collection.fetch({reset:!0,scope:"page"}))},onReset:function(e){if(e.length){this.$el.removeClass("hidden");var t=new o({collection:e,$container:this.$el});
this.listenTo(t,"scroll",this.onListScroll),this.list.show(t)}}});return l}),define("hb!templates/desktop/dashboard/DashboardUserPlaylistView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n    <a class="user-playlist-help" href="',(n=i.helpRoute)?n=n.call(e,{hash:{},data:t}):(n=e&&e.helpRoute,n=typeof n===d?n.call(e,{hash:{},data:t}):n),s+=u(n)+'" target="',(n=i.defaultTarget)?n=n.call(e,{hash:{},data:t}):(n=e&&e.defaultTarget,n=typeof n===d?n.call(e,{hash:{},data:t}):n),s+=u(n)+'"><i class="glyphicon circle-question-mark"></i></a>\n  '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<ul class="nav nav-header nav-dashboard pull-right">\n  <li><a class="previous-btn btn-gray disabled" href="#"><i class="glyphicon chevron-left"></i></a></li>\n  <li><a class="next-btn btn-gray disabled" href="#"><i class="glyphicon chevron-right"></i></a></li>\n</ul>\n\n<h2>\n  ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,t&&t.label,l):h.call(t,"t",t&&t.label,l)))+'\n\n  <a class="user-playlist-full" href="',(o=i.playlistRoute)?o=o.call(t,{hash:{},data:s}):(o=t&&t.playlistRoute,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'"><i class="plex-icon circle-chevron-right"></i></a>\n\n  ',o=i["if"].call(t,t&&t.helpRoute,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n</h2>\n\n<div class="dashboard-list-container"></div>\n'
})}),define("plex/base/models/user/UserPlaylistItemModel",["plex/base/utils/parser","plex/base/models/library/MetadataModel"],function(e,t){"use strict";var i=t.extend({idAttribute:"id",url:function(){return"/pms/playlists/"+this.get("playlist")+"/items/"+this.id},initialize:function(e,t){this.set("playlist",t.playlist||this.collection.key)},convert:function(){var i=t.prototype.convert.apply(this,arguments);return e.parseInteger(i,"id"),i},parse:function(){var i=t.prototype.parse.apply(this,arguments);
if(i.type="userPlaylistItem",i.ratingKey=i.url,i.thumb){var n=/\?(\d+)$/.exec(i.thumb);n&&(i.addedAt=n[1],e.parseInteger(i,"addedAt"))}return i}});return i}),define("plex/base/models/user/UserPlaylistItemCollection",["underscore","plex/base/utils/parser","plex/base/models/config","plex/base/models/BaseCollection","plex/base/models/user/UserPlaylistItemModel"],function(e,t,i,n,s){"use strict";var a=n.extend({model:s,url:function(){return"/pms/playlists/"+this.key+"/"+this.subset},initialize:function(e,t){this.key=t.key,this.label=t.label||"queue"===this.key?"Watch Later":"Recommended",this.subset=t.subset||"all","queue"===this.key&&(this.helpRoute=i.get("bundled")||i.get("hosted")?"#!/playlist/"+this.key+"/help":this.server.resolveUrl("/queue/help")),this.playlistRoute="#!/playlist/"+this.key
},parse:function(i){var n=this.convert(i);return t.parseArray(n,"Video"),e.each(n.Video,function(t){t.identifier=n.identifier,t.containerKey=e.result(this,"url")},this),n.Video},filterWatched:function(){var e=this.filter(function(e){return!!e.get("viewCount")});return this.clone(e)},filterUnwatched:function(){var e=this.filter(function(e){return!e.get("viewCount")});return this.clone(e)}});return a}),define("hb!templates/desktop/dashboard/DashboardEmptyUserPlaylistView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o,l="",c=i.helperMissing,d=this.escapeExpression,u="function";return l+='<h4 class="text-muted">\n  ',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"No queued items.",o):c.call(t,"t","No queued items.",o)))+'\n  <a href="',(r=i.helpRoute)?r=r.call(t,{hash:{},data:s}):(r=t&&t.helpRoute,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+'" target="',(r=i.defaultTarget)?r=r.call(t,{hash:{},data:s}):(r=t&&t.defaultTarget,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+'">',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Learn how to add videos to Watch Later.",o):c.call(t,"t","Learn how to add videos to Watch Later.",o)))+"</a>\n</h4>\n"
})}),define("plex/desktop/views/dashboard/DashboardEmptyUserPlaylistView",["hb!templates/desktop/dashboard/DashboardEmptyUserPlaylistView.tpl","marionette","plex/base/models/config"],function(e,t,i){"use strict";var n=t.ItemView.extend({template:e,initialize:function(e){this.type=e.type,this.helpRoute=e.helpRoute},serializeData:function(){return{type:this.type,helpRoute:this.helpRoute,defaultTarget:i.get("defaultTarget")}}});return n}),define("plex/desktop/views/dashboard/DashboardUserPlaylistView",["hb!templates/desktop/dashboard/DashboardUserPlaylistView.tpl","underscore","jquery","plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/models/config","plex/base/models/user/UserPlaylistItemCollection","plex/desktop/views/dashboard/DashboardMediaView","plex/desktop/views/lists/library/HorizontalMediaTileList","plex/desktop/views/dashboard/DashboardEmptyUserPlaylistView"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=o.extend({template:e,initialize:function(e){this.type=e.key,this.user=s.get("user"),this.collection=new r([],{server:this.user.server,parent:this.user,key:e.key,subset:"unwatched"}),this.label=this.collection.label,this.listenTo(n,"resize",this.onResize),this.listenTo(this.user,"change:signedIn",this.setup),this.setup()},setup:function(){this.$el.addClass("hidden"),this.user.get("signedIn")&&!this.user.get("restricted")&&(this.listenToOnce(this.collection,"reset",this.onReset),this.collection.fetch({reset:!0,scope:"page"}))
},serializeData:function(){return{label:this.label,helpRoute:this.collection.helpRoute,playlistRoute:this.collection.playlistRoute,defaultTarget:a.get("defaultTarget")}},onReset:function(e){var t=!this.collection.length&&"queue"===this.type;if(this.collection.length||t){this.$el.removeClass("hidden");var i;i=t?new c({type:this.type,helpRoute:this.collection.helpRoute}):new l({className:l.prototype.className+" show-context",collection:e,$container:this.$el}),this.listenTo(i,"scroll",this.onListScroll),this.list.show(i)
}}});return d}),define("plex/desktop/views/dashboard/DashboardView",["hb!templates/desktop/dashboard/DashboardView.tpl","marionette","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/models/appModel","plex/desktop/views/sidebar/DashboardSideBarView","plex/desktop/views/dashboard/DashboardMediaView","plex/desktop/views/dashboard/DashboardChannelsView","plex/desktop/views/dashboard/DashboardUserPlaylistView"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=t.Layout.extend({className:"priorities-container",template:e,ui:{1:".priority-1-container",2:".priority-2-container",3:".priority-3-container",4:".priority-4-container",5:".priority-5-container"},regions:{onDeck:".on-deck-container",recentlyAdded:".recently-added-container",channels:".channels-container",queue:".queue-container",recommendations:".recommendations-container"},initialize:function(){this.primaryServer=s.get("primaryServer"),this.onDeckPriority=n.get("dashboardPriorityOnDeck"),this.recentlyAddedPriority=n.get("dashboardPriorityRecentlyAdded"),this.channelsPriority=n.get("dashboardPriorityChannels"),this.queuePriority=n.get("dashboardPriorityQueue"),this.recommendationsPriority=n.get("dashboardPriorityRecommendations"),i.trigger("show:bar","sidebar",new a),this.listenTo(s,"change:primaryServer",this.onPrimaryServerChange),this.primaryServer&&this.listenTo(this.primaryServer,"change:shared",this.onPrimaryServerSharedChange)
},onRender:function(){n.get("dashboardOnDeckEnabled")&&this.onDeck.append(new r({key:"onDeck"}),this.ui[this.onDeckPriority]),n.get("dashboardRecentlyAddedEnabled")&&this.recentlyAdded.append(new r({key:"recentlyAdded"}),this.ui[this.recentlyAddedPriority]),n.get("dashboardChannelsEnabled")&&this.channels.append(new o,this.ui[this.channelsPriority]),n.get("dashboardQueueEnabled")&&this.queue.append(new l({key:"queue"}),this.ui[this.queuePriority]),n.get("dashboardRecommendationsEnabled")&&this.recommendations.append(new l({key:"recommendations"}),this.ui[this.recommendationsPriority])
},onClose:function(){i.trigger("hide:bar","sidebar")},onPrimaryServerChange:function(e,t){this.primaryServer&&this.stopListening(this.primaryServer),this.primaryServer=t,this.primaryServer&&this.listenTo(this.primaryServer,"change:shared",this.onPrimaryServerSharedChange)},onPrimaryServerSharedChange:function(){i.trigger("navigate:refresh")}});return c}),define("hb!templates/desktop/SignInView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="sign-in-logo text-center">\n  <i class="plex-image logo"></i>\n</div>\n\n<div class="row row-padded">\n  <div class="col-sm-6 col-sm-offset-3">\n    <form id="user-account-form"></form>\n  </div>\n</div>\n'
})}),define("hb!templates/desktop/SignInFormView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n    <div class="remember-group checkbox">\n      <label class="control-label">\n        <input type="checkbox" id="remember" checked> ',s={hash:{},data:t},a+=u((n=i.t||e&&e.t,n?n.call(e,"Remember me",s):d.call(e,"t","Remember me",s)))+"\n      </label>\n    </div>\n  "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h=this;
return c+='<div class="row">\n  <div class="col-sm-12">\n    <h2 class="sign-in-header">\n      <a class="sign-in-btn selected" href="#">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sign In",l):d.call(t,"t","Sign In",l)))+'</a>\n      <span class="sign-in-header-divider">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"or",l):d.call(t,"t","or",l)))+'</span>\n      <a class="sign-up-btn" href="#">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sign Up",l):d.call(t,"t","Sign Up",l)))+'</a>\n    </h2>\n  </div>\n</div>\n\n<div class="username-group form-group">\n  <label for="username" class="control-label">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Username",l):d.call(t,"t","Username",l)))+' <span class="control-error">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Required",l):d.call(t,"t","Required",l)))+'</span>\n  </label>\n  <input type="text" id="username" class="form-control" autocorrect="off" autocapitalize="off">\n</div>\n\n<div class="email-group form-group">\n  <label for="email" class="control-label">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Email",l):d.call(t,"t","Email",l)))+' <span class="control-error">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Required",l):d.call(t,"t","Required",l)))+'</span>\n  </label>\n  <input type="text" id="email" class="form-control" autocorrect="off" autocapitalize="off">\n</div>\n\n<div class="password-group form-group">\n  <label for="password" class="control-label">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Password",l):d.call(t,"t","Password",l)))+' <span class="control-error">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Required",l):d.call(t,"t","Required",l)))+'</span>\n  </label>\n  <input type="password" id="password" class="form-control">\n</div>\n\n<div class="confirm-group form-group">\n  <label for="confirm" class="control-label">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Confirm Password",l):d.call(t,"t","Confirm Password",l)))+' <span class="control-error">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Passwords do not match",l):d.call(t,"t","Passwords do not match",l)))+'</span>\n  </label>\n  <input type="password" id="confirm" class="form-control">\n</div>\n\n<div class="age-group form-group">\n  <label for="month" class="control-label">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Date of Birth",l):d.call(t,"t","Date of Birth",l)))+' <span class="invalid-error control-error">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"This can't be your birthday",l):d.call(t,"t","This can't be your birthday",l)))+'</span> <span class="underage-error control-error">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"You must be 13 years or older",l):d.call(t,"t","You must be 13 years or older",l)))+'</span>\n  </label>\n  <div class="row">\n    <div class="birthday-col col-xs-2">\n      <input type="text" id="month" class="form-control" placeholder="01">\n    </div>\n    <div class="birthday-col col-xs-2">\n      <input type="text" id="day" class="form-control" placeholder="31">\n    </div>\n    <div class="birthday-col col-xs-3">\n      <input type="text" id="age" class="form-control" placeholder="1985">\n    </div>\n  </div>\n</div>\n\n<div class="form-footer">\n  <button type="submit" class="btn btn-lg btn-primary btn-loading pull-right">\n    <div class="loading loading-sm"></div>\n    <span class="sign-in-label btn-label">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sign In",l):d.call(t,"t","Sign In",l)))+'</span>\n    <span class="sign-up-label btn-label">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sign Up",l):d.call(t,"t","Sign Up",l)))+'</span>\n  </button>\n\n  <div class="terms-group checkbox">\n    <label class="control-label">\n      <input type="checkbox" id="terms" checked> ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"I agree to the {1}terms of service{2}","<a href='https://plex.tv/legal' target='_blank'>","</a>",l):d.call(t,"t","I agree to the {1}terms of service{2}","<a href='https://plex.tv/legal' target='_blank'>","</a>",l)))+"</a>\n    </label>\n  </div>\n\n  ",o=i["if"].call(t,t&&t.showRememberMe,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+="\n</div>\n"
})}),define("plex/desktop/views/SignInFormView",["hb!templates/desktop/SignInFormView.tpl","underscore","marionette","moment"],function(e,t,i,n){"use strict";var s=i.ItemView.extend({className:"sign-in-form",template:e,validationFields:["username","email","password","confirm","age","terms"],ui:{submitBtn:"[type=submit]",signInBtn:".sign-in-btn",signUpBtn:".sign-up-btn",username:".username-group",email:".email-group",password:".password-group",confirm:".confirm-group",age:".age-group",terms:".terms-group"},events:{"click .sign-in-btn":"onSignInClick","click .sign-up-btn":"onSignUpClick","blur input":"onInputBlur","submit form":"onSubmit"},initialize:function(e){this.showRememberMe=e.showRememberMe
},serializeData:function(){return{showRememberMe:this.showRememberMe}},validateAll:function(e,i,n){var s=!0;return i||(i=this.validationFields),t.each(i,t.bind(function(t){var i=e[t];this.validate(i,n[t],n)||(s=!1)},this)),s},validate:function(e,i,s){var a,r=e.id;if(t.indexOf(this.validationFields,r)<0)return!0;var o=this.ui[r];if("confirm"===e.id)a=i===e.form.password.value;else if("age"===e.id){var l=parseInt(e.form.day.value,10),c=parseInt(e.form.month.value,10),d=parseInt(i,10),u=!!(l&&c&&d),h=32>l,p=13>c,m=d>1800;
if(!p&&32>c&&13>l){var f=c;c=l,l=f,p=!0}if(u&&h&&p&&m){var g=n({day:l,month:c-1,year:d}),v=n().diff(g,"years");s&&(s.birthday=g),a=v>12,o.removeClass("is-invalid"),o.addClass("is-underage")}else a=!1,o.addClass("is-invalid"),o.removeClass("is-underage")}else a=!!i;return o.toggleClass("has-error",!a),a},onSignInClick:function(e){e.preventDefault(),this.ui.signInBtn.addClass("selected"),this.ui.signUpBtn.removeClass("selected"),this.$el.addClass("sign-in-form"),this.$el.removeClass("sign-up-form")
},onSignUpClick:function(e){e.preventDefault(),this.ui.signInBtn.removeClass("selected"),this.ui.signUpBtn.addClass("selected"),this.$el.removeClass("sign-in-form"),this.$el.addClass("sign-up-form")},onInputBlur:function(e){var t=e.target,i="checkbox"===t.type?t.checked:t.value;this.validate(t,i)}});return s}),define("plex/desktop/views/SignInView",["hb!templates/desktop/SignInView.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/desktop/views/SignInFormView"],function(e,t,i,n,s,a,r){"use strict";
var o=n.Layout.extend({className:"sign-in-container container",template:e,ui:{form:"#user-account-form"},regions:{form:"#user-account-form"},events:{"submit form":"onSubmit"},signIn:function(e){return this.form.currentView.validateAll(this.ui.form[0],["username","password"],e)?a.execute("signIn",e):i.Deferred().reject().promise()},signUp:function(e){return this.form.currentView.validateAll(this.ui.form[0],null,e)?a.execute("signUp",e):i.Deferred().reject().promise()},onRender:function(){this.form.show(new r({showRememberMe:!0}))
},onSubmit:function(e){e.preventDefault();var i=e.currentTarget,n=this.form.currentView.ui.submitBtn;if(!n.hasClass("active")){n.addClass("active");var a,r={username:i.username.value,email:i.email.value,password:i.password.value,confirm:i.confirm.value,age:i.age.value,terms:i.terms.checked,remember:i.remember.checked};a=this.form.currentView.$el.hasClass("sign-in-form")?this.signIn(r):this.signUp(r),a.done(function(){s.trigger("navigate:refresh")}),a.fail(t.bind(function(){n.removeClass("active")
},this))}}});return o}),define("hb!templates/desktop/LogsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<textarea class="form-control">',(a=i.logs)?a=a.call(t,{hash:{},data:s}):(a=t&&t.logs,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"</textarea>\n"})}),define("plex/desktop/views/LogsView",["hb!templates/desktop/LogsView.tpl","marionette"],function(e,t){"use strict";
var i=t.ItemView.extend({className:"logs-container",template:e,ui:{textarea:"textarea"},collectionEvents:{add:"onAdd"},onlyAfterRender:["onAdd"],serializeData:function(){return{logs:this.collection.toJSONString()}},onAdd:function(){this.ui.textarea.text(this.collection.toJSONString())}});return i}),define("hb!templates/desktop/InfoView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"(Plex Pass)"}function r(e,t){var n,s,a="";return a+='\n  <p><span class="text-muted">Name:</span> '+p((n=e&&e.primaryServer,n=null==n||n===!1?n:n.friendlyName,typeof n===h?n.apply(e):n))+'</p>\n  <p><span class="text-muted">URL:</span> ',(s=i.primaryServerUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.primaryServerUrl,s=typeof s===h?s.call(e,{hash:{},data:t}):s),a+=p(s)+'</p>\n  <p><span class="text-muted">Version:</span> '+p((n=e&&e.primaryServer,n=null==n||n===!1?n:n.version,typeof n===h?n.apply(e):n))+'</p>\n  <p><span class="text-muted">Token:</span> '+p((n=e&&e.primaryServer,n=null==n||n===!1?n:n.accessToken,typeof n===h?n.apply(e):n))+"</p>\n"
}function o(){return'\n  <p><span class="text-muted">none</span></p>\n'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h="function",p=this.escapeExpression,m=i.helperMissing,f=this;return u+='<h3>Browser</h3>\n<p><span class="text-muted">Host:</span> ',(l=i.host)?l=l.call(t,{hash:{},data:s}):(l=t&&t.host,l=typeof l===h?l.call(t,{hash:{},data:s}):l),u+=p(l)+'</p>\n<p><span class="text-muted">User Agent:</span> ',(l=i.userAgent)?l=l.call(t,{hash:{},data:s}):(l=t&&t.userAgent,l=typeof l===h?l.call(t,{hash:{},data:s}):l),u+=p(l)+'</p>\n<p><span class="text-muted">Name:</span> '+p((l=t&&t.browser,l=null==l||l===!1?l:l.name,typeof l===h?l.apply(t):l))+'</p>\n<p><span class="text-muted">Version:</span> '+p((l=t&&t.browser,l=null==l||l===!1?l:l.version,typeof l===h?l.apply(t):l))+'</p>\n<p><span class="text-muted">Platform:</span> '+p((l=t&&t.browser,l=null==l||l===!1?l:l.platform,typeof l===h?l.apply(t):l))+'</p>\n<p><span class="text-muted">Mobile:</span> ',d={hash:{},data:s},u+=p((l=i.formatBoolean||t&&t.formatBoolean,l?l.call(t,(l=t&&t.browser,null==l||l===!1?l:l.mobile),d):m.call(t,"formatBoolean",(l=t&&t.browser,null==l||l===!1?l:l.mobile),d)))+'</p>\n\n<h3>User</h3>\n<p><span class="text-muted">Username:</span> '+p((l=t&&t.user,l=null==l||l===!1?l:l.username,typeof l===h?l.apply(t):l))+" ",c=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:f.noop,fn:f.program(1,a,s),data:s}),(c||0===c)&&(u+=c),u+='</p>\n<p><span class="text-muted">Email:</span> '+p((l=t&&t.user,l=null==l||l===!1?l:l.email,typeof l===h?l.apply(t):l))+'</p>\n<p><span class="text-muted">Token:</span> '+p((l=t&&t.user,l=null==l||l===!1?l:l.accessToken,typeof l===h?l.apply(t):l))+'</p>\n\n<h3>plex.tv</h3>\n<p><span class="text-muted">URL:</span> ',(c=i.cloudServerUrl)?c=c.call(t,{hash:{},data:s}):(c=t&&t.cloudServerUrl,c=typeof c===h?c.call(t,{hash:{},data:s}):c),u+=p(c)+'</p>\n<p><span class="text-muted">Available:</span> ',d={hash:{},data:s},u+=p((l=i.formatBoolean||t&&t.formatBoolean,l?l.call(t,(l=t&&t.cloudServer,null==l||l===!1?l:l.available),d):m.call(t,"formatBoolean",(l=t&&t.cloudServer,null==l||l===!1?l:l.available),d)))+'</p>\n<p><span class="text-muted">Authorized:</span> ',d={hash:{},data:s},u+=p((l=i.formatBoolean||t&&t.formatBoolean,l?l.call(t,(l=t&&t.cloudServer,null==l||l===!1?l:l.authorized),d):m.call(t,"formatBoolean",(l=t&&t.cloudServer,null==l||l===!1?l:l.authorized),d)))+"</p>\n\n<h3>Primary Server</h3>\n",c=i["if"].call(t,t&&t.primaryServer,{hash:{},inverse:f.program(5,o,s),fn:f.program(3,r,s),data:s}),(c||0===c)&&(u+=c),u+="\n"
})}),define("plex/desktop/views/InfoView",["hb!templates/desktop/InfoView.tpl","marionette","plex/base/utils/browser","plex/base/models/appModel"],function(e,t,i,n){"use strict";var s=t.ItemView.extend({template:e,initialize:function(){this.listenTo(n,"change:primaryServer",this.render),this.listenTo(n.get("user"),"change:signedIn",this.render)},serializeData:function(){var e=n.get("user"),t=n.get("primaryServer"),s={host:window.location.host,userAgent:window.navigator.userAgent,browser:i,user:e.toJSON(),hasPlexPass:e.hasPlexPass(),cloudServer:e.server.toJSON(),cloudServerUrl:e.server.url()};
return t&&(s.primaryServer=t.toJSON(),s.primaryServerUrl=t.url()),s}});return s}),define("hb!templates/desktop/error/ErrorView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n      <h2 class="text-muted">',(n=i.subtitle)?n=n.call(e,{hash:{},data:t}):(n=e&&e.subtitle,n=typeof n===c?n.call(e,{hash:{},data:t}):n),(n||0===n)&&(s+=n),s+="</h2>\n    "}function r(e,t){var n,s="";return s+="\n      <p>",(n=i.message)?n=n.call(e,{hash:{},data:t}):(n=e&&e.message,n=typeof n===c?n.call(e,{hash:{},data:t}):n),(n||0===n)&&(s+=n),s+="</p>\n    "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c="function",d=this;return l+='<div class="row row-padded">\n  <div class="col-md-8 col-md-offset-2">\n    <h1>',(o=i.title)?o=o.call(t,{hash:{},data:s}):(o=t&&t.title,o=typeof o===c?o.call(t,{hash:{},data:s}):o),(o||0===o)&&(l+=o),l+="</h1>\n    ",o=i["if"].call(t,t&&t.subtitle,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+="\n    ",o=i["if"].call(t,t&&t.message,{hash:{},inverse:d.noop,fn:d.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+="\n  </div>\n</div>"
})}),define("plex/base/views/error/AbstractErrorView",["marionette"],function(e){"use strict";var t=e.Layout.extend({regions:{content:".content"}});return t}),define("plex/base/views/error/BaseChannelErrorView",["plex/base/utils/t","plex/base/views/error/AbstractErrorView"],function(e,t){"use strict";var i=t.extend({serializeData:function(){return{title:e("This channel is not responding.")}}});return i}),define("plex/desktop/views/error/ChannelErrorView",["hb!templates/desktop/error/ErrorView.tpl","plex/base/views/error/BaseChannelErrorView"],function(e,t){"use strict";
var i=t.extend({className:"container",template:e});return i}),define("plex/base/views/error/BaseErrorView",["plex/base/views/error/AbstractErrorView"],function(e){"use strict";var t=e.extend({initialize:function(e){this.title=e.title,this.subtitle=e.subtitle,this.message=e.message},serializeData:function(){return{title:this.title,subtitle:this.subtitle,message:this.message}}});return t}),define("plex/desktop/views/error/ErrorView",["hb!templates/desktop/error/ErrorView.tpl","plex/base/views/error/BaseErrorView"],function(e,t){"use strict";
var i=t.extend({className:"container",template:e});return i}),define("plex/base/views/error/BaseNotFoundView",["plex/base/utils/t","plex/base/views/error/AbstractErrorView"],function(e,t){"use strict";var i=t.extend({initialize:function(e){this.type=e.type||"404"},serializeData:function(){var t,i;return"404"===this.type?(t=e("You must be lost."),i=e("This page doesn't exist.")):"server"===this.type?(t=e("Media server not found."),i=e("The server you're trying to access doesn't seem to exist.")):(t=e("Media not found."),i=e("The media you're trying to access doesn't seem to exist.")),{title:t,subtitle:i}
}});return i}),define("plex/desktop/views/error/NotFoundView",["hb!templates/desktop/error/ErrorView.tpl","plex/base/views/error/BaseNotFoundView"],function(e,t){"use strict";var i=t.extend({className:"container",template:e});return i}),define("plex/base/views/error/BaseServerRequiredView",["plex/base/views/error/AbstractErrorView"],function(e){"use strict";var t=e.extend({});return t}),define("plex/desktop/views/error/ServerRequiredView",["hb!templates/desktop/error/ErrorView.tpl","plex/base/utils/t","plex/base/views/error/BaseServerRequiredView"],function(e,t,i){"use strict";
var n=i.extend({className:"container",template:e,serializeData:function(){return{title:t("You don't have any media servers yet."),subtitle:t("{1}Download and install{2} one and try again.",'<a href="https://plex.tv/downloads" target="_blank">',"</a>")}}});return n}),define("plex/base/views/error/BaseUnauthorizedView",["plex/base/utils/t","plex/base/views/error/AbstractErrorView"],function(e,t){"use strict";var i=t.extend({serializeData:function(){return{title:e("No soup for you!"),subtitle:e("The server you're trying to access doesn't want to let you in. Make sure you're signed in as a user with access to this server.")}
}});return i}),define("plex/desktop/views/error/UnauthorizedView",["hb!templates/desktop/error/ErrorView.tpl","plex/base/views/error/BaseUnauthorizedView"],function(e,t){"use strict";var i=t.extend({className:"container",template:e});return i}),define("plex/base/views/error/BaseUnavailableView",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/views/error/AbstractErrorView"],function(e,t,i){"use strict";var n=i.extend({modelEvents:{"change:connected":"onConnectedChange"},serializeData:function(){var t,i,n=this.model,s=n.get("friendlyName");
return n.get("cloud")?n.get("downForMaintenance")?(t=e("Plex is down for maintenance."),i=e("Don't worry, it'll be back soon.")):(t=e("Plex is not reachable."),i=e("Make sure your server has an internet connection and any firewalls or other programs are set to allow access.")):(t=e("Server unavailable."),i=s?e("We couldn't reach \"{1}\". Make sure it's online and try again.",s):e("We couldn't reach this server. Make sure it's online and try again.")),{title:t,subtitle:i}},onConnectedChange:function(){t.trigger("navigate:refresh")
}});return n}),define("plex/desktop/views/error/UnavailableView",["hb!templates/desktop/error/ErrorView.tpl","plex/base/views/error/BaseUnavailableView"],function(e,t){"use strict";var i=t.extend({className:"container",template:e});return i}),define("plex/desktop/routes/DesktopAppController",["plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/commands/commands","plex/base/routes/BaseAppController","plex/desktop/views/DesktopAppView","plex/desktop/views/dashboard/DashboardView","plex/desktop/views/SignInView","plex/desktop/views/LogsView","plex/desktop/views/InfoView","plex/desktop/views/error/ChannelErrorView","plex/desktop/views/error/ErrorView","plex/desktop/views/error/NotFoundView","plex/desktop/views/error/ServerRequiredView","plex/desktop/views/error/UnauthorizedView","plex/desktop/views/error/UnavailableView"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f=n.extend({viewsByType:{signIn:r,error:d,channelError:c,notFound:u,serverRequired:h,unauthorized:p,unavailable:m},initialize:function(){n.prototype.initialize.apply(this,arguments),this.appView=new s,this.appView.render()},dashboard:function(){var t=this.populateView();t.done(function(){e.trigger("show:view",new a)})},logout:function(){var t=this.viewFor;i.execute("signOut").done(function(){e.trigger("navigate","login",{silent:!0})}).fail(function(){e.trigger("show:view",t("logoutError"))})},logs:function(){e.trigger("show:view",new o({collection:t.get("logs")}))
},info:function(){e.trigger("show:view",new l)}});return f}),define("plex/desktop/routes/DesktopAppRouter",["backbone","plex/base/utils/dispatcher","plex/base/routes/BaseAppRouter","plex/desktop/routes/DesktopAppController"],function(e,t,i,n){"use strict";var s=i.extend({initialize:function(){i.prototype.initialize.apply(this,arguments),this.listenTo(t,"navigate:refresh:dashboard",this.onNavigateRefreshDashboard)},controller:new n,appRoutes:{"!/dashboard":"dashboard","":"dashboard","!/login":"login","!/unauthorized":"unauthorized","!/logs":"logs","!/info":"info","*404":"error"},onNavigateRefreshDashboard:function(){var i=e.history.getFragment();
""===i||"!/dashboard"===i?e.history.loadUrl(""):t.trigger("navigate","dashboard")}});return s}),define("hb!templates/desktop/setup/SetupView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+="<h2>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Get Started",r):l.call(t,"t","Get Started",r)))+'</h2>\n\n<div class="setup-progress">\n  <div class="basic-segment setup-progress-segment">\n    <a class="segment-btn btn-gray" data-subset="setupBasic" href="#">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Basic Setup",r):l.call(t,"t","Basic Setup",r)))+'</a>\n  </div>\n  <div class="library-segment setup-progress-segment">\n    <a class="segment-btn btn-gray" data-subset="setupLibrary" href="#">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Library",r):l.call(t,"t","Library",r)))+'</a>\n  </div>\n  <div class="channels-segment setup-progress-segment">\n    <a class="segment-btn btn-gray" data-subset="setupChannels" href="#">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Channels",r):l.call(t,"t","Channels",r)))+'</a>\n  </div>\n</div>\n\n<div class="setup-container"></div>\n'
})}),define("hb!templates/desktop/setup/SetupLoadingView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="loading loading-inline"></div>\n\n<p class="loading-title">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Please wait a moment while Plex starts.",r):l.call(t,"t","Please wait a moment while Plex starts.",r)))+"</p>\n"})}),define("plex/desktop/views/setup/SetupLoadingView",["hb!templates/desktop/setup/SetupLoadingView.tpl","marionette"],function(e,t){"use strict";
var i=t.ItemView.extend({className:"setup-loading-container",template:e});return i}),define("hb!templates/desktop/setup/SetupErrorView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n      <h1>",s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"Setup is not allowed for shared servers.",s):c.call(e,"t","Setup is not allowed for shared servers.",s)))+"</h1>\n    "}function r(e,t){var n,s,a="";return a+="\n      <h1>",s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"A problem has been detected with a core component of Plex Media Server.",s):c.call(e,"t","A problem has been detected with a core component of Plex Media Server.",s)))+'</h1>\n      <h2 class="text-muted">',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"Please visit the {1}forums{2} and provide your logs, as described {3}here{4}.","<a href='https://forums.plex.tv' target='_blank'>","</a>","<a href='http://support.plex.tv/hc/en-us/articles/200250417-Log-File-Locations' target='_blank'>","</a>",s):c.call(e,"t","Please visit the {1}forums{2} and provide your logs, as described {3}here{4}.","<a href='https://forums.plex.tv' target='_blank'>","</a>","<a href='http://support.plex.tv/hc/en-us/articles/200250417-Log-File-Locations' target='_blank'>","</a>",s)))+"</h2>\n    "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;return l+='<div class="row row-padded">\n  <div class="col-md-8 col-md-offset-2">\n    ',o=i["if"].call(t,t&&t.shared,{hash:{},inverse:u.program(3,r,s),fn:u.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+="\n  </div>\n</div>\n"})}),define("plex/desktop/views/setup/SetupErrorView",["hb!templates/desktop/setup/SetupErrorView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({className:"setup-error-container",template:e});
return i}),define("hb!templates/desktop/setup/SetupBasicView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n        <p class="setup-basic-help text-muted">\n          ',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Let's start by giving your Plex Media Server a friendly name so it can identify itself to other computers on the network. If you leave it blank, your computer name will be used.",s):p.call(e,"t","Let's start by giving your Plex Media Server a friendly name so it can identify itself to other computers on the network. If you leave it blank, your computer name will be used.",s)))+'\n        </p>\n\n        <div class="form-group">\n          <label for="'+m((n=e&&e.friendlyNameSetting,n=null==n||n===!1?n:n.id,typeof n===f?n.apply(e):n))+'">'+m((n=e&&e.friendlyNameSetting,n=null==n||n===!1?n:n.label,typeof n===f?n.apply(e):n))+'</label>\n          <input type="text" id="'+m((n=e&&e.friendlyNameSetting,n=null==n||n===!1?n:n.id,typeof n===f?n.apply(e):n))+'" class="form-control" value="'+m((n=e&&e.friendlyNameSetting,n=null==n||n===!1?n:n.value,typeof n===f?n.apply(e):n))+'" placeholder="'+m((n=e&&e.server,n=null==n||n===!1?n:n.name,typeof n===f?n.apply(e):n))+'">\n        </div>\n      '
}function r(e,t){var n,s,a="";return a+='\n        <p class="setup-basic-help text-muted">\n          ',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Connecting your server to Plex allows you to stream media outside your home network.",s):p.call(e,"t","Connecting your server to Plex allows you to stream media outside your home network.",s)))+'\n        </p>\n\n        <div class="checkbox">\n          <label for="connect">\n            <input type="checkbox" id="connect" checked> ',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Connect to Plex",s):p.call(e,"t","Connect to Plex",s)))+"\n          </label>\n        </div>\n      "
}function o(e,t){var n,s,a,r="";return r+='\n        <p class="setup-basic-help text-muted">\n          ',a={hash:{},data:t},r+=m((n=i.t||e&&e.t,n?n.call(e,"Would you like to help us make Plex better for everyone? We collect anonymous data, which we use to improve the service over time.",a):p.call(e,"t","Would you like to help us make Plex better for everyone? We collect anonymous data, which we use to improve the service over time.",a)))+'\n        </p>\n\n        <div class="checkbox">\n          <label for="'+m((n=e&&e.collectUsageDataSetting,n=null==n||n===!1?n:n.id,typeof n===f?n.apply(e):n))+'">\n            <input type="checkbox" id="'+m((n=e&&e.collectUsageDataSetting,n=null==n||n===!1?n:n.id,typeof n===f?n.apply(e):n))+'" name="'+m((n=e&&e.collectUsageDataSetting,n=null==n||n===!1?n:n.id,typeof n===f?n.apply(e):n))+'" value="1" ',s=i["if"].call(e,(n=e&&e.collectUsageDataSetting,null==n||n===!1?n:n.value),{hash:{},inverse:g.noop,fn:g.program(6,l,t),data:t}),(s||0===s)&&(r+=s),r+="> ",a={hash:{},data:t},r+=m((n=i.t||e&&e.t,n?n.call(e,"Send feedback",a):p.call(e,"t","Send feedback",a)))+"\n          </label>\n        </div>\n      "
}function l(){return"checked"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p=i.helperMissing,m=this.escapeExpression,f="function",g=this;return h+='<div class="row">\n  <div class="col-md-4 visible-md visible-lg text-center">\n    <i class="plex-image server"></i>\n  </div>\n\n  <div class="col-md-8">\n    <h4>',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Welcome to Plex!",u):p.call(t,"t","Welcome to Plex!",u)))+'</h4>\n\n    <form id="setup-basic-form" class="settings-container">\n      ',d=i["if"].call(t,t&&t.friendlyNameSetting,{hash:{},inverse:g.noop,fn:g.program(1,a,s),data:s}),(d||0===d)&&(h+=d),h+="\n\n      ",d=i["if"].call(t,t&&t.signedIn,{hash:{},inverse:g.noop,fn:g.program(3,r,s),data:s}),(d||0===d)&&(h+=d),h+="\n\n      ",d=i["if"].call(t,t&&t.collectUsageDataSetting,{hash:{},inverse:g.noop,fn:g.program(5,o,s),data:s}),(d||0===d)&&(h+=d),h+='\n\n      <div class="setup-footer">\n        <button type="submit" class="submit-btn btn btn-primary btn-loading btn-lg">\n          <div class="loading loading-sm"></div>\n          <span class="btn-label">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Next",u):p.call(t,"t","Next",u)))+'</span>\n        </button>\n        <button class="next-btn hidden" data-subset="setupLibrary"></button>\n      </div>\n    </form>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/setup/SetupBasicView",["hb!templates/desktop/setup/SetupBasicView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel"],function(e,t,i,n,s,a,r){"use strict";var o=n.ItemView.extend({className:"setup-basic-container",template:e,ui:{connectCheckbox:"#connect",submitBtn:".submit-btn",nextBtn:".next-btn"},collectionEvents:{reset:"render"},events:{"change input[id]":"onInputChange","submit #setup-basic-form":"onSubmit"},initialize:function(){this.collection=this.model.get("settings"),this.collection.populate({reset:!0}),this.changes=this.model.supports("firstRunPref")?{FirstRun:0}:{};
var e=this.model.get("superToken");e&&(this.changes.PlexOnlineToken=e)},serializeData:function(){var e=this.model.toJSON(),t=this.collection.get("FriendlyName"),i=this.collection.get("collectUsageData");return{server:e,signedIn:!!e.superToken||"ok"===e.myPlexSigninState,friendlyNameSetting:t?t.toJSON():null,collectUsageDataSetting:i?i.toJSON():null}},save:function(){if(t.isEmpty(this.changes))return i.Deferred().resolve().promise();delete this.changes.connect;var e=this.collection.first().save(this.changes);
return e=e.then(this.whenRendered(function(){return this.ui.connectCheckbox.length?r.execute("connectServer",{cloudAccount:this.model.get("cloudAccount"),value:this.ui.connectCheckbox.prop("checked")}):void 0}),t.bind(function(){a.trigger("show:alert",{type:"error",message:s("There was a problem saving these settings.")})}))},onInputChange:function(e){var t=e.currentTarget,i=t.value;"checkbox"!==t.type||t.checked||(i="0"),this.changes[t.id]=i},onSubmit:function(e){e.preventDefault();var t=this.ui.submitBtn;
if(!t.hasClass("active")){t.addClass("active");var i=this.save();i.done(this.whenRendered(function(){var e=this.model.get("cloudAccount");e.get("mappingError")&&this.ui.nextBtn.data("subset","setupConnectError"),this.ui.nextBtn.click()})),i.always(function(){t.removeClass("active")})}}});return o}),define("hb!templates/desktop/setup/SetupConnectErrorView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,o="";return o+='\n        <div class="checkbox">\n          <label>\n            <input type="checkbox" id="'+m((n=e&&e.mappingModeSetting,n=null==n||n===!1?n:n.id,typeof n===p?n.apply(e):n))+'" value="1" ',s=i["if"].call(e,(n=e&&e.mappingModeSetting,null==n||n===!1?n:n.value),{hash:{},inverse:f.noop,fn:f.program(2,r,t),data:t}),(s||0===s)&&(o+=s),o+="> ",a={hash:{},data:t},o+=m((n=i.t||e&&e.t,n?n.call(e,"Manually specify port",a):g.call(e,"t","Manually specify port",a)))+"\n          </label>\n        </div>\n      "
}function r(){return"checked"}function o(e,t){var n,s,a="";return a+='\n        <div class="form-group">\n          <input type="text" id="'+m((n=e&&e.mappingPortSetting,n=null==n||n===!1?n:n.id,typeof n===p?n.apply(e):n))+'" class="form-control" value="'+m((n=e&&e.mappingPortSetting,n=null==n||n===!1?n:n.value,typeof n===p?n.apply(e):n))+'" ',s=i.unless.call(e,(n=e&&e.mappingModeSetting,null==n||n===!1?n:n.value),{hash:{},inverse:f.noop,fn:f.program(5,l,t),data:t}),(s||0===s)&&(a+=s),a+=">\n        </div>\n      "
}function l(){return"disabled"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p="function",m=this.escapeExpression,f=this,g=i.helperMissing;return h+='<div class="row">\n  <div class="col-md-4 visible-md visible-lg text-center">\n    <i class="plex-image server"></i>\n  </div>\n\n  <div class="remote-access-error-container col-md-8">\n    ',u={hash:{mappingError:(c=t&&t.cloudAccount,null==c||c===!1?c:c.mappingError),context:"setup"},data:s},h+=m((c=i.partial||t&&t.partial,c?c.call(t,"connectError",u):g.call(t,"partial","connectError",u)))+'\n\n    <form id="setup-manual-connect-form" class="form-inline">\n      ',d=i["if"].call(t,t&&t.mappingModeSetting,{hash:{},inverse:f.noop,fn:f.program(1,a,s),data:s}),(d||0===d)&&(h+=d),h+="\n\n      ",d=i["if"].call(t,t&&t.mappingPortSetting,{hash:{},inverse:f.noop,fn:f.program(4,o,s),data:s}),(d||0===d)&&(h+=d),h+='\n\n      <button type="submit" class="retry-btn btn btn-default btn-loading">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Retry",u):g.call(t,"t","Retry",u)))+'</span>\n      </button>\n\n      <p class="help-block">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Enable this if automatic mapping fails. You will need to configure your router. Detailed instructions are available {1}here{2}.","<a href='http://support.plex.tv/hc/en-us/articles/200931138-Troubleshooting-myPlex-Server-connections' target='_blank'>","</a>",u):g.call(t,"t","Enable this if automatic mapping fails. You will need to configure your router. Detailed instructions are available {1}here{2}.","<a href='http://support.plex.tv/hc/en-us/articles/200931138-Troubleshooting-myPlex-Server-connections' target='_blank'>","</a>",u)))+'</p>\n    </form>\n\n    <div class="setup-footer">\n      <button class="next-btn btn btn-primary btn-lg" data-subset="setupLibrary">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Next",u):g.call(t,"t","Next",u)))+"</button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/setup/SetupConnectErrorView",["hb!templates/desktop/setup/SetupConnectErrorView.tpl","underscore","jquery","marionette","plex/base/commands/commands"],function(e,t,i,n,s){"use strict";var a=n.ItemView.extend({className:"setup-connect-error-container",template:e,ui:{retryBtn:".retry-btn",nextBtn:".next-btn",manualPortMappingPort:"#ManualPortMappingPort"},events:{"change input[id]":"onInputChange","submit #setup-manual-connect-form":"onSubmit"},initialize:function(){this.collection=this.model.get("settings"),this.changes={}
},serializeData:function(){var e=this.model.get("cloudAccount"),t=this.collection.get("ManualPortMappingMode"),i=this.collection.get("ManualPortMappingPort");return{cloudAccount:e.toJSON(),mappingModeSetting:t?t.toJSON():null,mappingPortSetting:i?i.toJSON():null}},save:function(){if(t.isEmpty(this.changes))return i.Deferred().resolve().promise();var e=this.collection.first().save(this.changes);return e.done(t.bind(function(){t.each(this.changes,function(e,t){var i=this.collection.get(t),n=i.get("type");
"bool"===n?i.set("value","0"!==e):"int"==n?i.set("value",parseInt(e,10)):i.set("value",e)},this),this.changes={}},this)),e},reconnect:function(){return s.execute("reconnectServer",{cloudAccount:this.model.get("cloudAccount")})},onInputChange:function(e){var t=e.currentTarget,i=t.value;if("checkbox"===t.type){var n=!1;t.checked||(i="0",n=!0),this.ui.manualPortMappingPort[0].disabled=n}this.changes[t.id]=i},onSubmit:function(e){e.preventDefault();var i=this.ui.retryBtn;if(!i.hasClass("active")){i.addClass("active");
var n=this.save();n.always(t.bind(function(){var e=this.reconnect();e.done(t.bind(function(){this.isClosed||this.ui.nextBtn.click()},this)),e.fail(t.bind(this.render,this))},this))}}});return a}),define("hb!templates/desktop/setup/SetupLibraryView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+="<h4>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Organize Your Media",r):l.call(t,"t","Organize Your Media",r)))+'</h4>\n\n<p class="text-muted">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Plex organizes your media into libraries. You can add as many libraries as you want, and you can have multiple libraries with the same type.",r):l.call(t,"t","Plex organizes your media into libraries. You can add as many libraries as you want, and you can have multiple libraries with the same type.",r)))+'</p>\n\n<p class="setup-add-section-container">\n  <button class="add-section-btn btn btn-default">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Add Library",r):l.call(t,"t","Add Library",r)))+'</button>\n</p>\n\n<div class="setup-section-list-container"></div>\n\n<div class="setup-footer">\n  <button class="next-btn btn btn-primary btn-lg" data-subset="setupChannels">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Next",r):l.call(t,"t","Next",r)))+"</button>\n</div>\n"
})}),define("hb!templates/desktop/lists/setup/SectionCardListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<div class="card card-section">\n  <div class="card-actions">\n    <button class="edit-section-btn card-action-btn"><i class="glyphicon pencil"></i></button>\n    <button class="delete-section-btn card-action-btn btn-danger"><i class="glyphicon remove-2"></i></button>\n  </div>\n\n  <i class="section-icon glyphicon ',(a=i.icon)?a=a.call(t,{hash:{},data:s}):(a=t&&t.icon,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'"></i>\n  <span class="section-title"></span>\n</div>\n'
})}),define("plex/desktop/views/lists/setup/SectionCardListItem",["hb!templates/desktop/lists/setup/SectionCardListItem.tpl","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/desktop/views/modals/EditSectionModal"],function(e,t,i,n,s){"use strict";var a={artist:"music",movie:"film",photo:"picture",show:"display"},r=t.ItemView.extend({tagName:"li",className:"card-tile-list-item",template:e,events:{"click .edit-section-btn":"onEditClick","click .delete-section-btn":"onDeleteClick"},serializeData:function(){var e=this.model.server,t=this.model.toJSON();
return{section:t,serverID:e.id,icon:a[t.type]}},bindings:{".section-title":{modelAttribute:"title"}},onEditClick:function(e){e.preventDefault(),i.trigger("show:modal",new s({server:this.model.server,model:this.model}))},onDeleteClick:function(e){e.preventDefault(),n.execute("deleteSection",{section:this.model})}});return r}),define("plex/desktop/views/lists/setup/SectionCardList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/setup/SectionCardListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t});return i}),define("plex/desktop/views/setup/SetupLibraryView",["hb!templates/desktop/setup/SetupLibraryView.tpl","marionette","plex/base/utils/dispatcher","plex/desktop/views/lists/setup/SectionCardList","plex/desktop/views/modals/EditSectionModal"],function(e,t,i,n,s){"use strict";var a=t.Layout.extend({className:"setup-library-container",template:e,regions:{list:".setup-section-list-container"},events:{"click .add-section-btn":"onAddSectionClick"},initialize:function(){this.collection=this.model.get("sections"),this.collection.populate()
},onRender:function(){this.list.show(new n({collection:this.collection}))},onAddSectionClick:function(e){e.preventDefault(),i.trigger("show:modal",new s({server:this.model}))}});return a}),define("hb!templates/desktop/setup/SetupChannelsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+="<h4>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Install Channels",r):l.call(t,"t","Install Channels",r)))+'</h4>\n\n<p class="text-muted">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Plex channels give you access to online media from a variety of sites. You can browse and install these channels from the Channel Directory, but get started by installing some featured channels.",r):l.call(t,"t","Plex channels give you access to online media from a variety of sites. You can browse and install these channels from the Channel Directory, but get started by installing some featured channels.",r)))+'</p>\n\n<div class="setup-channel-list-container"></div>\n\n<div class="setup-footer">\n  <button class="next-btn btn btn-primary btn-lg" data-subset="setupComplete">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Next",r):l.call(t,"t","Next",r)))+"</button>\n</div>\n"
})}),define("hb!templates/desktop/lists/channel/ChannelDirectoryTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<a class="media-poster-container" href="#">\n  <div class="media-poster">\n     <div class="installed-icon"><i class="glyphicon ok-2"></i></div>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n'})}),define("hb!templates/desktop/modals/ChannelModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='<button class="browse-btn btn btn-primary">',s={hash:{},data:t},a+=u((n=i.t||e&&e.t,n?n.call(e,"Browse",s):d.call(e,"t","Browse",s)))+"</button>"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h="function",p=this;return c+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">'+u((r=t&&t.channel,r=null==r||r===!1?r:r.title,typeof r===h?r.apply(t):r))+'</h4>\n    </div>\n\n    <div class="modal-body">\n      <div class="channel-poster-container">\n        <div class="channel-poster media-poster"></div>\n\n        <div class="installed-actions-container">\n          ',o=i.unless.call(t,t&&t.agent,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n\n          <div class="btn-group">\n            <button type="button" class="update-btn btn btn-default btn-loading">\n              <div class="loading loading-sm"></div>\n              <span class="btn-label">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Update",l):d.call(t,"t","Update",l)))+'</span>\n              </button>\n            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n              <i class="caret-icon caret-icon-sm"></i>\n            </button>\n            <ul class="dropdown-menu pull-right">\n              <li><a class="restart-btn" href="#">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Restart",l):d.call(t,"t","Restart",l)))+'</a></li>\n              <li><a class="reset-btn" href="#">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Reset",l):d.call(t,"t","Reset",l)))+'</a></li>\n            </ul>\n          </div>\n\n          <button class="uninstall-btn btn btn-danger btn-loading">\n            <div class="loading loading-sm"></div>\n            <span class="btn-label">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Uninstall",l):d.call(t,"t","Uninstall",l)))+'</span>\n          </button>\n        </div>\n\n        <div class="uninstalled-actions-container">\n          <button class="install-btn btn btn-primary btn-loading">\n            <div class="loading loading-sm"></div>\n            <span class="btn-label">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Install",l):d.call(t,"t","Install",l)))+'</span>\n          </button>\n        </div>\n      </div>\n\n      <div class="channel-details">\n        '+u((r=t&&t.channel,r=null==r||r===!1?r:r.summary,typeof r===h?r.apply(t):r))+"\n      </div>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/ChannelModal",["hb!templates/desktop/modals/ChannelModal.tpl","underscore","plex/base/utils/dispatcher","plex/base/commands/commands","plex/desktop/views/modals/BaseModal","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s,a){"use strict";var r=s.extend({name:"channelModal",className:"channel-modal modal fade",template:e,ui:{poster:".media-poster",installBtn:".install-btn",updateBtn:".update-btn",uninstallBtn:".uninstall-btn"},events:t.extend({"click .browse-btn":"onBrowseClick","click .install-btn":"onInstallClick","click .update-btn":"onUpdateClick","click .restart-btn":"onRestartClick","click .reset-btn":"onResetClick","click .uninstall-btn":"onUninstallClick"},s.prototype.events),initialize:function(e){s.prototype.initialize.apply(this,arguments),this.closeOnInstall=e.closeOnInstall,this.image=new a({model:this.model,type:"channel",width:200})
},serializeData:function(){return{channel:this.model.toJSON(),serverID:this.model.server.id,agent:/com.plexapp.agents./.test(this.model.id)}},bindings:{".installed-actions-container":{modelAttribute:"installed",manual:!0,autohide:!0},".uninstalled-actions-container":{modelAttribute:"installed",manual:!0,autohide:function(e){return!e}}},onRender:function(){s.prototype.onRender.apply(this,arguments),this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()},onBrowseClick:function(e){e.preventDefault();
var n=this.model.get("key"),s=t.last(n.split("/"));i.trigger("navigate","channel",{serverID:this.model.server.id,channelID:s}),this.hide()},onInstallClick:function(e){e.preventDefault();var i=this.ui.installBtn;if(!i.hasClass("active")){i.addClass("active");var s=n.execute("installChannel",{channel:this.model});s.done(t.bind(function(){this.closeOnInstall&&this.hide()},this)),s.always(function(){i.removeClass("active")})}},onUpdateClick:function(e){e.preventDefault();var t=this.ui.updateBtn;if(!t.hasClass("active")){t.addClass("active");
var i=n.execute("updateChannel",{channel:this.model,skipConfirmation:!0});i.always(function(){t.removeClass("active")})}},onRestartClick:function(e){e.preventDefault(),n.execute("restartChannel",{channel:this.model})},onResetClick:function(e){e.preventDefault(),n.execute("resetChannel",{channel:this.model})},onUninstallClick:function(e){e.preventDefault();var t=this.ui.uninstallBtn;if(!t.hasClass("active")){t.addClass("active");var i=n.execute("uninstallChannel",{channel:this.model,skipConfirmation:!0});
i.always(function(){t.removeClass("active")})}}});return r}),define("plex/desktop/views/lists/channel/ChannelDirectoryTileListItem",["hb!templates/desktop/lists/channel/ChannelDirectoryTileListItem.tpl","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/views/images/MediaPosterImage","plex/desktop/views/modals/ChannelModal"],function(e,t,i,n,s,a){"use strict";var r=t.ItemView.extend({tagName:"li",className:"poster-item media-tile-list-item channel-directory-tile-list-item channel",template:e,ui:{poster:".media-poster",subtitle:".media-subtitle-1"},events:{"click a":"onClick"},initialize:function(e){this.closeOnInstall=e.closeOnInstall,this.image=new s({model:this.model,type:"channel",width:150})
},bindings:{".media-title":{modelAttribute:"title"},".installed-icon":{modelAttribute:"installed",manual:!0,autohide:!0,formatter:function(e){var t=e?i("Installed"):"";return this.ui.subtitle.text(t),e}}},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()},onClick:function(e){e.preventDefault(),n.trigger("show:modal",new a({model:this.model,closeOnInstall:this.closeOnInstall}))}});return r}),define("plex/desktop/views/lists/channel/ChannelDirectoryTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/channel/ChannelDirectoryTileListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"tile-list media-tile-list channel-directory-tile-list",itemView:t});return i}),define("plex/desktop/views/setup/SetupChannelsView",["hb!templates/desktop/setup/SetupChannelsView.tpl","marionette","plex/base/models/channel/ChannelCollection","plex/desktop/views/lists/channel/ChannelDirectoryTileList"],function(e,t,i,n){"use strict";var s=t.Layout.extend({className:"setup-channels-container",template:e,regions:{list:".setup-channel-list-container"},initialize:function(){this.collection=new i([],{server:this.model,url:"/system/appstore/featured"}),this.collection.fetch({scope:"page"})
},onRender:function(){this.list.show(new n({collection:this.collection,itemViewOptions:{closeOnInstall:!0}}))}});return s}),define("hb!templates/desktop/setup/SetupCompleteView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n        <h4>",s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Thanks for supporting Plex.",s):u.call(e,"t","Thanks for supporting Plex.",s)))+'</h4>\n        <span class="text-muted">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"We really appreciate it. See what {1}benefits{2} come with your subscription.","<a href='https://plex.tv/subscription/welcome' target='_blank'>","</a>",s):u.call(e,"t","We really appreciate it. See what {1}benefits{2} come with your subscription.","<a href='https://plex.tv/subscription/welcome' target='_blank'>","</a>",s)))+"</span>\n      "
}function r(e,t){var n,s,a,r="";return r+="\n        <h4>",a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Go Premium. Get a Plex Pass.",a):u.call(e,"t","Go Premium. Get a Plex Pass.",a)))+'</h4>\n        <span class="text-muted">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Everything you need to experience the best of Plex. Your subscription gives you premium features and exclusive access to new ones.",a):u.call(e,"t","Everything you need to experience the best of Plex. Your subscription gives you premium features and exclusive access to new ones.",a)))+'</span>\n\n        <div class="setup-plex-pass-action-container">\n          <a class="btn btn-sm btn-default" href="',(s=i.plexPassUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.plexPassUrl,s=typeof s===p?s.call(e,{hash:{},data:t}):s),r+=h(s)+'" target="_blank">',a={hash:{},data:t},r+=h((n=i.t||e&&e.t,n?n.call(e,"Learn More",a):u.call(e,"t","Learn More",a)))+"</a>\n        </div>\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p="function",m=this;return d+='<div class="row">\n  <div class="col-md-6">\n    <h4>',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Congratulations!",c):u.call(t,"t","Congratulations!",c)))+'</h4>\n\n    <p class="text-muted">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"See, that wasn't too bad, right? At this very moment, Plex is working tirelessly to build your library, and make it look beautiful.",c):u.call(t,"t","See, that wasn't too bad, right? At this very moment, Plex is working tirelessly to build your library, and make it look beautiful.",c)))+'</p>\n\n    <p class="text-muted">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Feel free to watch Plex work, or take this opportunity to {1}download{2} some Plex apps!","<a href='https://plex.tv/downloads' target='_blank'>","</a>",c):u.call(t,"t","Feel free to watch Plex work, or take this opportunity to {1}download{2} some Plex apps!","<a href='https://plex.tv/downloads' target='_blank'>","</a>",c)))+'</p>\n  </div>\n\n  <div class="col-md-6 visible-md visible-lg text-center">\n    <i class="plex-image plex-pass"></i>\n\n    <div class="setup-plex-pass-container">\n      ',l=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:m.program(3,r,s),fn:m.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='\n    </div>\n  </div>\n</div>\n\n<div class="setup-footer setup-done-footer">\n  <button class="done-btn btn btn-primary btn-lg">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Done",c):u.call(t,"t","Done",c)))+"</button>\n</div>\n"
})}),define("plex/desktop/views/setup/SetupCompleteView",["hb!templates/desktop/setup/SetupCompleteView.tpl","marionette","plex/base/models/appModel"],function(e,t,i){"use strict";var n=t.ItemView.extend({className:"setup-complete-container",template:e,serializeData:function(){var e=i.get("user");return{hasPlexPass:e.hasPlexPass(),plexPassUrl:e.server.get("plexPassUrl")}}});return n}),define("plex/desktop/views/setup/SetupView",["hb!templates/desktop/setup/SetupView.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/adapters/loggerAdapter","plex/base/commands/commands","plex/base/models/library/AgentCollection","plex/desktop/views/setup/SetupLoadingView","plex/desktop/views/setup/SetupErrorView","plex/desktop/views/setup/SetupBasicView","plex/desktop/views/setup/SetupConnectErrorView","plex/desktop/views/setup/SetupLibraryView","plex/desktop/views/setup/SetupChannelsView","plex/desktop/views/setup/SetupCompleteView"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f={setupLoading:l,setupError:c,setupBasic:d,setupConnectError:u,setupLibrary:h,setupChannels:p,setupComplete:m},g=["com.plexapp.agents.imdb","com.plexapp.agents.thetvdb","com.plexapp.agents.lastfm"],v=n.Layout.extend({className:"container",template:e,maxAttempts:120,regions:{container:".setup-container"},events:{"click .segment-btn":"onNavClick","click .next-btn":"onNavClick","click .done-btn":"onDoneClick"},onlyAfterRender:["onAgentsSuccess","onAgentsFail","onUpdatesComplete"],initialize:function(e){t.bindAll(this,"start","onAgentsSuccess","onAgentsFail","onUpdatesComplete"),this.subset=e.subset||"setupBasic",this.attempts=0,a.info("Starting the setup wizard")
},serializeData:function(){return{subset:this.subset}},start:function(){if(this.attempts>=this.maxAttempts)return a.error("Failed to start the setup wizard after "+this.attempts+" attempts"),void this.navigate("setupError");this.attempts++;var e=this.model.get("startState");if(e)a.log("Waiting for server to start ("+e+")"),this.model.fetch().done(t.delay(this.start,500));else{var i=new o([],{server:this.model}),n=i.fetch({scope:"page"});n.done(this.onAgentsSuccess),n.fail(this.onAgentsFail)}},navigate:function(e){var t=f[e];
this.previousSubset=this.subset,this.subset=e,this.container.show(new t({model:this.model})),this.$el.addClass(e),this.previousSubset!=e&&this.$el.removeClass(this.previousSubset)},onRender:function(){this.model.get("shared")?this.navigate("setupError"):(this.navigate("setupLoading"),this.start())},onAgentsSuccess:function(e){a.log("Looking for a core agent");for(var t=0,i=g.length;i>t;t++){var n=g[t];if(e.get(n)){a.log(n+" found");var s=r.execute("updateChannel",{server:this.model,silent:!0});return void s.always(this.onUpdatesComplete)
}}a.error("No core agents found"),this.navigate("setupError")},onAgentsFail:function(){a.warn("Unable to request agents"),t.delay(this.start,500)},onUpdatesComplete:function(){this.navigate(this.previousSubset)},onNavClick:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.data("subset");this.navigate(n),s.trigger("navigate",n,{trigger:!1})},onDoneClick:function(e){e.preventDefault(),s.trigger("navigate","dashboard")}});return v}),define("plex/desktop/routes/SetupController",["plex/base/utils/dispatcher","plex/base/routes/BaseController","plex/desktop/views/setup/SetupView"],function(e,t,i){"use strict";
var n=t.extend({setupBasic:function(t){var n;n=t?{serverID:t}:{primaryServer:!0};var s=this.populateView(n);s.done(function(t){e.trigger("show:view",new i({model:t.server,subset:"setupBasic"}))})},setupLibrary:function(){var t=this.populateView({primaryServer:!0});t.done(function(t){e.trigger("show:view",new i({model:t.server,subset:"setupLibrary"}))})},setupChannels:function(){var t=this.populateView({primaryServer:!0});t.done(function(t){e.trigger("show:view",new i({model:t.server,subset:"setupChannels"}))
})},setupComplete:function(){var t=this.populateView({primaryServer:!0});t.done(function(t){e.trigger("show:view",new i({model:t.server,subset:"setupComplete"}))})}});return n}),define("plex/desktop/routes/SetupRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/SetupController"],function(e,t){"use strict";var i=e.extend({controller:new t,appRoutes:{"!/setup(/:serverID)":"setupBasic","!/setup/library":"setupLibrary","!/setup/channels":"setupChannels","!/setup/complete":"setupComplete"}});
return i}),define("hb!templates/desktop/SearchView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<h2 class="searching-header">\n  ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Searching for {1}",t&&t.query,r):l.call(t,"t","Searching for {1}",t&&t.query,r)))+' <span class="loading loading-sm"></span>\n</h2>\n\n<h2 class="search-results-header">\n  ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Results for {1}",t&&t.query,r):l.call(t,"t","Results for {1}",t&&t.query,r)))+'\n</h2>\n\n<h4 class="empty-message text-muted text-center hidden">\n  ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"No matches found.",r):l.call(t,"t","No matches found.",r)))+'\n</h4>\n\n<div class="movie-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Movies",r):l.call(t,"t","Movies",r)))+'</h4></div>\n</div>\n\n<div class="show-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"TV Shows",r):l.call(t,"t","TV Shows",r)))+'</h4></div>\n</div>\n\n<div class="episode-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Episodes",r):l.call(t,"t","Episodes",r)))+'</h4></div>\n</div>\n\n<div class="artist-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Artists",r):l.call(t,"t","Artists",r)))+'</h4></div>\n</div>\n\n<div class="album-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Albums",r):l.call(t,"t","Albums",r)))+'</h4></div>\n</div>\n\n<div class="track-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Tracks",r):l.call(t,"t","Tracks",r)))+'</h4></div>\n</div>\n\n<div class="photo-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Photos",r):l.call(t,"t","Photos",r)))+'</h4></div>\n</div>\n\n<div class="clip-search-container hidden">\n  <div class="filter-bar"><h4>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Clips",r):l.call(t,"t","Clips",r)))+"</h4></div>\n</div>\n"
})}),define("plex/base/models/library/SearchProviderModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";var n=i.extend({idAttribute:"key",whitelistedAttrs:["key","machineIdentifier","type","title"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return n}),define("plex/base/models/library/SearchProviderCollection",["plex/base/models/BaseCollection","plex/base/models/library/SearchProviderModel"],function(e,t){"use strict";
var i=e.extend({model:t,url:function(){return"/system/search?query="+this.query},initialize:function(e,t){this.query=t.query},parse:function(e){return this.convert(e,"Provider")}});return i}),define("plex/desktop/views/lists/library/MediaTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/MediaTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list show-context",itemView:t});return i}),define("plex/desktop/views/SearchView",["hb!templates/desktop/SearchView.tpl","underscore","marionette","plex/base/adapters/settingsAdapter","plex/base/models/appModel","plex/base/models/library/SearchProviderCollection","plex/base/models/library/MetadataCollection","plex/desktop/views/lists/library/MediaTileList"],function(e,t,i,n,s,a,r,o){"use strict";
var l=["movie","show","episode","artist","album","track","photo","clip"],c=i.Layout.extend({className:"search-container container searching",template:e,ui:{emptyMessage:".empty-message"},initialize:function(e){this.bindAllWhenRendered("checkPendingRequests"),this.query=e.query,this.collections=[],this.channelProviders=[],this.pendingRequests=0,this.lists={},t.each(l,function(e){var t="."+e+"-search-container",i=new r;i.comparator=this.itemComparator;var n=new o({collection:i});n.sorted=!0,this.addRegion(e,t),this.lists[e]=n
},this);var i=s.get("servers");i.each(this.initializeServer,this),s.set("searchValue",this.query),this.listenTo(i,"change:authorized",this.initializeServer)},initializeServer:function(e){!e.get("authorized")||e.get("cloud")||e.get("synced")||(!e.get("shared")||n.get("sharedSearch"))&&e.populate().done(t.bind(function(){e.supports("search")&&this.initializeProviders(e)},this))},initializeProviders:function(e){var t=new r([],{server:e,url:"/search?local=1&query="+this.query}),i=new r([],{server:e,url:"/search?type=10&query="+this.query});
if(this.listenToOnce(t,"reset",this.onMetadataReset),this.listenToOnce(i,"reset",this.onMetadataReset),this.pendingRequests+=2,t.fetch({reset:!0,scope:"page"}).always(this.checkPendingRequests),i.fetch({reset:!0,scope:"page"}).always(this.checkPendingRequests),n.get("channelSearch")&&!e.get("shared")){var s=new a([],{server:e,query:this.query});this.listenToOnce(s,"reset",this.onChannelProvidersReset),this.pendingRequests++,s.fetch({reset:!0,scope:"page"}).always(this.checkPendingRequests)}},serializeData:function(){return{query:t.escape(decodeURIComponent(this.query))}
},checkPendingRequests:function(){if(!--this.pendingRequests){this.$el.removeClass("searching");var e=t.every(this.lists,function(e){return 0===e.collection.length});e&&this.ui.emptyMessage.removeClass("hidden")}},itemComparator:function(e){var t=e.server,i=t.get("friendlyName")||"",n=t.get("shared"),s=n?"1":"0";return s+=i.toLowerCase()},onRender:function(){t.each(l,function(e){var t=this.lists[e];this[e].append(t)},this)},onChannelProvidersReset:function(e){e.each(function(e){if(!(e.get("machineIdentifier")||t.indexOf(this.channelProviders,e.id)>-1)){var i=new r([],{server:e.server,url:e.id+"&query="+this.query});
this.listenToOnce(i,"reset",this.onMetadataReset),this.pendingRequests++,i.fetch({reset:!0,scope:"page"}).always(this.checkPendingRequests)}},this)},onMetadataReset:function(e){this.collections.push(e);var i=e.splitByType();for(var n in i){if(t.indexOf(l,n)<0)return;this.$("."+n+"-search-container").removeClass("hidden");var s=this.lists[n];s.collection.add(i[n])}}});return c}),define("hb!templates/desktop/section/SectionView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("hb!templates/desktop/actionbar/SectionActionBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="action-bar">\n  <ul class="nav action-bar-nav">\n    <li>\n      <a class="options-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Options",r):l.call(t,"t","Options",r)))+'" data-toggle="tooltip"><i class="glyphicon show-lines"></i></a>\n    </li>\n    <li>\n      <a class="play-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Play All",r):l.call(t,"t","Play All",r)))+'" data-toggle="tooltip"><i class="glyphicon play"></i></a>\n    </li>\n    <li>\n      <a class="play-shuffled-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Shuffle",r):l.call(t,"t","Shuffle",r)))+'" data-toggle="tooltip"><i class="glyphicon random"></i></a>\n    </li>\n    <li>\n      <a class="add-to-playlist-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Add to playlist",r):l.call(t,"t","Add to playlist",r)))+'" data-toggle="tooltip"><i class="plex-icon add-to-playlist"></i></a>\n    </li>\n    <li>\n      <a class="select-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Select",r):l.call(t,"t","Select",r)))+'" data-toggle="tooltip"><i class="glyphicon check"></i></a>\n    </li>\n    <li>\n      <a class="deselect-btn btn-gray selected" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Deselect All",r):l.call(t,"t","Deselect All",r)))+'" data-toggle="tooltip"><i class="glyphicon unchecked"></i></a>\n    </li>\n    <li>\n      <a class="edit-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Edit",r):l.call(t,"t","Edit",r)))+'" data-toggle="tooltip"><i class="glyphicon pencil"></i></a>\n    </li>\n    <li>\n      <a class="refresh-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Refresh",r):l.call(t,"t","Refresh",r)))+'" data-toggle="tooltip"><i class="glyphicon repeat"></i></a>\n    </li>\n    <li>\n      <a class="analyze-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Analyze",r):l.call(t,"t","Analyze",r)))+'" data-toggle="tooltip"><i class="glyphicon magic"></i></a>\n    </li>\n    <li>\n      <a class="mark-watched-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Mark as Watched",r):l.call(t,"t","Mark as Watched",r)))+'" data-toggle="tooltip"><i class="glyphicon circle-ok"></i></a>\n    </li>\n    <li>\n      <a class="mark-unwatched-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Mark as Unwatched",r):l.call(t,"t","Mark as Unwatched",r)))+'" data-toggle="tooltip"><i class="glyphicon circle-minus"></i></a>\n    </li>\n    <li>\n      <a class="add-to-collection-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Add to Collection",r):l.call(t,"t","Add to Collection",r)))+'" data-toggle="tooltip"><i class="glyphicon folder-plus"></i></a>\n    </li>\n    <li>\n      <a class="merge-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Merge",r):l.call(t,"t","Merge",r)))+'" data-toggle="tooltip"><i class="glyphicon resize-small"></i></a>\n    </li>\n    <li>\n      <a class="sync-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sync",r):l.call(t,"t","Sync",r)))+'" data-toggle="tooltip"><i class="glyphicon download"></i></a>\n    </li>\n    <li>\n      <a class="delete-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Delete",r):l.call(t,"t","Delete",r)))+'" data-toggle="tooltip"><i class="glyphicon bin"></i></a>\n    </li>\n  </ul>\n</div>\n'
})}),define("hb!templates/desktop/sidebar/SectionSideBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c=this,d=i.helperMissing,u=this.escapeExpression;return l+='<div class="side-bar-page main-page dark-scrollbar">\n  <div class="section-current-filters-container">\n    <div class="side-bar-actions">\n      <a class="new-filter-icon-btn new-filter-btn btn-gray ',r=i.unless.call(t,t&&t.showNewFilterIconBtn,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='" href="#"><i class="glyphicon plus"></i></a>\n    </div>\n\n    <h5>',o={hash:{},data:s},l+=u((r=i.t||t&&t.t,r?r.call(t,"Filters",o):d.call(t,"t","Filters",o)))+'</h5>\n    <div class="section-current-filters-list-container"></div>\n  </div>\n\n  <div class="section-sort-container hidden">\n    <h5>',o={hash:{},data:s},l+=u((r=i.t||t&&t.t,r?r.call(t,"Sort",o):d.call(t,"t","Sort",o)))+'</h5>\n    <div class="section-sort-list-container"></div>\n  </div>\n</div>\n\n<div class="side-bar-page filters-page dark-scrollbar">\n  <div class="section-filters-container">\n    <div class="side-bar-actions">\n      <a class="hide-btn btn-gray" href="#"><i class="glyphicon chevron-left"></i></a>\n    </div>\n\n    <h5>',o={hash:{},data:s},l+=u((r=i.t||t&&t.t,r?r.call(t,"Select A Filter",o):d.call(t,"t","Select A Filter",o)))+'</h5>\n    <div class="section-filters-list-container"></div>\n  </div>\n</div>\n\n<div class="side-bar-page filter-options-page dark-scrollbar">\n  <div class="section-filter-options-container">\n    <div class="side-bar-actions">\n      <a class="hide-btn btn-gray" href="#"><i class="glyphicon chevron-left"></i></a>\n    </div>\n\n    <h5 class="filter-options-header"></h5>\n    <div class="section-filter-option-list-container"></div>\n  </div>\n</div>\n'
})}),define("hb!templates/desktop/filterbar/SectionFilterBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<div class="filter-bar-right">\n  <a class="clear-filters-btn btn-gray" href="#"><i class="glyphicon remove-2"></i></a>\n</div>\n\n<h4>',(a=i.titles)?a=a.call(t,{hash:{},data:s}):(a=t&&t.titles,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"</h4>\n"
})}),define("plex/desktop/views/filterbar/SectionFilterBarView",["hb!templates/desktop/filterbar/SectionFilterBarView.tpl","underscore","marionette","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";var s=i.ItemView.extend({className:"filter-bar filter-bar-fixed",template:e,events:{"click .clear-filters-btn":"onClearFiltersClick"},serializeData:function(){var e=this.model.get("currentFilters"),i=[];return t.each(e,function(e){i.push(e.titles.join(", "))}),{titles:i.join(", ")}},onClearFiltersClick:function(e){e.preventDefault();
var t=this.model.get("currentFilters");t.length=0,this.model.trigger("change:currentFilters",this.model,t),n.trigger("navigate","section",{serverID:this.model.server.id,sectionID:this.model.id,subset:this.model.get("subset"),trigger:!1})}});return s}),define("hb!templates/desktop/lists/library/section/CurrentFilterList",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <div class="label-list-item">\n    <a class="new-filter-btn label label-btn label-default" href="#"><i class="label-icon glyphicon circle-plus"></i> ',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"New Filter",s):c.call(e,"t","New Filter",s)))+"</a>\n  </div>\n"
}function r(e,t){var n,s,a="";return a+='\n  <div class="label-list-item">\n    <a class="remove-filter-btn label label-btn label-primary" data-key="',(n=i.key)?n=n.call(e,{hash:{},data:t}):(n=e&&e.key,n=typeof n===u?n.call(e,{hash:{},data:t}):n),a+=d(n)+'" href="#"><i class="label-icon glyphicon circle-remove"></i> <span class="label-truncate">',s={hash:{},data:t},a+=d((n=i.csl||e&&e.csl,n?n.call(e,e&&e.titles,s):c.call(e,"csl",e&&e.titles,s)))+"</span></a>\n  </div>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var o,l="",c=i.helperMissing,d=this.escapeExpression,u="function",h=this;return o=i.unless.call(t,t&&t.currentFilters,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+="\n\n",o=i.each.call(t,t&&t.currentFilters,{hash:{},inverse:h.noop,fn:h.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+="\n"})}),define("plex/desktop/views/lists/library/section/CurrentFilterList",["hb!templates/desktop/lists/library/section/CurrentFilterList.tpl","jquery","marionette"],function(e,t,i){"use strict";
var n=i.ItemView.extend({className:"label-list section-current-filters-list",template:e,modelEvents:{"change:currentFilters":"render"},events:{"click .remove-filter-btn":"onRemoveFilterClick"},initialize:function(e){e.disabled&&this.$el.addClass("disabled")},serializeData:function(){return{currentFilters:this.model.get("currentFilters")}},onRemoveFilterClick:function(e){e.preventDefault();var i=t(e.currentTarget).data("key");this.trigger("removeAllFilters",i)}});return n}),define("hb!templates/desktop/lists/library/section/FilterListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"boolean-btn"
}function r(){return"filter-btn"}function o(){return"selected"}function l(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p=this,m=i.helperMissing,f=this.escapeExpression;return h+='<a class="',u={hash:{},inverse:p.program(3,r,s),fn:p.program(1,a,s),data:s},c=i.if_eq||t&&t.if_eq,d=c?c.call(t,(c=t&&t.filter,null==c||c===!1?c:c.filterType),"boolean",u):m.call(t,"if_eq",(c=t&&t.filter,null==c||c===!1?c:c.filterType),"boolean",u),(d||0===d)&&(h+=d),h+=" btn-gray ",d=i["if"].call(t,t&&t.selected,{hash:{},inverse:p.noop,fn:p.program(5,o,s),data:s}),(d||0===d)&&(h+=d),h+='" href="#">\n  ',u={hash:{},data:s},h+=f((c=i.t||t&&t.t,c?c.call(t,(c=t&&t.filter,null==c||c===!1?c:c.title),u):m.call(t,"t",(c=t&&t.filter,null==c||c===!1?c:c.title),u)))+'\n  <i class="selected-icon glyphicon ok-2 ',d=i.unless.call(t,t&&t.selected,{hash:{},inverse:p.noop,fn:p.program(7,l,s),data:s}),(d||0===d)&&(h+=d),h+='"></i>\n</a>\n'
})}),define("plex/desktop/views/lists/library/section/FilterListItem",["hb!templates/desktop/lists/library/section/FilterListItem.tpl","underscore","marionette"],function(e,t,i){"use strict";var n=i.ItemView.extend({tagName:"li",template:e,ui:{btn:"a",selectedIcon:".selected-icon"},events:{"click .boolean-btn":"onBooleanFilterClick","click .filter-btn":"onFilterClick"},onlyAfterRender:["onCurrentFiltersChange"],initialize:function(){this.listenTo(this.model.section,"change:currentFilters",this.onCurrentFiltersChange)
},serializeData:function(){return{filter:this.model.toJSON(),selected:this.isCurrentFilter()}},isCurrentFilter:function(){var e=this.model.section.get("currentFilters");return!!t.findWhere(e,{key:this.model.id})},onBooleanFilterClick:function(e){e.preventDefault();var t={key:this.model.id,title:this.model.get("title"),value:1};this.ui.btn.hasClass("selected")?this.trigger("removeFilter",t):this.trigger("addFilter",t)},onFilterClick:function(e){e.preventDefault(),this.trigger("showOptions",this.model)
},onCurrentFiltersChange:function(){var e=this.isCurrentFilter();this.ui.btn.toggleClass("selected",e),this.ui.selectedIcon.toggleClass("hidden",!e)}});return n}),define("plex/desktop/views/lists/library/section/FilterList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/section/FilterListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list side-bar-list",itemView:t,initialize:function(e){var t=this.collection.section;e.disabled?this.$el.addClass("disabled"):this.listenTo(t,"change:currentType",this.onCurrentTypeChange)
},onCurrentTypeChange:function(){this.collection.fetch({reset:!0,scope:"page"})}});return i}),define("hb!templates/desktop/lists/library/section/FilterOptionList",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c=this,d="function",u=this.escapeExpression,h=i.helperMissing;return l+='<form id="filter-options-search-form" class="',r=i.unless.call(t,t&&t.showSearch,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='">\n  <div class="form-group form-group-search">\n    <label class="control-label-search" for="filter-options-search"><i class="glyphicon search"></i></label>\n    <input type="search" id="filter-options-search" class="form-control form-control-search" value="',(r=i.query)?r=r.call(t,{hash:{},data:s}):(r=t&&t.query,r=typeof r===d?r.call(t,{hash:{},data:s}):r),l+=u(r)+'">\n  </div>\n</form>\n\n<div id="filter-options-loading" class="loading ',r=i.unless.call(t,t&&t.showLoading,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='"></div>\n\n<ul class="list side-bar-list">\n  <li><a class="filter-options-deselect-btn btn-gray" href="#">',o={hash:{},data:s},l+=u((r=i.t||t&&t.t,r?r.call(t,"Deselect All",o):h.call(t,"t","Deselect All",o)))+"</a>\n</ul>\n"
})}),define("hb!templates/desktop/lists/library/section/FilterOptionListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"selected"}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h=i.helperMissing,p=this.escapeExpression;return d+='<a class="filter-option-btn btn-gray ',o=i["if"].call(t,t&&t.selected,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(d+=o),d+='" href="#">\n  ',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,(o=t&&t.filterOption,null==o||o===!1?o:o.title),c):h.call(t,"t",(o=t&&t.filterOption,null==o||o===!1?o:o.title),c)))+'\n  <i class="selected-icon glyphicon ok-2 ',l=i.unless.call(t,t&&t.selected,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='"></i>\n</a>\n'
})}),define("plex/desktop/views/lists/library/section/FilterOptionListItem",["hb!templates/desktop/lists/library/section/FilterOptionListItem.tpl","underscore","marionette"],function(e,t,i){"use strict";var n=i.ItemView.extend({tagName:"li",template:e,ui:{btn:"a",selectedIcon:".selected-icon"},events:{"click a":"onClick"},onlyAfterRender:["onCurrentFiltersChange"],initialize:function(){this.listenTo(this.model.section,"change:currentFilters",this.onCurrentFiltersChange)},serializeData:function(){return{filterOption:this.model.toJSON(),selected:this.isCurrentFilter()}
},isCurrentFilter:function(){var e=this.model.section.get("currentFilters"),i=t.findWhere(e,{key:this.model.parent.id});if(!i)return!1;var n=i.values,s=t.find(n,t.bind(function(e){return e==this.model.get("key")},this));return!!s},onClick:function(e){e.preventDefault();var t={key:this.model.parent.id,title:this.model.get("title"),value:this.model.id};this.ui.btn.hasClass("selected")?this.trigger("removeFilter",t):this.trigger("addFilter",t)},onCurrentFiltersChange:function(){var e=this.isCurrentFilter();
this.ui.btn.toggleClass("selected",e),this.ui.selectedIcon.toggleClass("hidden",!e)}});return n}),define("plex/desktop/views/lists/library/section/FilterOptionList",["hb!templates/desktop/lists/library/section/FilterOptionList.tpl","jquery","marionette","plex/desktop/views/lists/library/section/FilterOptionListItem"],function(e,t,i,n){"use strict";var s=i.CompositeView.extend({classname:"filter-option-list-search-container",template:e,itemView:n,itemViewContainer:".side-bar-list",query:"",ui:{searchForm:"#filter-options-search-form",searchInput:"#filter-options-search",loading:"#filter-options-loading"},events:{"keyup #filter-options-search":"onSearchKeyUp","submit #filter-options-search-form":"onSearchSubmit","click .filter-options-deselect-btn":"onDeselectClick"},initialize:function(){this.originalCollection=this.collection,this.listenToOnce(this.originalCollection,"reset",this.onCollectionReset),this.collection.fetch({reset:!0,scope:"page"})
},serializeData:function(){return{showSearch:this.collection.length>20,query:this.query,showLoading:!this.collection.length}},search:function(){this.query=t.trim(this.ui.searchInput.val()),this.rebase(this.query?this.originalCollection.search(this.query):this.originalCollection)},selectExactMatch:function(){this.collection.each(function(e){var t=e.get("title");if(t&&t.toLowerCase()===this.query.toLowerCase()){var i={key:e.parent.id,title:t,value:e.id};this.trigger("addFilter",this,i)}},this)},onCollectionReset:function(e){var t=e.length>20;
this.ui.searchForm.toggleClass("hidden",!t),this.ui.loading.addClass("hidden")},onSearchKeyUp:function(){this.search()},onSearchSubmit:function(e){e.preventDefault(),this.search(),this.query&&this.selectExactMatch()},onDeselectClick:function(e){e.preventDefault(),this.trigger("removeAllFilters",this.collection.parent.id)}});return s}),define("hb!templates/desktop/lists/library/section/SortListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<a class="sort-btn btn-gray" href="#">\n  ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,t&&t.title,r):l.call(t,"t",t&&t.title,r)))+'\n  <i class="desc-icon caret-icon caret-icon-sm hidden"></i>\n  <i class="asc-icon caret-icon caret-icon-sm caret-icon-reverse hidden"></i>\n</a>\n'})}),define("plex/desktop/views/lists/library/section/SortListItem",["hb!templates/desktop/lists/library/section/SortListItem.tpl","marionette"],function(e,t){"use strict";
var i=t.ItemView.extend({tagName:"li",template:e,events:{"click a":"onClick"},initialize:function(){var e=this.model.section.get("currentSort");if(!e){var t=this.model.get("defaultDirection");t&&(this.model.set({selected:!0,direction:t}),this.model.section.set("currentSort",this.model,{silent:!0}))}this.listenTo(this.model.section,"change:currentSort",this.onCurrentSortChange)},bindings:{".sort-btn":{modelAttribute:"selected",manual:!0,formatter:function(e,t){t.toggleClass("selected",e)}},".desc-icon":{modelAttribute:"direction",manual:!0,formatter:function(e,t){t.toggleClass("hidden","desc"!==e)
}},".asc-icon":{modelAttribute:"direction",manual:!0,formatter:function(e,t){t.toggleClass("hidden","asc"!==e)}}},onCurrentSortChange:function(e,t){t&&this.model.id!==t.id&&this.model.set({selected:!1,direction:null})},onClick:function(e){e.preventDefault();var t=this.model.section.get("currentSort"),i=this.model.get("direction");i=i&&"asc"!==i?"asc":"desc",this.model.set({selected:!0,direction:i}),t&&t.id===this.model.id?this.model.section.trigger("change:currentSort",this.model.section,this.model):this.model.section.set("currentSort",this.model)
}});return i}),define("plex/desktop/views/lists/library/section/SortList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/section/SortListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list side-bar-list",itemView:t,initialize:function(e){var t=this.collection.section;e.disabled?this.$el.addClass("disabled"):t&&(this.listenTo(t,"change:currentType",this.onCurrentTypeChange),t.get("pseudo")||this.collection.populate({reset:!0,scope:"page"}))},onCurrentTypeChange:function(e){this.collection.section.set("currentSort",null,{silent:!0}),e.get("pseudo")||this.collection.fetch({reset:!0,scope:"page"})
}});return i}),define("plex/desktop/views/sidebar/SectionSideBarView",["hb!templates/desktop/sidebar/SectionSideBarView.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/models/appModel","plex/desktop/views/filterbar/SectionFilterBarView","plex/desktop/views/lists/library/section/CurrentFilterList","plex/desktop/views/lists/library/section/FilterList","plex/desktop/views/lists/library/section/FilterOptionList","plex/desktop/views/lists/library/section/SortList"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=i.Layout.extend({className:"side-bar",template:e,ui:{newFilterBtn:".new-filter-icon-btn",filterOptionsHeader:".filter-options-header",typeContainer:".section-type-container",sortContainer:".section-sort-container"},regions:{currentFilters:".section-current-filters-list-container",filters:".section-filters-list-container",filterOptions:".section-filter-option-list-container",sort:".section-sort-list-container"},modelEvents:{"change:currentFilters":"onCurrentFiltersChange","change:currentType":"onCurrentTypeChange","change:title":"onSectionTitleChange"},events:{"click .new-filter-btn":"onNewFilterClick","click .hide-btn":"onHideClick"},initialize:function(e){this.hidden=!a.get("sidebarOpen"),this.advancedFilters=!!this.model.get("allowAdvancedFilters"),this.linearFilters=!this.advancedFilters,this.mediaActions=e.mediaActions,this.hidden?this.$el.addClass("transition-out"):s.trigger("show:bar","sidebar"),r.set({searchType:"section",searchPlaceholder:this.model.get("title"),searchValue:this.getSearchValue()}),this.listenTo(s,"search:section",this.onSearch)
},serializeData:function(){return{showNewFilterIconBtn:this.advancedFilters&&!!this.model.get("currentFilters").length}},open:function(){this.hidden=!1,a.save("sidebarOpen",!0),this.$el.removeClass("transition-out"),s.trigger("show:bar","sidebar")},hide:function(){this.hidden=!0,a.save("sidebarOpen",!1),this.$el.addClass("transition-out"),s.trigger("hide:bar","sidebar")},getSearchValue:function(){var e=this.model.get("currentFilters"),i=t.findWhere(e,{key:"title"});return i&&i.values.length?i.values[0]:null
},addFilter:function(e,i){i||(i={});var n=this.model.get("currentFilters");this.linearFilters&&n.length&&(n.length=0);var s=t.findWhere(n,{key:e.key});if(s){if(t.indexOf(s.values,e.value)>-1)return;i.replace?(s.titles=[e.title],s.values=[e.value]):(s.titles.push(e.title),s.values.push(e.value))}else n.push({key:e.key,titles:[e.title],values:[e.value]});this.model.trigger("change:currentFilters",this.model,n)},removeFilter:function(e){var i=this.model.get("currentFilters"),n=t.findWhere(i,{key:e.key});
n&&(n.titles=t.reject(n.titles,function(t){return t===e.title}),n.values=t.reject(n.values,function(t){return t===e.value}),n.values.length||i.splice(t.indexOf(i,n),1)),this.model.trigger("change:currentFilters",this.model,i)},removeAllFilters:function(e){var i=this.model.get("currentFilters"),n=t.findWhere(i,{key:e});i.splice(t.indexOf(i,n),1),this.model.trigger("change:currentFilters",this.model,i)},onRender:function(){var e="all"!==this.model.get("currentSubset").id,i=this.model.get("currentFilters");
e&&(i.length=0);var n=new l({model:this.model,disabled:e}),a=new u({collection:this.model.get("sorts"),disabled:e});if(this.listenTo(n,"removeAllFilters",this.onRemoveAllFilters),this.listenToOnce(a,"collection:rendered",this.onSortListRender),this.currentFilters.show(n),this.sort.show(a),!e){var r=this.model.get("filters").populate({reset:!0,scope:"page"});r.done(t.bind(function(t){if(!this.isClosed){var i=this.linearFilters?t.filterBySecondary():t,n=new c({collection:i,disabled:e});this.listenTo(n,"itemview:addFilter",this.onAddFilter),this.listenTo(n,"itemview:removeFilter",this.onRemoveFilter),this.listenTo(n,"itemview:showOptions",this.onFilterListShowOptions),this.filters.show(n)
}},this))}i.length&&s.trigger("show:bar","filterbar",new o({model:this.model}))},onClose:function(){r.set({searchType:null,searchPlaceholder:null}),s.trigger("hide:bar","sidebar"),s.trigger("hide:bar","filterbar")},onCurrentFiltersChange:function(e,t){var i=!!t.length;this.ui.newFilterBtn.toggleClass("hidden",this.linearFilters||!i),r.set("searchValue",this.getSearchValue()),i?s.trigger("show:bar","filterbar",new o({model:this.model})):s.trigger("hide:bar","filterbar")},onCurrentTypeChange:function(){this.$el.removeClass("show-filters show-filter-options"),this.removeAllFilters()
},onSectionTitleChange:function(e,t){r.set("searchPlaceholder",t)},onSearch:function(e){return e?void this.addFilter({key:"title",value:e,title:e},{replace:!0}):void this.removeAllFilters("title")},onAddFilter:function(e,t){this.addFilter(t)},onRemoveFilter:function(e,t){this.removeFilter(t)},onRemoveAllFilters:function(e){this.removeAllFilters(e)},onFilterListShowOptions:function(e,t){var i=n(t.get("title"));this.$el.addClass("show-filter-options"),this.$el.removeClass("show-filters"),this.ui.filterOptionsHeader.text(i);
var s=new d({collection:t.get("options")});this.listenTo(s,"addFilter",this.onAddFilter),this.listenTo(s,"removeAllFilters",this.onRemoveAllFilters),this.listenTo(s,"itemview:addFilter",this.onAddFilter),this.listenTo(s,"itemview:removeFilter",this.onRemoveFilter),this.filterOptions.show(s)},onSortListRender:function(e){this.ui.sortContainer.toggleClass("hidden",!e.collection.length);var t=e.collection.length;t||this.listenToOnce(e,"before:item:added",this.onSortListItemAdded)},onSortListItemAdded:function(){this.ui.sortContainer.removeClass("hidden")
},onNewFilterClick:function(e){e.preventDefault(),this.$el.addClass("show-filters")},onHideClick:function(e){e.preventDefault(),this.$el.hasClass("show-filter-options")?(this.$el.removeClass("show-filter-options"),this.$el.addClass("show-filters")):this.$el.removeClass("show-filters")}});return h}),define("hb!templates/desktop/modals/AddToCollectionModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n        <ul class="list select-list select-collections-list dark-scrollbar">\n          ',n=i.each.call(e,e&&e.collections,{hash:{},inverse:g.noop,fn:g.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\n        </ul>\n      "
}function r(e,t){var n,s="";return s+='\n            <li class="striped-list-item select-list-item">\n              <a class="collection" data-value="',(n=i.key)?n=n.call(e,{hash:{},data:t}):(n=e&&e.key,n=typeof n===m?n.call(e,{hash:{},data:t}):n),s+=f(n)+'" href="#">',(n=i.title)?n=n.call(e,{hash:{},data:t}):(n=e&&e.title,n=typeof n===m?n.call(e,{hash:{},data:t}):n),s+=f(n)+"</a>\n            </li>\n          "}function o(e,t){var n;return n=i["if"].call(e,e&&e.loading,{hash:{},inverse:g.program(7,c,t),fn:g.program(5,l,t),data:t}),n||0===n?n:""
}function l(){return'\n        <div class="loading-container">\n          <div class="loading loading-inline"></div>\n        </div>\n      '}function c(e,t){var n,s,a="";return a+='\n        <div class="empty-message">',s={hash:{},data:t},a+=f((n=i.t||e&&e.t,n?n.call(e,"There are no collections in this library.",s):v.call(e,"t","There are no collections in this library.",s)))+"</div>\n      "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var d,u,h,p="",m="function",f=this.escapeExpression,g=this,v=i.helperMissing;
return p+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon folder-plus"></i> ',h={hash:{},data:s},p+=f((d=i.t||t&&t.t,d?d.call(t,"Select a Collection",h):v.call(t,"t","Select a Collection",h)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      ',u=i["if"].call(t,t&&t.collections,{hash:{},inverse:g.program(4,o,s),fn:g.program(1,a,s),data:s}),(u||0===u)&&(p+=u),p+='\n\n      <div class="message-container">\n        <input class="message form-control" placeholder="',h={hash:{},data:s},p+=f((d=i.t||t&&t.t,d?d.call(t,"New collection...",h):v.call(t,"t","New collection...",h)))+'">\n      </div>\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="add-btn btn btn-primary btn-loading disabled">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',h={hash:{},data:s},p+=f((d=i.t||t&&t.t,d?d.call(t,"Add",h):v.call(t,"t","Add",h)))+"</span>\n      </button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/AddToCollectionModal",["hb!templates/desktop/modals/AddToCollectionModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/library/section/FilterModel","plex/desktop/views/modals/BaseModal","plex/desktop/views/modals/SelectModal"],function(e,t,i,n,s,a,r,o){"use strict";var l=o.extend({name:"addToCollectionModal",className:"add-to-collection-modal select-modal modal modal-sm fade",template:e,ui:{addBtn:".add-btn",message:".message"},events:t.extend({"click .collection":"onCollectionClick","keyup .message":"onMessageKeyUp","click .add-btn":"onAddClick"},r.prototype.events),onlyAfterRender:["onReset"],initialize:function(e){o.prototype.initialize.apply(this,arguments),this.loading=!0,this.models=e.items,this.model=t.first(this.models),this.collectionIDs=[],this.filter=new a({filter:"collection",flterType:"string",type:"filter",title:"Collection"},{server:this.model.server,section:this.model.section,standalone:!0}),this.collections=this.filter.get("options"),this.collections.fetch().always(t.bind(this.onReset,this))
},serializeData:function(){return{loading:this.loading,collections:this.filter.get("options").toJSON()}},toggleAddButton:function(){var e=this.ui.message.val().trim();this.ui.addBtn.toggleClass("disabled",!this.collectionIDs.length&&!e)},onReset:function(){this.loading=!1,this.render()},onCollectionClick:function(e){e.preventDefault();var n=i(e.currentTarget),s=n.data("value");n.hasClass("selected")?this.collectionIDs.splice(t.indexOf(this.collectionIDs,s),1):this.collectionIDs.push(s),n.toggleClass("selected"),this.toggleAddButton()
},onMessageKeyUp:function(){this.toggleAddButton()},onAddClick:function(e){e.preventDefault();var a=this.ui.addBtn;if(!a.isDisabled()){a.addClass("active");var r=this.ui.message.val().trim(),o=[];r&&o.push(this.model.batchAdd(this.models,"collection",r)),t.each(this.collectionIDs,function(e){var t=this.collections.get(e);o.push(this.model.batchAdd(this.models,"collection",t.get("title")))},this);var l=i.when.apply(i,o);l.done(t.bind(this.hide,this)),l.fail(function(){a.removeClass("active"),s.trigger("show:alert",{type:"error",message:n("There was a problem adding to this collection.")})
})}}});return l}),define("plex/desktop/views/actionbar/SectionActionBarView",["hb!templates/desktop/actionbar/SectionActionBarView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/sidebar/SectionSideBarView","plex/desktop/views/modals/AddToCollectionModal","plex/desktop/views/modals/AddToPlaylistModal","plex/desktop/views/modals/EditMetadataModal","plex/desktop/views/modals/EditSectionModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p){"use strict";
var m=n.Layout.extend({className:"section-side-bar-container",template:e,ui:{playBtn:".play-btn",playShuffledBtn:".play-shuffled-btn",refreshBtn:".refresh-btn",analyzeBtn:".analyze-btn",markWatchedBtn:".mark-watched-btn",markUnwatchedBtn:".mark-unwatched-btn",addToCollectionBtn:".add-to-collection-btn",addToPlaylistBtn:".add-to-playlist-btn",mergeBtn:".merge-btn",syncBtn:".sync-btn",deleteBtn:".delete-btn"},regions:{sidebar:".side-bar"},triggers:{"click .options-btn":"toggleSidebar","click .play-btn":"play","click .play-shuffled-btn":"playShuffled","click .select-btn":"select","click .deselect-btn":"deselect","click .edit-btn":"edit","click .refresh-btn":"refresh","click .analyze-btn":"analyze","click .mark-watched-btn":"markWatched","click .mark-unwatched-btn":"markUnwatched","click .add-to-collection-btn":"addToCollection","click .add-to-playlist-btn":"addToPlaylist","click .merge-btn":"merge","click .sync-btn":"sync","click .delete-btn":"delete"},initialize:function(e){this.mediaActions=e.mediaActions,this.type=this.model.get("type"),this.multiuser=this.model.server.get("multiuser"),this.signedIn=l.get("user").get("signedIn"),this.listenTo(this.mediaActions,"change:selectedItems",this.onSelectedItemsChange),this.listenTo(a,{"shortcut:sidebar":this.onToggleSidebar,"shortcut:play":this.onPlay,"shortcut:refresh":this.onRefresh,"shortcut:analyze":this.onAnalyze,"shortcut:markWatched":this.onMarkWatched,"shortcut:markUnwatched":this.onMarkUnwatched,"shortcut:sync":this.onSync,"shortcut:edit":this.onEdit,"shortcut:delete":this.onDelete})
},bindingsModel:"mediaActions",bindings:{".play-btn":{modelAttribute:"showPlay",manual:!0,autohide:!0},".play-shuffled-btn":{modelAttribute:"showShuffle",manual:!0,autohide:!0},".select-btn":{modelAttribute:"selecting",manual:!0,autohide:function(e){return this.mediaActions.get("showSelect")?!e:!1}},".deselect-btn":{modelAttribute:"selecting",manual:!0,autohide:!0},".edit-btn":{modelAttribute:"selectedItems",manual:!0,autohide:function(e){return this.mediaActions.get("showEdit")?e&&e.length?!0:this.model.get("currentFilters").length?!0:void 0:!1
}},".refresh-btn":{modelAttribute:"selectedItems",manual:!0,autohide:function(e){return this.mediaActions.get("showRefresh")?e&&e.length&&!this.hasSelectedFolder:!1}},".analyze-btn":{modelAttribute:"selectedItems",manual:!0,autohide:function(e){return this.mediaActions.get("showAnalyze")?e&&e.length&&!this.hasSelectedFolder:!1}},".mark-watched-btn":{modelAttribute:"showMarkWatched",manual:!0,autohide:!0},".mark-unwatched-btn":{modelAttribute:"showMarkUnwatched",manual:!0,autohide:!0},".add-to-collection-btn":{modelAttribute:"selectedItems",manual:!0,autohide:function(e){return this.mediaActions.get("showAddToCollection")?e&&e.length&&!this.hasSelectedFolder:!1
}},".add-to-playlist-btn":{modelAttribute:"showAddToPlaylist",manual:!0,autohide:!0},".merge-btn":{modelAttribute:"selectedItems",manual:!0,autohide:function(e){if(!this.mediaActions.get("showMerge"))return!1;var t=this.model.server.supports("merge"),i=e&&e.length>1;return t&&i&&!this.hasSelectedFolder}},".sync-btn":{modelAttribute:"showSync",manual:!0,autohide:!0},".delete-btn":{modelAttribute:"selectedItems",manual:!0,autohide:function(e){return this.mediaActions.get("showDelete")?e&&e.length&&!this.hasSelectedFolder:!1
}}},onRender:function(){var e=new c({model:this.model,mediaActions:this.mediaActions});this.sidebar.append(e,this.$el),this.$el.tooltip({selector:".nav > li > a",container:"body",placement:"right"})},onClose:function(){this.mediaActions.stopListening(),this.mediaActions.deselectAll()},onSelectedItemsChange:function(e,i){if(i){this.hasSelectedFolder=t.some(i,function(e){return e.get("isFolder")});var n=s(i&&i.length?"Play selected":"Play All");this.ui.playBtn.attr("data-original-title",n)}},onToggleSidebar:function(){i(".tooltip").remove();
var e=this.sidebar.currentView;e.hidden?e.open():e.hide()},onPlay:function(){this.ui.playBtn.isDisabled()||o.execute("playMedia",{items:this.mediaActions.getActionTargets()})},onPlayShuffled:function(){this.ui.playShuffledBtn.isDisabled()||o.execute("playMedia",{items:this.mediaActions.getActionTargets(),shuffle:!0})},onSelect:function(){this.mediaActions.set("selecting",!0)},onDeselect:function(){this.mediaActions.set("selecting",!1)},onEdit:function(){if(!this.model.server.get("shared")&&!this.model.server.get("synced")){var e=this.mediaActions.get("selectedItems");
if(e.length){if(e.length>1&&!e[0].server.supports("batchEdit"))return;a.trigger("show:modal",new h({mediaActions:this.mediaActions}))}else a.trigger("show:modal",new p({server:this.model.server,model:this.model}))}},onRefresh:function(){return this.ui.refreshBtn.isDisabled()?void o.execute("updateLibrary",{section:this.model}):void o.execute("refreshMetadata",{items:this.mediaActions.getActionTargets()})},onAnalyze:function(){return this.ui.analyzeBtn.isDisabled()?void o.execute("analyzeSection",{section:this.model}):void o.execute("analyzeItems",{items:this.mediaActions.getActionTargets()})
},onMarkWatched:function(){this.ui.markWatchedBtn.isDisabled()||o.execute("markWatched",{items:this.mediaActions.getActionTargets()}).then(t.bind(function(){this.mediaActions.updateAll()},this))},onMarkUnwatched:function(){this.ui.markUnwatchedBtn.isDisabled()||o.execute("markUnwatched",{items:this.mediaActions.getActionTargets()}).then(t.bind(function(){this.mediaActions.updateAll()},this))},onAddToCollection:function(){this.ui.addToCollectionBtn.isDisabled()||a.trigger("show:modal",new d({items:this.mediaActions.getActionTargets()}))
},onAddToPlaylist:function(){this.ui.addToPlaylistBtn.isDisabled()||a.trigger("show:modal",new u({model:this.model,items:this.mediaActions.getActionTargets()}))},onMerge:function(){if(!this.ui.mergeBtn.isDisabled()){var e=this.mediaActions.getActionTargets(),i=t.first(e),n=e.slice(1);o.execute("merge",{item:i,items:n})}},onSync:function(){if(!this.ui.syncBtn.isDisabled()){var e=this.mediaActions.get("selectedItems"),t=r.getMediaTypeByString(this.model.get("type")),i={model:this.model,type:t,isNew:!0,isSection:!0,isDirectory:!0};
e.length&&!this.hasSelectedFolder&&(i.selectedItems=e),o.execute("showSyncModal",i)}},onDelete:function(){o.execute("deleteItems",{items:this.mediaActions.getActionTargets(),skipRedirect:!0})}});return m}),define("hb!templates/desktop/breadcrumbbar/SectionBreadcrumbBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n    <a class="update-btn btn-gray btn-loading btn-loading-replace btn-loading-static ',n=i["if"].call(e,e&&e.refreshing,{hash:{},inverse:h.noop,fn:h.program(2,r,t),data:t}),(n||0===n)&&(a+=n),a+='" href="#" title="',(n=i.updateTitle)?n=n.call(e,{hash:{},data:t}):(n=e&&e.updateTitle,n=typeof n===p?n.call(e,{hash:{},data:t}):n),a+=m(n)+'" data-title-alt="',(n=i.updateTitleAlt)?n=n.call(e,{hash:{},data:t}):(n=e&&e.updateTitleAlt,n=typeof n===p?n.call(e,{hash:{},data:t}):n),a+=m(n)+'" data-toggle="tooltip">\n      <span class="loading loading-bc"></span>\n      <i class="btn-label-alt glyphicon ban"></i>\n      <i class="btn-label glyphicon repeat"></i>\n    </a>\n\n    <span id="section-actions-dropdown" class="dropdown">\n      <a class="btn-gray dropdown-toggle" href="#section-actions-dropdown" data-toggle="dropdown"><i class="glyphicon cogwheel"></i> <i class="caret-icon caret-icon-sm"></i></a>\n\n      <ul class="dropdown-menu pull-right">\n        <li><a class="edit-btn btn-gray" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Edit Library",s):f.call(e,"t","Edit Library",s)))+'</a></li>\n        <li><a class="share-btn" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Share...",s):f.call(e,"t","Share...",s)))+'</a></li>\n        <li><a class="analyze-btn" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Analyze",s):f.call(e,"t","Analyze",s)))+'</a></li>\n        <li><a class="force-refresh-btn" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Force Refresh",s):f.call(e,"t","Force Refresh",s)))+'</a></li>\n        <li><a class="empty-trash-btn" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Empty Trash",s):f.call(e,"t","Empty Trash",s)))+'</a></li>\n        <li><a class="delete-btn has-danger" href="#">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Delete Library",s):f.call(e,"t","Delete Library",s)))+"</a></li>\n      </ul>\n    </span>\n  "
}function r(){return"active"}function o(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h=this,p="function",m=this.escapeExpression,f=i.helperMissing;return u+='<div class="breadcrumb-actions pull-right">\n  ',l=i.unless.call(t,t&&t.limited,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(l||0===l)&&(u+=l),u+='\n\n  <span id="section-list-dropdown" class="dropdown">\n    <a class="btn-gray dropdown-toggle" href="#section-list-dropdown" data-toggle="dropdown"><i class="glyphicon show-thumbnails"></i> <i class="caret-icon caret-icon-sm"></i></a>\n\n    <ul class="dropdown-menu pull-right">\n      <li><a class="list-btn" data-type="media-tile-list" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Posters",d):f.call(t,"t","Posters",d)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',d={hash:{},inverse:h.noop,fn:h.program(4,o,s),data:s},l=i.if_neq||t&&t.if_neq,c=l?l.call(t,t&&t.listType,"media-tile-list",d):f.call(t,"if_neq",t&&t.listType,"media-tile-list",d),(c||0===c)&&(u+=c),u+='"></i></a></li>\n      <li><a class="list-btn" data-type="media-details-list" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Details",d):f.call(t,"t","Details",d)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',d={hash:{},inverse:h.noop,fn:h.program(4,o,s),data:s},l=i.if_neq||t&&t.if_neq,c=l?l.call(t,t&&t.listType,"media-details-list",d):f.call(t,"if_neq",t&&t.listType,"media-details-list",d),(c||0===c)&&(u+=c),u+='"></i></a></li>\n      <li><a class="list-btn" data-type="media-list" href="#">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"List",d):f.call(t,"t","List",d)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',d={hash:{},inverse:h.noop,fn:h.program(4,o,s),data:s},l=i.if_neq||t&&t.if_neq,c=l?l.call(t,t&&t.listType,"media-list",d):f.call(t,"if_neq",t&&t.listType,"media-list",d),(c||0===c)&&(u+=c),u+='"></i></a></li>\n    </ul>\n  </span>\n</div>\n\n<span class="breadcrumb-dropdown"></span>\n<span class="breadcrumb-subset-dropdown"></span>\n<span class="breadcrumb-type-dropdown"></span>\n\n<span class="breadcrumb-items-dropdown">\n  <span class="items-badge badge badge-lg">',(c=i.totalSize)?c=c.call(t,{hash:{},data:s}):(c=t&&t.totalSize,c=typeof c===p?c.call(t,{hash:{},data:s}):c),u+=m(c)+"</span>\n</span>\n"
})}),define("hb!templates/desktop/dropdowns/SectionDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <a class="dropdown-toggle" href="#section-dropdown" data-toggle="dropdown">'+p((n=e&&e.currentSection,n=null==n||n===!1?n:n.title,typeof n===f?n.apply(e):n))+' <i class="caret-icon"></i></a>\n\n  <ul class="dropdown-menu">\n    ',s=i["if"].call(e,e&&e.showPlaylists,{hash:{},inverse:m.noop,fn:m.programWithDepth(2,r,t,e),data:t}),(s||0===s)&&(a+=s),a+="\n    ",s=i.each.call(e,e&&e.sections,{hash:{},inverse:m.noop,fn:m.programWithDepth(5,l,t,e),data:t}),(s||0===s)&&(a+=s),a+="\n  </ul>\n"
}function r(e,t,n){var s,a,r,l="";return l+='\n    <li><a href="#!/server/',r={hash:{},data:t},l+=p((s=i.encodeUrl||n&&n.encodeUrl,s?s.call(e,n&&n.serverID,r):h.call(e,"encodeUrl",n&&n.serverID,r)))+'/playlists"><span class="dropdown-truncated-label">',r={hash:{},data:t},l+=p((s=i.t||n&&n.t,s?s.call(e,"Playlists",r):h.call(e,"t","Playlists",r)))+"</span>",a=i.unless.call(e,(s=e&&e.currentSection,null==s||s===!1?s:s.key),{hash:{},inverse:m.noop,fn:m.program(3,o,t),data:t}),(a||0===a)&&(l+=a),l+="</a></li>\n    "
}function o(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}function l(e,t,n){var s,a,r,l="";return l+='\n      <li><a href="#!/server/',r={hash:{},data:t},l+=p((s=i.encodeUrl||n&&n.encodeUrl,s?s.call(e,n&&n.serverID,r):h.call(e,"encodeUrl",n&&n.serverID,r)))+"/section/",r={hash:{},data:t},l+=p((s=i.encodeUrl||e&&e.encodeUrl,s?s.call(e,e&&e.key,r):h.call(e,"encodeUrl",e&&e.key,r)))+'"><span class="dropdown-truncated-label">',(a=i.title)?a=a.call(e,{hash:{},data:t}):(a=e&&e.title,a=typeof a===f?a.call(e,{hash:{},data:t}):a),l+=p(a)+"</span>",r={hash:{},inverse:m.noop,fn:m.program(3,o,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,(s=n&&n.currentSection,null==s||s===!1?s:s.key),e&&e.key,r):h.call(e,"if_eq",(s=n&&n.currentSection,null==s||s===!1?s:s.key),e&&e.key,r),(a||0===a)&&(l+=a),l+="</a></li>\n    "
}function c(e){var t,i="";return i+="\n  "+p((t=e&&e.currentSection,t=null==t||t===!1?t:t.title,typeof t===f?t.apply(e):t))+"\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var d,u="",h=i.helperMissing,p=this.escapeExpression,m=this,f="function";return d=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:m.program(7,c,s),fn:m.program(1,a,s),data:s}),(d||0===d)&&(u+=d),u+="\n"})}),define("plex/desktop/views/dropdowns/SectionDropdown",["hb!templates/desktop/dropdowns/SectionDropdown.tpl","marionette"],function(e,t){"use strict";
var i=t.ItemView.extend({id:"section-dropdown",tagName:"span",className:"dropdown",template:e,modelEvents:{"change:title":"render"},serializeData:function(){var e=this.model.server.supports("playlists");return{showDropdown:this.collection.length>1||e,showPlaylists:e,sections:this.collection.toJSON(),serverID:this.model.server.id,currentSection:this.model.toJSON()}}});return i}),define("hb!templates/desktop/dropdowns/SectionSubsetDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,o="";
return o+='\n  <a class="btn-gray dropdown-toggle" href="#section-subset-dropdown" data-toggle="dropdown">',a={hash:{},data:t},o+=p((n=i.t||e&&e.t,n?n.call(e,(n=e&&e.currentSubset,null==n||n===!1?n:n.title),a):h.call(e,"t",(n=e&&e.currentSubset,null==n||n===!1?n:n.title),a)))+' <i class="caret-icon"></i></a>\n\n  <ul class="dropdown-menu">\n    ',s=i.each.call(e,e&&e.subsets,{hash:{},inverse:m.noop,fn:m.programWithDepth(2,r,t,e),data:t}),(s||0===s)&&(o+=s),o+="\n  </ul>\n"}function r(e,t,n){var s,a="";
return a+="\n      ",s=i["if"].call(e,e&&e.primary,{hash:{},inverse:m.noop,fn:m.programWithDepth(3,o,t,n),data:t}),(s||0===s)&&(a+=s),a+="\n    "}function o(e,t,n){var s,a,r,o="";return o+='\n        <li><a href="#!/server/',r={hash:{},data:t},o+=p((s=i.encodeUrl||n&&n.encodeUrl,s?s.call(e,n&&n.serverID,r):h.call(e,"encodeUrl",n&&n.serverID,r)))+"/section/",r={hash:{},data:t},o+=p((s=i.encodeUrl||n&&n.encodeUrl,s?s.call(e,n&&n.sectionID,r):h.call(e,"encodeUrl",n&&n.sectionID,r)))+"/",r={hash:{},data:t},o+=p((s=i.encodeUrl||e&&e.encodeUrl,s?s.call(e,e&&e.key,r):h.call(e,"encodeUrl",e&&e.key,r)))+'">',r={hash:{},data:t},o+=p((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):h.call(e,"t",e&&e.title,r)))+" ",r={hash:{},inverse:m.noop,fn:m.program(4,l,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,(s=n&&n.currentSubset,null==s||s===!1?s:s.key),e&&e.key,r):h.call(e,"if_eq",(s=n&&n.currentSubset,null==s||s===!1?s:s.key),e&&e.key,r),(a||0===a)&&(o+=a),o+="</a></li>\n      "
}function l(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}function c(e,t){var n,s,a="";return a+='\n  <span class="dropdown-placeholder">',s={hash:{},data:t},a+=p((n=i.t||e&&e.t,n?n.call(e,(n=e&&e.currentSubset,null==n||n===!1?n:n.title),s):h.call(e,"t",(n=e&&e.currentSubset,null==n||n===!1?n:n.title),s)))+"</span>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var d,u="",h=i.helperMissing,p=this.escapeExpression,m=this;return d=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:m.program(6,c,s),fn:m.program(1,a,s),data:s}),(d||0===d)&&(u+=d),u+="\n"
})}),define("plex/desktop/views/dropdowns/SectionSubsetDropdown",["hb!templates/desktop/dropdowns/SectionSubsetDropdown.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({id:"section-subset-dropdown",tagName:"span",className:"dropdown",template:e,collectionEvents:{reset:"render"},initialize:function(){this.collection.populate({reset:!0,scope:"page"})},serializeData:function(){var e=this.collection.get(this.model.id)||this.model;return{showDropdown:this.collection.length>1,subsets:this.collection.toJSON(),currentSubset:e.toJSON(),serverID:this.model.server.id,sectionID:this.model.section.id}
}});return i}),define("hb!templates/desktop/dropdowns/SectionTypeDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<a class="btn-gray dropdown-toggle" href="#section-type-dropdown" data-toggle="dropdown">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,(a=t&&t.currentType,null==a||a===!1?a:a.plural),r):l.call(t,"t",(a=t&&t.currentType,null==a||a===!1?a:a.plural),r)))+' <i class="caret-icon"></i></a>\n\n<ul class="dropdown-menu"></ul>\n'
})}),define("hb!templates/desktop/dropdowns/SectionTypeDropdownItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h=this;return c+='<a href="#">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,t&&t.plural,l):d.call(t,"t",t&&t.plural,l)))+" ",o=i["if"].call(t,t&&t.selected,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+="</a>\n"
})}),define("plex/desktop/views/dropdowns/SectionTypeDropdownItem",["hb!templates/desktop/dropdowns/SectionTypeDropdownItem.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({tagName:"li",template:e,events:{"click a":"onClick"},onClick:function(e){e.preventDefault();var t=this.model.section,i=t.get("currentType");i.set("selected",!1),this.model.set("selected",!0),this.model.section.set("currentType",this.model)}});return i}),define("plex/desktop/views/dropdowns/SectionTypeDropdown",["hb!templates/desktop/dropdowns/SectionTypeDropdown.tpl","marionette","plex/desktop/views/dropdowns/SectionTypeDropdownItem"],function(e,t,i){"use strict";
var n=t.CompositeView.extend({id:"section-type-dropdown",tagName:"span",className:"dropdown",template:e,itemView:i,itemViewContainer:".dropdown-menu",modelEvents:{"change:currentType":"render","change:currentSubset":"render"},serializeData:function(){return{currentType:this.model.get("currentType").toJSON()}},onRender:function(){var e=this.collection.length<2,t=this.model.get("allowAdvancedFilters"),i="all"!==this.model.get("currentSubset").id;this.$el.toggleClass("hidden",e||!t||i)}});return n}),define("plex/desktop/views/breadcrumbbar/SectionBreadcrumbBarView",["hb!templates/desktop/breadcrumbbar/SectionBreadcrumbBarView.tpl","jquery","underscore","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/desktop/views/dropdowns/SectionDropdown","plex/desktop/views/dropdowns/SectionSubsetDropdown","plex/desktop/views/dropdowns/SectionTypeDropdown","plex/desktop/views/modals/EditSectionModal","plex/desktop/views/modals/user/EditFriendModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p=n.Layout.extend({className:"breadcrumb-bar",template:e,ui:{listSelectedIcons:"#section-list-dropdown .dropdown-selected-icon",itemsBadge:".items-badge",updateBtn:".update-btn"},regions:{sectionDropdown:".breadcrumb-dropdown",subsetDropdown:".breadcrumb-subset-dropdown",typeDropdown:".breadcrumb-type-dropdown"},events:{"click .list-btn":"onListClick","click .edit-btn":"onEditClick","click .share-btn":"onShareClick","click .update-btn":"onUpdateClick","click .analyze-btn":"onAnalyzeClick","click .force-refresh-btn":"onForceRefreshClick","click .empty-trash-btn":"onEmptyTrashClick","click .delete-btn":"onDeleteClick"},onlyAfterRender:["onTotalSizeChange"],initialize:function(){var e=this.model.get("items");
this.refreshing=this.model.get("refreshing"),this.updateTitle=s("Update Library"),this.updateTitleAlt=s("Cancel Update"),this.shared=this.model.server.get("shared"),this.synced=this.model.server.get("synced"),this.limited=!(!this.shared&&!this.synced),this.listenTo(e,"change:totalSize",this.onTotalSizeChange),this.listenTo(this.model,"change:refreshing",this.onRefreshingChange),this.listenTo(this.model,"change:currentType",this.updateListViewDropdown),this.listenTo(a,"shortcut:delete",this.onDelete)
},serializeData:function(){return{limited:this.limited,totalSize:this.model.get("items").totalSize,listType:r.getInstance().getSectionListType(this.model),refreshing:this.refreshing,updateTitle:this.refreshing?this.updateTitleAlt:this.updateTitle,updateTitleAlt:this.refreshing?this.updateTitle:this.updateTitleAlt}},updateListViewDropdown:function(e){i.isString(e)||(e=r.getInstance().getSectionListType(this.model)),this.ui.listSelectedIcons.each(function(n,s){var a=t(s),r=a.closest(".list-btn").data("type");
a.toggleClass("hidden",!i.isEqual(e,r))})},onRender:function(){this.$el.tooltip({selector:".breadcrumb-actions > a",container:"body",placement:"bottom"}),this.sectionDropdown.show(new l({model:this.model,collection:this.model.server.get("sections")})),this.subsetDropdown.show(new c({model:this.model.get("currentSubset"),collection:this.model.get("subsets")})),this.typeDropdown.show(new d({model:this.model,collection:this.model.get("types")}))},onTotalSizeChange:function(e,t){var i=null==t?"":t;this.ui.itemsBadge.text(i)
},onEditClick:function(e){e.preventDefault(),this.limited||a.trigger("show:modal",new u({server:this.model.server,model:this.model}))},onUpdateClick:function(e){e.preventDefault(),this.limited||o.execute("updateLibrary",{section:this.model,cancel:this.model.get("refreshing")})},onShareClick:function(e){e.preventDefault(),this.limited||a.trigger("show:modal",new h({defaultPaneType:"ownedServer",defaultPaneID:this.model.server.id}))},onAnalyzeClick:function(e){e.preventDefault(),this.limited||o.execute("analyzeSection",{section:this.model})
},onForceRefreshClick:function(e){e.preventDefault(),this.limited||o.execute("updateLibrary",{section:this.model,params:{force:!0}})},onEmptyTrashClick:function(e){e.preventDefault(),this.limited||o.execute("emptyTrash",{section:this.model})},onDeleteClick:function(e){e.preventDefault(),this.onDelete()},onListClick:function(e){e.preventDefault();var i=t(e.currentTarget),n=i.data("type"),s=this.model.get("currentType");r.getInstance().saveListType(s,n),this.updateListViewDropdown(n)},onDelete:function(){if(!this.limited){var e=o.execute("deleteSection",{section:this.model});
e.done(function(){a.trigger("navigate","dashboard")})}},onRefreshingChange:function(){var e=this.ui.updateBtn,n=this.ui.updateBtn.attr("data-original-title");if(this.ui.updateBtn.toggleClass("active",this.model.get("refreshing")),n){var s=t(".tooltip > .tooltip-inner").html();i.contains([this.updateTitle,this.updateTitleAlt],s)&&t(".tooltip > .tooltip-inner").html(e.attr("data-title-alt")),e.attr("data-original-title",e.attr("data-title-alt")),e.attr("data-title-alt",n)}}});return p}),define("hb!templates/desktop/alphabar/AlphaBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("hb!templates/desktop/lists/library/section/AlphaListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<a class="btn-gray" href="#">',(a=i.title)?a=a.call(t,{hash:{},data:s}):(a=t&&t.title,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"</a>\n"})}),define("plex/desktop/views/lists/library/section/AlphaListItem",["hb!templates/desktop/lists/library/section/AlphaListItem.tpl","marionette"],function(e,t){"use strict";
var i=t.ItemView.extend({tagName:"li",className:"alpha-bar-list-item",template:e,events:{"click a":"onClick"},onClick:function(e){e.preventDefault(),this.model.section.set("currentFirstCharacter",this.model)}});return i}),define("plex/desktop/views/lists/library/section/AlphaList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/section/AlphaListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list alpha-bar-list",itemView:t});return i}),define("plex/desktop/views/alphabar/AlphaBarView",["hb!templates/desktop/alphabar/AlphaBarView.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/utils/constants/timelineEvents","plex/desktop/views/lists/library/section/AlphaList"],function(e,t,i,n,s,a){"use strict";
var r=i.Layout.extend({className:"action-bar alpha-bar",template:e,regions:{list:".alpha-bar-list"},modelEvents:{"change:currentFilters":"onListRefresh","socket:timeline":"onTimeline"},collectionEvents:{reset:"onReset"},initialize:function(){this.listenTo(n,"resize",this.onResize),this.collection.clear(),this.updateCollection(),this.debouncedUpdateCollection=t.debounce(this.updateCollection,2e3)},measure:function(){this.updateContainerHeight(),this.updateLineHeight()},updateContainerHeight:function(){this.containerHeight=this.$el.height()
},updateLineHeight:function(){var e=this.collection.length;if(e){var t=this.containerHeight/e;this.$el.css("line-height",t+"px")}},updateCollection:function(){this.collection.fetch({reset:!0,scope:"page"})},onRender:function(){this.list.append(new a({collection:this.collection}),this.$el),t.defer(t.bind(this.measure,this))},onListRefresh:function(){this.list.currentView.$el.addClass("hidden"),this.updateCollection()},onReset:function(e){return e.length<10?(this.$el.addClass("hidden"),void n.trigger("hide:bar","alphabar",{preserve:!0})):(this.containerHeight&&this.updateLineHeight(),this.$el.removeClass("hidden"),this.list.currentView.$el.removeClass("hidden"),void n.trigger("show:bar","alphabar"))
},onResize:function(){this.updateContainerHeight(),this.updateLineHeight()},onTimeline:function(e){(e.state===s.CREATED||e.state===s.DELETED)&&this.debouncedUpdateCollection()}});return r}),define("hb!templates/desktop/section/SectionListView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=u((n=i.t||e&&e.t,n?n.call(e,"Click {1}here{2} to add content to the library.",'<a href="#" class="add-to-library-link">',"</a>",s):d.call(e,"t","Click {1}here{2} to add content to the library.",'<a href="#" class="add-to-library-link">',"</a>",s)))+"\n    "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h=this;return c+='<div class="section-loading-container hidden">\n  <div class="loading loading-inline"></div>\n</div>\n\n<h4 class="empty-message text-muted text-center">\n  <span class="empty-default">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"The library has no content yet.",l):d.call(t,"t","The library has no content yet.",l)))+"\n\n    ",o=i["if"].call(t,t&&t.canEdit,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n  </span>\n  <span class="empty-refreshing">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"The library is still being refreshed. Hang on while we look for your content.",l):d.call(t,"t","The library is still being refreshed. Hang on while we look for your content.",l)))+'\n  </span>\n  <span class="empty-filter">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"There is no content matching your active filter.",l):d.call(t,"t","There is no content matching your active filter.",l)))+'\n  </span>\n  <span class="empty-folder">\n    ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"There is no content in the selected folder.",l):d.call(t,"t","There is no content in the selected folder.",l)))+"\n  </span>\n</h4>\n"
})}),define("plex/base/utils/throttledTaskQueue",["underscore","plex/base/adapters/performanceAdapter"],function(e,t){"use strict";function i(t,a){o=setTimeout(function(){o=null,n(),e.times(a,s),r.length&&i(t,a)},t)}function n(){var t=(new Date).getTime();r=e.filter(r,function(e){return e.expire>t})}function s(){for(var e=0;e<r.length;e++){var t=r[e],i=!1;try{i=t.fn.apply(t.thisArg)}catch(n){console.error(n),i=!0}if(i){r.splice(e,1);break}}}var a={defaultWait:100,defaultBatchSize:1,timeout:3e4,enqueue:function(e,n,s,a){var l={fn:e,thisArg:n,cancelToken:s,expire:(new Date).getTime()+this.timeout};
if(a?r.unshift(l):r.push(l),!o){var c=t.prop("taskThrottle")||{},d=c.wait||this.defaultWait,u=c.batchSize||this.defaultBatchSize;i(d,u)}},cancel:function(t){r=e.reject(r,function(e){return e.cancelToken===t})}},r=[],o=null;return a}),define("plex/desktop/mixins/multiselectListMixin",["underscore","marionette","plex/base/utils/rangeUtil"],function(e,t,i){"use strict";var n={selectable:!0,events:{mousedown:"onMouseDown",mouseup:"onMouseUp",mouseleave:"onMouseUp"},itemEvents:{select:"onItemSelect",autoselect:"onItemAutoselect"},itemViewOptions:function(){return{mediaActions:this.parentMediaActions||this.mediaActions}
},initialize:function(e){e.mediaActions&&(this.mediaActions=e.mediaActions,this.listenTo(this.mediaActions,{"change:selectedItems":this.onMediaActionsSelectedItemsChange,"change:selecting":this.onMediaActionsSelectingChange}),this.shiftRange={start:-1,end:-1})},isViewSelected:function(t){var i=this.mediaActions.get("selectedItems");if(0===i.length)return!1;var n=t.model,s=e.indexOf(i,n);if(-1!==s)return!0;var a=n.get("children"),r=a&&a.length&&a.every(function(e){return e.selected});return r?!0:!1
},singleSelect:function(e){this.shiftRange.end=-1;var t=e.model;this.isViewSelected(e)?(this.shiftRange.start=-1,this.deselectItem(t),e.deselect()):(this.shiftRange.start=this.collection.indexOf(t),this.previousCollectionOffset=this.collection.populatedRange?this.collection.populatedRange.start:0,this.selectItem(t),e.select())},multiSelect:function(t){if(this.getViewForModel){var n=this.collection.indexOf(t.model),s=this.collection.populatedRange.start,a=this.previousCollectionOffset-s,r=[],o=[];
if(this.previousCollectionOffset=s,this.shiftRange.start<0)this.shiftRange.start=n,r.push(t.model),t.select();else if(this.shiftRange.end<0)this.shiftRange.start+=a,this.shiftRange.end=n,i.each(this.shiftRange,function(e){var t=this.collection.at(e);if(t){r.push(t);var i=this.getViewForModel(t);i&&i.select()}},this);else{i.each(this.shiftRange,function(e){var t=this.collection.at(e);t&&o.push(t)},this),this.shiftRange.start+=a,this.shiftRange.end=n,i.each(this.shiftRange,function(e){var t=this.collection.at(e);
if(t){r.push(t);var i=this.getViewForModel(t);i&&i.select()}},this);var l=[o].concat(r);o=e.without.apply(e,l),e.each(o,function(e){var t=this.getViewForModel(e);t&&t.deselect()},this)}this.mediaActions.selectItems(r,{superset:this.collection}),this.mediaActions.deselectItems(o,{superset:this.collection})}},selectItem:function(e){this.mediaActions.selectItem(e,{superset:this.collection})},deselectItem:function(e){this.mediaActions.deselectItem(e,{superset:this.collection})},forwardItemViewEvents:function(i){this.stopListening(i,"all"),this.listenTo(i,"all",function(n){var s=Array.prototype.slice.call(arguments);
s[0]="itemview:"+n,s.splice(1,0,i);var a=t.normalizeMethods.call(this,this.itemEvents);"undefined"!=typeof a&&e.isFunction(a[n])&&a[n].apply(this,s),t.triggerMethod.apply(this,s)},this)},onMediaActionsSelectedItemsChange:function(e,t){this.getViewForModel&&(t&&t.length||(this.shiftRange.start=-1,this.shiftRange.end=-1,this.collection.each(function(e){var t=this.getViewForModel(e);t&&t.deselect&&t.deselect()},this)))},onMediaActionsSelectingChange:function(e){this.$el.toggleClass("hide-actions",e)
},onClose:function(){this.mediaActions&&this.mediaActions.deselectAll()},onMouseDown:function(){this.isMouseDown=!0},onMouseUp:function(){this.isMouseDown=!1},onItemSelect:function(e,t,i){this.selectable&&(i||(i={}),i.multiSelect?this.multiSelect(t):this.singleSelect(t))},onItemAutoselect:function(){this.isMouseDown&&this.onItemSelect.apply(this,arguments)},onItemRemoved:function(e){e.model.selected&&(this.deselectItem(e.model),e.deselect())}};return n}),define("plex/base/utils/ViewPool",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";
var i=t.extend({initialize:function(){this.pool=[]},lockOrCreate:function(t,i,n){e.each(t,function(s){if(!this.find(s)){var a=e.find(this.pool,function(i){return!e.contains(t,i.id)},this);a||(a={},this.pool.push(a),a.view=i.call(n,a)),a.id=s}},this)},each:function(t,i){e.each(this.pool,t,i)},filter:function(t,i){this.pool=e.filter(this.pool,t,i)},find:function(t){return e.findWhere(this.pool,{id:t})},findByModel:function(t){return e.find(this.pool,function(e){return e.view.model===t})},close:function(){e.each(this.pool,function(e){e.view.close()
}),this.pool=[]}});return i}),define("plex/base/views/cells/CellContainerView",["underscore","marionette","plex/base/utils/throttledTaskQueue","plex/base/utils/ViewPool"],function(e,t,i,n){"use strict";var s=t.View.extend({initialize:function(){t.View.prototype.initialize.apply(this,arguments),this.pool=new n(this)},render:function(){this.isRendered||this.triggerMethod("before:render",this),this.isRendered=!0;var e=this.getLockIndexes();this.pool.lockOrCreate(e,this.createCellView,this),this.scheduleFilling(e),this.prepareCells(e),this.pool.each(this.moveCell,this),this.moveElement(),this.clearVisibleReusedCells()
},createCellView:function(i){var n=t.getOption(this,"itemView"),s=t.getOption(this,"itemViewOptions");e.isFunction(s)&&(s=s.call(this,i));var a=new n(s);return a.render(),this.$el.append(a.$el),a},scheduleFilling:function(t){i.cancel(this.cid),e.each(t,function(e){var t=this.pool.find(e);t.filledWithIndex!==t.id&&i.enqueue(function(){var e=this.fillCell(t);return e&&(t.filledWithIndex=t.id),e},this,this.cid)},this)},prepareCells:function(){this.pool.each(this.prepareCell,this)},clearVisibleReusedCells:function(){var e=this.getVisibleBounds();
this.pool.each(function(t){var i=t.filledWithIndex===t.id,n=-1===t.filledWithIndex,s=t.id>=e.from&&t.id<=e.to;!s||i||n||(this.clearCell(t),t.filledWithIndex=-1)},this)},_getImmediateChildren:function(){return e.pluck(this.pool.pool,"view")},onClose:function(){i.cancel(this.cid),this.pool.close()}});return s}),window.Modernizr=function(e,t,i){function n(e){v.cssText=e}function s(e,t){return typeof e===t}function a(e,t){return!!~(""+e).indexOf(t)}function r(e,t){for(var n in e){var s=e[n];if(!a(s,"-")&&v[s]!==i)return"pfx"==t?s:!0
}return!1}function o(e,t,n){for(var a in e){var r=t[e[a]];if(r!==i)return n===!1?e[a]:s(r,"function")?r.bind(n||t):r}return!1}function l(e,t,i){var n=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+w.join(n+" ")+n).split(" ");return s(t,"string")||s(t,"undefined")?r(a,t):(a=(e+" "+x.join(n+" ")+n).split(" "),o(a,t,i))}var c,d,u,h="2.8.3",p={},m=t.documentElement,f="modernizr",g=t.createElement(f),v=g.style,y=({}.toString," -webkit- -moz- -o- -ms- ".split(" ")),b="Webkit Moz O ms",w=b.split(" "),x=b.toLowerCase().split(" "),k={},S=[],C=S.slice,P=function(e,i,n,s){var a,r,o,l,c=t.createElement("div"),d=t.body,u=d||t.createElement("body");
if(parseInt(n,10))for(;n--;)o=t.createElement("div"),o.id=s?s[n]:f+(n+1),c.appendChild(o);return a=["&#173;",'<style id="s',f,'">',e,"</style>"].join(""),c.id=f,(d?c:u).innerHTML+=a,u.appendChild(c),d||(u.style.background="",u.style.overflow="hidden",l=m.style.overflow,m.style.overflow="hidden",m.appendChild(u)),r=i(c,e),d?c.parentNode.removeChild(c):(u.parentNode.removeChild(u),m.style.overflow=l),!!r},A={}.hasOwnProperty;u=s(A,"undefined")||s(A.call,"undefined")?function(e,t){return t in e&&s(e.constructor.prototype[t],"undefined")
}:function(e,t){return A.call(e,t)},Function.prototype.bind||(Function.prototype.bind=function(e){var t=this;if("function"!=typeof t)throw new TypeError;var i=C.call(arguments,1),n=function(){if(this instanceof n){var s=function(){};s.prototype=t.prototype;var a=new s,r=t.apply(a,i.concat(C.call(arguments)));return Object(r)===r?r:a}return t.apply(e,i.concat(C.call(arguments)))};return n}),k.csstransforms3d=function(){var e=!!l("perspective");return e&&"webkitPerspective"in m.style&&P("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(t){e=9===t.offsetLeft&&3===t.offsetHeight
}),e};for(var _ in k)u(k,_)&&(d=_.toLowerCase(),p[d]=k[_](),S.push((p[d]?"":"no-")+d));return p.addTest=function(e,t){if("object"==typeof e)for(var n in e)u(e,n)&&p.addTest(n,e[n]);else{if(e=e.toLowerCase(),p[e]!==i)return p;t="function"==typeof t?t():t,"undefined"!=typeof enableClasses&&enableClasses&&(m.className+=" "+(t?"":"no-")+e),p[e]=t}return p},n(""),g=c=null,p._version=h,p._prefixes=y,p._domPrefixes=x,p._cssomPrefixes=w,p.testProp=function(e){return r([e])},p.testAllProps=l,p.testStyles=P,p
}(this,this.document),define("modernizr",function(e){return function(){var t;return t||e.Modernizr}}(this)),define("jquery.translate",["jquery","modernizr"],function(e,t){"use strict";e.fn.translate=t.csstransforms3d?function(e,t){this.css("transform","translate3d("+e+"px, "+t+"px, 0)")}:function(e,t){this.css("transform","translate("+e+"px, "+t+"px)")}}),define("plex/desktop/views/lists/VirtualList",["underscore","backbone","marionette","plex/base/utils/dispatcher","plex/base/utils/rangeUtil","plex/base/utils/throttledTaskQueue","plex/desktop/mixins/multiselectListMixin","plex/base/views/cells/CellContainerView","jquery.translate"],function(e,t,i,n,s,a,r,o){"use strict";
var l=o.extend({mixins:r,paginated:!0,scrollPosition:0,scrollDirection:"down",mergeDelay:5e3,viewsByModel:{},initialize:function(t){o.prototype.initialize.apply(this,arguments),e.bindAll(this,"onResize","onScroll"),this.mediaActions=t.mediaActions,r.initialize.apply(this,arguments),null!=t.paginated&&(this.paginated=t.paginated),this.channelName=t.channelName||"content",this.sizeProperty=this.paginated?"totalSize":"length",this.initializingScrollPosition=!0,this.merge=e.throttle(e.bind(this.merge,this),this.mergeDelay),this.collection.scrollPosition&&(this.restoringScrollPosition=!0,this.scrollPosition=this.collection.scrollPosition),this.listenTo(this.collection,"reset",this.onCollectionReset),this.listenTo(this.collection,"add",this.onCollectionAdd),this.listenTo(this.collection,"remove",this.onCollectionRemove),n.trigger(this.channelName+".subscribe:resize",this.onResize),n.trigger(this.channelName+".subscribe:scroll",this.onScroll),n.trigger("start:scrollListener")
},getLockIndexes:function(){var t,i=this.getVisibleBounds(),n=this.getLockBounds(),s=this.getIndexBounds(),a=e.range(i.from,i.to+1),r=e.range(i.to+1,n.to+1),o=e.range(i.from-1,n.from-1,-1);return"down"===this.scrollDirection?(o.reverse(),t=a.concat(r,o)):(a.reverse(),o.reverse(),t=a.concat(o,r)),e.filter(t,function(e){return e>=s.from&&e<=s.to},this)},getVisibleBounds:function(){if(this.itemHeight&&this.itemsPerRow&&this.itemsPerPage){var e=Math.floor(this.scrollPosition/this.itemHeight)*this.itemsPerRow;
return e>this.getTotalSize()&&(this.scrollPosition=0,e=0),{from:e,to:e+this.itemsPerPage-1+2*this.itemsPerRow}}return{from:0,to:0}},getLockBounds:function(){var e=this.getPageSize(),t=this.getVisibleBounds();return{from:t.from-e,to:t.to+e}},prepareCells:function(t){var i=this.getIndexBounds();this.pool.filter(function(e){return i.from<=e.id&&i.to>=e.id?!0:(e.view.close(),e.view.$el.remove(),!1)},this);var n=e.reject(t,this.getModelForId,this);if(n.length){if(this.collection.populatePromise&&"pending"===this.collection.populatePromise.state())return void this.collection.populatePromise.done(e.bind(this.prepareCells,this,t));
var a=s.roundByPage({start:e.min(n),last:e.max(n)},2*this.getPageSize());a.reloadThreshold=a.size;var r=this.collection.populateRange(a);this.trigger("change:loading",!0,{prepend:"up"===this.scrollDirection}),r.always(e.bind(function(){this.trigger("change:loading",!1)},this))}},moveCell:function(e){if(e.updatedCSS||(e.view.$el.css({position:"absolute"}),e.updatedCSS=!0),this.itemWidth&&this.itemsPerRow){var t=e.id%this.itemsPerRow,i=Math.floor(e.id/this.itemsPerRow);e.view.$el.translate(t*this.itemWidth,i*this.itemHeight),e.movedToIndex=e.id
}},moveElement:function(){},createCellView:function(n){var s=i.getOption(this,"itemViewOptions");e.isFunction(s)&&(s=s.call(this,n)),s=e.clone(s),s.model=this.getModelForId(n.id),s.mediaActions=this.mediaActions,n.el&&(s.el=n.el);var a=i.getOption(this,"itemView");a._ensureElementExtension||(a._ensureElementExtension=a.extend({_ensureElement:function(){var i=this.el?e.result(this,"el"):t.$("<"+e.result(this,"tagName")+">");this.setElement(i,!1);var n=e.extend({},e.result(this,"attributes"));this.id&&(n.id=e.result(this,"id")),this.className&&(n["class"]=e.result(this,"className")),this.$el.attr(n)
}}));var r=new a._ensureElementExtension(s);return n.el||(this.$el.append(r.$el),n.el=r.el),this.forwardItemViewEvents(r),r.remove=function(){return this.stopListening(),this.$el.unbind(),this.$el.empty(),this},r},getPageSize:function(){return this.itemsPerPage||1},clearAllReusedCells:function(){this.pool.each(function(e){var t=e.filledWithIndex===e.id,i=-1===e.filledWithIndex;t||i||(this.clearCell(e),e.filledWithIndex=-1)},this)},getTotalSize:function(){return this.collection[this.sizeProperty]||0
},fillCell:function(e){var t=this.getModelForId(e.id);return t&&t===e.view.model&&!e.view.isClosed?!0:(this.clearCell(e),t?(e.view=this.createCellView(e),e.view.render(),this.indexViewByModel(e.view),!0):!1)},clearCell:function(e){var t=e.view;t.model&&delete this.viewsByModel[t.model.cid],t.isClosed||t.close()},getIndexBounds:function(){return{from:0,to:this.getTotalSize()-1}},getModelForId:function(e){return this.collection.at(e-this.collection.populatedRange.start)},getViewForModel:function(e){return this.viewsByModel[e.cid]
},indexViewByModel:function(e){this.viewsByModel[e.model.cid]=e},render:function(){this.updateHeight(),this.restoringScrollPosition||(o.prototype.render.apply(this,arguments),this.clearAllReusedCells())},updateHeight:function(){this.recalculateHeight&&(this.recalculateHeight=!1,this.listHeight=Math.ceil(this.getIndexBounds().to/this.itemsPerRow)*this.itemHeight-this.itemMarginBottom,this.$el.css("height",this.listHeight),this.initScrolling())},itemViewOptions:function(){var t,i,n=this.collection.section;
if(n){var s=n.get("currentType"),a=this.collection.getSort();if(t=s&&s.get("typeString"),a){var r=a.split(":");r.length&&(i=e.first(r))}}else t="clip";return{type:t,sort:i}},measureItem:function(){var t=this.createCellView({id:this.collection.populatedRange.start});t.model||(this.remeasureItem=!0),t.render(),t.$el.css("visibility","hidden");var i=t.$el.appendTo(this.$el);e.defer(e.bind(function(){this.itemWidth=i.outerWidth(!0),this.itemHeight=i.outerHeight(!0),this.itemMarginRight=parseInt(i.css("margin-right"),10),this.itemMarginBottom=parseInt(i.css("margin-bottom"),10),t.close(),t.$el.remove(),this.measureContainer(),this.render()
},this))},measureContainer:function(){var e=parseInt(this.$el.css("margin-top"),10),t=parseInt(this.$el.css("margin-bottom"),10);this.containerWidth=this.$el.width(),this.containerHeight=this.containerSize.height-e-t,this.itemsPerRow=Math.floor(this.containerWidth/this.itemWidth),this.itemsPerColumn=Math.floor((this.containerHeight+this.itemMarginBottom)/this.itemHeight),this.itemsPerPage=this.itemsPerRow*this.itemsPerColumn,this.itemsPadding=this.itemsPerRow*Math.max(this.itemsPerColumn,2),this.itemsPerPageWithPadding=2*this.itemsPadding+this.itemsPerPage,this.itemHeight&&(this.recalculateHeight=!0)
},scrollToIndex:function(e){var t=Math.floor(e/this.itemsPerRow),i=t*this.itemHeight;this.restrictScrollDirection=!0,n.trigger("update:scrollPosition",i)},merge:function(){if(!this.isClosed){var t=this.collection.populatedRange,i=t.start,n=t.end>this.itemsPerPageWithPadding?t.end:this.itemsPerPageWithPadding;if(n){if(i>0)return this.scrollDirection="up",void this.collection.populateRange({start:0,size:i});this.collection.pageStart=i,this.collection.pageSize=n;var s=this.collection.fetch();s.done(e.bind(function(){this.collection.length<n&&(n=this.collection.length),this.collection.populatedRange={start:t.start,end:t.start+n,size:n},this.collection.scrollPosition=this.scrollPosition,this.onCollectionReset()
},this))}}},initScrolling:function(){this.initializingScrollPosition&&(this.restrictScrollDirection=!0,this.initializingScrollPosition=!1,this.restoringScrollPosition=!1,this.collection.scrollPosition?n.trigger("update:scrollPosition",this.collection.scrollPosition):this.containerScrollPosition.scrollTop>0&&n.trigger("update:scrollPosition",0))},onDeselectAll:function(t){e.each(t,function(e){this.pool.each(function(t){t.view.model===e&&t.view.deselect()},this)},this)},onClose:function(){o.prototype.onClose.apply(this,arguments),r.onClose.apply(this,arguments),n.trigger("stop:scrollListener"),n.trigger(this.channelName+".unsubscribe:resize",this.onResize),n.trigger(this.channelName+".unsubscribe:scroll",this.onScroll),this.collection.scrollPosition=this.scrollPosition
},onCollectionReset:function(t,i){a.cancel(this.cid),this.pool.each(function(e){e.id=e.filledWithIndex=this.collection.indexOf(e.view.model)},this),i&&i.previousModels&&e.each(i.previousModels,this.onCollectionRemove,this),this.initializingScrollPosition=!0,this.measureItem(),this.render(),this.getTotalSize()||this.trigger("change:loading",!1)},onCollectionAdd:function(e){this.remeasureItem&&(this.remeasureItem=!1,this.measureItem(e))},onCollectionRemove:function(e){var t=this.pool.findByModel(e),i=t&&t.view||{model:e,deselect:function(){}};
this.triggerMethod("item:removed",i)},onResize:function(e){this.containerSize=e,this.measureItem(),this.scrollDirection=this.containerWidth>this.$el.width()?"up":"down",this.render()},onScroll:function(e){this.containerScrollPosition=e,this.restoringScrollPosition||(this.itemWidth||this.measureItem(),this.scrollDirection=0!==this.containerScrollPosition.scrollTop&&this.containerScrollPosition.scrollTop<this.scrollPosition?"up":"down",this.restrictScrollDirection&&(this.scrollDirection="down",this.restrictScrollDirection=!1),this.scrollPosition=this.containerScrollPosition.scrollTop,this.render())
}});return l}),define("plex/desktop/views/lists/library/VirtualMediaTileList",["plex/desktop/views/lists/VirtualList","plex/desktop/views/lists/library/MediaTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list virtual-list media-tile-list",itemView:t});return i}),define("hb!templates/desktop/lists/library/MediaDetailsListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"show-actions"}function r(){return"selected"}function o(){return"hidden"
}function l(){return'\n      <span class="media-added-at"></span>\n    '}function c(e,t){var n,s,a;return a={hash:{},inverse:x.program(12,u,t),fn:x.program(10,d,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"originallyAvailableAt",a):k.call(e,"if_eq",e&&e.sort,"originallyAvailableAt",a),s||0===s?s:""}function d(){return'\n      <span class="media-available-at"></span>\n    '}function u(e,t){var n,s,a;return a={hash:{},inverse:x.program(15,p,t),fn:x.program(13,h,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"rating",a):k.call(e,"if_eq",e&&e.sort,"rating",a),s||0===s?s:""
}function h(){return'\n      <span class="media-rating"></span>\n    '}function p(e,t){var n,s,a;return a={hash:{},inverse:x.program(18,f,t),fn:x.program(16,m,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"mediaHeight",a):k.call(e,"if_eq",e&&e.sort,"mediaHeight",a),s||0===s?s:""}function m(){return'\n      <span class="media-resolution"></span>\n    '}function f(e,t){var n,s,a;return a={hash:{},inverse:x.noop,fn:x.program(19,g,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.sort,"duration",a):k.call(e,"if_eq",e&&e.sort,"duration",a),s||0===s?s:""
}function g(){return'\n      <span class="media-duration"></span>\n    '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var v,y,b,w="",x=this,k=i.helperMissing,S="function",C=this.escapeExpression;return w+='<a class="media-list-inner-item ',v=i["if"].call(t,t&&t.showActions,{hash:{},inverse:x.noop,fn:x.program(1,a,s),data:s}),(v||0===v)&&(w+=v),w+=" ",v=i["if"].call(t,t&&t.selected,{hash:{},inverse:x.noop,fn:x.program(3,r,s),data:s}),(v||0===v)&&(w+=v),w+='" href="',(v=i.url)?v=v.call(t,{hash:{},data:s}):(v=t&&t.url,v=typeof v===S?v.call(t,{hash:{},data:s}):v),w+=C(v)+'">\n  <div class="media-poster">\n    <span class="media-count-badge badge hidden"></span>\n    <span class="unwatched-count-badge badge hidden"></span>\n\n    <div class="media-progress"></div>\n  </div>\n\n  <div class="media-actions ',v=i.unless.call(t,t&&t.showActions,{hash:{},inverse:x.noop,fn:x.program(5,o,s),data:s}),(v||0===v)&&(w+=v),w+='">\n    <button class="play-btn media-action-btn" tabindex="-1"><i class="glyphicon play"></i></button>\n    <button class="play-unwatched-btn media-action-btn" tabindex="-1"><i class="glyphicon play"></i></button>\n    <button class="edit-btn media-action-btn btn-loading btn-loading-static" tabindex="-1">\n      <i class="btn-label glyphicon pencil"></i>\n      <div class="loading loading-sm"></div>\n    </button>\n    <button class="more-btn media-action-btn" tabindex="-1"><i class="glyphicon more"></i></button>\n  </div>\n\n  <div class="media-sort media-heading secondary">\n    ',b={hash:{},inverse:x.program(9,c,s),fn:x.program(7,l,s),data:s},v=i.if_eq||t&&t.if_eq,y=v?v.call(t,t&&t.sort,"addedAt",b):k.call(t,"if_eq",t&&t.sort,"addedAt",b),(y||0===y)&&(w+=y),w+='\n  </div>\n\n  <span class="media-title media-heading"></span>\n  <span class="media-subtitle-2 media-heading secondary"></span>\n  <span class="media-subtitle-1 media-heading secondary"></span>\n  <span class="unwatched-icon"></span>\n  <span class="media-context media-heading secondary"></span>\n\n  <p class="media-tagline"></p>\n\n  <p class="media-summary"></p>\n</a>\n\n<div class="media-actions-dropdown dropdown pull-right">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/MediaDetailsListItem",["hb!templates/desktop/lists/library/MediaDetailsListItem.tpl","underscore","plex/desktop/views/lists/library/MediaListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n){"use strict";var s=i.extend({className:"striped-list-item media-list-item media-details-list-item",template:e,ui:t.extend({poster:".media-poster"},i.prototype.ui),initialize:function(){i.prototype.initialize.apply(this,arguments),this.model&&this.createImageView()
},createImageView:function(){var e=this.type;"episode"===e&&(e="show"),this.image=new n({model:this.model,type:e,getUrl:this.getPosterUrl,height:150})},bindings:t.extend({},i.prototype.bindings,{".media-count-badge":{modelAttribute:"Media",formatter:function(e){return e&&e.length||0},autohide:function(e){return/^(clip|userPlaylistItem)$/.test(this.model.get("type"))?!1:e>1}},".unwatched-count-badge":{modelAttribute:"unviewedLeafCount",autohide:function(e){return this.shared&&!this.multiuser?!1:/^(artist|album)$/.test(this.model.get("type"))?!1:!!e
}},".media-tagline":{modelAttribute:"tagline",autohide:!0},".media-summary":{modelAttribute:"summary",autohide:!0}})});return s}),define("plex/desktop/views/lists/library/VirtualMediaDetailsList",["plex/desktop/views/lists/VirtualList","plex/desktop/views/lists/library/MediaDetailsListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list virtual-list media-list media-details-list",itemView:t});return i}),define("plex/desktop/views/lists/library/VirtualMediaList",["plex/desktop/views/lists/VirtualList","plex/desktop/views/lists/library/MediaListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"list virtual-list media-list",itemView:t});return i}),define("plex/desktop/views/section/SectionListView",["hb!templates/desktop/section/SectionListView.tpl","underscore","marionette","plex/base/utils/constants/timelineEvents","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/desktop/views/lists/library/VirtualMediaTileList","plex/desktop/views/lists/library/VirtualMediaDetailsList","plex/desktop/views/lists/library/VirtualMediaList","plex/desktop/views/modals/EditSectionModal"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=i.Layout.extend({className:"section-list-container",template:e,ui:{loading:".section-loading-container",emptyMessageContainer:".empty-message"},regions:{list:"ul"},modelEvents:{"change:selecting":"onSelectingChange","change:currentType":"onCurrentTypeChange","change:currentFilters":"onListRefresh","change:currentSort":"onListRefresh","change:currentFirstCharacter":"onCurrentFirstCharacterChange","socket:timeline":"onTimeline","change:refreshing":"showEmptyMessage"},collectionEvents:{reset:"showEmptyMessage","change:totalSize":"showEmptyMessage"},events:{"click .add-to-library-link":"onAddToLibraryLinkClick"},onlyAfterRender:["showLoading","hideLoading","showEmptyMessage"],initialize:function(e){this.listenTo(a.getInstance(),"change:listType",this.onListTypeChange),this.mediaActions=e.mediaActions,this.collection.fetch({reset:!0,scope:"page"})
},serializeData:function(){return{canEdit:!this.model.server.get("shared")&&!this.model.server.get("synced")}},showLoading:function(e){e||(e={});var t=this.list.currentView,i=t.itemsPerPage,n=this.collection[t.sizeProperty];this.ui.loading.toggleClass("has-scrollbar",n>i),this.ui.loading.toggleClass("bottom",!e.prepend),this.ui.loading.removeClass("hidden")},hideLoading:function(){this.ui.loading.addClass("hidden")},showEmptyMessage:function(){this.ui.emptyMessageContainer.removeClass("folder filter refreshing default");
var e=this.collection[this.list.currentView.sizeProperty];if(0===e){var t=this.model.get("currentSubset"),i=this.model.get("currentFilters");this.ui.emptyMessageContainer.addClass(t&&"folder"===t.id?"folder":t&&"all"!==t.id?"filter":i&&i.length?"filter":this.model.get("refreshing")?"refreshing":"default")}},getListConstructor:function(){var e=a.getInstance().getSectionListType(this.model);switch(e){case"media-details-list":return o;case"media-list":return l;default:return r}},onRender:function(){var e=this.getListConstructor();
e&&(this.list.append(new e({collection:this.collection,paginated:!this.model.server.get("synced"),mediaActions:this.mediaActions}),this.$el),this.listenTo(this.list.currentView,{"change:loading":this.onLoadingChange}))},onClose:function(){this.collection.clear()},onSelectingChange:function(e,t){this.$el.toggleClass("hide-actions",t)},onCurrentTypeChange:function(){this.onListRefresh();var e=a.getInstance().getSectionListType(this.model),t=a.getInstance().getSectionListType(this.model,this.model.previous("currentType"));
e!==t&&this.render()},onListRefresh:function(){this.collection.scrollPosition=0,this.collection.clear({silent:!1}),this.collection.fetch({reset:!0,scope:"page"}),this.showLoading()},onListTypeChange:function(){this.list.currentView.scrollPosition=0,this.collection.populatedRange.start>0&&(this.collection.clear(),this.collection.fetch({reset:!0,scope:"page"})),this.render()},onCurrentFirstCharacterChange:function(e,t){for(var i=e.get("alphanumeric"),n=0,s=0,a=i.length;a>s;s++){var r=i.at(s);if(t.id===r.id)break;
n+=r.get("size")}this.list.currentView.scrollToIndex(n)},onTimeline:function(e){if(e.state===n.CREATED||e.state===n.DELETED){var t=this.model.get("currentType");("folder"===this.collection.subset||e.type===t.id)&&this.list.currentView.merge()}},onLoadingChange:function(e,t){e?this.showLoading(t):this.hideLoading()},onAddToLibraryLinkClick:function(e){e.preventDefault(),s.trigger("show:modal",new c({server:this.model.server,model:this.model,selectedPane:"folders"}))}});return d}),define("plex/desktop/views/section/SectionView",["hb!templates/desktop/section/SectionView.tpl","marionette","plex/base/utils/dispatcher","plex/base/utils/types/subsetTypes","plex/base/utils/types/mediaTypes","plex/base/adapters/settingsAdapter","plex/desktop/models/MediaActionsModel","plex/base/models/library/section/SectionSubsetModel","plex/desktop/views/actionbar/SectionActionBarView","plex/desktop/views/breadcrumbbar/SectionBreadcrumbBarView","plex/desktop/views/alphabar/AlphaBarView","plex/desktop/views/section/SectionListView"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=t.Layout.extend({className:"section-container",template:e,regions:{list:".section-list-container"},modelEvents:{"change:currentType":"toggleAlphaBar","change:currentSort":"toggleAlphaBar"},initialize:function(e){this.initSubset(e),this.initType(e),this.model.set("currentFolderKey",e.folderKey),this.mediaActions=new r({},{section:this.model,showAdvanced:!0}),i.trigger("show:bar","actionbar",new l({model:this.model,mediaActions:this.mediaActions})),i.trigger("show:bar","breadcrumbbar",new c({model:this.model})),this.toggleAlphaBar()
},initSubset:function(e){var t=e.subset,i=this.model.getScopedKey("subset");t||(t=a.get(i)),this.subset=n.getSubsetType(t),(!this.subset||this.model.get("currentFilters").length)&&(this.subset=n.getSubsetType("all")),a.save(i,this.subset.key);var s=this.model.get("currentSubset");s&&s.id!==this.subset.key&&(this.model.get("items").scrollPosition=0,this.model.set("currentSubset",new o(this.subset,{server:this.model.server,section:this.model})))},initType:function(e){var t=e.type,i=this.model.get("currentType");
if(!i||t&&i.id!==t){var n=this.model.get("types"),a=s.getMediaTypeByString(this.model.get("type")),r=s.getRelatedMediaTypes(a.typeString);n.reset(r,{parse:!0});var o=n.get(t||a.id);o.set("selected",!0),this.model.set("currentType",o)}},toggleAlphaBar:function(){this.supportsAlphaPagination()?i.trigger("show:bar","alphabar",new d({model:this.model,collection:this.model.get("alphanumeric")})):i.trigger("hide:bar","alphabar")},supportsAlphaPagination:function(){if(!this.model.get("allowAdvancedFilters")||"all"!==this.subset.key)return!1;
var e=this.model.get("currentType"),t=this.model.get("currentSort");if(!t){var i=/^(season|episode|album|track)$/;return!i.test(e.get("typeString"))}var n=t.get("key"),s=t.get("direction");return"titleSort"===n&&"asc"===s},onRender:function(){this.list.append(new u({model:this.model,collection:this.model.get("items"),mediaActions:this.mediaActions}),this.$el)},onClose:function(){i.trigger("hide:bar","actionbar"),i.trigger("hide:bar","breadcrumbbar"),i.trigger("hide:bar","alphabar")}});return h}),define("hb!templates/desktop/details/DetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("hb!templates/desktop/actionbar/ActionBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s;return s={hash:{},data:t},g((n=i.t||e&&e.t,n?n.call(e,"Play",s):f.call(e,"t","Play",s)))}function r(e,t){var n,s;return s={hash:{},data:t},g((n=i.t||e&&e.t,n?n.call(e,"Play All",s):f.call(e,"t","Play All",s)))}function o(e,t){var n,s,a="";return a+='<li><a class="play-next-btn secondary-only ',n=i.unless.call(e,e&&e.canQueue,{hash:{},inverse:v.noop,fn:v.program(6,l,t),data:t}),(n||0===n)&&(a+=n),a+='" href="#">',s={hash:{},data:t},a+=g((n=i.t||e&&e.t,n?n.call(e,"Play Next",s):f.call(e,"t","Play Next",s)))+"</a></li>"
}function l(){return"disabled"}function c(e,t){var n,s,a="";return a+='<li><a class="add-to-up-next-btn secondary-only ',n=i.unless.call(e,e&&e.canQueue,{hash:{},inverse:v.noop,fn:v.program(6,l,t),data:t}),(n||0===n)&&(a+=n),a+='" href="#">',s={hash:{},data:t},a+=g((n=i.t||e&&e.t,n?n.call(e,"Add to Up Next",s):f.call(e,"t","Add to Up Next",s)))+"</a></li>"}function d(e,t){var n,s,a="";return a+='\n        <li><a class="download-btn secondary-only" href="',(n=i.downloadUrl)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadUrl,n=typeof n===y?n.call(e,{hash:{},data:t}):n),a+=g(n)+'" download="',(n=i.downloadName)?n=n.call(e,{hash:{},data:t}):(n=e&&e.downloadName,n=typeof n===y?n.call(e,{hash:{},data:t}):n),a+=g(n)+'">',s={hash:{},data:t},a+=g((n=i.t||e&&e.t,n?n.call(e,"Download",s):f.call(e,"t","Download",s)))+"</a></li>\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var u,h,p,m="",f=i.helperMissing,g=this.escapeExpression,v=this,y="function";return m+='<ul class="nav action-bar-nav">\n  <li>\n    <a class="play-btn btn-gray" href="#" title="',u=i["if"].call(t,t&&t.isSingleItem,{hash:{},inverse:v.program(3,r,s),fn:v.program(1,a,s),data:s}),(u||0===u)&&(m+=u),m+='" data-toggle="tooltip"><i class="glyphicon play"></i></a>\n  </li>\n  <li>\n    <a class="play-unwatched-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Play Unwatched",p):f.call(t,"t","Play Unwatched",p)))+'" data-toggle="tooltip"><i class="glyphicon play"></i></a>\n  </li>\n  <li>\n    <a class="play-shuffled-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Shuffle",p):f.call(t,"t","Shuffle",p)))+'" data-toggle="tooltip"><i class="glyphicon random"></i></a>\n  </li>\n  <li>\n    <a class="play-trailer-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Play Trailer",p):f.call(t,"t","Play Trailer",p)))+'" data-toggle="tooltip"><i class="plex-icon play-strip"></i></a>\n  </li>\n  <li>\n    <a class="edit-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Edit",p):f.call(t,"t","Edit",p)))+'" data-toggle="tooltip"><i class="glyphicon pencil"></i></a>\n  </li>\n  <li>\n    <a class="add-to-playlist-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Add to playlist",p):f.call(t,"t","Add to playlist",p)))+'" data-toggle="tooltip"><i class="plex-icon add-to-playlist"></i></a>\n  </li>\n  <li>\n    <a class="refresh-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Refresh",p):f.call(t,"t","Refresh",p)))+'" data-toggle="tooltip"><i class="glyphicon repeat"></i></a>\n  </li>\n  <li>\n    <a class="analyze-btn btn-gray secondary-action" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Analyze",p):f.call(t,"t","Analyze",p)))+'" data-toggle="tooltip"><i class="glyphicon magic"></i></a>\n  </li>\n  <li>\n    <a class="mark-watched-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Mark as Watched",p):f.call(t,"t","Mark as Watched",p)))+'" data-toggle="tooltip"><i class="glyphicon circle-ok"></i></a>\n  </li>\n  <li>\n    <a class="mark-unwatched-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Mark as Unwatched",p):f.call(t,"t","Mark as Unwatched",p)))+'" data-toggle="tooltip"><i class="glyphicon circle-minus"></i></a>\n  </li>\n  <li>\n    <a class="select-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Select",p):f.call(t,"t","Select",p)))+'" data-toggle="tooltip"><i class="glyphicon check"></i></a>\n  </li>\n  <li>\n    <a class="deselect-btn btn-gray selected" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Deselect All",p):f.call(t,"t","Deselect All",p)))+'" data-toggle="tooltip"><i class="glyphicon unchecked"></i></a>\n  </li>\n  <li>\n    <a class="sync-btn btn-gray" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Sync",p):f.call(t,"t","Sync",p)))+'" data-toggle="tooltip"><i class="glyphicon download"></i></a>\n  </li>\n  <li>\n    <a class="share-btn btn-gray secondary-action" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Share",p):f.call(t,"t","Share",p)))+'" data-toggle="tooltip"><i class="glyphicon share"></i></a>\n  </li>\n  <li>\n    <a class="recommend-btn btn-gray secondary-action" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Recommend",p):f.call(t,"t","Recommend",p)))+'" data-toggle="tooltip"><i class="glyphicon share-alt"></i></a>\n  </li>\n  <li>\n    <a class="delete-btn btn-gray secondary-action" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Delete",p):f.call(t,"t","Delete",p)))+'" data-toggle="tooltip"><i class="glyphicon bin"></i></a>\n  </li>\n  <li>\n    <a class="delete-from-user-playlist-btn btn-gray secondary-action" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Delete",p):f.call(t,"t","Delete",p)))+'" data-toggle="tooltip"><i class="glyphicon bin"></i></a>\n  </li>\n  <li>\n    <a class="info-btn btn-gray secondary-action" href="#" title="',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Info",p):f.call(t,"t","Info",p)))+'" data-toggle="tooltip"><i class="glyphicon circle-info"></i></a>\n  </li>\n\n  <li class="secondary-actions-dropdown dropdown">\n    <a class="more-btn btn-gray dropdown-toggle" href="#" data-toggle="dropdown"><i class="glyphicon more"></i></a>\n    <ul class="dropdown-menu">\n      <li><a class="play-all-btn secondary-only" href="#">',h=i["if"].call(t,t&&t.isSingleItem,{hash:{},inverse:v.program(3,r,s),fn:v.program(1,a,s),data:s}),(h||0===h)&&(m+=h),m+="</a></li>\n      ",h=i["if"].call(t,t&&t.showQueue,{hash:{},inverse:v.noop,fn:v.program(5,o,s),data:s}),(h||0===h)&&(m+=h),m+="\n      ",h=i["if"].call(t,t&&t.showQueue,{hash:{},inverse:v.noop,fn:v.program(8,c,s),data:s}),(h||0===h)&&(m+=h),m+='\n      <li class="secondary-divider divider"></li>\n      <li><a class="analyze-btn" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Analyze",p):f.call(t,"t","Analyze",p)))+'</a></li>\n      <li><a class="match-btn secondary-only" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Match",p):f.call(t,"t","Match",p)))+'</a></li>\n      <li><a class="fix-match-btn secondary-only" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Fix Incorrect Match",p):f.call(t,"t","Fix Incorrect Match",p)))+'</a></li>\n      <li><a class="unmatch-btn secondary-only" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Unmatch",p):f.call(t,"t","Unmatch",p)))+'</a></li>\n      <li><a class="split-apart-btn secondary-only" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Split Apart",p):f.call(t,"t","Split Apart",p)))+"</a></li>\n      ",h=i["if"].call(t,t&&t.downloadUrl,{hash:{},inverse:v.noop,fn:v.program(10,d,s),data:s}),(h||0===h)&&(m+=h),m+='\n      <li><a class="watch-later-btn" href="#" tabindex="-1">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Watch Later",p):f.call(t,"t","Watch Later",p)))+'</a></li>\n      <li><a class="share-btn" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Share",p):f.call(t,"t","Share",p)))+'</a></li>\n      <li><a class="recommend-btn" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Recommend",p):f.call(t,"t","Recommend",p)))+'</a></li>\n      <li><a class="delete-btn has-danger" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Delete",p):f.call(t,"t","Delete",p)))+'</a></li>\n      <li><a class="delete-from-user-playlist-btn has-danger" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Delete",p):f.call(t,"t","Delete",p)))+'</a></li>\n      <li><a class="info-btn" href="#">',p={hash:{},data:s},m+=g((u=i.t||t&&t.t,u?u.call(t,"Info",p):f.call(t,"t","Info",p)))+"</a></li>\n    </ul>\n  </li>\n</ul>\n"
})}),define("hb!templates/desktop/modals/FixIncorrectMatchModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n          <div class="match-location">\n            ',s={hash:{},data:t},a+=p((n=i.t||e&&e.t,n?n.call(e,"Location",s):h.call(e,"t","Location",s)))+": ",s={hash:{},data:t},a+=p((n=i.truncateMiddle||e&&e.truncateMiddle,n?n.call(e,e&&e.location,60,12,s):h.call(e,"truncateMiddle",e&&e.location,60,12,s)))+"\n          </div>\n        "
}function r(e,t){var n,s,a="";return a+='\n          <ul class="list modal-list">\n            <li class="modal-list-item"><a class="search-options-btn" href="#">',s={hash:{},data:t},a+=p((n=i.t||e&&e.t,n?n.call(e,"Search Options",s):h.call(e,"t","Search Options",s)))+'</a></li>\n            <li class="auto-match-dropdown-region modal-list-item"></li>\n          </ul>\n        '}function o(e,t){var n,s,a="";return a+='\n            <button type="button" class="search-btn btn btn-primary btn-loading">\n              <div class="loading loading-sm"></div>\n                <span class="btn-label">',s={hash:{},data:t},a+=p((n=i.t||e&&e.t,n?n.call(e,"Search",s):h.call(e,"t","Search",s)))+"</span>\n            </button>\n          "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h=i.helperMissing,p=this.escapeExpression,m=this;return u+='<div class="modal-dialog">\n  <div class="modal-content">\n    <form id="fix-incorrect-match-form">\n      <div class="modal-header">\n        <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n        <h4 class="modal-title"><i class="modal-icon glyphicon nameplate"></i> <span class="modal-title-text"></span></h4>\n        ',l=i["if"].call(t,t&&t.location,{hash:{},inverse:m.noop,fn:m.program(1,a,s),data:s}),(l||0===l)&&(u+=l),u+='\n      </div>\n\n      <div class="modal-body modal-body-scroll dark-scrollbar">\n        ',l=i["if"].call(t,t&&t.showNavigation,{hash:{},inverse:m.noop,fn:m.program(3,r,s),data:s}),(l||0===l)&&(u+=l),u+='\n\n          <div class="pane-region"></div>\n      </div>\n\n      <div class="modal-footer">\n        <div class="match-search-actions">\n          <button type="button" class="cancel-btn btn btn-default">',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Cancel",d):h.call(t,"t","Cancel",d)))+"</button>\n          ",c=i["if"].call(t,t&&t.showNavigation,{hash:{},inverse:m.noop,fn:m.program(5,o,s),data:s}),(c||0===c)&&(u+=c),u+="\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/dropdowns/AutoMatchDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n    <li><a class="auto-match-agent" href="#" data-id="',(n=i.identifier)?n=n.call(e,{hash:{},data:t}):(n=e&&e.identifier,n=typeof n===d?n.call(e,{hash:{},data:t}):n),s+=u(n)+'">',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===d?n.call(e,{hash:{},data:t}):n),s+=u(n)+"</a></li>\n  "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<a class="dropdown-toggle" href="#auto-match-dropdown" data-toggle="dropdown">',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Auto Match",l):h.call(t,"t","Auto Match",l)))+' <i class="caret-icon caret-icon-sm"></i></a>\n\n<ul class="dropdown-menu">\n  ',o=i.each.call(t,t&&t.agents,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+="\n</ul>\n"})}),define("plex/desktop/views/dropdowns/AutoMatchDropdown",["hb!templates/desktop/dropdowns/AutoMatchDropdown.tpl","jquery","marionette","plex/base/commands/commands"],function(e,t,i,n){"use strict";
var s=i.ItemView.extend({id:"auto-match-dropdown",tagName:"span",className:"dropdown",template:e,collectionEvents:{reset:"render"},events:{"click .auto-match-agent":"onClick"},serializeData:function(){return{agents:this.collection.toJSON()}},onClick:function(e){e.preventDefault();var i=t(e.currentTarget).data("id"),s=this.collection.get(i);n.execute("autoMatch",{item:this.model,agent:s})}});return s}),define("hb!templates/desktop/section/fixincorrectmatch/FixIncorrectMatchFormView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";
return s+='\n          <option value="',(n=i.value)?n=n.call(e,{hash:{},data:t}):(n=e&&e.value,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" ',n=i["if"].call(e,e&&e.selected,{hash:{},inverse:f.noop,fn:f.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+=">",(n=i.label)?n=n.call(e,{hash:{},data:t}):(n=e&&e.label,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</option>\n        "}function r(){return"selected"}function o(e,t){var n,s,a="";return a+='\n          <option value="">',s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Loading...",s):g.call(e,"t","Loading...",s)))+"</option>\n        "
}function l(e,t){var n,s="";return s+='\n          <option value="',(n=i.value)?n=n.call(e,{hash:{},data:t}):(n=e&&e.value,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+'">',(n=i.label)?n=n.call(e,{hash:{},data:t}):(n=e&&e.label,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</option>\n        "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p="function",m=this.escapeExpression,f=this,g=i.helperMissing;return h+='<div class="row">\n  <div class="col-md-6">\n    <div class="form-group">\n      <label class="control-label" for="match-search-title">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Title",u):g.call(t,"t","Title",u)))+'</label>\n      <input type="text" id="match-search-title" name="title" class="form-control" value="'+m((c=t&&t.item,c=null==c||c===!1?c:c.title,typeof c===p?c.apply(t):c))+'">\n    </div>\n  </div>\n\n  <div class="col-md-6">\n    <div class="form-group">\n      <label class="control-label" for="match-search-agent">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Agent",u):g.call(t,"t","Agent",u)))+'</label>\n      <select id="match-search-agent" name="agent">\n        ',d=i.each.call(t,t&&t.agents,{hash:{},inverse:f.program(4,o,s),fn:f.program(1,a,s),data:s}),(d||0===d)&&(h+=d),h+='\n      </select>\n    </div>\n  </div>\n</div>\n\n<div class="row">\n  <div class="col-md-6">\n    <div class="form-group">\n      <label class="control-label" for="match-search-year">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Year",u):g.call(t,"t","Year",u)))+'</label>\n      <input type="text" id="match-search-year" name="year" class="form-control" value="'+m((c=t&&t.item,c=null==c||c===!1?c:c.year,typeof c===p?c.apply(t):c))+'">\n    </div>\n  </div>\n\n  <div class="col-md-6">\n    <div class="form-group">\n      <label class="control-label" for="match-search-language">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Language",u):g.call(t,"t","Language",u)))+'</label>\n      <select id="match-search-language" name="language">\n        ',d=i.each.call(t,t&&t.languages,{hash:{},inverse:f.program(4,o,s),fn:f.program(6,l,s),data:s}),(d||0===d)&&(h+=d),h+="\n      </select>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/section/fixincorrectmatch/FixIncorrectMatchFormView",["hb!templates/desktop/section/fixincorrectmatch/FixIncorrectMatchFormView.tpl","marionette","underscore","plex/base/utils/languageUtil","plex/base/models/library/AgentCollection","plex/base/models/library/ExclusiveAgentProxy"],function(e,t,i,n,s,a){"use strict";function r(e){return i.map(e,function(e){return'<option value="'+e.value+'"'+(e.selected?" selected":"")+">"+e.label+"</option>"}).join("\n")}function o(e,t){return e.map(function(e){return{label:e.get("name"),value:e.get("identifier"),selected:t===e.get("identifier")}
})}function l(e,t){return e?i.map(e.get("language"),function(e){return{label:n.getLanguageName(e),value:e,selected:e===t}}):[]}var c=t.ItemView.extend({template:e,ui:{agentSelect:"#match-search-agent",languageSelect:"#match-search-language"},events:{"change #match-search-agent":"onAgentSelectChange"},modelEvents:{"agent:change":"onAgentChange"},onlyAfterRender:["updateAgents","updateLanguages"],initialize:function(){var e=this.setupAgents();e.then(i.bind(this.updateAgents,this)),e.then(i.bind(this.updateLanguages,this))
},serializeData:function(){var e=this.model.section.get("agent"),t=this.model.agentsProxy.get(e),i={item:this.model.toJSON(),agents:o(this.model.agentsProxy,e),languages:l(t)};return i},setupAgents:function(){if(this.model.agentsPromise)return this.model.agentsPromise;var e=this.model.section.getSectionType(),t=new s([],{server:this.model.server,sectionType:e}),i=e.exclusiveAgents,n=new a(t,i,this.model.section.get("agent"));return this.model.agents=t,this.model.agentsProxy=n,this.model.agentsPromise=this.model.agents.populate({reset:!0,cancelable:!0}),this.model.agentsPromise
},updateAgents:function(){var e=this.model.section.get("agent");this.ui.agentSelect.html(r(o(this.model.agentsProxy,e)))},updateLanguages:function(){var e=this.model.section.get("agent"),t=this.model.agentsProxy.get(e);return e?void this.ui.languageSelect.html(r(l(t,this.model.section.get("language")))):void this.ui.languageSelect.empty()},onAgentsReset:function(){this.updateAgents(),this.updateLanguages()},onAgentSelectChange:function(e){this.model.section.set("language",e.currentTarget.value)},onAgentChange:function(){this.updateLanguages()
},onModalClose:function(){this.model.agents=null,this.model.agentsProxy=null,this.model.agentsPromise=null}});return c}),define("hb!templates/desktop/section/fixincorrectmatch/FixIncorrectMatchResultsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="result-region">\n  <div class="loading loading-inline"></div>\n</div>\n'})}),define("plex/base/models/library/MatchResultModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel","plex/base/models/BaseCollection"],function(e,t,i,n){"use strict";
var s=i.extend({idAttribute:"guid",whitelistedAttrs:["guid","id","name","parentName","parentGUID","parentID","score","thumb","type","year"],convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return t.parseInteger(n,"score"),n.score=Math.min(Math.max(n.score,0),100),n},parse:function(t){var i=this.convert(t),s=i.SearchResult;return i=e.pick(i,this.whitelistedAttrs),s&&(i.children=new n(s,{parent:this,server:this.server})),i}});return s}),define("plex/base/models/library/MatchResultCollection",["plex/base/models/BaseCollection","plex/base/models/library/MatchResultModel"],function(e,t){"use strict";
var i=e.extend({model:t,url:function(){return"/library/metadata/"+this.parent.id+"/matches"},parse:function(e){return this.convert(e,"SearchResult")}});return i}),define("hb!templates/desktop/lists/library/MatchResultListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n        <span class="match-name">',(n=i.parentName)?n=n.call(e,{hash:{},data:t}):(n=e&&e.parentName,n=typeof n===h?n.call(e,{hash:{},data:t}):n),s+=p(n)+'</span> &ndash; <span class="match-name">',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===h?n.call(e,{hash:{},data:t}):n),s+=p(n)+"</span>\n      "
}function r(e,t){var n,s="";return s+='\n        <span class="match-name">',(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===h?n.call(e,{hash:{},data:t}):n),s+=p(n)+"</span>\n      "}function o(e,t){var n,s="";return s+='\n        <span class="match-year">',(n=i.year)?n=n.call(e,{hash:{},data:t}):(n=e&&e.year,n=typeof n===h?n.call(e,{hash:{},data:t}):n),s+=p(n)+'</span>\n        <span class="match-separator">&middot;</span>\n      '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var l,c,d,u="",h="function",p=this.escapeExpression,m=this,f=i.helperMissing;return u+='<a class="match-result col-xs-12" href="#">\n  <div class="row">\n    <div class="col-xs-9 match-title-info">\n      ',l=i["if"].call(t,t&&t.parentName,{hash:{},inverse:m.program(3,r,s),fn:m.program(1,a,s),data:s}),(l||0===l)&&(u+=l),u+='\n    </div>\n    <div class="col-xs-3 match-score-info" title="',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Score {1}",t&&t.score,d):f.call(t,"t","Score {1}",t&&t.score,d)))+'">\n      ',c=i["if"].call(t,t&&t.year,{hash:{},inverse:m.noop,fn:m.program(5,o,s),data:s}),(c||0===c)&&(u+=c),u+='\n      <span class="match-score"><i class="match-score-icon glyphicon certificate"></i>',(c=i.score)?c=c.call(t,{hash:{},data:s}):(c=t&&t.score,c=typeof c===h?c.call(t,{hash:{},data:s}):c),u+=p(c)+'</span>\n    </div>\n  </div>\n  <div class="row match-extended-info hidden">\n    <div class="col-xs-4">\n      <img class="match-art" src="',(c=i.thumb)?c=c.call(t,{hash:{},data:s}):(c=t&&t.thumb,c=typeof c===h?c.call(t,{hash:{},data:s}):c),u+=p(c)+'"/>\n    </div>\n    <div class="col-xs-8 children-region"></div>\n  </div>\n</a>\n'
})}),define("hb!templates/desktop/lists/library/MatchResultChildListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"missing"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=i.helperMissing,u=this.escapeExpression,h="function",p=this;return c+='<div class="row disc-number hidden">\n  ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Disc {1}",t&&t.parentIndex,l):d.call(t,"t","Disc {1}",t&&t.parentIndex,l)))+'\n</div>\n\n<div class="row striped-list-inner-item">\n  <span class="col-xs-1 match-index">\n    ',(o=i.index)?o=o.call(t,{hash:{},data:s}):(o=t&&t.index,o=typeof o===h?o.call(t,{hash:{},data:s}):o),c+=u(o)+'.\n  </span>\n  <span class="col-xs-11 match-track-name ',o=i.unless.call(t,t&&t.matched,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='">\n    ',(o=i.name)?o=o.call(t,{hash:{},data:s}):(o=t&&t.name,o=typeof o===h?o.call(t,{hash:{},data:s}):o),c+=u(o)+"\n  </span>\n</div>\n"
})}),define("plex/desktop/views/lists/library/MatchResultChildListItem",["hb!templates/desktop/lists/library/MatchResultChildListItem.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({tagName:"li",template:e,className:"striped-list-item",initialize:function(e){this.item=e.item}});return i}),define("plex/desktop/mixins/views/discMarkerMixin",["underscore"],function(e){"use strict";var t={collectionEvents:{sync:"onSync"},markDiscNumbers:function(){if(this.collection.server.supports("premiumMusic")){var e=this.collection.reduce(function(e,t,i){var n=t.get("parentIndex");
return n!==e.lastDiscNumber&&(e.markers[i]=n,e.lastDiscNumber=n,e.count+=1),e},{markers:{},lastDiscNumber:null,count:0});return this.discMarkers=e.markers,e.count}},onRender:function(){var t=this.markDiscNumbers();1!==t&&e.each(this.discMarkers,e.bind(function(e,t){this.$("li:eq("+t+") .disc-number").removeClass("hidden")},this))},onSync:function(){this.render()}};return t}),define("plex/desktop/views/lists/library/MatchResultChildList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/MatchResultChildListItem","plex/desktop/mixins/views/discMarkerMixin"],function(e,t,i){"use strict";
var n=e.extend({mixins:[i],tagName:"ul",itemView:t,className:"list"});return n}),define("plex/desktop/views/lists/library/MatchResultListItem",["hb!templates/desktop/lists/library/MatchResultListItem.tpl","marionette","plex/base/commands/commands","plex/desktop/views/lists/library/MatchResultChildList"],function(e,t,i,n){"use strict";var s=t.Layout.extend({tagName:"li",className:"striped-list-item match-result-list-item row",template:e,ui:{matchExtendedInfo:".match-extended-info"},regions:{childrenRegion:".children-region"},events:{"click .match-result":"onClick"},initialize:function(e){this.item=e.item
},onRender:function(){var e=this.model.get("children");if(e){var t=e.first();t&&"track"===t.get("type")&&(this.ui.matchExtendedInfo.removeClass("hidden"),this.childrenRegion.show(new n({collection:e})))}},onClick:function(e){e.preventDefault(),i.execute("match",{item:this.item,guid:this.model.id,name:this.model.get("name"),children:this.model.get("children")})}});return s}),define("hb!templates/desktop/lists/library/MatchResultListEmpty",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="match-empty-message">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"No matches found.",r):l.call(t,"t","No matches found.",r)))+"</div>\n"})}),define("plex/desktop/views/lists/library/MatchResultListEmpty",["hb!templates/desktop/lists/library/MatchResultListEmpty.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({template:e});return i}),define("plex/desktop/views/lists/library/MatchResultList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/MatchResultListItem","plex/desktop/views/lists/library/MatchResultListEmpty"],function(e,t,i){"use strict";
var n=e.extend({tagName:"ul",className:"list match-result-list",itemView:t,emptyView:i});return n}),define("plex/desktop/views/section/fixincorrectmatch/FixIncorrectMatchResultsView",["hb!templates/desktop/section/fixincorrectmatch/FixIncorrectMatchResultsView.tpl","underscore","marionette","plex/base/models/library/MatchResultCollection","plex/desktop/views/lists/library/MatchResultList"],function(e,t,i,n,s){"use strict";var a=i.Layout.extend({template:e,regions:{resultRegion:".result-region"},onlyAfterRender:["updateResults"],initialize:function(){this.setupResults();
var e=this.model.section,i={manual:1},n={reset:!0,timeout:0,data:i};/com\.plexapp\.agents\.none\:\/\//.test(this.model.get("guid"))&&t.extend(n,{data:t.extend(i,{agent:e.get("agent"),language:e.get("language")}),processData:!0}),this.model.results.populate(n).then(t.bind(this.updateResults,this))},setupResults:function(){if(!this.model.results){var e=this.model.results||new n([],{server:this.model.server,parent:this.model});this.model.results=e}},updateResults:function(){this.resultRegion.show(new s({collection:this.model.results,itemViewOptions:{item:this.model}}))
},onModalClose:function(){this.model.results=null}});return a}),define("plex/desktop/views/modals/FixIncorrectMatchModal",["hb!templates/desktop/modals/FixIncorrectMatchModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/languageUtil","plex/base/utils/types/sectionTypes","plex/base/models/library/AgentCollection","plex/desktop/views/modals/BaseModal","plex/desktop/views/dropdowns/AutoMatchDropdown","plex/desktop/mixins/views/modals/paneModalMixin","plex/desktop/views/section/fixincorrectmatch/FixIncorrectMatchFormView","plex/desktop/views/section/fixincorrectmatch/FixIncorrectMatchResultsView"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=o.extend({mixins:[c],name:"fixIncorrectMatch",className:"fix-incorrect-match-modal modal modal-lg fade",template:e,panes:{form:{constructor:d},results:{constructor:u}},ui:{searchBtn:".search-btn"},regions:{paneRegion:".pane-region",autoMatchDropdownRegion:".auto-match-dropdown-region"},events:t.extend({"click .auto-match-agent":"hide","click .match-result":"hide","click .search-options-btn":"onSearchOptionsClick","click .cancel-btn":"onCancelClick","click .search-btn":"onSearchClick","submit #fix-incorrect-match-form":"onSearchSubmit"},o.prototype.events),onlyAfterRender:["showPane","updateSearchBtn"],initialize:function(){o.prototype.initialize.apply(this,arguments),d.prototype.setupAgents.apply(this),u.prototype.setupResults.apply(this),this.showPane("results")
},serializeData:function(){var e={location:this.model.getLocation(),showNavigation:!this.model.isPlexMusicItem()};return e},updateSearchBtn:function(e){this.ui.searchBtn.toggleClass("disabled","form"!==e)},fetchResults:function(e){var i=t.reduce(e.serializeArray(),function(e,t){return e[t.name]=t.value,e},{manual:1});this.model.results.fetch({reset:!0,data:i,processData:!0,timeout:0})},bindings:{".modal-title-text":{modelAttribute:"guid",formatter:function(e){return n(/com\.plexapp\.agents\.none\:\/\//.test(e)?"Match":"Fix Incorrect Match")
}}},onRender:function(){o.prototype.onRender.apply(this,arguments),this.autoMatchDropdownRegion.show(new l({model:this.model,collection:this.model.agentsProxy}))},onPaneShow:function(e){this.updateSearchBtn(e)},onSearchOptionsClick:function(e){e.preventDefault(),this.showPane("form")},onCancelClick:function(e){e.preventDefault(),"results"!==this.selectedPane?this.showPane("results"):this.hide()},onSearchClick:function(e){e.preventDefault();var t=i(e.currentTarget);if(!t.isDisabled()){var n=t.closest("form");
this.fetchResults(n),this.showPane("results")}},onSearchSubmit:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.find("search-btn");n.isDisabled()||(this.fetchResults(t),this.showPane("results"))}});return h}),define("plex/desktop/views/actionbar/ActionBarView",["hb!templates/desktop/actionbar/ActionBarView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/base/utils/formatters/stringUtil","plex/base/commands/commands","plex/desktop/models/MediaActionsModel","plex/desktop/views/modals/AddToPlaylistModal","plex/desktop/views/modals/EditMetadataModal","plex/desktop/views/modals/FixIncorrectMatchModal","plex/desktop/views/modals/ShareModal","plex/desktop/views/modals/RecommendModal","plex/desktop/views/modals/MediaInfoModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f){"use strict";
var g=["episode","movie","clip","userPlaylistItem"],v={preventDefault:!0,stopPropagation:!1},y=n.ItemView.extend({className:"action-bar",template:e,ui:{primaryActions:".action-bar-nav",secondaryActions:".dropdown-menu",playBtn:".play-btn",playAllBtn:".play-all-btn",playUnwatchedBtn:".play-unwatched-btn",playShuffledBtn:".play-shuffled-btn",playTrailerBtn:".play-trailer-btn",playNextBtn:".play-next-btn",addToUpNextBtn:".add-to-up-next-btn",addToPlaylistBtn:".add-to-playlist-btn",secondaryDivider:".secondary-divider",editBtn:".edit-btn",refreshBtn:".refresh-btn",analyzeBtn:".analyze-btn",markWatchedBtn:".mark-watched-btn",markUnwatchedBtn:".mark-unwatched-btn",syncBtn:".sync-btn",watchLaterBtn:".watch-later-btn",shareBtn:".share-btn",recommendBtn:".recommend-btn",deleteBtn:".delete-btn",deleteFromUserPlaylistBtn:".delete-from-user-playlist-btn",infoBtn:".info-btn"},triggers:{"click .play-btn":"play","click .play-all-btn":t.extend({event:"play"},v),"click .play-unwatched-btn":"playUnwatched","click .play-shuffled-btn":"playShuffled","click .play-trailer-btn":"playTrailer","click .edit-btn":"edit","click .refresh-btn":"refresh","click .analyze-btn":t.extend({event:"analyze"},v),"click .mark-watched-btn":"markWatched","click .mark-unwatched-btn":"markUnwatched","click .match-btn":t.extend({event:"fixMatch"},v),"click .select-btn":"select","click .deselect-btn":"deselect","click .fix-match-btn":t.extend({event:"fixMatch"},v),"click .unmatch-btn":t.extend({event:"unmatch"},v),"click .split-apart-btn":t.extend({event:"splitApart"},v),"click .sync-btn":"sync","click .watch-later-btn":t.extend({event:"watchLater"},v),"click .share-btn":t.extend({event:"share"},v),"click .recommend-btn":t.extend({event:"recommend"},v),"click .delete-btn":t.extend({event:"delete"},v),"click .delete-from-user-playlist-btn":t.extend({event:"deleteFromUserPlaylist"},v),"click .info-btn":t.extend({event:"info"},v),"click .play-next-btn":t.extend({event:"playNext"},v),"click .add-to-up-next-btn":t.extend({event:"addToUpNext"},v),"click .add-to-playlist-btn":"addToPlaylist"},onlyAfterRender:["onPlay","onPlayUnwatched","onPlayShuffled","onPlayTrailer","onEdit","onRefresh","onAnalyze","onMarkWatched","onMarkUnwatched","onSync","onWatchLater","onShare","onRecommend","onDelete","onDeleteFromUserPlaylist","onInfo","onPlayNext","onAddToUpNext","onAddToPlaylist","updateDropdown"],initialize:function(e){this.type=this.model.get("type"),this.mediaActions=e.mediaActions,this.listenTo(this.mediaActions,"change",t.throttle(this.updateDropdown,50)),this.listenTo(this.mediaActions,"change:selectedItems",this.onSelectedItemsChange),this.listenTo(a,{"shortcut:play":this.onPlay,"shortcut:edit":this.onEdit,"shortcut:refresh":this.onRefresh,"shortcut:analyze":this.onAnalyze,"shortcut:markWatched":this.onMarkWatched,"shortcut:markUnwatched":this.onMarkUnwatched,"shortcut:sync":this.onSync,"shortcut:delete":this.onDelete,"shortcut:info":this.onInfo}),this.listenTo(a,"shortcut:play",this.onPlayUnwatched),this.listenTo(a,"shortcut:delete",this.onDeleteFromUserPlaylist)
},serializeData:function(){var e=t.extend({},this.mediaActions.attributes);if(e.isSingleItem=t.contains(g,this.type),this.mediaActions.get("showDownload")){e.downloadUrl=this.model.getDownloadUrl();var i=this.model.getFilepath();i&&(e.downloadName=o.getLastSegment(i))}return e},updateDropdown:function(){var e=this.ui.secondaryActions.find("a:not(.hidden)"),t=e.hasClass("secondary-only"),i=e.length>2||t;if(this.$el.toggleClass("show-secondary-actions-dropdown",i),i){var n=this.ui.secondaryDivider,s=n.prevAll(":not(:has(.hidden))").length,a=n.nextAll(":not(:has(.hidden))").length;
n.toggleClass("hidden",!s||!a)}},bindingsModel:"mediaActions",bindings:{".play-btn":{modelAttribute:"showPlay",manual:!0,autohide:!0},".play-all-btn":{modelAttribute:"showPlayAll",manual:!0,autohide:!0},".play-unwatched-btn":{modelAttribute:"showPlayUnwatched",manual:!0,autohide:!0},".play-shuffled-btn":{modelAttribute:"showShuffle",manual:!0,autohide:!0},".play-trailer-btn":{modelAttribute:"showPlayTrailer",manual:!0,autohide:!0},".add-to-playlist-btn":{modelAttribute:"showAddToPlaylist",manual:!0,autohide:!0},".edit-btn":{modelAttribute:"showEdit",manual:!0,autohide:!0},".refresh-btn":{modelAttribute:"showRefresh",manual:!0,autohide:!0},".analyze-btn":{modelAttribute:"showAnalyze",manual:!0,autohide:!0},".mark-watched-btn":{modelAttribute:"showMarkWatched",manual:!0,autohide:!0},".mark-unwatched-btn":{modelAttribute:"showMarkUnwatched",manual:!0,autohide:!0},".match-btn":{modelAttribute:"showMatch",manual:!0,autohide:!0},".select-btn":{modelAttribute:"selecting",manual:!0,autohide:function(e){return!e&&this.mediaActions.get("showSelect")
}},".deselect-btn":{modelAttribute:"selecting",manual:!0,autohide:!0},".fix-match-btn":{modelAttribute:"showFixMatch",manual:!0,autohide:!0},".unmatch-btn":{modelAttribute:"showUnmatch",manual:!0,autohide:!0},".split-apart-btn":{modelAttribute:"showSplitApart",manual:!0,autohide:!0},".sync-btn":{modelAttribute:"showSync",manual:!0,autohide:!0},".download-btn":{modelAttribute:"showDownload",manual:!0,autohide:!0},".watch-later-btn":{modelAttribute:"showWatchLater",manual:!0,autohide:!0},".share-btn, .recommend-btn":{modelAttribute:"showShare",manual:!0,autohide:!0},".delete-btn":{modelAttribute:"showDelete",manual:!0,autohide:!0},".delete-from-user-playlist-btn":{modelAttribute:"showDeleteFromUserPlaylist",manual:!0,autohide:!0},".info-btn":{modelAttribute:"showInfo",manual:!0,autohide:!0}},onRender:function(){this.$el.tooltip({selector:".nav > li > a",container:"body",placement:"right"}),this.updateDropdown()
},onPlay:function(){this.ui.playBtn.isDisabled()&&this.ui.playAllBtn.isDisabled()||l.execute("playMedia",{items:this.mediaActions.getActionTargets()})},onPlayUnwatched:function(){this.ui.playUnwatchedBtn.isDisabled()||l.execute("playMedia",{items:this.mediaActions.getActionTargets(),unwatched:!0})},onPlayShuffled:function(){this.ui.playShuffledBtn.isDisabled()||l.execute("playMedia",{items:this.mediaActions.getActionTargets(),shuffle:!0})},onPlayTrailer:function(){if(!this.ui.playTrailerBtn.isDisabled()){var e=this.model.get("extras"),t=e.findWhere({key:this.model.get("primaryExtraKey")});
l.execute("playMedia",{items:[t]})}},onEdit:function(){this.ui.editBtn.isDisabled()||a.trigger("show:modal",new u({mediaActions:this.mediaActions}))},onRefresh:function(){this.ui.refreshBtn.isDisabled()||l.execute("refreshMetadata",{items:this.mediaActions.getActionTargets()})},onAnalyze:function(){this.ui.analyzeBtn.isDisabled()||l.execute("analyzeItems",{items:this.mediaActions.getActionTargets()})},onMarkWatched:function(){this.ui.markWatchedBtn.isDisabled()||l.execute("markWatched",{items:this.mediaActions.getActionTargets()})
},onMarkUnwatched:function(){this.ui.markUnwatchedBtn.isDisabled()||l.execute("markUnwatched",{items:this.mediaActions.getActionTargets()})},onSelect:function(){this.mediaActions.set("selecting",!0)},onDeselect:function(){this.mediaActions.set("selecting",!1)},onFixMatch:function(){a.trigger("show:modal",new h({model:this.model}))},onUnmatch:function(){l.execute("unmatch",{item:this.model})},onSplitApart:function(){l.execute("splitApart",{item:this.model})},onSync:function(){if(!this.ui.syncBtn.isDisabled()){var e=r.getMediaTypeByString(this.model.get("type")),t=this.mediaActions.getActionTargets(),i=t.length>1,n={model:this.model,type:e,isNew:!0,isSection:i,section:this.model.server.getSectionForItem(this.model),selectedItems:t};
l.execute("showSyncModal",n)}},onWatchLater:function(){this.ui.watchLaterBtn.isDisabled()||l.execute("watchLater",{items:this.mediaActions.getActionTargets()})},onShare:function(){this.ui.shareBtn.isDisabled()||a.trigger("show:modal",new p({model:this.model}))},onRecommend:function(){this.ui.recommendBtn.isDisabled()||a.trigger("show:modal",new m({model:this.model}))},onDelete:function(){this.ui.deleteBtn.isDisabled()||(this.model.get("playlistType")?l.execute("deletePlaylist",{item:this.model}):l.execute("deleteItems",{items:this.mediaActions.getActionTargets()}))
},onDeleteFromUserPlaylist:function(){if(!this.ui.deleteFromUserPlaylistBtn.isDisabled()){var e=this.model.destroy();e.done(t.bind(function(){i(".tooltip").remove(),a.trigger("navigate","userPlaylist",{key:this.model.get("playlist")})},this))}},onInfo:function(){this.ui.infoBtn.isDisabled()||a.trigger("show:modal",new f({model:this.model}))},onPlayNext:function(){this.ui.playNextBtn.isDisabled()||l.execute("queueMedia",{item:this.model,next:!0})},onAddToUpNext:function(){this.ui.addToUpNextBtn.isDisabled()||l.execute("queueMedia",{item:this.model,next:!1})
},onAddToPlaylist:function(){this.ui.addToPlaylistBtn.isDisabled()||a.trigger("show:modal",new d({model:this.model,items:this.mediaActions.getActionTargets()}))},onSelectedItemsChange:function(e,t){var i=s(t&&t.length?"Play selected":"Play All");this.ui.playBtn.attr("data-original-title",i)}});return y}),define("hb!templates/desktop/breadcrumbbar/DetailsBreadcrumbBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,o="";return o+='\n    <span id="section-list-dropdown" class="dropdown">\n      <a class="btn-gray dropdown-toggle" href="#section-list-dropdown" data-toggle="dropdown"><i class="glyphicon show-thumbnails"></i> <i class="caret-icon caret-icon-sm"></i></a>\n\n      <ul class="dropdown-menu pull-right">\n        <li><a class="list-btn" data-type="episode-tile-list" href="#">',a={hash:{},data:t},o+=g((n=i.t||e&&e.t,n?n.call(e,"Posters",a):f.call(e,"t","Posters",a)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',a={hash:{},inverse:v.noop,fn:v.program(2,r,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,e&&e.listType,"episode-tile-list",a):f.call(e,"if_neq",e&&e.listType,"episode-tile-list",a),(s||0===s)&&(o+=s),o+='"></i></a></li>\n        <li><a class="list-btn" data-type="episode-details-list" href="#">',a={hash:{},data:t},o+=g((n=i.t||e&&e.t,n?n.call(e,"Details",a):f.call(e,"t","Details",a)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',a={hash:{},inverse:v.noop,fn:v.program(2,r,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,e&&e.listType,"episode-details-list",a):f.call(e,"if_neq",e&&e.listType,"episode-details-list",a),(s||0===s)&&(o+=s),o+='"></i></a></li>\n        <li><a class="list-btn" data-type="episode-list" href="#">',a={hash:{},data:t},o+=g((n=i.t||e&&e.t,n?n.call(e,"List",a):f.call(e,"t","List",a)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',a={hash:{},inverse:v.noop,fn:v.program(2,r,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,e&&e.listType,"episode-list",a):f.call(e,"if_neq",e&&e.listType,"episode-list",a),(s||0===s)&&(o+=s),o+='"></i></a></li>\n      </ul>\n    </span>\n  '
}function r(){return"hidden"}function o(e,t){var n,s="";return s+='\n  <span id="section-dropdown" class="details-breadcrumb dropdown">\n\n    ',n=i["if"].call(e,e&&e.section,{hash:{},inverse:v.program(7,c,t),fn:v.program(5,l,t),data:t}),(n||0===n)&&(s+=n),s+='\n\n    <a class="btn-gray dropdown-toggle split-dropdown-toggle" href="#section-dropdown" data-toggle="dropdown">\n      <i class="caret-icon caret-icon-sm"></i>\n    </a>\n\n    <ul class="dropdown-menu">\n      ',n=i["if"].call(e,e&&e.showPlaylists,{hash:{},inverse:v.noop,fn:v.program(9,d,t),data:t}),(n||0===n)&&(s+=n),s+="\n\n      ",n=i.each.call(e,e&&e.sections,{hash:{},inverse:v.noop,fn:v.programWithDepth(12,h,t,e),data:t}),(n||0===n)&&(s+=n),s+="\n    </ul>\n  </span>\n"
}function l(e){var t,i="";return i+='\n      <a class="section-btn btn-gray" data-key="'+g((t=e&&e.section,t=null==t||t===!1?t:t.key,typeof t===y?t.apply(e):t))+'" href="#">'+g((t=e&&e.section,t=null==t||t===!1?t:t.title,typeof t===y?t.apply(e):t))+"</a>\n    "}function c(e,t){var n,s,a="";return a+='\n      <a class="playlists-btn btn-gray" href="#">',s={hash:{},data:t},a+=g((n=i.t||e&&e.t,n?n.call(e,"Playlists",s):f.call(e,"t","Playlists",s)))+"</a>\n    "}function d(e,t){var n,s,a,r="";return r+='\n        <li><a class="playlists-btn" href="#"><span class="dropdown-truncated-label">',a={hash:{},data:t},r+=g((n=i.t||e&&e.t,n?n.call(e,"Playlists",a):f.call(e,"t","Playlists",a)))+"</span>",s=i.unless.call(e,(n=e&&e.section,null==n||n===!1?n:n.key),{hash:{},inverse:v.noop,fn:v.program(10,u,t),data:t}),(s||0===s)&&(r+=s),r+="</a></li>\n      "
}function u(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}function h(e,t,n){var s,a,o,l="";return l+='\n        <li><a class="section-btn" data-key="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===y?s.call(e,{hash:{},data:t}):s),l+=g(s)+'" href="#"><span class="dropdown-truncated-label">',(s=i.title)?s=s.call(e,{hash:{},data:t}):(s=e&&e.title,s=typeof s===y?s.call(e,{hash:{},data:t}):s),l+=g(s)+'</span><i class="dropdown-selected-icon glyphicon ok-2 ',o={hash:{},inverse:v.noop,fn:v.program(2,r,t),data:t},s=i.if_neq||n&&n.if_neq,a=s?s.call(e,(s=n&&n.section,null==s||s===!1?s:s.key),e&&e.key,o):f.call(e,"if_neq",(s=n&&n.section,null==s||s===!1?s:s.key),e&&e.key,o),(a||0===a)&&(l+=a),l+='"></i></a></li>\n      '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var p,m="",f=i.helperMissing,g=this.escapeExpression,v=this,y="function";return m+='<div class="breadcrumb-actions pull-right">\n  ',p=i["if"].call(t,t&&t.listType,{hash:{},inverse:v.noop,fn:v.program(1,a,s),data:s}),(p||0===p)&&(m+=p),m+='\n\n  <a class="previous-btn btn-gray hidden" href="#"><i class="glyphicon chevron-left"></i></a>\n  <a class="next-btn btn-gray hidden" href="#"><i class="glyphicon chevron-right"></i></a>\n</div>\n\n',p=i["if"].call(t,t&&t.showSectionDropdown,{hash:{},inverse:v.noop,fn:v.program(4,o,s),data:s}),(p||0===p)&&(m+=p),m+='\n\n<span class="grandparent-item hidden"></span>\n<span class="parents-dropdown hidden"></span>\n<span class="siblings-dropdown hidden"></span>\n<span class="current-item hidden"></span>\n'
})}),define("hb!templates/desktop/dropdowns/BreadcrumbDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <a class="breadcrumb-btn btn-gray" data-key="'+p((n=e&&e.item,n=null==n||n===!1?n:n.key,typeof n===h?n.apply(e):n))+'" href="#"><span class="breadcrumb-truncated-label">'+p((n=e&&e.item,n=null==n||n===!1?n:n.title,typeof n===h?n.apply(e):n))+'</span></a>\n\n  <a class="btn-gray dropdown-toggle split-dropdown-toggle" href="#',(s=i.id)?s=s.call(e,{hash:{},data:t}):(s=e&&e.id,s=typeof s===h?s.call(e,{hash:{},data:t}):s),a+=p(s)+'" data-toggle="dropdown">\n    <i class="caret-icon caret-icon-sm"></i>\n  </a>\n\n  <ul class="dropdown-menu">\n    ',s=i.each.call(e,e&&e.items,{hash:{},inverse:m.noop,fn:m.programWithDepth(2,r,t,e),data:t}),(s||0===s)&&(a+=s),a+="\n  </ul>\n"
}function r(e,t,n){var s,a,r,l="";return l+='\n      <li><a class="breadcrumb-btn" data-key="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===h?s.call(e,{hash:{},data:t}):s),l+=p(s)+'" href="#"><span class="dropdown-truncated-label">',(s=i.title)?s=s.call(e,{hash:{},data:t}):(s=e&&e.title,s=typeof s===h?s.call(e,{hash:{},data:t}):s),l+=p(s)+'</span><i class="dropdown-selected-icon glyphicon ok-2 ',r={hash:{},inverse:m.noop,fn:m.program(3,o,t),data:t},s=i.if_neq||n&&n.if_neq,a=s?s.call(e,(s=n&&n.item,null==s||s===!1?s:s.key),e&&e.key,r):f.call(e,"if_neq",(s=n&&n.item,null==s||s===!1?s:s.key),e&&e.key,r),(a||0===a)&&(l+=a),l+='"></i></a></li>\n    '
}function o(){return"hidden"}function l(e,t){var n,s="";return s+='\n  <a class="breadcrumb-btn btn-gray" ',n=i.unless.call(e,e&&e.hasDetails,{hash:{},inverse:m.noop,fn:m.program(6,c,t),data:t}),(n||0===n)&&(s+=n),s+=' href="#">\n    <span class="breadcrumb-truncated-label">'+p((n=e&&e.item,n=null==n||n===!1?n:n.title,typeof n===h?n.apply(e):n))+"</span>\n  </a>\n"}function c(e){var t,i="";return i+='data-key="'+p((t=e&&e.item,t=null==t||t===!1?t:t.key,typeof t===h?t.apply(e):t))+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var d,u="",h="function",p=this.escapeExpression,m=this,f=i.helperMissing;return d=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:m.program(5,l,s),fn:m.program(1,a,s),data:s}),(d||0===d)&&(u+=d),u+="\n"})}),define("plex/desktop/views/dropdowns/BreadcrumbDropdown",["hb!templates/desktop/dropdowns/BreadcrumbDropdown.tpl","jquery","marionette","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";var s=i.ItemView.extend({tagName:"span",className:"details-breadcrumb dropdown",template:e,events:{"click .breadcrumb-btn":"onClick"},initialize:function(e){this.listenTo(this.model,"change:title",this.render),this.isLeaf=e&&e.isLeaf||!1
},serializeData:function(){var e=this.collection&&this.collection.length>1;return{id:this.id,item:this.model.toJSON(),items:e?this.collection.toJSON():null,hasDetails:this.isLeaf,showDropdown:e}},onClick:function(e){e.preventDefault();var i=t(e.currentTarget).data("key");i&&n.trigger("navigate","details",{serverID:this.model.server.id,key:i})}});return s}),define("plex/desktop/views/breadcrumbbar/DetailsBreadcrumbBarView",["hb!templates/desktop/breadcrumbbar/DetailsBreadcrumbBarView.tpl","jquery","marionette","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/models/library/MetadataModel","plex/desktop/views/dropdowns/BreadcrumbDropdown"],function(e,t,i,n,s,a,r){"use strict";
var o=i.Layout.extend({className:"details-breadcrumb-bar breadcrumb-bar",template:e,ui:{previousBtn:".previous-btn",nextBtn:".next-btn",listSelectedIcons:"#section-list-dropdown .dropdown-selected-icon"},regions:{currentItem:".current-item",grandparentItem:".grandparent-item",siblingsDropdown:".siblings-dropdown",parentsDropdown:".parents-dropdown"},events:{"click .playlists-btn":"onPlaylistsClick","click .section-btn":"onSectionClick","click .list-btn":"onListClick","click .previous-btn":"onPreviousClick","click .next-btn":"onNextClick"},onlyAfterRender:["onSiblingsPopulate","onParentsPopulate"],initialize:function(){var e=this.model.get("parentKey");
if(!e)return void this.onSiblingsPopulate(!1);var t,i={server:this.model.server,section:this.model.section},n=this.parent=new a({key:e},i),s=n.populate({scope:"page"});s=s.then(function(){return t=n.get("children"),t.populate({scope:"page"})}),s.done(this.onSiblingsPopulate);var r=this.model.get("grandparentKey");if(r){var o=this.grandparent=new a({key:r},i),l=o.populate({scope:"page"});l=l.then(function(){var e=o.get("children");return e.populate({scope:"page"})}),l.done(this.onParentsPopulate)}},serializeData:function(){var e=this.model.server,t=this.model.section,i=t||this.model.get("playlistType");
return{serverID:e.id,showSectionDropdown:i,showPlaylists:this.model.server.supports("playlists"),sections:e.get("sections").toJSON(),section:t?t.toJSON():null,item:this.model.toJSON(),parent:this.parent?this.parent.toJSON():null,grandparent:this.grandparent?this.grandparent.toJSON():null,listType:this.getListType()}},getListTypeSettingKey:function(){var e="episodeListType",t=this.model.section||this.model.server;return t.getScopedKey(e)},getListType:function(){return"season"===this.model.get("type")?s.get(this.getListTypeSettingKey())||"episode-tile-list":null
},previous:function(){this.previousSibling&&n.trigger("navigate","details",{serverID:this.model.server.id,key:this.previousSibling.get("key")})},next:function(){this.nextSibling&&n.trigger("navigate","details",{serverID:this.model.server.id,key:this.nextSibling.get("key")})},onSiblingsPopulate:function(e){if(!e)return this.currentItem.show(new r({model:this.model,isLeaf:!0})),void this.currentItem.$el.removeClass("hidden");var t=e.get(this.model.id),i=e.indexOf(t);i>0&&(this.previousSibling=e.at(i-1)),i<e.length-1&&(this.nextSibling=e.at(i+1)),this.ui.previousBtn.toggleClass("disabled",!this.previousSibling),this.ui.nextBtn.toggleClass("disabled",!this.nextSibling),this.ui.previousBtn.removeClass("hidden"),this.ui.nextBtn.removeClass("hidden"),this.grandparent||(this.grandparentItem.show(new r({model:this.parent})),this.grandparentItem.$el.removeClass("hidden")),this.siblingsDropdown.show(new r({id:"siblings-dropdown",model:this.model,collection:e})),this.siblingsDropdown.$el.removeClass("hidden")
},onParentsPopulate:function(e){this.grandparentItem.show(new r({model:this.grandparent})),this.grandparentItem.$el.removeClass("hidden"),this.parentsDropdown.show(new r({id:"parents-dropdown",model:this.parent,collection:e})),this.parentsDropdown.$el.removeClass("hidden")},onSectionClick:function(e){e.preventDefault();var i=t(e.currentTarget),s=i.data("key");n.trigger("navigate","section",{serverID:this.model.server.id,sectionID:s})},onPlaylistsClick:function(e){e.preventDefault(),n.trigger("navigate","playlists",{serverID:this.model.server.id})
},onListClick:function(e){e.preventDefault();var i=t(e.currentTarget),n=i.data("type");s.save(this.getListTypeSettingKey(),n),this.ui.listSelectedIcons.addClass("hidden"),i.find(".dropdown-selected-icon").removeClass("hidden")},onPreviousClick:function(e){e.preventDefault(),this.previous()},onNextClick:function(e){e.preventDefault(),this.next()}});return o}),define("hb!templates/desktop/details/MovieDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="details-title-container">\n  <h1 class="item-title"></h1>\n  <h2 class="item-year"></h2>\n</div>\n\n<div class="details-metadata-container">\n  <div class="movie-details-metadata-container">\n    <div class="details-progress-container">\n      <div class="item-progress details-progress"></div>\n    </div>\n\n    <div class="metadata-right pull-right">\n      <div class="item-genre metadata-tags"></div>\n\n      <div class="rating-container"></div>\n\n      <div class="content-rating-flag-container"></div>\n    </div>\n\n    <p class="metadata-labels">\n      <span class="item-duration metadata-duration"></span> <span class="item-unwatched-label label label-primary">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unwatched",r):l.call(t,"t","Unwatched",r)))+'</span> <a class="item-unavailable-btn label label-btn label-danger" href="#"><i class="label-icon glyphicon circle-info"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unavailable",r):l.call(t,"t","Unavailable",r)))+'</a>\n    </p>\n\n    <p class="item-tagline metadata-tagline"></p>\n\n    <div class="item-director metadata-tags">\n      <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Director",r):l.call(t,"t","Director",r)))+'</span> <span class="metadata-tag-list"></span>\n    </div>\n    <div class="item-writer metadata-tags">\n      <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Writer",r):l.call(t,"t","Writer",r)))+'</span> <span class="metadata-tag-list"></span>\n    </div>\n    <div class="item-cast metadata-tags">\n      <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Cast",r):l.call(t,"t","Cast",r)))+'</span> <span class="metadata-tag-list"></span>\n    </div>\n\n    <div class="item-audio metadata-tags metadata-tags-separator">\n      <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Audio",r):l.call(t,"t","Audio",r)))+'</span>\n    </div>\n    <div class="item-subtitles metadata-tags">\n      <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Subtitles",r):l.call(t,"t","Subtitles",r)))+'</span>\n    </div>\n\n    <div class="summary-container"></div>\n\n    <div class="studio-flag-container"></div>\n  </div>\n\n  <div class="extras-region hidden">\n    <h3 class="extras-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Extras",r):l.call(t,"t","Extras",r)))+'</h3>\n  </div>\n</div>\n\n<div class="details-poster-container">\n  <a class="media-poster-container play-btn" href="#">\n    <div class="movie-poster item-poster media-poster">\n      <div class="media-poster-overlay"></div>\n      <div class="media-poster-overlay-icons">\n        <i class="media-poster-overlay-icon glyphicon play"></i>\n      </div>\n\n      <span class="media-count-badge badge badge-lg hidden"></span>\n    </div>\n  </a>\n\n  <div class="video-audio-flags-container media-flags"></div>\n</div>\n'
})}),define("plex/base/utils/formatters/tagUtil",["underscore","plex/base/utils/formatters/stringUtil","plex/base/utils/types/mediaTypes"],function(e,t,i){"use strict";var n={truncateTagList:function(i){var n=i.tags,s=i.separator||", ",a="";if(n&&n.length){var r=i.maxTags||n.length;r>n.length&&(r=n.length);for(var o=0;r>o;o++){var l=n[o],c=e.escape(t.truncate(l.tag,i.maxLen));"undefined"!=typeof l.tag&&""!==l.tag&&(a+=c,r>o+1&&(a+=s))}}return a},truncateLinkedTagList:function(n){var s=n.model.section,a=i.getMediaTypeByString(n.model.get("type")),r=n.tags,o=s&&s.get("allowAdvancedFilters"),l="",c=function(i){var r=e.escape(t.truncate(i.tag,n.maxLen));
if(!o||!i.id)return r;var l=["#!/server/"+encodeURIComponent(s.server.id),"/section/"+encodeURIComponent(s.id),"/filter","/"+encodeURIComponent(a.id),"/"+encodeURIComponent(n.key),"/"+encodeURIComponent(i.id),"/"+encodeURIComponent(i.tag)];return'<a class="pivot-link" href="'+l.join("")+'">'+r+"</a>"};if(r&&r.length){var d=n.maxTags||r.length;d>r.length&&(d=r.length);for(var u=0;d>u;u++){var h=r[u];"undefined"!=typeof h.tag&&""!==h.tag&&(l+=c(h),d>u+1&&(l+=", "))}}return l}};return n}),define("plex/base/mixins/details/baseDetailsMixin",["underscore","plex/base/utils/mediaUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/utils/formatters/tagUtil"],function(e,t,i,n){"use strict";
var s={tagsRenderer:n.truncateLinkedTagList,tagsRendererOptions:{},defaultBindings:{".item-title":{modelAttribute:"title"},".item-year":{modelAttribute:"year"},".item-progress":{modelAttribute:"viewOffset",manual:!0,formatter:function(e,t){var i=this.model.get("duration"),n=!(!e||!i);if(n){var s=Math.round(e/i*100);t.css("width",s+"%")}t.parent().toggleClass("hidden",!n)}},".item-duration":{modelAttribute:"duration",autohide:!0,formatter:function(e){return e?i.formatHoursMinutes(e):0}},".item-unwatched-label":{modelAttribute:"viewCount",modelListeners:["viewCount","viewOffset"],manual:!0,autohide:function(e){if(this.shared&&!this.multiuser)return!1;
var t=this.model.get("viewOffset");return!e&&!t}},".item-unavailable-btn":{modelAttribute:"Media",manual:!0,autohide:function(e){var i=t.getMissingParts(e);return!!i.length}},".item-available-at":{modelAttribute:"originallyAvailableAt",autohide:!0,formatter:function(e){return e?i.formatDate(e):""}},".item-tagline":{modelAttribute:"tagline",autohide:!0},".item-genre":{modelAttribute:"Genre",autohide:!0,isHtml:!0,formatter:function(t){if(!t||!t.length)return"";var i=this.tagsRenderer(e.extend({},this.tagsRendererOptions,{model:this.model,key:"genre",tags:t,maxLen:50,maxTags:2}));
return i}},".item-director":{modelAttribute:"Director",manual:!0,autohide:!0,formatter:function(t,i){if(!t||!t.length)return"";var n=this.tagsRenderer(e.extend({},this.tagsRendererOptions,{model:this.model,key:"director",tags:t,maxLen:50,maxTags:3}));return i.find(".metadata-tag-list").html(n),n}},".item-writer":{modelAttribute:"Writer",manual:!0,autohide:!0,formatter:function(t,i){if(!t||!t.length)return"";var n=this.tagsRenderer(e.extend({},this.tagsRendererOptions,{model:this.model,key:"writer",tags:t,maxLen:50,maxTags:3}));
return i.find(".metadata-tag-list").html(n),n}},".item-cast":{modelAttribute:"Role",manual:!0,autohide:!0,formatter:function(t,i){if(!t||!t.length)return"";var n=this.tagsRenderer(e.extend({},this.tagsRendererOptions,{model:this.model,key:"actor",tags:t,maxLen:50,maxTags:5}));return i.find(".metadata-tag-list").html(n),n}},".item-summary":{modelAttribute:"summary",autohide:!0},".item-content-rating":{modelAttribute:"contentRating",autohide:!0},".media-count-badge":{modelAttribute:"Media",formatter:function(e){return e.length
},autohide:function(e){return e>1}},".details-unwatched-count-badge":{modelAttribute:"unviewedLeafCount",autohide:function(e){return this.shared&&!this.multiuser?!1:!!e}},".content-rating-flag-container":{modelAttribute:"contentRating",manual:!0,autohide:!0},".studio-flag-container":{modelAttribute:"studio",manual:!0,autohide:!0}}};return s}),define("plex/base/mixins/details/movieDetailsMixin",["underscore","plex/base/mixins/details/baseDetailsMixin"],function(e,t){"use strict";var i={bindings:e.pick(t.defaultBindings,[".item-title",".item-year",".item-progress",".item-duration",".item-unwatched-label",".item-unavailable-btn",".item-tagline",".item-genre",".item-director",".item-writer",".item-cast",".item-content-rating",".media-count-badge",".content-rating-flag-container",".studio-flag-container"])};
return i}),define("plex/desktop/views/details/BaseDetailsView",["underscore","backbone","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/utils/types/mediaTypes","plex/base/adapters/playerControllerAdapter","plex/base/mixins/details/baseDetailsMixin","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/modals/MediaInfoModal"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";var h=i.Layout.extend({mixins:l,posterWidth:250,ui:{poster:".item-poster"},regions:{rating:".rating-container",summary:".summary-container",audio:".item-audio",subtitles:".item-subtitles",studio:".studio-flag-container",contentRating:".content-rating-flag-container",videoResolution:".video-audio-flags-container",audioCodec:".video-audio-flags-container",audioChannels:".video-audio-flags-container",poster:".details-poster-container",list:".details-list-region"},events:{"click .details-poster-container > .play-btn":"onPlayClick","click .item-unavailable-btn":"onUnavailableClick"},initialize:function(i){e.bindAll(this,"onResize","onScroll"),this.mediaActions=i.mediaActions,this.collection=this.model.get("children"),this.shared=this.model.server.get("shared"),this.synced=this.model.server.get("synced"),this.multiuser=this.model.server.get("multiuser"),this.progress=new t.Model({loading:!1,failed:!1}),this.listenTo(d,"change:primaryPlayer",this.onPrimaryPlayerChange),this.pageSize&&(s.trigger("content.subscribe:resize",this.onResize),s.trigger("content.subscribe:scroll",this.onScroll)),this.mirror()
},serializeData:function(){var e=this.model.server.get("playQueueManager"),t=this.model.get("grandparentKey"),i=this.model.get("parentKey");return{serverID:this.model.server.id,grandparentKey:i?encodeURIComponent(t):null,parentKey:i?encodeURIComponent(i):null,canPlay:e.canCreateFor(this.model),limited:this.shared||this.synced}},mirror:function(){if(this.allowMirror){var e;e=this.model.get("isPlaylist")?this.model.get("playlistType"):r.getChildMediaType(this.model.get("type")).element;var t=a.getTypeByElement(e),i=o.getInstance(t);
i&&i.mirror({item:this.model})}},populatePage:function(){this.progress.set("loading",!0);var t=this.collection.populateRange({start:0,end:this.collection.length+this.pageSize,scope:"page"});return t.always(e.bind(function(){this.progress.set("loading",!1)},this)),t},onRender:function(){if(this.collection&&this.ListConstructor){var t;t=this.pageSize?this.populatePage():this.collection.fetch({scope:"page"}),t.fail(e.bind(function(){s.trigger("show:alert",{type:"error",message:n("There was a problem loading these items.")}),this.progress.set("failed",!0)
},this)),this.list.append(new this.ListConstructor({model:this.model,mediaActions:this.mediaActions,collection:this.collection,itemViewOptions:this.listItemViewOptions}))}this.ratingView&&this.rating.show(this.ratingView),this.audioDropdown&&this.audio.append(this.audioDropdown),this.subtitlesDropdown&&this.subtitles.append(this.subtitlesDropdown),this.posterImage&&this.posterImage.setElement(this.ui.poster),this.studioFlag&&this.studio.show(this.studioFlag),this.contentRatingFlag&&this.contentRating.show(this.contentRatingFlag),this.videoResolutionFlag&&this.videoResolution.append(this.videoResolutionFlag),this.audioCodecFlag&&this.audioCodec.append(this.audioCodecFlag),this.audioChannelsFlag&&this.audioChannels.append(this.audioChannelsFlag),this.summaryView&&this.summary.append(this.summaryView)
},onClose:function(){this.posterImage&&this.posterImage.close(),this.pageSize&&(s.trigger("content.unsubscribe:resize",this.onResize),s.trigger("content.unsubscribe:scroll",this.onScroll))},onPrimaryPlayerChange:function(e,t){t&&this.mirror()},onPlayClick:function(e){e.preventDefault(),c.execute("playMedia",{item:this.model})},onUnavailableClick:function(e){e.preventDefault(),s.trigger("show:modal",new u({model:this.model}))},onResize:function(e){this.containerSize=e},onScroll:function(e){if(!this.progress.get("loading")){var t=this.model.get("children"),i=e.scrollHeight-this.containerSize.innerHeight,n=i-e.scrollTop<10,s=t.length<t.totalSize;
n&&s&&this.populatePage()}}});return h}),define("hb!templates/desktop/details/components/SummaryView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<p class="item-summary metadata-summary"></p>\n\n<div class="summary-divider hidden">\n  <button type="button" class="summary-divider-btn">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"More",r):l.call(t,"t","More",r)))+"</button>\n</div>\n"
})}),define("plex/desktop/views/details/components/SummaryView",["hb!templates/desktop/details/components/SummaryView","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t,i,n,s,a){"use strict";var r=n.ItemView.extend({className:"summary",template:e,ui:{summary:".metadata-summary",divider:".summary-divider",dividerBtn:".summary-divider-btn"},events:{"click .summary-divider-btn":"onMoreSummaryClick"},onlyAfterRender:["onDeferredRender","updateDividerBtnVisibility"],bindings:{".item-summary":{modelAttribute:"summary",autohide:!0,isHtml:!0,formatter:function(e){this.$el.toggleClass("hidden",!e),this.updateDividerBtnVisibility();
var n=t.map(t.compact(e.split("\n")),function(e){return i.trim(t.escape(e))});return n.length?"<p>"+n.join("</p><p>")+"</p>":void 0}}},initialize:function(){this.listenTo(a,"resize",this.onResize)},updateDividerBtn:function(e){var t=s(e?"More":"Less");this.ui.dividerBtn.html(t)},updateDividerBtnVisibility:function(){if(this.originalHeight){var e=this.ui.summary.prop("scrollHeight");e<=this.originalHeight?this.ui.divider.addClass("hidden"):(this.updateDividerBtn(!this.expanded),this.ui.divider.removeClass("hidden"))
}},onRender:function(){t.defer(t.bind(this.onDeferredRender,this))},onDeferredRender:function(){this.expanded=!1;var e=this.ui.summary.prop("scrollHeight"),t=this.ui.summary.prop("clientHeight");this.originalHeight=t,e>t&&(this.ui.summary.css("max-height",t+"px"),this.ui.divider.removeClass("hidden"))},onResize:function(){this.isClosed||this.updateDividerBtnVisibility()},onMoreSummaryClick:function(){var e=this.ui.summary.prop("scrollHeight")+100;this.expanded?(this.ui.summary.css("max-height",this.originalHeight+"px"),this.expanded=!1):(this.ui.summary.css("max-height",e+"px"),this.expanded=!0),this.updateDividerBtn(!this.expanded)
}});return r}),define("hb!templates/desktop/dropdowns/StreamDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,o="";return o+='\n  <a class="dropdown-toggle" href="#',(n=i.type)?n=n.call(e,{hash:{},data:t}):(n=e&&e.type,n=typeof n===d?n.call(e,{hash:{},data:t}):n),o+=u(n)+'-dropdown" data-toggle="dropdown">\n    ',a={hash:{},data:t},o+=u((n=i.formatStreamLanguage||e&&e.formatStreamLanguage,n?n.call(e,e&&e.type,e&&e.selectedStream,a):h.call(e,"formatStreamLanguage",e&&e.type,e&&e.selectedStream,a)))+'\n    <i class="caret-icon caret-icon-sm"></i>\n  </a>\n  <ul class="dropdown-menu">\n    ',s=i.each.call(e,e&&e.streams,{hash:{},inverse:p.noop,fn:p.programWithDepth(2,r,t,e),data:t}),(s||0===s)&&(o+=s),o+="\n  </ul>\n"
}function r(e,t,n){var s,a,r,l="";return l+='\n      <li>\n        <a data-id="',(s=i.id)?s=s.call(e,{hash:{},data:t}):(s=e&&e.id,s=typeof s===d?s.call(e,{hash:{},data:t}):s),l+=u(s)+'" href="#">\n          ',r={hash:{},data:t},l+=u((s=i.formatStreamLanguage||n&&n.formatStreamLanguage,s?s.call(e,n&&n.type,e,r):h.call(e,"formatStreamLanguage",n&&n.type,e,r)))+"\n          ",a=i["if"].call(e,e&&e.selected,{hash:{},inverse:p.noop,fn:p.program(3,o,t),data:t}),(a||0===a)&&(l+=a),l+="\n        </a>\n      </li>\n    "
}function o(){return'\n            <i class="dropdown-selected-icon glyphicon ok-2"></i>\n          '}function l(e,t){var n,s,a="";return a+="\n  ",s={hash:{},data:t},a+=u((n=i.formatStreamLanguage||e&&e.formatStreamLanguage,n?n.call(e,e&&e.type,e&&e.selectedStream,s):h.call(e,"formatStreamLanguage",e&&e.type,e&&e.selectedStream,s)))+"\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:p.program(5,l,s),fn:p.program(1,a,s),data:s}),c||0===c?c:""
})}),define("plex/desktop/views/dropdowns/StreamDropdown",["hb!templates/desktop/dropdowns/StreamDropdown.tpl","underscore","jquery","marionette","plex/base/utils/mediaUtil","plex/base/utils/types/streamTypes","plex/base/commands/commands"],function(e,t,i,n,s,a,r){"use strict";var o=n.ItemView.extend({tagName:"span",className:"dropdown",template:e,modelEvents:{"change:Media":"render","change:streams":"render"},events:{"click .dropdown-menu a":"onStreamClick"},initialize:function(e){this.streamType=a.getStreamTypeByString(e.type),this.disabled=e.disabled
},serializeData:function(){var e=this.model.server.get("multiuser"),i=this.model.server.get("shared"),n=t.first(this.model.get("Media")),a=s.getStreams(n,{streamType:this.streamType.id}),r=s.getStreams(n,{streamType:this.streamType.id,selected:!0}),o=t.first(r);return{showDropdown:!this.disabled&&a.length>1&&(!i||e),type:this.streamType.typeString,streams:a,selectedStream:o}},onRender:function(){this.$el.attr("id",this.streamType.typeString+"-dropdown")},onStreamClick:function(e){e.preventDefault();
var t=i(e.currentTarget),n=t.data("id");r.execute("selectStream",{item:this.model,streamType:this.streamType,streamID:n})}});return o}),define("plex/base/views/images/MediaFlagImage",["plex/base/views/images/BaseImage"],function(e){"use strict";var t=e.extend({setup:function(e){if(e.className&&this.$el.addClass(e.className),this.model=e.model,this.server=e.model.server,e.flag){var t=this.model.get("Media");this.flag=e.flag,t&&t.length&&(this.path=t[0][this.flag]),this.listenTo(this.model,"change:Media",this.onMediaChange)
}else this.flag=e.modelAttribute,this.path=this.model.get(this.flag),this.listenTo(this.model,"change:"+this.flag,this.onChange);this.prefix=this.model.get("mediaTagPrefix"),this.version=this.model.get("mediaTagVersion"),this.path&&(this.url=this.getUrl(this.path)),this.setDimensions(e)},getUrl:function(e){return this.prefix+this.flag+"/"+encodeURIComponent(e)+"?t="+this.version},onMediaChange:function(e,t){this.onChange(e,t&&t.length?t[0][this.flag]:null)}});return t}),define("hb!templates/desktop/lists/library/ExtraTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r="",o="function",l=this.escapeExpression;return r+='<a class="media-poster-container play-btn" href="',(a=i.url)?a=a.call(t,{hash:{},data:s}):(a=t&&t.url,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n    <div class="media-poster-overlay-icons">\n      <i class="media-poster-overlay-icon glyphicon play"></i>\n    </div>\n\n    <div class="media-progress"></div>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n'
})}),define("plex/desktop/views/lists/library/ExtraTileListItem",["hb!templates/desktop/lists/library/ExtraTileListItem.tpl","plex/base/utils/t","plex/base/utils/types/extraTypes","plex/desktop/views/lists/library/MediaListItem","plex/desktop/views/lists/library/MediaTileListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s,a){"use strict";var r=n.extend({className:"poster-item media-tile-list-item extra-tile-list-item",template:e,ui:s.prototype.ui,initialize:function(){n.prototype.initialize.apply(this,arguments),this.image=new a({model:this.model,type:"clip",width:250})
},bindings:{".media-title":{modelAttribute:"title"},".media-subtitle-1":{modelAttribute:"extraType",formatter:function(e){return e?t(i.getExtraType(e).title):void 0}}}});return r}),define("plex/desktop/views/lists/library/ExtraTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/ExtraTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list extra-tile-list",itemView:t});return i}),define("plex/desktop/views/details/MovieDetailsView",["hb!templates/desktop/details/MovieDetailsView.tpl","underscore","plex/base/mixins/details/movieDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/RatingView","plex/desktop/views/details/components/SummaryView","plex/desktop/views/dropdowns/StreamDropdown","plex/base/views/images/MediaPosterImage","plex/base/views/images/MediaFlagImage","plex/desktop/views/lists/library/ExtraTileList"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=n.extend({mixins:i,className:"movie-details-row details-row",template:e,allowMirror:!0,ui:t.extend({extrasRegion:".extras-region"},n.prototype.ui),regions:t.extend({extrasList:".extras-region"},n.prototype.regions),initialize:function(){n.prototype.initialize.apply(this,arguments),this.extras=this.model.get("extras"),this.extras&&this.listenTo(this.extras,"reset add remove",this.updateExtras),this.ratingView=new s({model:this.model}),this.summaryView=new a({model:this.model}),this.audioDropdown=new r({type:"audio",model:this.model}),this.subtitlesDropdown=new r({type:"subtitles",model:this.model}),this.posterImage=new o({model:this.model,type:this.model.get("type"),width:this.posterWidth}),this.contentRatingFlag=new l({model:this.model,modelAttribute:"contentRating",className:"content-rating-flag",width:70,height:30}),this.videoResolutionFlag=new l({model:this.model,flag:"videoResolution",className:"media-flag",width:100,height:20}),this.audioCodecFlag=new l({model:this.model,flag:"audioCodec",className:"media-flag",width:100,height:20}),this.audioChannelsFlag=new l({model:this.model,flag:"audioChannels",className:"media-flag",width:100,height:20}),this.studioFlag=new l({model:this.model,modelAttribute:"studio",className:"studio-flag",width:200,height:40})
},updateExtras:function(){this.ui.extrasRegion.toggleClass("hidden",!(this.extras&&this.extras.length))},onRender:function(){n.prototype.onRender.apply(this,arguments),this.extras&&(this.extrasList.append(new c({collection:this.extras})),this.updateExtras())}});return d}),define("hb!templates/desktop/details/ShowDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n  <a class="media-poster-container play-btn" href="#">\n    <div class="show-poster item-poster media-poster">\n      <div class="media-poster-overlay"></div>\n      <div class="media-poster-overlay-icons">\n        <i class="media-poster-overlay-icon glyphicon play"></i>\n      </div>\n\n      <span class="unwatched-count-badge details-unwatched-count-badge badge badge-lg hidden"></span>\n    </div>\n  </a>\n  '
}function r(){return'\n  <div class="show-poster item-poster media-poster">\n    <span class="unwatched-count-badge details-unwatched-count-badge badge badge-lg hidden"></span>\n  </div>\n  '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=this;return l+='<div class="details-title-container">\n  <h1 class="item-title"></h1>\n  <h2 class="item-year"></h2>\n</div>\n\n<div class="details-metadata-container">\n  <div class="show-details-metadata-container">\n    <div class="metadata-right pull-right">\n      <div class="item-genre metadata-tags"></div>\n    </div>\n\n    <p class="metadata-labels">\n      <span class="item-duration metadata-duration"></span>\n\n      <span class="rating-container rating-container-inline"></span>\n\n      <span class="content-rating-flag-container content-rating-flag-container-inline"></span>\n    </p>\n\n    <div class="summary-container"></div>\n\n    <div class="studio-flag-container"></div>\n  </div>\n\n  <div class="season-list-container details-list-region"></div>\n</div>\n\n<div class="details-poster-container">\n  ',o=i["if"].call(t,t&&t.canPlay,{hash:{},inverse:c.program(3,r,s),fn:c.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+="\n</div>\n"
})}),define("plex/base/mixins/details/showDetailsMixin",["underscore","plex/base/mixins/details/baseDetailsMixin"],function(e,t){"use strict";var i={bindings:e.pick(t.defaultBindings,[".item-title",".item-year",".item-duration",".item-genre",".item-content-rating",".details-unwatched-count-badge",".content-rating-flag-container",".studio-flag-container"])};return i}),define("hb!templates/desktop/lists/library/SeasonTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hide-actions"
}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=this,d="function",u=this.escapeExpression;return l+='<a class="media-poster-container ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='" href="',(o=i.url)?o=o.call(t,{hash:{},data:s}):(o=t&&t.url,o=typeof o===d?o.call(t,{hash:{},data:s}):o),l+=u(o)+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="media-poster-actions ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+='">\n      <button class="play-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="play-unwatched-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="more-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n\n    <span class="unwatched-count-badge badge badge-lg hidden"></span>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n\n<div class="media-actions-dropdown dropdown">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/SeasonTileListItem",["hb!templates/desktop/lists/library/SeasonTileListItem.tpl","underscore","plex/base/utils/t","plex/desktop/views/lists/library/MediaListItem","plex/desktop/views/lists/library/MediaTileListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s,a){"use strict";var r=n.extend({className:"poster-item media-tile-list-item",template:e,ui:s.prototype.ui,initialize:function(){n.prototype.initialize.apply(this,arguments),this.image=new a({model:this.model,type:"season",width:150})
},bindings:t.extend({},n.prototype.bindings,{".media-title":{modelAttribute:"title"},".media-subtitle-1":{modelAttribute:"leafCount",formatter:function(e){return null==e?"":1===e?i("{1} episode",e):i("{1} episodes",e)}},".unwatched-count-badge":{modelAttribute:"unviewedLeafCount",autohide:function(e){var t=this.model.server.get("shared"),i=this.model.server.get("multiuser");return t&&!i?!1:"album"===this.type?!1:!!e}}}),onMoreClick:function(){s.prototype.onMoreClick.apply(this,arguments)}});return r
}),define("plex/desktop/views/lists/library/SeasonTileList",["plex/desktop/mixins/multiselectListMixin","plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/SeasonTileListItem"],function(e,t,i){"use strict";var n=t.extend({mixins:[e],tagName:"ul",className:"tile-list media-tile-list season-tile-list",itemView:i});return n}),define("plex/desktop/views/details/ShowDetailsView",["hb!templates/desktop/details/ShowDetailsView.tpl","plex/base/mixins/details/showDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/RatingView","plex/desktop/views/details/components/SummaryView","plex/base/views/images/MediaPosterImage","plex/base/views/images/MediaFlagImage","plex/desktop/views/lists/library/SeasonTileList"],function(e,t,i,n,s,a,r,o){"use strict";
var l=i.extend({mixins:t,className:"show-details-row details-row",template:e,allowMirror:!0,initialize:function(){i.prototype.initialize.apply(this,arguments),this.ListConstructor=o,this.ratingView=new n({model:this.model}),this.summaryView=new s({model:this.model}),this.posterImage=new a({model:this.model,type:this.model.get("type"),width:this.posterWidth}),this.contentRatingFlag=new r({model:this.model,modelAttribute:"contentRating",className:"show-content-rating content-rating-flag",width:70,height:30}),this.studioFlag=new r({model:this.model,modelAttribute:"studio",className:"show-studio studio-flag",width:200,height:40})
}});return l}),define("hb!templates/desktop/details/SeasonDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<div class="details-title-container">\n  <h1><a class="show-title btn-metadata-link" href="#!/server/',(a=i.serverID)?a=a.call(t,{hash:{},data:s}):(a=t&&t.serverID,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"/details/",(a=i.parentKey)?a=a.call(t,{hash:{},data:s}):(a=t&&t.parentKey,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'"></a></h1>\n  <h2 class="season-title"></h2>\n</div>\n\n<div class="details-metadata-container">\n  <div class="media-actions-container title"></div>\n  <div class="summary-container"></div>\n  <div class="episode-list-container details-list-region"></div>\n</div>\n'
})}),define("hb!templates/desktop/lists/library/EpisodeTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hide-actions"}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=this,d="function",u=this.escapeExpression;return l+='<a class="media-poster-container ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='" href="',(o=i.url)?o=o.call(t,{hash:{},data:s}):(o=t&&t.url,o=typeof o===d?o.call(t,{hash:{},data:s}):o),l+=u(o)+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="media-poster-actions ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+='">\n      <button class="play-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="more-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n\n    <span class="media-count-badge badge badge-lg hidden"></span>\n\n    <div class="media-progress"></div>\n  </div>\n\n  <span class="unwatched-icon"></span>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n\n<div class="media-actions-dropdown dropdown">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/EpisodeTileListItem",["hb!templates/desktop/lists/library/EpisodeTileListItem.tpl","underscore","plex/base/utils/mediaUtil","plex/desktop/views/lists/library/MediaListItem","plex/desktop/views/lists/library/MediaTileListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s,a){"use strict";var r=n.extend({className:"poster-item media-tile-list-item episode-tile-list-item",template:e,ui:s.prototype.ui,bypassShowUnwatchedIconsSetting:!0,initialize:function(){n.prototype.initialize.apply(this,arguments),this.image=new a({model:this.model,type:"episode",width:250})
},bindings:t.extend({},n.prototype.bindings,{".media-title":{modelAttribute:"title"},".media-subtitle-1":{modelAttribute:"index",formatter:function(e){return i.getEpisodeIndex({episodePrefix:"Episode {1}",episodeIndex:e,date:this.model.get("originallyAvailableAt"),noLeadingZero:!0})}},".media-count-badge":{modelAttribute:"Media",formatter:function(e){return e&&e.length||0},autohide:function(e){return e>1}}}),onMoreClick:function(){s.prototype.onMoreClick.apply(this,arguments)}});return r}),define("plex/desktop/views/lists/library/EpisodeTileList",["plex/desktop/mixins/multiselectListMixin","plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/EpisodeTileListItem"],function(e,t,i){"use strict";
var n=t.extend({mixins:[e],tagName:"ul",className:"tile-list media-tile-list episode-tile-list",itemView:i});return n}),define("plex/desktop/views/lists/library/MediaDetailsList",["plex/desktop/mixins/multiselectListMixin","plex/desktop/views/lists/BaseList"],function(e,t){"use strict";var i=t.extend({mixins:[e]});return i}),define("hb!templates/desktop/lists/library/EpisodeDetailsListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"show-actions"}function r(){return"hidden"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=this,d="function",u=this.escapeExpression;return l+='<a class="episode-list-inner-item media-list-inner-item ',o=i["if"].call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='" href="',(o=i.url)?o=o.call(t,{hash:{},data:s}):(o=t&&t.url,o=typeof o===d?o.call(t,{hash:{},data:s}):o),l+=u(o)+'">\n  <div class="media-poster">\n    <span class="media-count-badge badge hidden"></span>\n    <span class="unwatched-count-badge badge hidden"></span>\n\n    <div class="media-progress"></div>\n  </div>\n\n  <div class="media-actions ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+='">\n    <button class="play-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n    <button class="edit-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n    <button class="more-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n  </div>\n\n  <span class="media-index media-heading secondary"></span>\n  <span class="media-title media-heading"></span>\n  <span class="unwatched-icon"></span>\n  <span class="media-context media-heading media-rating"></span>\n\n  <p class="media-tagline"></p>\n\n  <p class="media-summary"></p>\n</a>\n\n<div class="media-actions-dropdown dropdown pull-right">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/EpisodeDetailsListItem",["hb!templates/desktop/lists/library/EpisodeDetailsListItem.tpl","underscore","plex/base/utils/mediaUtil","plex/desktop/views/lists/library/MediaDetailsListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s){"use strict";var a=n.extend({className:"striped-list-item media-list-item media-details-list-item episode-details-list-item",template:e,showRating:!0,bypassShowUnwatchedIconsSetting:!0,createImageView:function(){this.image=new s({model:this.model,type:"episode",getUrl:this.getPosterUrl,height:110})
},getPosterUrl:function(e){return e},bindings:t.extend({},n.prototype.bindings,{".media-title":{modelAttribute:"title"},".media-index":{modelAttribute:"index",autohide:!0,formatter:function(e,t){return t.toggleClass("date",null==e),i.getEpisodeIndex({episodeIndex:e,date:this.model.get("originallyAvailableAt"),noLeadingZero:!0})}}})});return a}),define("plex/desktop/views/lists/library/EpisodeDetailsList",["plex/desktop/views/lists/library/MediaDetailsList","plex/desktop/views/lists/library/EpisodeDetailsListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"list media-list media-details-list episode-details-list show-context",itemView:t});return i}),define("plex/desktop/views/lists/library/MediaList",["plex/desktop/mixins/multiselectListMixin","plex/desktop/views/lists/BaseList"],function(e,t){"use strict";var i=t.extend({mixins:[e],onAddChild:function(e){this.forwardItemViewEvents(e)}});return i}),define("hb!templates/desktop/lists/library/EpisodeListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"show-actions"
}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=this,d="function",u=this.escapeExpression;return l+='<a class="episode-list-inner-item media-list-inner-item ',o=i["if"].call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='" href="',(o=i.url)?o=o.call(t,{hash:{},data:s}):(o=t&&t.url,o=typeof o===d?o.call(t,{hash:{},data:s}):o),l+=u(o)+'">\n  <span class="media-index media-heading secondary"></span>\n  <span class="media-title media-heading"></span>\n  <span class="unwatched-icon"></span>\n\n  <div class="media-actions ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+='">\n    <button class="play-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n    <button class="edit-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n    <button class="more-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n  </div>\n\n  <span class="media-context media-heading media-rating"></span>\n</a>\n\n<div class="media-actions-dropdown dropdown pull-right">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/EpisodeListItem",["hb!templates/desktop/lists/library/EpisodeListItem.tpl","underscore","plex/base/utils/mediaUtil","plex/desktop/views/lists/library/MediaListItem"],function(e,t,i,n){"use strict";var s=n.extend({className:"striped-list-item media-list-item episode-list-item",template:e,showRating:!0,bypassShowUnwatchedIconsSetting:!0,regions:{rating:".media-rating"},bindings:t.extend({},n.prototype.bindings,{".media-title":{modelAttribute:"title"},".media-index":{modelAttribute:"index",autohide:!0,formatter:function(e,t){return t.toggleClass("date",null==e),i.getEpisodeIndex({episodeIndex:e,date:this.model.get("originallyAvailableAt"),noLeadingZero:!0})
}}})});return s}),define("plex/desktop/views/lists/library/EpisodeList",["plex/desktop/views/lists/library/MediaList","plex/desktop/views/lists/library/EpisodeListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list media-list episode-list show-context",itemView:t});return i}),define("plex/desktop/views/details/SeasonDetailsView",["hb!templates/desktop/details/SeasonDetailsView.tpl","plex/base/adapters/settingsAdapter","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/details/components/SummaryView","plex/desktop/views/lists/library/EpisodeTileList","plex/desktop/views/lists/library/EpisodeDetailsList","plex/desktop/views/lists/library/EpisodeList"],function(e,t,i,n,s,a,r){"use strict";
var o=i.extend({className:"season-details-row details-row",template:e,allowMirror:!0,initialize:function(){i.prototype.initialize.apply(this,arguments),this.ListConstructor=this.getListConstructor(),this.summaryView=new n({model:this.model}),this.listenTo(t.getInstance(),"change:"+this.getListTypeSettingKey(),this.onListTypeChange)},getListTypeSettingKey:function(){var e="episodeListType",t=this.model.section||this.model.server;return t.getScopedKey(e)},getListConstructor:function(e){switch(e||(e=t.get(this.getListTypeSettingKey())),e){case"episode-details-list":return a;
case"episode-list":return r;default:return s}},bindings:{".show-title":{modelAttribute:"parentTitle"},".season-title":{modelAttribute:"title"}},onListTypeChange:function(e,t){this.ListConstructor=this.getListConstructor(t),this.render()}});return o}),define("hb!templates/desktop/details/EpisodeDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l="function",c=this.escapeExpression,d=i.helperMissing;
return o+='<div class="details-title-container">\n  <h1><a class="show-title btn-metadata-link" href="#!/server/',(a=i.serverID)?a=a.call(t,{hash:{},data:s}):(a=t&&t.serverID,a=typeof a===l?a.call(t,{hash:{},data:s}):a),o+=c(a)+"/details/",(a=i.grandparentKey)?a=a.call(t,{hash:{},data:s}):(a=t&&t.grandparentKey,a=typeof a===l?a.call(t,{hash:{},data:s}):a),o+=c(a)+'"></a></h1>\n  <h2 class="episode-title"></h2>\n  <h3 class="episode-index"></h3>\n</div>\n\n<div class="details-metadata-container">\n  <div class="details-progress-container">\n    <div class="item-progress details-progress"></div>\n  </div>\n\n  <div class="metadata-right pull-right">\n    <div class="item-available-at metadata-tags"></div>\n\n    <div class="rating-container"></div>\n\n    <div class="content-rating-flag-container"></div>\n  </div>\n\n  <p class="metadata-labels">\n    <span class="item-duration metadata-duration"></span> <span class="item-unwatched-label label label-primary">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unwatched",r):d.call(t,"t","Unwatched",r)))+'</span> <a class="item-unavailable-btn label label-btn label-danger" href="#"><i class="label-icon glyphicon circle-info"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Unavailable",r):d.call(t,"t","Unavailable",r)))+'</a>\n  </p>\n\n  <div class="item-director metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Director",r):d.call(t,"t","Director",r)))+'</span> <span class="metadata-tag-list"></span>\n  </div>\n  <div class="item-writer metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Writer",r):d.call(t,"t","Writer",r)))+'</span> <span class="metadata-tag-list"></span>\n  </div>\n  <div class="item-cast metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Cast",r):d.call(t,"t","Cast",r)))+'</span> <span class="metadata-tag-list"></span>\n  </div>\n\n  <div class="item-audio metadata-tags metadata-tags-separator">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Audio",r):d.call(t,"t","Audio",r)))+'</span>\n  </div>\n  <div class="item-subtitles metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Subtitles",r):d.call(t,"t","Subtitles",r)))+'</span>\n  </div>\n\n  <div class="summary-container"></div>\n</div>\n\n<div class="details-poster-container">\n  <a class="media-poster-container play-btn" href="#">\n    <div class="episode-poster item-poster media-poster">\n      <div class="media-poster-overlay"></div>\n      <div class="media-poster-overlay-icons">\n        <i class="media-poster-overlay-icon glyphicon play"></i>\n      </div>\n    </div>\n  </a>\n\n  <div class="video-audio-flags-container media-flags"></div>\n</div>\n'
})}),define("plex/base/mixins/details/episodeDetailsMixin",["underscore","plex/base/mixins/details/baseDetailsMixin","plex/base/utils/mediaUtil"],function(e,t,i){"use strict";var n={bindings:e.extend({".show-title":{modelAttribute:"grandparentTitle"},".episode-title":{modelAttribute:"title"},".episode-index":{modelAttribute:"index",formatter:function(e){return i.getSeasonEpisodeIndex({seasonIndex:this.model.get("parentIndex"),episodePrefix:" \xb7 E{1}",episodeIndex:e,date:this.model.get("originallyAvailableAt"),noLeadingZero:!0})
}}},e.pick(t.defaultBindings,[".item-year",".item-progress",".item-duration",".item-unwatched-label",".item-unavailable-btn",".item-available-at",".item-director",".item-writer",".item-cast",".item-content-rating",".media-count-badge",".content-rating-flag-container"]))};return n}),define("plex/desktop/views/details/EpisodeDetailsView",["hb!templates/desktop/details/EpisodeDetailsView.tpl","plex/base/mixins/details/episodeDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/RatingView","plex/desktop/views/details/components/SummaryView","plex/desktop/views/dropdowns/StreamDropdown","plex/base/views/images/MediaPosterImage","plex/base/views/images/MediaFlagImage"],function(e,t,i,n,s,a,r,o){"use strict";
var l=i.extend({mixins:t,className:"episode-details-row details-row",template:e,allowMirror:!0,initialize:function(){i.prototype.initialize.apply(this,arguments),this.ratingView=new n({model:this.model}),this.summaryView=new s({model:this.model}),this.audioDropdown=new a({type:"audio",model:this.model}),this.subtitlesDropdown=new a({type:"subtitles",model:this.model}),this.posterImage=new r({model:this.model,type:this.model.get("type"),width:this.posterWidth}),this.contentRatingFlag=new o({model:this.model,modelAttribute:"contentRating",className:"content-rating-flag",width:70,height:30}),this.videoResolutionFlag=new o({model:this.model,flag:"videoResolution",className:"media-flag",width:100,height:20}),this.audioCodecFlag=new o({model:this.model,flag:"audioCodec",className:"media-flag",width:100,height:20}),this.audioChannelsFlag=new o({model:this.model,flag:"audioChannels",className:"media-flag",width:100,height:20})
}});return l}),define("hb!templates/desktop/details/ArtistDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n  <a class="media-poster-container play-btn" href="#">\n    <div class="artist-poster item-poster media-poster">\n      <div class="media-poster-overlay"></div>\n      <div class="media-poster-overlay-icons">\n        <i class="media-poster-overlay-icon glyphicon play"></i>\n      </div>\n    </div>\n  </a>\n  '}function r(){return'\n    <div class="artist-poster item-poster media-poster"></div>\n  '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return d+='<div class="details-title-container">\n  <h1 class="item-title"></h1>\n</div>\n\n<div class="details-metadata-container">\n  <div class="artist-details-metadata-container">\n    <div class="metadata-right pull-right">\n      <div class="item-genre metadata-tags"></div>\n    </div>\n\n    <p class="metadata-labels">\n    </p>\n\n    <div class="summary-container"></div>\n  </div>\n\n  <div class="popular-tracks-region hidden">\n    <h3 class="popular-tracks-header">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Popular Tracks",c):u.call(t,"t","Popular Tracks",c)))+'</h3>\n  </div>\n\n  <div class="albums-region details-list-region">\n    <h3 class="albums-header">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Albums",c):u.call(t,"t","Albums",c)))+'</h3>\n  </div>\n\n  <div class="extras-region hidden">\n    <h3 class="extras-header">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Music Videos",c):u.call(t,"t","Music Videos",c)))+'</h3>\n  </div>\n\n  <div class="concert-region hidden">\n    <h3 class="concert-region-header">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"On Tour",c):u.call(t,"t","On Tour",c)))+'</h3>\n  </div>\n\n  <div class="similar-artists-region hidden">\n    <h3 class="similar-artists-header">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Similar Artists",c):u.call(t,"t","Similar Artists",c)))+'</h3>\n  </div>\n</div>\n\n<div class="details-poster-container">\n  ',l=i["if"].call(t,t&&t.canPlay,{hash:{},inverse:p.program(3,r,s),fn:p.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+="\n</div>\n"
})}),define("plex/base/mixins/details/artistDetailsMixin",["underscore","plex/base/mixins/details/baseDetailsMixin"],function(e,t){"use strict";var i={bindings:e.pick(t.defaultBindings,[".item-title",".item-genre"])};return i}),define("hb!templates/desktop/details/components/ConcertView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<a class="concert-link" target="_blank">\n  <div class="concert-calendar">\n    <div class="concert-month"></div>\n    <div class="concert-day"></div>\n  </div>\n  <div class="concert-details">\n    <div class="concert-name"></div>\n    <div class="concert-location">\n      <span class="concert-venue"></span>\n      (<span class="concert-city"></span>)\n    </div>\n  </div>\n</a>\n'
})}),define("plex/desktop/views/details/components/ConcertView",["hb!templates/desktop/details/components/ConcertView","underscore","marionette","moment"],function(e,t,i,n){"use strict";var s=i.ItemView.extend({className:"concert",template:e,bindings:{".concert-link":{modelAttribute:"url",manual:!0,formatter:function(e,t){t.attr("href",e)}},".concert-month":{modelAttribute:"at",formatter:function(e){return n.unix(e).format("MMM")}},".concert-day":{modelAttribute:"at",formatter:function(e){return n.unix(e).format("DD")
}},".concert-name":{modelAttribute:"tag"},".concert-venue":{modelAttribute:"venue"},".concert-city":{modelAttribute:"city",modelListeners:["city","country"],formatter:function(e){var i=t.compact([e,this.model.get("country")]);return i.join(", ")}}}});return s}),define("hb!templates/desktop/lists/library/ArtistTrackListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"selected"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o="",l=this,c="function",d=this.escapeExpression;
return o+='<div class="striped-list-inner-item media-list-item track-list-item track">\n  <a class="track-list-inner-item show-actions ',r=i["if"].call(t,t&&t.selected,{hash:{},inverse:l.noop,fn:l.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+='" href="#">\n    <div class="track-actions media-actions">\n      <button class="track-more-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n\n    <span class="track-index media-index media-heading secondary">\n      <span>',(r=i.index)?r=r.call(t,{hash:{},data:s}):(r=t&&t.index,r=typeof r===c?r.call(t,{hash:{},data:s}):r),o+=d(r)+'</span>\n      <i class="glyphicon volume-up"></i>\n    </span>\n    <span class="track-title media-title media-heading"></span>\n    <span class="track-subtitle-1 media-subtitle-1 media-heading secondary"></span>\n    <span class="track-context media-context media-heading secondary"></span>\n\n    <button class="track-music-video-btn media-action-btn btn-link" tabindex="-1"><i class="plex-icon display"></i></button>\n  </a>\n\n  <div class="track-actions-dropdown media-actions-dropdown dropdown pull-right">\n    <div class="dropdown-toggle" data-toggle="dropdown"></div>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/ArtistTrackListItem",["hb!templates/desktop/lists/library/ArtistTrackListItem.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/utils/formatters/dateTimeUtil","plex/base/commands/commands","plex/base/models/library/MetadataModel","plex/desktop/models/MediaActionsModel","plex/desktop/views/dropdowns/MediaActionsDropdown","plex/desktop/views/modals/EditMetadataModal"],function(e,t,i,n,s,a,r,o,l,c){"use strict";var d=n.ItemView.extend({tagName:"li",className:"striped-list-item",template:e,ui:{index:".track-index span",actions:".track-actions",dropdown:".track-actions-dropdown"},events:{"click .track-list-inner-item":"onClick","click .track-music-video-btn":"onMusicVideoClick","click .track-more-btn":"onMoreClick","hide.bs.dropdown .track-actions-dropdown":"onDropdownHide"},collectionEvents:{sort:"onCollectionSort"},initialize:function(e){t.bindAll(this,"onResize"),this.artistTitle=e.artistTitle,this.parentMediaActions=e.mediaActions,this.mediaActions=new l({},{item:this.model}),this.playQueueManager=this.model.server.get("playQueueManager"),this.listenTo(this.playQueueManager,"change:playQueue:audio",this.onPlayQueueChange),this.listenTo(this.playQueueManager,"remove:playQueue:audio",this.onRemovePlayQueue),this.onPlayQueueChange(this.playQueueManager.getFor(this.model)),s.trigger("content.subscribe:resize",this.onResize)
},serializeData:function(){return{index:this.getIndex(),selected:this.selected}},getIndex:function(){return this.collection.indexOf(this.model)+1},bindings:{".track-parent-index":{modelAttribute:"parentIndex"},".track-title":{modelAttribute:"title"},".track-subtitle-1":{modelAttribute:"originalTitle",autohide:function(e){var t=e&&this.artistTitle&&e.toLowerCase()!==this.artistTitle.toLowerCase();return this.$el.toggleClass("show-subtitle",!!t),t}},".track-context":{modelAttribute:"duration",autohide:!0,formatter:function(e){return e?a.formatDuration(e):!1
}},".track-music-video-btn":{model:"mediaActions",modelAttribute:"showPlayMusicVideo",manual:!0,autohide:!0}},onRender:function(){var e=this.playQueueManager.getFor(this.model);if(e){var t=e.get("selectedItem");t&&this.model.get("key")===t.get("key")&&this.$(".track-list-item").addClass("current-track")}},onClose:function(){this.dropdown&&this.dropdown.close(),s.trigger("content.unsubscribe:resize",this.onResize)},onResize:function(e){this.containerSize=e},onCollectionSort:function(){this.ui.index.text(this.getIndex())
},onClick:function(e){e.preventDefault(),r.execute("playMedia",{item:this.model,siblings:!0})},onMusicVideoClick:function(e){e.preventDefault(),e.stopImmediatePropagation();var i=this.model.server.getSectionForItem(this.model);if(!t.isEmpty(i)){var n=new o({key:this.model.get("primaryExtraKey"),type:"clip",librarySectionUUID:i.get("uuid")},{server:this.model.server,section:this.model.section});r.execute("playMedia",{item:n})}},onMoreClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.dropdown=new c({model:this.model}),this.ui.dropdown.append(this.dropdown.render().el),this.ui.dropdown.addClass("open"),this.$el.addClass("force-hover");
var t=i(e.currentTarget),n=this.ui.actions.position().top,s=this.dropdown.getPosition(t,this.containerSize,n);this.ui.dropdown.css(s)},onDropdownHide:function(){this.dropdown&&(this.dropdown.close(),this.dropdown=null,this.$el.removeClass("force-hover"))},onPlayQueueSelectedItemChange:function(e,t){var i=!(!t||this.model.get("key")!==t.get("key"));this.$(".track-list-item").toggleClass("current-track",i)},onPlayQueueChange:function(e){e&&this.listenTo(e,"change:selectedItem",this.onPlayQueueSelectedItemChange)
},onRemovePlayQueue:function(e){this.stopListening(e),this.$(".track-list-item").removeClass("current-track")}});return d}),define("plex/desktop/views/lists/library/ArtistTrackList",["underscore","plex/desktop/views/lists/library/MediaList","plex/desktop/views/lists/library/ArtistTrackListItem"],function(e,t,i){"use strict";var n=t.extend({tagName:"ul",className:"list media-list track-list show-context",itemView:i,itemViewOptions:function(){return{collection:this.collection}}});return n}),define("hb!templates/desktop/lists/library/AlbumTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hide-actions"
}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=this,d="function",u=this.escapeExpression;return l+='<a class="media-poster-container ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='" href="',(o=i.url)?o=o.call(t,{hash:{},data:s}):(o=t&&t.url,o=typeof o===d?o.call(t,{hash:{},data:s}):o),l+=u(o)+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="media-poster-actions ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:c.noop,fn:c.program(3,r,s),data:s}),(o||0===o)&&(l+=o),l+='">\n      <button class="play-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="more-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n\n<div class="media-actions-dropdown dropdown">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/AlbumTileListItem",["hb!templates/desktop/lists/library/AlbumTileListItem.tpl","underscore","plex/desktop/views/lists/library/MediaListItem","plex/desktop/views/lists/library/MediaTileListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s){"use strict";var a=i.extend({className:"poster-item media-tile-list-item",template:e,ui:n.prototype.ui,initialize:function(){i.prototype.initialize.apply(this,arguments),this.image=new s({model:this.model,type:"album",width:180})
},bindings:t.extend({},i.prototype.bindings,{".media-title":{modelAttribute:"title"},".media-subtitle-1":{modelAttribute:"year"}}),onMoreClick:function(){n.prototype.onMoreClick.apply(this,arguments)}});return a}),define("plex/desktop/views/lists/library/AlbumTileList",["plex/desktop/mixins/multiselectListMixin","plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/AlbumTileListItem"],function(e,t,i){"use strict";var n=t.extend({mixins:[e],tagName:"ul",className:"tile-list media-tile-list album-tile-list",itemView:i});
return n}),define("plex/desktop/views/details/ArtistDetailsView",["hb!templates/desktop/details/ArtistDetailsView.tpl","underscore","plex/base/utils/dispatcher","plex/base/utils/constants/timelineEvents","plex/base/mixins/details/artistDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/details/components/ConcertView","plex/desktop/views/details/components/SummaryView","plex/base/views/images/MediaPosterImage","plex/desktop/views/lists/library/ArtistTrackList","plex/desktop/views/lists/library/AlbumTileList","plex/desktop/views/lists/library/ExtraTileList"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=a.extend({mixins:s,className:"artist-details-row details-row",template:e,allowMirror:!0,ui:t.extend({concertRegion:".concert-region",popularTracksRegion:".popular-tracks-region",extrasRegion:".extras-region",similarArtistsRegion:".similar-artists-region"},a.prototype.ui),regions:t.extend({concert:".concert-region",popularTracksList:".popular-tracks-region",extrasList:".extras-region",similarArtistsList:".similar-artists-region"},a.prototype.regions),modelEvents:{"socket:timeline":"onTimeline","change:concerts":"onConcertsChange","change:related":"onRelatedChange"},initialize:function(){a.prototype.initialize.apply(this,arguments),this.bindAllWhenRendered("updateConcerts","showConcert","updatePopularTracks","updateExtras","updateSimilarArtists","showSimilarArtistsList"),this.ListConstructor=d,this.listItemViewOptions={mediaActions:this.mediaActions},this.popularLeaves=this.model.get("popularLeaves"),this.popularLeaves&&this.listenTo(this.popularLeaves,"reset add remove",this.updatePopularTracks),this.extras=this.model.get("extras"),this.extras&&this.listenTo(this.extras,"reset add remove",this.updateExtras),this.concerts=this.model.get("concerts"),this.concerts&&this.listenTo(this.concerts,"reset add remove",this.showConcert),this.related=this.model.get("related"),this.related&&this.listenTo(this.related,"reset add remove",this.showSimilarArtistsList),this.summaryView=new o({model:this.model}),this.posterImage=new l({model:this.model,type:this.model.get("type"),width:this.posterWidth})
},updatePopularTracks:function(){this.ui.popularTracksRegion.toggleClass("hidden",!(this.popularLeaves&&this.popularLeaves.length))},updateExtras:function(){this.ui.extrasRegion.toggleClass("hidden",!(this.extras&&this.extras.length))},updateConcerts:function(){this.ui.concertRegion.toggleClass("hidden",!(this.concerts&&this.concerts.length))},showConcert:function(){var e=this.concerts&&this.concerts.first();e?this.concert.append(new r({model:e})):this.concert.close(),this.updateConcerts()},updateSimilarArtists:function(){this.ui.similarArtistsRegion.toggleClass("hidden",!(this.similarArtists&&this.similarArtists.length))
},showSimilarArtistsList:function(){if(this.similarArtists&&(this.stopListening(this.similarArtists),this.similarArtists=null),this.related){var e=this.related.get("artist.similar");e&&(this.similarArtists=e.get("children"),this.similarArtistsList.append(new d({collection:this.similarArtists})),this.listenTo(this.similarArtists,"reset add remove",this.updateSimilarArtists))}this.updateSimilarArtists()},onRender:function(){a.prototype.onRender.apply(this,arguments),this.popularLeaves&&(this.popularTracksList.append(new c({collection:this.popularLeaves})),this.updatePopularTracks()),this.collection.populate({scope:"page"}).then(this.whenRendered(function(){this.extras&&(this.extrasList.append(new u({collection:this.extras})),this.updateExtras()),this.showConcert(),this.showSimilarArtistsList()
}))},onTimeline:function(e){e.state===n.DELETED&&i.trigger("navigate","section",{serverID:this.model.server.id,sectionID:this.model.section.id})},onConcertsChange:function(e,t){this.concerts&&this.stopListening(this.concerts),this.concerts=t,t&&this.listenTo(t,"reset add remove",this.showConcert),this.showConcert()},onRelatedChange:function(e,t){this.related&&this.stopListening(this.related),this.related=t,t&&this.listenTo(t,"reset add remove",this.showSimilarArtistsList),this.showSimilarArtistsList()
}});return h}),define("hb!templates/desktop/details/AlbumDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n  <a class="media-poster-container play-btn" href="#">\n    <div class="album-poster item-poster media-poster">\n      <div class="media-poster-overlay"></div>\n      <div class="media-poster-overlay-icons">\n        <i class="media-poster-overlay-icon glyphicon play"></i>\n      </div>\n    </div>\n  </a>\n  '}function r(){return'\n  <div class="album-poster item-poster media-poster"></div>\n  '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c="function",d=this.escapeExpression,u=this;return l+='<div class="details-title-container">\n  <h1><a class="artist-title btn-metadata-link" href="#!/server/',(o=i.serverID)?o=o.call(t,{hash:{},data:s}):(o=t&&t.serverID,o=typeof o===c?o.call(t,{hash:{},data:s}):o),l+=d(o)+"/details/",(o=i.parentKey)?o=o.call(t,{hash:{},data:s}):(o=t&&t.parentKey,o=typeof o===c?o.call(t,{hash:{},data:s}):o),l+=d(o)+'"></a></h1>\n  <h2 class="album-title"></h2>\n  <h3 class="item-year"></h3>\n</div>\n\n<div class="details-metadata-container">\n  <div class="metadata-right pull-right">\n    <div class="item-genre metadata-tags"></div>\n  </div>\n\n  <p class="metadata-labels">\n    <span class="rating-container rating-container-inline"></span>\n  </p>\n\n  <div class="summary-container"></div>\n\n  <div class="track-list-container details-list-region"></div>\n</div>\n\n<div class="details-poster-container">\n  ',o=i["if"].call(t,t&&t.canPlay,{hash:{},inverse:u.program(3,r,s),fn:u.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+="\n</div>\n"
})}),define("plex/base/mixins/details/albumDetailsMixin",["underscore","plex/base/mixins/details/baseDetailsMixin"],function(e,t){"use strict";var i={bindings:e.extend({".artist-title":{modelAttribute:"parentTitle"},".album-title":{modelAttribute:"title"}},e.pick(t.defaultBindings,[".item-year",".item-genre"]))};return i}),define("hb!templates/desktop/lists/library/TrackListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"selected"}function r(){return'\n        <button class="track-edit-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return d+='<div class="disc-number hidden">\n  ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Disc {1}",'<span class="track-parent-index"></span>',c):u.call(t,"t","Disc {1}",'<span class="track-parent-index"></span>',c)))+'\n</div>\n\n<div class="striped-list-inner-item media-list-item track-list-item track">\n  <a class="track-list-inner-item show-actions ',l=i["if"].call(t,t&&t.selected,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='" href="#">\n    <div class="track-actions media-actions">\n      ',l=i["if"].call(t,t&&t.showEdit,{hash:{},inverse:p.noop,fn:p.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='\n      <button class="track-more-btn media-action-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n\n    <span class="track-index media-index media-heading secondary">\n      <span></span>\n      <i class="glyphicon volume-up"></i>\n    </span>\n    <span class="track-title media-title media-heading"></span>\n    <span class="track-subtitle-1 media-subtitle-1 media-heading secondary"></span>\n    <span class="track-context media-context media-heading secondary"></span>\n\n    <button class="track-music-video-btn media-action-btn btn-link" tabindex="-1"><i class="plex-icon display"></i></button>\n  </a>\n\n  <div class="track-actions-dropdown media-actions-dropdown dropdown pull-right">\n    <div class="dropdown-toggle" data-toggle="dropdown"></div>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/lists/library/TrackListItem",["hb!templates/desktop/lists/library/TrackListItem.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/utils/formatters/dateTimeUtil","plex/base/commands/commands","plex/desktop/mixins/multiselectListItemMixin","plex/base/models/library/MetadataModel","plex/desktop/models/MediaActionsModel","plex/desktop/views/dropdowns/MediaActionsDropdown","plex/desktop/views/modals/EditMetadataModal"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=n.ItemView.extend({mixins:[o],tagName:"li",template:e,className:"striped-list-item",ui:{actions:".track-actions",container:".track-list-inner-item",dropdown:".track-actions-dropdown"},events:{"mousenter .track-list-inner-item":"onMouseEnter","mouseleave .track-list-inner-item":"onMouseLeave","mousedown .track-list-inner-item":"onMouseDown","click .track-list-inner-item":"onClick","click .track-music-video-btn":"onMusicVideoClick","click .track-edit-btn":"onEditClick","click .track-more-btn":"onMoreClick","hide.bs.dropdown .track-actions-dropdown":"onDropdownHide"},onlyAfterRender:["select","deselect"],initialize:function(e){t.bindAll(this,"onResize"),this.artistTitle=e.artistTitle,this.parentMediaActions=e.mediaActions,this.mediaActions=new c({},{item:this.model}),this.playQueueManager=this.model.server.get("playQueueManager"),this.listenTo(this.playQueueManager,"change:playQueue:audio",this.onPlayQueueChange),this.listenTo(this.playQueueManager,"remove:playQueue:audio",this.onRemovePlayQueue),this.onPlayQueueChange(this.playQueueManager.getFor(this.model)),s.trigger("content.subscribe:resize",this.onResize)
},serializeData:function(){return this.shared=this.model.server.get("shared"),this.synced=this.model.server.get("synced"),{showEdit:!this.shared&&!this.synced,selected:this.selected}},bindings:{".track-index span":{modelAttribute:"index",formatter:function(e){return 1>e?"":e}},".track-parent-index":{modelAttribute:"parentIndex"},".track-title":{modelAttribute:"title"},".track-subtitle-1":{modelAttribute:"originalTitle",autohide:function(e){var t=e&&this.artistTitle&&e.toLowerCase()!==this.artistTitle.toLowerCase();
return this.$el.toggleClass("show-subtitle",!!t),t}},".track-context":{modelAttribute:"duration",autohide:!0,formatter:function(e){return e?a.formatDuration(e):!1}},".track-music-video-btn":{model:"mediaActions",modelAttribute:"showPlayMusicVideo",manual:!0,autohide:!0}},onRender:function(){var e=this.playQueueManager.getFor(this.model);if(e){var t=e.get("selectedItem");t&&this.model.get("key")===t.get("key")&&this.$(".track-list-item").addClass("current-track")}},onClose:function(){this.dropdown&&this.dropdown.close(),s.trigger("content.unsubscribe:resize",this.onResize)
},onResize:function(e){this.containerSize=e},onClick:function(e){this.stopTrackingSelecting(e,function(){e.preventDefault(),r.execute("playMedia",{item:this.model,siblings:!0})})},onMusicVideoClick:function(e){e.preventDefault(),e.stopImmediatePropagation();var i=this.model.server.getSectionForItem(this.model);if(!t.isEmpty(i)){var n=new l({key:this.model.get("primaryExtraKey"),type:"clip",librarySectionUUID:i.get("uuid")},{server:this.model.server,section:this.model.section});r.execute("playMedia",{item:n})
}},onEditClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),s.trigger("show:modal",new u({mediaActions:this.mediaActions}))},onMoreClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.dropdown=new d({model:this.model}),this.ui.dropdown.append(this.dropdown.render().el),this.ui.dropdown.addClass("open"),this.$el.addClass("force-hover");var t=i(e.currentTarget),n=this.ui.actions.position().top,s=this.dropdown.getPosition(t,this.containerSize,n);this.ui.dropdown.css(s)
},onDropdownHide:function(){this.dropdown&&(this.dropdown.close(),this.dropdown=null,this.$el.removeClass("force-hover"))},onPlayQueueSelectedItemChange:function(e,t){var i=!(!t||this.model.get("key")!==t.get("key"));this.$(".track-list-item").toggleClass("current-track",i)},onPlayQueueChange:function(e){e&&this.listenTo(e,"change:selectedItem",this.onPlayQueueSelectedItemChange)},onRemovePlayQueue:function(e){this.stopListening(e),this.$(".track-list-item").removeClass("current-track")},select:function(){this.ui.container.addClass("selected")
},deselect:function(){this.ui.container.removeClass("selected")}});return h}),define("plex/desktop/views/lists/library/TrackList",["underscore","plex/desktop/mixins/views/discMarkerMixin","plex/desktop/views/lists/library/MediaList","plex/desktop/views/lists/library/TrackListItem"],function(e,t,i,n){"use strict";var s=i.extend({mixins:[t],initialize:function(){i.prototype.initialize.apply(this,arguments),this.listenTo(this.collection,"change:parentIndex",e.debounce(this.onParentIndexChange))},tagName:"ul",className:"list media-list track-list show-context",itemView:n,onParentIndexChange:function(e){null!=e.previous("parentIndex")&&this.collection.fetch()
}});return s}),define("plex/desktop/views/details/AlbumDetailsView",["hb!templates/desktop/details/AlbumDetailsView.tpl","plex/base/mixins/details/albumDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/RatingView","plex/desktop/views/details/components/SummaryView","plex/base/views/images/MediaPosterImage","plex/desktop/views/lists/library/TrackList"],function(e,t,i,n,s,a,r){"use strict";var o=i.extend({mixins:t,className:"album-details-row details-row",template:e,allowMirror:!0,initialize:function(){i.prototype.initialize.apply(this,arguments),this.ListConstructor=r,this.listItemViewOptions={artistTitle:this.model.get("parentTitle"),mediaActions:this.mediaActions},this.ratingView=new n({model:this.model}),this.summaryView=new s({model:this.model}),this.posterImage=new a({model:this.model,type:this.model.get("type"),width:this.posterWidth})
}});return o}),define("hb!templates/desktop/details/PhotoAlbumDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="details-title-container">\n  <h1 class="item-title"></h1>\n</div>\n\n<div class="details-metadata-container">\n  <div class="summary-container"></div>\n  <div class="photo-list-container details-list-region"></div>\n</div>\n'})}),define("hb!templates/desktop/lists/library/PhotoTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"collection-poster-container"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=this,u=i.helperMissing;return c+='<a class="media-poster-container hide-actions ',l={hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s},r=i.if_eq||t&&t.if_eq,o=r?r.call(t,(r=t&&t.item,null==r||r===!1?r:r.type),"photoAlbum",l):u.call(t,"if_eq",(r=t&&t.item,null==r||r===!1?r:r.type),"photoAlbum",l),(o||0===o)&&(c+=o),c+='" href="#">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="collection-title-container">\n      <div class="collection-title"></div>\n    </div>\n  </div>\n</a>\n'
})}),define("plex/desktop/views/lists/library/PhotoTileListItem",["hb!templates/desktop/lists/library/PhotoTileListItem.tpl","plex/base/utils/dispatcher","plex/base/commands/commands","plex/desktop/views/lists/library/MediaListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s){"use strict";var a=n.extend({className:"poster-item media-tile-list-item",template:e,ui:{poster:".media-poster"},events:{"click a":"onClick"},initialize:function(){n.prototype.initialize.apply(this,arguments),this.image=new s({model:this.model,type:this.type,width:200})
},bindings:{".collection-title-container":{modelAttribute:"title",manual:!0,autohide:function(){return"photoAlbum"===this.type}},".collection-title":{modelAttribute:"title"}},onClick:function(e){e.preventDefault(),"photoAlbum"===this.type?t.trigger("navigate","details",{serverID:this.model.server.id,key:this.model.get("key")}):i.execute("playMedia",{item:this.model,siblings:this.canPlaySiblings()})}});return a}),define("plex/desktop/views/lists/library/PhotoTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/PhotoTileListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"tile-list photo-tile-list",itemView:t});return i}),define("plex/desktop/views/details/PhotoAlbumDetailsView",["hb!templates/desktop/details/PhotoAlbumDetailsView.tpl","underscore","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/details/components/SummaryView","plex/desktop/views/lists/library/PhotoTileList"],function(e,t,i,n,s){"use strict";var a=i.extend({className:"photo-album-details-row details-row",template:e,initialize:function(){i.prototype.initialize.apply(this,arguments),this.ListConstructor=s,this.summaryView=new n({model:this.model})
},bindings:t.pick(i.prototype.defaultBindings,[".item-title"])});return a}),define("hb!templates/desktop/details/ClipDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="details-title-container">\n  <h1 class="item-title"></h1>\n  <h2 class="item-year"></h2>\n</div>\n\n<div class="details-metadata-container">\n  <div class="metadata-right pull-right">\n    <div class="item-genre metadata-tags"></div>\n\n    <div class="rating-container"></div>\n\n    <div class="content-rating-flag-container"></div>\n  </div>\n\n  <p class="metadata-labels">\n    <span class="item-duration metadata-duration"></span>\n  </p>\n\n  <p class="item-tagline metadata-tagline"></p>\n\n  <div class="item-director metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Director",r):l.call(t,"t","Director",r)))+'</span> <span class="metadata-tag-list"></span>\n  </div>\n  <div class="item-writer metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Writer",r):l.call(t,"t","Writer",r)))+'</span> <span class="metadata-tag-list"></span>\n  </div>\n  <div class="item-cast metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Cast",r):l.call(t,"t","Cast",r)))+'</span> <span class="metadata-tag-list"></span>\n  </div>\n\n  <div class="item-audio metadata-tags metadata-tags-separator">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Audio",r):l.call(t,"t","Audio",r)))+'</span>\n  </div>\n  <div class="item-subtitles metadata-tags">\n    <span class="metadata-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Subtitles",r):l.call(t,"t","Subtitles",r)))+'</span>\n  </div>\n\n  <div class="summary-container"></div>\n\n  <div class="studio-flag-container"></div>\n</div>\n\n<div class="details-poster-container">\n  <a class="media-poster-container play-btn" href="#">\n    <div class="clip-poster item-poster media-poster">\n      <div class="media-poster-overlay"></div>\n      <div class="media-poster-overlay-icons">\n        <i class="media-poster-overlay-icon glyphicon play"></i>\n      </div>\n    </div>\n  </a>\n\n  <div class="video-audio-flags-container media-flags"></div>\n</div>\n'
})}),define("plex/base/mixins/details/clipDetailsMixin",["underscore","plex/base/mixins/details/baseDetailsMixin"],function(e,t){"use strict";var i={bindings:e.pick(t.defaultBindings,[".item-title",".item-year",".item-duration",".item-tagline",".item-genre",".item-director",".item-writer",".item-cast",".item-content-rating",".content-rating-flag-container",".studio-flag-container"])};return i}),define("plex/desktop/views/details/ClipDetailsView",["hb!templates/desktop/details/ClipDetailsView.tpl","plex/base/mixins/details/clipDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/RatingView","plex/desktop/views/details/components/SummaryView","plex/desktop/views/dropdowns/StreamDropdown","plex/base/views/images/MediaPosterImage","plex/base/views/images/MediaFlagImage"],function(e,t,i,n,s,a,r,o){"use strict";
var l=i.extend({mixins:t,className:"clip-details-row details-row",template:e,allowMirror:!0,initialize:function(){i.prototype.initialize.apply(this,arguments),this.ratingView=new n({model:this.model,disabled:!0}),this.summaryView=new s({model:this.model}),this.audioDropdown=new a({type:"audio",model:this.model}),this.subtitlesDropdown=new a({type:"subtitles",model:this.model}),this.posterImage=new r({model:this.model,type:this.model.get("type"),width:this.posterWidth}),this.contentRatingFlag=new o({model:this.model,modelAttribute:"contentRating",className:"content-rating-flag",width:70,height:30}),this.videoResolutionFlag=new o({model:this.model,flag:"videoResolution",className:"media-flag",width:100,height:20}),this.audioCodecFlag=new o({model:this.model,flag:"audioCodec",className:"media-flag",width:100,height:20}),this.audioChannelsFlag=new o({model:this.model,flag:"audioChannels",className:"media-flag",width:100,height:20}),this.studioFlag=new o({model:this.model,modelAttribute:"studio",className:"studio-flag",width:200,height:40})
}});return l}),define("hb!templates/desktop/details/PlaylistDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n    <div class="playlist-poster item-poster media-poster ',(n=i.type)?n=n.call(e,{hash:{},data:t}):(n=e&&e.type,n=typeof n===h?n.call(e,{hash:{},data:t}):n),s+=p(n)+'">\n      ',n=i["if"].call(e,e&&e.smart,{hash:{},inverse:m.noop,fn:m.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\n    </div>\n  "}function r(){return'\n        <span class="smart-badge badge badge-round">\n          <i class="icon glyphicon cogwheel"></i>\n        </span>\n      '
}function o(e,t){var n,s,a,o="";return o+="\n      ",a={hash:{},inverse:m.noop,fn:m.program(2,r,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,e&&e.type,"audio",a):f.call(e,"if_neq",e&&e.type,"audio",a),(s||0===s)&&(o+=s),o+="\n    "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h="function",p=this.escapeExpression,m=this,f=i.helperMissing;return u+='<div class="details-title-container ',(l=i.type)?l=l.call(t,{hash:{},data:s}):(l=t&&t.type,l=typeof l===h?l.call(t,{hash:{},data:s}):l),u+=p(l)+'">\n  <h1 class="item-title"></h1>\n</div>\n\n<div class="details-metadata-container ',(l=i.type)?l=l.call(t,{hash:{},data:s}):(l=t&&t.type,l=typeof l===h?l.call(t,{hash:{},data:s}):l),u+=p(l)+'">\n  <div class="playlist-details-metadata-container">\n    <p class="metadata-right pull-right">\n      <span class="item-duration metadata-duration"></span>\n    </p>\n\n    <p class="metadata-labels">\n      <span class="item-count"></span>\n    </p>\n\n    <p class="item-summary metadata-summary"></p>\n  </div>\n\n  <div class="playlist-items-container details-list-region"></div>\n\n  <h1 class="error-text hidden">',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Failed to load items for this playlist.",d):f.call(t,"t","Failed to load items for this playlist.",d)))+'</h1>\n\n  <div class="loading-container">\n    <div class="loading loading-inline"></div>\n  </div>\n</div>\n\n<div class="details-poster-container ',(c=i.type)?c=c.call(t,{hash:{},data:s}):(c=t&&t.type,c=typeof c===h?c.call(t,{hash:{},data:s}):c),u+=p(c)+'">\n  ',d={hash:{},inverse:m.noop,fn:m.program(1,a,s),data:s},l=i.if_eq||t&&t.if_eq,c=l?l.call(t,t&&t.type,"audio",d):f.call(t,"if_eq",t&&t.type,"audio",d),(c||0===c)&&(u+=c),u+='\n\n  <div class="playlist-side-strip item-side-strip media-poster ',(c=i.type)?c=c.call(t,{hash:{},data:s}):(c=t&&t.type,c=typeof c===h?c.call(t,{hash:{},data:s}):c),u+=p(c)+'">\n    ',c=i["if"].call(t,t&&t.smart,{hash:{},inverse:m.noop,fn:m.program(4,o,s),data:s}),(c||0===c)&&(u+=c),u+="\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/lists/library/PlaylistListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n    <div class="media-actions media-reorder">\n        <div class="sortable-handle btn-gray-link"><i class="glyphicon show-lines"></i></div>\n    </div>\n  '}function r(){return'\n    <div class="media-poster-container play-btn">\n      <div class="media-poster">\n        <div class="media-poster-overlay"></div>\n        <div class="media-poster-overlay-icons">\n            <i class="media-poster-overlay-icon glyphicon play"></i>\n        </div>\n      </div>\n    </div>\n  '
}function o(){return'\n    <div class="media-actions media-delete">\n        <button class="delete-btn media-action-btn btn-gray-link btn-danger" tabindex="-1"><i class="glyphicon remove-2"></i></button>\n    </div>\n  '}function l(){return"has-actions"}function c(){return'\n        <div class="media-detail media-heading only-detail">\n          <span class="media-title"></span>\n        </div>\n        <div class="media-secondary-subtitle media-detail media-heading secondary"></div>\n      '}function d(e,t){var n,s,a,r="";
return r+='\n        <div class="media-detail media-heading">\n          <span class="media-title ',a={hash:{},inverse:g.noop,fn:g.program(12,u,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,e&&e.type,"track",a):v.call(e,"if_neq",e&&e.type,"track",a),(s||0===s)&&(r+=s),r+='"></span>\n        </div>\n        <div class="media-detail media-heading secondary">\n          <span class="media-primary-subtitle btn-metadata-link"></span>\n        </div>\n        <div class="media-detail media-heading secondary">\n          <span class="media-secondary-subtitle btn-metadata-link"></span>\n        </div>\n      '
}function u(){return"btn-metadata-link"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var h,p,m,f="",g=this,v=i.helperMissing,y="function",b=this.escapeExpression;return f+='<a class="show-actions playlist-inner-item ',(h=i.type)?h=h.call(t,{hash:{},data:s}):(h=t&&t.type,h=typeof h===y?h.call(t,{hash:{},data:s}):h),f+=b(h)+'" href="#">\n  ',h=i["if"].call(t,t&&t.canEdit,{hash:{},inverse:g.noop,fn:g.program(1,a,s),data:s}),(h||0===h)&&(f+=h),f+='\n\n  <div class="media-index media-heading secondary">\n    <i class="glyphicon volume-up"></i>\n  </div>\n\n  ',m={hash:{},inverse:g.noop,fn:g.program(3,r,s),data:s},h=i.if_neq||t&&t.if_neq,p=h?h.call(t,t&&t.type,"track",m):v.call(t,"if_neq",t&&t.type,"track",m),(p||0===p)&&(f+=p),f+="\n\n  ",p=i["if"].call(t,t&&t.canEdit,{hash:{},inverse:g.noop,fn:g.program(5,o,s),data:s}),(p||0===p)&&(f+=p),f+='\n\n  <div class="media-item ',(p=i.type)?p=p.call(t,{hash:{},data:s}):(p=t&&t.type,p=typeof p===y?p.call(t,{hash:{},data:s}):p),f+=b(p)+" ",p=i["if"].call(t,t&&t.canEdit,{hash:{},inverse:g.noop,fn:g.program(7,l,s),data:s}),(p||0===p)&&(f+=p),f+='">\n    <div class="media-details">\n      ',m={hash:{},inverse:g.program(11,d,s),fn:g.program(9,c,s),data:s},h=i.if_eq||t&&t.if_eq,p=h?h.call(t,t&&t.type,"movie",m):v.call(t,"if_eq",t&&t.type,"movie",m),(p||0===p)&&(f+=p),f+='\n      <div class="media-duration media-heading secondary"></div>\n    </div>\n  </div>\n</a>\n'
})}),define("plex/desktop/views/lists/library/PlaylistListItem",["hb!templates/desktop/lists/library/PlaylistListItem.tpl","underscore","plex/base/utils/dispatcher","plex/base/utils/mediaUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/commands/commands","plex/desktop/views/lists/library/BasePlayListItem"],function(e,t,i,n,s,a,r){"use strict";var o=r.extend({className:"striped-list-item media-list-item playlist-item",template:e,events:{"click .delete-btn":"onDeleteClick","click .playlist-inner-item":"onClick","click .media-details":"onDetailsClick","click .media-primary-subtitle":"onGrandparentClick","click .media-secondary-subtitle":"onParentClick"},posterWidth:{video:103},attributes:function(){return{"data-playlist-id":this.model.get("playlistItemID")}
},bindings:t.extend({".media-primary-subtitle":{modelAttribute:"grandparentTitle",formatter:function(e){var t=e;return this.model.parent&&(t=t||this.model.parent.get("parentTitle"),this.model.parent.parent&&(t=this.model.parent.parent.get("title"))),"movie"===this.type&&(t=""),t||""}},".media-secondary-subtitle":{modelAttribute:"parentTitle",modelListeners:["parentTitle","index","year"],formatter:function(e){var t=e;return this.model.parent&&(t=t||this.model.parent.get("title")),"episode"===this.type?t=n.getSeasonEpisodeIndex({noLeadingZero:!0,seasonPrefix:"Season {1}",episodePrefix:" - Episode {1}",seasonIndex:this.model.get("parentIndex"),episodeIndex:this.model.get("index"),date:this.model.get("originallyAvailableAt")}):"movie"===this.type&&(t=this.model.get("year")),t||""
}},".media-duration":{modelAttribute:"duration",formatter:function(e){return"track"===this.type?s.formatDuration(e):s.formatHoursMinutes(e)}}},r.prototype.bindings),initialize:function(e){r.prototype.initialize.apply(this,arguments),this.canEdit=e&&e.canEdit,"track"===this.type&&(this.playQueueManager=this.model.server.get("playQueueManager"),this.listenTo(this.playQueueManager,"change:playQueue:audio",this.onPlayQueueChange),this.listenTo(this.playQueueManager,"remove:playQueue:audio",this.onRemovePlayQueue),this.onPlayQueueChange(this.playQueueManager.getFor(this.model)))
},serializeData:function(){return{canEdit:this.canEdit,type:this.type}},navigateTo:function(e,t){e&&(t.preventDefault(),t.stopPropagation(),i.trigger("navigate","details",{serverID:this.model.server.id,key:e}))},onRender:function(){if(r.prototype.onRender.apply(this,arguments),"track"===this.type){var e=this.playQueueManager.getFor(this.model);if(!e)return;var t=e.get("selectedItem");t&&this.model.get("key")===t.get("key")&&this.$el.addClass("current-track")}},onClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),a.execute("playMedia",{item:this.model,siblings:!0})
},onDeleteClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.trigger("remove",this.model.get("playlistItemID"))},onDetailsClick:function(e){"track"!==this.model.get("type")&&this.navigateTo(this.model.get("key"),e)},onParentClick:function(e){this.navigateTo(this.model.get("parentKey"),e)},onGrandparentClick:function(e){this.navigateTo(this.model.get("grandparentKey"),e)},onPlayQueueSelectedItemChange:function(e,t){var i=!(!t||this.model.get("key")!==t.get("key"));this.$el.toggleClass("current-track",i)
},onPlayQueueChange:function(e){e&&this.listenTo(e,"change:selectedItem",this.onPlayQueueSelectedItemChange)},onRemovePlayQueue:function(e){this.stopListening(e),this.$el.removeClass("current-track")}});return o}),define("plex/desktop/views/lists/library/PlaylistList",["jquery","underscore","sortable","plex/desktop/views/lists/BaseList","plex/desktop/views/lists/library/PlaylistListItem"],function(e,t,i,n,s){"use strict";var a=n.extend({tagName:"ol",className:"list media-list playlist-items",itemView:s,sorted:!0,itemEvents:{remove:"onItemRemove"},initialize:function(){this.canEdit=!this.model.get("smart")
},onRender:function(){this.sortable&&this.sortable.destroy(),this.canEdit&&(this.sortable=new i(this.el,{onUpdate:t.bind(this.onItemMove,this),handle:".sortable-handle"}))},onItemRemove:function(e,t,i){this.model.removeItem(i)},onItemMove:function(t){var i=e(t.item).data("playlist-id"),n=e(t.item).prev().data("playlist-id");this.model.moveItem(i,n)},onClose:function(){this.sortable&&this.sortable.destroy()}});return a}),define("plex/desktop/views/details/PlaylistDetailsView",["hb!templates/desktop/details/PlaylistDetailsView.tpl","underscore","plex/base/utils/t","plex/base/utils/posterSizes","plex/base/utils/formatters/dateTimeUtil","plex/base/mixins/details/baseDetailsMixin","plex/desktop/views/details/BaseDetailsView","plex/desktop/views/images/CompositeImage","plex/desktop/views/lists/library/PlaylistList"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=r.extend({className:"playlist-details-row details-row",template:e,posterWidth:200,pageSize:50,ui:t.extend({sideStrip:".item-side-strip"},r.prototype.ui),bindings:t.extend(t.pick(a.defaultBindings,[".item-title",".item-summary"]),{".item-duration":{modelAttribute:"duration",autohide:!0,formatter:function(e){return e?s.formatBroadDuration(e):0}},".item-count":{modelAttribute:"leafCount",formatter:function(e){return 0===e?i("This playlist has no items."):1===e?i("1 Item"):i("{1} Items",e)}},".no-items":{modelAttribute:"leafCount",manual:!0,autohide:!0,formatter:function(e){return 0===e
}},".loading-container":{model:"progress",modelAttribute:"loading",manual:!0,autohide:!0},".error-text":{model:"progress",modelAttribute:"failed",manual:!0,autohide:!0}}),serializeData:function(){return{smart:this.model.get("smart"),type:this.model.get("playlistType")}},initialize:function(){r.prototype.initialize.apply(this,arguments),this.ListConstructor=l,this.listItemViewOptions={canEdit:!this.model.get("smart")};var e="video"===this.model.get("playlistType");this.posterWidth=200;var t=e?n.ratios.portrait:n.ratios.landscape,i=e?n.ratios.portrait:n.ratios.square;
this.sideStripImage=new o({model:this.model,media:e?"thumb":"art",width:this.posterWidth,height:this.posterWidth/t*16,columns:1,rows:16,unique:!0,noPlaceholder:!0}),this.posterImage=new o({model:this.model,width:this.posterWidth,height:this.posterWidth/i,noPlaceholder:!0})},onRender:function(){r.prototype.onRender.apply(this,arguments),this.sideStripImage.setElement(this.ui.sideStrip)},onClose:function(){return this.posterImage&&this.sideStripImage.close(),r.prototype.onClose.apply(this,arguments)
}});return c}),define("hb!templates/desktop/details/UnknownDetailsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="row row-padded">\n  <div class="col-md-8 col-md-offset-2">\n    <h1>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"This media type does not have a details page.",r):l.call(t,"t","This media type does not have a details page.",r)))+"</h1>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/details/UnknownDetailsView",["hb!templates/desktop/details/UnknownDetailsView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({className:"container",template:e});return i}),define("plex/desktop/views/details/DetailsView",["hb!templates/desktop/details/DetailsView.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/desktop/models/MediaActionsModel","plex/desktop/views/actionbar/ActionBarView","plex/desktop/views/breadcrumbbar/DetailsBreadcrumbBarView","plex/desktop/views/details/MovieDetailsView","plex/desktop/views/details/ShowDetailsView","plex/desktop/views/details/SeasonDetailsView","plex/desktop/views/details/EpisodeDetailsView","plex/desktop/views/details/ArtistDetailsView","plex/desktop/views/details/AlbumDetailsView","plex/desktop/views/details/PhotoAlbumDetailsView","plex/desktop/views/details/ClipDetailsView","plex/desktop/views/details/PlaylistDetailsView","plex/desktop/views/details/UnknownDetailsView"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y){"use strict";
var b={movie:c,show:d,season:u,episode:h,artist:p,album:m,photoAlbum:f,clip:g,userPlaylistItem:g,playlist:v},w={playlist:{blur:5,saturation:50}},x=i.Layout.extend({className:"details-container",template:e,regions:{details:".row"},events:{"click .pivot-link":"onPivotClick"},initialize:function(){var e=this.model.get("grandparentTheme")||this.model.get("parentTheme")||this.model.get("theme"),i=this.model.get("type"),c={};t(w).has(i)&&(c=w[i]),this.mediaActions=new r({},{item:this.model,type:i,showAdvanced:!0}),this.once("render",t.bind(function(){n.trigger("show:background",{model:this.model,imageFilters:c}),n.trigger("show:bar","actionbar",new o({model:this.model,mediaActions:this.mediaActions})),this.model.isLibraryItem()&&n.trigger("show:bar","breadcrumbbar",new l({model:this.model}))
},this)),e&&s.get("playThemeMusic")&&a.execute("playSound",{key:this.model.get("key"),url:this.model.server.resolveUrl(e,{appendToken:!0}),volume:50,autoLoad:!0,autoPlay:!0,background:!0})},onRender:function(){var e,i=this.model.get("type");if(t(b).has(i)){var n=b[i];e=new n({model:this.model,mediaActions:this.mediaActions})}else e=new y({model:this.model});this.details.append(e,this.$el)},onClose:function(){n.trigger("hide:bar","actionbar"),this.model.isLibraryItem()&&n.trigger("hide:bar","breadcrumbbar")
},onPivotClick:function(){var e=this.model.section;if(e){var t=e.get("items");t.scrollPosition=0}}});return x}),define("plex/desktop/routes/LibraryController",["plex/base/utils/dispatcher","plex/base/routes/BaseController","plex/desktop/views/SearchView","plex/desktop/views/section/SectionView","plex/desktop/views/details/DetailsView"],function(e,t,i,n,s){"use strict";var a=t.extend({search:function(t){var n=this.populateView({primaryServer:!0});n.done(function(){e.trigger("show:view",new i({query:t}))
})},section:function(t,i,s){var a=this.populateView({serverID:t,sectionID:i});a.done(function(t){e.trigger("show:view",new n({model:t.section,subset:s}))})},sectionFolder:function(t,i,s){var a=this.populateView({serverID:t,sectionID:i});a.done(function(t){var i=t.section.get("items");i.scrollPosition=0,e.trigger("show:view",new n({model:t.section,subset:"folder",folderKey:s}))})},sectionFilter:function(t,i,s,a,r,o){var l=this.populateView({serverID:t,sectionID:i});l.done(function(t){var i=t.section.get("currentFilters");
i.length=0,o||(o=r),i.push({key:a,values:r.split(","),titles:o.split(",")}),e.trigger("show:view",new n({model:t.section,type:parseInt(s,10)}))})},details:function(t,i){var n=this.populateView({serverID:t,key:i,populateData:{includeRelatedCount:"5",includePopularLeaves:"1",includeConcerts:"1"}});n.done(function(t){e.trigger("show:view",new s({model:t.item}))})}});return a}),define("plex/desktop/routes/LibraryRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/LibraryController"],function(e,t){"use strict";
var i=e.extend({controller:new t,appRoutes:{"!/search/:query":"search","!/server/:serverID/section/:sectionID(/:subset)":"section","!/server/:serverID/section/:sectionID/folder/:key":"sectionFolder","!/server/:serverID/section/:sectionID/filter/:type/:key/:value(/:title)":"sectionFilter","!/server/:serverID/details/:key":"details"}});return i}),define("hb!templates/desktop/channel/ChannelView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("hb!templates/desktop/breadcrumbbar/ChannelBreadcrumbBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'<a class="settings-btn btn-gray" href="#"><i class="glyphicon cogwheel"></i></a>'}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h=i.helperMissing,p=this.escapeExpression,m="function";return d+='<div class="breadcrumb-actions pull-right">\n  ',o=i["if"].call(t,t&&t.showSettings,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(o||0===o)&&(d+=o),d+='\n\n  <span id="channel-list-dropdown" class="dropdown">\n    <a class="btn-gray dropdown-toggle" href="#channel-list-dropdown" data-toggle="dropdown"><i class="glyphicon show-thumbnails"></i> <i class="caret-icon caret-icon-sm"></i></a>\n\n    <ul class="dropdown-menu pull-right">\n      <li><a class="list-btn" data-type="media-tile-list" href="#">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Posters",c):h.call(t,"t","Posters",c)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',c={hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s},o=i.if_neq||t&&t.if_neq,l=o?o.call(t,t&&t.listType,"media-tile-list",c):h.call(t,"if_neq",t&&t.listType,"media-tile-list",c),(l||0===l)&&(d+=l),d+='"></i></a></li>\n      <li><a class="list-btn" data-type="media-details-list" href="#">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Details",c):h.call(t,"t","Details",c)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',c={hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s},o=i.if_neq||t&&t.if_neq,l=o?o.call(t,t&&t.listType,"media-details-list",c):h.call(t,"if_neq",t&&t.listType,"media-details-list",c),(l||0===l)&&(d+=l),d+='"></i></a></li>\n      <li><a class="list-btn" data-type="media-list" href="#">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"List",c):h.call(t,"t","List",c)))+'<i class="dropdown-selected-icon glyphicon ok-2 ',c={hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s},o=i.if_neq||t&&t.if_neq,l=o?o.call(t,t&&t.listType,"media-list",c):h.call(t,"if_neq",t&&t.listType,"media-list",c),(l||0===l)&&(d+=l),d+='"></i></a></li>\n    </ul>\n  </span>\n</div>\n\n<span class="breadcrumb-dropdown"><a href="',(l=i.channelUrl)?l=l.call(t,{hash:{},data:s}):(l=t&&t.channelUrl,l=typeof l===m?l.call(t,{hash:{},data:s}):l),d+=p(l)+'">',(l=i.channelTitle)?l=l.call(t,{hash:{},data:s}):(l=t&&t.channelTitle,l=typeof l===m?l.call(t,{hash:{},data:s}):l),d+=p(l)+'</a></span>\n<span class="breadcrumb-subset-dropdown ',l=i.unless.call(t,t&&t.title,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='"><span class="dropdown-placeholder">',(l=i.title)?l=l.call(t,{hash:{},data:s}):(l=t&&t.title,l=typeof l===m?l.call(t,{hash:{},data:s}):l),d+=p(l)+'</span></span>\n<span class="list-badge badge badge-lg">',(l=i.totalSize)?l=l.call(t,{hash:{},data:s}):(l=t&&t.totalSize,l=typeof l===m?l.call(t,{hash:{},data:s}):l),d+=p(l)+"</span>\n"
})}),define("plex/desktop/views/breadcrumbbar/ChannelBreadcrumbBarView",["hb!templates/desktop/breadcrumbbar/ChannelBreadcrumbBarView.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/models/server/ServerSettingCollection","plex/desktop/views/modals/ChannelSettingsModal"],function(e,t,i,n,s,a,r){"use strict";var o=n.Layout.extend({className:"breadcrumb-bar",template:e,ui:{listSelectedIcons:"#channel-list-dropdown .dropdown-selected-icon"},events:{"click .settings-btn":"onSettingsClick","click .list-btn":"onListClick"},initialize:function(e){this.currentListType=e.currentListType,this.settingsKey=this.model.get("settingsKey"),!this.settingsKey&&this.model.channel&&(this.settingsKey=this.model.channel.get("settingsKey"))
},serializeData:function(){var e=this.model.channel||this.model,t=e?e.get("title"):this.model.get("title"),i=e?e.id:e.get("identifier"),n="#!/server/"+encodeURIComponent(this.model.server.id);n+="/channel/"+encodeURIComponent(i);var s=this.model.channel?this.model.get("title"):null;return{channelTitle:t,channelUrl:n,title:s,totalSize:this.model.get("items").length,showSettings:!!this.settingsKey,listType:this.currentListType}},onSettingsClick:function(e){e.preventDefault();var i=new a([],{server:this.model.server,url:this.settingsKey});
i.fetch().done(t.bind(function(){s.trigger("show:modal",new r({model:this.model.channel||this.model,collection:i}))},this))},onListClick:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.data("type");this.trigger("change:listType",n),this.ui.listSelectedIcons.addClass("hidden"),t.find(".dropdown-selected-icon").removeClass("hidden")}});return o}),define("plex/desktop/views/channel/ChannelView",["hb!templates/desktop/channel/ChannelView.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/breadcrumbbar/ChannelBreadcrumbBarView","plex/desktop/views/lists/library/VirtualMediaTileList","plex/desktop/views/lists/library/VirtualMediaDetailsList","plex/desktop/views/lists/library/VirtualMediaList"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=i.Layout.extend({className:"channel-container",template:e,regions:{list:".channel-list-container"},initialize:function(){var e=this.model.get("header"),t=this.model.get("message");(e||t)&&n.trigger("show:alert",{message:t||e}),this.searchKey=this.model.get("searchKey"),this.searchPlaceholder=this.model.get("title"),!this.searchKey&&this.model.channel&&(this.searchKey=this.model.channel.get("searchKey"),this.searchPlaceholder=this.model.channel.get("title")),this.searchKey&&(s.set({searchType:"channel",searchPlaceholder:this.searchPlaceholder}),this.listenTo(n,"search:channel",this.onSearch)),this.listType=this.getListType();
var i=new a({model:this.model,currentListType:this.listType});this.listenTo(i,"change:listType",this.onListTypeChange),n.trigger("show:bar","breadcrumbbar",i),n.trigger("show:background",{model:this.model,dim:!0})},getListType:function(){var e="media-tile-list",i="media-details-list",n="media-list",s=this.collection.length,a=this.model.get("viewGroup");if("Pictures"===a)return e;if("List"===a)return n;if(this.collection.findWhere({type:"photo"}))return e;var r=t.compact(this.collection.pluck("summary")),o=t.uniq(this.collection.pluck("thumb")),l=this.collection.reduce(function(e,t){var i=t.get("title");
return i?e+i.length:e},0),c=l/s;return o.length>s/2&&30>c?e:r.length>s/2?i:n},getListConstructor:function(){switch(this.listType){case"media-tile-list":return r;case"media-details-list":return o;default:return l}},onRender:function(){var e=this.getListConstructor();this.list.append(new e({collection:this.collection,paginated:!1}),this.$el)},onClose:function(){s.set({searchType:null,searchPlaceholder:null}),n.trigger("hide:bar","breadcrumbbar")},onSearch:function(e){if(e){var t=this.model.channel||this.model,i=t.id?t.id:t.get("identifier"),s=this.searchKey;
s+=s.indexOf("?")>0?"&":"?",s+="query="+e,n.trigger("navigate","channel",{serverID:this.model.server.id,channelID:i,key:s})}},onListTypeChange:function(e){this.listType=e,this.collection.scrollPosition=0,this.list.currentView.scrollPosition=0,this.render()}});return c}),define("hb!templates/desktop/channel/ChannelsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='<span class="badge">',(n=i.allCount)?n=n.call(e,{hash:{},data:t}):(n=e&&e.allCount,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</span>"
}function r(e,t){var n,s="";return s+='<span class="badge">',(n=i.videoCount)?n=n.call(e,{hash:{},data:t}):(n=e&&e.videoCount,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</span>"}function o(e,t){var n,s="";return s+='<span class="badge">',(n=i.musicCount)?n=n.call(e,{hash:{},data:t}):(n=e&&e.musicCount,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</span>"}function l(e,t){var n,s="";return s+='<span class="badge">',(n=i.photoCount)?n=n.call(e,{hash:{},data:t}):(n=e&&e.photoCount,n=typeof n===p?n.call(e,{hash:{},data:t}):n),s+=m(n)+"</span>"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d,u,h="",p="function",m=this.escapeExpression,f=i.helperMissing,g=this;return h+='<ul class="nav nav-header pull-right">\n  <li><a class="all-btn btn-gray selected" href="#">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"All",u):f.call(t,"t","All",u))),d=i["if"].call(t,t&&t.allCount,{hash:{},inverse:g.noop,fn:g.program(1,a,s),data:s}),(d||0===d)&&(h+=d),h+='</a></li>\n  <li><a class="video-btn btn-gray" href="#">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Video",u):f.call(t,"t","Video",u))),d=i["if"].call(t,t&&t.videoCount,{hash:{},inverse:g.noop,fn:g.program(3,r,s),data:s}),(d||0===d)&&(h+=d),h+='</a></li>\n  <li><a class="music-btn btn-gray" href="#">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Music",u):f.call(t,"t","Music",u))),d=i["if"].call(t,t&&t.musicCount,{hash:{},inverse:g.noop,fn:g.program(5,o,s),data:s}),(d||0===d)&&(h+=d),h+='</a></li>\n  <li><a class="photo-btn btn-gray" href="#">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Photo",u):f.call(t,"t","Photo",u))),d=i["if"].call(t,t&&t.photoCount,{hash:{},inverse:g.noop,fn:g.program(7,l,s),data:s}),(d||0===d)&&(h+=d),h+="</a></li>\n</ul>\n\n<h2>",u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Channels",u):f.call(t,"t","Channels",u)))+'</h2>\n\n<div class="filter-bar">\n  <a class="btn btn-sm btn-primary pull-right" href="#!/server/',u={hash:{},data:s},h+=m((c=i.encodeUrl||t&&t.encodeUrl,c?c.call(t,t&&t.serverID,u):f.call(t,"encodeUrl",t&&t.serverID,u)))+'/directory">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Install Channels",u):f.call(t,"t","Install Channels",u)))+'</a>\n  <a class="check-updates-btn btn btn-sm btn-default btn-loading" href="#">\n    <div class="loading loading-sm"></div>\n    <span class="btn-label">',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Check for Updates",u):f.call(t,"t","Check for Updates",u)))+'</span>\n  </a>\n</div>\n\n<div class="channels-container"></div>\n'
})}),define("plex/desktop/views/lists/channel/ChannelTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/channel/ChannelTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list channel-tile-list",itemView:t});return i}),define("plex/desktop/views/channel/ChannelsView",["hb!templates/desktop/channel/ChannelsView.tpl","underscore","jquery","marionette","plex/base/commands/commands","plex/desktop/views/lists/channel/ChannelTileList"],function(e,t,i,n,s,a){"use strict";
var r=n.Layout.extend({className:"container",template:e,ui:{navLinks:".nav a",checkUpdatesBtn:".check-updates-btn"},regions:{list:".channels-container"},events:{"click .nav a":"onNavClick","click .all-btn":"onAllClick","click .video-btn":"onVideoClick","click .music-btn":"onMusicClick","click .photo-btn":"onPhotoClick","click .check-updates-btn":"onCheckUpdatesClick"},initialize:function(){this.videoCollection=this.collection.filterByType("video"),this.musicCollection=this.collection.filterByType("music"),this.photoCollection=this.collection.filterByType("photos")
},serializeData:function(){return{serverID:this.collection.server.id,allCount:this.collection.length,videoCount:this.videoCollection.length,musicCount:this.musicCollection.length,photoCount:this.photoCollection.length}},onRender:function(){this.list.show(new a({collection:this.collection}))},onNavClick:function(e){this.ui.navLinks.removeClass("selected"),i(e.currentTarget).addClass("selected")},onAllClick:function(e){e.preventDefault(),this.list.show(new a({collection:this.collection}))},onVideoClick:function(e){e.preventDefault(),this.list.show(new a({collection:this.videoCollection}))
},onMusicClick:function(e){e.preventDefault(),this.list.show(new a({collection:this.musicCollection}))},onPhotoClick:function(e){e.preventDefault(),this.list.show(new a({collection:this.photoCollection}))},onCheckUpdatesClick:function(e){e.preventDefault();var i=this.ui.checkUpdatesBtn;if(!i.hasClass("active")){i.addClass("active");var n=s.execute("updateChannel",{server:this.collection.server});n.always(t.bind(function(){i.removeClass("active")},this))}}});return r}),define("hb!templates/desktop/channel/ChannelDirectoryView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t,n){var s,a,o,l="";
return l+='\n        <li><a class="card btn-gray ',o={hash:{},inverse:u.noop,fn:u.program(2,r,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,n&&n.currentKey,e&&e.key,o):h.call(e,"if_eq",n&&n.currentKey,e&&e.key,o),(a||0===a)&&(l+=a),l+='" href="#!/server/',o={hash:{},data:t},l+=p((s=i.encodeUrl||n&&n.encodeUrl,s?s.call(e,n&&n.serverID,o):h.call(e,"encodeUrl",n&&n.serverID,o)))+"/directory/",o={hash:{},data:t},l+=p((s=i.encodeUrl||e&&e.encodeUrl,s?s.call(e,e&&e.key,o):h.call(e,"encodeUrl",e&&e.key,o)))+'">',o={hash:{},data:t},l+=p((s=i.t||e&&e.t,s?s.call(e,e&&e.title,o):h.call(e,"t",e&&e.title,o)))+"</a></li>\n      "
}function r(){return"selected"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h=i.helperMissing,p=this.escapeExpression;return d+="<h2>",c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Channel Directory",c):h.call(t,"t","Channel Directory",c)))+'</h2>\n\n<div class="filter-bar">\n  <a class="btn btn-sm btn-default pull-right" href="#!/server/',c={hash:{},data:s},d+=p((o=i.encodeUrl||t&&t.encodeUrl,o?o.call(t,t&&t.serverID,c):h.call(t,"encodeUrl",t&&t.serverID,c)))+'/channels">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Browse Channels",c):h.call(t,"t","Browse Channels",c)))+'</a>\n</div>\n\n<div class="row">\n  <div class="col-md-3">\n    <ul class="nav nav-cards">\n      ',l=i.each.call(t,t&&t.directories,{hash:{},inverse:u.noop,fn:u.programWithDepth(1,a,s,t),data:s}),(l||0===l)&&(d+=l),d+='\n    </ul>\n  </div>\n\n  <div class="directory-container col-md-9"></div>\n</div>\n'
})}),define("hb!templates/desktop/lists/channel/ChannelDirectoryListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<a class="card-collapsed" href="#!/server/',r={hash:{},data:s},o+=c((a=i.encodeUrl||t&&t.encodeUrl,a?a.call(t,t&&t.serverID,r):l.call(t,"encodeUrl",t&&t.serverID,r)))+"/directory/",r={hash:{},data:s},o+=c((a=i.encodeUrl||t&&t.encodeUrl,a?a.call(t,t&&t.currentKey,r):l.call(t,"encodeUrl",t&&t.currentKey,r)))+"/",r={hash:{},data:s},o+=c((a=i.encodeUrl||t&&t.encodeUrl,a?a.call(t,(a=t&&t.channel,null==a||a===!1?a:a.key),r):l.call(t,"encodeUrl",(a=t&&t.channel,null==a||a===!1?a:a.key),r)))+'">\n  <span class="media-title media-heading"></span>\n</a>\n'
})}),define("plex/desktop/views/lists/channel/ChannelDirectoryListItem",["hb!templates/desktop/lists/channel/ChannelDirectoryListItem.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/server/ServerSettingCollection","plex/desktop/views/modals/ChannelSettingsModal"],function(e,t,i,n,s,a,r){"use strict";var o=i.ItemView.extend({tagName:"li",className:"striped-list-item",template:e,events:{"click a":"onClick"},initialize:function(e){this.currentKey=e.currentKey
},serializeData:function(){return{channel:this.model.toJSON(),serverID:this.model.server.id,currentKey:this.currentKey}},bindings:{".media-title":{modelAttribute:"title"}},onClick:function(e){if(/\/updates$/.test(this.model.id))e.preventDefault(),s.execute("updateChannel",{server:this.model.server});else if(/\/prefs$/.test(this.model.id)){e.preventDefault();var i=new a([],{server:this.model.server,url:this.model.id});i.fetch().done(t.bind(function(){n.trigger("show:modal",new r({model:this.model,collection:i}))
},this))}}});return o}),define("plex/desktop/views/lists/channel/ChannelDirectoryList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/channel/ChannelDirectoryListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list card-list",itemView:t});return i}),define("plex/desktop/views/channel/ChannelDirectoryView",["hb!templates/desktop/channel/ChannelDirectoryView.tpl","marionette","plex/base/models/channel/ChannelCollection","plex/desktop/views/lists/channel/ChannelDirectoryList","plex/desktop/views/lists/channel/ChannelDirectoryTileList"],function(e,t,i,n,s){"use strict";
var a=t.Layout.extend({className:"container",template:e,regions:{list:".directory-container"},initialize:function(e){this.currentKey=e.currentKey,this.currentPath=e.currentPath,this.currentKey||(this.currentKey=this.collection.first().get("key")),this.currentPath||(this.currentPath=this.currentKey);var t=new i([],{server:this.collection.server,url:this.currentPath});this.listenToOnce(t,"reset",this.onReset),t.fetch({reset:!0,scope:"page"})},serializeData:function(){return{directories:this.collection.toJSON(),serverID:this.collection.server.id,currentKey:this.currentKey}
},onReset:function(e){var t,i={collection:e,itemViewOptions:{currentKey:this.currentKey}};t="Store:Info"===e.viewGroup?new s(i):new n(i),this.list.show(t)}});return a}),define("plex/desktop/routes/ChannelController",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/routes/BaseController","plex/base/models/channel/ChannelCollection","plex/desktop/views/channel/ChannelView","plex/desktop/views/channel/ChannelsView","plex/desktop/views/channel/ChannelDirectoryView","plex/desktop/views/details/DetailsView","plex/desktop/views/error/ErrorView"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=i.extend({channel:function(e,i,n){var a=this.populateView({serverID:e,channelID:i,channelKey:n});a.done(function(e){var i=e.channelItem?e.channelItem:e.channel;t.trigger("show:view",new s({model:i,collection:i.get("items")}))})},channelDetails:function(e,i,n){var s=this.populateView({serverID:e,channelID:i,channelKey:n});s.done(function(e){var i=e.channelItem.get("items"),n=i.first();t.trigger("show:view",new o({model:n}))})},channels:function(i){var s=this.populateView({serverID:i});s.done(function(i){var s=new n([],{server:i.server,subset:"all"});
s.comparator=s.sortByTitle;var r=s.fetch({scope:"page"});r.done(function(){t.trigger("show:view",new a({collection:s}))}),r.fail(function(){t.trigger("show:view",new l({message:e("Your channels are unavailable.")}))})})},directory:function(i,s,a){var o=this.populateView({serverID:i});o.done(function(i){var o=new n([],{server:i.server,url:"system/appstore"}),c=o.fetch({scope:"page"});c.done(function(){t.trigger("show:view",new r({collection:o,currentKey:s,currentPath:a}))}),c.fail(function(){t.trigger("show:view",new l({title:e("The channel directory is unavailable.")}))
})})}});return c}),define("plex/desktop/routes/ChannelRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/ChannelController"],function(e,t){"use strict";var i=e.extend({controller:new t,appRoutes:{"!/server/:serverID/channel/:channelID(/:key)":"channel","!/server/:serverID/channel/:channelID/details/:key":"channelDetails","!/server/:serverID/channels":"channels","!/server/:serverID/directory(/:key)(/:path)":"directory"}});return i}),define("hb!templates/desktop/playlists/PlaylistsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a="";return a})}),define("hb!templates/desktop/actionbar/PlaylistsActionBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="action-bar">\n  <ul class="nav action-bar-nav">\n    <li>\n      <a class="options-btn btn-gray" href="#" title="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Options",r):l.call(t,"t","Options",r)))+'" data-toggle="tooltip"><i class="glyphicon show-lines"></i></a>\n    </li>\n  </ul>\n</div>\n'
})}),define("hb!templates/desktop/sidebar/PlaylistsSideBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="side-bar-page main-page minimal-scroll">\n  <div class="section-sort-container">\n    <h5>',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sort",r):l.call(t,"t","Sort",r)))+'</h5>\n    <div class="section-sort-list-container"></div>\n  </div>\n</div>'
})}),define("plex/desktop/views/sidebar/PlaylistsSideBarView",["hb!templates/desktop/sidebar/PlaylistsSideBarView.tpl","marionette","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/desktop/views/lists/library/section/SortList"],function(e,t,i,n,s){"use strict";var a=t.Layout.extend({className:"side-bar",template:e,ui:{sortContainer:".section-sort-container"},regions:{sort:".section-sort-list-container"},initialize:function(){this.hidden=!n.get("sidebarOpen"),this.hidden?this.$el.addClass("transition-out"):i.trigger("show:bar","sidebar")
},open:function(){this.hidden=!1,n.save("sidebarOpen",!0),this.$el.removeClass("transition-out"),i.trigger("show:bar","sidebar")},hide:function(){this.hidden=!0,n.save("sidebarOpen",!1),this.$el.addClass("transition-out"),i.trigger("hide:bar","sidebar")},onRender:function(){this.sort.show(new s({collection:this.model.get("sorts")}))},onClose:function(){i.trigger("hide:bar","sidebar")}});return a}),define("plex/desktop/views/actionbar/PlaylistsActionBarView",["hb!templates/desktop/actionbar/PlaylistsActionBarView.tpl","jquery","marionette","plex/base/utils/dispatcher","plex/desktop/views/sidebar/PlaylistsSideBarView"],function(e,t,i,n,s){"use strict";
var a=i.Layout.extend({className:"playlists-side-bar-container",template:e,regions:{sidebar:".side-bar"},triggers:{"click .options-btn":"toggleSidebar"},onlyAfterRender:["onToggleSidebar"],initialize:function(){this.listenTo(n,{"shortcut:sidebar":this.onToggleSidebar})},onRender:function(){this.$el.tooltip({selector:".nav > li > a",container:"body",placement:"right"}),this.sidebar.append(new s({model:this.model}),this.$el)},onToggleSidebar:function(){t(".tooltip").remove();var e=this.sidebar.currentView;
e.hidden?e.open():e.hide()}});return a}),define("hb!templates/desktop/breadcrumbbar/PlaylistsBreadcrumbBarView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n    <span id="section-actions-dropdown" class="dropdown">\n      <a class="btn-gray dropdown-toggle" href="#section-actions-dropdown" data-toggle="dropdown"><i class="glyphicon cogwheel"></i> <i class="caret-icon caret-icon-sm"></i></a>\n\n      <ul class="dropdown-menu pull-right">\n        <li><a class="import-btn" href="#">',s={hash:{},data:t},a+=c((n=i.t||e&&e.t,n?n.call(e,"Import from iTunes",s):l.call(e,"t","Import from iTunes",s)))+"</a></li>\n      </ul>\n    </span>\n  "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o="",l=i.helperMissing,c=this.escapeExpression,d=this,u="function";return o+='<div class="breadcrumb-actions pull-right">\n  ',r=i["if"].call(t,t&&t.canImportPlaylists,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+='\n</div>\n\n<span class="breadcrumb-dropdown"></span>\n<span class="breadcrumb-subset-dropdown"></span>\n\n<span class="breadcrumb-items-dropdown">\n  <span class="items-badge badge badge-lg">',(r=i.totalSize)?r=r.call(t,{hash:{},data:s}):(r=t&&t.totalSize,r=typeof r===u?r.call(t,{hash:{},data:s}):r),o+=c(r)+"</span>\n</span>\n"
})}),define("hb!templates/desktop/dropdowns/PlaylistTypeDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t,n){var s,a,o,l="";return l+='\n  <li><a href="#" class="type-btn" data-key="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===u?s.call(e,{hash:{},data:t}):s),l+=h(s)+'">',o={hash:{},data:t},l+=h((s=i.t||e&&e.t,s?s.call(e,e&&e.title,o):p.call(e,"t",e&&e.title,o)))+" ",o={hash:{},inverse:m.noop,fn:m.program(2,r,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,(s=n&&n.currentType,null==s||s===!1?s:s.key),e&&e.key,o):p.call(e,"if_eq",(s=n&&n.currentType,null==s||s===!1?s:s.key),e&&e.key,o),(a||0===a)&&(l+=a),l+="</a></li>\n  "
}function r(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u="function",h=this.escapeExpression,p=i.helperMissing,m=this;return d+='<a class="btn-gray dropdown-toggle" href="#playlist-type-dropdown" data-toggle="dropdown">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,(o=t&&t.currentType,null==o||o===!1?o:o.title),c):p.call(t,"t",(o=t&&t.currentType,null==o||o===!1?o:o.title),c)))+' <i class="caret-icon"></i></a>\n\n<ul class="dropdown-menu">\n  ',l=i.each.call(t,t&&t.types,{hash:{},inverse:m.noop,fn:m.programWithDepth(1,a,s,t),data:s}),(l||0===l)&&(d+=l),d+="\n</ul>\n"
})}),define("plex/desktop/views/dropdowns/PlaylistTypeDropdown",["hb!templates/desktop/dropdowns/PlaylistTypeDropdown.tpl","underscore","jquery","marionette"],function(e,t,i,n){"use strict";var s=n.ItemView.extend({id:"playlist-type-dropdown",tagName:"span",className:"dropdown",template:e,events:{"click .type-btn":"onClick"},types:[{key:0,title:"All"},{key:"audio",title:"Music"},{key:"video",title:"Video"}],initialize:function(){this.listenTo(this.model,"change:currentType",this.render)},serializeData:function(){return{currentType:t(this.types).findWhere({key:this.model.get("currentType")}),types:this.types}
},onClick:function(e){e.preventDefault();var t=i(e.currentTarget).data("key");this.model.set("currentType",t)}});return s}),define("hb!templates/desktop/modals/ImportPlaylistsModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}function r(e,t){var n,s="";return s+='\n              <option value="',(n=i.key)?n=n.call(e,{hash:{},data:t}):(n=e&&e.key,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+'">',(n=i.title)?n=n.call(e,{hash:{},data:t}):(n=e&&e.title,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+"</option>\n            "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u="function",h=this.escapeExpression,p=i.helperMissing,m=this;return d+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon glyphicon file-import"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Import from iTunes",c):p.call(t,"t","Import from iTunes",c)))+'\n      </h4>\n    </div>\n\n    <div class="modal-body">\n      <p class="help-block">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Importing from iTunes will import your music playlists. It will also import your ratings, the date you added the music, as well as play and skip counts for tracks in your library. Depending on how many tracks you have, this process can take many minutes to complete.",c):p.call(t,"t","Importing from iTunes will import your music playlists. It will also import your ratings, the date you added the music, as well as play and skip counts for tracks in your library. Depending on how many tracks you have, this process can take many minutes to complete.",c)))+'</p>\n\n\n      <div class="form-group ',l=i.unless.call(t,t&&t.showSections,{hash:{},inverse:m.noop,fn:m.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='">\n        <label class="control-label">\n          ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Add to library: ",c):p.call(t,"t","Add to library: ",c)))+'\n          <select id="section-list">\n            ',l=i.each.call(t,t&&t.sections,{hash:{},inverse:m.noop,fn:m.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='\n          </select>\n        </label>\n      </div>\n      <div class="form-group">\n        <label class="control-label">\n          <input type="checkbox" id="import-all"> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Overwrite existing playlists",c):p.call(t,"t","Overwrite existing playlists",c)))+'\n        </label>\n      </div>\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="cancel-btn btn btn-default" data-dismiss="modal">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Cancel",c):p.call(t,"t","Cancel",c)))+'</button>\n      <button type="button" class="import-btn btn btn-primary btn-loading">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Import",c):p.call(t,"t","Import",c)))+"</span>\n      </button>\n    </div>\n\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/ImportPlaylistsModal",["hb!templates/desktop/modals/ImportPlaylistsModal.tpl","underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/BaseModal"],function(e,t,i,n,s,a){"use strict";var r=a.extend({name:"importPlaylistsModal",className:"import-playlists-modal modal fade",template:e,ui:{importBtn:".import-btn",sections:"#section-list",importAll:"#import-all"},events:t.extend({"click .import-btn":"onImportClick"},a.prototype.events),initialize:function(e){a.prototype.initialize.apply(this,arguments),this.server=e.server,this.musicSections=e.server.get("sections").where({type:"artist"})
},serializeData:function(){var e=t.map(this.musicSections,function(e){return e.pick("key","title")});return{showSections:e.length>1,sections:e}},onImportClick:function(e){e.preventDefault();var a=this.ui.importBtn;a.addClass("active");var r=this.ui.sections.val(),o="/playlists/import/itunes?sectionID="+r;this.ui.importAll[0].checked&&(o+="&force=1");var l=t.extend(this.server.getXHROptions(o),{type:"PUT"}),c=i.ajax(l);c.done(t.bind(function(){s.trigger("show:alert",{type:"success",message:n("Playlists have been imported.")}),this.server.get("playlists").get("items").fetch(),this.hide()
},this)),c.fail(function(){s.trigger("show:alert",{type:"error",message:n("There was a problem importing.")})})}});return r}),define("plex/desktop/views/breadcrumbbar/PlaylistsBreadcrumbBarView",["hb!templates/desktop/breadcrumbbar/PlaylistsBreadcrumbBarView.tpl","marionette","plex/base/utils/dispatcher","plex/desktop/views/dropdowns/SectionDropdown","plex/desktop/views/dropdowns/PlaylistTypeDropdown","plex/desktop/views/modals/ImportPlaylistsModal"],function(e,t,i,n,s,a){"use strict";var r=t.Layout.extend({className:"breadcrumb-bar",template:e,ui:{itemsBadge:".items-badge"},regions:{sectionDropdown:".breadcrumb-dropdown",typeDropdown:".breadcrumb-subset-dropdown"},events:{"click .import-btn":"onImportClick"},initialize:function(){this.listenTo(this.model.get("items"),"reset remove add",this.onSizeChange);
var e=!(this.model.server.get("shared")||this.model.server.get("synced")),t=this.model.server.get("sections").where({type:"artist"}).length>0;this.canImportPlaylists=e&&t},serializeData:function(){return{totalSize:this.model.get("items").length,canImportPlaylists:this.canImportPlaylists}},onRender:function(){this.sectionDropdown.show(new n({model:this.model,collection:this.model.server.get("sections")})),this.typeDropdown.show(new s({model:this.model}))},onSizeChange:function(){this.ui.itemsBadge.text(this.model.get("items").length)
},onImportClick:function(e){this.limited||(e.preventDefault(),i.trigger("show:modal",new a({server:this.model.server})))}});return r}),define("hb!templates/desktop/playlists/PlaylistTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n      <span class="smart-badge badge badge-round">\n        <i class="icon glyphicon cogwheel"></i>\n      </span>\n    '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o="",l="function",c=this.escapeExpression,d=this;
return o+='<a class="media-poster-container" href="',(r=i.url)?r=r.call(t,{hash:{},data:s}):(r=t&&t.url,r=typeof r===l?r.call(t,{hash:{},data:s}):r),o+=c(r)+'">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    ',r=i["if"].call(t,t&&t.smart,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+='\n\n    <div class="media-poster-actions">\n      <button class="play-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="more-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon more"></i></button>\n    </div>\n\n  </div>\n\n  <div class="media-subtitle-1-fill media-heading playlist-title"></div>\n  <div class="media-subtitle-2-fill media-heading secondary playlist-duration"></div>\n</a>\n\n<div class="media-actions-dropdown playlist-actions-dropdown dropdown">\n  <div class="dropdown-toggle" data-toggle="dropdown"></div>\n</div>\n'
})}),define("plex/desktop/views/playlists/PlaylistTileListItem",["hb!templates/desktop/playlists/PlaylistTileListItem.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/utils/formatters/dateTimeUtil","plex/base/commands/commands","plex/desktop/views/images/CompositeImage","plex/desktop/views/dropdowns/MediaActionsDropdown","plex/desktop/views/modals/EditMetadataModal"],function(e,t,i,n,s,a,r,o,l,c){"use strict";var d=n.ItemView.extend({tagName:"li",className:"poster-item media-tile-list-item playlist-tile-list-item playlist",template:e,events:{"click .play-btn":"onPlayClick","click .edit-btn":"onEditClick","click .more-btn":"onMoreClick","hide.bs.dropdown .playlist-actions-dropdown":"onDropdownHide"},ui:{composite:".media-poster",actions:".media-poster-actions",dropdown:".media-actions-dropdown"},bindings:{".playlist-title":{modelAttribute:"title"},".playlist-duration":{modelAttribute:"duration",formatter:function(e){return a.formatBroadDuration(e)
}}},initialize:function(){t.bindAll(this,"onResize"),this.compositeImage=new o({model:this.model,width:150}),s.trigger("content.subscribe:resize",this.onResize)},serializeData:function(){var e="#!/server/"+encodeURIComponent(this.model.server.id);return e+="/playlist/"+this.model.get("ratingKey"),{url:e,smart:this.model.get("smart")}},onRender:function(){this.compositeImage.setElement(this.ui.composite)},onClose:function(){s.trigger("content.unsubscribe:resize",this.onResize)},onResize:function(e){this.containerSize=e
},onPlayClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),r.execute("playMedia",{item:this.model})},onEditClick:function(e){e.preventDefault(),s.trigger("show:modal",new c({model:this.model}))},onMoreClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.dropdown=new l({model:this.model}),this.ui.dropdown.append(this.dropdown.render().el),this.ui.dropdown.addClass("open"),this.$el.addClass("force-hover");var t=i(e.currentTarget),n=this.ui.actions.position().top,s=this.dropdown.getPosition(t,this.containerSize,n);
this.ui.dropdown.css(s)},onDropdownHide:function(){this.dropdown&&(this.dropdown.close(),this.dropdown=null,this.$el.removeClass("force-hover"))}});return d}),define("plex/desktop/views/playlists/PlaylistTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/playlists/PlaylistTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list playlist-tile-list",itemView:t,modelEvents:{"change:currentSort":"onListRefresh","change:currentType":"onListRefresh"},onListRefresh:function(){this.collection.clear(),this.collection.fetch({reset:!0,scope:"page"})
},onClose:function(){this.collection.clear()}});return i}),define("plex/desktop/views/playlists/PlaylistsView",["hb!templates/desktop/playlists/PlaylistsView.tpl","marionette","plex/base/utils/dispatcher","plex/desktop/views/actionbar/PlaylistsActionBarView","plex/desktop/views/breadcrumbbar/PlaylistsBreadcrumbBarView","plex/desktop/views/playlists/PlaylistTileList"],function(e,t,i,n,s,a){"use strict";var r=t.Layout.extend({className:"section-container",template:e,regions:{list:".playlists-container"},initialize:function(){i.trigger("show:bar","actionbar",new n({model:this.model})),i.trigger("show:bar","breadcrumbbar",new s({model:this.model}))
},onRender:function(){this.list.append(new a({model:this.model,collection:this.model.get("items")}),this.$el)},onClose:function(){i.trigger("hide:bar","actionbar"),i.trigger("hide:bar","breadcrumbbar")}});return r}),define("plex/desktop/routes/PlaylistController",["jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/routes/BaseController","plex/base/models/library/PlaylistModel","plex/desktop/views/error/ErrorView","plex/desktop/views/playlists/PlaylistsView","plex/desktop/views/details/DetailsView"],function(e,t,i,n,s,a,r,o){"use strict";
var l=n.extend({playlists:function(n){var s=this.populateView({serverID:n});s.done(function(n){var s=n.server.get("playlists"),o=n.server.get("sections").populate({scope:"page"}),l=s.get("items").populate({scope:"page"}),c=e.when(o,l);c.done(function(){i.trigger("show:view",new r({model:s}))}),c.fail(function(){i.trigger("show:view",new a({title:t("Playlists are unavailable for this server.")}))})})},playlist:function(n,r){var l=this.populateView({serverID:n});l.done(function(n){var l=n.server.get("sections").populate({scope:"page"}),c=new s({ratingKey:r},{server:n.server}),d=c.fetch({scope:"page"});
d.fail(function(){i.trigger("show:view",new a({title:t("Playlist not found.")}))}),e.when(l,d).done(function(){i.trigger("show:view",new o({model:c}))})})}});return l}),define("plex/desktop/routes/PlaylistRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/PlaylistController"],function(e,t){"use strict";var i=e.extend({controller:new t,appRoutes:{"!/server/:serverID/playlists":"playlists","!/server/:serverID/playlist/:key":"playlist"}});return i}),define("plex/base/models/server/ServerAccountModel",["underscore","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i){"use strict";
var n=i.extend({idAttribute:"key",whitelistedAttrs:["key","name","defaultAudioLanguage","autoSelectAudio","defaultSubtitleLanguage","subtitleMode"],url:function(){return this.get("key")},convert:function(i){var n=e.isObject(i)?i:t.parseXML(i);return n.Account&&(n=n.Account),t.parseBoolean(n,"autoSelectAudio"),n},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});return n}),define("hb!templates/desktop/settings/SettingsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"selected"
}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=this,h=i.helperMissing,p=this.escapeExpression;return d+='<ul class="nav nav-header pull-right">\n  <li class="web-nav-item"><a class="web-btn btn-gray ',c={hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.subset,"web",c):h.call(t,"if_eq",t&&t.subset,"web",c),(l||0===l)&&(d+=l),d+='" href="#!/settings/web">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Web",c):h.call(t,"t","Web",c)))+'</a></li>\n  <li class="server-nav-item ',l=i.unless.call(t,t&&t.hasPrimaryServer,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='"><a class="server-btn btn-gray ',c={hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.subset,"server",c):h.call(t,"if_eq",t&&t.subset,"server",c),(l||0===l)&&(d+=l),d+='" href="#!/settings/server">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Server",c):h.call(t,"t","Server",c)))+'</a></li>\n  <li class="users-nav-item ',l=i.unless.call(t,t&&t.signedIn,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='"><a class="users-btn btn-gray ',c={hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.subset,"users",c):h.call(t,"if_eq",t&&t.subset,"users",c),(l||0===l)&&(d+=l),d+='" href="#!/settings/users">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Users",c):h.call(t,"t","Users",c)))+'<span class="badge"></span></a></li>\n  <li class="devices-nav-item ',l=i.unless.call(t,t&&t.signedIn,{hash:{},inverse:u.noop,fn:u.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='"><a class="devices-btn btn-gray ',c={hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s},o=i.if_eq||t&&t.if_eq,l=o?o.call(t,t&&t.subset,"devices",c):h.call(t,"if_eq",t&&t.subset,"devices",c),(l||0===l)&&(d+=l),d+='" href="#!/settings/devices">',c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Devices",c):h.call(t,"t","Devices",c)))+"</a></li>\n</ul>\n\n<h2>",c={hash:{},data:s},d+=p((o=i.t||t&&t.t,o?o.call(t,"Settings",c):h.call(t,"t","Settings",c)))+'</h2>\n\n<div class="settings-container"></div>\n'
})}),define("hb!templates/desktop/settings/WebSettingsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n        <li><a class="card btn-gray" href="#sync-web-group">',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Sync",s):E.call(e,"t","Sync",s)))+"</a></li>\n      "}function r(e,t){var n,s,a="";return a+='\n            <span class="check-for-updates-container ',(n=i.updateState)?n=n.call(e,{hash:{},data:t}):(n=e&&e.updateState,n=typeof n===R?n.call(e,{hash:{},data:t}):n),a+=L(n)+'">\n              <a class="check-for-updates-btn label label-btn label-primary" href="#"><i class="label-icon glyphicon upload"></i> ',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Check for Updates",s):E.call(e,"t","Check for Updates",s)))+'</a>\n              <a class="checking-for-updates-btn label label-btn label-primary active" href="#"><i class="label-icon glyphicon upload"></i> ',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Checking for Updates",s):E.call(e,"t","Checking for Updates",s)))+'</a>\n              <a class="available-updates-btn label label-btn label-primary" href="#"><i class="label-icon glyphicon download"></i> ',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Download Updates",s):E.call(e,"t","Download Updates",s)))+'</a>\n              <a class="downloading-updates-btn label label-btn label-primary active" href="#"><i class="label-icon glyphicon download"></i> ',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Downloading Updates",s):E.call(e,"t","Downloading Updates",s)))+'</a>\n              <a class="refresh-updates-btn label label-btn label-primary" href="#"><i class="label-icon glyphicon repeat"></i> ',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Refresh to Apply",s):E.call(e,"t","Refresh to Apply",s)))+'</a>\n              <span class="install-info-label up-to-date-label"><i class="success-icon glyphicon ok-2"></i> ',s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,"Up to date",s):E.call(e,"t","Up to date",s)))+"</span>\n            </span>\n          "
}function o(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.language),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.language),r),(a||0===a)&&(o+=a),o+=">\n                ",(a=i.title)?a=a.call(e,{hash:{},data:t}):(a=e&&e.title,a=typeof a===R?a.call(e,{hash:{},data:t}):a),o+=L(a)+"\n              </option>\n            "
}function l(){return"selected"}function c(){return"checked"}function d(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.debugLevel),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.debugLevel),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n            "
}function u(e,t){var n,s,a,r="";return r+='\n          <div class="form-group">\n            <label for="chromecastAppID">Chromecast Receiver</label>\n            <select id="chromecastAppID">\n              ',n=i.each.call(e,e&&e.chromecastAppIDs,{hash:{},inverse:O.noop,fn:O.programWithDepth(13,h,t,e),data:t}),(n||0===n)&&(r+=n),r+='\n            </select>\n            <p class="help-block">Refresh after saving this setting for it to take effect.</p>\n          </div>\n\n          <div id="chromecast-custom-group" class="form-group ',a={hash:{},inverse:O.noop,fn:O.program(15,p,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,(n=e&&e.settings,null==n||n===!1?n:n.chromecastAppID),"custom",a):E.call(e,"if_neq",(n=e&&e.settings,null==n||n===!1?n:n.chromecastAppID),"custom",a),(s||0===s)&&(r+=s),r+='">\n            <label for="chromecastCustomAppID">Custom Chromecast Application ID</label>\n            <input type="text" id="chromecastCustomAppID" class="form-control" placeholder="Application ID" value="'+L((n=e&&e.settings,n=null==n||n===!1?n:n.chromecastCustomAppID,typeof n===R?n.apply(e):n))+'">\n            <p class="help-block">Refresh after saving this setting for it to take effect.</p>\n          </div>\n\n          <div class="form-group">\n            <label for="myPlexScheme">Plex.tv Scheme</label>\n            <input type="text" id="myPlexScheme" class="form-control" placeholder="https" value="'+L((n=e&&e.settings,n=null==n||n===!1?n:n.myPlexScheme,typeof n===R?n.apply(e):n))+'">\n          </div>\n\n          <div class="form-group">\n            <label for="myPlexUrl">Plex.tv Address</label>\n            <input type="text" id="myPlexUrl" class="form-control" placeholder="plex.tv" value="'+L((n=e&&e.settings,n=null==n||n===!1?n:n.myPlexUrl,typeof n===R?n.apply(e):n))+'">\n          </div>\n        '
}function h(e,t,n){var s,a,r,o="";return o+='\n                <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.chromecastAppID),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.chromecastAppID),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n              "
}function p(){return"hidden"}function m(e,t){var n,s,a="";return a+='\n            <li id="',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===R?n.call(e,{hash:{},data:t}):n),a+=L(n)+'" class="card card-sortable">\n              <div class="card-handle"><i class="glyphicon show-lines"></i></div>\n              <label for="',(n=i.enabledID)?n=n.call(e,{hash:{},data:t}):(n=e&&e.enabledID,n=typeof n===R?n.call(e,{hash:{},data:t}):n),a+=L(n)+'">\n                <input type="checkbox" id="',(n=i.enabledID)?n=n.call(e,{hash:{},data:t}):(n=e&&e.enabledID,n=typeof n===R?n.call(e,{hash:{},data:t}):n),a+=L(n)+'" ',n=i["if"].call(e,e&&e.enabled,{hash:{},inverse:O.noop,fn:O.program(8,c,t),data:t}),(n||0===n)&&(a+=n),a+="> ",s={hash:{},data:t},a+=L((n=i.t||e&&e.t,n?n.call(e,e&&e.title,s):E.call(e,"t",e&&e.title,s)))+"\n              </label>\n            </li>\n          "
}function f(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.index)?s=s.call(e,{hash:{},data:t}):(s=e&&e.index,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.index,(s=n&&n.settings,null==s||s===!1?s:s.localQuality),r):E.call(e,"if_eq",e&&e.index,(s=n&&n.settings,null==s||s===!1?s:s.localQuality),r),(a||0===a)&&(o+=a),o+=">\n                ",r={hash:{},data:t},o+=L((s=i.formatVideoQuality||e&&e.formatVideoQuality,s?s.call(e,e,r):E.call(e,"formatVideoQuality",e,r)))+"\n              </option>\n            "
}function g(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.index)?s=s.call(e,{hash:{},data:t}):(s=e&&e.index,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.index,(s=n&&n.settings,null==s||s===!1?s:s.remoteQuality),r):E.call(e,"if_eq",e&&e.index,(s=n&&n.settings,null==s||s===!1?s:s.remoteQuality),r),(a||0===a)&&(o+=a),o+=">\n                ",r={hash:{},data:t},o+=L((s=i.formatVideoQuality||e&&e.formatVideoQuality,s?s.call(e,e,r):E.call(e,"formatVideoQuality",e,r)))+"\n              </option>\n            "
}function v(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.index)?s=s.call(e,{hash:{},data:t}):(s=e&&e.index,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.index,(s=n&&n.settings,null==s||s===!1?s:s.channelQuality),r):E.call(e,"if_eq",e&&e.index,(s=n&&n.settings,null==s||s===!1?s:s.channelQuality),r),(a||0===a)&&(o+=a),o+=">\n                ",r={hash:{},data:t},o+=L((s=i.formatVideoQuality||e&&e.formatVideoQuality,s?s.call(e,e,r):E.call(e,"formatVideoQuality",e,r)))+"\n              </option>\n            "
}function y(e,t){var n,s,a,r="";return r+='\n          <div class="form-group">\n            <label class="control-label">\n              <input type="checkbox" id="dash" ',s=i["if"].call(e,(n=e&&e.settings,null==n||n===!1?n:n.dash),{hash:{},inverse:O.noop,fn:O.program(8,c,t),data:t}),(s||0===s)&&(r+=s),r+="> ",a={hash:{},data:t},r+=L((n=i.t||e&&e.t,n?n.call(e,"Experimental Player",a):E.call(e,"t","Experimental Player",a)))+'\n            </label>\n            <p class="help-block">',a={hash:{},data:t},r+=L((n=i.t||e&&e.t,n?n.call(e,"Use the experimental video player, which supports streaming to the HTML5 video element instead of the Flash player. Requires Plex Media Server 0.9.8.6 or later.",a):E.call(e,"t","Use the experimental video player, which supports streaming to the HTML5 video element instead of the Flash player. Requires Plex Media Server 0.9.8.6 or later.",a)))+"</p>\n          </div>\n        "
}function b(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'"',r={hash:{},inverse:O.noop,fn:O.program(28,w,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.audioBoost),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.audioBoost),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n            "
}function w(){return" selected"}function x(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'"',r={hash:{},inverse:O.noop,fn:O.program(28,w,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.subtitleSize),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.subtitleSize),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n            "
}function k(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'" ',r={hash:{},inverse:O.noop,fn:O.program(6,l,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.subtitlesBurnLevel),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.subtitlesBurnLevel),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n            "
}function S(e,t,n){var s,a,r,o="";return o+='\n              <option value="',(s=i.value)?s=s.call(e,{hash:{},data:t}):(s=e&&e.value,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'"',r={hash:{},inverse:O.noop,fn:O.program(28,w,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.extrasPrefixCount),r):E.call(e,"if_eq",e&&e.value,(s=n&&n.settings,null==s||s===!1?s:s.extrasPrefixCount),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n            "
}function C(e,t){var n,s,a,r="";return r+='\n        <div id="sync-web-group" class="settings-group">\n          <h4 class="settings-header">',a={hash:{},data:t},r+=L((n=i.t||e&&e.t,n?n.call(e,"Default Quality",a):E.call(e,"t","Default Quality",a)))+'</h4>\n\n          <div class="form-group">\n            <label for="syncVideoQuality">',a={hash:{},data:t},r+=L((n=i.t||e&&e.t,n?n.call(e,"Video",a):E.call(e,"t","Video",a)))+'</label>\n            <select id="syncVideoQuality">\n              ',s=i.each.call(e,e&&e.syncQualities,{hash:{},inverse:O.noop,fn:O.programWithDepth(37,P,t,e),data:t}),(s||0===s)&&(r+=s),r+='\n            </select>\n          </div>\n\n          <div class="form-group">\n            <label for="syncAudioQuality">',a={hash:{},data:t},r+=L((n=i.t||e&&e.t,n?n.call(e,"Audio",a):E.call(e,"t","Audio",a)))+'</label>\n            <select id="syncAudioQuality">\n              ',s=i.each.call(e,e&&e.syncQualities,{hash:{},inverse:O.noop,fn:O.programWithDepth(39,A,t,e),data:t}),(s||0===s)&&(r+=s),r+='\n            </select>\n          </div>\n\n          <div class="form-group">\n            <label for="syncPictureQuality">',a={hash:{},data:t},r+=L((n=i.t||e&&e.t,n?n.call(e,"Photo",a):E.call(e,"t","Photo",a)))+'</label>\n            <select id="syncPictureQuality">\n              ',s=i.each.call(e,e&&e.syncQualities,{hash:{},inverse:O.noop,fn:O.programWithDepth(41,_,t,e),data:t}),(s||0===s)&&(r+=s),r+="\n            </select>\n          </div>\n        </div>\n      "
}function P(e,t,n){var s,a,r,o="";return o+='\n                <option value="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'"',r={hash:{},inverse:O.noop,fn:O.program(28,w,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.key,(s=n&&n.settings,null==s||s===!1?s:s.syncVideoQuality),r):E.call(e,"if_eq",e&&e.key,(s=n&&n.settings,null==s||s===!1?s:s.syncVideoQuality),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n              "
}function A(e,t,n){var s,a,r,o="";return o+='\n                <option value="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'"',r={hash:{},inverse:O.noop,fn:O.program(28,w,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.key,(s=n&&n.settings,null==s||s===!1?s:s.syncAudioQuality),r):E.call(e,"if_eq",e&&e.key,(s=n&&n.settings,null==s||s===!1?s:s.syncAudioQuality),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n              "
}function _(e,t,n){var s,a,r,o="";return o+='\n                <option value="',(s=i.key)?s=s.call(e,{hash:{},data:t}):(s=e&&e.key,s=typeof s===R?s.call(e,{hash:{},data:t}):s),o+=L(s)+'"',r={hash:{},inverse:O.noop,fn:O.program(28,w,t),data:t},s=i.if_eq||e&&e.if_eq,a=s?s.call(e,e&&e.key,(s=n&&n.settings,null==s||s===!1?s:s.syncPictureQuality),r):E.call(e,"if_eq",e&&e.key,(s=n&&n.settings,null==s||s===!1?s:s.syncPictureQuality),r),(a||0===a)&&(o+=a),o+=">",r={hash:{},data:t},o+=L((s=i.t||e&&e.t,s?s.call(e,e&&e.title,r):E.call(e,"t",e&&e.title,r)))+"</option>\n              "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var I,T,M,D="",E=i.helperMissing,L=this.escapeExpression,R="function",O=this;return D+='<div class="filter-bar">\n  <button class="toggle-advanced-btn btn btn-sm btn-default pull-right basic-setting">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Show Advanced",M):E.call(t,"t","Show Advanced",M)))+'</button>\n  <button class="toggle-advanced-btn btn btn-sm btn-default pull-right advanced-setting">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Hide Advanced",M):E.call(t,"t","Hide Advanced",M)))+'</button>\n</div>\n\n<div class="row">\n  <div class="col-sm-4 col-md-3">\n    <ul class="settings-nav nav nav-cards">\n      <li><a class="card btn-gray selected" href="#general-web-group">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"General",M):E.call(t,"t","General",M)))+'</a></li>\n      <li class="advanced-setting"><a class="card btn-gray" href="#debug-web-group">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Debug",M):E.call(t,"t","Debug",M)))+'</a></li>\n      <li><a class="card btn-gray" href="#dashboard-web-group">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Dashboard",M):E.call(t,"t","Dashboard",M)))+'</a></li>\n      <li><a class="card btn-gray" href="#search-web-group">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Search",M):E.call(t,"t","Search",M)))+'</a></li>\n      <li><a class="card btn-gray" href="#player-web-group">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Player",M):E.call(t,"t","Player",M)))+"</a></li>\n      ",T=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:O.noop,fn:O.program(1,a,s),data:s}),(T||0===T)&&(D+=T),D+='\n    </ul>\n  </div>\n\n  <div class="col-sm-8 col-md-9">\n    <form id="web-settings-form">\n      <div id="general-web-group" class="settings-group active">\n        <h4 class="version-title">\n          ',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Version",M):E.call(t,"t","Version",M)))+" ",(T=i.version)?T=T.call(t,{hash:{},data:s}):(T=t&&t.version,T=typeof T===R?T.call(t,{hash:{},data:s}):T),D+=L(T)+"\n\n          ",T=i["if"].call(t,t&&t.showUpdate,{hash:{},inverse:O.noop,fn:O.program(3,r,s),data:s}),(T||0===T)&&(D+=T),D+='\n        </h4>\n\n        <div class="form-group">\n          <label for="language">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Language",M):E.call(t,"t","Language",M)))+'</label>\n          <select id="language">\n            ',T=i.each.call(t,t&&t.languages,{hash:{},inverse:O.noop,fn:O.programWithDepth(5,o,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Help us translate Plex/Web into your language {1}here{2}.","<a href='https://getlocalization.com/plexweb' target='_blank'>","</a>",M):E.call(t,"t","Help us translate Plex/Web into your language {1}here{2}.","<a href='https://getlocalization.com/plexweb' target='_blank'>","</a>",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="autoLogin" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.autoLogin),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Automatically sign in",M):E.call(t,"t","Automatically sign in",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Do not prompt to select a user or enter a PIN during startup on this device.",M):E.call(t,"t","Do not prompt to select a user or enter a PIN during startup on this device.",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="playThemeMusic" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.playThemeMusic),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Play Theme Music",M):E.call(t,"t","Play Theme Music",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Automatically play theme music in the background when available.",M):E.call(t,"t","Automatically play theme music in the background when available.",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="showUnwatchedIcons" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.showUnwatchedIcons),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Show Unwatched Icons",M):E.call(t,"t","Show Unwatched Icons",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Show unwatched icons in list items.",M):E.call(t,"t","Show unwatched icons in list items.",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="keyboardShortcuts" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.keyboardShortcuts),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Enable Keyboard Shortcuts",M):E.call(t,"t","Enable Keyboard Shortcuts",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Press ? to view the list of {1}available shortcuts{2}.","<a class='keyboard-shortcuts-btn' href='#'>","</a>",M):E.call(t,"t","Press ? to view the list of {1}available shortcuts{2}.","<a class='keyboard-shortcuts-btn' href='#'>","</a>",M)))+'</p>\n        </div>\n      </div>\n\n      <div id="debug-web-group" class="settings-group">\n        <div class="form-group">\n          <label for="debugLevel">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Debug Level",M):E.call(t,"t","Debug Level",M)))+'</label>\n          <select id="debugLevel" data-type="int">\n            ',T=i.each.call(t,t&&t.debugLevels,{hash:{},inverse:O.noop,fn:O.programWithDepth(10,d,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"You can view the debug logs {1}here{2}.","<a href='#!/logs'>","</a>",M):E.call(t,"t","You can view the debug logs {1}here{2}.","<a href='#!/logs'>","</a>",M)))+"</p>\n        </div>\n\n        ",T=i["if"].call(t,t&&t.isNinja,{hash:{},inverse:O.noop,fn:O.program(12,u,s),data:s}),(T||0===T)&&(D+=T),D+='\n      </div>\n\n      <div id="dashboard-web-group" class="settings-group">\n        <p class="help-block sortable-help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Drag the items below to reorder your dashboard content.",M):E.call(t,"t","Drag the items below to reorder your dashboard content.",M)))+'</p>\n\n        <ul class="list dashboard-list">\n          ',T=i.each.call(t,t&&t.dashboardPriorities,{hash:{},inverse:O.noop,fn:O.program(17,m,s),data:s}),(T||0===T)&&(D+=T),D+='\n        </ul>\n      </div>\n\n      <div id="search-web-group" class="settings-group">\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="sharedSearch" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.sharedSearch),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Search Shared Libraries",M):E.call(t,"t","Search Shared Libraries",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Allow searching libraries that have been shared with you.",M):E.call(t,"t","Allow searching libraries that have been shared with you.",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="channelSearch" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.channelSearch),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Search Channels",M):E.call(t,"t","Search Channels",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Allow searching channels that have enabled search.",M):E.call(t,"t","Allow searching channels that have enabled search.",M)))+'</p>\n        </div>\n      </div>\n\n      <div id="player-web-group" class="settings-group">\n        <h4 class="settings-header">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Streaming Quality",M):E.call(t,"t","Streaming Quality",M)))+'</h4>\n\n        <div class="form-group">\n          <label for="localQuality">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Local Quality",M):E.call(t,"t","Local Quality",M)))+'</label>\n          <select id="localQuality" data-type="int">\n            <option value="-1">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Original",M):E.call(t,"t","Original",M)))+"</option>\n            ",T=i.each.call(t,t&&t.availableQualities,{hash:{},inverse:O.noop,fn:O.programWithDepth(19,f,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n        </div>\n\n        <div class="form-group">\n          <label for="remoteQuality">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Remote Quality",M):E.call(t,"t","Remote Quality",M)))+'</label>\n          <select id="remoteQuality" data-type="int">\n            <option value="-1">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Original",M):E.call(t,"t","Original",M)))+"</option>\n            ",T=i.each.call(t,t&&t.availableQualities,{hash:{},inverse:O.noop,fn:O.programWithDepth(21,g,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n        </div>\n\n        <div class="form-group">\n          <label for="channelQuality">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Channel Quality",M):E.call(t,"t","Channel Quality",M)))+'</label>\n          <select id="channelQuality" data-type="int">\n            <option value="-1">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Original",M):E.call(t,"t","Original",M)))+"</option>\n            ",T=i.each.call(t,t&&t.availableQualities,{hash:{},inverse:O.noop,fn:O.programWithDepth(23,v,s,t),data:s}),(T||0===T)&&(D+=T),D+="\n          </select>\n        </div>\n\n        ",T=i["if"].call(t,t&&t.showExperimentalPlayer,{hash:{},inverse:O.noop,fn:O.program(25,y,s),data:s}),(T||0===T)&&(D+=T),D+='\n\n        <div class="form-group advanced-setting">\n          <label class="control-label">\n            <input type="checkbox" id="directPlay" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.directPlay),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Direct Play",M):E.call(t,"t","Direct Play",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Allows the player to play compatible media without any conversion. In most browsers, direct play supports MP4 videos with h264 video and AAC audio. Videos with subtitles cannot be played directly.",M):E.call(t,"t","Allows the player to play compatible media without any conversion. In most browsers, direct play supports MP4 videos with h264 video and AAC audio. Videos with subtitles cannot be played directly.",M)))+'</p>\n        </div>\n\n        <div class="form-group advanced-setting">\n          <label class="control-label">\n            <input type="checkbox" id="directStream" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.directStream),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Direct Stream",M):E.call(t,"t","Direct Stream",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Allows the server to copy compatible audio and video streams without converting them.",M):E.call(t,"t","Allows the server to copy compatible audio and video streams without converting them.",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label class="control-label">\n            <input type="checkbox" id="autoResolution" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.autoResolution),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Automatically Select Resolution",M):E.call(t,"t","Automatically Select Resolution",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"When multiple resolutions are available for a video, automatically use the best resolution below the maximum quality.",M):E.call(t,"t","When multiple resolutions are available for a video, automatically use the best resolution below the maximum quality.",M)))+'</p>\n        </div>\n\n        <h4 class="settings-header">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Audio & Subtitles",M):E.call(t,"t","Audio & Subtitles",M)))+'</h4>\n\n        <div class="form-group advanced-setting">\n          <label class="control-label">\n            <input type="checkbox" id="allowAC3" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.allowAC3),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Allow Direct Play of AC3 Audio",M):E.call(t,"t","Allow Direct Play of AC3 Audio",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Allow MP4 videos with AC3 audio to be played directly. Browser support for AC3 audio is limited.",M):E.call(t,"t","Allow MP4 videos with AC3 audio to be played directly. Browser support for AC3 audio is limited.",M)))+'</p>\n        </div>\n\n        <div class="form-group advanced-setting">\n          <label class="control-label">\n            <input type="checkbox" id="preferAAC" ',T=i["if"].call(t,(I=t&&t.settings,null==I||I===!1?I:I.preferAAC),{hash:{},inverse:O.noop,fn:O.program(8,c,s),data:s}),(T||0===T)&&(D+=T),D+="> ",M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Prefer AAC Audio",M):E.call(t,"t","Prefer AAC Audio",M)))+'\n          </label>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Prefer AAC over MP3 when transcoding audio. Some devices, like the Wii U, only support HLS with AAC audio.",M):E.call(t,"t","Prefer AAC over MP3 when transcoding audio. Some devices, like the Wii U, only support HLS with AAC audio.",M)))+'</p>\n        </div>\n\n        <div class="form-group">\n          <label for="audioBoost">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Audio Boost",M):E.call(t,"t","Audio Boost",M)))+'</label>\n          <select id="audioBoost" data-type="int">\n            ',T=i.each.call(t,t&&t.audioBoostLevels,{hash:{},inverse:O.noop,fn:O.programWithDepth(27,b,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n        </div>\n\n        <div class="form-group">\n          <label for="subtitleSize">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Subtitle Size",M):E.call(t,"t","Subtitle Size",M)))+'</label>\n          <select id="subtitleSize" data-type="int">\n            ',T=i.each.call(t,t&&t.subtitleSizes,{hash:{},inverse:O.noop,fn:O.programWithDepth(30,x,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n        </div>\n\n        <div class="form-group">\n          <label for="subtitlesBurnLevel">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Burn Subtitles",M):E.call(t,"t","Burn Subtitles",M)))+'</label>\n          <select id="subtitlesBurnLevel">\n            ',T=i.each.call(t,t&&t.subtitlesBurnLevels,{hash:{},inverse:O.noop,fn:O.programWithDepth(32,k,s,t),data:s}),(T||0===T)&&(D+=T),D+='\n          </select>\n          <p class="help-block">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Determines if the server should burn in subtitles when converting video depending on the subtitles format. Avoiding burn in improves server performance and is only supported by the HTML5 player.",M):E.call(t,"t","Determines if the server should burn in subtitles when converting video depending on the subtitles format. Avoiding burn in improves server performance and is only supported by the HTML5 player.",M)))+'</p>\n        </div>\n\n        <h4 class="settings-header">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Extras",M):E.call(t,"t","Extras",M)))+'</h4>\n\n        <div class="form-group">\n          <label for="extrasPrefixCount">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Cinema Trailers to Play Before Movies",M):E.call(t,"t","Cinema Trailers to Play Before Movies",M)))+'</label>\n          <select id="extrasPrefixCount" data-type="int">\n            ',T=i.each.call(t,t&&t.extrasPrefixCounts,{hash:{},inverse:O.noop,fn:O.programWithDepth(34,S,s,t),data:s}),(T||0===T)&&(D+=T),D+="\n          </select>\n        </div>\n      </div>\n\n      ",T=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:O.noop,fn:O.program(36,C,s),data:s}),(T||0===T)&&(D+=T),D+='\n\n      <div class="form-footer">\n        <button type="submit" class="submit-btn btn btn-lg btn-primary btn-loading disabled">\n          <div class="loading loading-sm"></div>\n          <span class="btn-label">',M={hash:{},data:s},D+=L((I=i.t||t&&t.t,I?I.call(t,"Save Changes",M):E.call(t,"t","Save Changes",M)))+'</span>\n        </button>\n\n        <span class="form-message"></span>\n      </div>\n    </form>\n  </div>\n</div>\n'
})}),define("plex/base/utils/types/syncQualities",["underscore","plex/base/utils/BaseClass"],function(e,t){"use strict";var i=t.extend({qualities:[{key:"low",title:"Low",videoQuality:24,videoResolutionFactor:.5,photoQuality:24,musicBitrate:96},{key:"medium",title:"Medium",videoQuality:49,videoResolutionFactor:.75,photoQuality:49,musicBitrate:128},{key:"high",title:"High",videoQuality:74,videoResolutionFactor:1,photoQuality:74,musicBitrate:192},{key:"highest",title:"Highest",videoQuality:99,photoQuality:99,musicBitrate:320}],initialize:function(){this.byKey=e.reduce(this.qualities,function(e,t){return e[t.key]=t,e
},{})},getQuality:function(e){return this.byKey[e]},getQualityByVideoQuality:function(e){return 25>=e?this.byKey.low:50>=e?this.byKey.medium:75>=e?this.byKey.high:this.byKey.highest}});return new i}),define("plex/base/utils/constants/debugLevels",[],function(){"use strict";var e={DISABLED:0,ENABLED:1,VERBOSE:2};return e.settings=[{value:e.DISABLED,title:"Disabled"},{value:e.ENABLED,title:"Enabled"},{value:e.VERBOSE,title:"Verbose"}],e}),define("plex/desktop/utils/constants/subtitleSizes",[],function(){"use strict";
var e={TINY:50,SMALL:75,NORMAL:100,LARGE:125,HUGE:200};return e.settings=[{value:e.TINY,title:"Tiny"},{value:e.SMALL,title:"Small"},{value:e.NORMAL,title:"Normal"},{value:e.LARGE,title:"Large"},{value:e.HUGE,title:"Huge"}],e}),define("plex/desktop/utils/constants/audioBoostLevels",[],function(){"use strict";var e={NONE:100,SMALL:150,LARGE:200,HUGE:250};return e.settings=[{value:e.NONE,title:"None"},{value:e.SMALL,title:"Small"},{value:e.LARGE,title:"Large"},{value:e.HUGE,title:"Huge"}],e}),define("plex/desktop/views/settings/WebSettingsView",["hb!templates/desktop/settings/WebSettingsView.tpl","underscore","jquery","marionette","sortable","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/capabilities","plex/base/utils/languageUtil","plex/base/utils/playerQualities","plex/base/utils/types/syncQualities","plex/base/utils/constants/debugLevels","plex/base/utils/constants/subtitlesBurnLevels","plex/desktop/utils/constants/castAppIDs","plex/desktop/utils/constants/subtitleSizes","plex/desktop/utils/constants/audioBoostLevels","plex/base/adapters/localizerAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/base/models/config","plex/base/adapters/keyboardShortcutsAdapter","plex/desktop/views/modals/KeyboardShortcutsModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y,b,w,x){"use strict";
var k=[{value:0,title:"None"},{value:1,title:"1"},{value:2,title:"2"},{value:3,title:"3"},{value:4,title:"4"},{value:5,title:"5"}],S=[{id:"dashboardPriorityOnDeck",enabledID:"dashboardOnDeckEnabled",title:"On Deck"},{id:"dashboardPriorityRecentlyAdded",enabledID:"dashboardRecentlyAddedEnabled",title:"Recently Added"},{id:"dashboardPriorityChannels",enabledID:"dashboardChannelsEnabled",title:"Channels"},{id:"dashboardPriorityQueue",enabledID:"dashboardQueueEnabled",title:"Watch Later"},{id:"dashboardPriorityRecommendations",enabledID:"dashboardRecommendationsEnabled",title:"Recommended"}],C=n.ItemView.extend({className:"web-settings-container",template:e,ui:{checkForUpdates:".check-for-updates-container",dashboardList:".dashboard-list",chromecastCustomGroup:"#chromecast-custom-group",submitBtn:".submit-btn",message:".form-message"},events:{"click .toggle-advanced-btn":"onToggleAdvancedClick","click .settings-nav a":"onSettingsGroupClick","click .check-for-updates-btn":"onCheckForUpdatesClick","click .available-updates-btn":"onDownloadUpdatesClick","click .refresh-updates-btn":"onRefreshUpdatesClick","click .keyboard-shortcuts-btn":"onKeyboardShortcutsClick","change #chromecastAppID":"onChromecastAppIDChange","change input[id]":"onInputChange","keyup input[type=text]":"onInputChange","change select[id]":"onInputChange","update .dashboard-list":"onDashboardUpdate","submit #web-settings-form":"onSubmit"},onlyAfterRender:["saveChanges"],initialize:function(){this.changes={};
var e=y.get("user");this.listenTo(e,"change:signedIn",this.onSignedInChange),this.listenTo(y,"change:primaryServer",this.render),this.listenTo(y,"change:updateState",this.onUpdateStateChange),this.listenTo(r,"shortcut:save",this.saveChanges)},serializeData:function(){var e=[],i=this.model.toJSON(),n=y.get("user"),s=n.hasPlexPass(),a=n.isNinja(),r=y.get("servers"),v=r.findWhere({bundled:!0});return t.each(t.keys(g.getLanguages()),function(t){e.push({value:t,title:l.getLanguageName(t)})}),t.each(S,function(e){e.value=i[e.id],e.enabled=i[e.enabledID]
}),{settings:i,hasPlexPass:s,isNinja:a,showExperimentalPlayer:o.hasMediaSource&&b.get("flash"),showUpdate:v&&!v.get("shared"),updateState:y.get("updateState"),version:y.get("version"),languages:e,debugLevels:u.settings,subtitlesBurnLevels:h.settings,chromecastAppIDs:p.settings,availableQualities:c.getAvailableQualities().reverse(),subtitleSizes:m.settings,audioBoostLevels:f.settings,extrasPrefixCounts:k,syncQualities:d.qualities,dashboardPriorities:t.sortBy(S,"value")}},saveChanges:function(){var e=this.ui.submitBtn,i=this.ui.message;
if(!e.isDisabled()){e.addClass("active");var n=!!this.changes.language,s=this.model.save(this.changes);s.done(t.bind(function(){this.changes={},n||(e.addClass("disabled"),i.text(a("Your changes have been saved.")))},this)),s.fail(t.bind(function(){i.text(a("Your changes could not be saved."))},this)),s.always(t.bind(function(){n||e.removeClass("active")},this))}},onRender:function(){this.sortable=new s(this.ui.dashboardList[0],{draggable:".card-sortable"})},onClose:function(){"latest"===y.get("updateState")&&y.set("updateState","none")
},onSignedInChange:function(e,t){null!=t&&this.render()},onUpdateStateChange:function(e,t){this.ui.checkForUpdates.removeClass(y.previous("updateState")),this.ui.checkForUpdates.addClass(t)},onToggleAdvancedClick:function(e){e.preventDefault();var t=this.$el.hasClass("show-advanced");t&&this.$(".advanced-setting > .selected").length&&this.$(".nav a:first").click(),this.$el.toggleClass("show-advanced",!t)},onSettingsGroupClick:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.attr("href");
this.$(".settings-group").removeClass("active"),this.$(n).addClass("active"),this.$(".nav a").removeClass("selected"),t.addClass("selected")},onCheckForUpdatesClick:function(e){e.preventDefault(),v.execute("checkForBundleUpdates",{checkAppStore:!0})},onDownloadUpdatesClick:function(e){e.preventDefault(),v.execute("installBundleUpdates")},onRefreshUpdatesClick:function(e){e.preventDefault(),window.location.reload(!0)},onKeyboardShortcutsClick:function(e){e.preventDefault(),r.trigger("show:modal",new x({shortcuts:w.prop("shortcuts")}))
},onChromecastAppIDChange:function(e){var t=e.currentTarget.value===p.CUSTOM;this.ui.chromecastCustomGroup.toggleClass("hidden",!t)},onInputChange:function(e){var t=i(e.currentTarget),n=e.currentTarget,s=n.value;"checkbox"===n.type&&(s=t.prop("checked")),"int"===t.data("type")&&(s=parseInt(s,10)),this.changes[n.id]=s,this.ui.submitBtn.removeClass("disabled"),this.ui.message.text("")},onDashboardUpdate:function(){var e={};this.ui.dashboardList.find(".card-sortable").each(function(t,i){e[i.id]=t+1}),t.extend(this.changes,e),this.ui.submitBtn.removeClass("disabled"),this.ui.message.text("")
},onSubmit:function(e){e.preventDefault(),this.saveChanges()}});return C}),define("hb!templates/desktop/settings/server/ServerSettingsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n    <div class="filter-bar-right">\n      <button class="toggle-advanced-btn btn btn-sm btn-default basic-setting">',s={hash:{},data:t},a+=c((n=i.t||e&&e.t,n?n.call(e,"Show Advanced",s):l.call(e,"t","Show Advanced",s)))+'</button>\n      <button class="toggle-advanced-btn btn btn-sm btn-default advanced-setting">',s={hash:{},data:t},a+=c((n=i.t||e&&e.t,n?n.call(e,"Hide Advanced",s):l.call(e,"t","Hide Advanced",s)))+"</button>\n    </div>\n  "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o="",l=i.helperMissing,c=this.escapeExpression,d=this;return o+='<div class="filter-bar">\n  ',r=i.unless.call(t,t&&t.shared,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+='\n</div>\n\n<div class="settings-row row">\n  <div class="nav-region col-sm-4 col-md-3"></div>\n  <div class="pane-region col-sm-8 col-md-9"></div>\n</div>\n'})}),define("hb!templates/desktop/dropdowns/PrimaryServerDropdown",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n  <a class="dropdown-toggle" href="#primary-server-dropdown" data-toggle="dropdown">\n    <span class="dropdown-friendly-name">'+h((n=e&&e.currentServer,n=null==n||n===!1?n:n.friendlyName,typeof n===u?n.apply(e):n))+'</span> <i class="caret-icon"></i>\n  </a>\n\n  <ul class="dropdown-menu">\n    ',s=i.each.call(e,e&&e.servers,{hash:{},inverse:p.noop,fn:p.programWithDepth(2,r,t,e),data:t}),(s||0===s)&&(a+=s),a+="\n  </ul>\n"}function r(e,t,n){var s,a,r,l="";return l+='\n      <li><a data-id="',(s=i.machineIdentifier)?s=s.call(e,{hash:{},data:t}):(s=e&&e.machineIdentifier,s=typeof s===u?s.call(e,{hash:{},data:t}):s),l+=h(s)+'" href="#"><span class="dropdown-truncated-label">',(s=i.friendlyName)?s=s.call(e,{hash:{},data:t}):(s=e&&e.friendlyName,s=typeof s===u?s.call(e,{hash:{},data:t}):s),l+=h(s)+"</span>",r={hash:{},inverse:p.noop,fn:p.program(3,o,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,(s=n&&n.currentServer,null==s||s===!1?s:s.machineIdentifier),e&&e.machineIdentifier,r):m.call(e,"if_eq",(s=n&&n.currentServer,null==s||s===!1?s:s.machineIdentifier),e&&e.machineIdentifier,r),(a||0===a)&&(l+=a),l+="</a></li>\n    "
}function o(){return'<i class="dropdown-selected-icon glyphicon ok-2"></i>'}function l(e){var t,i="";return i+='\n  <span class="dropdown-placeholder">\n    <span class="dropdown-friendly-name">'+h((t=e&&e.currentServer,t=null==t||t===!1?t:t.friendlyName,typeof t===u?t.apply(e):t))+"</span>\n  </span>\n"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var c,d="",u="function",h=this.escapeExpression,p=this,m=i.helperMissing;return c=i["if"].call(t,t&&t.showDropdown,{hash:{},inverse:p.program(5,l,s),fn:p.program(1,a,s),data:s}),(c||0===c)&&(d+=c),d+="\n"
})}),define("plex/desktop/views/dropdowns/PrimaryServerDropdown",["hb!templates/desktop/dropdowns/PrimaryServerDropdown.tpl","underscore","jquery","marionette","plex/base/models/appModel","plex/base/models/server/serverStorageModel"],function(e,t,i,n,s,a){"use strict";var r=n.ItemView.extend({id:"primary-server-dropdown",tagName:"span",className:"dropdown",template:e,collectionEvents:{"change:friendlyName":"render","change:authorized":"onServerAuthorizedChange"},events:{"click .dropdown-menu a":"onServerClick"},initialize:function(){this.model=s.get("primaryServer"),this.collection=s.get("servers"),this.listenTo(s,"change:primaryServer",this.render)
},serializeData:function(){var e=this.collection.toJSON(),i=t.filter(e,function(e){return e.authorized?e.cloud||e.shared||e.synced?!1:!0:!1});return{showDropdown:i.length>1,servers:i,currentServer:this.model?this.model.toJSON():null}},onServerAuthorizedChange:function(e,t){t&&this.render()},onServerClick:function(e){e.preventDefault();var t=i(e.currentTarget).data("id"),n=this.collection.get(t);n&&(s.set("primaryServer",n),a.save("lastPrimaryServerID",n.id))}});return r}),define("hb!templates/desktop/settings/server/ServerSettingsNavListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l="function",c=this.escapeExpression,d=i.helperMissing;return o+='<a class="card btn-gray" href="#" data-group="',(a=i.id)?a=a.call(t,{hash:{},data:s}):(a=t&&t.id,a=typeof a===l?a.call(t,{hash:{},data:s}):a),o+=c(a)+'">\n  <span class="modal-nav-icon">\n    <i class="server-settings-status-icon unknown glyphicon circle-question-mark"></i>\n    <i class="server-settings-status-icon error glyphicon circle-exclamation-mark"></i>\n    <i class="server-settings-status-icon success glyphicon circle-ok"></i>\n  </span>\n\n  ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,t&&t.title,r):d.call(t,"t",t&&t.title,r)))+"\n</a>\n"
})}),define("plex/desktop/views/settings/server/ServerSettingsNavListItem",["hb!templates/desktop/settings/server/ServerSettingsNavListItem.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({tagName:"li",className:"server-settings-nav-list-item",template:e,ui:{card:".card"},events:{"click .card":"onClick"},select:function(){this.ui.card.addClass("selected")},deselect:function(){this.ui.card.removeClass("selected")},showDecorator:function(e){this.currentStatus&&this.$el.removeClass(this.currentStatus),this.currentStatus=e,this.$el.addClass(e)
},onClick:function(e){e.preventDefault(),this.ui.card.hasClass("selected")||this.trigger("change:pane",this.model.id)}});return i}),define("plex/desktop/views/settings/server/ServerSettingsNavList",["marionette","plex/desktop/views/settings/server/ServerSettingsNavListItem"],function(e,t){"use strict";var i=e.CollectionView.extend({tagName:"ul",className:"nav nav-cards",itemView:t,selectGroup:function(e){this.selectedView&&this.selectedView.deselect(),this.selectedView=this.children.findByModel(this.collection.get(e)),this.selectedView.select()
},showDecorator:function(e,t){var i=this.children.findByModel(this.collection.get(e));i.showDecorator(t)}});return i}),define("hb!templates/desktop/settings/server/ServerSettingsGeneralPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n    ",s={hash:{idSuffix:"_c"},data:t},a+=d((n=i.partial||e&&e.partial,n?n.call(e,"setting",s):c.call(e,"partial","setting",s)))+"\n  "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;
return l+='<div class="sign-in-region"></div>\n\n<hr>\n\n<form id="server-settings-form">\n  <div class="form-group">\n    <h4 class="version-header"><span class="version"></span> <span class="update-region"></span></h4>\n  </div>\n\n  ',r=i.each.call(t,t,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='\n\n  <div class="form-footer">\n    <button type="submit" class="submit-btn btn btn-lg btn-primary btn-loading disabled">\n      <div class="loading loading-sm"></div>\n      <span class="btn-label">',o={hash:{},data:s},l+=d((r=i.t||t&&t.t,r?r.call(t,"Save Changes",o):c.call(t,"t","Save Changes",o)))+'</span>\n    </button>\n\n    <span class="form-message"></span>\n  </div>\n</form>\n'
})}),define("hb!templates/desktop/settings/server/ServerSettingsPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+="\n    ",s={hash:{idSuffix:"_c"},data:t},a+=d((n=i.partial||e&&e.partial,n?n.call(e,"setting",s):c.call(e,"partial","setting",s)))+"\n  "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;return l+='<form id="server-settings-form">\n  ',r=i.each.call(t,t,{hash:{},inverse:u.noop,fn:u.program(1,a,s),data:s}),(r||0===r)&&(l+=r),l+='\n\n  <div class="form-footer">\n    <button type="submit" class="submit-btn btn btn-lg btn-primary btn-loading disabled">\n      <div class="loading loading-sm"></div>\n      <span class="btn-label">',o={hash:{},data:s},l+=d((r=i.t||t&&t.t,r?r.call(t,"Save Changes",o):c.call(t,"t","Save Changes",o)))+'</span>\n    </button>\n\n    <span class="form-message"></span>\n  </div>\n</form>\n'
})}),define("plex/desktop/views/settings/server/ServerSettingsPane",["hb!templates/desktop/settings/server/ServerSettingsPane.tpl","underscore","marionette","plex/base/utils/t"],function(e,t,i,n){"use strict";var s=i.Layout.extend({className:"form-group",template:e,isDisabled:!0,isActive:!1,ui:{submitBtn:".submit-btn",message:".form-message"},events:{"change #server-settings-form input[name]":"onInputChange","keyup #server-settings-form input[type=text]":"onInputChange","change #server-settings-form select[name]":"onInputChange","submit #server-settings-form":"onSubmit"},initialize:function(e){this.changes=e.changes
},serializeData:function(){return t.where(this.collection.toJSON(),{group:this.options.group,hidden:!1})},enable:function(){this.isDisabled=!1,this.ui.submitBtn.removeClass("disabled"),this.ui.message.text("")},updateModel:function(e,t){var i=this.collection.get(e);return i?i.set("value",t):void 0},onRender:function(){t.isEmpty(this.changes)||this.enable()},onInputChange:function(e){var t=e.currentTarget,i=t.name,n=t.value,s=t.value;if(i){"checkbox"===t.type&&(s=t.checked,s||(n="0"));var a=this.updateModel(i,s);
a&&(this.changes[t.name]=n,this.enable())}},onSubmit:function(e){e.preventDefault(),this.trigger("save")},onBeforeSave:function(){this.isActive=!0,this.ui.submitBtn.addClass("active")},onAfterSave:function(e){var t;this.isActive=!1,this.ui.submitBtn.removeClass("active"),e?(this.isDisabled=!0,this.ui.submitBtn.addClass("disabled"),t=n("Your changes have been saved.")):t=n("Your changes could not be saved."),this.ui.message.text(t)}});return s}),define("hb!templates/desktop/settings/server/ServerSettingsSignInView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="server-account-poster user-poster img-circle placeholder-friend"></div>\n\n<div class="server-account-info">\n  <div class="server-account-user">\n    <div class="server-account-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Server signed in as",r):l.call(t,"t","Server signed in as",r)))+'</div>\n    <div class="server-account-username"></div>\n  </div>\n\n  <button class="server-sign-out-btn btn btn-default btn-loading">\n    <div class="loading loading-sm"></div>\n    <span class="btn-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sign Out",r):l.call(t,"t","Sign Out",r)))+'</span>\n  </button>\n</div>\n\n<form id="server-sign-in-form" class="form-inline">\n  <div class="form-group">\n    <input type="text" class="form-control" name="username" placeholder="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Username or email",r):l.call(t,"t","Username or email",r)))+'" autocorrect="off" autocapitalize="off">\n  </div>\n\n  <div class="form-group">\n    <input type="password" class="form-control" name="password" placeholder="',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Password",r):l.call(t,"t","Password",r)))+'">\n  </div>\n\n  <button type="submit" class="server-sign-in-btn btn btn-primary btn-loading">\n    <div class="loading loading-sm"></div>\n    <span class="btn-label">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sign In",r):l.call(t,"t","Sign In",r)))+'</span>\n  </button>\n\n  <p class="help-block">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Sign in with your Plex account to help your devices find this server, access your media remotely, and more. {1}Learn more{2}","<a href='https://support.plex.tv/hc/en-us/articles/200484543-Connecting-a-Server'>","</a>",r):l.call(t,"t","Sign in with your Plex account to help your devices find this server, access your media remotely, and more. {1}Learn more{2}","<a href='https://support.plex.tv/hc/en-us/articles/200484543-Connecting-a-Server'>","</a>",r)))+"</p>\n</form>\n"
})}),define("plex/desktop/views/settings/server/ServerSettingsSignInView",["hb!templates/desktop/settings/server/ServerSettingsSignInView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel","plex/base/views/images/GravatarImage"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=n.ItemView.extend({className:"server-account-container",template:e,ui:{poster:".server-account-poster",signInBtn:".server-sign-in-btn",signOutBtn:".server-sign-out-btn",username:"input[name=username]",password:"input[name=password]"},events:{"submit #server-sign-in-form":"onSubmit","click .server-sign-out-btn":"onSignOutClick"},modelEvents:{"change:signedIn":"updateSignInState","change:username":"updateUserImage"},initialize:function(){this.user=o.get("user"),this.image=new l({type:"friend",width:60}),this.listenTo(this.user,"change:signedIn",this.updateUserImage)
},updateSignInState:function(){this.$el.toggleClass("signed-in",this.model.get("signedIn"))},updateUserImage:function(){var e=this.model.get("username");e===this.user.get("username")||e===this.user.get("email")?this.image.setModel(this.user):(this.image.setModel(null),this.image.url=null),this.image.render()},submit:function(e){var i={cloudAccount:this.model,username:e.username.value,password:e.password.value},n=this.signInUser(i);return n=n.then(t.bind(function(){var e=this.model.server;if(!e.get("accessToken")){var t=this.user.get("accessToken");
t&&e.set("accessToken",t)}return this.signIn(i)},this))},signIn:function(e){return r.execute("signInServer",e)},signInUser:function(e){return this.user.get("signedIn")?i.Deferred().resolve().promise():r.execute("signIn",{username:e.username,password:e.password})},signOut:function(){return this.ui.username.val(""),this.ui.password.val(""),r.execute("signOutServer",{cloudAccount:this.model})},bindings:{".server-account-username":{modelAttribute:"username"}},onRender:function(){this.image.setElement(this.ui.poster),this.updateSignInState(),this.updateUserImage()
},onClose:function(){this.image.close()},onSubmit:function(e){if(e.preventDefault(),!this.ui.signInBtn.isDisabled()){this.ui.signInBtn.addClass("active");var i=this.submit(e.target);i.done(t.bind(function(){this.model.fetch();var e=r.execute("connectServer",{cloudAccount:this.model,value:!0});e.always(t.bind(function(){this.user.get("signedIn")&&this.user.server.get("resources").fetch()},this))},this)),i.always(this.whenRendered(function(){this.ui.signInBtn.removeClass("active")}))}},onSignOutClick:function(e){if(e.preventDefault(),!this.ui.signOutBtn.isDisabled()){this.ui.signOutBtn.addClass("active");
var i=this.signOut();i.done(t.bind(function(){this.model.fetch()},this)),i.always(this.whenRendered(function(){this.ui.signOutBtn.removeClass("active")}))}}});return c}),define("hb!templates/desktop/settings/server/ServerSettingsUpdateView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<a href="#" class="check-for-updates-btn label label-btn label-primary active">\n  <i class="label-icon glyphicon upload"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Check for Updates",r):l.call(t,"t","Check for Updates",r)))+'\n</a>\n\n<a href="#" class="checking-for-updates-btn label label-btn label-primary active">\n  <i class="label-icon glyphicon upload"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Checking for Updates",r):l.call(t,"t","Checking for Updates",r)))+'\n</a>\n\n<a href="#" class="available-updates-btn label label-btn label-primary">\n  <i class="label-icon glyphicon download"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Download Updates",r):l.call(t,"t","Download Updates",r)))+'\n</a>\n\n<span class="downloading-updates-container label label-btn label-progress active">\n  <i class="label-icon glyphicon download"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Downloading Update",r):l.call(t,"t","Downloading Update",r)))+' <span class="downloading-progress-container hidden">(<span class="downloading-progress-label"></span>%)</span\n></span>\n\n<a href="#" class="install-updates-btn label label-btn label-primary">\n  <i class="label-icon glyphicon download"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Install Update",r):l.call(t,"t","Install Update",r)))+'\n</a>\n\n<a href="#" class="installing-updates-btn label label-btn label-primary active">\n  <i class="label-icon glyphicon upload"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Installing",r):l.call(t,"t","Installing",r)))+'\n</a>\n\n<span class="install-info-label up-to-date-label">\n  <i class="success-icon glyphicon ok-2"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Up to date",r):l.call(t,"t","Up to date",r)))+'\n</span>\n\n<span class="install-info-label install-error-label">\n  <i class="failure-icon glyphicon circle-exclamation-mark"></i> <span class="update-error-message"></span> <a class="install-manual-link" href="https://plex.tv/downloads" target="_blank">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Please install manually.",r):l.call(t,"t","Please install manually.",r)))+'</a>\n</span>\n\n<a href="#" class="release-notes-btn label label-btn label-default">\n  <i class="label-icon glyphicon circle-info"></i> ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"What's New",r):l.call(t,"t","What's New",r)))+"\n</a>\n"
})}),define("hb!templates/desktop/modals/ReleaseNotesModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t,n){var s,a,o,l="";return l+='\n        <h4 class="update-list-title">',o={hash:{},data:t},l+=p((s=i.t||e&&e.t,s?s.call(e,"New",o):m.call(e,"t","New",o)))+"</h4>\n        <ul>\n          ",a=i.each.call(e,n&&n.added,{hash:{},inverse:f.noop,fn:f.program(2,r,t),data:t}),(a||0===a)&&(l+=a),l+="\n        </ul>\n      "}function r(e){var t="";return t+="\n            <li>"+p(typeof e===h?e.apply(e):e)+"</li>\n          "
}function o(e,t,n){var s,a,o,l="";return l+='\n        <h4 class="update-list-title">',o={hash:{},data:t},l+=p((s=i.t||e&&e.t,s?s.call(e,"Fixes",o):m.call(e,"t","Fixes",o)))+"</h4>\n        <ul>\n          ",a=i.each.call(e,n&&n.fixed,{hash:{},inverse:f.noop,fn:f.program(2,r,t),data:t}),(a||0===a)&&(l+=a),l+="\n        </ul>\n      "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h="function",p=this.escapeExpression,m=i.helperMissing,f=this;return u+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-info"></i> ',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Plex Media Server Release Notes",d):m.call(t,"t","Plex Media Server Release Notes",d)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <span class="text-muted">',d={hash:{},data:s},u+=p((l=i.t||t&&t.t,l?l.call(t,"Version {1}",t&&t.version,d):m.call(t,"t","Version {1}",t&&t.version,d)))+"</span>\n      ",c=i["if"].call(t,t&&t.added,{hash:{},inverse:f.noop,fn:f.programWithDepth(1,a,s,t),data:s}),(c||0===c)&&(u+=c),u+="\n      ",c=i["if"].call(t,t&&t.fixed,{hash:{},inverse:f.noop,fn:f.programWithDepth(4,o,s,t),data:s}),(c||0===c)&&(u+=c),u+="\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/ReleaseNotesModal",["hb!templates/desktop/modals/ReleaseNotesModal.tpl","plex/desktop/views/modals/BaseModal"],function(e,t){"use strict";function i(e){return e?e.split("\n"):[]}var n=t.extend({name:"releaseNotesModal",template:e,serializeData:function(){var e=this.model.toJSON();return e.version=e.version.replace(/\-.*/gi,""),e.added=i(e.added),e.fixed=i(e.fixed),e}});return n}),define("plex/desktop/views/settings/server/ServerSettingsUpdateView",["hb!templates/desktop/settings/server/ServerSettingsUpdateView.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/modals/ReleaseNotesModal"],function(e,t,i,n,s,a,r,o){"use strict";
var l=i.ItemView.extend({tagName:"span",className:"check-for-updates-container",template:e,ui:{checkForUpdatesBtn:".check-for-updates-btn",downloadUpdatesContainer:".downloading-updates-container",downloadProgressContainer:".downloading-progress-container",downloadProgressLabel:".downloading-progress-label",updateProgressLabel:".downloading-updates-label",updateErrorMessage:".update-error-message",installManualLink:".install-manual-link"},modelEvents:{"change:state":"onStateChange","change:progress":"onProgressChange"},events:{"click .check-for-updates-btn":"onCheckForUpdatesClick","click .available-updates-btn":"onDownloadUpdatesClick","click .install-updates-btn":"onInstallUpdatesClick","click .release-notes-btn":"onInfoClick"},initialize:function(){this.model.fetch().then(this.whenRendered(function(){var e=this.model.get("state");
if("downloaded"===e&&this.model.get("shouldInstall"))return this.model.set("shouldInstall",!1),void this.installUpdates();var t=this.collection.get("ButlerTaskCheckForUpdates"),i=t&&t.get("value");!i||"none"!==e&&"done"!==e||this.checkForUpdates({download:!1})}))},checkForUpdates:function(e){var t=a.execute("checkForServerUpdates",{server:this.model.server,download:e.download,initialState:e.initialState});t.always(this.whenRendered(function(){this.ui.checkForUpdatesBtn.removeClass("active")}))},installUpdates:function(){a.execute("installServerUpdates",{server:this.model.server})
},waitForInstall:function(){this.listenTo(this.model.server,"change:connected",this.onServerConnectedChange)},showUpdateState:function(e){this.$el.removeClass(this.model.previous("state"));var t=e;this.model.get("canInstall")||"available"!==e||(t="notify"),this.$el.addClass(t);var i=!(!this.model.get("added")&&!this.model.get("fixed"));if(this.$el.toggleClass("has-release-notes",i),"installing"===t)this.waitForInstall();else if("error"===t||"notify"===t){var s;this.model.get("error")?(s=this.model.get("error"),this.ui.installManualLink.addClass("hidden")):this.model.get("canInstall")?(s=n("Something went wrong."),this.ui.installManualLink.removeClass("hidden")):(s=n("An update is available."),this.ui.installManualLink.removeClass("hidden"));
var a=r.get("user").server,o=this.model.get("downloadURL")||a.get("appsUrl");this.ui.installManualLink.attr("href",o),this.ui.updateErrorMessage.text(s)}},onRender:function(){this.showUpdateState(this.model.get("state"))},onStateChange:function(e,t){this.isRendered&&this.showUpdateState(t)},onProgressChange:function(e,i){t.isNumber(i)?(this.ui.downloadUpdatesContainer.css({"background-size":i+"% 100%"}),this.ui.downloadProgressContainer.removeClass("hidden"),this.ui.downloadProgressLabel.text(i)):this.ui.downloadProgressContainer.addClass("hidden")
},onServerConnectedChange:function(e,t){t&&(this.stopListening(e,"change:connected",this.onServerConnectedChange),a.execute("checkForServerUpdates",{server:this.model.server}))},onCheckForUpdatesClick:function(e){e.preventDefault(),this.ui.checkForUpdatesBtn.isDisabled()||(this.ui.checkForUpdatesBtn.addClass("active"),this.checkForUpdates({download:!0}))},onDownloadUpdatesClick:function(e){e.preventDefault(),this.checkForUpdates({download:!0,initialState:"downloading"})},onInstallUpdatesClick:function(e){e.preventDefault(),this.installUpdates()
},onInfoClick:function(e){e.preventDefault(),s.trigger("show:modal",new o({model:this.model}))}});return l}),define("plex/desktop/views/settings/server/ServerSettingsGeneralPane",["hb!templates/desktop/settings/server/ServerSettingsGeneralPane.tpl","underscore","plex/base/utils/t","plex/desktop/views/settings/server/ServerSettingsPane","plex/desktop/views/settings/server/ServerSettingsSignInView","plex/desktop/views/settings/server/ServerSettingsUpdateView"],function(e,t,i,n,s,a){"use strict";var r=n.extend({template:e,regions:{signIn:".sign-in-region",update:".update-region"},serializeData:function(){var e=n.prototype.serializeData.apply(this,arguments),i=t.findWhere(e,{id:"FriendlyName"});
return i&&(i.placeholder=this.model.get("name")||this.model.get("friendlyName")),e},bindings:{".version":{modelAttribute:"version",formatter:function(e){return i("Version {1}",e)}}},onRender:function(){n.prototype.onRender.apply(this,arguments),this.signIn.show(new s({model:this.model.get("cloudAccount"),collection:this.collection})),this.update.show(new a({model:this.model.get("update"),collection:this.collection}))}});return r}),define("hb!templates/desktop/settings/server/ServerSettingsRemoteAccessPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";
return a+='\n    <h4 class="status-header status-header-single">\n      <span class="loading loading-sm"></span> ',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Connecting server...",s):R.call(e,"t","Connecting server...",s)))+"\n    </h4>\n  "}function r(e,t){var n,s,a;return a={hash:{},inverse:N.program(6,l,t),fn:N.program(4,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"disconnecting",a):R.call(e,"if_eq",(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"disconnecting",a),s||0===s?s:""
}function o(e,t){var n,s,a="";return a+='\n    <h4 class="status-header status-header-single">\n      <span class="loading loading-sm"></span> ',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Disconnecting server...",s):R.call(e,"t","Disconnecting server...",s)))+"\n    </h4>\n  "}function l(e,t){var n;return n=i["if"].call(e,e&&e.isUnavailable,{hash:{},inverse:N.program(12,h,t),fn:N.program(7,c,t),data:t}),n||0===n?n:""}function c(e,t){var n,s,a,r="";return r+='\n    <h4 class="status-header text-danger">',a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"Not available outside your network",a):R.call(e,"t","Not available outside your network",a)))+"</h4>\n    ",s=i["if"].call(e,e&&e.isSignedOut,{hash:{},inverse:N.program(10,u,t),fn:N.program(8,d,t),data:t}),(s||0===s)&&(r+=s),r+="\n  "
}function d(e,t){var n,s,a="";return a+='\n      <span class="status-description help-block">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"First {1}sign in{2} to access your server from anywhere.","<a class='sign-in-link' href='#'>","</a>",s):R.call(e,"t","First {1}sign in{2} to access your server from anywhere.","<a class='sign-in-link' href='#'>","</a>",s)))+"</span>\n    "}function u(e,t){var n,s,a="";return a+='\n      <span class="status-description help-block">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"{1}Enable{2} to access your server from anywhere.","<a class='enable-link' href='#'>","</a>",s):R.call(e,"t","{1}Enable{2} to access your server from anywhere.","<a class='enable-link' href='#'>","</a>",s)))+"</span>\n    "
}function h(e,t){var n,s,a;return a={hash:{},inverse:N.program(15,m,t),fn:N.program(13,p,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"unreachable",a):R.call(e,"if_eq",(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"unreachable",a),s||0===s?s:""}function p(e,t){var n,s,a="";return a+='\n    <h4 class="status-header text-danger">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Not available outside your network",s):R.call(e,"t","Not available outside your network",s)))+'</h4>\n    <span class="unreachable-description status-description help-block">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Your server is signed in to Plex, but is not reachable from outside your network. {1}Learn more{2}","<a href='https://support.plex.tv/hc/en-us/articles/200484543-Connecting-a-Server' target='_blank'>","</a>",s):R.call(e,"t","Your server is signed in to Plex, but is not reachable from outside your network. {1}Learn more{2}","<a href='https://support.plex.tv/hc/en-us/articles/200484543-Connecting-a-Server' target='_blank'>","</a>",s)))+"</span>\n  "
}function m(e,t){var n,s,a="";return a+='\n    <h4 class="status-header status-header-single text-success">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Fully accessible outside your network",s):R.call(e,"t","Fully accessible outside your network",s)))+"</h4>\n  "}function f(e,t){var n,s,a,r="";return r+="\n",a={hash:{},inverse:N.noop,fn:N.program(18,g,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"disconnecting",a):R.call(e,"if_neq",(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"disconnecting",a),(s||0===s)&&(r+=s),r+="\n"
}function g(e,t){var n,s,a,r="";return r+='\n  <div class="remote-access-advanced">\n    <div class="remote-access-mapping-container ',s=i.unless.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.mappingError),{hash:{},inverse:N.noop,fn:N.program(19,v,t),data:t}),(s||0===s)&&(r+=s),r+='">\n      <hr>\n\n      <h4 class="mapping-header">',a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"Server Mapping",a):R.call(e,"t","Server Mapping",a)))+'</h4>\n      <i class="plex-image server-xs server-logo"></i>\n\n      <div class="remote-access-mapping">\n        <span class="mapping-label text-muted">',a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"Private",a):R.call(e,"t","Private",a)))+'</span>\n        <span class="mapping-address">\n          ',s=i["if"].call(e,e&&e.hasPrivateAddress,{hash:{},inverse:N.program(23,b,t),fn:N.program(21,y,t),data:t}),(s||0===s)&&(r+=s),r+="\n        </span>\n\n        ",s=i["if"].call(e,e&&e.hasPublicAddress,{hash:{},inverse:N.program(27,x,t),fn:N.program(25,w,t),data:t}),(s||0===s)&&(r+=s),r+='\n\n        <span class="mapping-label text-muted">',a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"Public",a):R.call(e,"t","Public",a)))+'</span>\n        <span class="mapping-address">\n          ',s=i["if"].call(e,e&&e.hasPublicAddress,{hash:{},inverse:N.program(23,b,t),fn:N.program(29,k,t),data:t}),(s||0===s)&&(r+=s),r+="\n        </span>\n\n        ",a={hash:{},inverse:N.program(27,x,t),fn:N.program(25,w,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"ok",a):R.call(e,"if_eq",(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"ok",a),(s||0===s)&&(r+=s),r+='\n\n        <span class="mapping-internet ',a={hash:{},inverse:N.noop,fn:N.program(31,S,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"ok",a):R.call(e,"if_neq",(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"ok",a),(s||0===s)&&(r+=s),r+='">\n          <i class="mapping-internet-icon glyphicon globe text-muted"></i> ',a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"Internet",a):R.call(e,"t","Internet",a)))+"\n        </span>\n      </div>\n    </div>\n\n    ",s=i["if"].call(e,e&&e.hasMappingSettings,{hash:{},inverse:N.noop,fn:N.program(33,C,t),data:t}),(s||0===s)&&(r+=s),r+="\n\n    ",s=i.unless.call(e,e&&e.isDisabled,{hash:{},inverse:N.noop,fn:N.program(42,T,t),data:t}),(s||0===s)&&(r+=s),r+="\n  </div>\n"
}function v(){return"advanced-setting"}function y(e,t){var n,s,a="";return a+='\n            <span class="mapping-value">'+O((n=e&&e.cloudAccount,n=null==n||n===!1?n:n.privateAddress,typeof n===F?n.apply(e):n))+'</span>\n            <span class="mapping-separator text-muted">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,":",s):R.call(e,"t",":",s)))+'</span>\n            <span class="mapping-value">'+O((n=e&&e.cloudAccount,n=null==n||n===!1?n:n.privatePort,typeof n===F?n.apply(e):n))+"</span>\n          "
}function b(e,t){var n,s,a="";return a+='\n            <span class="mapping-empty-value">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Unknown IP",s):R.call(e,"t","Unknown IP",s)))+"</span>\n          "}function w(){return'\n          <i class="mapping-icon glyphicon left-arrow text-success"></i>\n        '}function x(){return'\n          <i class="mapping-icon glyphicon remove-2 text-danger"></i>\n        '}function k(e,t){var n,s,a="";return a+='\n            <span class="mapping-value">'+O((n=e&&e.cloudAccount,n=null==n||n===!1?n:n.publicAddress,typeof n===F?n.apply(e):n))+'</span>\n            <span class="mapping-separator text-muted">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,":",s):R.call(e,"t",":",s)))+'</span>\n            <span class="mapping-value">'+O((n=e&&e.cloudAccount,n=null==n||n===!1?n:n.publicPort,typeof n===F?n.apply(e):n))+"</span>\n          "
}function S(){return"unreachable"}function C(e,t){var n,s,a,r="";return r+='\n      <div class="remote-access-error-container ',s=i.unless.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.mappingError),{hash:{},inverse:N.noop,fn:N.program(19,v,t),data:t}),(s||0===s)&&(r+=s),r+='">\n        <div class="form-inline">\n          <div class="checkbox">\n            <label>\n              <input type="checkbox" id="'+O((n=e&&e.mappingModeSetting,n=null==n||n===!1?n:n.id,typeof n===F?n.apply(e):n))+'" name="'+O((n=e&&e.mappingModeSetting,n=null==n||n===!1?n:n.id,typeof n===F?n.apply(e):n))+'" value="1" ',s=i["if"].call(e,(n=e&&e.mappingModeSetting,null==n||n===!1?n:n.value),{hash:{},inverse:N.noop,fn:N.program(34,P,t),data:t}),(s||0===s)&&(r+=s),r+="> ",a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"Manually specify port",a):R.call(e,"t","Manually specify port",a)))+'\n            </label>\n          </div>\n\n          <div class="form-group">\n            <input type="text" id="'+O((n=e&&e.mappingPortSetting,n=null==n||n===!1?n:n.id,typeof n===F?n.apply(e):n))+'" name="'+O((n=e&&e.mappingPortSetting,n=null==n||n===!1?n:n.id,typeof n===F?n.apply(e):n))+'" class="form-control" value="'+O((n=e&&e.mappingPortSetting,n=null==n||n===!1?n:n.value,typeof n===F?n.apply(e):n))+'" ',s=i.unless.call(e,(n=e&&e.mappingModeSetting,null==n||n===!1?n:n.value),{hash:{},inverse:N.noop,fn:N.program(36,A,t),data:t}),(s||0===s)&&(r+=s),r+='>\n          </div>\n\n          <button class="retry-btn btn btn-primary btn-loading">\n            <div class="loading loading-sm"></div>\n            <span class="btn-label">',a={hash:{},inverse:N.program(40,I,t),fn:N.program(38,_,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"unreachable",a):R.call(e,"if_eq",(n=e&&e.cloudAccount,null==n||n===!1?n:n.remoteAccessState),"unreachable",a),(s||0===s)&&(r+=s),r+='</span>\n          </button>\n        </div>\n\n        <p class="help-block">',a={hash:{},data:t},r+=O((n=i.t||e&&e.t,n?n.call(e,"You may need to enable this to establish a direct connection from outside your network.  You may also need to configure your router.  Detailed instructions are available {1}here{2}.","<a href='http://support.plex.tv/hc/en-us/articles/200931138-Troubleshooting-myPlex-Server-connections' target='_blank'>","</a>",a):R.call(e,"t","You may need to enable this to establish a direct connection from outside your network.  You may also need to configure your router.  Detailed instructions are available {1}here{2}.","<a href='http://support.plex.tv/hc/en-us/articles/200931138-Troubleshooting-myPlex-Server-connections' target='_blank'>","</a>",a)))+"</p>\n      </div>\n    "
}function P(){return"checked"}function A(){return"disabled"}function _(e,t){var n,s;return s={hash:{},data:t},O((n=i.t||e&&e.t,n?n.call(e,"Retry",s):R.call(e,"t","Retry",s)))}function I(e,t){var n,s;return s={hash:{},data:t},O((n=i.t||e&&e.t,n?n.call(e,"Apply",s):R.call(e,"t","Apply",s)))}function T(e,t){var n,s,a="";return a+='\n      <button class="remote-access-disable-btn btn btn-sm btn-danger advanced-setting">',s={hash:{},data:t},a+=O((n=i.t||e&&e.t,n?n.call(e,"Disable Remote Access",s):R.call(e,"t","Disable Remote Access",s)))+"</button>\n    "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var M,D,E,L="",R=i.helperMissing,O=this.escapeExpression,N=this,F="function";return L+='<i class="remote-access-status-icon glyphicon globe"></i>\n<div class="remote-access-status-message">\n  ',E={hash:{},inverse:N.program(3,r,s),fn:N.program(1,a,s),data:s},M=i.if_eq||t&&t.if_eq,D=M?M.call(t,(M=t&&t.cloudAccount,null==M||M===!1?M:M.remoteAccessState),"connecting",E):R.call(t,"if_eq",(M=t&&t.cloudAccount,null==M||M===!1?M:M.remoteAccessState),"connecting",E),(D||0===D)&&(L+=D),L+="\n</div>\n\n",E={hash:{},inverse:N.noop,fn:N.program(17,f,s),data:s},M=i.if_neq||t&&t.if_neq,D=M?M.call(t,(M=t&&t.cloudAccount,null==M||M===!1?M:M.remoteAccessState),"connecting",E):R.call(t,"if_neq",(M=t&&t.cloudAccount,null==M||M===!1?M:M.remoteAccessState),"connecting",E),(D||0===D)&&(L+=D),L+="\n"
})}),define("plex/desktop/views/settings/server/ServerSettingsRemoteAccessPane",["hb!templates/desktop/settings/server/ServerSettingsRemoteAccessPane.tpl","underscore","jquery","plex/base/commands/commands","plex/desktop/views/settings/server/ServerSettingsPane"],function(e,t,i,n,s){"use strict";var a=s.extend({className:"remote-access-container",template:e,ui:{manualPortMappingMode:"#ManualPortMappingMode",manualPortMappingPort:"#ManualPortMappingPort"},events:{"change .remote-access-error-container input[id]":"onInputChange","click .sign-in-link":"onSignInClick","click .enable-link":"onEnableClick","click .retry-btn":"onRetryClick","click .remote-access-disable-btn":"onDisableClick"},initialize:function(e){this.cloudAccount=e.cloudAccount,this.changes=e.changes,this.listenTo(this.cloudAccount,{"change:signInState":this.render,"change:remoteAccessState":this.render})
},serializeData:function(){var e=this.collection.get("PublishServerOnPlexOnlineKey"),t=this.collection.get("ManualPortMappingMode"),i=this.collection.get("ManualPortMappingPort"),n=this.cloudAccount.toJSON(),s=!e.get("value"),a=!n.signedIn,r=s||a;return{isDisabled:s,isSignedOut:a,isUnavailable:r,hasPrivateAddress:!(!n.privateAddress||!n.privatePort),hasPublicAddress:!(!n.publicAddress||!n.publicPort),cloudAccount:n,hasMappingSettings:!(!t||!i),mappingModeSetting:t?t.toJSON():null,mappingPortSetting:i?i.toJSON():null}
},enable:function(){},connect:function(){return n.execute("connectServer",{cloudAccount:this.cloudAccount,value:!0})},disconnect:function(){return n.execute("connectServer",{cloudAccount:this.cloudAccount,value:!1})},reconnect:function(){return n.execute("reconnectServer",{cloudAccount:this.cloudAccount})},saveChanges:function(){if(t.isEmpty(this.changes))return i.Deferred().resolve().promise();var e=this.collection.first().save(this.changes);return e.done(t.bind(function(){this.changes={}},this)),e
},onInputChange:function(){s.prototype.onInputChange.apply(this,arguments),this.ui.manualPortMappingPort.prop("disabled",!this.ui.manualPortMappingMode.prop("checked"))},onSignInClick:function(e){e.preventDefault(),this.trigger("change:pane","general")},onEnableClick:function(e){e.preventDefault(),this.connect()},onDisableClick:function(e){e.preventDefault(),this.disconnect()},onRetryClick:function(e){e.preventDefault(),this.cloudAccount.set("remoteAccessState","connecting"),this.saveChanges().always(t.bind(this.reconnect,this))
}});return a}),define("hb!templates/desktop/settings/server/ServerSettingsAgentsPane",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t,n){var s,a,o,l="";return l+='\n    <li class="',o={hash:{},inverse:d.noop,fn:d.program(2,r,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,(s=n&&n.currentType,null==s||s===!1?s:s.id),e&&e.id,o):u.call(e,"if_eq",(s=n&&n.currentType,null==s||s===!1?s:s.id),e&&e.id,o),(a||0===a)&&(l+=a),l+='">\n      <a class="btn-gray" data-type="',(a=i.typeString)?a=a.call(e,{hash:{},data:t}):(a=e&&e.typeString,a=typeof a===h?a.call(e,{hash:{},data:t}):a),l+=p(a)+'" href="#">',o={hash:{},data:t},l+=p((s=i.t||e&&e.t,s?s.call(e,e&&e.plural,o):u.call(e,"t",e&&e.plural,o)))+"</a>\n    </li>\n  "
}function r(){return"active"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c="",d=this,u=i.helperMissing,h="function",p=this.escapeExpression;return c+='<ul class="agent-types-nav nav nav-pills">\n  ',o=i.each.call(t,t&&t.agentTypes,{hash:{},inverse:d.noop,fn:d.programWithDepth(1,a,s,t),data:s}),(o||0===o)&&(c+=o),c+='\n</ul>\n\n<div class="agents-list-container"></div>\n\n<p class="help-block sortable-help-block">',l={hash:{},data:s},c+=p((o=i.t||t&&t.t,o?o.call(t,"Select which additional agents should contribute to metadata from {1}, and drag them to change the order of preference.","<span class='agent-label'></span>",l):u.call(t,"t","Select which additional agents should contribute to metadata from {1}, and drag them to change the order of preference.","<span class='agent-label'></span>",l)))+'</p>\n\n<div class="contributors-list-container"></div>\n'
})}),define("hb!templates/desktop/lists/settings/AgentListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<a class="btn-gray" data-identifier="',(a=i.identifier)?a=a.call(t,{hash:{},data:s}):(a=t&&t.identifier,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'" href="#">',(a=i.name)?a=a.call(t,{hash:{},data:s}):(a=t&&t.name,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+"</a>\n"
})}),define("plex/desktop/views/lists/settings/AgentListItem",["hb!templates/desktop/lists/settings/AgentListItem.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({tagName:"li",template:e,bindings:{a:{modelAttribute:"selected",manual:!0,formatter:function(e){this.$el.toggleClass("active",!!e)}}}});return i}),define("plex/desktop/views/lists/settings/AgentList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/settings/AgentListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"agents-nav nav nav-pills nav-pills-sm",itemView:t});
return i}),define("hb!templates/desktop/lists/settings/ContributorListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"checked"}function r(){return"disabled"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c="",d="function",u=this.escapeExpression,h=this,p=i.helperMissing;return c+='<div class="card-actions">\n  <button class="info-btn card-action-btn"><i class="glyphicon circle-info"></i></button>\n  <button class="settings-btn card-action-btn"><i class="glyphicon cogwheel"></i></button>\n</div>\n\n<div class="card-handle"><i class="glyphicon show-lines"></i></div>\n\n<label for="',(o=i.identifier)?o=o.call(t,{hash:{},data:s}):(o=t&&t.identifier,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'">\n  <input id="',(o=i.identifier)?o=o.call(t,{hash:{},data:s}):(o=t&&t.identifier,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" name="',(o=i.identifier)?o=o.call(t,{hash:{},data:s}):(o=t&&t.identifier,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+'" type="checkbox"  ',o=i["if"].call(t,t&&t.enabled,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+=" ",o=i["if"].call(t,t&&t.primary,{hash:{},inverse:h.noop,fn:h.program(3,r,s),data:s}),(o||0===o)&&(c+=o),c+="> ",l={hash:{},data:s},c+=u((o=i.t||t&&t.t,o?o.call(t,t&&t.name,l):p.call(t,"t",t&&t.name,l)))+"\n</label>\n"
})}),define("hb!templates/desktop/modals/AgentInfoModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r="",o="function",l=this.escapeExpression;return r+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title">\n        <i class="modal-icon glyphicon circle-info"></i>\n        ',(a=i.name)?a=a.call(t,{hash:{},data:s}):(a=t&&t.name,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'\n      </h4>\n    </div>\n\n    <div class="modal-body">\n      <p class="agent-icon-container"></p>\n      <p>',(a=i.attribution)?a=a.call(t,{hash:{},data:s}):(a=t&&t.attribution,a=typeof a===o?a.call(t,{hash:{},data:s}):a),(a||0===a)&&(r+=a),r+="</p>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/AgentInfoModal",["hb!templates/desktop/modals/AgentInfoModal.tpl","plex/desktop/views/modals/BaseModal","plex/base/views/images/BaseImage"],function(e,t,i){"use strict";var n=t.extend({name:"agentInfoModal",className:"agent-info-modal modal fade",template:e,regions:{icon:".agent-icon-container"},onRender:function(){t.prototype.onRender.apply(this,arguments),this.icon.show(new i({model:this.model,url:"/system/agents/attribution/image?identifier="+this.model.id,className:"agent-icon",width:100,height:100}))
}});return n}),define("plex/desktop/views/lists/settings/ContributorListItem",["hb!templates/desktop/lists/settings/ContributorListItem.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/models/server/ServerSettingCollection","plex/desktop/views/modals/ChannelSettingsModal","plex/desktop/views/modals/AgentInfoModal"],function(e,t,i,n,s,a,r){"use strict";var o=i.ItemView.extend({tagName:"li",className:"card card-sortable",template:e,events:{"change input[type=checkbox]":"onEnabledChange","click .settings-btn":"onSettingsClick","click .info-btn":"onInfoClick"},initialize:function(){this.model.fetchAttribution()
},bindings:{".info-btn":{modelAttribute:"attribution",manual:!0,autohide:!0},".settings-btn":{modelAttribute:"hasPrefs",manual:!0,autohide:!0}},onEnabledChange:function(e){this.model.set("enabled",e.target.checked)},onSettingsClick:function(e){e.preventDefault();var i=new s([],{server:this.model.server,url:"/:/plugins/"+this.model.id+"/prefs"});i.fetch().done(t.bind(function(){n.trigger("show:modal",new a({model:this.model,collection:i}))},this))},onInfoClick:function(e){e.preventDefault(),n.trigger("show:modal",new r({model:this.model}))
}});return o}),define("plex/desktop/views/lists/settings/ContributorList",["sortable","plex/desktop/views/lists/BaseList","plex/desktop/views/lists/settings/ContributorListItem"],function(e,t,i){"use strict";var n=t.extend({tagName:"ul",className:"list contributor-list",itemView:i,events:{"change input[type=checkbox]":"save",update:"save"},save:function(){var e=[];this.$(":checked").each(function(){e.push(this.name)}),this.trigger("save",e.join(","))},onRender:function(){this.sortable=new e(this.$el[0],{draggable:".card-sortable"})
},onClose:function(){this.sortable.destroy()}});return n}),define("plex/desktop/views/settings/server/ServerSettingsAgentsPane",["hb!templates/desktop/settings/server/ServerSettingsAgentsPane.tpl","underscore","jquery","marionette","plex/base/utils/types/mediaTypes","plex/base/models/library/AgentCollection","plex/desktop/views/lists/settings/AgentList","plex/desktop/views/lists/settings/ContributorList"],function(e,t,i,n,s,a,r,o){"use strict";var l=n.Layout.extend({template:e,ui:{agentLabel:".agent-label",typeNavItems:".agent-types-nav li",agentNavItems:".agents-nav li"},regions:{agentsList:".agents-list-container",contributorsList:".contributors-list-container"},events:{"click .agent-types-nav a":"onAgentTypeClick","click .agents-nav a":"onAgentClick"},initialize:function(){this.bindAllWhenRendered("onAgentsReset","onContributorsReset"),this.agentTypes=[],this.agentTypes.push(s.getMediaTypeByString("movie")),this.agentTypes.push(s.getMediaTypeByString("show")),this.agentTypes.push(s.getMediaTypeByString("artist")),this.agentTypes.push(s.getMediaTypeByString("album")),this.agentTypes.push(s.getMediaTypeByString("photo")),this.currentType=t.first(this.agentTypes),this.populateAgents()
},serializeData:function(){return{currentType:this.currentType,agentTypes:this.agentTypes}},populateAgents:function(){this.agents=new a([],{server:this.model,mediaTypeID:this.currentType.id,allowInCache:!0});var e=this.agents.populate({reset:!0,scope:"page"});e.done(t.bind(this.onAgentsReset,this))},selectAgent:function(e){this.currentAgent&&this.currentAgent.set("selected",!1),this.currentAgent=e,e.set("selected",!0),this.ui.agentLabel.text(e.get("name")),this.additionalAgents=new a([],{server:this.model,mediaTypeID:this.currentType.id,relatedAgent:e.id,allowInCache:!0}),this.contributors=new a([],{server:this.model,mediaTypeID:this.currentType.id,primaryAgent:e.id,allowInCache:!0}),this.contributorsList.show(new o({collection:this.contributors})),this.listenTo(this.contributorsList.currentView,"save",this.onContributorsSave),this.populateContributors()
},populateContributors:function(){var e=[];e.push(this.additionalAgents.populate({reset:!0,scope:"page"})),e.push(this.contributors.populate({reset:!0,scope:"page"}));var n=i.when.apply(i,e);n.done(t.bind(this.onContributorsReset,this))},onAgentsReset:function(){if(this.agentsList.show(new r({collection:this.agents})),this.agents.length){var e=this.agents.findWhere({selected:!0})||this.agents.first();this.selectAgent(e)}},onContributorsReset:function(){var e=t.bind(function(e){return e.id===this.currentAgent.id?(e.set("primary",!0),!0):!!this.contributors.get(e.id)
},this);this.contributors.reset(this.additionalAgents.filter(e))},onAgentTypeClick:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.data("type");this.currentType=s.getMediaTypeByString(n),this.populateAgents(),this.ui.typeNavItems.removeClass("active"),t.parent("li").addClass("active")},onAgentClick:function(e){e.preventDefault();var t=i(e.target),n=t.data("identifier"),s=this.agents.get(n);this.selectAgent(s)},onContributorsSave:function(e){this.currentAgent.url="system/agents/"+this.currentAgent.id+"/config/"+this.currentType.id;
var i=this.currentAgent.save({order:e});i.done(t.bind(function(){this.additionalAgents.fetch({silent:!0}),this.contributors.fetch({silent:!0})},this))}});return l}),define("plex/desktop/views/settings/server/ServerSettingsChannelsPane",["underscore","plex/desktop/views/settings/server/ServerSettingsPane"],function(e,t){"use strict";var i=t.extend({prefix:"channel.",serializeData:function(){var i=t.prototype.serializeData.apply(this,arguments),n=this.options.channelSettings.toJSON();return e.each(n,function(e){e.id=this.prefix+e.id
},this),i.unshift.apply(i,n),i},updateModel:function(e,i){var n=t.prototype.updateModel.apply(this,arguments);if(n)return n;var s=e.replace(this.prefix,""),a=this.options.channelSettings.get(s);return a?a.set("value",i):void 0}});return i}),define("plex/desktop/views/settings/server/ServerSettingsLanguagesPane",["underscore","plex/base/utils/t","plex/base/utils/languageUtil","plex/desktop/views/settings/server/ServerSettingsPane"],function(e,t,i,n){"use strict";var s=n.extend({prefix:"account.",serializeData:function(){var n=this.options.account,s=[],a=e.map(i.languages,function(e,t){return{value:t,label:e}
});return s.push({id:this.prefix+"autoSelectAudio",label:t("Automatically select audio tracks"),summary:t("Automatically select audio tracks in your preferred language when possible."),"default":!1,value:n.get("autoSelectAudio"),type:"bool",group:"account.language",advanced:!1,hidden:!1}),s.push({id:this.prefix+"defaultAudioLanguage",label:t("Prefer audio tracks in"),"default":"en",value:n.get("defaultAudioLanguage"),type:"text",group:"account.language",advanced:!1,hidden:!1,enumValues:a}),s.push({id:this.prefix+"subtitleMode",label:t("Subtitle mode"),"default":1,value:parseInt(n.get("subtitleMode"),10),type:"int",group:"account.language",advanced:!1,hidden:!1,enumValues:[{value:"0",label:t("Manually selected")},{value:"1",label:t("Shown with foreign audio")},{value:"2",label:t("Always enabled")}]}),s.push({id:this.prefix+"defaultSubtitleLanguage",label:t("Prefer subtitles in"),"default":"en",value:n.get("defaultSubtitleLanguage"),type:"text",group:"account.language",advanced:!1,hidden:!1,enumValues:a}),s
},updateModel:function(e,t){var i=n.prototype.updateModel.apply(this,arguments);if(i)return i;var s=e.replace(this.prefix,""),a=this.options.account;return a.has(s)?a.set(s,t):void 0}});return s}),define("plex/desktop/views/settings/server/ServerSettingsView",["hb!templates/desktop/settings/server/ServerSettingsView.tpl","underscore","jquery","backbone","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/dropdowns/PrimaryServerDropdown","plex/desktop/views/settings/server/ServerSettingsNavList","plex/desktop/views/settings/server/ServerSettingsGeneralPane","plex/desktop/views/settings/server/ServerSettingsRemoteAccessPane","plex/desktop/views/settings/server/ServerSettingsAgentsPane","plex/desktop/views/settings/server/ServerSettingsChannelsPane","plex/desktop/views/settings/server/ServerSettingsLanguagesPane","plex/desktop/views/settings/server/ServerSettingsPane"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f=s.Layout.extend({className:"server-settings-container",template:e,remoteAccessDecorators:{connecting:"unknown",disconnecting:"unknown",unreachable:"error",ok:"success"},regions:{serverDropdown:".filter-bar",nav:".nav-region",pane:".pane-region"},events:{"click .toggle-advanced-btn":"onToggleAdvancedClick"},panes:{general:{constructor:c,group:"general",title:"General",isCustom:!0},remoteAccess:{constructor:d,group:"remoteAccess",title:"Remote Access",isCustom:!0},agents:{constructor:u,group:"agents",title:"Agents",isCustom:!0},library:{constructor:m,group:"library",title:"Library"},channels:{constructor:h,group:"channels",title:"Channels",isCustom:!0},network:{constructor:m,group:"network",title:"Network"},transcoder:{constructor:m,group:"transcoder",title:"Transcoder"},languages:{constructor:p,group:"account.language",title:"Languages",isCustom:!0},dlna:{constructor:m,group:"dlna",title:"DLNA"},bonjour:{constructor:m,group:"bonjour",title:"Network Discovery"},butler:{constructor:m,group:"butler",title:"Scheduled Tasks"},extras:{constructor:m,group:"extras",title:"Extras"}},initialize:function(e){if(this.account=e.account,this.cloudAccount=e.cloudAccount,this.channelSettings=e.channelSettings,this.tempSettings=this.collection.cloneDeep(),this.tempAccount=this.account.clone(),this.tempChannelSettings=this.channelSettings.cloneDeep(),this.changes={},this.initGroups(),this.model.supports("reachability")){var n="/myplex/refreshReachability",s=t.extend(this.model.getXHROptions(n),{type:"PUT"});
i.ajax(s)}r.set("primaryServer",this.model),this.listenTo(a,"shortcut:save",this.saveChanges),this.listenTo(r,"change:primaryServer",this.onPrimaryServerChange),this.listenTo(this.cloudAccount,"change:remoteAccessState",this.onRemoteAccessStatusChange)},initGroups:function(){var e=t.keys(this.panes),i=t.chain(this.collection.pluck("group")).unique().compact().value();this.groups=new n.Collection,t.each(e,function(e){var n=this.panes[e];(n.isCustom||t.contains(i,e))&&this.addGroup(e,n)},this),t.each(i,function(i){if(!t.contains(e,i)){var n={constructor:m,group:i,title:i};
this.panes[i]=n,this.addGroup(i,n)}},this)},addGroup:function(e,i){var n=t.omit(i,"constructor");n.id=e,this.groups.add(n)},showPane:function(e){if(this.currentPane){if(this.currentPane.isActive)return this.currentPane;this.stopListening(this.currentPane),this.flushChanges()}var t=this.panes[e],i=t.constructor,n=new i({model:this.model,collection:this.tempSettings,account:this.tempAccount,cloudAccount:this.cloudAccount,channelSettings:this.tempChannelSettings,group:t.group,changes:this.changes});
return this.currentPane=n,this.pane.show(n),this.nav.currentView.selectGroup(e),this.listenTo(this.currentPane,{"change:pane":this.showPane,save:this.saveChanges}),n},flushChanges:function(){this.currentPane.changes&&t.extend(this.changes,this.currentPane.changes)},saveChanges:function(){if(this.flushChanges(),!this.currentPane.isDisabled&&!this.currentPane.isActive){this.currentPane.triggerMethod("before:save");var e=[],n=this.getPrefixedChanges("channel."),s=this.getPrefixedChanges("account.");
if(!t.isEmpty(n)){var a=this.channelSettings.first().getSaveParams(n),r=t.result(this.channelSettings,"url"),o=r+"/set?"+i.param(a,!0);e.push(i.ajax(this.model.getXHROptions(o)))}t.isEmpty(s)||e.push(this.account.save(s)),t.isEmpty(this.changes)||e.push(this.collection.first().save(this.changes));var l=i.when.apply(i,e);l.done(t.bind(function(){var e=t.keys(this.changes);t.each(e,function(e){var t=this.tempSettings.get(e),i=this.collection.get(e);i.set("value",t.get("value"))},this),this.changes={},this.currentPane&&(this.currentPane.changes&&(this.currentPane.changes={}),this.currentPane.triggerMethod("after:save",!0))
},this)),l.fail(t.bind(function(){this.currentPane&&this.currentPane.triggerMethod("after:save",!1)},this))}},getPrefixedChanges:function(e){var i={};return t.each(this.changes,function(t,n){var s=0===n.lastIndexOf(e,0);s&&(i[n.substring(e.length)]=t,delete this.changes[n])},this),i},onRender:function(){this.serverDropdown.append(new o);var e=new l({collection:this.groups});this.listenTo(e,"itemview:change:pane",this.onNavItemChangePane),this.nav.show(e);var t=this.remoteAccessDecorators[this.cloudAccount.get("remoteAccessState")];
t&&this.nav.currentView.showDecorator("remoteAccess",t),this.showPane("general")},onClose:function(){this.currentPane=null},onNavItemChangePane:function(e,t){this.showPane(t)},onPrimaryServerChange:function(e,t){var i=this.model.get("update");return"installing"===i.get("state")?void this.listenTo(this.model,"change:connected",this.onServerConnectedChange):void(t&&a.trigger("navigate","serverSettings",{serverID:t.id}))},onRemoteAccessStatusChange:function(e,t){var i=this.remoteAccessDecorators[t];
i&&this.nav.currentView.showDecorator("remoteAccess",i)},onServerConnectedChange:function(e,t){t&&(this.stopListening(e,"change:connected",this.onServerConnectedChange),r.set("primaryServer",e))},onToggleAdvancedClick:function(e){e.preventDefault();var t=this.$el.hasClass("show-advanced");this.$el.toggleClass("show-advanced",!t)}});return f}),define("hb!templates/desktop/settings/UsersView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"}function r(){return"selected"
}function o(e,t){var n,s,a,o="";return o+='\n        <li>\n          <a class="friends-card card btn-gray ',a={hash:{},inverse:h.noop,fn:h.program(3,r,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.subset,"friends",a):p.call(e,"if_eq",e&&e.subset,"friends",a),(s||0===s)&&(o+=s),o+='" href="#!/settings/users/friends">\n            <span class="badge"></span>\n            ',a={hash:{},data:t},o+=m((n=i.t||e&&e.t,n?n.call(e,"Friends",a):p.call(e,"t","Friends",a)))+"\n          </a>\n        </li>\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c,d,u="",h=this,p=i.helperMissing,m=this.escapeExpression;return u+='<div class="filter-bar">\n  <div class="filter-bar-right">\n    <button class="add-user-btn btn btn-sm btn-default ',l=i.unless.call(t,t&&t.showAddUser,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(l||0===l)&&(u+=l),u+='">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Add User",d):p.call(t,"t","Add User",d)))+'</button>\n    <button class="leave-home-btn btn btn-sm btn-danger ',c=i.unless.call(t,t&&t.showLeaveHome,{hash:{},inverse:h.noop,fn:h.program(1,a,s),data:s}),(c||0===c)&&(u+=c),u+='">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Leave Home",d):p.call(t,"t","Leave Home",d)))+'</button>\n\n    <button class="invite-friend-btn btn btn-sm btn-default">',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"Invite Friend",d):p.call(t,"t","Invite Friend",d)))+'</button>\n  </div>\n</div>\n\n<div class="users-row row">\n  <div class="col-sm-4 col-md-3">\n    <ul class="nav nav-cards">\n      <li>\n        <a class="home-card card btn-gray ',d={hash:{},inverse:h.noop,fn:h.program(3,r,s),data:s},l=i.if_eq||t&&t.if_eq,c=l?l.call(t,t&&t.subset,"home",d):p.call(t,"if_eq",t&&t.subset,"home",d),(c||0===c)&&(u+=c),u+='" href="#!/settings/users/home">\n          <span class="badge"></span>\n          ',d={hash:{},data:s},u+=m((l=i.t||t&&t.t,l?l.call(t,"My Home",d):p.call(t,"t","My Home",d)))+"\n        </a>\n      </li>\n      ",c=i["if"].call(t,t&&t.showFriends,{hash:{},inverse:h.noop,fn:h.program(5,o,s),data:s}),(c||0===c)&&(u+=c),u+="\n    </ul>\n  </div>\n</div>\n"
})}),define("hb!templates/desktop/settings/HomeView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<h3 class="invite-list-header top">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Invites",r):l.call(t,"t","Invites",r)))+'</h3>\n<div class="invite-list-container"></div>\n\n<h3 class="friend-list-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"My Home",r):l.call(t,"t","My Home",r)))+'</h3>\n<div class="friend-list-container"></div>\n\n<h3 class="pending-list-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Pending",r):l.call(t,"t","Pending",r)))+'</h3>\n  <div class="pending-list-container"></div>\n</div>\n'
})}),define("hb!templates/desktop/settings/FriendsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<h3 class="invite-list-header top">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Invites",r):l.call(t,"t","Invites",r)))+'</h3>\n<div class="invite-list-container"></div>\n\n<h3 class="friend-list-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Friends",r):l.call(t,"t","Friends",r)))+'</h3>\n<div class="friend-list-container"></div>\n\n<h3 class="pending-list-header">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Pending",r):l.call(t,"t","Pending",r)))+'</h3>\n  <div class="pending-list-container"></div>\n</div>\n'
})}),define("hb!templates/desktop/lists/settings/InviteListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'<button class="accept-btn card-action-btn btn-success"><i class="glyphicon ok-2"></i></button>'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o="",l=this;return o+='<div class="card card-user">\n  <div class="card-poster media-poster img-circle"></div>\n\n  <div class="card-actions">\n    ',r=i["if"].call(t,t&&t.showAccept,{hash:{},inverse:l.noop,fn:l.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+='\n    <button class="delete-btn card-action-btn btn-danger"><i class="glyphicon remove-2"></i></button>\n  </div>\n\n  <h4 class="username"></h4>\n\n  <div class="card-details">\n    <p class="user-summary"></p>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/lists/settings/InviteListItem",["hb!templates/desktop/lists/settings/InviteListItem.tpl","underscore","moment","marionette","plex/base/utils/t","plex/base/utils/formatters/stringUtil","plex/base/commands/commands","plex/base/models/appModel","plex/base/views/images/GravatarImage"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=n.ItemView.extend({tagName:"li",className:"card-tile-list-item card-2-col-item",template:e,ui:{poster:".card-poster"},events:{"click .accept-btn":"onAcceptClick","click .delete-btn":"onDeleteClick"},initialize:function(){this.subset=this.model.collection.subset,this.image=new l({model:this.model,type:"friend",width:80})
},serializeData:function(){return{showAccept:"requests"===this.subset}},bindings:{".username":{modelAttribute:"friendlyName"},".user-summary":{modelAttribute:"Server",autohide:!0,formatter:function(e){if("requested"===this.subset){var n=this.model.get("createdAt");return n?s("invite sent {1}",i.unix(n).fromNow()):s("invite sent to {1}",this.model.get("email"))}var r=this.model.get("friend"),o=this.model.get("server"),l=this.model.get("home");if(o){var c=t.reduce(e,function(e,t){return e+=t.numLibraries
},0),d=a.pluralize(s("library"),c,s("libraries"));return l?s("wants you to join their home and share {1} {2} with you",c,d):r?s("wants to be friends and share {1} {2} with you",c,d):s("wants to share {1} {2} with you",c,d)}return s(l?"wants you to join their home":"wants to be friends")}}},onRender:function(){this.image.setElement(this.ui.poster)},onClose:function(){this.image.close()},onAcceptClick:function(e){e.preventDefault(),r.execute("acceptInvite",{invite:this.model})},onDeleteClick:function(e){e.preventDefault(),r.execute("rejectInvite",{invite:this.model,subset:this.subset})
}});return c}),define("plex/desktop/views/lists/settings/InviteList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/settings/InviteListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t,sorted:!0});return i}),define("hb!templates/desktop/lists/settings/FriendListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="card card-user card-friend">\n  <div class="card-poster media-poster img-circle"></div>\n\n  <div class="card-actions">\n    <button class="edit-btn card-action-btn"><i class="glyphicon pencil"></i></button>\n    <button class="delete-btn card-action-btn btn-danger"><i class="glyphicon remove-2"></i></button>\n  </div>\n\n  <h4 class="username"></h4>\n\n  <div class="card-details"></div>\n</div>\n'
})}),define("hb!templates/desktop/lists/settings/FriendListItemStatusView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <p class="user-summary">\n    <i class="server-share-direction-icon glyphicon right-arrow"></i>\n    <a class="server-share-edit-btn server-share-status shared '+v((n=e&&e.shared,n=null==n||n===!1?n:n.status,typeof n===y?n.apply(e):n))+" ",s=i.unless.call(e,e&&e.canEdit,{hash:{},inverse:b.noop,fn:b.program(2,r,t),data:t}),(s||0===s)&&(a+=s),a+='" href="#">\n      <i class="server-share-status-icon available glyphicon circle-ok"></i>\n      <i class="server-share-status-icon unavailable glyphicon circle-exclamation-mark"></i>\n      <i class="server-share-status-icon unknown glyphicon circle-question-mark"></i>\n      <i class="server-share-status-hover-icon glyphicon pencil"></i>\n    </a>\n\n    ',s=i["if"].call(e,(n=e&&e.shared,null==n||n===!1?n:n.hasActiveShare),{hash:{},inverse:b.program(6,l,t),fn:b.program(4,o,t),data:t}),(s||0===s)&&(a+=s),a+="\n  </p>\n"
}function r(){return"disabled"}function o(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"shares {1} {2} with you",(n=e&&e.shared,null==n||n===!1?n:n.numLibraries),(n=e&&e.shared,null==n||n===!1?n:n.libraryLabel),s):g.call(e,"t","shares {1} {2} with you",(n=e&&e.shared,null==n||n===!1?n:n.numLibraries),(n=e&&e.shared,null==n||n===!1?n:n.libraryLabel),s)))+"\n    "}function l(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"wants to share {1} {2} with you",(n=e&&e.shared,null==n||n===!1?n:n.numLibraries),(n=e&&e.shared,null==n||n===!1?n:n.libraryLabel),s):g.call(e,"t","wants to share {1} {2} with you",(n=e&&e.shared,null==n||n===!1?n:n.numLibraries),(n=e&&e.shared,null==n||n===!1?n:n.libraryLabel),s)))+"\n    "
}function c(e,t){var n,s,a="";return a+='\n  <p class="user-summary">\n    <i class="server-share-direction-icon glyphicon left-arrow"></i>\n     <a class="server-share-edit-btn server-share-status owned '+v((n=e&&e.owned,n=null==n||n===!1?n:n.status,typeof n===y?n.apply(e):n))+" ",s=i.unless.call(e,e&&e.canEdit,{hash:{},inverse:b.noop,fn:b.program(2,r,t),data:t}),(s||0===s)&&(a+=s),a+='" href="#">\n      <i class="server-share-status-icon available glyphicon circle-ok"></i>\n      <i class="server-share-status-icon unavailable glyphicon circle-exclamation-mark"></i>\n      <i class="server-share-status-icon unknown glyphicon circle-question-mark"></i>\n      <i class="server-share-status-hover-icon glyphicon pencil"></i>\n    </a>\n\n    ',s=i["if"].call(e,(n=e&&e.owned,null==n||n===!1?n:n.hasActiveShare),{hash:{},inverse:b.program(11,u,t),fn:b.program(9,d,t),data:t}),(s||0===s)&&(a+=s),a+="\n  </p>\n"
}function d(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"sharing {1} {2} with this {3}",(n=e&&e.owned,null==n||n===!1?n:n.numLibraries),(n=e&&e.owned,null==n||n===!1?n:n.libraryLabel),(n=e&&e.owned,null==n||n===!1?n:n.friendLabel),s):g.call(e,"t","sharing {1} {2} with this {3}",(n=e&&e.owned,null==n||n===!1?n:n.numLibraries),(n=e&&e.owned,null==n||n===!1?n:n.libraryLabel),(n=e&&e.owned,null==n||n===!1?n:n.friendLabel),s)))+"\n    "}function u(e,t){var n,s,a="";
return a+="\n      ",s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"invited to share {1} {2}",(n=e&&e.owned,null==n||n===!1?n:n.numLibraries),(n=e&&e.owned,null==n||n===!1?n:n.libraryLabel),s):g.call(e,"t","invited to share {1} {2}",(n=e&&e.owned,null==n||n===!1?n:n.numLibraries),(n=e&&e.owned,null==n||n===!1?n:n.libraryLabel),s)))+"\n    "}function h(e,t){var n,s,a="";return a+='\n  <p class="user-summary server-share-empty-message">',s={hash:{},data:t},a+=v((n=i.t||e&&e.t,n?n.call(e,"no shared libraries",s):g.call(e,"t","no shared libraries",s)))+"</p>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var p,m,f="",g=i.helperMissing,v=this.escapeExpression,y="function",b=this;return m=i["if"].call(t,(p=t&&t.shared,null==p||p===!1?p:p.numLibraries),{hash:{},inverse:b.noop,fn:b.program(1,a,s),data:s}),(m||0===m)&&(f+=m),f+="\n\n",m=i["if"].call(t,(p=t&&t.owned,null==p||p===!1?p:p.numLibraries),{hash:{},inverse:b.noop,fn:b.program(8,c,s),data:s}),(m||0===m)&&(f+=m),f+="\n\n",m=i["if"].call(t,t&&t.showEmptyMessage,{hash:{},inverse:b.noop,fn:b.program(13,h,s),data:s}),(m||0===m)&&(f+=m),f+="\n"
})}),define("plex/desktop/views/lists/settings/FriendListItemStatusView",["hb!templates/desktop/lists/settings/FriendListItemStatusView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/formatters/stringUtil","plex/base/models/appModel","plex/desktop/views/modals/user/EditFriendModal"],function(e,t,i,n,s,a,r,o,l){"use strict";var c=n.ItemView.extend({className:"friend-server-status-container",template:e,events:{"click .server-share-edit-btn":"onEditClick"},initialize:function(){this.collection=this.model.get("serverShares"),this.servers=o.get("servers"),this.attachedServers=[],this.collection.each(this.addServerShare,this),this.listenTo(this.collection,{add:this.onServerShareAdd,remove:this.onServerShareRemove,"change:numLibraries":this.render}),this.listenTo(this.servers,"add",this.onServerAdd)
},serializeData:function(){var e={owned:this.getLibrariesData({owned:!0}),shared:this.getLibrariesData({owned:!1}),canEdit:!o.get("user").get("restricted")};return e.owned.numLibraries||e.shared.numLibraries||(e.showEmptyMessage=!0),e},getLibrariesData:function(e){var t={friendLabel:s(this.model.get("restricted")?"user":"friend"),status:this.getServerStatus(e),hasActiveShare:!!this.collection.findWhere({pending:!1,owned:e.owned})};return t.numLibraries=this.collection.getLibraryCount({pending:!t.hasActiveShare,owned:e.owned}),t.libraryLabel=r.pluralize(s("library"),t.numLibraries,s("libraries")),t
},getServerStatus:function(e){for(var t,i=0,n=this.collection.length;n>i;i++){var s=this.collection.at(i);if(s.get("owned")===e.owned){var a=this.servers.get(s.get("machineIdentifier")),r=a&&a.get("connected");if(r===!1)return"unavailable";r&&(t="available")}}return t},addServerShare:function(e){var t=this.servers.get(e.get("machineIdentifier"));t&&this.attachServer(t)},removeServerShare:function(e){var t=this.servers.get(e.get("machineIdentifier"));t&&!e.get("owned")&&this.detachServer(t)},attachServer:function(e){this.attachedServers.push(e),this.listenTo(e,"change:connected",this.render)
},detachServer:function(e){var i=t.indexOf(this.attachedServers,e);i>-1&&this.attachedServers.splice(i,1),this.stopListening(e)},onServerShareAdd:function(e){this.addServerShare(e),this.render()},onServerShareRemove:function(e){this.removeServerShare(e),this.render()},onServerAdd:function(e){this.collection.findWhere({machineIdentifier:e.id})&&(this.attachServer(e),this.render())},onEditClick:function(e){e.preventDefault();var t=i(e.currentTarget);if(!t.isDisabled()){var n,s=t.hasClass("owned"),r=this.collection.findWhere({owned:s});
r&&(n=r.get("machineIdentifier")),a.trigger("show:modal",new l({model:this.model,defaultPaneType:s?"ownedServer":"sharedServer",defaultPaneID:n}))}}});return c}),define("plex/desktop/views/lists/settings/FriendListItem",["hb!templates/desktop/lists/settings/FriendListItem.tpl","marionette","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/views/images/GravatarImage","plex/desktop/views/lists/settings/FriendListItemStatusView","plex/desktop/views/modals/user/EditFriendModal"],function(e,t,i,n,s,a,r){"use strict";
var o=t.Layout.extend({tagName:"li",className:"card-tile-list-item card-2-col-item",template:e,ui:{poster:".card-poster"},regions:{details:".card-details"},events:{"click .edit-btn":"onEditClick","click .delete-btn":"onDeleteClick"},initialize:function(){this.serverShares=this.model.get("serverShares"),this.image=new s({model:this.model,type:"friend",width:80})},bindings:{".username":{modelAttribute:"title"}},onRender:function(){this.image.setElement(this.ui.poster),this.details.show(new a({model:this.model}))
},onClose:function(){this.image.close()},onEditClick:function(e){e.preventDefault(),i.trigger("show:modal",new r({model:this.model}))},onDeleteClick:function(e){e.preventDefault(),n.execute("removeFriend",{friend:this.model})}});return o}),define("hb!templates/desktop/lists/settings/FriendListEmptyView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<h4 class="text-muted text-center">',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"No friends yet. {1}Invite a friend{2} and share your libraries.","<a class='invite-friend-btn' href='#'>","</a>",r):l.call(t,"t","No friends yet. {1}Invite a friend{2} and share your libraries.","<a class='invite-friend-btn' href='#'>","</a>",r)))+"</h4>\n"
})}),define("plex/desktop/views/lists/settings/FriendListEmptyView",["hb!templates/desktop/lists/settings/FriendListEmptyView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({template:e});return i}),define("plex/desktop/views/lists/settings/FriendList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/settings/FriendListItem","plex/desktop/views/lists/settings/FriendListEmptyView"],function(e,t,i){"use strict";var n=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t,emptyView:i,sorted:!0});
return n}),define("plex/desktop/views/settings/FriendsView",["hb!templates/desktop/settings/FriendsView.tpl","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/lists/settings/InviteList","plex/desktop/views/lists/settings/FriendList"],function(e,t,i,n,s,a){"use strict";var r=t.Layout.extend({className:"friends-container col-sm-8 col-md-9",template:e,ui:{inviteListHeader:".invite-list-header",friendListHeader:".friend-list-header",pendingListHeader:".pending-list-header"},regions:{inviteList:".invite-list-container",friendList:".friend-list-container",pendingList:".pending-list-container"},initialize:function(){var e=n.get("user");
return e.get("restricted")?void i.trigger("navigate","users",{subset:"home"}):(this.collection=e.get("friends").filterByUnrestricted(),this.invites=e.get("invites").filterByFriends(),this.sentInvites=e.get("sentInvites").filterByFriends(),void this.addListeners())},addListeners:function(){this.listenTo(this.invites,"reset add remove",this.onInvitesChange),this.listenTo(this.sentInvites,"reset add remove",this.onInvitesChange)},updateHeaders:function(){var e=!!this.invites.length,t=!!this.sentInvites.length,i=e||t;
this.ui.friendListHeader.toggleClass("hidden",!i),this.ui.inviteListHeader.toggleClass("hidden",!e),this.ui.pendingListHeader.toggleClass("hidden",!t),this.ui.friendListHeader.toggleClass("top",!e),this.ui.inviteListHeader.toggleClass("top",e)},onRender:function(){this.friendList.show(new a({collection:this.collection})),this.inviteList.show(new s({collection:this.invites})),this.pendingList.show(new s({collection:this.sentInvites})),this.updateHeaders()},onClose:function(){this.collection.destroy&&this.collection.destroy(),this.invites.destroy(),this.sentInvites.destroy()
},onInvitesChange:function(){this.updateHeaders()}});return r}),define("hb!templates/desktop/lists/settings/HomeUserListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'<div class="selected-user-icon"></div>'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o="",l=this;return o+='<div class="card card-user card-friend card-home-user">\n  ',r=i["if"].call(t,t&&t.isSignedInUser,{hash:{},inverse:l.noop,fn:l.program(1,a,s),data:s}),(r||0===r)&&(o+=r),o+='\n\n  <div class="card-poster media-poster img-circle"></div>\n\n  <div class="card-actions">\n    <button class="pin-btn pin-protected-btn card-action-btn btn-success"><i class="glyphicon lock"></i></button>\n    <button class="pin-btn pin-unprotected-btn card-action-btn"><i class="glyphicon unlock"></i></button>\n    <button class="edit-btn card-action-btn"><i class="glyphicon pencil"></i></button>\n    <button class="delete-btn card-action-btn btn-danger"><i class="glyphicon remove-2"></i></button>\n  </div>\n\n  <h4>\n    <i class="admin-icon glyphicon crown"></i>\n    <span class="username"></span>\n  </h4>\n\n  <div class="card-details">\n    <div class="user-type text-muted"></div>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/lists/settings/HomeUserListItem",["hb!templates/desktop/lists/settings/HomeUserListItem.tpl","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/commands","plex/base/models/appModel","plex/base/views/images/GravatarImage","plex/desktop/views/lists/settings/FriendListItemStatusView","plex/desktop/views/modals/user/EditFriendModal","plex/desktop/views/modals/user/UserSelectModal"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";var u=i.Layout.extend({tagName:"li",className:"card-tile-list-item card-2-col-item",template:e,ui:{poster:".card-poster"},regions:{details:".card-details"},events:{"click .pin-btn":"onPINClick","click .edit-btn":"onEditClick","click .delete-btn":"onDeleteClick"},initialize:function(e){var t=r.get("user"),i=t.get("friends"),n=i.get(this.model.id);
this.isAdmin=e.isAdmin,this.isSignedInUser=this.model.id===t.id,this.image=new o({model:this.model,type:"friend",width:80}),n?this.friend=n:this.listenTo(i,"add",this.onFriendAdd)},serializeData:function(){return{isSignedInUser:this.isSignedInUser}},canEditPIN:function(){var e=this.isSignedInUser&&!this.model.get("restricted"),t=this.isAdmin&&this.model.get("restricted");return e||t},showStatusView:function(){this.friend&&this.details.append(new l({model:this.friend}))},bindings:{".username":{modelAttribute:"title"},".admin-icon":{modelAttribute:"admin",autohide:!0,manual:!0},".user-type":{modelAttribute:"restricted",autohide:!0,formatter:function(e){return e?n("Managed User"):void 0
}},".pin-protected-btn":{modelAttribute:"protected",manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.canEditPIN()),e}},".pin-unprotected-btn":{modelAttribute:"protected",manual:!0,autohide:!0,formatter:function(e,t){return t.toggleClass("disabled",!this.canEditPIN()),!e}},".edit-btn":{modelAttribute:"admin",manual:!0,autohide:!0,formatter:function(){var e=r.get("user"),t=this.isAdmin||!e.get("restricted")&&!this.model.get("restricted");return t&&!this.isSignedInUser
}},".delete-btn":{modelAttribute:"admin",manual:!0,autohide:!0,formatter:function(){return this.isAdmin&&!this.isSignedInUser}}},onRender:function(){this.image.setElement(this.ui.poster),this.showStatusView()},onClose:function(){this.image.close()},onFriendAdd:function(e){e.id===this.model.id&&(this.friend=e,this.showStatusView())},onPINClick:function(e){e.preventDefault(),t(e.currentTarget).isDisabled()||s.trigger("show:modal",new d({model:this.model,isEditing:!0}))},onEditClick:function(e){e.preventDefault(),s.trigger("show:modal",new c({type:"home",homeUser:this.model,isAdmin:this.isAdmin}))
},onDeleteClick:function(e){e.preventDefault(),a.execute("removeHomeUser",{homeUser:this.model})}});return u}),define("hb!templates/desktop/lists/settings/HomeUserListEmptyView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n  <h4 class="text-muted text-center">',s={hash:{},data:t},a+=d((n=i.t||e&&e.t,n?n.call(e,"No one else is in your home. {1}Add a user{2} to enable user switching.","<a class='add-user-btn' href='#'>","</a>",s):c.call(e,"t","No one else is in your home. {1}Add a user{2} to enable user switching.","<a class='add-user-btn' href='#'>","</a>",s)))+"</h4>\n"
}function r(e,t){var n,s,a,r="";return r+='\n  <h4 class="text-muted text-center">',a={hash:{},data:t},r+=d((n=i.t||e&&e.t,n?n.call(e,"You need a Plex Pass to add users to your home.",a):c.call(e,"t","You need a Plex Pass to add users to your home.",a)))+'</h4>\n\n  <p class="text-center">\n    <a class="btn btn-sm btn-primary" href="',(s=i.plexPassUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.plexPassUrl,s=typeof s===u?s.call(e,{hash:{},data:t}):s),r+=d(s)+'" target="_blank">',a={hash:{},data:t},r+=d((n=i.t||e&&e.t,n?n.call(e,"Learn More",a):c.call(e,"t","Learn More",a)))+"</a>\n  </p>\n"
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l="",c=i.helperMissing,d=this.escapeExpression,u="function",h=this;return o=i["if"].call(t,t&&t.hasPlexPass,{hash:{},inverse:h.program(3,r,s),fn:h.program(1,a,s),data:s}),(o||0===o)&&(l+=o),l+='\n\n<ul class="list centered-home-user-container"></ul>\n'})}),define("plex/desktop/views/lists/settings/HomeUserListEmptyView",["hb!templates/desktop/lists/settings/HomeUserListEmptyView.tpl","underscore","marionette","plex/base/models/appModel","plex/desktop/views/lists/settings/HomeUserListItem"],function(e,t,i,n,s){"use strict";
var a=i.Layout.extend({template:e,regions:{card:".centered-home-user-container"},initialize:function(e){this.itemViewOptions=e},serializeData:function(){var e=n.get("user");return{hasPlexPass:e.hasPlexPass(),plexPassUrl:e.server.get("plexPassUrl")}},onRender:function(){var e=n.get("user"),i=e.get("homeUsers");i.length&&this.card.show(new s(t.extend({},this.itemViewOptions,{model:i.first()})))}});return a}),define("plex/desktop/views/lists/settings/HomeUserList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/settings/HomeUserListItem","plex/desktop/views/lists/settings/HomeUserListEmptyView"],function(e,t,i){"use strict";
var n=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t,emptyView:i,sorted:!0,isEmpty:function(){return!this.collection||this.collection.length<2},addChildView:function(t){this.isEmpty(this.collection)?this.showEmptyView():this._showingEmptyView?this.render():this.children.findByModel(t)||e.prototype.addChildView.apply(this,arguments)},showEmptyView:function(){this._showingEmptyView||this.children.each(function(e){this.removeChildView(e)},this),e.prototype.showEmptyView.apply(this,arguments)
}});return n}),define("plex/desktop/views/settings/HomeView",["hb!templates/desktop/settings/HomeView.tpl","plex/base/models/appModel","plex/desktop/views/settings/FriendsView","plex/desktop/views/lists/settings/InviteList","plex/desktop/views/lists/settings/HomeUserList"],function(e,t,i,n,s){"use strict";var a=i.extend({template:e,initialize:function(){var e=t.get("user");this.collection=e.get("homeUsers"),this.invites=e.get("invites").filterByHome(),this.sentInvites=e.get("sentInvites").filterByHome(),this.signedInHomeUser=this.collection.get(e.id),this.itemViewOptions={isAdmin:!(!this.signedInHomeUser||!this.signedInHomeUser.get("admin"))},this.addListeners()
},addListeners:function(){i.prototype.addListeners.apply(this,arguments),this.signedInHomeUser&&this.listenTo(this.signedInHomeUser,"change:admin",this.onAdminChange)},onRender:function(){this.friendList.show(new s({collection:this.collection,itemViewOptions:this.itemViewOptions})),this.inviteList.show(new n({collection:this.invites})),this.pendingList.show(new n({collection:this.sentInvites})),this.updateHeaders()},onAdminChange:function(e,t){this.friendList.currentView&&(this.itemViewOptions.isAdmin=t)
}});return a}),define("plex/desktop/views/settings/UsersView",["hb!templates/desktop/settings/UsersView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/loggerAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/settings/HomeView","plex/desktop/views/settings/FriendsView","plex/desktop/views/modals/user/EditFriendModal","plex/desktop/views/modals/user/UserSelectModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h){"use strict";
var p={home:c,friends:d},m=n.Layout.extend({className:"users-container",template:e,ui:{navLinks:".nav-cards a",homeBadge:".home-card > .badge",friendsBadge:".friends-card > .badge",addUserBtn:".add-user-btn",leaveHomeBtn:".leave-home-btn"},regions:{container:".users-row"},events:{"click .nav-cards a":"onNavClick","click .add-user-btn":"onAddUserClick","click .leave-home-btn":"onLeaveHomeClick","click .invite-friend-btn":"onInviteFriendClick"},shouldShowAddUser:function(){return this.signedInHomeUser.get("admin")&&this.user.hasPlexPass()
},shouldShowLeaveHome:function(){return this.home.length>1&&!this.signedInHomeUser.get("restricted")},shouldShowFriends:function(){return!this.signedInHomeUser.get("restricted")},initialize:function(e){this.subset=e.usersSubset,this.user=l.get("user"),this.home=this.user.get("homeUsers"),this.invites=this.user.get("invites"),this.signedInHomeUser=this.home.get(this.user.id),this.proxies={home:this.invites.filterByHome(),friends:this.invites.filterByFriends()},e.promptPIN&&a.trigger("show:modal",new h({model:this.signedInHomeUser,isEditing:!0,isEditWarning:!this.signedInHomeUser.get("protected")})),this.listenTo(this.signedInHomeUser,"change:admin",this.onAdminChange),this.listenTo(this.home,"reset add remove",this.onHomeChange),this.listenTo(this.invites,"reset add remove",this.onInvitesChange)
},serializeData:function(){return{subset:this.subset,showAddUser:this.shouldShowAddUser(),showLeaveHome:this.shouldShowLeaveHome(),showFriends:this.shouldShowFriends()}},showSubset:function(e){e&&(this.$el.removeClass("show-"+this.subset),this.subset=e),this.$el.addClass("show-"+this.subset);var t=p[this.subset];t?this.container.append(new t):r.warn("Invalid subset: "+this.subset)},updateBadges:function(){var e={home:this.proxies.home.length,friends:this.proxies.friends.length};t.each(t.keys(e),function(t){var i=this.ui[t+"Badge"];
i.text(e[t]),i.toggleClass("hidden",0===e[t])},this)},onRender:function(){this.showSubset(),this.updateBadges()},onClose:function(){t.each(this.proxies,function(e){e.destroy()})},onAdminChange:function(){this.ui.addUserBtn.toggleClass("hidden",!this.shouldShowAddUser())},onHomeChange:function(){this.ui.leaveHomeBtn.toggleClass("hidden",!this.shouldShowLeaveHome())},onInvitesChange:function(){this.updateBadges()},onNavClick:function(e){e.preventDefault();var n=i(e.currentTarget);n.hasClass("selected")||(this.ui.navLinks.removeClass("selected"),n.addClass("selected"),this.showSubset(t.last(e.currentTarget.href.split("/"))),a.trigger("navigate","users",{subset:this.subset,trigger:!1}))
},onAddUserClick:function(e){e.preventDefault();var t=this.user.get("maxHomeSize");t&&this.home.length-1<t?a.trigger("show:modal",new u({type:"home"})):a.trigger("show:alert",{type:"error",message:s("You have reached the {1} person home limit.",t)})},onLeaveHomeClick:function(e){e.preventDefault(),o.execute("removeHomeUser",{homeUser:this.signedInHomeUser,isSignedInUser:!0})},onInviteFriendClick:function(e){e.preventDefault(),a.trigger("show:modal",new u({type:"friend"}))}});return m}),define("hb!templates/desktop/settings/DevicesView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";
return s+="\n      ",n=i["if"].call(e,e&&e.title,{hash:{},inverse:d.noop,fn:d.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\n    "}function r(e,t){var n,s,a,r="";return r+='\n        <li>\n          <a class="card btn-gray ',a={hash:{},inverse:d.noop,fn:d.program(3,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,e&&e.id,"all",a):u.call(e,"if_eq",e&&e.id,"all",a),(s||0===s)&&(r+=s),r+='" data-id="',(s=i.id)?s=s.call(e,{hash:{},data:t}):(s=e&&e.id,s=typeof s===h?s.call(e,{hash:{},data:t}):s),r+=p(s)+'" href="#">',a={hash:{},data:t},r+=p((n=i.t||e&&e.t,n?n.call(e,e&&e.title,a):u.call(e,"t",e&&e.title,a)))+"</a>\n        </li>\n      "
}function o(){return"selected"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c="",d=this,u=i.helperMissing,h="function",p=this.escapeExpression;return c+='<div class="col-sm-4 col-md-3">\n  <ul class="nav nav-cards">\n    ',l=i.each.call(t,t&&t.deviceTypes,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(l||0===l)&&(c+=l),c+='\n  </ul>\n</div>\n\n<div class="device-list-container col-sm-8 col-md-9"></div>\n'})}),define("hb!templates/desktop/lists/settings/DeviceListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){return this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{},'<div class="card card-device">\n  <i class="card-poster device-icon"></i>\n\n  <div class="card-actions">\n    <button class="remove-device-btn card-action-btn btn-danger"><i class="glyphicon remove-2"></i></button>\n  </div>\n\n  <h4 class="name"></h4>\n\n  <div class="card-details">\n    <div class="pull-right">\n      <div class="last-seen text-muted"></div>\n\n      <span class="sync-info hidden">\n        <span class="glyphicon circle-arrow-down sync-icon"></span>\n        <span class="sync-count"></span>\n        <span class="sync-size"></span>\n      </span>\n    </div>\n\n    <span class="version text-muted"></span>\n\n    <div class="device-info-container">\n      <div class="product"></div>\n      <div class="device text-muted"></div>\n      <div class="platform-info text-muted">\n        <span class="platform"></span>\n        <span class="platform-version"></span>\n      </div>\n    </div>\n  </div>\n</div>\n'
})}),define("plex/base/utils/deviceIcons",["underscore"],function(e){"use strict";var t={pms:/plex.*media.*server|plex.*media.*hub/i,osx:/macosx/i,pht:/plex.*home.*theater|plex.*media.*center/i,win8:/windows/i,wp:/windows.*phone|wince/i,ios:/ios/i,android:/android/i,chrome:/chrome/i,safari:/safari/i,firefox:/firefox/i,ie:/internet.*explorer|explorer.*windows/i,opera:/opera/i,wiiu:/wii.*u/i,samsung:/samsung/i,roku:/roku/i,atv:/plex.*atv/i,gtv:/google.*tv/i,cloudsync:/cloudsync/i,dlna:/dlna/i,xbox:/xbox/i},i=e.pairs(t),n={},s={getIcon:function(t){var s="default";
return t?n.hasOwnProperty(t)?n[t]:(e.every(i,function(e){var i=e[1].test(t);return i&&(s=e[0],n[t]=s),!i}),s):s}};return s}),define("plex/desktop/views/lists/settings/DeviceListItem",["hb!templates/desktop/lists/settings/DeviceListItem.tpl","marionette","moment","plex/base/utils/deviceIcons","plex/base/utils/formatters/stringUtil","plex/base/utils/formatters/numberUtil","plex/base/commands/commands"],function(e,t,i,n,s,a,r){"use strict";var o=t.ItemView.extend({tagName:"li",className:"card-tile-list-item card-2-col-item",template:e,ui:{icon:".device-icon",syncInfo:".sync-info"},events:{"click .remove-device-btn":"onRemoveClick"},isMediaServer:function(){if(null==this.isServer){var e=this.model.get("product").toLowerCase();
this.isServer="plex media server"===e}return this.isServer},bindings:{".device-icon":{modelAttribute:"platform",manual:!0,formatter:function(e,t){var i=n.getIcon(e);t.addClass("device-icon-"+i)}},".name":{modelAttribute:"name",autohide:!1},".version":{modelAttribute:"productVersion",autohide:!1},".product":{modelAttribute:"product",autohide:!1},".platform":{modelAttribute:"platform",autohide:function(e){return e&&this.isMediaServer()}},".platform-version":{modelAttribute:"platformVersion",autohide:function(e){return e&&this.isMediaServer()
}},".device":{modelAttribute:"device",autohide:!1},".last-seen":{modelAttribute:"lastSeenAt",autohide:!0,formatter:function(e){return e?i.unix(e).fromNow():void 0}},".sync-count":{modelAttribute:"SyncList",autohide:!1,formatter:function(e){if(e){var t,i=e.itemsCompleteCount;return i&&i>0&&(t=[i,s.pluralize("item",i)].join(" "),this.ui.syncInfo.removeClass("hidden")),t}}},".sync-size":{modelAttribute:"SyncList",autohide:!1,formatter:function(e){if(e){var t,i=e.totalSize;return i&&i>0&&(t=["(",a.bytesToSize(i),")"].join("")),t
}}}},onRemoveClick:function(e){e.preventDefault(),this.isMediaServer()?r.execute("removeServer",{device:this.model}):r.execute("removeDevice",{device:this.model})}});return o}),define("plex/desktop/views/lists/settings/DeviceList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/settings/DeviceListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t});return i}),define("plex/desktop/views/settings/DevicesView",["hb!templates/desktop/settings/DevicesView.tpl","underscore","jquery","marionette","plex/desktop/views/lists/settings/DeviceList"],function(e,t,i,n,s){"use strict";
var a=n.Layout.extend({className:"devices-container row",template:e,regions:{list:".device-list-container"},events:{"click .nav a":"onDeviceTypeClick"},ui:{filters:".nav a"},deviceTypes:[{id:"all",title:"All",ids:["all"]},{id:"web",title:"Web",ids:["Web Client","Plex Web"]},{id:"pht",title:"Home Theater",ids:["Plex Home Theater","Plex for Home Theater","PlexHomeTheater","Plex Media Center"]},{id:"pms",title:"Server",ids:["Plex Media Server"]},{id:"android",title:"Android",ids:["Plex for Android","Android"]},{id:"ios",title:"iOS",ids:["Plex/iOS","Plex for iOS"]},{id:"samsung",title:"Samsung",ids:["Plex for Samsung"]},{id:"google-tv",title:"Google TV",ids:["Google TV"]},{id:"windows",title:"Windows",ids:["Plex for Windows"]},{id:"apple-tv",title:"Apple TV",ids:["Plex-ATV"]},{id:"windows-phone",title:"Windows Phone",ids:["Plex for Windows Phone"]},{id:"plexbmc",title:"PleXBMC",ids:["PleXBMC"]},{id:"cloud-sync",title:"Cloud Sync",ids:["Cloud Sync"]},{id:"roku",title:"Roku",ids:["Plex for Roku"]},{id:"popcorn-hour",title:"Popcorn Hour",ids:["Plex for Popcorn Hour"]},{id:"xbox",title:"Xbox One",ids:["Plex for Xbox One"]},{id:"other",title:"Other",ids:[]}],initialize:function(){this.products=this.collection.products(),this.addOtherIds()
},serializeData:function(){return{deviceTypes:this.getFilteredDeviceTypes()}},sortDeviceTypes:function(e){var i=t.sortBy(e,function(e){return"all"===e.id?"":e.title.toLowerCase()});return i},getFilteredDeviceTypes:function(){var e=this.deviceTypes.filter(function(e){return"all"===e.id?!0:t.intersection(this.products,e.ids).length>0},this);return this.sortDeviceTypes(e)},addOtherIds:function(){var e=t.flatten(t.map(this.deviceTypes,function(e){return e.ids})),i=t.difference(this.products,e),n=t.find(this.deviceTypes,function(e){return"other"===e.id
});t.each(i,function(e){n.ids.push(e)})},onRender:function(){this.list.show(new s({collection:this.collection}))},onDeviceTypeClick:function(e){e.preventDefault();var n=i(e.currentTarget),a=n.data("id"),r=this.collection;if(this.ui.filters.removeClass("selected"),n.addClass("selected"),"all"!==a){var o=t.findWhere(this.deviceTypes,{id:a});r=this.collection.filterByProducts(o.ids)}this.list.show(new s({collection:r}))}});return a}),define("plex/desktop/views/settings/SettingsView",["hb!templates/desktop/settings/SettingsView.tpl","underscore","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/settings/WebSettingsView","plex/desktop/views/settings/server/ServerSettingsView","plex/desktop/views/settings/UsersView","plex/desktop/views/settings/DevicesView"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c={web:a,server:r,users:o,devices:l},d=i.Layout.extend({className:"container",template:e,ui:{webNavItem:".web-nav-item",serverNavItem:".server-nav-item",usersNavItem:".users-nav-item",devicesNavItem:".devices-nav-item",usersBadge:".users-btn > .badge"},regions:{container:".settings-container"},onlyAfterRender:["onSignedInChange","onPrimaryServerChange"],initialize:function(e){this.options=e,this.subset=e.subset||"web";var t=s.get("user"),i=t.get("invites");this.subsets={users:i},this.listenTo(t,"change:signedIn",this.onSignedInChange),this.listenTo(s,"change:primaryServer",this.onPrimaryServerChange),this.listenTo(i,"reset add remove",this.onInvitesChange),this.listenTo(n,"change:language",this.render)
},serializeData:function(){var e=s.get("user"),t=s.get("primaryServer");return{subset:this.subset,signedIn:e.get("signedIn"),hasPrimaryServer:t&&!t.get("shared")}},updateBadges:function(){var e={users:this.subsets.users.length};t.each(t.keys(e),function(t){var i=this.ui[t+"Badge"];i.text(e[t]),i.toggleClass("hidden",0===e[t])},this)},onRender:function(){var e=c[this.subset];this.container.show(new e(this.options)),this.updateBadges()},onSignedInChange:function(e,t){this.ui.usersNavItem.toggleClass("hidden",!t),this.ui.devicesNavItem.toggleClass("hidden",!t)
},onPrimaryServerChange:function(e,t){var i=t&&!t.get("shared");this.ui.serverNavItem.toggleClass("hidden",!i)},onInvitesChange:function(){this.updateBadges()}});return d}),define("plex/desktop/routes/SettingsController",["jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/routes/BaseController","plex/base/models/appModel","plex/base/models/server/ServerAccountModel","plex/base/models/server/ServerSettingCollection","plex/desktop/views/settings/SettingsView","plex/desktop/views/error/ErrorView"],function(e,t,i,n,s,a,r,o,l,c){"use strict";
var d=s.extend({settings:function(){var e=this.populateView();e.done(function(){i.trigger("show:view",new l({model:n.getInstance(),subset:"web"}))})},webSettings:function(){var e=this.populateView();e.done(function(){i.trigger("show:view",new l({model:n.getInstance(),subset:"web"}))})},serverSettings:function(n){var s;s=n?{serverID:n}:{primaryServer:!0};var a=this.populateView(s);a.done(function(n){var s=n.server;if(s.get("shared"))return void i.trigger("show:view",new c({title:t("Server settings are restricted from shared users.")}));
var a=s.get("settings"),d=new r({key:"/accounts/1"},{server:s}),u=s.get("cloudAccount"),h=new o([],{server:s,url:"/system/:/prefs"}),p=e.when(a.fetch(),d.fetch({scope:"page"}),u.fetch({scope:"page"}),h.fetch({scope:"page"}));p.done(function(){i.trigger("show:view",new l({model:s,collection:s.get("settings"),account:d,cloudAccount:u,channelSettings:h,subset:"server"}))}),p.fail(function(){i.trigger("show:view",new c({title:t("Server settings are unavailable.")}))})})},users:function(n){var s=this.populateView({serverID:"myPlex"});
s.done(function(){var s=a.get("user"),r=s.get("homeUsers"),o=s.get("friends"),d=s.get("invites"),u=s.get("sentInvites"),h=e.when(s.fetch({scope:"page"}),r.fetch({scope:"page"}),o.fetch({scope:"page"}),d.fetch({scope:"page"}),u.fetch({scope:"page"}));h.done(function(){var e=!1;"pin"===n?(n="home",e=!0):n||(n=d.length&&!d.findWhere({home:!0})?"friends":"home"),i.trigger("show:view",new l({model:a.get("user"),subset:"users",usersSubset:n,promptPIN:e}))}),h.fail(function(){var e;e=t("friends"===n?"Your friends are unavailable.":"Your home is unavailable."),i.trigger("show:view",new c({title:e}))
})})},devices:function(){var e=this.populateView({serverID:"myPlex"});e.done(function(){var e=a.get("user"),n=e.get("devices"),s=n.fetch({scope:"page"});s.done(function(){i.trigger("show:view",new l({model:e,collection:n,subset:"devices"}))}),s.fail(function(){i.trigger("show:view",new c({title:t("Your devices are unavailable.")}))})})}});return d}),define("plex/desktop/routes/SettingsRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/SettingsController"],function(e,t){"use strict";var i=e.extend({controller:new t,appRoutes:{"!/settings":"settings","!/settings/web":"webSettings","!/settings/server(/:serverID)":"serverSettings","!/settings/users":"users","!/settings/users(/:subset)":"users","!/settings/devices":"devices"}});
return i}),define("hb!templates/desktop/activity/ActivityView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"selected"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=this,u=i.helperMissing,h=this.escapeExpression;return c+='<ul class="nav nav-header pull-right">\n  <li class="alerts-nav-item"><a class="alerts-btn btn-gray ',l={hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s},r=i.if_eq||t&&t.if_eq,o=r?r.call(t,t&&t.subset,"alerts",l):u.call(t,"if_eq",t&&t.subset,"alerts",l),(o||0===o)&&(c+=o),c+='" href="#!/activity/alerts">',l={hash:{},data:s},c+=h((r=i.t||t&&t.t,r?r.call(t,"Alerts",l):u.call(t,"t","Alerts",l)))+'</a></li>\n  <li class="sync-nav-item"><a class="sync-btn btn-gray ',l={hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s},r=i.if_eq||t&&t.if_eq,o=r?r.call(t,t&&t.subset,"sync",l):u.call(t,"if_eq",t&&t.subset,"sync",l),(o||0===o)&&(c+=o),c+='" href="#!/activity/sync">',l={hash:{},data:s},c+=h((r=i.t||t&&t.t,r?r.call(t,"Sync",l):u.call(t,"t","Sync",l)))+'</a></li>\n  <li class="now-playing-nav-item"><a class="now-playing-btn btn-gray ',l={hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s},r=i.if_eq||t&&t.if_eq,o=r?r.call(t,t&&t.subset,"nowPlaying",l):u.call(t,"if_eq",t&&t.subset,"nowPlaying",l),(o||0===o)&&(c+=o),c+='" href="#!/activity/playing">',l={hash:{},data:s},c+=h((r=i.t||t&&t.t,r?r.call(t,"Now Playing",l):u.call(t,"t","Now Playing",l)))+'<span class="badge"></span></a></li>\n</ul>\n\n<h2>',l={hash:{},data:s},c+=h((r=i.t||t&&t.t,r?r.call(t,"Activity",l):u.call(t,"t","Activity",l)))+'</h2>\n\n<div class="activity-container"></div>\n'
})}),define("hb!templates/desktop/activity/AlertsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,o="";return o+='\n    <div class="filter-bar-right">\n      <span class="page-count">',a={hash:{},data:t},o+=h((n=i.t||e&&e.t,n?n.call(e,"{1} of {2}",e&&e.page,e&&e.pages,a):u.call(e,"t","{1} of {2}",e&&e.page,e&&e.pages,a)))+'</span>\n\n      <a class="previous-btn btn-gray ',s=i.unless.call(e,e&&e.enablePrevious,{hash:{},inverse:p.noop,fn:p.program(2,r,t),data:t}),(s||0===s)&&(o+=s),o+='" href="#">\n        <i class="glyphicon chevron-left"></i>\n      </a>\n\n      <a class="next-btn btn-gray ',s=i.unless.call(e,e&&e.enableNext,{hash:{},inverse:p.noop,fn:p.program(2,r,t),data:t}),(s||0===s)&&(o+=s),o+='" href="#">\n        <i class="glyphicon chevron-right"></i>\n      </a>\n    </div>\n  '
}function r(){return"disabled"}function o(e,t){var n,s,a="";return a+='\n  <div class="row row-padded">\n    <div class="col-md-8 col-md-offset-2">\n      <h4 class="text-muted text-center">',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Alerts are restricted from shared users.",s):u.call(e,"t","Alerts are restricted from shared users.",s)))+"</h4>\n    </div>\n  </div>\n"}function l(){return'\n  <div class="alert-list-container"></div>\n'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return d+='<div class="filter-bar">\n  ',c=i.unless.call(t,t&&t.shared,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(c||0===c)&&(d+=c),d+="\n</div>\n\n",c=i["if"].call(t,t&&t.shared,{hash:{},inverse:p.program(6,l,s),fn:p.program(4,o,s),data:s}),(c||0===c)&&(d+=c),d+="\n"})}),define("hb!templates/desktop/lists/activity/AlertListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n    <i class="server-alert-icon glyphicon cogwheel"></i>\n  '
}function r(e,t){var n,s,a;return a={hash:{},inverse:q.program(6,l,t),fn:q.program(4,o,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"status",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"status",a),s||0===s?s:""}function o(){return'\n    <i class="server-alert-icon glyphicon bullhorn"></i>\n  '}function l(e,t){var n,s,a;return a={hash:{},inverse:q.program(9,d,t),fn:q.program(7,c,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"playing",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"playing",a),s||0===s?s:""
}function c(){return'\n    <i class="server-alert-icon glyphicon imac"></i>\n  '}function d(e,t){var n,s,a;return a={hash:{},inverse:q.program(15,m,t),fn:q.program(10,u,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"websocket",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"websocket",a),s||0===s?s:""}function u(e,t){var n,s,a="";return a+="\n    ",s=i["if"].call(e,(n=e&&e.event,null==n||n===!1?n:n.opened),{hash:{},inverse:q.program(13,p,t),fn:q.program(11,h,t),data:t}),(s||0===s)&&(a+=s),a+="\n  "
}function h(){return'\n      <i class="server-alert-icon glyphicon bullhorn"></i>\n    '}function p(){return'\n      <i class="server-alert-icon glyphicon warning-sign"></i>\n    '}function m(e,t){var n,s,a;return a={hash:{},inverse:q.program(18,g,t),fn:q.program(16,f,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.state),0,a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n.state),0,a),s||0===s?s:""}function f(){return'\n    <i class="server-alert-icon glyphicon plus"></i>\n  '
}function g(e,t){var n,s,a;return a={hash:{},inverse:q.program(21,y,t),fn:q.program(19,v,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.state),5,a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n.state),5,a),s||0===s?s:""}function v(){return'\n    <i class="server-alert-icon glyphicon ok-2"></i>\n  '}function y(e,t){var n,s,a;return a={hash:{},inverse:q.program(24,w,t),fn:q.program(22,b,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.state),6,a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n.state),6,a),s||0===s?s:""
}function b(){return'\n    <i class="server-alert-icon glyphicon magic"></i>\n  '}function w(e,t){var n,s,a;return a={hash:{},inverse:q.program(27,k,t),fn:q.program(25,x,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.state),9,a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n.state),9,a),s||0===s?s:""}function x(){return'\n    <i class="server-alert-icon glyphicon bin"></i>\n  '}function k(){return'\n    <i class="server-alert-icon glyphicon tags"></i>\n  '}function S(e,t){var n,s,a="";
return a+="\n    ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,"{1} set to {2}.",(n=e&&e.event,null==n||n===!1?n:n.label),(n=e&&e.event,null==n||n===!1?n:n.value),s):H.call(e,"t","{1} set to {2}.",(n=e&&e.event,null==n||n===!1?n:n.label),(n=e&&e.event,null==n||n===!1?n:n.value),s)))+"\n  "}function C(e,t){var n,s,a;return a={hash:{},inverse:q.program(38,T,t),fn:q.program(32,P,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"status",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"status",a),s||0===s?s:""
}function P(e,t){var n,s,a="";return a+="\n    ",s=i["if"].call(e,(n=e&&e.event,null==n||n===!1?n:n.message),{hash:{},inverse:q.program(35,_,t),fn:q.program(33,A,t),data:t}),(s||0===s)&&(a+=s),a+="\n  "}function A(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.message),s):H.call(e,"t",(n=e&&e.event,null==n||n===!1?n:n.message),s)))+"\n    "}function _(e,t){var n,s,a,r="";return r+="\n      ",a={hash:{},data:t},r+=W((n=i.t||e&&e.t,n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.title),a):H.call(e,"t",(n=e&&e.event,null==n||n===!1?n:n.title),a))),s=i["if"].call(e,(n=e&&e.event,null==n||n===!1?n:n.description),{hash:{},inverse:q.noop,fn:q.program(36,I,t),data:t}),(s||0===s)&&(r+=s),r+="\n    "
}function I(e,t){var n,s,a="";return a+=": ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.description),s):H.call(e,"t",(n=e&&e.event,null==n||n===!1?n:n.description),s)))}function T(e,t){var n,s,a;return a={hash:{},inverse:q.program(41,D,t),fn:q.program(39,M,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"timeline",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"timeline",a),s||0===s?s:""}function M(e,t){var n,s,a="";
return a+="\n    ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.stateString),s):H.call(e,"t",(n=e&&e.event,null==n||n===!1?n:n.stateString),s)))+'\n    <a href="#!/server/',s={hash:{},data:t},a+=W((n=i.encodeUrl||e&&e.encodeUrl,n?n.call(e,e&&e.serverID,s):H.call(e,"encodeUrl",e&&e.serverID,s)))+"/details/",s={hash:{},data:t},a+=W((n=i.encodeUrl||e&&e.encodeUrl,n?n.call(e,e&&e.itemKey,s):H.call(e,"encodeUrl",e&&e.itemKey,s)))+'">'+W((n=e&&e.event,n=null==n||n===!1?n:n.mediaTitle,typeof n===$?n.apply(e):n))+"</a>\n    ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,"in",s):H.call(e,"t","in",s)))+'\n    <a href="#!/server/',s={hash:{},data:t},a+=W((n=i.encodeUrl||e&&e.encodeUrl,n?n.call(e,e&&e.serverID,s):H.call(e,"encodeUrl",e&&e.serverID,s)))+"/section/",s={hash:{},data:t},a+=W((n=i.encodeUrl||e&&e.encodeUrl,n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n.sectionID),s):H.call(e,"encodeUrl",(n=e&&e.event,null==n||n===!1?n:n.sectionID),s)))+'">'+W((n=e&&e.event,n=null==n||n===!1?n:n.sectionTitle,typeof n===$?n.apply(e):n))+"</a>\n  "
}function D(e,t){var n,s,a;return a={hash:{},inverse:q.program(44,L,t),fn:q.program(42,E,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"playing",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"playing",a),s||0===s?s:""}function E(e,t){var n,s,a="";return a+="\n    ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,"{1} started playing {2} on {3}.",(n=e&&e.event,null==n||n===!1?n:n.username),(n=e&&e.event,null==n||n===!1?n:n.title),(n=e&&e.event,null==n||n===!1?n:n.player),s):H.call(e,"t","{1} started playing {2} on {3}.",(n=e&&e.event,null==n||n===!1?n:n.username),(n=e&&e.event,null==n||n===!1?n:n.title),(n=e&&e.event,null==n||n===!1?n:n.player),s)))+"\n  "
}function L(e,t){var n,s,a;return a={hash:{},inverse:q.noop,fn:q.program(45,R,t),data:t},n=i.if_eq||e&&e.if_eq,s=n?n.call(e,(n=e&&e.event,null==n||n===!1?n:n._type),"websocket",a):H.call(e,"if_eq",(n=e&&e.event,null==n||n===!1?n:n._type),"websocket",a),s||0===s?s:""}function R(e,t){var n,s,a="";return a+="\n    ",s=i["if"].call(e,(n=e&&e.event,null==n||n===!1?n:n.opened),{hash:{},inverse:q.program(48,N,t),fn:q.program(46,O,t),data:t}),(s||0===s)&&(a+=s),a+="\n  "}function O(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,"Opened connection to {1}, listening for events.",e&&e.serverName,s):H.call(e,"t","Opened connection to {1}, listening for events.",e&&e.serverName,s)))+"\n    "
}function N(e,t){var n,s;return s=i["if"].call(e,(n=e&&e.event,null==n||n===!1?n:n.closed),{hash:{},inverse:q.program(51,B,t),fn:q.program(49,F,t),data:t}),s||0===s?s:""}function F(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,"Connection to {1} closed.",e&&e.serverName,s):H.call(e,"t","Connection to {1} closed.",e&&e.serverName,s)))+"\n    "}function B(e,t){var n,s,a="";return a+="\n      ",s={hash:{},data:t},a+=W((n=i.t||e&&e.t,n?n.call(e,"Unable to listen for events on {1}.",e&&e.serverName,s):H.call(e,"t","Unable to listen for events on {1}.",e&&e.serverName,s)))+"\n    "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var U,V,z,j="",q=this,H=i.helperMissing,W=this.escapeExpression,$="function";return j+='<div class="striped-list-inner-item alert-list-inner-item">\n  ',z={hash:{},inverse:q.program(3,r,s),fn:q.program(1,a,s),data:s},U=i.if_eq||t&&t.if_eq,V=U?U.call(t,(U=t&&t.event,null==U||U===!1?U:U._type),"setting",z):H.call(t,"if_eq",(U=t&&t.event,null==U||U===!1?U:U._type),"setting",z),(V||0===V)&&(j+=V),j+='\n\n  <div class="server-alert-details">\n  <span class="server-alert-time">',z={hash:{},data:s},j+=W((U=i.formatDate||t&&t.formatDate,U?U.call(t,(U=t&&t.event,null==U||U===!1?U:U.time),"LT",z):H.call(t,"formatDate",(U=t&&t.event,null==U||U===!1?U:U.time),"LT",z)))+"</span>\n  ",z={hash:{},inverse:q.program(31,C,s),fn:q.program(29,S,s),data:s},U=i.if_eq||t&&t.if_eq,V=U?U.call(t,(U=t&&t.event,null==U||U===!1?U:U._type),"setting",z):H.call(t,"if_eq",(U=t&&t.event,null==U||U===!1?U:U._type),"setting",z),(V||0===V)&&(j+=V),j+="\n  </div>\n</div>\n"
})}),define("plex/desktop/views/lists/activity/AlertListItem",["hb!templates/desktop/lists/activity/AlertListItem.tpl","marionette","plex/base/utils/t"],function(e,t,i){"use strict";var n=t.ItemView.extend({tagName:"li",className:"card-collapsed striped-list-item alert-list-item",template:e,serializeData:function(){var e={serverID:this.model.server.id,serverName:this.model.server.get("friendlyName"),itemKey:"/library/metadata/"+this.model.get("itemID"),event:this.model.toJSON()};if("timeline"==this.model.get("_type"))switch(e.event.sectionTitle=this.model.get("section")?this.model.get("section").get("title"):"section "+this.model.get("sectionID"),e.event.mediaTitle=this.model.get("title")||"an item",this.model.get("state")){case 0:e.event.stateString=i("Created");
break;case 1:e.event.stateString=i("Progress for");break;case 2:e.event.stateString=i("Matching");break;case 3:e.event.stateString=i("Downloading metadata for");break;case 4:e.event.stateString=i("Loading metadata for");break;case 5:e.event.stateString=i("Finished processing");break;case 6:e.event.stateString=i("Analyzing");break;case 9:e.event.stateString=i("Deleted")}return e}});return n}),define("plex/desktop/views/lists/activity/AlertList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/activity/AlertListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"list card-list alert-list",itemView:t,reversed:!0});return i}),define("plex/desktop/views/activity/AlertsView",["hb!templates/desktop/activity/AlertsView.tpl","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/dropdowns/PrimaryServerDropdown","plex/desktop/views/lists/activity/AlertList"],function(e,t,i,n,s,a,r){"use strict";var o=t.Layout.extend({className:"alerts-container",template:e,ui:{pageCount:".page-count",previousBtn:".previous-btn",nextBtn:".next-btn"},regions:{serverDropdown:".filter-bar",list:".alert-list-container"},modelEvents:{"change:shared":"onSharedChange"},collectionEvents:{add:"onAlertAdd"},events:{"click .previous-btn":"onPreviousClick","click .next-btn":"onNextClick"},onlyAfterRender:["onAlertAdd"],initialize:function(){this.shared=this.model.get("shared"),this.page=1,this.listCollection=this.collection.clone(this.collection.page(this.page,{reverse:!0})),this.listCollection.stopListening(),s.set("primaryServer",this.model),this.listenTo(s,"change:primaryServer",this.onPrimaryServerChange)
},serializeData:function(){var e=this.collection.pages();return{shared:this.shared,page:this.page,pages:e,enablePrevious:this.page>1,enableNext:this.page<e}},updatePages:function(){var e=this.collection.pages();this.ui.pageCount.text(i("{1} of {2}",this.page,e)),this.ui.previousBtn.toggleClass("disabled",this.page<2),this.ui.nextBtn.toggleClass("disabled",this.page>=e)},updateList:function(){this.listCollection.reset(this.collection.page(this.page,{reverse:!0}))},onRender:function(){this.serverDropdown.append(new a),this.shared||this.list.append(new r({collection:this.listCollection}))
},onPrimaryServerChange:function(e,t){t&&n.trigger("navigate","alerts",{serverID:t.id})},onSharedChange:function(e,t){this.shared=t,this.render()},onAlertAdd:function(){this.shared||(this.updatePages(),this.updateList())},onPreviousClick:function(e){e.preventDefault(),this.ui.previousBtn.isDisabled()||(this.page--,this.updatePages(),this.updateList())},onNextClick:function(e){e.preventDefault(),this.ui.nextBtn.isDisabled()||(this.page++,this.updatePages(),this.updateList())}});return o}),define("hb!templates/desktop/activity/SyncView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";
return s+='\n    <div class="filter-bar-right">\n      ',n=i["if"].call(e,e&&e.hasTouchScreen,{hash:{},inverse:w.noop,fn:w.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+='\n      <a class="refresh-btn btn-gray" href="#"><i class="glyphicon repeat"></i></a>\n    </div>\n  '}function r(){return'<a class="edit-btn btn-gray" href="#"><i class="glyphicon pencil"></i></a>'}function o(e,t){var n,s,a="";return a+='\n  <div class="row row-padded">\n    <div class="col-md-8 col-md-offset-2">\n      <h4 class="text-muted text-center">',s={hash:{},data:t},a+=k((n=i.t||e&&e.t,n?n.call(e,"Sync is restricted from shared users.",s):x.call(e,"t","Sync is restricted from shared users.",s)))+"</h4>\n    </div>\n  </div>\n"
}function l(e,t){var n,s="";return s+="\n  ",n=i["if"].call(e,e&&e.hasPlexPass,{hash:{},inverse:w.program(20,v,t),fn:w.program(7,c,t),data:t}),(n||0===n)&&(s+=n),s+="\n"}function c(e,t){var n,s="";return s+="\n    ",n=i["if"].call(e,e&&e.devices,{hash:{},inverse:w.program(18,g,t),fn:w.program(8,d,t),data:t}),(n||0===n)&&(s+=n),s+="\n  "}function d(e,t){var n,s="";return s+='\n      <div class="row">\n        <div class="col-sm-4 col-md-3">\n          <ul class="nav nav-cards">\n            ',n=i.each.call(e,e&&e.devices,{hash:{},inverse:w.noop,fn:w.programWithDepth(9,u,t,e),data:t}),(n||0===n)&&(s+=n),s+='\n          </ul>\n        </div>\n\n        <div class="sync-device-container col-sm-8 col-md-9"></div>\n      </div>\n    '
}function u(e,t,n){var s,a,r,o="";return o+='\n              <li>\n                <a class="card btn-gray ',r={hash:{},inverse:w.noop,fn:w.program(10,h,t),data:t},s=i.if_eq||n&&n.if_eq,a=s?s.call(e,(s=n&&n.selectedDevice,null==s||s===!1?s:s.id),e&&e.id,r):x.call(e,"if_eq",(s=n&&n.selectedDevice,null==s||s===!1?s:s.id),e&&e.id,r),(a||0===a)&&(o+=a),o+='" data-id="',(a=i.id)?a=a.call(e,{hash:{},data:t}):(a=e&&e.id,a=typeof a===S?a.call(e,{hash:{},data:t}):a),o+=k(a)+'" href="#">\n                  ',a=i["if"].call(e,e&&e.name,{hash:{},inverse:w.program(14,m,t),fn:w.program(12,p,t),data:t}),(a||0===a)&&(o+=a),o+=" ",a=i["if"].call(e,e&&e.isCloudSync,{hash:{},inverse:w.noop,fn:w.program(16,f,t),data:t}),(a||0===a)&&(o+=a),o+="\n                </a>\n              </li>\n            "
}function h(){return"selected"}function p(e,t){var n;return(n=i.name)?n=n.call(e,{hash:{},data:t}):(n=e&&e.name,n=typeof n===S?n.call(e,{hash:{},data:t}):n),k(n)}function m(e,t){var n;return(n=i.device)?n=n.call(e,{hash:{},data:t}):(n=e&&e.device,n=typeof n===S?n.call(e,{hash:{},data:t}):n),k(n)}function f(){return'<i class="cloud-sync-icon glyphicon cloud"></i><button class="cloud-sync-settings-btn btn-link btn-gray"><i class="glyphicon cogwheel"></i></button>'}function g(e,t){var n,s,a="";return a+='\n      <div class="row row-padded">\n        <h4 class="text-muted text-center">',s={hash:{},data:t},a+=k((n=i.t||e&&e.t,n?n.call(e,"You have no sync capable devices.",s):x.call(e,"t","You have no sync capable devices.",s)))+"</h4>\n      </div>\n    "
}function v(e,t){var n,s,a,r="";return r+='\n    <div class="row row-padded">\n      <h4 class="text-muted text-center">',a={hash:{},data:t},r+=k((n=i.t||e&&e.t,n?n.call(e,"You need a Plex Pass to use sync.",a):x.call(e,"t","You need a Plex Pass to use sync.",a)))+'</h4>\n\n      <p class="text-center">\n        <a class="btn btn-sm btn-primary" href="',(s=i.plexPassUrl)?s=s.call(e,{hash:{},data:t}):(s=e&&e.plexPassUrl,s=typeof s===S?s.call(e,{hash:{},data:t}):s),r+=k(s)+'" target="_blank">',a={hash:{},data:t},r+=k((n=i.t||e&&e.t,n?n.call(e,"Learn More",a):x.call(e,"t","Learn More",a)))+"</a>\n      </p>\n    </div>\n  "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var y,b="",w=this,x=i.helperMissing,k=this.escapeExpression,S="function";return b+='<div class="filter-bar">\n  ',y=i.unless.call(t,t&&t.shared,{hash:{},inverse:w.noop,fn:w.program(1,a,s),data:s}),(y||0===y)&&(b+=y),b+="\n</div>\n\n",y=i["if"].call(t,t&&t.shared,{hash:{},inverse:w.program(6,l,s),fn:w.program(4,o,s),data:s}),(y||0===y)&&(b+=y),b+="\n"})}),define("hb!templates/desktop/activity/SyncDeviceView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+='<div class="row row-loading">\n  <div class="loading loading-inline"></div>\n</div>\n\n<div class="sync-empty-message row row-padded hidden">\n  <h4 class="text-muted text-center">\n    ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Nothing is synced to this device.",r):l.call(t,"t","Nothing is synced to this device.",r)))+'\n  </h4>\n</div>\n\n<div class="sync-item-list-container"></div>\n'})}),define("hb!templates/desktop/lists/activity/SyncItemTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"cloud-download"
}function r(){return"circle-arrow-down"}function o(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var l,c="",d=this;return c+='<a class="media-poster-container" href="#">\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n\n    <div class="sync-status">\n      <div class="sync-status-transcode hidden"></div>\n\n      <i class="sync-status-icon sync-complete-icon glyphicon ok-2 hidden"></i>\n      <i class="sync-status-icon sync-waiting-icon glyphicon ',l=i["if"].call(t,t&&t.isCloudSync,{hash:{},inverse:d.program(3,r,s),fn:d.program(1,a,s),data:s}),(l||0===l)&&(c+=l),c+=' hidden"></i>\n      <i class="sync-status-icon sync-processing-icon glyphicon more hidden"></i>\n      <i class="sync-status-icon sync-failed-icon glyphicon warning-sign ',l=i.unless.call(t,t&&t.isFailure,{hash:{},inverse:d.noop,fn:d.program(5,o,s),data:s}),(l||0===l)&&(c+=l),c+='"></i>\n      <i class="sync-status-icon sync-unknown-icon glyphicon circle-question-mark ',l=i["if"].call(t,t&&t.isFailure,{hash:{},inverse:d.noop,fn:d.program(5,o,s),data:s}),(l||0===l)&&(c+=l),c+='"></i>\n    </div>\n\n    <div class="media-poster-actions">\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="delete-btn media-poster-btn btn-link btn-danger" tabindex="-1"><i class="glyphicon remove-2"></i></button>\n    </div>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n  <div class="media-context media-heading secondary"></div>\n</a>\n'
})}),define("plex/base/models/library/SyncMetadataCollection",["underscore","plex/base/models/library/MetadataCollection","plex/base/models/library/SyncMetadataModel"],function(e,t,i){"use strict";var n=t.extend({model:i,url:function(){return"/sync/items/"+this.syncItemId},initialize:function(e,t){this.syncItemId=t.syncItemId},parse:function(){var i=t.prototype.parse.apply(this,arguments);return e.each(i,e.bind(function(e){e.syncItemId=this.syncItemId},this)),i}});return n}),define("hb!templates/desktop/modals/SyncStatusModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e){var t,i="";
return i+='\n        <p class="text-muted"><i class="glyphicon warning-sign"></i> '+u((t=e&&e.Status,t=null==t||t===!1?t:t.failure,typeof t===d?t.apply(e):t))+"</p>\n      "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon download"></i> ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Sync Status",l):h.call(t,"t","Sync Status",l)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <h4 class="sync-item-title">',(o=i.rootTitle)?o=o.call(t,{hash:{},data:s}):(o=t&&t.rootTitle,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+" &middot; ",(o=i.title)?o=o.call(t,{hash:{},data:s}):(o=t&&t.title,o=typeof o===d?o.call(t,{hash:{},data:s}):o),c+=u(o)+"</h3>\n\n      ",o=i["if"].call(t,(r=t&&t.Status,null==r||r===!1?r:r.failure),{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='\n\n      <div class="sync-status-list-container"></div>\n    </div>\n  </div>\n</div>\n'
})}),define("hb!templates/desktop/lists/activity/SyncStatusListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a="";return a+='\n    <i class="glyphicon cloud-download"></i> ',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Waiting to be uploaded",s):u.call(e,"t","Waiting to be uploaded",s)))+"\n  "}function r(e,t){var n,s,a="";return a+='\n    <i class="glyphicon circle-arrow-down"></i> ',s={hash:{},data:t},a+=h((n=i.t||e&&e.t,n?n.call(e,"Waiting to be downloaded",s):u.call(e,"t","Waiting to be downloaded",s)))+"\n  "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u=i.helperMissing,h=this.escapeExpression,p=this;return d+='<div class="media-poster"></div>\n\n<p class="title"></p>\n\n<p class="complete-subtitle subtitle hidden">\n  <i class="glyphicon ok-2"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Synced",c):u.call(t,"t","Synced",c)))+'\n</p>\n\n<p class="waiting-subtitle subtitle hidden">\n  ',l=i["if"].call(t,t&&t.isCloudSync,{hash:{},inverse:p.program(3,r,s),fn:p.program(1,a,s),data:s}),(l||0===l)&&(d+=l),d+='\n</p>\n\n<p class="downloading-subtitle subtitle hidden">\n  <i class="glyphicon more"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Downloading",c):u.call(t,"t","Downloading",c)))+' &middot; <span class="transcode-progress"></span>%\n</p>\n\n<p class="converting-subtitle subtitle hidden">\n  <i class="glyphicon more"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Converting",c):u.call(t,"t","Converting",c)))+' &middot; <span class="transcode-progress"></span>% &middot; <span class="transcode-remaining"></span>\n</p>\n\n<p class="processing-subtitle subtitle hidden">\n  <i class="glyphicon more"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Waiting to be converted",c):u.call(t,"t","Waiting to be converted",c)))+'\n</p>\n\n<p class="unknown-subtitle subtitle hidden">\n  <i class="glyphicon circle-question-mark"></i> ',c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,"Unknown",c):u.call(t,"t","Unknown",c)))+'\n</p>\n\n<p class="failed-subtitle subtitle hidden">\n  <i class="glyphicon warning-sign"></i> <span class="error-message"></span>\n</p>\n'
})}),define("plex/desktop/views/lists/activity/SyncStatusListItem",["hb!templates/desktop/lists/activity/SyncStatusListItem.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/syncUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s,a,r){"use strict";var o=i.ItemView.extend({tagName:"li",className:"sync-status-list-item",template:e,ui:{poster:".media-poster"},initialize:function(e){this.syncItem=e.syncItem,this.transcodeJobs=this.model.server.get("transcodeJobs"),this.$el.addClass(this.model.get("type")),this.image=new r({model:this.model,type:this.model.get("type"),getUrl:this.getPosterUrl,height:50,background:!1}),this.listenTo(this.transcodeJobs,"reset",function(){this.model.trigger("change:Media",this.model,this.model.get("Media"))
})},serializeData:function(){return{isCloudSync:this.model.device.get("isCloudSync")}},getPosterUrl:function(e){return e||this.model.get("parentThumb")||this.model.get("grandparentThumb")},analyzeTranscodeJobs:function(){var e;if(this.transcodeJobs.each(t.bind(function(t){if(this.syncItem.id===t.get("syncItemId")){var i=this.model.get("thumb"),n=this.model.get("title"),s=t.get("transcodeThumb"),a=t.get("title"),r=a&&a.indexOf(n)>-1,o=!0;if(i&&s){var l=new RegExp("(.+)"+t.get("thumb")+"$");o=l.exec(i)
}r&&o&&(e=t)}},this)),e&&e.get("progress")>0){var i=Math.round(10*e.get("speed"))/10,n=a.formatMinutesRemaining(e.get("remaining")),s=Math.round(10*e.get("progress"))/10;return{active:!0,speed:i,remaining:n,progress:s}}return{active:!1}},analyzeParts:function(){var e="complete",t=this.model.get("Media");if(!t.length)return"unknown";for(var i=0,n=t.length;n>i;i++)for(var a=t[i].Part,r=0,o=a.length;o>r;r++){var l=a[r],c=s.getSyncStateFromPart(l);s.failedRegex.test(c)&&(e=s.getSyncStateContextFromPart(l)),s.processingRegex.test(c)&&(e="downloading"===c?"downloading":"processing"),s.waitingRegex.test(c)&&"processing"!==e&&(e=l.key?"waiting":"processing")
}return e},getErrorMessage:function(e){switch(e){case"sourceFileUnavailable":return n("This media is inaccessible. Please check that the file exists with the correct permissions.");case"sourceFileMetadataError":return n("The metadata for this media is invalid. Please reanalyze the media and try again.");case"clientProfileError":return n("The client profile for the sync target is invalid.");case"ioError":return n("An error occurred processing this media. Please check that the disk is not full.");case"transcoderError":return n("The transcoder was unable to process this media.");
case"mediaAnalysisError":return n("This media was unable to be analyzed.");case"downloadFailed":return n("This media was unable to be downloaded. Please check that it is still available and try again.");case"unknownError":return n("An error occurred while syncing this media.")}return n("An error occurred while syncing this media.")},bindings:{".title":{modelAttribute:"title"},".subtitle":{modelAttribute:"Media",manual:!0,formatter:function(){var e=this.analyzeParts(),t=this.analyzeTranscodeJobs();
switch(this.$(".subtitle").addClass("hidden"),e){case"complete":this.$(".complete-subtitle").removeClass("hidden");break;case"waiting":this.$(".waiting-subtitle").removeClass("hidden");break;case"downloading":t.active?(this.$(".downloading-subtitle").removeClass("hidden"),this.$(".transcode-progress").text(t.progress)):this.$(".processing-subtitle").removeClass("hidden");break;case"processing":t.active?(this.$(".converting-subtitle").removeClass("hidden"),this.$(".transcode-progress").text(t.progress),this.$(".transcode-remaining").text(t.remaining)):this.$(".processing-subtitle").removeClass("hidden");
break;case"unknown":this.$(".unknown-subtitle").removeClass("hidden");break;default:this.$(".failed-subtitle").removeClass("hidden"),this.$(".error-message").text(this.getErrorMessage(e))}}}},onRender:function(){this.image.setElement(this.ui.poster)}});return o}),define("plex/desktop/views/lists/activity/SyncStatusList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/activity/SyncStatusListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list sync-status-list",itemView:t});
return i}),define("plex/desktop/views/modals/SyncStatusModal",["hb!templates/desktop/modals/SyncStatusModal.tpl","plex/desktop/views/modals/BaseModal","plex/desktop/views/lists/activity/SyncStatusList"],function(e,t,i){"use strict";var n=t.extend({name:"syncStatusModal",template:e,regions:{list:".sync-status-list-container"},onRender:function(){t.prototype.onRender.apply(this,arguments),this.list.show(new i({collection:this.collection,itemViewOptions:{syncItem:this.model}}))}});return n}),define("hb!templates/desktop/modals/SyncModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hidden"
}function r(){return"selected"}function o(e,t){var n,s,a="";return a+='\n            <p class="help-block">',s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"Some cloud storage providers limit file size or upload time, If you have trouble, try reducing your quality setting. Cloud Sync content will not be available until all items are converted and uploaded.",s):b.call(e,"t","Some cloud storage providers limit file size or upload time, If you have trouble, try reducing your quality setting. Cloud Sync content will not be available until all items are converted and uploaded.",s)))+"</p>\n          "
}function l(){return"checked"}function c(e,t){var n,s="";return s+='value="',(n=i.limitValue)?n=n.call(e,{hash:{},data:t}):(n=e&&e.limitValue,n=typeof n===x?n.call(e,{hash:{},data:t}):n),s+=w(n)+'"'}function d(e,t){var n,s,a="";return a+="\n              ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"A large number of sync items may be time-consuming to convert, and the time to upload is dependent on your bandwidth. A large number of high quality items may take a very long time. If you have trouble, try reducing the number of items or your quality setting.",s):b.call(e,"t","A large number of sync items may be time-consuming to convert, and the time to upload is dependent on your bandwidth. A large number of high quality items may take a very long time. If you have trouble, try reducing the number of items or your quality setting.",s)))+"\n            "
}function u(e,t){var n,s,a="";return a+="\n              ",s={hash:{},data:t},a+=w((n=i.t||e&&e.t,n?n.call(e,"A large number of sync items may be time-consuming to convert and transfer to your device. If you have trouble, try reducing the number of items.",s):b.call(e,"t","A large number of sync items may be time-consuming to convert and transfer to your device. If you have trouble, try reducing the number of items.",s)))+"\n            "}function h(e,t){var n,s,r,o="";return o+='\n          <p class="duration-warning help-block ',r={hash:{},inverse:k.noop,fn:k.program(1,a,t),data:t},n=i.if_neq||e&&e.if_neq,s=n?n.call(e,e&&e.selectedLimit,"duration",r):b.call(e,"if_neq",e&&e.selectedLimit,"duration",r),(s||0===s)&&(o+=s),o+='">\n            <i class="limit-warning-icon glyphicon circle-exclamation-mark"></i>\n\n            <span class="limit-warning-text">\n              ',r={hash:{},data:t},o+=w((n=i.t||e&&e.t,n?n.call(e,"This device will not support limiting by duration in a future update.",r):b.call(e,"t","This device will not support limiting by duration in a future update.",r)))+"\n            </span>\n          </p>\n        "
}function p(e,t){var n,s;return s={hash:{},data:t},w((n=i.t||e&&e.t,n?n.call(e,"Sync",s):b.call(e,"t","Sync",s)))}function m(e,t){var n,s;return s={hash:{},data:t},w((n=i.t||e&&e.t,n?n.call(e,"Save",s):b.call(e,"t","Save",s)))}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var f,g,v,y="",b=i.helperMissing,w=this.escapeExpression,x="function",k=this;return y+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon download"></i> ',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Sync",v):b.call(t,"t","Sync",v)))+'</h4>\n    </div>\n\n    <form id="sync-form" class="settings-container">\n      <div class="modal-body">\n        <div class="form-group ',g=i.unless.call(t,t&&t.isSection,{hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s}),(g||0===g)&&(y+=g),y+='">\n          <label class="control-label" for="sync-title">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Title",v):b.call(t,"t","Title",v)))+'</label>\n          <input type="text" id="sync-title" name="title" class="form-control" value="',(g=i.title)?g=g.call(t,{hash:{},data:s}):(g=t&&t.title,g=typeof g===x?g.call(t,{hash:{},data:s}):g),y+=w(g)+'" placeholder="',(g=i.title)?g=g.call(t,{hash:{},data:s}):(g=t&&t.title,g=typeof g===x?g.call(t,{hash:{},data:s}):g),y+=w(g)+'">\n        </div>\n\n        <div class="form-group">\n          <label class="control-label" for="sync-quality">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Quality",v):b.call(t,"t","Quality",v)))+'</label>\n          <select id="sync-quality" name="quality">\n            <option value="low" ',v={hash:{},inverse:k.noop,fn:k.program(3,r,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedQuality,"low",v):b.call(t,"if_eq",t&&t.selectedQuality,"low",v),(g||0===g)&&(y+=g),y+=">",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Low",v):b.call(t,"t","Low",v)))+'</option>\n            <option value="medium" ',v={hash:{},inverse:k.noop,fn:k.program(3,r,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedQuality,"medium",v):b.call(t,"if_eq",t&&t.selectedQuality,"medium",v),(g||0===g)&&(y+=g),y+=">",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Medium",v):b.call(t,"t","Medium",v)))+'</option>\n            <option value="high" ',v={hash:{},inverse:k.noop,fn:k.program(3,r,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedQuality,"high",v):b.call(t,"if_eq",t&&t.selectedQuality,"high",v),(g||0===g)&&(y+=g),y+=">",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"High",v):b.call(t,"t","High",v)))+'</option>\n            <option value="highest" ',v={hash:{},inverse:k.noop,fn:k.program(3,r,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedQuality,"highest",v):b.call(t,"if_eq",t&&t.selectedQuality,"highest",v),(g||0===g)&&(y+=g),y+=">",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Highest",v):b.call(t,"t","Highest",v)))+"</option>\n          </select>\n\n          ",g=i["if"].call(t,t&&t.isCloudSyncDevice,{hash:{},inverse:k.noop,fn:k.program(5,o,s),data:s}),(g||0===g)&&(y+=g),y+='\n        </div>\n\n        <div class="form-group ',v={hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s},f=i.if_neq||t&&t.if_neq,g=f?f.call(t,t&&t.childElement,"video",v):b.call(t,"if_neq",t&&t.childElement,"video",v),(g||0===g)&&(y+=g),y+=" ",g=i.unless.call(t,t&&t.isDirectory,{hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s}),(g||0===g)&&(y+=g),y+='">\n          <label class="control-label">\n            <input type="checkbox" id="sync-unwatched" name="unwatched" ',g=i["if"].call(t,t&&t.unwatched,{hash:{},inverse:k.noop,fn:k.program(7,l,s),data:s}),(g||0===g)&&(y+=g),y+="> ",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Unwatched",v):b.call(t,"t","Unwatched",v)))+'\n          </label>\n        </div>\n\n        <div class="form-group ',g=i.unless.call(t,t&&t.isDirectory,{hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s}),(g||0===g)&&(y+=g),y+='">\n          <label class="limit-label">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Limit",v):b.call(t,"t","Limit",v)))+'</label>\n          <label class="radio-inline" for="sync-limit-items"><input type="radio" id="sync-limit-items" name="limit" value="count" ',v={hash:{},inverse:k.noop,fn:k.program(7,l,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedLimit,"count",v):b.call(t,"if_eq",t&&t.selectedLimit,"count",v),(g||0===g)&&(y+=g),y+="> ",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"By number of items",v):b.call(t,"t","By number of items",v)))+'</label>\n          <label class="radio-inline ',g=i.unless.call(t,t&&t.showDurationLimit,{hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s}),(g||0===g)&&(y+=g),y+='" for="sync-limit-duration"><input type="radio" id="sync-limit-duration" name="limit" value="duration" ',v={hash:{},inverse:k.noop,fn:k.program(7,l,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedLimit,"duration",v):b.call(t,"if_eq",t&&t.selectedLimit,"duration",v),(g||0===g)&&(y+=g),y+="> ",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"By duration",v):b.call(t,"t","By duration",v)))+'</label>\n          <label class="radio-inline" for="sync-limit-none"><input type="radio" id="sync-limit-none" name="limit" value="all" ',v={hash:{},inverse:k.noop,fn:k.program(7,l,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedLimit,"all",v):b.call(t,"if_eq",t&&t.selectedLimit,"all",v),(g||0===g)&&(y+=g),y+="> ",v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"None",v):b.call(t,"t","None",v)))+'</label>\n        </div>\n\n        <div class="limit-value-group form-group ',v={hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s},f=i.if_eq||t&&t.if_eq,g=f?f.call(t,t&&t.selectedLimit,"all",v):b.call(t,"if_eq",t&&t.selectedLimit,"all",v),(g||0===g)&&(y+=g),y+='">\n          <input type="text" id="sync-limit-value" name="limitValue" class="limit-value-control form-control" ',g=i["if"].call(t,t&&t.limitValue,{hash:{},inverse:k.noop,fn:k.program(9,c,s),data:s}),(g||0===g)&&(y+=g),y+='>\n          <label class="limit-items-label limit-value-label ',v={hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s},f=i.if_neq||t&&t.if_neq,g=f?f.call(t,t&&t.selectedLimit,"count",v):b.call(t,"if_neq",t&&t.selectedLimit,"count",v),(g||0===g)&&(y+=g),y+='" for="sync-limit-value">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"items",v):b.call(t,"t","items",v)))+'</label>\n          <label class="limit-duration-label limit-value-label ',v={hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s},f=i.if_neq||t&&t.if_neq,g=f?f.call(t,t&&t.selectedLimit,"duration",v):b.call(t,"if_neq",t&&t.selectedLimit,"duration",v),(g||0===g)&&(y+=g),y+='" for="sync-limit-value">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"minutes",v):b.call(t,"t","minutes",v)))+'</label>\n        </div>\n\n        <p class="limit-warning help-block ',g=i.unless.call(t,t&&t.showLimitWarning,{hash:{},inverse:k.noop,fn:k.program(1,a,s),data:s}),(g||0===g)&&(y+=g),y+='">\n          <i class="limit-warning-icon glyphicon circle-exclamation-mark"></i>\n\n          <span class="limit-warning-text">\n            ',g=i["if"].call(t,t&&t.isCloudSyncDevice,{hash:{},inverse:k.program(13,u,s),fn:k.program(11,d,s),data:s}),(g||0===g)&&(y+=g),y+="\n          </span>\n        </p>\n\n        ",g=i["if"].call(t,t&&t.showDurationLimit,{hash:{},inverse:k.noop,fn:k.program(15,h,s),data:s}),(g||0===g)&&(y+=g),y+='\n      </div>\n\n      <div class="modal-footer">\n        <button type="button" class="btn btn-default" data-dismiss="modal">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Cancel",v):b.call(t,"t","Cancel",v)))+'</button>\n        <button type="submit" class="submit-btn btn btn-primary btn-loading">\n          <div class="loading loading-sm"></div>\n          <span class="btn-label">',g=i["if"].call(t,t&&t.isNew,{hash:{},inverse:k.program(19,m,s),fn:k.program(17,p,s),data:s}),(g||0===g)&&(y+=g),y+='</span>\n        </button>\n      </div>\n    </form>\n\n    <div class="sync-success-container row">\n      <div class="col-sm-3 text-center">\n        <p class="sync-success-icon"><i class="glyphicon ok-2"></i></p>\n      </div>\n\n      <div class="col-sm-8">\n        <h4>',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"This media is being synced to your device.",v):b.call(t,"t","This media is being synced to your device.",v)))+'</h4>\n        <h4 class="text-muted">',v={hash:{},data:s},y+=w((f=i.t||t&&t.t,f?f.call(t,"Watch the status of the sync {1}here{2}.","<a class='sync-status-btn' href='#'>","</a>",v):b.call(t,"t","Watch the status of the sync {1}here{2}.","<a class='sync-status-btn' href='#'>","</a>",v)))+"</h4>\n      </div>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/SyncModal",["hb!templates/desktop/modals/SyncModal.tpl","underscore","jquery","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/utils/types/mediaTypes","plex/base/utils/types/syncQualities","plex/base/adapters/settingsAdapter","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/modals/BaseModal"],function(e,t,i,n,s,a,r,o,l,c,d){"use strict";var u=d.extend({name:"syncModal",className:"sync-modal modal fade",template:e,defaultCountLimits:{video:5,audio:50,photo:50},warningCountLimits:{video:10,audio:100,photo:100},defaultDurationLimit:60,warningDurationLimit:300,ui:{limitValueGroup:".limit-value-group",limitValueInput:"#sync-limit-value",limitValueLabel:".limit-value-label",limitItemsLabel:".limit-items-label",limitDurationLabel:".limit-duration-label",limitWarning:".limit-warning",durationWarning:".duration-warning",submitBtn:".submit-btn"},events:t.extend({"change input[name=limit]":"onLimitChange","keyup input[name=limitValue]":"onLimitValueChange","change input[name=limitValue]":"onLimitValueChange","submit #sync-form":"onSubmit","click .sync-status-btn":"onSyncStatusClick"},d.prototype.events),initialize:function(e){d.prototype.initialize.apply(this,arguments),this.isNew=e.isNew,this.device=this.model?this.model.device:e.device,e.isNew?(this.type=e.type,this.subset=e.subset,this.selectedItems=e.selectedItems,this.isSection=e.isSection,this.isDirectory=!(!e.isDirectory&&"directory"!==this.type.element),this.limit=this.isDirectory?"count":"all"):(this.type=a.getMediaTypeByString(this.model.get("metadataType")),this.isDirectory=this.model.get("isDirectory"),this.limit=this.model.get("Policy").scope),this.section=this.model.server.getSectionForItem(this.model),this.childMediaType=a.getChildMediaType(this.type.typeString)
},serializeData:function(){var e=this.childMediaType.element,t=this.device.get("SyncList"),i=t&&t.version<2,n={isCloudSyncDevice:this.device.get("isCloudSync"),title:this.isSection?this.section.getSyncTitle(this.selectedItems):this.model.get("title"),childElement:e,showDurationLimit:e!==s.elements.PHOTO&&i,isNew:this.isNew,isSection:this.isSection,isDirectory:this.isDirectory,selectedLimit:this.limit};if(this.isNew)"video"===e?n.selectedQuality=o.get("syncVideoQuality"):"audio"===e?n.selectedQuality=o.get("syncAudioQuality"):"photo"===e&&(n.selectedQuality=o.get("syncPictureQuality")),"count"===this.limit?n.limitValue=this.defaultCountLimits[e]:"duration"===this.limit&&(n.limitValue=this.defaultDurationLimit);
else{var a=this.model.get("MediaSettings"),l=this.model.get("Policy"),c=r.getQualityByVideoQuality(a.videoQuality);n.selectedQuality=c.key,n.unwatched=parseInt(l.unwatched,10),n.limitValue=l.value,"duration"===l.scope&&(n.limitValue/=60,n.showDurationLimit=!0)}return n.showLimitWarning=this.shouldShowLimitWarning(n.limitValue),n},shouldShowLimitWarning:function(e){e=parseInt(e,10);var t=this.childMediaType.element;return"duration"===this.limit?e>this.warningDurationLimit:"count"===this.limit?e>this.warningCountLimits[t]:"all"===this.limit?this.isDirectory:!1
},showLimitWarning:function(e){var t=this.shouldShowLimitWarning(e);return this.ui.limitWarning.toggleClass("hidden",!t),t},create:function(e){var i={isDirectory:this.isDirectory,subset:this.subset,selectedItems:this.selectedItems,device:this.device,settings:e,childMediaType:this.childMediaType};this.isSection?i.section=this.model:i.item=this.model;var n=l.execute("createSyncItem",i);n.done(t.bind(function(){this.isClosed||this.$el.addClass("show-sync-success")},this)),n.always(t.bind(function(){this.isClosed||this.ui.submitBtn.removeClass("active")
},this))},edit:function(e){var i={syncItem:this.model,settings:e},n=l.execute("editSyncItem",i);n.done(t.bind(this.hide,this)),n.fail(t.bind(function(){this.isClosed||this.ui.submitBtn.removeClass("active")},this))},onLimitChange:function(e){switch(this.limit=i(e.currentTarget).val(),this.ui.limitValueLabel.addClass("hidden"),this.ui.durationWarning.addClass("hidden"),this.limit){case"all":this.ui.limitValueGroup.addClass("hidden");break;case"count":var t=this.childMediaType.element;this.ui.limitValueGroup.removeClass("hidden"),this.ui.limitItemsLabel.removeClass("hidden"),this.ui.limitValueInput.val(this.defaultCountLimits[t]);
break;case"duration":this.ui.durationWarning.removeClass("hidden"),this.ui.limitValueGroup.removeClass("hidden"),this.ui.limitDurationLabel.removeClass("hidden"),this.ui.limitValueInput.val(this.defaultDurationLimit)}this.showLimitWarning(this.ui.limitValueInput.val())},onLimitValueChange:function(){this.showLimitWarning(this.ui.limitValueInput.val())},onSubmit:function(e){e.preventDefault();var t=this.ui.submitBtn;if(!t.hasClass("active")){t.addClass("active");var i=e.currentTarget,n={title:i.title.value,quality:i.quality.value,unwatched:i.unwatched.checked?1:0,scope:this.limit};
"all"!==this.limit&&(n.value=parseInt(i.limitValue.value,10),"duration"===this.limit&&(n.value*=60)),this.isNew?this.create(n):this.edit(n)}},onSyncStatusClick:function(e){e.preventDefault(),this.hide(),n.trigger("navigate","sync",{serverID:this.model.server.id,deviceID:this.device.id})}});return u}),define("plex/desktop/views/lists/activity/SyncItemTileListItem",["hb!templates/desktop/lists/activity/SyncItemTileListItem.tpl","underscore","backbone","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/syncUtil","plex/base/utils/formatters/dateTimeUtil","plex/base/commands/commands","plex/base/models/library/SyncMetadataCollection","plex/base/views/images/MediaPosterImage","plex/desktop/views/progressbar/CircleProgressBarView","plex/desktop/views/modals/SyncStatusModal","plex/desktop/views/modals/SyncModal","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m){"use strict";
var f=n.Layout.extend({tagName:"li",className:"poster-item media-tile-list-item sync-tile-list-item",template:e,metadataItemsDelay:5e3,ui:{poster:".media-poster",transcodeStatus:".sync-status-transcode",transcodeTimeRemaining:".media-context",statusIcons:".sync-status-icon",completeIcon:".sync-complete-icon",waitingIcon:".sync-waiting-icon",processingIcon:".sync-processing-icon",failedIcon:".sync-failed-icon",unknownIcon:".sync-unknown-icon"},regions:{transcodeProgress:".sync-status-transcode"},events:{"click a":"onClick","click .edit-btn":"onEditClick","click .delete-btn":"onDeleteClick"},onlyAfterRender:["onMetadataItemsReset","onMediaChange","onTranscodeJobsReset"],initialize:function(e){this.server=e.server,this.model.parent=this.server,this.type=this.model.get("metadataType"),this.$el.addClass(this.type);
var n=this.type,s=150;"episode"===n?n="show":("clip"===n||"userPlaylistItem"===n)&&(s=250),this.image=new d({server:this.server,type:n,width:s}),this.progressModel=new i.Model({current:0});var a=this.server.get("transcodeJobs");this.metadataItems=new c([],{server:this.server,device:this.model.device,syncItemId:this.model.id}),this.listenTo(this.metadataItems,"reset",this.onMetadataItemsReset),this.listenTo(a,"reset",this.onTranscodeJobsReset),this.metadataItems.fetch({reset:!0}),this.server.supports("syncNotifications")?this.listenTo(this.metadataItems,"change:Media",this.onMediaChange):this.metadataItemsInterval=setInterval(t.bind(function(){this.metadataItems.fetch({reset:!0})
},this),this.metadataItemsDelay)},serializeData:function(){return{syncItem:this.model.toJSON(),isCloudSync:this.model.device.get("isCloudSync"),isFailure:!!this.model.get("Status").failure}},getPosterUrl:function(e){var t=e.get("thumb");return this.hasMultipleItems?this.hasSameParents?e.get("parentThumb")||e.get("grandparentThumb")||t:this.hasSameGrandparents?e.get("grandparentThumb")||e.get("parentThumb")||t:void 0:t},updatePoster:function(e){if(this.hasPoster=!0,!e){var t=this.metadataItems.first();
if(!t)return;e=this.getPosterUrl(t)}this.image.url!==e&&(this.image.src=null,this.image.url=e,this.image.render())},analyzeParts:function(e){if(this.model.get("Status").failure)return"failed";var i=e.models,n=i.length;if(!n)return"unknown";for(var s="complete",a=[],o=[],l=0;n>l;l++){var c=i[l],d=c.get("Media");if(a.push(c.get("grandparentKey")),o.push(c.get("parentKey")),d.length||(s="unknown"),"failed"!==s&&"unknown"!==s)for(var u=0,h=d.length;h>u;u++)for(var p=d[u].Part,m=0,f=p.length;f>m;m++){var g=p[m],v=r.getSyncStateFromPart(g);
r.failedRegex.test(v)&&(s="failed"),r.processingRegex.test(v)&&(s="processing"),r.waitingRegex.test(v)&&"processing"!==s&&(s=g.key?"waiting":"processing")}}return this.hasMultipleItems=n>1,this.hasSameGrandparents=1===t.compact(t.uniq(a)).length,this.hasSameParents=1===t.compact(t.uniq(o)).length,this.hasPoster||this.updatePoster(),s},bindings:{".media-title":{modelAttribute:"title"},".media-subtitle-1":{modelAttribute:"rootTitle"}},onRender:function(){this.image.setElement(this.ui.poster),this.transcodeProgress.append(new u({model:this.progressModel}))
},onClose:function(){clearInterval(this.metadataItemsInterval)},onMetadataItemsReset:function(e){var t=this.analyzeParts(e);if(this.ui.statusIcons.addClass("hidden"),this.ui.transcodeStatus.hasClass("hidden"))switch(t){case"complete":this.ui.completeIcon.removeClass("hidden");break;case"waiting":this.ui.waitingIcon.removeClass("hidden");break;case"processing":this.ui.processingIcon.removeClass("hidden");break;case"failed":this.ui.failedIcon.removeClass("hidden");break;default:this.ui.unknownIcon.removeClass("hidden")
}},onMediaChange:function(){this.onMetadataItemsReset(this.metadataItems)},onTranscodeJobsReset:function(e){var t=e.where({syncItemId:this.model.id});if(!t.length)return this.ui.transcodeStatus.hasClass("hidden")||(this.ui.transcodeStatus.addClass("hidden"),this.ui.waitingIcon.removeClass("hidden")),this.ui.transcodeTimeRemaining.text(""),void this.updatePoster();var i=t[0];if(this.ui.statusIcons.addClass("hidden"),i.get("progress")>0){this.ui.transcodeStatus.removeClass("hidden");var n=i.get("type"),a=o.formatMinutesRemaining(i.get("remaining")),r=.01*i.get("progress");
if(this.progressModel.set("fraction",r),"download"===n)this.progressModel.set("text",i.get("progress").toString()+"%"),this.ui.transcodeTimeRemaining.text(s("Downloading"));else if("upload"===n)this.progressModel.set("text",i.get("progress").toString()+"%"),this.ui.transcodeTimeRemaining.text(s("Uploading"));else{var l=Math.round(10*i.get("speed"))/10;l>10&&(l=Math.round(l)),this.progressModel.set("text",l.toString()+"x"),this.ui.transcodeTimeRemaining.text(a)}this.updatePoster(i.get("thumb"))}else this.ui.transcodeStatus.addClass("hidden"),this.ui.processingIcon.removeClass("hidden")
},onClick:function(e){e.preventDefault(),a.trigger("show:modal",new h({model:this.model,collection:this.metadataItems}))},onEditClick:function(e){e.stopImmediatePropagation(),e.preventDefault(),a.trigger("show:modal",new p({model:this.model}))},onDeleteClick:function(e){e.stopImmediatePropagation(),e.preventDefault();var i=new m({title:s("Stop Syncing"),message:s("Are you sure you want to stop syncing this item? It will be removed from the device."),confirmLabel:s("Remove"),cancelLabel:s("Cancel"),async:!0,hasDanger:!0}),n=i.promise;
n.done(t.bind(function(){var e=this.model.destroy();e.done(t.bind(function(){l.execute("refreshSyncItems",{server:this.server,silent:!0,skipContent:!0})},this)),e.always(function(){i.hide()})},this)),a.trigger("show:modal",i)}});return f}),define("plex/desktop/views/lists/activity/SyncItemTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/activity/SyncItemTileListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"tile-list media-tile-list sync-tile-list show-context",itemView:t});
return i}),define("plex/desktop/views/activity/SyncDeviceView",["hb!templates/desktop/activity/SyncDeviceView.tpl","marionette","plex/base/models/user/SyncItemCollection","plex/desktop/views/lists/activity/SyncItemTileList"],function(e,t,i,n){"use strict";var s=t.Layout.extend({className:"sync-device-items-container",template:e,ui:{loading:".row-loading",empty:".sync-empty-message"},regions:{list:".sync-item-list-container"},onlyAfterRender:["onSyncItemsReset"],initialize:function(e){this.server=e.server,this.collection=new i([],{server:this.server,device:this.model});
var t=this.model.get("syncItems");this.listenTo(t,{reset:this.onSyncItemsReset}),this.listenTo(this.collection,{reset:this.onSyncItemsChange,remove:this.onSyncItemsChange}),t.fetch({reset:!0,scope:"page"})},onRender:function(){this.list.show(new n({collection:this.collection,itemViewOptions:{server:this.server}}))},onSyncItemsReset:function(e){this.ui.loading.addClass("hidden"),this.collection.reset(e.filterByServer(this.server.id).models)},onSyncItemsChange:function(){this.ui.empty.toggleClass("hidden",!!this.collection.length)
}});return s}),define("plex/desktop/views/activity/SyncView",["hb!templates/desktop/activity/SyncView.tpl","underscore","jquery","marionette","plex/base/utils/dispatcher","plex/base/utils/capabilities","plex/base/commands/commands","plex/base/models/appModel","plex/desktop/views/dropdowns/PrimaryServerDropdown","plex/desktop/views/activity/SyncDeviceView"],function(e,t,i,n,s,a,r,o,l,c){"use strict";var d=n.Layout.extend({className:"sync-container",template:e,transcodeJobDelay:2e3,ui:{devices:".nav a"},regions:{filterBar:".filter-bar",container:".sync-device-container"},modelEvents:{"change:shared":"onSharedChange"},events:{"click .nav a":"onDeviceClick","click .edit-btn":"onEditClick","click .refresh-btn":"onRefreshClick","click .cloud-sync-settings-btn":"onCloudSyncSettingsClick"},initialize:function(e){this.selectedDevice=e.selectedDevice,this.user=o.get("user"),this.shared=this.model.get("shared"),this.transcodeJobs=this.model.get("transcodeJobs"),o.set("primaryServer",this.model),this.listenTo(o,"change:primaryServer",this.onPrimaryServerChange),this.collection.length&&!this.shared&&(this.selectedDevice||(this.selectedDevice=this.collection.first()),this.fetchTranscodeJobs())
},serializeData:function(){return{shared:this.shared,hasTouchScreen:a.hasTouchScreen,hasPlexPass:this.user.hasPlexPass(),plexPassUrl:this.user.server.get("plexPassUrl"),selectedDevice:this.selectedDevice?this.selectedDevice.toJSON():null,devices:this.collection.toJSON()}},fetchTranscodeJobs:function(){this.transcodeJobs.fetch({reset:!0,scope:"page"}),this.transcodeJobTimeout=setTimeout(t.bind(this.fetchTranscodeJobs,this),this.transcodeJobDelay)},showList:function(){this.selectedDevice?this.container.show(new c({model:this.selectedDevice,server:this.model})):this.container.close()
},onRender:function(){this.filterBar.append(new l),!this.shared&&this.user.hasPlexPass()&&this.showList()},onClose:function(){clearTimeout(this.transcodeJobTimeout)},onPrimaryServerChange:function(e,t){t&&s.trigger("navigate","sync",{serverID:t.id})},onSharedChange:function(e,t){this.shared=t,this.render()},onDeviceClick:function(e){e.preventDefault();var t=i(e.currentTarget),n=t.data("id");this.ui.devices.removeClass("selected"),t.addClass("selected"),this.selectedDevice=this.collection.get(n),this.showList()
},onEditClick:function(e){e.preventDefault(),i(e.currentTarget).toggleClass("selected"),this.$el.toggleClass("force-hover")},onRefreshClick:function(e){e.preventDefault(),r.execute("refreshSyncItems",{server:this.model})},onCloudSyncSettingsClick:function(e){e.preventDefault(),e.stopImmediatePropagation();var t=o.get("user");window.open(t.server.get("cloudSyncUrl"))}});return d}),define("hb!templates/desktop/activity/NowPlayingView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n  <div class="sessions-list-container"></div>\n'
}function r(e,t){var n,s="";return s+='\n  <div class="row row-padded">\n    <h4 class="text-muted text-center">\n      ',n=i["if"].call(e,e&&e.shared,{hash:{},inverse:f.program(6,l,t),fn:f.program(4,o,t),data:t}),(n||0===n)&&(s+=n),s+="\n    </h4>\n  </div>\n"}function o(e,t){var n,s,a="";return a+="\n        ",s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Now Playing is restricted from shared users.",s):p.call(e,"t","Now Playing is restricted from shared users.",s)))+"\n      "}function l(e,t){var n;
return n=i["if"].call(e,e&&e.synced,{hash:{},inverse:f.program(9,d,t),fn:f.program(7,c,t),data:t}),n||0===n?n:""}function c(e,t){var n,s,a="";return a+="\n        ",s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Now Playing is unavailable with synced servers.",s):p.call(e,"t","Now Playing is unavailable with synced servers.",s)))+"\n      "}function d(e,t){var n,s,a="";return a+="\n        ",s={hash:{},data:t},a+=m((n=i.t||e&&e.t,n?n.call(e,"Now Playing requires Plex Media Server {1} or later.",e&&e.minServerVersion,s):p.call(e,"t","Now Playing requires Plex Media Server {1} or later.",e&&e.minServerVersion,s)))+"\n      "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var u,h="",p=i.helperMissing,m=this.escapeExpression,f=this;return h+='<div class="filter-bar"></div>\n\n',u=i["if"].call(t,t&&t.shouldShowList,{hash:{},inverse:f.program(3,r,s),fn:f.program(1,a,s),data:s}),(u||0===u)&&(h+=u),h+="\n"})}),define("hb!templates/desktop/lists/activity/SessionTileListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return"hide-actions"}function r(){return"hidden"}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var o,l,c="",d=this,u="function",h=this.escapeExpression,p=i.helperMissing;return c+='<a class="media-poster-container ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+='" href="',(o=i.url)?o=o.call(t,{hash:{},data:s}):(o=t&&t.url,o=typeof o===u?o.call(t,{hash:{},data:s}):o),c+=h(o)+'">\n  <div class="media-poster-fade invisible"></div>\n  <div class="media-poster">\n    <div class="media-poster-overlay"></div>\n    <div class="media-poster-top-overlay"></div>\n\n    <div class="media-poster-actions ',o=i.unless.call(t,t&&t.showActions,{hash:{},inverse:d.noop,fn:d.program(3,r,s),data:s}),(o||0===o)&&(c+=o),c+='">\n      <button class="play-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon play"></i></button>\n      <button class="edit-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon pencil"></i></button>\n      <button class="info-btn media-poster-btn btn-link" tabindex="-1"><i class="glyphicon circle-info"></i></button>\n    </div>\n\n    <button class="close-btn btn-link btn-gray" href="#"><i class="glyphicon remove-2"></i></button>\n\n    <i class="device-icon"></i>\n\n    <div class="session-player"></div>\n    <div class="session-state"></div>\n    <div class="session-transcode-details">\n      <p class="session-transcode-title">\n        <span class="session-transcode"></span>\n        <span class="session-transcode-throttled"></span>\n      </p>\n\n      <p class="session-transcode-video">\n        <span class="session-transcode-label">',l={hash:{},data:s},c+=h((o=i.t||t&&t.t,o?o.call(t,"Video",l):p.call(t,"t","Video",l)))+'</span>\n        <span class="session-transcode-video-decision"></span>\n      </p>\n\n      <p class="session-transcode-audio">\n        <span class="session-transcode-label">',l={hash:{},data:s},c+=h((o=i.t||t&&t.t,o?o.call(t,"Audio",l):p.call(t,"t","Audio",l)))+'</span>\n        <span class="session-transcode-audio-decision"></span>\n      </p>\n    </div>\n\n    <div class="media-progress"></div>\n  </div>\n\n  <div class="session-user pull-right">\n    <div class="user-poster img-circle"></div>\n    <div class="session-username media-heading secondary"></div>\n  </div>\n\n  <div class="media-title media-heading"></div>\n  <div class="media-subtitle-1 media-heading secondary"></div>\n</a>\n'
})}),define("plex/desktop/views/lists/activity/SessionTileListItem",["hb!templates/desktop/lists/activity/SessionTileListItem.tpl","underscore","plex/base/utils/t","plex/base/utils/deviceIcons","plex/base/utils/playerUtil","plex/base/utils/mediaUtil","plex/base/utils/formatters/stringUtil","plex/base/commands/commands","plex/desktop/views/lists/library/MediaListItem","plex/base/views/images/MediaPosterImage"],function(e,t,i,n,s,a,r,o,l,c){"use strict";var d=l.extend({className:"poster-item session-tile-list-item",template:e,screenshotPreferredIndex:"hd",screenshotInterval:null,screenshotIntervalDelay:2e3,screenshotCount:0,ui:{poster:".media-poster",posterFade:".media-poster-fade",userPoster:".user-poster"},events:t.extend({"click .info-btn":"onInfoClick","click .close-btn":"onInfoClick"},l.prototype.events),modelEvents:{"change:viewOffset":"onViewOffsetChange","change:Player":"onPlayerChange"},initialize:function(){l.prototype.initialize.apply(this,arguments);
var e=this.getScreenshotUrl(this.model.get("Media"));this.image=new c({model:this.model,modelAttribute:"ratingKey",type:"clip",getUrl:this.getPosterUrl,width:350,url:e?e:null}),this.userImage=new c({model:this.model,modelAttribute:"User",type:"friend",getUrl:this.getUserPosterUrl,width:44}),this.posterFade=new c({model:this.model,modelAttribute:"Media",type:"clip",getUrl:t.bind(this.getScreenshotUrl,this),width:350});var i=this.model.get("Player");i&&i.state===s.states.PLAYING&&(this.screenshotInterval=setInterval(t.bind(this.updateScreenshot,this),this.screenshotIntervalDelay)),this.listenTo(this.model,"change:Player",this.onPlayerChange)
},getPosterUrl:function(){var e=this.model;return"photo"===e.get("type")?e.get("thumb"):e.get("art")||e.get("parentArt")||e.get("grandparentArt")||e.get("thumb")},getUserPosterUrl:function(e){return e.thumb},getScreenshotUrl:function(e){var i=t.first(e);if(i){var n=this.model.get("viewOffset")||0,s=this.screenshotCount*this.screenshotIntervalDelay+n+4e3;return a.getScreenshotUrl(i,s,this.screenshotPreferredIndex)}},updateScreenshot:function(){this.screenshotCount++;var e=this.posterFade.screenshotUrl,i=this.getScreenshotUrl(this.model.get("Media"));
i&&(this.posterFade.screenshotUrl=i,this.posterFade.load(i).done(this.whenRendered(function(i){this.posterFade.showImage(i),this.ui.posterFade.removeClass("invisible"),this.posterFadeDelay=t.delay(this.whenRendered(function(){if(this.image.showImage(i),this.ui.posterFade.addClass("invisible"),e){var t=this.posterFade.cache,n=this.image.getTranscodeUrl(e),s=t.get(t.getItemCacheKey({url:n}));s&&t.remove(s)}}),800)})))},bindings:t.extend({},l.prototype.bindings,{".media-subtitle-1":{modelAttribute:"year",modelListeners:["title","year"],autohide:!0,formatter:function(){var e=l.prototype.bindings[".media-subtitle-1"].formatter.apply(this,arguments),t=l.prototype.bindings[".media-subtitle-2"].formatter.call(this,this.model.get("index"));
return t?t+" "+e:e}},".device-icon":{modelAttribute:"Player",manual:!0,formatter:function(e,t){var i=n.getIcon(e.platform||e.product);t.addClass("device-icon-"+i)}},".session-player":{modelAttribute:"Player",formatter:function(e){return e.title}},".session-state":{modelAttribute:"Player",formatter:function(e){return i(r.titleCase(e.state))}},".session-transcode":{modelAttribute:"TranscodeSession",formatter:function(e){return i(e?"Transcoding":"Direct Play")}},".session-transcode-throttled":{modelAttribute:"TranscodeSession",autohide:!0,formatter:function(e){return e&&"1"===e.throttled?i("(throttled)"):""
}},".session-transcode-video-decision":{modelAttribute:"TranscodeSession",formatter:function(e,t){var n=!(!e||!e.videoCodec);return t.parent().toggleClass("hidden",!n),n?"copy"===e.videoDecision?i("Direct Stream"):i("Transcode ({1})",e.videoCodec):""}},".session-transcode-audio-decision":{modelAttribute:"TranscodeSession",formatter:function(e,t){var n=!(!e||!e.audioCodec);return t.parent().toggleClass("hidden",!n),n?"copy"===e.audioDecision?i("Direct Stream"):i("Transcode ({1})",e.audioCodec):""}},".session-username":{modelAttribute:"User",formatter:function(e){return e.title
}}}),onRender:function(){l.prototype.onRender.apply(this,arguments),this.userImage.setElement(this.ui.userPoster),this.posterFade.setElement(this.ui.posterFade)},onClose:function(){l.prototype.onClose.call(this),clearTimeout(this.posterFadeDelay),clearInterval(this.screenshotInterval),this.posterFade&&this.posterFade.close()},onViewOffsetChange:function(){this.screenshotCount=0},onPlayerChange:function(e,i){i&&(i.state!==s.states.PLAYING&&this.screenshotInterval?(this.screenshotInterval=clearInterval(this.screenshotInterval),this.screenshotCount=0):i.state!==s.states.PLAYING||this.screenshotInterval||(this.screenshotInterval=setInterval(t.bind(this.updateScreenshot,this),this.screenshotIntervalDelay)))
},onPlayClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),o.execute("playMedia",{item:this.model,offset:this.model.get("viewOffset")})},onInfoClick:function(e){e.preventDefault(),e.stopImmediatePropagation(),this.$el.toggleClass("dim")}});return d}),define("hb!templates/desktop/lists/activity/SessionTileListEmptyView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;
return o+='<div class="row row-padded">\n  <h4 class="text-muted text-center">\n    ',r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Nothing is currently being played.",r):l.call(t,"t","Nothing is currently being played.",r)))+"\n  </h4>\n</div>\n"})}),define("plex/desktop/views/lists/activity/SessionTileListEmptyView",["hb!templates/desktop/lists/activity/SessionTileListEmptyView.tpl","marionette"],function(e,t){"use strict";var i=t.ItemView.extend({template:e});return i}),define("plex/desktop/views/lists/activity/SessionTileList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/activity/SessionTileListItem","plex/desktop/views/lists/activity/SessionTileListEmptyView"],function(e,t,i){"use strict";
var n=e.extend({tagName:"ul",className:"tile-list session-tile-list",itemView:t,emptyView:i});return n}),define("plex/desktop/views/activity/NowPlayingView",["hb!templates/desktop/activity/NowPlayingView.tpl","marionette","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/dropdowns/PrimaryServerDropdown","plex/desktop/views/lists/activity/SessionTileList"],function(e,t,i,n,s,a){"use strict";var r=t.Layout.extend({className:"now-playing-container",template:e,regions:{filterBar:".filter-bar",list:".sessions-list-container"},modelEvents:{"change:shared":"onSharedChange"},shouldShowList:function(){return!this.shared&&!this.synced&&this.supported
},initialize:function(){this.shared=this.model.get("shared"),this.synced=this.model.get("synced"),this.supported=this.model.supports("publicNowPlaying")||this.model.get("myPlexSubscription"),n.set("primaryServer",this.model),this.listenTo(n,"change:primaryServer",this.onPrimaryServerChange)},serializeData:function(){return{shouldShowList:this.shouldShowList(),shared:this.shared,synced:this.synced,minServerVersion:this.model.features.publicNowPlaying}},onRender:function(){this.filterBar.append(new s),this.shouldShowList()&&this.list.show(new a({collection:this.collection}))
},onPrimaryServerChange:function(e,t){t&&i.trigger("navigate","nowPlaying",{serverID:t.id})},onSharedChange:function(e,t){this.shared=t,this.render()}});return r}),define("plex/desktop/views/activity/ActivityView",["hb!templates/desktop/activity/ActivityView.tpl","underscore","marionette","plex/desktop/views/activity/AlertsView","plex/desktop/views/activity/SyncView","plex/desktop/views/activity/NowPlayingView"],function(e,t,i,n,s,a){"use strict";var r={alerts:n,sync:s,nowPlaying:a},o=i.Layout.extend({className:"container",template:e,ui:{nowPlayingBadge:".now-playing-btn > .badge"},regions:{container:".activity-container"},onlyAfterRender:["onNowPlayingChange"],initialize:function(e){this.options=e,this.subset=e.subset||"alerts",this.subsets={nowPlaying:this.model.get("sessions")},this.listenTo(this.subsets.nowPlaying,"reset add remove",this.onNowPlayingChange)
},serializeData:function(){return{subset:this.subset}},updateBadges:function(){var e={nowPlaying:this.subsets.nowPlaying.length};t.each(t.keys(e),function(t){var i=this.ui[t+"Badge"];i.text(e[t]),i.toggleClass("hidden",0===e[t])},this)},onRender:function(){var e=r[this.subset];this.container.show(new e(this.options)),this.updateBadges()},onNowPlayingChange:function(){this.updateBadges()}});return o}),define("plex/desktop/routes/ActivityController",["underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/routes/BaseController","plex/base/models/appModel","plex/desktop/views/activity/ActivityView","plex/desktop/views/error/ErrorView"],function(e,t,i,n,s,a,r){"use strict";
var o=n.extend({activity:function(){var e=this.populateView({primaryServer:!0});e.done(function(e){var t=e.server;i.trigger("show:view",new a({model:t,collection:t.get("alerts"),subset:"alerts"}))})},alerts:function(e){var t;t=e?{serverID:e}:{primaryServer:!0};var n=this.populateView(t);n.done(function(e){var t=e.server;i.trigger("show:view",new a({model:t,collection:t.get("alerts"),subset:"alerts"}))})},sync:function(n,o){var l=this.populateView({serverID:"myPlex"});l=l.then(e.bind(function(){var e;
return e=n?{serverID:n}:{primaryServer:!0},this.populateView(e)},this)),l.done(function(e){var n=s.get("user"),l=n.get("devices"),c=l.populate();c.done(function(){var t=l.filterSyncDevices(),n=o?t.get(o):null;i.trigger("show:view",new a({model:e.server,collection:t,selectedDevice:n,subset:"sync"}))}),c.fail(function(){i.trigger("show:view",new r({title:t("Sync status is unavailable.")}))})})},nowPlaying:function(e){var t;t=e?{serverID:e}:{primaryServer:!0};var n=this.populateView(t);n.done(function(e){var t=e.server;
i.trigger("show:view",new a({model:t,collection:t.get("sessions"),subset:"nowPlaying"}))})}});return o}),define("plex/desktop/routes/ActivityRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/ActivityController"],function(e,t){"use strict";var i=e.extend({controller:new t,appRoutes:{"!/activity":"activity","!/activity/alerts(/:serverID)":"alerts","!/activity/sync(/:serverID)(/:deviceID)":"sync","!/activity/playing(/:serverID)":"nowPlaying"}});return i}),define("hb!templates/desktop/user/UserPlaylistView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";
return s+='\n    <li><a class="',(n=i.subset)?n=n.call(e,{hash:{},data:t}):(n=e&&e.subset,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+'-btn btn-gray" href="#!/playlist/',(n=i.key)?n=n.call(e,{hash:{},data:t}):(n=e&&e.key,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+"/",(n=i.subset)?n=n.call(e,{hash:{},data:t}):(n=e&&e.subset,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+'">',(n=i.title)?n=n.call(e,{hash:{},data:t}):(n=e&&e.title,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+'<span class="badge"></span></a></li>\n  '
}function r(e,t){var n,s="";return s+='\n    <a class="user-playlist-help" href="',(n=i.helpRoute)?n=n.call(e,{hash:{},data:t}):(n=e&&e.helpRoute,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+'" target="',(n=i.defaultTarget)?n=n.call(e,{hash:{},data:t}):(n=e&&e.defaultTarget,n=typeof n===u?n.call(e,{hash:{},data:t}):n),s+=h(n)+'"><i class="glyphicon circle-question-mark"></i></a>\n  '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var o,l,c,d="",u="function",h=this.escapeExpression,p=this,m=i.helperMissing;
return d+='<ul class="nav nav-header pull-right">\n  ',o=i.each.call(t,t&&t.filters,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(d+=o),d+="\n</ul>\n\n<h2>\n  ",c={hash:{},data:s},d+=h((o=i.t||t&&t.t,o?o.call(t,t&&t.label,c):m.call(t,"t",t&&t.label,c)))+"\n\n  ",l=i["if"].call(t,t&&t.helpRoute,{hash:{},inverse:p.noop,fn:p.program(3,r,s),data:s}),(l||0===l)&&(d+=l),d+='\n</h2>\n\n<div class="user-playlist-container"></div>\n'})}),define("hb!templates/desktop/lists/user/UserPlaylistListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var a,r="",o="function",l=this.escapeExpression;return r+='<a class="card card-user-playlist" href="',(a=i.url)?a=a.call(t,{hash:{},data:s}):(a=t&&t.url,a=typeof a===o?a.call(t,{hash:{},data:s}):a),r+=l(a)+'">\n  <div class="card-poster media-poster"></div>\n\n  <div class="card-actions">\n    <button class="play-btn card-action-btn"><i class="glyphicon play"></i></button>\n    <button class="mark-unwatched-btn card-action-btn"><i class="glyphicon circle-minus"></i></button>\n    <button class="mark-watched-btn card-action-btn"><i class="glyphicon circle-ok"></i></button>\n    <button class="delete-btn card-action-btn btn-danger"><i class="glyphicon remove-2"></i></button>\n  </div>\n\n  <h4 class="media-title"></h4>\n\n  <div class="card-details">\n    <span class="media-subtitle-1"></span>\n    <span class="media-context"></span>\n\n    <p class="media-summary"></p>\n  </div>\n</a>'
})}),define("plex/desktop/views/lists/user/UserPlaylistListItem",["hb!templates/desktop/lists/user/UserPlaylistListItem.tpl","underscore","plex/base/commands/commands","plex/desktop/views/lists/library/MediaDetailsListItem"],function(e,t,i,n){"use strict";var s=n.extend({template:e,className:"card-tile-list-item card-2-col-item",events:{"click .play-btn":"onPlayClick","click .mark-watched-btn":"onMarkWatchedClick","click .mark-unwatched-btn":"onMarkUnwatchedClick","click .delete-btn":"onDeleteClick"},serializeData:function(){var e=n.prototype.serializeData.apply(this,arguments);
return e},bindings:t.extend({},n.prototype.bindings,{".media-summary":{autohide:!0,formatter:function(){return this.model.get("message")||this.model.get("summary")}},".mark-unwatched-btn":{modelAttribute:"viewCount",manual:!0,autohide:function(e){return e>0}},".mark-watched-btn":{modelAttribute:"viewCount",manual:!0,autohide:function(e){return 0===e}}}),onPlayClick:function(e){e.preventDefault(),i.execute("playMedia",{item:this.model,siblings:this.canPlaySiblings()})},onMarkWatchedClick:function(e){e.preventDefault(),i.execute("markWatched",{item:this.model})
},onMarkUnwatchedClick:function(e){e.preventDefault(),i.execute("markUnwatched",{item:this.model})},onDeleteClick:function(e){e.preventDefault(),this.model.destroy()}});return s}),define("plex/desktop/views/lists/user/UserPlaylistList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/user/UserPlaylistListItem"],function(e,t){"use strict";var i=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t});return i}),define("plex/desktop/views/user/UserPlaylistView",["hb!templates/desktop/user/UserPlaylistView.tpl","underscore","jquery","marionette","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/models/config","plex/desktop/views/lists/user/UserPlaylistList"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c=n.Layout.extend({className:"container",template:e,ui:{navLinks:".nav a",allBadge:".all-btn > .badge",unwatchedBadge:".unwatched-btn > .badge",watchedBadge:".watched-btn > .badge"},regions:{list:".user-playlist-container"},events:{"click .nav a":"onNavClick"},initialize:function(e){this.initSubset(e),this.subsets={all:this.collection,unwatched:this.collection.filterUnwatched(),watched:this.collection.filterWatched()},this.listenTo(this.collection,{add:this.onCollectionChange,remove:this.onCollectionChange,"change:viewCount":this.onCollectionChange})
},initSubset:function(e){var t=e.subset,i=this.collection.key+"!subset";t||(t=r.get(i)),t||(t="unwatched"),r.save(i,t),this.subset=t},serializeData:function(){return{label:this.collection.label,helpRoute:this.collection.helpRoute,defaultTarget:o.get("defaultTarget"),filters:[{title:s("All"),key:this.collection.key,subset:"all"},{title:s("Unwatched"),key:this.collection.key,subset:"unwatched"},{title:s("Watched"),key:this.collection.key,subset:"watched"}]}},updateBadges:function(){var e={all:this.subsets.all.length,unwatched:this.subsets.unwatched.length,watched:this.subsets.watched.length};
t.each(t.keys(e),function(t){var i=this.ui[t+"Badge"];i.text(e[t]),i.toggleClass("hidden",0===e[t])},this)},onRender:function(){this.list.show(new l({collection:this.subsets[this.subset]})),this.ui.navLinks.filter('[href*="/'+this.subset+'"]').addClass("selected"),this.updateBadges()},onCollectionChange:function(){this.subsets.unwatched.set(this.collection.filterUnwatched().models),this.subsets.watched.set(this.collection.filterWatched().models),this.updateBadges()},onNavClick:function(e){e.preventDefault(),this.ui.navLinks.removeClass("selected"),i(e.currentTarget).addClass("selected"),this.initSubset({subset:t.last(e.currentTarget.href.split("/"))}),this.list.show(new l({collection:this.subsets[this.subset]})),a.trigger("navigate","userPlaylist",{key:this.collection.key,subset:this.subset,trigger:!1})
}});return c}),define("hb!templates/desktop/user/AnnouncementsView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o="",l=i.helperMissing,c=this.escapeExpression;return o+="<h2>",r={hash:{},data:s},o+=c((a=i.t||t&&t.t,a?a.call(t,"Announcements",r):l.call(t,"t","Announcements",r)))+'</h2>\n\n<div class="announcements-container"></div>\n'})}),define("hb!templates/desktop/lists/user/AnnouncementListItem",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(){return'\n    <div class="unread"></div>\n  '
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d=this,u="function",h=this.escapeExpression,p=i.helperMissing;return c+='<div class="card card-announcement">\n  ',r=i["if"].call(t,t&&t.isUnread,{hash:{},inverse:d.noop,fn:d.program(1,a,s),data:s}),(r||0===r)&&(c+=r),c+='\n\n  <h4><a href="',(r=i.link)?r=r.call(t,{hash:{},data:s}):(r=t&&t.link,r=typeof r===u?r.call(t,{hash:{},data:s}):r),c+=h(r)+'" target="_blank">',(r=i.title)?r=r.call(t,{hash:{},data:s}):(r=t&&t.title,r=typeof r===u?r.call(t,{hash:{},data:s}):r),c+=h(r)+'</a></h4>\n\n  <a href="',(r=i.link)?r=r.call(t,{hash:{},data:s}):(r=t&&t.link,r=typeof r===u?r.call(t,{hash:{},data:s}):r),c+=h(r)+'" target="_blank"><img class="thumb"/></a>\n\n  <p class="date">',l={hash:{},data:s},c+=h((r=i.formatTimestamp||t&&t.formatTimestamp,r?r.call(t,t&&t.timestamp,l):p.call(t,"formatTimestamp",t&&t.timestamp,l)))+'</p>\n  <p class="description">',(o=i.description)?o=o.call(t,{hash:{},data:s}):(o=t&&t.description,o=typeof o===u?o.call(t,{hash:{},data:s}):o),(o||0===o)&&(c+=o),c+="</p>\n</div>\n"
})}),define("plex/desktop/views/lists/user/AnnouncementListItem",["hb!templates/desktop/lists/user/AnnouncementListItem.tpl","marionette","plex/base/views/images/BaseImage"],function(e,t,i){"use strict";var n=t.ItemView.extend({tagName:"li",className:"card-tile-list-item",template:e,ui:{thumb:".thumb"},initialize:function(){this.image=new i({url:this.model.get("thumb")})},onRender:function(){this.image.setElement(this.ui.thumb)},onClose:function(){this.image.close()}});return n}),define("plex/desktop/views/lists/user/AnnouncementList",["plex/desktop/views/lists/BaseList","plex/desktop/views/lists/user/AnnouncementListItem"],function(e,t){"use strict";
var i=e.extend({tagName:"ul",className:"list card-tile-list",itemView:t});return i}),define("plex/desktop/views/user/AnnouncementsView",["hb!templates/desktop/user/AnnouncementsView.tpl","marionette","plex/desktop/views/lists/user/AnnouncementList","plex/base/models/appModel"],function(e,t,i,n){"use strict";var s=t.Layout.extend({className:"container",template:e,regions:{list:".announcements-container"},onRender:function(){var e=this.collection;n.get("user").hasPlexPass()&&(e=e.clone(e.reject(function(e){return"PlexPass"===e.get("promo")
}))),this.list.show(new i({collection:e}))}});return s}),define("hb!templates/desktop/user/QueueHelpView",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var a,r,o,l="",c=i.helperMissing,d=this.escapeExpression,u="function";return l+="<h2>",o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Watch Later Help",o):c.call(t,"t","Watch Later Help",o)))+'</h2>\n\n<div class="filter-bar">\n<h4>',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Add videos from your browser",o):c.call(t,"t","Add videos from your browser",o)))+'</h4>\n</div>\n\n<div class="row text-muted">\n  <div class="col-md-5">\n    <div class="text-center">\n      <a class="btn btn-primary btn-lg btn-plexit" href=\'javascript: var s=document.createElement("script");s.type="text/javascript";s.src="//plex.tv/queue/bookmarklet_payload";var h=document.getElementsByTagName("head")[0];h.appendChild(s);void(0);\'><span class="plexit-hidden">\u276f</span> Plex It!</a>\n    </div>\n\n    <ol class="steps-list">\n      <li>',(r=i.firstStepText)?r=r.call(t,{hash:{},data:s}):(r=t&&t.firstStepText,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+"</li>\n      <li>",o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,'To save a video to Watch Later, click "Plex It!" in your Bookmarks Bar.',o):c.call(t,"t",'To save a video to Watch Later, click "Plex It!" in your Bookmarks Bar.',o)))+"</li>\n      <li>",o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"A panel will appear on the left side of the page to let you know the video has been saved.",o):c.call(t,"t","A panel will appear on the left side of the page to let you know the video has been saved.",o)))+"</li>\n      <li>",o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,'You can also recommend the video to friends or "fling" it to a Plex player and watch it there.',o):c.call(t,"t",'You can also recommend the video to friends or "fling" it to a Plex player and watch it there.',o)))+'</li>\n    </ol>\n  </div>\n\n  <div class="col-md-7 text-right">\n    <img class="plexit-img" src="',(r=i.stepsImgSrc)?r=r.call(t,{hash:{},data:s}):(r=t&&t.stepsImgSrc,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+'"/>\n  </div>\n</div>\n\n<div class="filter-bar">\n  <h4>',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Add videos by email",o):c.call(t,"t","Add videos by email",o)))+'</h4>\n</div>\n\n<div class="row text-muted">\n  <div class="col-md-5">\n    <div class="queue-email form-control input-lg disabled" title="',(r=i.copyCommand)?r=r.call(t,{hash:{},data:s}):(r=t&&t.copyCommand,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+'" tabindex="-1">',(r=i.queueEmail)?r=r.call(t,{hash:{},data:s}):(r=t&&t.queueEmail,r=typeof r===u?r.call(t,{hash:{},data:s}):r),l+=d(r)+'</div>\n    <ol class="steps-list">\n      <li>',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Send an email to the address above with any link(s) you want added to Watch Later.",o):c.call(t,"t","Send an email to the address above with any link(s) you want added to Watch Later.",o)))+"</li>\n      <li>",o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Add this to your address book so you can easily email links from your iPhone, iPad, Android, or any other device.",o):c.call(t,"t","Add this to your address book so you can easily email links from your iPhone, iPad, Android, or any other device.",o)))+'</li>\n    </ol>\n  </div>\n  <div class="col-md-7 text-right">\n    <img class="email-links" src="img/queue/email-links.png"/>\n  </div>\n</div>\n'
})}),define("plex/desktop/views/user/QueueHelpView",["hb!templates/desktop/user/QueueHelpView.tpl","underscore","marionette","plex/base/utils/t","plex/base/utils/browser","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal","plex/base/utils/dispatcher"],function(e,t,i,n,s,a,r,o){"use strict";var l=i.ItemView.extend({className:"container queue-help-container",template:e,ui:{queueEmail:".queue-email",plexitBtn:".btn-plexit"},events:{"focus .queue-email":"onQueueEmailFocus","mouseup .queue-email":"onQueueEmailMouseUp","click .btn-plexit":"onPlexitClick","mousedown .btn-plexit":"onPlexitMouseDown","mouseup .btn-plexit":"onPlexitMouseUp"},initialize:function(e){this.queueEmail=e.queueEmail,"ie"===s.id?(this.stepsImgSrc="img/queue/bookmarklet-steps-ie.png",this.modalText=n('Right click the "Plex It!" button and choose Add to Favorites so you can save videos to Watch Later.'),this.firstStepText=n("Add the button above to your favorites bar.")):(this.stepsImgSrc="img/queue/bookmarklet-steps.png",this.modalText=n('Drag the "Plex it!" button to your Bookmarks Bar so you can save videos to your Watch Later.'),this.firstStepText=n("Drag the button above to your bookmarks bar."));
var i=["OSX","Windows","Linux"];if(-1!==t.indexOf(i,s.platform)){var a="OSX"===s.platform?"\u2318 C":"Ctrl C";this.copyCommand=n(a+" to copy")}},serializeData:function(){return{queueEmail:this.queueEmail,copyCommand:this.copyCommand,stepsImgSrc:this.stepsImgSrc,firstStepText:this.firstStepText}},onRender:function(){this.copyCommand&&this.$el.tooltip({selector:".queue-email",placement:"top",trigger:"focus"})},onQueueEmailFocus:function(){this.ui.queueEmail.selectText()},onQueueEmailMouseUp:function(){return!1
},onPlexitClick:function(e){e.preventDefault();var t=new r({title:n("Plex It!"),message:this.modalText,confirmLabel:n("OK"),hideCancel:!0});o.trigger("show:modal",t)},onPlexitMouseDown:function(){this.ui.plexitBtn.css("user-select","text")},onPlexitMouseUp:function(){this.ui.plexitBtn.css("user-select","none")}});return l}),define("plex/desktop/routes/UserController",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/routes/BaseController","plex/base/models/appModel","plex/base/models/user/UserPlaylistItemModel","plex/base/models/user/UserPlaylistItemCollection","plex/desktop/views/user/UserPlaylistView","plex/desktop/views/user/AnnouncementsView","plex/desktop/views/details/DetailsView","plex/desktop/views/error/ErrorView","plex/desktop/views/user/QueueHelpView"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=n.extend({userPlaylist:function(i,n){var a=this.populateView({serverID:"myPlex"});a.done(function(){var a=s.get("user"),l=new r([],{server:a.server,parent:a,key:i}),c=l.fetch({scope:"page"});c.done(function(){t.trigger("show:view",new o({model:s.get("user"),collection:l,subset:n}))}),c.fail(function(){t.trigger("show:view",new d({title:e("This playlist is unavailable.")}))})})},userPlaylistDetails:function(i,n){var r=this.populateView({serverID:"myPlex"});r.done(function(r){var o=s.get("user"),l=new a({id:n},{server:r.server,parent:o,playlist:i}),u=l.fetch({scope:"page"});
u.done(function(){t.trigger("show:view",new c({model:l}))}),u.fail(function(){t.trigger("show:view",new d({title:e("This playlist item is unavailable.")}))})})},queueHelp:function(){var e=this.populateView({serverID:"myPlex"});e.done(function(){var e=s.get("user");t.trigger("show:view",new u({queueEmail:e.get("queueEmail")}))})},announcements:function(){var n=this.populateView();n.done(function(){var n=s.get("announcements"),a=n.fetch({scope:"page"});a.done(function(){t.trigger("show:view",new l({collection:n})),i.save("announcementsLastReadTimestamp",(new Date).getTime())
}),a.fail(function(){t.trigger("show:view",new d({title:e("Announcements are not available.")}))})})}});return h}),define("plex/desktop/routes/UserRouter",["plex/base/routes/BaseRouter","plex/desktop/routes/UserController"],function(e,t){"use strict";var i=e.extend({controller:new t,appRoutes:{"!/playlist/queue/help":"queueHelp","!/playlist/:key(/:subset)":"userPlaylist","!/playlist/:key/details/:itemID":"userPlaylistDetails","!/announcements":"announcements"}});return i}),define("plex/desktop/initializers/routerInitializer",["backbone","plex/desktop/routes/DesktopAppRouter","plex/desktop/routes/SetupRouter","plex/desktop/routes/LibraryRouter","plex/desktop/routes/ChannelRouter","plex/desktop/routes/PlaylistRouter","plex/desktop/routes/SettingsRouter","plex/desktop/routes/ActivityRouter","plex/desktop/routes/UserRouter"],function(e,t,i,n,s,a,r,o,l){"use strict";
var c={init:function(){new t,new i,new n,new s,new a,new r,new o,new l,e.history.start()}};return c}),function(e,t){function i(e,t,i){return e.addEventListener?void e.addEventListener(t,i,!1):void e.attachEvent("on"+t,i)}function n(e){if("keypress"==e.type){var t=String.fromCharCode(e.which);return e.shiftKey||(t=t.toLowerCase()),t}return C[e.which]?C[e.which]:P[e.which]?P[e.which]:String.fromCharCode(e.which).toLowerCase()}function s(e,t){return e.sort().join(",")===t.sort().join(",")}function a(e){e=e||{};
var t,i=!1;for(t in M)e[t]?i=!0:M[t]=0;i||(L=!1)}function r(e,t,i,n,a,r){var o,l,c=[],d=i.type;if(!I[e])return[];for("keyup"==d&&p(e)&&(t=[e]),o=0;o<I[e].length;++o)if(l=I[e][o],(n||!l.seq||M[l.seq]==l.level)&&d==l.action&&("keypress"==d&&!i.metaKey&&!i.ctrlKey||s(t,l.modifiers))){var u=!n&&l.combo==a,h=n&&l.seq==n&&l.level==r;(u||h)&&I[e].splice(o,1),c.push(l)}return c}function o(e){var t=[];return e.shiftKey&&t.push("shift"),e.altKey&&t.push("alt"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),t
}function l(e){return e.preventDefault?void e.preventDefault():void(e.returnValue=!1)}function c(e){return e.stopPropagation?void e.stopPropagation():void(e.cancelBubble=!0)}function d(e,t,i,n){O.stopCallback(t,t.target||t.srcElement,i,n)||e(t,i)===!1&&(l(t),c(t))}function u(e,t,i){var n,s=r(e,t,i),o={},l=0,c=!1;for(n=0;n<s.length;++n)s[n].seq&&(l=Math.max(l,s[n].level));for(n=0;n<s.length;++n)if(s[n].seq){if(s[n].level!=l)continue;c=!0,o[s[n].seq]=1,d(s[n].callback,i,s[n].combo,s[n].seq)}else c||d(s[n].callback,i,s[n].combo);
var u="keypress"==i.type&&E;i.type!=L||p(e)||u||a(o),E=c&&"keydown"==i.type}function h(e){"number"!=typeof e.which&&(e.which=e.keyCode);var t=n(e);if(t)return"keyup"==e.type&&D===t?void(D=!1):void O.handleKey(t,o(e),e)}function p(e){return"shift"==e||"ctrl"==e||"alt"==e||"meta"==e}function m(){clearTimeout(S),S=setTimeout(a,1e3)}function f(){if(!k){k={};for(var e in C)e>95&&112>e||C.hasOwnProperty(e)&&(k[C[e]]=e)}return k}function g(e,t,i){return i||(i=f()[e]?"keydown":"keypress"),"keypress"==i&&t.length&&(i="keydown"),i
}function v(e,t,i,s){function r(t){return function(){L=t,++M[e],m()}}function o(t){d(i,t,e),"keyup"!==s&&(D=n(t)),setTimeout(a,10)}M[e]=0;for(var l=0;l<t.length;++l){var c=l+1===t.length,u=c?o:r(s||b(t[l+1]).action);w(t[l],u,s,e,l)}}function y(e){return"+"===e?["+"]:e.split("+")}function b(e,t){var i,n,s,a=[];for(i=y(e),s=0;s<i.length;++s)n=i[s],_[n]&&(n=_[n]),t&&"keypress"!=t&&A[n]&&(n=A[n],a.push("shift")),p(n)&&a.push(n);return t=g(n,a,t),{key:n,modifiers:a,action:t}}function w(e,t,i,n,s){T[e+":"+i]=t,e=e.replace(/\s+/g," ");
var a,o=e.split(" ");return o.length>1?void v(e,o,t,i):(a=b(e,i),I[a.key]=I[a.key]||[],r(a.key,a.modifiers,{type:a.action},n,e,s),void I[a.key][n?"unshift":"push"]({callback:t,modifiers:a.modifiers,action:a.action,seq:n,level:s,combo:e}))}function x(e,t,i){for(var n=0;n<e.length;++n)w(e[n],t,i)}for(var k,S,C={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},P={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},A={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},_={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},I={},T={},M={},D=!1,E=!1,L=!1,R=1;20>R;++R)C[111+R]="f"+R;
for(R=0;9>=R;++R)C[R+96]=R;i(t,"keypress",h),i(t,"keydown",h),i(t,"keyup",h);var O={bind:function(e,t,i){return e=e instanceof Array?e:[e],x(e,t,i),this},unbind:function(e,t){return O.bind(e,function(){},t)},trigger:function(e,t){return T[e+":"+t]&&T[e+":"+t]({},e),this},reset:function(){return I={},T={},this},stopCallback:function(e,t){return(" "+t.className+" ").indexOf(" mousetrap ")>-1?!1:"INPUT"==t.tagName||"SELECT"==t.tagName||"TEXTAREA"==t.tagName||t.isContentEditable},handleKey:u};e.Mousetrap=O,"function"==typeof define&&define.amd&&define("mousetrap",O)
}(window,document),define("plex/desktop/initializers/keyboardShortcutsInitializer",["underscore","mousetrap","plex/base/utils/dispatcher","plex/base/adapters/settingsAdapter","plex/base/adapters/keyboardShortcutsAdapter"],function(e,t,i,n,s){"use strict";var a={init:function(){function a(t){return(o||arguments[1]instanceof KeyboardEvent&&"esc"===arguments[2])&&n.get("keyboardShortcuts")?t.apply(r,e.toArray(arguments).slice(1)):void 0}var r=s.getInstance(),o=!0;i.on("anyModalOpen",function(){o=!1}),i.on("allModalsClosed",function(){o=!0
}),e.each(r.shortcuts,function(i){t.bind(i.keys,e.wrap(r[i.fn],a))})}};return a}),+function(e){"use strict";function t(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in t)if(void 0!==e.style[i])return{end:t[i]}}e.fn.emulateTransitionEnd=function(t){var i=!1,n=this;e(this).one(e.support.transition.end,function(){i=!0});var s=function(){i||e(n).trigger(e.support.transition.end)
};return setTimeout(s,t),this},e(function(){e.support.transition=t()})}(window.jQuery),define("transition",["jquery"],function(){}),+function(e){"use strict";function t(){e(n).remove(),e(s).each(function(t){var n=i(e(this));n.hasClass("open")&&(n.trigger(t=e.Event("hide.bs.dropdown")),t.isDefaultPrevented()||n.removeClass("open").trigger("hidden.bs.dropdown"))})}function i(t){var i=t.attr("data-target");i||(i=t.attr("href"),i=i&&/#/.test(i)&&i.replace(/.*(?=#[^\s]*$)/,""));var n=i&&e(i);return n&&n.length?n:t.parent()
}var n=".dropdown-backdrop",s="[data-toggle=dropdown]",a=function(t){e(t).on("click.bs.dropdown",this.toggle)};a.prototype.toggle=function(n){var s=e(this);if(!s.is(".disabled, :disabled")){var a=i(s),r=a.hasClass("open");if(t(),!r){if("ontouchstart"in document.documentElement&&!a.closest(".navbar-nav").length&&e('<div class="dropdown-backdrop"/>').insertAfter(e(this)).on("click",t),a.trigger(n=e.Event("show.bs.dropdown")),n.isDefaultPrevented())return;a.toggleClass("open").trigger("shown.bs.dropdown"),s.focus()
}return!1}},a.prototype.keydown=function(t){if(/(38|40|27)/.test(t.keyCode)){var n=e(this);if(t.preventDefault(),t.stopPropagation(),!n.is(".disabled, :disabled")){var a=i(n),r=a.hasClass("open");if(!r||r&&27==t.keyCode)return 27==t.which&&a.find(s).focus(),n.click();var o=e("[role=menu] li:not(.divider):visible a",a);if(o.length){var l=o.index(o.filter(":focus"));38==t.keyCode&&l>0&&l--,40==t.keyCode&&l<o.length-1&&l++,~l||(l=0),o.eq(l).focus()}}}};var r=e.fn.dropdown;e.fn.dropdown=function(t){return this.each(function(){var i=e(this),n=i.data("dropdown");
n||i.data("dropdown",n=new a(this)),"string"==typeof t&&n[t].call(i)})},e.fn.dropdown.Constructor=a,e.fn.dropdown.noConflict=function(){return e.fn.dropdown=r,this},e(document).on("click.bs.dropdown.data-api",t).on("click.bs.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("click.bs.dropdown.data-api",s,a.prototype.toggle).on("keydown.bs.dropdown.data-api",s+", [role=menu]",a.prototype.keydown)}(window.jQuery),define("dropdown",["jquery"],function(){}),+function(e){"use strict";
var t=function(e,t){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null,this.init("tooltip",e,t)};t.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1},t.prototype.init=function(t,i,n){this.enabled=!0,this.type=t,this.$element=e(i),this.options=this.getOptions(n);for(var s=this.options.trigger.split(" "),a=s.length;a--;){var r=s[a];
if("click"==r)this.$element.on("click."+this.type,this.options.selector,e.proxy(this.toggle,this));else if("manual"!=r){var o="hover"==r?"mouseenter":"focus",l="hover"==r?"mouseleave":"blur";this.$element.on(o+"."+this.type,this.options.selector,e.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,e.proxy(this.leave,this))}}this.options.selector?this._options=e.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},t.prototype.getDefaults=function(){return t.DEFAULTS
},t.prototype.getOptions=function(t){return t=e.extend({},this.getDefaults(),this.$element.data(),t),t.delay&&"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t},t.prototype.getDelegateOptions=function(){var t={},i=this.getDefaults();return this._options&&e.each(this._options,function(e,n){i[e]!=n&&(t[e]=n)}),t},t.prototype.enter=function(t){var i=t instanceof this.constructor?t:e(t.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);return clearTimeout(i.timeout),i.hoverState="in",i.options.delay&&i.options.delay.show?void(i.timeout=setTimeout(function(){"in"==i.hoverState&&i.show()
},i.options.delay.show)):i.show()},t.prototype.leave=function(t){var i=t instanceof this.constructor?t:e(t.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);return clearTimeout(i.timeout),i.hoverState="out",i.options.delay&&i.options.delay.hide?void(i.timeout=setTimeout(function(){"out"==i.hoverState&&i.hide()},i.options.delay.hide)):i.hide()},t.prototype.show=function(){var t=e.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){if(this.$element.trigger(t),t.isDefaultPrevented())return;
var i=this.tip();this.setContent(),this.options.animation&&i.addClass("fade");var n="function"==typeof this.options.placement?this.options.placement.call(this,i[0],this.$element[0]):this.options.placement,s=/\s?auto?\s?/i,a=s.test(n);a&&(n=n.replace(s,"")||"top"),i.detach().css({top:0,left:0,display:"block"}).addClass(n),this.options.container?i.appendTo(this.options.container):i.insertAfter(this.$element);var r=this.getPosition(),o=i[0].offsetWidth,l=i[0].offsetHeight;if(a){var c=this.$element.parent(),d=n,u=document.documentElement.scrollTop||document.body.scrollTop,h="body"==this.options.container?window.innerWidth:c.outerWidth(),p="body"==this.options.container?window.innerHeight:c.outerHeight(),m="body"==this.options.container?0:c.offset().left;
n="bottom"==n&&r.top+r.height+l-u>p?"top":"top"==n&&r.top-u-l<0?"bottom":"right"==n&&r.right+o>h?"left":"left"==n&&r.left-o<m?"right":n,i.removeClass(d).addClass(n)}var f=this.getCalculatedOffset(n,r,o,l);this.applyPlacement(f,n),this.$element.trigger("shown.bs."+this.type)}},t.prototype.applyPlacement=function(e,t){var i,n=this.tip(),s=n[0].offsetWidth,a=n[0].offsetHeight,r=parseInt(n.css("margin-top"),10),o=parseInt(n.css("margin-left"),10);isNaN(r)&&(r=0),isNaN(o)&&(o=0),e.top=e.top+r,e.left=e.left+o,n.offset(e).addClass("in");
var l=n[0].offsetWidth,c=n[0].offsetHeight;if("top"==t&&c!=a&&(i=!0,e.top=e.top+a-c),/bottom|top/.test(t)){var d=0;e.left<0&&(d=-2*e.left,e.left=0,n.offset(e),l=n[0].offsetWidth,c=n[0].offsetHeight),this.replaceArrow(d-s+l,l,"left")}else this.replaceArrow(c-a,c,"top");i&&n.offset(e)},t.prototype.replaceArrow=function(e,t,i){this.arrow().css(i,e?50*(1-e/t)+"%":"")},t.prototype.setContent=function(){var e=this.tip(),t=this.getTitle();e.find(".tooltip-inner")[this.options.html?"html":"text"](t),e.removeClass("fade in top bottom left right")
},t.prototype.hide=function(){function t(){"in"!=i.hoverState&&n.detach()}var i=this,n=this.tip(),s=e.Event("hide.bs."+this.type);return this.$element.trigger(s),s.isDefaultPrevented()?void 0:(n.removeClass("in"),e.support.transition&&this.$tip.hasClass("fade")?n.one(e.support.transition.end,t).emulateTransitionEnd(150):t(),this.$element.trigger("hidden.bs."+this.type),this)},t.prototype.fixTitle=function(){var e=this.$element;(e.attr("title")||"string"!=typeof e.attr("data-original-title"))&&e.attr("data-original-title",e.attr("title")||"").attr("title","")
},t.prototype.hasContent=function(){return this.getTitle()},t.prototype.getPosition=function(){var t=this.$element[0];return e.extend({},"function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{width:t.offsetWidth,height:t.offsetHeight},this.$element.offset())},t.prototype.getCalculatedOffset=function(e,t,i,n){return"bottom"==e?{top:t.top+t.height,left:t.left+t.width/2-i/2}:"top"==e?{top:t.top-n,left:t.left+t.width/2-i/2}:"left"==e?{top:t.top+t.height/2-n/2,left:t.left-i}:{top:t.top+t.height/2-n/2,left:t.left+t.width}
},t.prototype.getTitle=function(){var e,t=this.$element,i=this.options;return e=t.attr("data-original-title")||("function"==typeof i.title?i.title.call(t[0]):i.title)},t.prototype.tip=function(){return this.$tip=this.$tip||e(this.options.template)},t.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},t.prototype.validate=function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},t.prototype.enable=function(){this.enabled=!0
},t.prototype.disable=function(){this.enabled=!1},t.prototype.toggleEnabled=function(){this.enabled=!this.enabled},t.prototype.toggle=function(t){var i=t?e(t.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type):this;i.tip().hasClass("in")?i.leave(i):i.enter(i)},t.prototype.destroy=function(){this.hide().$element.off("."+this.type).removeData("bs."+this.type)};var i=e.fn.tooltip;e.fn.tooltip=function(i){return this.each(function(){var n=e(this),s=n.data("bs.tooltip"),a="object"==typeof i&&i;
s||n.data("bs.tooltip",s=new t(this,a)),"string"==typeof i&&s[i]()})},e.fn.tooltip.Constructor=t,e.fn.tooltip.noConflict=function(){return e.fn.tooltip=i,this}}(window.jQuery),define("tooltip",["jquery"],function(){}),+function(e){"use strict";var t=function(i,n){this.$element=e(i),this.options=e.extend({},t.DEFAULTS,n)};t.DEFAULTS={loadingText:"loading..."},t.prototype.setState=function(e){var t="disabled",i=this.$element,n=i.is("input")?"val":"html",s=i.data();e+="Text",s.resetText||i.data("resetText",i[n]()),i[n](s[e]||this.options[e]),setTimeout(function(){"loadingText"==e?i.addClass(t).attr(t,t):i.removeClass(t).removeAttr(t)
},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons"]');if(e.length){var t=this.$element.find("input").prop("checked",!this.$element.hasClass("active")).trigger("change");"radio"===t.prop("type")&&e.find(".active").removeClass("active")}this.$element.toggleClass("active")};var i=e.fn.button;e.fn.button=function(i){return this.each(function(){var n=e(this),s=n.data("bs.button"),a="object"==typeof i&&i;s||n.data("bs.button",s=new t(this,a)),"toggle"==i?s.toggle():i&&s.setState(i)
})},e.fn.button.Constructor=t,e.fn.button.noConflict=function(){return e.fn.button=i,this},e(document).on("click.bs.button.data-api","[data-toggle^=button]",function(t){var i=e(t.target);i.hasClass("btn")||(i=i.closest(".btn")),i.button("toggle"),t.preventDefault()})}(window.jQuery),define("button",["jquery"],function(){}),+function(e){"use strict";var t=function(t,i){this.options=i,this.$element=e(t),this.$backdrop=this.isShown=null,this.options.remote&&this.$element.load(this.options.remote)};t.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},t.prototype.toggle=function(e){return this[this.isShown?"hide":"show"](e)
},t.prototype.show=function(t){var i=this,n=e.Event("show.bs.modal",{relatedTarget:t});this.$element.trigger(n),this.isShown||n.isDefaultPrevented()||(this.isShown=!0,this.escape(),this.$element.on("click.dismiss.modal",'[data-dismiss="modal"]',e.proxy(this.hide,this)),this.backdrop(function(){var n=e.support.transition&&i.$element.hasClass("fade");i.$element.parent().length||i.$element.appendTo(document.body),i.$element.show(),n&&i.$element[0].offsetWidth,i.$element.addClass("in").attr("aria-hidden",!1),i.enforceFocus();
var s=e.Event("shown.bs.modal",{relatedTarget:t});n?i.$element.find(".modal-dialog").one(e.support.transition.end,function(){i.$element.focus().trigger(s)}).emulateTransitionEnd(300):i.$element.focus().trigger(s)}))},t.prototype.hide=function(t){t&&t.preventDefault(),t=e.Event("hide.bs.modal"),this.$element.trigger(t),this.isShown&&!t.isDefaultPrevented()&&(this.isShown=!1,this.escape(),e(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.modal"),e.support.transition&&this.$element.hasClass("fade")?this.$element.one(e.support.transition.end,e.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal())
},t.prototype.enforceFocus=function(){e(document).off("focusin.bs.modal").on("focusin.bs.modal",e.proxy(function(e){this.$element[0]===e.target||this.$element.has(e.target).length||this.$element.focus()},this))},t.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.bs.modal",e.proxy(function(e){27==e.which&&this.hide()},this)):this.isShown||this.$element.off("keyup.dismiss.bs.modal")},t.prototype.hideModal=function(){var e=this;this.$element.hide(),this.backdrop(function(){e.removeBackdrop(),e.$element.trigger("hidden.bs.modal")
})},t.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},t.prototype.backdrop=function(t){var i=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var n=e.support.transition&&i;if(this.$backdrop=e('<div class="modal-backdrop '+i+'" />').appendTo(document.body),this.$element.on("click.dismiss.modal",e.proxy(function(e){e.target===e.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus.call(this.$element[0]):this.hide.call(this))
},this)),n&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!t)return;n?this.$backdrop.one(e.support.transition.end,t).emulateTransitionEnd(150):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,t).emulateTransitionEnd(150):t()):t&&t()};var i=e.fn.modal;e.fn.modal=function(i,n){return this.each(function(){var s=e(this),a=s.data("bs.modal"),r=e.extend({},t.DEFAULTS,s.data(),"object"==typeof i&&i);
a||s.data("bs.modal",a=new t(this,r)),"string"==typeof i?a[i](n):r.show&&a.show(n)})},e.fn.modal.Constructor=t,e.fn.modal.noConflict=function(){return e.fn.modal=i,this},e(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(t){var i=e(this),n=i.attr("href"),s=e(i.attr("data-target")||n&&n.replace(/.*(?=#[^\s]+$)/,"")),a=s.data("modal")?"toggle":e.extend({remote:!/#/.test(n)&&n},s.data(),i.data());t.preventDefault(),s.modal(a,this).one("hide",function(){i.is(":visible")&&i.focus()
})}),e(document).on("show.bs.modal",".modal",function(){e(document.body).addClass("modal-open")}).on("hidden.bs.modal",".modal",function(){e(document.body).removeClass("modal-open")})}(window.jQuery),define("modal",["jquery"],function(){}),define("plex/desktop/initializers/mainInitializer",["jquery","fastclick","plex/base/initializers/appInitializer","plex/base/initializers/settingsInitializer","plex/desktop/initializers/desktopAnalyticsInitializer","plex/base/initializers/cloudServerEventInitializer","plex/base/initializers/mediaServerEventInitializer","plex/desktop/initializers/userInitializer","plex/desktop/initializers/desktopServerInitializer","plex/desktop/initializers/routerInitializer","plex/desktop/initializers/keyboardShortcutsInitializer","plex/base/models/appModel","transition","dropdown","tooltip","button","modal"],function(e,t,i,n,s,a,r,o,l,c,d,u){"use strict";
var h=function(){new t(document.body);var h=[];h.push(i.init(u)),h.push(n.init()),e.when.apply(e,h).done(function(){s.init(),a.init(),r.init(),o.init(),l.init(),c.init(),d.init()})};return h});var SM2_DEFER=!0;!function(e,t){"use strict";function i(i,n){function s(e){return pt.preferFlash&&rt&&!pt.ignoreFlash&&pt.flash[e]!==t&&pt.flash[e]}function a(e){return function(t){var i,n=this._s;return i=n&&n._a?e.call(this,t):null}}this.setupOptions={url:i||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1e3,wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0,html5Test:/^(probably|maybe)$/i,preferFlash:!1,noSWFCache:!1,idPrefix:"sound"},this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100},this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null},this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null},this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},opus:{type:["audio/ogg; codecs=opus","audio/opus"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}},this.movieID="sm2-container",this.id=n||"sm2movie",this.debugID="soundmanager-debug",this.debugURLParam=/([#?&])debug=1/i,this.versionNumber="V2.97a.20140901",this.version=null,this.movieURL=null,this.altURL=null,this.swfLoaded=!1,this.enabled=!1,this.oMC=null,this.sounds={},this.soundIDs=[],this.muted=!1,this.didFlashBlock=!1,this.filePattern=null,this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i},this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1},this.sandbox={},this.html5={usingFlash:null},this.flash={},this.html5Only=!1,this.ignoreFlash=!1;
var r,o,l,c,d,u,h,p,m,f,g,v,y,b,w,x,k,S,C,P,A,_,I,T,M,D,E,L,R,O,N,F,B,U,V,z,j,q,H,W,$,Y,Q,K,X,G,J,Z,et,tt,it,nt,st,at,rt,ot,lt,ct,dt,ut,ht,pt=this,mt=null,ft=null,gt=navigator.userAgent,vt=e.location.href.toString(),yt=document,bt=[],wt=!1,xt=!1,kt=!1,St=!1,Ct=!1,Pt=8,At=null,_t=null,It=!1,Tt=!1,Mt=0,Dt=null,Et=[],Lt=null,Rt=Array.prototype.slice,Ot=!1,Nt=0,Ft=gt.match(/(ipad|iphone|ipod)/i),Bt=gt.match(/android/i),Ut=gt.match(/msie/i),Vt=gt.match(/webkit/i),zt=gt.match(/safari/i)&&!gt.match(/chrome/i),jt=gt.match(/opera/i),qt=gt.match(/(mobile|pre\/|xoom)/i)||Ft||Bt,Ht=!vt.match(/usehtml5audio/i)&&!vt.match(/sm2\-ignorebadua/i)&&zt&&!gt.match(/silk/i)&&gt.match(/OS X 10_6_([3-7])/i),Wt=(e.console!==t&&console.log!==t,yt.hasFocus!==t?yt.hasFocus():null),$t=zt&&(yt.hasFocus===t||!yt.hasFocus()),Yt=!$t,Qt=/(mp3|mp4|mpa|m4a|m4b)/i,Kt=1e3,Xt="about:blank",Gt="data:audio/wave;base64,/UklGRiYAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQIAAAD//w==",Jt=yt.location?yt.location.protocol.match(/http/i):null,Zt=Jt?"":"http://",ei=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,ti=["mpeg4","aac","flv","mov","mp4","m4v","f4v","m4a","m4b","mp4v","3gp","3g2"],ii=new RegExp("\\.("+ti.join("|")+")(\\?.*)?$","i");
this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i,this.useAltURL=!Jt,z={swfBox:"sm2-object-box",swfDefault:"movieContainer",swfError:"swf_error",swfTimedout:"swf_timedout",swfLoaded:"swf_loaded",swfUnblocked:"swf_unblocked",sm2Debug:"sm2_debug",highPerf:"high_performance",flashDebug:"flash_debug"},this.hasHTML5=function(){try{return Audio!==t&&(jt&&opera!==t&&opera.version()<10?new Audio(null):new Audio).canPlayType!==t}catch(e){return!1}}(),this.setup=function(e){var i=!pt.url;return e!==t&&kt&&Lt&&pt.ok()&&(e.flashVersion!==t||e.url!==t||e.html5Test!==t),m(e),e&&(i&&T&&e.url!==t&&pt.beginDelayedInit(),T||e.url===t||"complete"!==yt.readyState||setTimeout(_,1)),pt
},this.ok=function(){return Lt?kt&&!St:pt.useHTML5Audio&&pt.hasHTML5},this.supported=this.ok,this.getMovie=function(t){return o(t)||yt[t]||e[t]},this.createSound=function(e,i){function n(){return a=j(a),pt.sounds[a.id]=new r(a),pt.soundIDs.push(a.id),pt.sounds[a.id]}var s,a,o=null;if(!kt||!pt.ok())return!1;if(i!==t&&(e={id:e,url:i}),a=p(e),a.url=K(a.url),void 0===a.id&&(a.id=pt.setupOptions.idPrefix+Nt++),W(a.id,!0))return pt.sounds[a.id];if(J(a))o=n(),o._setup_html5(a);else{if(pt.html5Only)return n();
if(pt.html5.usingFlash&&a.url&&a.url.match(/data\:/i))return n();u>8&&null===a.isMovieStar&&(a.isMovieStar=!!(a.serverURL||(a.type?a.type.match(ei):!1)||a.url&&a.url.match(ii))),a=q(a,s),o=n(),8===u?ft._createSound(a.id,a.loops||1,a.usePolicyFile):(ft._createSound(a.id,a.url,a.usePeakData,a.useWaveformData,a.useEQData,a.isMovieStar,a.isMovieStar?a.bufferTime:!1,a.loops||1,a.serverURL,a.duration||null,a.autoPlay,!0,a.autoLoad,a.usePolicyFile),a.serverURL||(o.connected=!0,a.onconnect&&a.onconnect.apply(o))),a.serverURL||!a.autoLoad&&!a.autoPlay||o.load(a)
}return!a.serverURL&&a.autoPlay&&o.play(),o},this.destroySound=function(e,t){if(!W(e))return!1;var i,n=pt.sounds[e];for(n._iO={},n.stop(),n.unload(),i=0;i<pt.soundIDs.length;i++)if(pt.soundIDs[i]===e){pt.soundIDs.splice(i,1);break}return t||n.destruct(!0),n=null,delete pt.sounds[e],!0},this.load=function(e,t){return W(e)?pt.sounds[e].load(t):!1},this.unload=function(e){return W(e)?pt.sounds[e].unload():!1},this.onPosition=function(e,t,i,n){return W(e)?pt.sounds[e].onposition(t,i,n):!1},this.onposition=this.onPosition,this.clearOnPosition=function(e,t,i){return W(e)?pt.sounds[e].clearOnPosition(t,i):!1
},this.play=function(e,t){var i=null,n=t&&!(t instanceof Object);if(!kt||!pt.ok())return!1;if(W(e,n))n&&(t={url:t});else{if(!n)return!1;n&&(t={url:t}),t&&t.url&&(t.id=e,i=pt.createSound(t).play())}return null===i&&(i=pt.sounds[e].play(t)),i},this.start=this.play,this.setPosition=function(e,t){return W(e)?pt.sounds[e].setPosition(t):!1},this.stop=function(e){return W(e)?pt.sounds[e].stop():!1},this.stopAll=function(){var e;for(e in pt.sounds)pt.sounds.hasOwnProperty(e)&&pt.sounds[e].stop()},this.pause=function(e){return W(e)?pt.sounds[e].pause():!1
},this.pauseAll=function(){var e;for(e=pt.soundIDs.length-1;e>=0;e--)pt.sounds[pt.soundIDs[e]].pause()},this.resume=function(e){return W(e)?pt.sounds[e].resume():!1},this.resumeAll=function(){var e;for(e=pt.soundIDs.length-1;e>=0;e--)pt.sounds[pt.soundIDs[e]].resume()},this.togglePause=function(e){return W(e)?pt.sounds[e].togglePause():!1},this.setPan=function(e,t){return W(e)?pt.sounds[e].setPan(t):!1},this.setVolume=function(e,t){return W(e)?pt.sounds[e].setVolume(t):!1},this.mute=function(e){var t=0;
if(e instanceof String&&(e=null),e)return W(e)?pt.sounds[e].mute():!1;for(t=pt.soundIDs.length-1;t>=0;t--)pt.sounds[pt.soundIDs[t]].mute();return pt.muted=!0,!0},this.muteAll=function(){pt.mute()},this.unmute=function(e){var t;if(e instanceof String&&(e=null),e)return W(e)?pt.sounds[e].unmute():!1;for(t=pt.soundIDs.length-1;t>=0;t--)pt.sounds[pt.soundIDs[t]].unmute();return pt.muted=!1,!0},this.unmuteAll=function(){pt.unmute()},this.toggleMute=function(e){return W(e)?pt.sounds[e].toggleMute():!1},this.getMemoryUse=function(){var e=0;
return ft&&8!==u&&(e=parseInt(ft._getMemoryUse(),10)),e},this.disable=function(i){var n;if(i===t&&(i=!1),St)return!1;for(St=!0,n=pt.soundIDs.length-1;n>=0;n--)O(pt.sounds[pt.soundIDs[n]]);return h(i),st.remove(e,"load",y),!0},this.canPlayMIME=function(e){var t;return pt.hasHTML5&&(t=Z({type:e})),!t&&Lt&&(t=e&&pt.ok()?!!((u>8?e.match(ei):null)||e.match(pt.mimePattern)):null),t},this.canPlayURL=function(e){var t;return pt.hasHTML5&&(t=Z({url:e})),!t&&Lt&&(t=e&&pt.ok()?!!e.match(pt.filePattern):null),t
},this.canPlayLink=function(e){return e.type!==t&&e.type&&pt.canPlayMIME(e.type)?!0:pt.canPlayURL(e.href)},this.getSoundById=function(e){if(!e)return null;var t=pt.sounds[e];return t},this.onready=function(t,i){var n="onready",s=!1;if("function"!=typeof t)throw B("needFunction",n);return i||(i=e),g(n,t,i),v(),s=!0,s},this.ontimeout=function(t,i){var n="ontimeout",s=!1;if("function"!=typeof t)throw B("needFunction",n);return i||(i=e),g(n,t,i),v({type:n}),s=!0,s},this._writeDebug=function(){return!0
},this._wD=this._writeDebug,this._debug=function(){},this.reboot=function(t,i){var n,s,a;for(n=pt.soundIDs.length-1;n>=0;n--)pt.sounds[pt.soundIDs[n]].destruct();if(ft)try{Ut&&(_t=ft.innerHTML),At=ft.parentNode.removeChild(ft)}catch(r){}if(_t=At=Lt=ft=null,pt.enabled=T=kt=It=Tt=wt=xt=St=Ot=pt.swfLoaded=!1,pt.soundIDs=[],pt.sounds={},Nt=0,t)bt=[];else for(n in bt)if(bt.hasOwnProperty(n))for(s=0,a=bt[n].length;a>s;s++)bt[n][s].fired=!1;return pt.html5={usingFlash:null},pt.flash={},pt.html5Only=!1,pt.ignoreFlash=!1,e.setTimeout(function(){A(),i||pt.beginDelayedInit()
},20),pt},this.reset=function(){return pt.reboot(!0,!0)},this.getMoviePercent=function(){return ft&&"PercentLoaded"in ft?ft.PercentLoaded():null},this.beginDelayedInit=function(){Ct=!0,_(),setTimeout(function(){return Tt?!1:(D(),P(),Tt=!0,!0)},20),b()},this.destruct=function(){pt.disable(!0)},r=function(e){var i,n,s,a,r,o,l,c,d,h,m=this,f=!1,g=[],v=0,y=null;d={duration:null,time:null},this.id=e.id,this.sID=this.id,this.url=e.url,this.options=p(e),this.instanceOptions=this.options,this._iO=this.instanceOptions,this.pan=this.options.pan,this.volume=this.options.volume,this.isHTML5=!1,this._a=null,h=this.url?!1:!0,this.id3={},this._debug=function(){},this.load=function(e){var i,n=null;
if(e!==t?m._iO=p(e,m.options):(e=m.options,m._iO=e,y&&y!==m.url&&(m._iO.url=m.url,m.url=null)),m._iO.url||(m._iO.url=m.url),m._iO.url=K(m._iO.url),m.instanceOptions=m._iO,i=m._iO,!i.url&&!m.url)return m;if(i.url===m.url&&0!==m.readyState&&2!==m.readyState)return 3===m.readyState&&i.onload&&ht(m,function(){i.onload.apply(m,[!!m.duration])}),m;if(m.loaded=!1,m.readyState=1,m.playState=0,m.id3={},J(i))n=m._setup_html5(i),n._called_load||(m._html5_canplay=!1,m.url!==i.url&&(m._a.src=i.url,m.setPosition(0)),m._a.autobuffer="auto",m._a.preload="auto",m._a._called_load=!0);
else{if(pt.html5Only)return m;if(m._iO.url&&m._iO.url.match(/data\:/i))return m;try{m.isHTML5=!1,m._iO=q(j(i)),m._iO.autoPlay&&(m._iO.position||m._iO.from)&&(m._iO.autoPlay=!1),i=m._iO,8===u?ft._load(m.id,i.url,i.stream,i.autoPlay,i.usePolicyFile):ft._load(m.id,i.url,!!i.stream,!!i.autoPlay,i.loops||1,!!i.autoLoad,i.usePolicyFile)}catch(s){E({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:!0})}}return m.url=i.url,m},this.unload=function(){return 0!==m.readyState&&(m.isHTML5?(a(),m._a&&(m._a.pause(),y=tt(m._a))):8===u?ft._unload(m.id,Xt):ft._unload(m.id),i()),m
},this.destruct=function(e){m.isHTML5?(a(),m._a&&(m._a.pause(),tt(m._a),Ot||s(),m._a._s=null,m._a=null)):(m._iO.onfailure=null,ft._destroySound(m.id)),e||pt.destroySound(m.id,!0)},this.play=function(e,i){var n,s,a,l,d,g,v=!0,y=null;if(i=i===t?!0:i,e||(e={}),m.url&&(m._iO.url=m.url),m._iO=p(m._iO,m.options),m._iO=p(e,m._iO),m._iO.url=K(m._iO.url),m.instanceOptions=m._iO,!m.isHTML5&&m._iO.serverURL&&!m.connected)return m.getAutoPlay()||m.setAutoPlay(!0),m;if(J(m._iO)&&(m._setup_html5(m._iO),r()),1!==m.playState||m.paused||(n=m._iO.multiShot,n||(m.isHTML5&&m.setPosition(m._iO.position),y=m)),null!==y)return y;
if(e.url&&e.url!==m.url&&(m.readyState||m.isHTML5||8!==u||!h?m.load(m._iO):h=!1),m.loaded||(0===m.readyState?(m.isHTML5||pt.html5Only?m.isHTML5?m.load(m._iO):y=m:(m._iO.autoPlay=!0,m.load(m._iO)),m.instanceOptions=m._iO):2===m.readyState&&(y=m)),null!==y)return y;if(!m.isHTML5&&9===u&&m.position>0&&m.position===m.duration&&(e.position=0),m.paused&&m.position>=0&&(!m._iO.serverURL||m.position>0))m.resume();else{if(m._iO=p(e,m._iO),(!m.isHTML5&&null!==m._iO.position&&m._iO.position>0||null!==m._iO.from&&m._iO.from>0||null!==m._iO.to)&&0===m.instanceCount&&0===m.playState&&!m._iO.serverURL){if(a=function(){m._iO=p(e,m._iO),m.play(m._iO)
},m.isHTML5&&!m._html5_canplay?(m.load({_oncanplay:a}),y=!1):m.isHTML5||m.loaded||m.readyState&&2===m.readyState||(m.load({onload:a}),y=!1),null!==y)return y;m._iO=c()}(!m.instanceCount||m._iO.multiShotEvents||m.isHTML5&&m._iO.multiShot&&!Ot||!m.isHTML5&&u>8&&!m.getAutoPlay())&&m.instanceCount++,m._iO.onposition&&0===m.playState&&o(m),m.playState=1,m.paused=!1,m.position=m._iO.position===t||isNaN(m._iO.position)?0:m._iO.position,m.isHTML5||(m._iO=q(j(m._iO))),m._iO.onplay&&i&&(m._iO.onplay.apply(m),f=!0),m.setVolume(m._iO.volume,!0),m.setPan(m._iO.pan,!0),m.isHTML5?m.instanceCount<2?(r(),s=m._setup_html5(),m.setPosition(m._iO.position),s.play()):(l=new Audio(m._iO.url),d=function(){st.remove(l,"ended",d),m._onfinish(m),tt(l),l=null
},g=function(){st.remove(l,"canplay",g);try{l.currentTime=m._iO.position/Kt}catch(e){}l.play()},st.add(l,"ended",d),void 0!==m._iO.volume&&(l.volume=Math.max(0,Math.min(1,m._iO.volume/100))),m.muted&&(l.muted=!0),m._iO.position?st.add(l,"canplay",g):l.play()):(v=ft._start(m.id,m._iO.loops||1,9===u?m.position:m.position/Kt,m._iO.multiShot||!1),9!==u||v||m._iO.onplayerror&&m._iO.onplayerror.apply(m))}return m},this.start=this.play,this.stop=function(e){var t,i=m._iO;return 1===m.playState&&(m._onbufferchange(0),m._resetOnPosition(0),m.paused=!1,m.isHTML5||(m.playState=0),l(),i.to&&m.clearOnPosition(i.to),m.isHTML5?m._a&&(t=m.position,m.setPosition(0),m.position=t,m._a.pause(),m.playState=0,m._onTimer(),a()):(ft._stop(m.id,e),i.serverURL&&m.unload()),m.instanceCount=0,m._iO={},i.onstop&&i.onstop.apply(m)),m
},this.setAutoPlay=function(e){m._iO.autoPlay=e,m.isHTML5||(ft._setAutoPlay(m.id,e),e&&(m.instanceCount||1!==m.readyState||m.instanceCount++))},this.getAutoPlay=function(){return m._iO.autoPlay},this.setPosition=function(e){e===t&&(e=0);var i,n,s=m.isHTML5?Math.max(e,0):Math.min(m.duration||m._iO.duration,Math.max(e,0));if(m.position=s,n=m.position/Kt,m._resetOnPosition(m.position),m._iO.position=s,m.isHTML5){if(m._a){if(m._html5_canplay){if(m._a.currentTime!==n)try{m._a.currentTime=n,(0===m.playState||m.paused)&&m._a.pause()
}catch(a){}}else if(n)return m;m.paused&&m._onTimer(!0)}}else i=9===u?m.position:n,m.readyState&&2!==m.readyState&&ft._setPosition(m.id,i,m.paused||!m.playState,m._iO.multiShot);return m},this.pause=function(e){return m.paused||0===m.playState&&1!==m.readyState?m:(m.paused=!0,m.isHTML5?(m._setup_html5().pause(),a()):(e||e===t)&&ft._pause(m.id,m._iO.multiShot),m._iO.onpause&&m._iO.onpause.apply(m),m)},this.resume=function(){var e=m._iO;return m.paused?(m.paused=!1,m.playState=1,m.isHTML5?(m._setup_html5().play(),r()):(e.isMovieStar&&!e.serverURL&&m.setPosition(m.position),ft._pause(m.id,e.multiShot)),!f&&e.onplay?(e.onplay.apply(m),f=!0):e.onresume&&e.onresume.apply(m),m):m
},this.togglePause=function(){return 0===m.playState?(m.play({position:9!==u||m.isHTML5?m.position/Kt:m.position}),m):(m.paused?m.resume():m.pause(),m)},this.setPan=function(e,i){return e===t&&(e=0),i===t&&(i=!1),m.isHTML5||ft._setPan(m.id,e),m._iO.pan=e,i||(m.pan=e,m.options.pan=e),m},this.setVolume=function(e,i){return e===t&&(e=100),i===t&&(i=!1),m.isHTML5?m._a&&(pt.muted&&!m.muted&&(m.muted=!0,m._a.muted=!0),m._a.volume=Math.max(0,Math.min(1,e/100))):ft._setVolume(m.id,pt.muted&&!m.muted||m.muted?0:e),m._iO.volume=e,i||(m.volume=e,m.options.volume=e),m
},this.mute=function(){return m.muted=!0,m.isHTML5?m._a&&(m._a.muted=!0):ft._setVolume(m.id,0),m},this.unmute=function(){m.muted=!1;var e=m._iO.volume!==t;return m.isHTML5?m._a&&(m._a.muted=!1):ft._setVolume(m.id,e?m._iO.volume:m.options.volume),m},this.toggleMute=function(){return m.muted?m.unmute():m.mute()},this.onPosition=function(e,i,n){return g.push({position:parseInt(e,10),method:i,scope:n!==t?n:m,fired:!1}),m},this.onposition=this.onPosition,this.clearOnPosition=function(e,t){var i;if(e=parseInt(e,10),isNaN(e))return!1;
for(i=0;i<g.length;i++)e===g[i].position&&(t&&t!==g[i].method||(g[i].fired&&v--,g.splice(i,1)))},this._processOnPosition=function(){var e,t,i=g.length;if(!i||!m.playState||v>=i)return!1;for(e=i-1;e>=0;e--)t=g[e],!t.fired&&m.position>=t.position&&(t.fired=!0,v++,t.method.apply(t.scope,[t.position]),i=g.length);return!0},this._resetOnPosition=function(e){var t,i,n=g.length;if(!n)return!1;for(t=n-1;t>=0;t--)i=g[t],i.fired&&e<=i.position&&(i.fired=!1,v--);return!0},c=function(){var e,t,i=m._iO,n=i.from,s=i.to;
return t=function(){m.clearOnPosition(s,t),m.stop()},e=function(){null===s||isNaN(s)||m.onPosition(s,t)},null===n||isNaN(n)||(i.position=n,i.multiShot=!1,e()),i},o=function(){var e,t=m._iO.onposition;if(t)for(e in t)t.hasOwnProperty(e)&&m.onPosition(parseInt(e,10),t[e])},l=function(){var e,t=m._iO.onposition;if(t)for(e in t)t.hasOwnProperty(e)&&m.clearOnPosition(parseInt(e,10))},r=function(){m.isHTML5&&$(m)},a=function(){m.isHTML5&&Y(m)},i=function(e){e||(g=[],v=0),f=!1,m._hasTimer=null,m._a=null,m._html5_canplay=!1,m.bytesLoaded=null,m.bytesTotal=null,m.duration=m._iO&&m._iO.duration?m._iO.duration:null,m.durationEstimate=null,m.buffered=[],m.eqData=[],m.eqData.left=[],m.eqData.right=[],m.failures=0,m.isBuffering=!1,m.instanceOptions={},m.instanceCount=0,m.loaded=!1,m.metadata={},m.readyState=0,m.muted=!1,m.paused=!1,m.peakData={left:0,right:0},m.waveformData={left:[],right:[]},m.playState=0,m.position=null,m.id3={}
},i(),this._onTimer=function(e){var t,i,n=!1,s={};return m._hasTimer||e?(m._a&&(e||(m.playState>0||1===m.readyState)&&!m.paused)&&(t=m._get_html5_duration(),t!==d.duration&&(d.duration=t,m.duration=t,n=!0),m.durationEstimate=m.duration,i=m._a.currentTime*Kt||0,i!==d.time&&(d.time=i,n=!0),(n||e)&&m._whileplaying(i,s,s,s,s)),n):void 0},this._get_html5_duration=function(){var e=m._iO,t=m._a&&m._a.duration?m._a.duration*Kt:e&&e.duration?e.duration:null,i=t&&!isNaN(t)&&1/0!==t?t:null;return i},this._apply_loop=function(e,t){e.loop=t>1?"loop":""
},this._setup_html5=function(e){var t,s=p(m._iO,e),a=Ot?mt:m._a,r=decodeURI(s.url);if(Ot?r===decodeURI(at)&&(t=!0):r===decodeURI(y)&&(t=!0),a){if(a._s)if(Ot)a._s&&a._s.playState&&!t&&a._s.stop();else if(!Ot&&r===decodeURI(y))return m._apply_loop(a,s.loops),a;t||(y&&i(!1),a.src=s.url,m.url=s.url,y=s.url,at=s.url,a._called_load=!1)}else s.autoLoad||s.autoPlay?(m._a=new Audio(s.url),m._a.load()):m._a=jt&&opera.version()<10?new Audio(null):new Audio,a=m._a,a._called_load=!1,Ot&&(mt=a);return m.isHTML5=!0,m._a=a,a._s=m,n(),m._apply_loop(a,s.loops),s.autoLoad||s.autoPlay?m.load():(a.autobuffer=!1,a.preload="auto"),a
},n=function(){function e(e,t,i){return m._a?m._a.addEventListener(e,t,i||!1):null}if(m._a._added_events)return!1;var t;m._a._added_events=!0;for(t in ct)ct.hasOwnProperty(t)&&e(t,ct[t]);return!0},s=function(){function e(e,t,i){return m._a?m._a.removeEventListener(e,t,i||!1):null}var t;m._a._added_events=!1;for(t in ct)ct.hasOwnProperty(t)&&e(t,ct[t])},this._onload=function(e){var t=!!e||!m.isHTML5&&8===u&&m.duration;return m.loaded=t,m.readyState=t?3:2,m._onbufferchange(0),m._iO.onload&&ht(m,function(){m._iO.onload.apply(m,[t])
}),!0},this._onbufferchange=function(e){return 0===m.playState?!1:e&&m.isBuffering||!e&&!m.isBuffering?!1:(m.isBuffering=1===e,m._iO.onbufferchange&&m._iO.onbufferchange.apply(m,[e]),!0)},this._onsuspend=function(){return m._iO.onsuspend&&m._iO.onsuspend.apply(m),!0},this._onfailure=function(e,t,i){m.failures++,m._iO.onfailure&&1===m.failures&&m._iO.onfailure(e,t,i)},this._onwarning=function(e,t,i){m._iO.onwarning&&m._iO.onwarning(e,t,i)},this._onfinish=function(){var e=m._iO.onfinish;m._onbufferchange(0),m._resetOnPosition(0),m.instanceCount&&(m.instanceCount--,m.instanceCount||(l(),m.playState=0,m.paused=!1,m.instanceCount=0,m.instanceOptions={},m._iO={},a(),m.isHTML5&&(m.position=0)),(!m.instanceCount||m._iO.multiShotEvents)&&e&&ht(m,function(){e.apply(m)
}))},this._whileloading=function(e,t,i,n){var s=m._iO;m.bytesLoaded=e,m.bytesTotal=t,m.duration=Math.floor(i),m.bufferLength=n,m.durationEstimate=m.isHTML5||s.isMovieStar?m.duration:s.duration?m.duration>s.duration?m.duration:s.duration:parseInt(m.bytesTotal/m.bytesLoaded*m.duration,10),m.isHTML5||(m.buffered=[{start:0,end:m.duration}]),(3!==m.readyState||m.isHTML5)&&s.whileloading&&s.whileloading.apply(m)},this._whileplaying=function(e,i,n,s,a){var r,o=m._iO;return isNaN(e)||null===e?!1:(m.position=Math.max(0,e),m._processOnPosition(),!m.isHTML5&&u>8&&(o.usePeakData&&i!==t&&i&&(m.peakData={left:i.leftPeak,right:i.rightPeak}),o.useWaveformData&&n!==t&&n&&(m.waveformData={left:n.split(","),right:s.split(",")}),o.useEQData&&a!==t&&a&&a.leftEQ&&(r=a.leftEQ.split(","),m.eqData=r,m.eqData.left=r,a.rightEQ!==t&&a.rightEQ&&(m.eqData.right=a.rightEQ.split(",")))),1===m.playState&&(m.isHTML5||8!==u||m.position||!m.isBuffering||m._onbufferchange(0),o.whileplaying&&o.whileplaying.apply(m)),!0)
},this._oncaptiondata=function(e){m.captiondata=e,m._iO.oncaptiondata&&m._iO.oncaptiondata.apply(m,[e])},this._onmetadata=function(e,t){var i,n,s={};for(i=0,n=e.length;n>i;i++)s[e[i]]=t[i];m.metadata=s,m._iO.onmetadata&&m._iO.onmetadata.call(m,m.metadata)},this._onid3=function(e,t){var i,n,s=[];for(i=0,n=e.length;n>i;i++)s[e[i]]=t[i];m.id3=p(m.id3,s),m._iO.onid3&&m._iO.onid3.apply(m)},this._onconnect=function(e){e=1===e,m.connected=e,e&&(m.failures=0,W(m.id)&&(m.getAutoPlay()?m.play(t,m.getAutoPlay()):m._iO.autoLoad&&m.load()),m._iO.onconnect&&m._iO.onconnect.apply(m,[e]))
},this._ondataerror=function(){m.playState>0&&m._iO.ondataerror&&m._iO.ondataerror.apply(m)}},M=function(){return yt.body||yt.getElementsByTagName("div")[0]},o=function(e){return yt.getElementById(e)},p=function(e,i){var n,s,a=e||{};n=i===t?pt.defaultOptions:i;for(s in n)n.hasOwnProperty(s)&&a[s]===t&&(a[s]="object"!=typeof n[s]||null===n[s]?n[s]:p(a[s],n[s]));return a},ht=function(t,i){t.isHTML5||8!==u?i():e.setTimeout(i,0)},f={onready:1,ontimeout:1,defaultOptions:1,flash9Options:1,movieStarOptions:1},m=function(e,i){var n,s=!0,a=i!==t,r=pt.setupOptions,o=f;
for(n in e)if(e.hasOwnProperty(n))if("object"!=typeof e[n]||null===e[n]||e[n]instanceof Array||e[n]instanceof RegExp)a&&o[i]!==t?pt[i][n]=e[n]:r[n]!==t?(pt.setupOptions[n]=e[n],pt[n]=e[n]):o[n]===t?s=!1:pt[n]instanceof Function?pt[n].apply(pt,e[n]instanceof Array?e[n]:[e[n]]):pt[n]=e[n];else{if(o[n]!==t)return m(e[n],n);s=!1}return s},st=function(){function t(e){var t=Rt.call(e),i=t.length;return a?(t[1]="on"+t[1],i>3&&t.pop()):3===i&&t.push(!1),t}function i(e,t){var i=e.shift(),n=[r[t]];a?i[n](e[0],e[1]):i[n].apply(i,e)
}function n(){i(t(arguments),"add")}function s(){i(t(arguments),"remove")}var a=e.attachEvent,r={add:a?"attachEvent":"addEventListener",remove:a?"detachEvent":"removeEventListener"};return{add:n,remove:s}}(),ct={abort:a(function(){}),canplay:a(function(){var e,i=this._s;if(i._html5_canplay)return!0;if(i._html5_canplay=!0,i._onbufferchange(0),e=i._iO.position===t||isNaN(i._iO.position)?null:i._iO.position/Kt,this.currentTime!==e)try{this.currentTime=e}catch(n){}i._iO._oncanplay&&i._iO._oncanplay()
}),canplaythrough:a(function(){var e=this._s;e.loaded||(e._onbufferchange(0),e._whileloading(e.bytesLoaded,e.bytesTotal,e._get_html5_duration()),e._onload(!0))}),durationchange:a(function(){var e,t=this._s;e=t._get_html5_duration(),isNaN(e)||e===t.duration||(t.durationEstimate=t.duration=e)}),ended:a(function(){var e=this._s;e._onfinish()}),error:a(function(){this._s._onload(!1)}),loadeddata:a(function(){var e=this._s;e._loaded||zt||(e.duration=e._get_html5_duration())}),loadedmetadata:a(function(){}),loadstart:a(function(){this._s._onbufferchange(1)
}),play:a(function(){this._s._onbufferchange(0)}),playing:a(function(){this._s._onbufferchange(0)}),progress:a(function(e){var t,i,n=this._s,s=0,a=("progress"===e.type,e.target.buffered),r=e.loaded||0,o=e.total||1;if(n.buffered=[],a&&a.length){for(t=0,i=a.length;i>t;t++)n.buffered.push({start:a.start(t)*Kt,end:a.end(t)*Kt});s=(a.end(0)-a.start(0))*Kt,r=Math.min(1,s/(e.target.duration*Kt))}isNaN(r)||(n._whileloading(r,o,n._get_html5_duration()),r&&o&&r===o&&ct.canplaythrough.call(this,e))}),ratechange:a(function(){}),suspend:a(function(e){var t=this._s;
ct.progress.call(this,e),t._onsuspend()}),stalled:a(function(){}),timeupdate:a(function(){this._s._onTimer()}),waiting:a(function(){var e=this._s;e._onbufferchange(1)})},J=function(e){var t;return t=e&&(e.type||e.url||e.serverURL)?e.serverURL||e.type&&s(e.type)?!1:e.type?Z({type:e.type}):Z({url:e.url})||pt.html5Only||e.url.match(/data\:/i):!1},tt=function(e){var t;return e&&(t=zt?Xt:pt.html5.canPlayType("audio/wav")?Gt:Xt,e.src=t,void 0!==e._called_unload&&(e._called_load=!1)),Ot&&(at=null),t},Z=function(e){if(!pt.useHTML5Audio||!pt.hasHTML5)return!1;
var i,n,a,r,o=e.url||null,l=e.type||null,c=pt.audioFormats;if(l&&pt.html5[l]!==t)return pt.html5[l]&&!s(l);if(!et){et=[];for(r in c)c.hasOwnProperty(r)&&(et.push(r),c[r].related&&(et=et.concat(c[r].related)));et=new RegExp("\\.("+et.join("|")+")(\\?.*)?$","i")}return a=o?o.toLowerCase().match(et):null,a&&a.length?a=a[1]:l?(n=l.indexOf(";"),a=(-1!==n?l.substr(0,n):l).substr(6)):i=!1,a&&pt.html5[a]!==t?i=pt.html5[a]&&!s(a):(l="audio/"+a,i=pt.html5.canPlayType({type:l}),pt.html5[a]=i,i=i&&pt.html5[l]&&!s(l)),i
},nt=function(){function e(e){var t,i,n=!1,s=!1;if(!r||"function"!=typeof r.canPlayType)return n;if(e instanceof Array){for(a=0,i=e.length;i>a;a++)(pt.html5[e[a]]||r.canPlayType(e[a]).match(pt.html5Test))&&(s=!0,pt.html5[e[a]]=!0,pt.flash[e[a]]=!!e[a].match(Qt));n=s}else t=r&&"function"==typeof r.canPlayType?r.canPlayType(e):!1,n=!(!t||!t.match(pt.html5Test));return n}if(!pt.useHTML5Audio||!pt.hasHTML5)return pt.html5.usingFlash=!0,Lt=!0,!1;var i,n,s,a,r=Audio!==t?jt&&opera.version()<10?new Audio(null):new Audio:null,o={};
s=pt.audioFormats;for(i in s)if(s.hasOwnProperty(i)&&(n="audio/"+i,o[i]=e(s[i].type),o[n]=o[i],i.match(Qt)?(pt.flash[i]=!0,pt.flash[n]=!0):(pt.flash[i]=!1,pt.flash[n]=!1),s[i]&&s[i].related))for(a=s[i].related.length-1;a>=0;a--)o["audio/"+s[i].related[a]]=o[i],pt.html5[s[i].related[a]]=o[i],pt.flash[s[i].related[a]]=o[i];return o.canPlayType=r?e:null,pt.html5=p(pt.html5,o),pt.html5.usingFlash=G(),Lt=pt.html5.usingFlash,!0},C={},B=function(){},j=function(e){return 8===u&&e.loops>1&&e.stream&&(e.stream=!1),e
},q=function(e){return e&&!e.usePolicyFile&&(e.onid3||e.usePeakData||e.useWaveformData||e.useEQData)&&(e.usePolicyFile=!0),e},H=function(){},l=function(){return!1},O=function(e){var t;for(t in e)e.hasOwnProperty(t)&&"function"==typeof e[t]&&(e[t]=l);t=null},N=function(e){e===t&&(e=!1),(St||e)&&pt.disable(e)},F=function(e){var t,i=null;if(e)if(e.match(/\.swf(\?.*)?$/i)){if(i=e.substr(e.toLowerCase().lastIndexOf(".swf?")+4))return e}else e.lastIndexOf("/")!==e.length-1&&(e+="/");return t=(e&&-1!==e.lastIndexOf("/")?e.substr(0,e.lastIndexOf("/")+1):"./")+pt.movieURL,pt.noSWFCache&&(t+="?ts="+(new Date).getTime()),t
},k=function(){u=parseInt(pt.flashVersion,10),8!==u&&9!==u&&(pt.flashVersion=u=Pt);var e=pt.debugMode||pt.debugFlash?"_debug.swf":".swf";pt.useHTML5Audio&&!pt.html5Only&&pt.audioFormats.mp4.required&&9>u&&(pt.flashVersion=u=9),pt.version=pt.versionNumber+(pt.html5Only?" (HTML5-only mode)":9===u?" (AS3/Flash 9)":" (AS2/Flash 8)"),u>8?(pt.defaultOptions=p(pt.defaultOptions,pt.flash9Options),pt.features.buffering=!0,pt.defaultOptions=p(pt.defaultOptions,pt.movieStarOptions),pt.filePatterns.flash9=new RegExp("\\.(mp3|"+ti.join("|")+")(\\?.*)?$","i"),pt.features.movieStar=!0):pt.features.movieStar=!1,pt.filePattern=pt.filePatterns[8!==u?"flash9":"flash8"],pt.movieURL=(8===u?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",e),pt.features.peakData=pt.features.waveformData=pt.features.eqData=u>8
},L=function(e,t){return ft?void ft._setPolling(e,t):!1},R=function(){},W=this.getSoundById,V=function(){var e=[];return pt.debugMode&&e.push(z.sm2Debug),pt.debugFlash&&e.push(z.flashDebug),pt.useHighPerformance&&e.push(z.highPerf),e.join(" ")},U=function(){var e=(B("fbHandler"),pt.getMoviePercent()),t=z,i={type:"FLASHBLOCK"};return pt.html5Only?!1:void(pt.ok()?pt.oMC&&(pt.oMC.className=[V(),t.swfDefault,t.swfLoaded+(pt.didFlashBlock?" "+t.swfUnblocked:"")].join(" ")):(Lt&&(pt.oMC.className=V()+" "+t.swfDefault+" "+(null===e?t.swfTimedout:t.swfError)),pt.didFlashBlock=!0,v({type:"ontimeout",ignoreInit:!0,error:i}),E(i)))
},g=function(e,i,n){bt[e]===t&&(bt[e]=[]),bt[e].push({method:i,scope:n||null,fired:!1})},v=function(e){if(e||(e={type:pt.ok()?"onready":"ontimeout"}),!kt&&e&&!e.ignoreInit)return!1;if("ontimeout"===e.type&&(pt.ok()||St&&!e.ignoreInit))return!1;var t,i,n={success:e&&e.ignoreInit?pt.ok():!St},s=e&&e.type?bt[e.type]||[]:[],a=[],r=[n],o=Lt&&!pt.ok();for(e.error&&(r[0].error=e.error),t=0,i=s.length;i>t;t++)s[t].fired!==!0&&a.push(s[t]);if(a.length)for(t=0,i=a.length;i>t;t++)a[t].scope?a[t].method.apply(a[t].scope,r):a[t].method.apply(this,r),o||(a[t].fired=!0);
return!0},y=function(){e.setTimeout(function(){pt.useFlashBlock&&U(),v(),"function"==typeof pt.onload&&pt.onload.apply(e),pt.waitForWindowLoad&&st.add(e,"load",y)},1)},ot=function(){if(rt!==t)return rt;var i,n,s,a=!1,r=navigator,o=r.plugins,l=e.ActiveXObject;if(o&&o.length)n="application/x-shockwave-flash",s=r.mimeTypes,s&&s[n]&&s[n].enabledPlugin&&s[n].enabledPlugin.description&&(a=!0);else if(l!==t&&!gt.match(/MSAppHost/i)){try{i=new l("ShockwaveFlash.ShockwaveFlash")}catch(c){i=null}a=!!i,i=null
}return rt=a,a},G=function(){var e,t,i=pt.audioFormats,n=Ft&&!!gt.match(/os (1|2|3_0|3_1)\s/i);if(n?(pt.hasHTML5=!1,pt.html5Only=!0,pt.oMC&&(pt.oMC.style.display="none")):pt.useHTML5Audio&&(pt.html5&&pt.html5.canPlayType||(pt.hasHTML5=!1)),pt.useHTML5Audio&&pt.hasHTML5){X=!0;for(t in i)i.hasOwnProperty(t)&&i[t].required&&(pt.html5.canPlayType(i[t].type)?pt.preferFlash&&(pt.flash[t]||pt.flash[i[t].type])&&(e=!0):(X=!1,e=!0))}return pt.ignoreFlash&&(e=!1,X=!0),pt.html5Only=pt.hasHTML5&&pt.useHTML5Audio&&!e,!pt.html5Only
},K=function(e){var t,i,n,s=0;if(e instanceof Array){for(t=0,i=e.length;i>t;t++)if(e[t]instanceof Object){if(pt.canPlayMIME(e[t].type)){s=t;break}}else if(pt.canPlayURL(e[t])){s=t;break}e[s].url&&(e[s]=e[s].url),n=e[s]}else n=e;return n},$=function(e){e._hasTimer||(e._hasTimer=!0,!qt&&pt.html5PollingInterval&&(null===Dt&&0===Mt&&(Dt=setInterval(Q,pt.html5PollingInterval)),Mt++))},Y=function(e){e._hasTimer&&(e._hasTimer=!1,!qt&&pt.html5PollingInterval&&Mt--)},Q=function(){var e;if(null!==Dt&&!Mt)return clearInterval(Dt),Dt=null,!1;
for(e=pt.soundIDs.length-1;e>=0;e--)pt.sounds[pt.soundIDs[e]].isHTML5&&pt.sounds[pt.soundIDs[e]]._hasTimer&&pt.sounds[pt.soundIDs[e]]._onTimer()},E=function(i){i=i!==t?i:{},"function"==typeof pt.onerror&&pt.onerror.apply(e,[{type:i.type!==t?i.type:null}]),i.fatal!==t&&i.fatal&&pt.disable()},lt=function(){if(!Ht||!ot())return!1;var e,t,i=pt.audioFormats;for(t in i)if(i.hasOwnProperty(t)&&("mp3"===t||"mp4"===t)&&(pt.html5[t]=!1,i[t]&&i[t].related))for(e=i[t].related.length-1;e>=0;e--)pt.html5[i[t].related[e]]=!1
},this._setSandboxType=function(){},this._externalInterfaceOK=function(){if(pt.swfLoaded)return!1;pt.swfLoaded=!0,$t=!1,Ht&&lt(),setTimeout(d,Ut?100:1)},D=function(e,i){function n(){}function s(e,t){return'<param name="'+e+'" value="'+t+'" />'}if(wt&&xt)return!1;if(pt.html5Only)return k(),n(),pt.oMC=o(pt.movieID),d(),wt=!0,xt=!0,!1;var a,r,l,c,u,h,p,m,f=i||pt.url,g=pt.altURL||f,v="JS/Flash audio component (SoundManager 2)",y=M(),b=V(),w=null,x=yt.getElementsByTagName("html")[0];if(w=x&&x.dir&&x.dir.match(/rtl/i),e=e===t?pt.id:e,k(),pt.url=F(Jt?f:g),i=pt.url,pt.wmode=!pt.wmode&&pt.useHighPerformance?"transparent":pt.wmode,null!==pt.wmode&&(gt.match(/msie 8/i)||!Ut&&!pt.useHighPerformance)&&navigator.platform.match(/win32|win64/i)&&(Et.push(C.spcWmode),pt.wmode=null),a={name:e,id:e,src:i,quality:"high",allowScriptAccess:pt.allowScriptAccess,bgcolor:pt.bgColor,pluginspage:Zt+"www.macromedia.com/go/getflashplayer",title:v,type:"application/x-shockwave-flash",wmode:pt.wmode,hasPriority:"true"},pt.debugFlash&&(a.FlashVars="debug=1"),pt.wmode||delete a.wmode,Ut)r=yt.createElement("div"),c=['<object id="'+e+'" data="'+i+'" type="'+a.type+'" title="'+a.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+Zt+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">',s("movie",i),s("AllowScriptAccess",pt.allowScriptAccess),s("quality",a.quality),pt.wmode?s("wmode",pt.wmode):"",s("bgcolor",pt.bgColor),s("hasPriority","true"),pt.debugFlash?s("FlashVars",a.FlashVars):"","</object>"].join("");
else{r=yt.createElement("embed");for(l in a)a.hasOwnProperty(l)&&r.setAttribute(l,a[l])}if(R(),b=V(),y=M())if(pt.oMC=o(pt.movieID)||yt.createElement("div"),pt.oMC.id)m=pt.oMC.className,pt.oMC.className=(m?m+" ":z.swfDefault)+(b?" "+b:""),pt.oMC.appendChild(r),Ut&&(u=pt.oMC.appendChild(yt.createElement("div")),u.className=z.swfBox,u.innerHTML=c),xt=!0;else{if(pt.oMC.id=pt.movieID,pt.oMC.className=z.swfDefault+" "+b,h=null,u=null,pt.useFlashBlock||(pt.useHighPerformance?h={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"}:(h={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},w&&(h.left=Math.abs(parseInt(h.left,10))+"px"))),Vt&&(pt.oMC.style.zIndex=1e4),!pt.debugFlash)for(p in h)h.hasOwnProperty(p)&&(pt.oMC.style[p]=h[p]);
try{Ut||pt.oMC.appendChild(r),y.appendChild(pt.oMC),Ut&&(u=pt.oMC.appendChild(yt.createElement("div")),u.className=z.swfBox,u.innerHTML=c),xt=!0}catch(S){throw new Error(B("domError")+" \n"+S.toString())}}return wt=!0,n(),!0},P=function(){return pt.html5Only?(D(),!1):ft?!1:pt.url?(ft=pt.getMovie(pt.id),ft||(At?(Ut?pt.oMC.innerHTML=_t:pt.oMC.appendChild(At),At=null,wt=!0):D(pt.id,pt.url),ft=pt.getMovie(pt.id)),"function"==typeof pt.oninitmovie&&setTimeout(pt.oninitmovie,1),!0):!1},b=function(){setTimeout(w,1e3)
},x=function(){e.setTimeout(function(){pt.setup({preferFlash:!1}).reboot(),pt.didFlashBlock=!0,pt.beginDelayedInit()},1)},w=function(){var t,i=!1;return pt.url?It?!1:(It=!0,st.remove(e,"load",b),rt&&$t&&!Wt?!1:(kt||(t=pt.getMoviePercent(),t>0&&100>t&&(i=!0)),void setTimeout(function(){return t=pt.getMoviePercent(),i?(It=!1,e.setTimeout(b,1),!1):void(!kt&&Yt&&(null===t?pt.useFlashBlock||0===pt.flashLoadTimeout?pt.useFlashBlock&&U():!pt.useFlashBlock&&X?x():v({type:"ontimeout",ignoreInit:!0,error:{type:"INIT_FLASHBLOCK"}}):0===pt.flashLoadTimeout||(!pt.useFlashBlock&&X?x():N(!0))))
},pt.flashLoadTimeout))):!1},S=function(){function t(){st.remove(e,"focus",S)}return Wt||!$t?(t(),!0):(Yt=!0,Wt=!0,It=!1,b(),t(),!0)},ut=function(){},dt=function(){},h=function(t){if(kt)return!1;if(pt.html5Only)return kt=!0,y(),!0;var i,n=pt.useFlashBlock&&pt.flashLoadTimeout&&!pt.getMoviePercent(),s=!0;return n||(kt=!0),i={type:!rt&&Lt?"NO_FLASH":"INIT_TIMEOUT"},(St||t)&&(pt.useFlashBlock&&pt.oMC&&(pt.oMC.className=V()+" "+(null===pt.getMoviePercent()?z.swfTimedout:z.swfError)),v({type:"ontimeout",error:i,ignoreInit:!0}),E(i),s=!1),St||(pt.waitForWindowLoad&&!Ct?st.add(e,"load",y):y()),s
},c=function(){var e,i=pt.setupOptions;for(e in i)i.hasOwnProperty(e)&&(pt[e]===t?pt[e]=i[e]:pt[e]!==i[e]&&(pt.setupOptions[e]=pt[e]))},d=function(){function t(){st.remove(e,"load",pt.beginDelayedInit)}if(kt)return!1;if(pt.html5Only)return kt||(t(),pt.enabled=!0,h()),!0;P();try{ft._externalInterfaceTest(!1),L(!0,pt.flashPollingInterval||(pt.useHighPerformance?10:50)),pt.debugMode||ft._disableDebug(),pt.enabled=!0,pt.html5Only||st.add(e,"unload",l)}catch(i){return E({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),N(!0),h(),!1
}return h(),t(),!0},_=function(){return T?!1:(T=!0,c(),R(),!rt&&pt.hasHTML5&&pt.setup({useHTML5Audio:!0,preferFlash:!1}),nt(),!rt&&Lt&&(Et.push(C.needFlash),pt.setup({flashLoadTimeout:1})),yt.removeEventListener&&yt.removeEventListener("DOMContentLoaded",_,!1),P(),!0)},it=function(){return"complete"===yt.readyState&&(_(),yt.detachEvent("onreadystatechange",it)),!0},I=function(){Ct=!0,_(),st.remove(e,"load",I)},A=function(){qt&&(pt.setupOptions.useHTML5Audio=!0,pt.setupOptions.preferFlash=!1,(Ft||Bt&&!gt.match(/android\s2\.3/i))&&(Ft&&(pt.ignoreFlash=!0),Ot=!0))
},A(),ot(),st.add(e,"focus",S),st.add(e,"load",b),st.add(e,"load",I),yt.addEventListener?yt.addEventListener("DOMContentLoaded",_,!1):yt.attachEvent?yt.attachEvent("onreadystatechange",it):E({type:"NO_DOM2_EVENTS",fatal:!0})}if(!e||!e.document)throw new Error("SoundManager requires a browser with window and document objects.");var n=null;void 0!==e.SM2_DEFER&&SM2_DEFER||(n=new i),"object"==typeof module&&module&&"object"==typeof module.exports?(e.soundManager=n,module.exports.SoundManager=i,module.exports.soundManager=n):"function"==typeof define&&define.amd?define("soundmanager-lib",[],function(){return e.SoundManager=i,e.soundManager=n,n
}):(e.SoundManager=i,e.soundManager=n)}(window),define("soundmanager",["soundmanager-lib","plex/base/models/config"],function(e,t){"use strict";return e=new SoundManager,window.soundManager=e,e.url="swf/soundmanager",e.debugMode=!1,e.preferFlash=t.get("flash"),e.flashVersion=9,e.flashLoadTimeout=2e3,e.useFastPolling=!0,e.useHighPerformance=!0,e.beginDelayedInit(),e}),define("plex/desktop/commands/library/playSoundCommand",["underscore","soundmanager"],function(e,t){"use strict";function i(){l&&(l.destruct(),l=null)
}function n(){var e=setInterval(function(){return l?(l.setVolume(l.volume-5),void(l.volume<=0&&(clearInterval(e),i()))):void clearInterval(e)},50)}function s(n){n.onfinish=n.onfinish?e.wrap(n.onfinish,function(e){i(),e()}):i,n.id=n.url,l=t.createSound(n),l.key=n.key,l.background=!!n.background,n.oncreate&&n.oncreate(l)}function a(e){if(l&&e.background){if(!l.background)return;if(l.url===e.url)return void(l.key=e.key)}i(),t.preferFlash&&!t.swfLoaded?(t.preferFlash=!1,t.onready(function(){s(e)}),t.reboot()):s(e)
}function r(e){l&&(e.key&&e.key!==l.key||(l.background?n():e.background||i()))}function o(e){e||(e={}),e.stop?r(e):a(e)}var l;return o}),define("plex/desktop/commands/library/refreshMetadataCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/LibraryFailureModal"],function(e,t,i,n,s){"use strict";function a(a){var r,o;return a.item?(r=a.item,o=[r]):(o=a.items,r=o[0]),t.when.apply(t,e.map(o,function(i){var n="/library/metadata/"+i.id+"/refresh",s=e.extend(r.server.getXHROptions(n),{type:"PUT"});
return t.ajax(s).promise()})).fail(function(e){503===e.status?n.trigger("show:modal",new s({model:r.server})):n.trigger("show:alert",{type:"error",message:i("There was a problem refreshing.")})})}return a}),define("plex/desktop/commands/library/analyzeItemsCommand",["underscore","jquery"],function(e,t){"use strict";function i(i){var n=i.items;return t.when.apply(t,e.map(n,function(i){var n="/library/metadata/"+i.id+"/analyze",s=e.extend(i.server.getXHROptions(n),{type:"PUT"});return t.ajax(s).promise()
}))}return i}),define("plex/desktop/commands/library/analyzeSectionCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";function a(a){function r(){var e=t.ajax(d);e.done(function(){o.resolve()}),e.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem analyzing the library.")}),o.reject(e)}),e.always(function(){u.hide()})}var o=t.Deferred(),l=a.section,c="/library/sections/"+l.id+"/analyze",d=e.extend(l.server.getXHROptions(c),{type:"PUT"}),u=new s({title:i("Analyze Library"),message:i("Analyzes all the media files in the library. The analysis captures information about the media which helps Plex decide how to optimally play back the media."),confirmLabel:i("Analyze"),cancelLabel:i("Cancel"),async:!0}),h=u.promise;
return h.done(r),h.fail(function(){o.reject()}),n.trigger("show:modal",u),o.promise()}return a}),define("plex/desktop/commands/library/markWatchedCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a){"use strict";function r(r){function c(){var s=e(u).map(function(e){var i="/:/scrobble?key="+encodeURIComponent(e.get("ratingKey"))+"&identifier="+e.get("identifier"),n=t.ajax(d.server.getXHROptions(i));
return n.done(function(){l(e),o(e)}),n}),a=t.when.apply(t,s);a.done(function(){h.resolve()}),a.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem marking this item as watched.")}),h.reject()})}var d,u,h=t.Deferred();r.item?(d=r.item,u=[d]):r.items&&(u=r.items,d=u[0]);var p=d.get("type"),m=s.getMediaTypeByString(p),f=m&&"directory"===m.element,g=(f||u.length>1)&&!r.force,v=1===u.length,y=v&&d.get("isSection")?d.getSyncTitle():d.get("title");if(g){var b;switch(d.get("type")){case"movie":b=v?i("Are you sure you want to mark {1} as watched?",y):i("Are you sure you want to mark these movies as watched?");
break;case"show":case"season":case"episode":b=v?i("Are you sure you want to mark all episodes of {1} as watched?",y):i("Are you sure you want to mark these episodes as watched?");break;default:b=v?i("Are you sure you want to mark {1} as watched?",y):i("Are you sure you want to mark these items as watched?")}var w=new a({title:i("Mark as Watched"),message:b}),x=w.promise;x.done(c),x.fail(function(){h.reject()}),n.trigger("show:modal",w)}else c();return h.promise()}function o(e){var t=s.getMediaTypeByString(e.get("type"));
if(!t||"directory"!==t.element)return void e.set({viewOffset:0,viewCount:1});e.set({unviewedLeafCount:0,viewedLeafCount:e.get("leafCount")});var i=e.get("children")||e.get("items");i&&i.each(o)}function l(e){var t=s.getMediaTypeByString(e.get("type")),i=e.parent&&s.getMediaTypeByString(e.parent.get("type"));if(i&&i.id===t.parent){var n=e.get("unviewedLeafCount");e.parent.set({unviewedLeafCount:e.parent.get("unviewedLeafCount")-n,viewedLeafCount:e.parent.get("viewedLeafCount")+n}),l(e.parent)}}return r
}),define("plex/desktop/commands/library/markUnwatchedCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a){"use strict";function r(r){function c(){var s=e(u).map(function(e){var i="/:/unscrobble?key="+encodeURIComponent(e.get("ratingKey"))+"&identifier="+e.get("identifier"),n=t.ajax(d.server.getXHROptions(i));return n.done(function(){l(e),o(e)}),n}),a=t.when.apply(t,s);a.done(function(){h.resolve()
}),a.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem marking this item as unwatched.")}),h.reject()})}var d,u,h=t.Deferred();r.item?(d=r.item,u=[d]):r.items&&(u=r.items,d=u[0]);var p=d.get("type"),m=s.getMediaTypeByString(p),f=m&&"directory"===m.element,g=(f||u.length>1)&&!r.force,v=1===u.length,y=v&&d.get("isSection")?d.getSyncTitle():d.get("title");if(g){var b;switch(d.get("type")){case"movie":b=v?i("Are you sure you want to mark {1} as unwatched?",y):i("Are you sure you want to mark these movies as unwatched?");
break;case"show":case"season":case"episode":b=v?i("Are you sure you want to mark all episodes of {1} as unwatched?",y):i("Are you sure you want to mark these episodes as unwatched?");break;default:b=v?i("Are you sure you want to mark {1} as unwatched?",y):i("Are you sure you want to mark these items as unwatched?")}var w=new a({title:i("Mark as Unwatched"),message:b}),x=w.promise;x.done(c),x.fail(function(){h.reject()}),n.trigger("show:modal",w)}else c();return h.promise()}function o(e){var t=s.getMediaTypeByString(e.get("type"));
if(!t||"directory"!==t.element)return void e.set({viewOffset:0,viewCount:0});e.set({unviewedLeafCount:e.get("leafCount"),viewedLeafCount:0});var i=e.get("children")||e.get("items");i&&i.each(o)}function l(e){var t=s.getMediaTypeByString(e.get("type")),i=e.parent&&s.getMediaTypeByString(e.parent.get("type"));if(i&&i.id===t.parent){var n=e.get("viewedLeafCount");e.parent.set({unviewedLeafCount:e.parent.get("unviewedLeafCount")+n,viewedLeafCount:e.parent.get("viewedLeafCount")-n}),l(e.parent)}}return r
}),define("plex/desktop/commands/library/unmatchCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel"],function(e,t,i,n){"use strict";function s(s){var a=s.item,r="/library/metadata/"+a.id+"/unmatch",o=e.extend(a.server.getXHROptions(r),{type:"PUT"}),l=t.ajax(o);return l.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem unmatching this item.")})}),l.promise()}return s}),define("plex/desktop/commands/library/splitApartCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";
function a(a){function r(){var s=e.extend(l.server.getXHROptions(c),{type:"PUT"}),a=t.ajax(s);a.done(function(){var e,t=l.get("type");e="show"===t||"artist"===t||"album"===t?"Location":"Media",l.set(e,l.get(e).slice(0,1)),n.trigger("navigate:back"),o.resolve()}),a.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem splitting this item apart.")}),o.reject(e)}),a.always(function(){d.hide()})}var o=t.Deferred(),l=a.item,c="/library/metadata/"+l.id+"/split",d=new s({title:i("Split Apart"),message:i("Are you sure you want to split this item apart?"),async:!0}),u=d.promise;
return u.done(r),u.fail(function(){o.reject()}),n.trigger("show:modal",d),o.promise()}return a}),define("plex/desktop/commands/library/mergeCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";function a(a){function r(){var e=t.ajax(u);e.done(function(){o.resolve()}),e.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem merging these items.")}),o.reject(e)}),e.always(function(){h.hide()
})}var o=t.Deferred(),l=a.item,c=e.pluck(a.items,"id").join(","),d="/library/metadata/"+l.id+"/merge?ids="+c,u=e.extend(l.server.getXHROptions(d),{type:"PUT"}),h=new s({title:i("Merge"),message:i("Are you sure you want to merge these items together?"),async:!0}),p=h.promise;return p.done(r),p.fail(function(){o.reject()}),n.trigger("show:modal",h),o.promise()}return a}),define("plex/base/commands/library/deleteFileCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";
function s(s){var a,r=s.item,o=s.media,l=r.server;if(o){var c="/library/metadata/"+r.id+"/media/"+o.id,d=e.extend(l.getXHROptions(c),{type:"DELETE"});a=t.ajax(d),a.done(function(){var t=s.item.get("Media");t.splice(e.indexOf(t,o),1),r.trigger("change:Media",r,r.get("Media"))})}else a=r.destroy({wait:!0});return a.fail(function(e){var t=403===e.status?'"Allow clients to delete media" must be enabled in your server settings.':"There was a problem deleting this item.";n.trigger("show:alert",{type:"error",message:i(t)})
}),a}return s}),define("plex/desktop/commands/library/deleteItemCommand",["underscore","plex/base/utils/dispatcher","plex/base/commands/library/deleteFileCommand","plex/base/models/library/MetadataModel"],function(e,t,i,n){"use strict";function s(e){var t=i(e);return t.done(function(){var t=e.item,i=a(t.get("parentKey"),e);if(!i)return void r(e);var n=i.get("children");if(n.length)return void o(i.get("key"),e);i.trigger("destroy",i,i.collection);var s=a(t.get("grandparentKey"),e);if(!s)return void r(e);
var l=s.get("children");l.length?o(s.get("key"),e):r(e)}),t}function a(t,i){if(!t)return!1;var s=new n({key:t},{server:i.item.server,onlyIfCached:!0});return e.isEmpty(s)?!1:s}function r(e){if(!e.skipRedirect){var i=e.item;t.trigger("navigate","section",{serverID:i.server.id,sectionID:i.section.id})}}function o(e,i){if(!i.skipRedirect){var n=i.item;t.trigger("navigate","details",{serverID:n.server.id,key:e})}}return s}),define("hb!templates/desktop/modals/SelectMediaFileModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s,a,r="";
return r+='\n          <li class="striped-list-item select-list-item">\n            <a class="media" data-value="'+u((n=t,n=null==n||n===!1?n:n.index,typeof n===d?n.apply(e):n))+'" href="#">\n              ',a={hash:{},data:t},n=i.shortFilename||e&&e.shortFilename,s=n?n.call(e,(n=e&&e.Part,n=null==n||n===!1?n:n[0],null==n||n===!1?n:n.file),35,a):h.call(e,"shortFilename",(n=e&&e.Part,n=null==n||n===!1?n:n[0],null==n||n===!1?n:n.file),35,a),(s||0===s)&&(r+=s),r+="\n            </a>\n          </li>\n        "
}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};var r,o,l,c="",d="function",u=this.escapeExpression,h=i.helperMissing,p=this;return c+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon file"></i> ',l={hash:{},data:s},c+=u((r=i.t||t&&t.t,r?r.call(t,"Select a File",l):h.call(t,"t","Select a File",l)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <ul class="list select-list">\n        ',o=i.each.call(t,t&&t.medias,{hash:{},inverse:p.noop,fn:p.program(1,a,s),data:s}),(o||0===o)&&(c+=o),c+="\n      </ul>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/SelectMediaFileModal",["hb!templates/desktop/modals/SelectMediaFileModal.tpl","underscore","plex/desktop/views/modals/SelectModal"],function(e,t,i){"use strict";var n=i.extend({name:"SelectMediaFileModal",template:e,serializeData:function(){var e=this.model.get("Media");return{medias:e}}});return n}),define("plex/desktop/commands/library/deleteMediaItemCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/commands/library/deleteFileCommand","plex/desktop/views/modals/SelectMediaFileModal","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a,r){"use strict";
function o(e){var t=l(e);return t=t.then(function(t){var i=c(),n=i.promise.then(function(){return s({item:e.item,media:t}).always(function(){i.hide()})});return n})}function l(e){var i=t.Deferred(),s=e.item,r=s.get("Media");if(e.index in r)return i.resolve(r[e.index]).promise();var o=new a({model:s}),l=o.promise;return l.done(function(e){i.resolve(r[e])}),l.fail(function(){i.reject()}),n.trigger("show:modal",o),i.promise()}function c(){var e=new r({title:i("Delete File"),message:i("Are you sure you want to delete this file from your filesystem?"),confirmLabel:i("Delete"),cancelLabel:i("Cancel"),async:!0,hasDanger:!0});
return n.trigger("show:modal",e),e}return o}),define("plex/desktop/commands/library/deleteItemsCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/desktop/commands/library/deleteItemCommand","plex/desktop/commands/library/deleteMediaItemCommand","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a,r,o){"use strict";function l(i){var n=i.items,s=i.item;n||(n=[s]),s||(s=e.first(n));var o=s.get("Media");if(1===n.length&&o.length>1&&s.server.supports("specificMediaDeletion"))return r({item:s});
var l=c({item:s,items:n}),d=l.promise,u=d.then(function(){var s=e.map(n,function(e){return a({item:e,skipRedirect:i.skipRedirect})});return t.when.apply(t,s).always(function(){l.hide()})});return u}function c(e){var t,a,r=e.item,l=e.items,c=l.length>1,d=s.getMediaTypeByString(r.get("type"));c?(t=i(d.plural),a=i("Are you sure you want to delete {1} items from your filesystem?",l.length)):(t=i(d.title),a=i("Are you sure you want to delete this item from your filesystem?"));var u={title:i("Delete {1}",t),message:a,confirmLabel:i("Delete"),cancelLabel:i("Cancel"),async:!0,hasDanger:!0};
(c||d.child)&&(u.requireDoubleConfirm=!0,u.doubleConfirmMessage=i("Multiple files may be deleted."),u.doubleConfirmLabel=i("Yes, I'm sure"));var h=new o(u);return n.trigger("show:modal",h),h}return l}),define("plex/desktop/commands/library/deleteSectionCommand",["jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n){"use strict";function s(s){function a(){var e=o.destroy({wait:!0});e.done(function(){r.resolve()}),e.fail(function(e){i.trigger("show:alert",{type:"error",message:t("There was a problem deleting the library.")}),r.reject(e)
}),e.always(function(){l.hide()})}var r=e.Deferred(),o=s.section,l=new n({title:t("Delete Library"),message:t("Are you sure you want to delete {1}?",o.get("title")),confirmLabel:t("Delete"),cancelLabel:t("Cancel"),requireDoubleConfirm:!0,doubleConfirmMessage:t("This cannot be undone."),doubleConfirmLabel:t("Yes, I'm sure"),async:!0,hasDanger:!0}),c=l.promise;return c.done(a),c.fail(function(){r.reject()}),i.trigger("show:modal",l),r.promise()}return s}),define("plex/desktop/commands/library/deleteSectionThumbnailsCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";
function a(a){function r(){var e=t.ajax(c);return e.done(function(){n.trigger("show:alert",{type:"success",message:i("The preview thumbnails for items in this library were deleted.")})}),e.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem deleting the preview thumbnails for items in this library.")})}),e.always(function(){d.hide()}),e}var o=a.section,l="/library/sections/"+o.id+"/indexes",c=e.extend(o.server.getXHROptions(l),{type:"DELETE"}),d=new s({title:i("Delete Preview Thumbnails"),message:i("Are you sure you want to delete the preview thumbnails for items in this library? This cannot be undone."),confirmLabel:i("Delete"),cancelLabel:i("Cancel"),async:!0,hasDanger:!0}),u=d.promise;
return u=u.then(function(){return r()}),n.trigger("show:modal",d),u}return a}),define("plex/desktop/commands/library/deletePlaylistCommand",["jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n){"use strict";function s(s){function a(){var e=s.item.destroy();e.done(function(){i.trigger("navigate","playlists",{serverID:o.id}),r.resolve()}),e.fail(function(e){i.trigger("show:alert",{type:"error",message:t("There was a problem deleting the playlist.")}),r.reject(e)
}),e.always(function(){l.hide()})}var r=e.Deferred(),o=s.item.server,l=new n({title:t("Delete Playlist"),message:t("Are you sure you want to delete {1}? This cannot be undone.",s.item.get("title")),confirmLabel:t("Delete"),cancelLabel:t("Cancel"),async:!0,hasDanger:!0}),c=l.promise;return c.done(a),c.fail(function(){r.reject()}),i.trigger("show:modal",l),r.promise()}return s}),define("plex/desktop/commands/library/updateLibraryCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal","plex/desktop/views/modals/LibraryFailureModal"],function(e,t,i,n,s,a){"use strict";
function r(r){function o(){var e=t.ajax(g);e.done(function(){l.resolve()}),e.fail(function(e){if(503===e.status)n.trigger("show:modal",new a({model:h}));else{var t=i(u?"There was a problem canceling the update.":"There was a problem updating the library.");n.trigger("show:alert",{type:"error",message:t})}l.reject(e)})}var l=t.Deferred(),c=r.section,d=c?c.id:"all",u=r.cancel,h=c?c.server:r.server,p=r.params||{},m={};p.force&&(m.force=1);var f="/library/sections/"+d+"/refresh",g=e.extend(h.getXHROptions(f),{data:m});
if(u&&(g.type="DELETE",c&&c.set("refreshing",!1)),m.force){var v=new s({title:i("Force Refresh"),message:i("Forces a download of fresh media information from the internet. This can take a long time. Any locked fields are not modified."),confirmLabel:i("Refresh"),cancelLabel:i("Cancel")}),y=v.promise;y.done(o),y.fail(function(){l.reject()}),n.trigger("show:modal",v)}else o();return l.promise()}return r}),define("plex/desktop/commands/library/optimizeCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";
function a(a){function r(){var e=t.ajax(d);e.done(function(){n.trigger("show:alert",{type:"success",message:i("The database was optimized.")}),o.resolve()}),e.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem optimizing this database.")}),o.reject(e)}),e.always(function(){u.hide()})}var o=t.Deferred(),l=a.server,c="/library/optimize",d=e.extend(l.getXHROptions(c),{type:"PUT"}),u=new s({title:i("Optimize Database"),message:i("Cleans up the library database and ensures it is operating as quickly as possible. This is especially useful when you've added or removed a large amount of media from the library."),confirmLabel:i("Optimize"),cancelLabel:i("Cancel"),async:!0}),h=u.promise;
return h.done(r),h.fail(function(){o.reject()}),n.trigger("show:modal",u),o.promise()}return a}),define("plex/desktop/commands/library/cleanBundlesCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";function a(a){function r(){var e=t.ajax(d);e.done(function(){n.trigger("show:alert",{type:"success",message:i("Unused bundles are being removed.")}),o.resolve()}),e.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem removing unused bundles.")}),o.reject(e)
}),e.always(function(){u.hide()})}var o=t.Deferred(),l=a.server,c="/library/clean/bundles",d=e.extend(l.getXHROptions(c),{type:"PUT"}),u=new s({title:i("Clean Bundles"),message:i("The media server stores information about your media to disk, as well as posters, artwork, and other media resources from the internet. Running this task deletes any bundles which are no longer in use."),confirmLabel:i("Clean"),cancelLabel:i("Cancel"),async:!0}),h=u.promise;return h.done(r),h.fail(function(){o.reject()}),n.trigger("show:modal",u),o.promise()
}return a}),define("plex/desktop/commands/library/emptyTrashCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";function a(a){function r(){e.each(d,function(i){var n="/library/sections/"+i+"/emptyTrash",s=e.extend(c.getXHROptions(n),{type:"PUT"});u.push(t.ajax(s))});var s=t.when.apply(t,u);s.done(function(){n.trigger("show:alert",{type:"success",message:i("The trash was emptied.")}),o.resolve()
}),s.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem emptying the trash.")}),o.reject(e)}),s.always(function(){p.hide()})}var o=t.Deferred(),l=a.section,c=l?l.server:a.server,d=[],u=[];if(l)d.push(l.id);else{var h=c.get("sections");h.each(function(e){d.push(e.id)})}var p=new s({title:i("Empty Trash"),message:i("By default the media server doesn't remove information for media right away. This helps if a drive is temporarily disconnected. When you empty the trash for a section, all information about missing media is deleted."),confirmLabel:i("Empty"),cancelLabel:i("Cancel"),async:!0}),m=p.promise;
return m.done(r),m.fail(function(){o.reject()}),n.trigger("show:modal",p),o.promise()}return a}),define("plex/desktop/commands/library/matchCommand",["underscore","jquery"],function(e,t){"use strict";function i(i){var n=i.item,s={guid:i.guid,name:i.name};"album"===n.get("type")&&i.children&&i.children.reduce(function(e,t){var i=t.get("id");return i&&(e["guid["+i+"]"]=t.get("guid")),e},s);var a="/library/metadata/"+n.id+"/match?"+t.param(s,!0),r=e.extend(n.server.getXHROptions(a),{type:"PUT"});return t.ajax(r).promise()
}return i}),define("plex/desktop/commands/library/autoMatchCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";function a(a){var r=t.Deferred(),o=a.item,l=a.agent,c={agent:l.id,manual:0},d="/library/metadata/"+o.id+"/matches?"+t.param(c,!0),u=e.extend(o.server.getXHROptions(d)),h=t.ajax(u);return h.done(function(a){var l=e.isObject(a)?a:s.parseXML(a);if(l.SearchResult){var d=l.SearchResult;e.isArray(l.SearchResult)&&(d=l.SearchResult[0]),c={guid:d.guid,name:d.name};
var u="/library/metadata/"+o.id+"/match?"+t.param(c,!0),h=e.extend(o.server.getXHROptions(u),{type:"PUT"}),p=t.ajax(h);p.done(function(){r.resolve()}),p.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem matching this item.")}),r.reject()})}else n.trigger("show:alert",{type:"error",message:i("No matches were found using this agent.")}),r.reject()}),h.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem searching for matches.")}),r.reject(e)
}),r.promise()}return a}),define("plex/desktop/commands/library/changeArtworkCommand",["underscore","jquery"],function(e,t){"use strict";function i(i){var s=i.item,a={url:i.artworkRatingKey},r="/library/metadata/"+s.id+"/"+i.artworkType+"?"+t.param(a,!0),o=e.extend(s.server.getXHROptions(r),{type:"PUT"}),l=t.ajax(o);return l.done(function(e){s.set(n[i.artworkType],e)}),l.promise()}var n={poster:"thumb",art:"art",banner:"banner"};return i}),define("plex/desktop/commands/channel/installChannelCommand",["jquery"],function(e){"use strict";
function t(t){var i=t.channel,n=i.get("identifier"),s=n?"/system/appstore/apps/"+n:i.get("key"),a=s+"/install",r=i.server.getXHROptions(a),o=e.ajax(r);return o.done(function(){i.set("installed",!0)}),o.promise()}return t}),define("plex/desktop/commands/channel/updateChannelCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";function a(a){function r(a){var l=e.isObject(a)?a:s.parseXML(a);if(!l||!l.message&&!l.Directory)return void o();
if(l.message)h||n.trigger("show:alert",{type:"success",message:i(l.message)}),c.resolve();else{s.parseArray(l,"Directory");var d=l.Directory[0].key,p=t.ajax(u.getXHROptions(d));p.done(r),p.fail(o)}}function o(e){h||n.trigger("show:alert",{type:"error",message:i("There was a problem checking for updates.")}),c.reject(e)}var l,c=t.Deferred(),d=a.channel,u=d?d.server:a.server,h=a.silent;if(d){var p=d.get("identifier"),m=p?"/system/appstore/apps/"+p:d.get("key");l=m+"/update"}else l="/system/appstore/updates";
var f=t.ajax(u.getXHROptions(l));return f.done(r),f.fail(o),c.promise()}return a}),define("plex/desktop/commands/channel/restartChannelCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";function a(a){var r=a.channel,o=r.get("identifier"),l=o?"/system/appstore/apps/"+o:r.get("key"),c=l+"/restart",d=r.server.getXHROptions(c),u=t.ajax(d);return u.done(function(t){var a,r=e.isObject(t)?t:s.parseXML(t);a=r.message?r.message:i("This channel was successfully restarted."),n.trigger("show:alert",{type:"success",message:a})
}),u.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem restarting this channel.")})}),u.promise()}return a}),define("plex/desktop/commands/channel/resetChannelCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";function a(a){var r=a.channel,o=r.get("identifier"),l=o?"/system/appstore/apps/"+o:r.get("key"),c=l+"/reset",d=r.server.getXHROptions(c),u=t.ajax(d);return u.done(function(t){var a,r=e.isObject(t)?t:s.parseXML(t);
a=r.message?r.message:i("This channel was successfully reset."),n.trigger("show:alert",{type:"success",message:a})}),u.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem resetting this channel.")})}),u.promise()}return a}),define("plex/desktop/commands/channel/uninstallChannelCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a){"use strict";function r(r){function o(){var a=t.ajax(p);
a.done(function(t){var a=e.isObject(t)?t:s.parseXML(t);c.set("installed",!1),a.message&&!r.skipConfirmation&&n.trigger("show:alert",{type:"success",message:i(a.message)}),l.resolve()}),a.fail(function(e){n.trigger("show:alert",{type:"error",message:i("This channel could not be uninstalled.")}),l.reject(e)})}var l=t.Deferred(),c=r.channel,d=c.get("identifier"),u=d?"/system/appstore/apps/"+d:c.get("key"),h=u+"/uninstall",p=c.server.getXHROptions(h);if(r.skipConfirmation)o();else{var m=new a({title:i("Uninstall Channel"),message:i("Are you sure you want to uninstall this channel?")}),f=m.promise;
f.done(o),f.fail(function(){l.reject()}),n.trigger("show:modal",m)}return l.promise()}return r}),define("plex/desktop/commands/channel/watchLaterCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel"],function(e,t,i,n,s){"use strict";function a(a){var r="/pms/playlists/queue/items",o={url:a.item.get("url")};r+="?"+t.param(o,!0);var l=s.get("user"),c=l.server,d=e.extend(c.getXHROptions(r),{type:"POST"}),u=t.ajax(d).promise();return u.done(function(){n.trigger("show:alert",{type:"success",message:i("{1} added to Watch Later.",a.item.get("title"))})
}),u.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem adding to Watch Later.")})}),u}return a}),define("plex/base/utils/playMedia",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/playerUtil","plex/base/utils/types/mediaTypes","plex/base/adapters/loggerAdapter","plex/base/adapters/settingsAdapter"],function(e,t,i,n,s,a,r,o){"use strict";function l(e){return e.get("isPlaylist")?e.get("playlistType"):a.getChildMediaType(e.get("type")).element
}function c(t,i){var n=e(i).pick("controller","offset","useMiniPlayer","isSwitchingPlayers"),a=l(t);return n.type=s.getTypeByElement(a),n}function d(t,i){var n=e(i).pick("shuffle","unwatched","continuous","items","excludeSeedItem"),s="movie"===t.get("type")&&!t.get("viewOffset");return s&&i.supportsContinuous&&(n.extrasPrefixCount=o.get("extrasPrefixCount")),n}function u(e,i){var n=t.Deferred();if(i.siblings&&e.collection){var s;s=e.parent&&e.parent.get("isPlaylist")?e.parent:e.collection,n.resolve({toPlay:e,toAdd:s})
}else if(i.unwatched&&"show"===e.get("type")){var a=e.populate({data:{includeOnDeck:"1"}});a.done(function(){var t=e.get("onDeck");n.resolve(t?{toPlay:t,toAdd:e}:{toAdd:e})}),a.fail(function(){n.reject()})}else n.resolve({toAdd:e});return n.promise()}function h(e,i){return e&&e.get("hasUserAdditions")?i.confirmClearPlayQueue():t.Deferred().resolve().promise()}function p(e){return e.controller||e.playQueue?!0:void 0}function m(e,t){return e&&e.get("selectedItem")&&e.get("selectedItem").get("key")===t.get("key")
}function f(e){n.trigger("show:alert",{type:"error",message:e||i("Sorry, there was a problem playing this item.")})}function g(e){var i=t.Deferred(),n=e.item||e.items[0],s=c(n,e);if(p(s))return i.resolve(s).promise();var a=d(n,e),o=u(n,e);return o.done(function(t){t.toPlay&&(a.firstItem=t.toPlay);var o=n.server.get("playQueueManager"),l=o.getFor(t.toPlay||t.toAdd);if(m(l,n))return void(e.isCompanionConnect?(s.model=l.get("selectedItem"),s.playQueue=l,i.resolve(s)):i.reject());var c=h(l,e);c.done(function(){var e=o.createFor(t.toAdd,t.toPlay);
if(!e)return r.warn("Unable to queue item; failed to create play queue"),f(),void i.reject();var n=e.addContent(t.toAdd,a);n.done(function(){return e.get("collection").length?(s.model=e.get("selectedItem"),s.playQueue=e,void i.resolve(s)):(r.warn("Unable to queue item; empty play queue"),f(e.get("message")),void i.reject())}),n.fail(function(){r.warn("Unable to queue item; failed to add content"),f(),i.reject()})})}),o.fail(function(){r.warn("Unable to queue item; failed to get next unwatched item"),f(),i.reject()
}),i.promise()}return g}),define("plex/desktop/commands/player/playMediaCommand",["underscore","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/playMedia","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a){"use strict";function r(r){var o=e.clone(r);o.confirmClearPlayQueue=function(){var e=new a({title:t("Play Now"),message:t("This will clear the contents of Up Next and play the selection instead.")});return i.trigger("show:modal",e),e.promise
};var l=s.get("primaryPlayer");return o.supportsContinuous=!l||e(l.get("protocolCapabilities")).contains("playqueues"),n(o).then(function(e){i.trigger("show:player",e)})}return r}),define("plex/desktop/commands/player/queueMediaCommand",["plex/base/utils/dispatcher","plex/base/utils/types/mediaTypes","plex/base/adapters/loggerAdapter"],function(e,t,i){"use strict";function n(n){var s,a;n.items?(a=n.items,s=a[0]):n.item&&(s=n.item,a=[s]),n.items=a;var r=t.getChildMediaType(s.get("type")).element,o=s.server.get("playQueueManager").getFor(s);
o?o.queueContent(s,n).done(function(){"audio"===r.element&&e.trigger("show:music",{collection:o})}):i.warn("No compatible queue found. Item not queued.")}return n}),define("plex/desktop/commands/server/connectServerCommand",["jquery","plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t,i){"use strict";function n(n){function s(){var e=r.fetch();e.done(function(){var e=r.get("mappingState"),t=n.value&&"unknown"===e,i=!n.value&&"mapped"===e;"waiting"===e||t||i?a||(a=setInterval(s,d)):(a=clearInterval(a),r.isWaiting()&&r.set("remoteAccessState",""),c.resolve())
})}var a,r=n.cloudAccount,o=r.server.get("settings"),l=o.get("PublishServerOnPlexOnlineKey"),c=e.Deferred(),d=500;if(!r.isWaiting()){var u=n.value?"connecting":"disconnecting";r.set("remoteAccessState",u)}var h=r.previous("remoteAccessState"),p=l.save({PublishServerOnPlexOnlineKey:n.value},{timeout:0});return p.done(s),p.fail(function(e){var s;s=t(n.value?"There was a problem connecting your server.":"There was a problem disconnecting your server."),i.trigger("show:alert",{type:"error",message:s}),r.set("remoteAccessState",h),c.reject(e)
}),c.promise()}return n}),define("plex/desktop/commands/server/reconnectServerCommand",["underscore","jquery","plex/base/utils/dispatcher"],function(e,t,i){"use strict";function n(n){var s=t.Deferred(),a=n.cloudAccount,r={cloudAccount:a,value:!1};return i.trigger("command","connectServer",r,function(t){t=t.then(e.bind(function(){r.value=!0,i.trigger("command","connectServer",r,function(e){e.done(function(){a.get("mappingError")?s.reject():s.resolve()}),e.fail(function(){s.reject()})})},this)),t.fail(function(){s.reject()
})}),s.promise()}return n}),define("plex/desktop/commands/server/signInServerCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";function a(a){var r=t.Deferred(),o=a.cloudAccount;o.set("signedIn",!0,{silent:!0}),o.set({username:"",password:""});var l=o.save({username:a.username,password:a.password},{wait:!0,timeout:0});return l.done(function(t){var l=e.isObject(t)?t:s.parseXML(t);l&&"invalid"===l.signInState?(n.trigger("show:alert",{type:"error",message:i("The username or password is incorrect.")}),r.reject()):(o.trigger("change:signedIn",o,!0),o.server.set({myPlexSigninState:"ok",myPlexUsername:a.username}),r.resolve())
}),l.fail(function(e){o.set("signedIn",!1,{silent:!0});var t;t=i(401===e.status?"The username or password is incorrect.":"There was a problem signing in to Plex."),n.trigger("show:alert",{type:"error",message:t}),r.reject(e)}),r.promise()}return a}),define("plex/desktop/commands/server/signUpServerCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/parser"],function(e,t,i,n,s){"use strict";function a(a){var r=t.Deferred(),o=a.cloudAccount;o.set("signedIn",!1),o.set({username:"",email:"",password:""});
var l=o.save({username:a.username,email:a.email,password:a.password});return l.done(function(t){var a=e.isObject(t)?t:s.parseXML(t);if(a&&"invalid"===a.signInState){var l;s.parseArray(a,"Error"),l=i(a.Error.length?e.first(a.Error).error:"This account information is invalid."),n.trigger("show:alert",{type:"error",message:l}),r.reject()}else o.set("signedIn",!0),r.resolve()}),l.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem signing up for a Plex account.")}),r.reject(e)
}),r.promise()}return a}),define("plex/desktop/commands/server/signOutServerCommand",["plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t){"use strict";function i(i){var n=i.cloudAccount,s=n.destroy({timeout:0});return s.done(function(){n.server.set({myPlexSigninState:"none",myPlexSubscription:!1})}),s.fail(function(){t.trigger("show:alert",{type:"error",message:e("There was a problem signing the server out.")})}),s.promise()}return i}),define("plex/desktop/commands/server/removeServerCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/base/models/server/ServerModel","plex/base/models/server/serverStorageModel","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a,r,o){"use strict";
function l(t){var i=new a({machineIdentifier:t},{onlyIfCached:!0});return e.isEmpty(i)?void 0:i}function c(e){var t=e.get("cloudAccount"),i=t.destroy();return i.done(function(){e.set({myPlexSigninState:"none",myPlexSubscription:!1})}),i}function d(e){e.trigger("destroy",e,e.collection),e.cache.remove(e),r.removeLiteServer(e)}function u(a){function r(){var i;if(p)i=p.destroy({wait:!0});else{var s="/api/servers/"+m.id,a=e.extend(h.server.getXHROptions(s),{type:"DELETE"});i=t.ajax(a)}if(m.get("connected")&&"ok"===m.get("myPlexSigninState")){var r=m.get("cloudAccount");
i=i.then(function(){return r.fetch()}),i=i.then(function(){return c(m)})}return m.get("connected")===!1?d(m):i.always(function(){n.trigger("test:server",m),m.populate().fail(function(){d(m)})}),i.always(function(){f.hide()}),i.promise()}var u,h=s.get("user"),p=a.device,m=a.server||l(p.get("clientIdentifier"));u=i(p?"If you remove the server, you will need to sign the server in again to restore access to Plex.":"Are you sure you want to remove this server?");var f=new o({title:i("Remove Server"),message:u,confirmLabel:i("Remove"),cancelLabel:i("Cancel"),async:!0,hasDanger:!0}),g=f.promise;
return g=g.then(function(){return r()}),n.trigger("show:modal",f),g}return u}),define("plex/base/models/server/UpdateHistoryModel",["underscore","moment","plex/base/utils/parser","plex/base/models/BaseModel"],function(e,t,i,n){"use strict";var s=n.extend({whitelistedAttrs:["name","summary","time"],convert:function(n){var s=e.isObject(n)?n:i.parseXML(n);return s.time=t(s.subtitle,"YYYY-MM-DD HH:mm:ss").toDate(),s},parse:function(t){var i=this.convert(t);return i=e.pick(i,this.whitelistedAttrs)}});
return s}),define("plex/base/models/server/UpdateHistoryCollection",["plex/base/models/BaseCollection","plex/base/models/server/UpdateHistoryModel"],function(e,t){"use strict";var i=e.extend({model:t,url:"/system/appstore/history",parse:function(e){return this.convert(e,"Directory")}});return i}),define("plex/desktop/commands/server/checkForBundleUpdatesCommand",["underscore","jquery","plex/base/utils/parser","plex/base/models/appModel","plex/base/models/server/UpdateHistoryCollection"],function(e,t,i,n,s){"use strict";
function a(s){var a="/system/appstore/updates",r=t.ajax(s.getXHROptions(a));return n.set("updateState","checking"),r.done(function(t){var s=i.parseXML(t);if(s.Directory&&s.Directory.length){var a=s.Directory[0].summary.split("\n");e.indexOf(a,"WebClient")>=0?n.set("updateState","available"):n.set("updateState","latest")}else n.set("updateState","latest")}),r.fail(function(){n.set("updateState","none")}),r}function r(e){var t=new s([],{server:e,pageStart:0,pageSize:l?40:1});return t.on("reset",function(e){if(0!==e.length)if(l){var t=e.where({name:"WebClient"});
t.length>0&&t[0].get("time")>l&&n.set("updateState","downloaded")}else l=e.first().get("time")}),t.fetch({reset:!0})}function o(e){e||(e={});var t=n.get("updateState");if("available"!==t&&"downloaded"!==t){var i=n.get("servers"),s=i.findWhere({bundled:!0});if(s&&!s.get("authorized")&&i.each(function(e){if(!e.get("cloud")&&!e.get("synced")){var t=e.get("activeConnection");t&&t.address===window.location.hostname&&(s=e)}}),s&&s.get("authorized")&&!s.get("shared"))return e.checkAppStore?a(s).then(function(){return r(s)
}):r(s)}}var l;return o}),define("plex/desktop/commands/server/installBundleUpdatesCommand",["jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel"],function(e,t,i,n){"use strict";function s(){var s=n.get("servers"),a=s.findWhere({bundled:!0});if(a&&!a.get("shared")){n.set("updateState","downloading");var r="/system/appstore/apps/com.plexapp.plugins.webclient/update",o=e.ajax(a.getXHROptions(r));return o.done(function(){window.location.reload(!0)}),o.fail(function(){n.set("updateState","available"),i.trigger("show:alert",{type:"error",message:t("There was a problem installing these updates.")})
}),o}}return s}),define("plex/desktop/commands/server/checkForServerUpdatesCommand",["underscore","jquery"],function(e,t){"use strict";function i(i){var n=i.server,s={download:i.download===!1?"0":"1"},a="/updater/check?"+t.param(s,!0),r=e.extend(n.getXHROptions(a),{type:"PUT"}),o=i.initialState||"checking",l=n.get("update");l.set("state",o);var c=t.ajax(r).promise();return c.fail(function(){l.set("state","error")}),c}return i}),define("plex/desktop/commands/server/installServerUpdatesCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";
function a(a){function r(){var e=l.get("update");e.set("state","installing");var i=t.ajax(d).promise();return i.fail(function(){e.set("state","error")}),i}var o,l=a.server,c="/updater/apply",d=e.extend(l.getXHROptions(c),{type:"PUT"});l.get("activeConnection").isLoopbackAddress||(o=new s({title:i("Remote Installation"),confirmLabel:i("Continue"),cancelLabel:i("Cancel"),message:i("The installer may display dialogs that require input. Make sure you have desktop access to the computer running Plex Media Server before continuing."),hasDanger:!0}),n.trigger("show:modal",o));
var u=o?o.promise:t.Deferred().resolve().promise();return u=u.then(function(){return r()})}return a}),define("plex/desktop/commands/server/redirectToHttpCommand",["jquery","plex/base/models/config"],function(e,t){"use strict";function i(){return window.location=n(),e.Deferred().resolve().promise()}function n(){return t.get("hosted")?"http://"+window.location.host+"/web?secure=0":window.location.href.replace("https://","http://")}return i}),define("hb!templates/desktop/modals/TermsModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=this.merge(n,e.partials),s=s||{};
var a,r,o,l="",c=i.helperMissing,d=this.escapeExpression,u=this;return l+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <h4 class="modal-title"><i class="modal-icon glyphicon circle-info"></i> ',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Plex Terms of Service",o):c.call(t,"t","Plex Terms of Service",o)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      ',r=u.invokePartial(n.terms,"terms",t,i,n,s),(r||0===r)&&(l+=r),l+='\n    </div>\n\n    <div class="modal-footer">\n      <button type="button" class="confirm-btn btn btn-lg btn-primary btn-loading">\n        <div class="loading loading-sm"></div>\n        <span class="btn-label">',o={hash:{},data:s},l+=d((a=i.t||t&&t.t,a?a.call(t,"Agree",o):c.call(t,"t","Agree",o)))+"</span>\n      </button>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/TermsModal",["hb!templates/desktop/modals/TermsModal.tpl","underscore","plex/desktop/views/modals/BaseModal"],function(e,t,i){"use strict";var n=i.extend({name:"termsModal",template:e,isForced:!0,ui:{confirmBtn:".confirm-btn"},events:t.extend({"click .confirm-btn":"onConfirmClick"},i.prototype.events),onConfirmClick:function(e){e.preventDefault();var i=this.ui.confirmBtn;if(!i.isDisabled()){i.addClass("active");var n=this.collection.first().save({AcceptedEULA:!0});
n.always(t.bind(this.hide,this))}}});return n}),define("plex/desktop/commands/ui/showTermsOfServiceCommand",["plex/base/utils/dispatcher","plex/desktop/views/modals/TermsModal"],function(e,t){"use strict";function i(i){e.trigger("show:modal",new t({collection:i.collection}))}return i}),define("hb!templates/desktop/modals/SelectDeviceModal",["handlebars"],function(e){return e.template(function(e,t,i,n,s){function a(e,t){var n,s="";return s+='\n          <li class="striped-list-item select-list-item">\n            <a class="media" data-value="',(n=i.id)?n=n.call(e,{hash:{},data:t}):(n=e&&e.id,n=typeof n===f?n.call(e,{hash:{},data:t}):n),s+=m(n)+'" href="#">\n              ',n=i["if"].call(e,e&&e.name,{hash:{},inverse:g.program(4,o,t),fn:g.program(2,r,t),data:t}),(n||0===n)&&(s+=n),s+="\n\n              ",n=i["if"].call(e,e&&e.isCloudSync,{hash:{},inverse:g.noop,fn:g.program(6,l,t),data:t}),(n||0===n)&&(s+=n),s+="\n            </a>\n          </li>\n        "
}function r(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=m((n=i.truncate||e&&e.truncate,n?n.call(e,e&&e.name,25,s):p.call(e,"truncate",e&&e.name,25,s)))+"\n              "}function o(e,t){var n,s,a="";return a+="\n                ",s={hash:{},data:t},a+=m((n=i.truncate||e&&e.truncate,n?n.call(e,e&&e.device,25,s):p.call(e,"truncate",e&&e.device,25,s)))+"\n              "}function l(){return'<i class="cloud-sync-icon glyphicon cloud"></i>'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),s=s||{};
var c,d,u,h="",p=i.helperMissing,m=this.escapeExpression,f="function",g=this;return h+='<div class="modal-dialog">\n  <div class="modal-content">\n    <div class="modal-header">\n      <button type="button" class="close" data-dismiss="modal"><i class="glyphicon remove-2"></i></button>\n      <h4 class="modal-title"><i class="modal-icon glyphicon iphone"></i> ',u={hash:{},data:s},h+=m((c=i.t||t&&t.t,c?c.call(t,"Choose Destination",u):p.call(t,"t","Choose Destination",u)))+'</h4>\n    </div>\n\n    <div class="modal-body modal-body-scroll dark-scrollbar">\n      <ul class="list select-list">\n        ',d=i.each.call(t,t&&t.devices,{hash:{},inverse:g.noop,fn:g.program(1,a,s),data:s}),(d||0===d)&&(h+=d),h+="\n      </ul>\n    </div>\n  </div>\n</div>\n"
})}),define("plex/desktop/views/modals/SelectDeviceModal",["hb!templates/desktop/modals/SelectDeviceModal.tpl","plex/desktop/views/modals/SelectModal"],function(e,t){"use strict";var i=t.extend({name:"selectDeviceModal",template:e,serializeData:function(){return{devices:this.collection.toJSON()}}});return i}),define("plex/desktop/commands/user/showSyncModalCommand",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/modals/PlexPassModal","plex/desktop/views/modals/SyncModal","plex/desktop/views/modals/SelectDeviceModal"],function(e,t,i,n,s,a){"use strict";
function r(r){var o=i.get("user"),l=o.hasPlexPass();if(!l)return void t.trigger("show:modal",new n({model:o}));if("ok"!==r.model.server.get("myPlexSigninState")){var c=e("This server needs to be connected to Plex to sync its content.");return void t.trigger("show:alert",{type:"error",message:c})}var d=o.get("devices"),u=d.filterSyncDevices(r.model),h=new s(r);if(u.length>1){var p=new a({collection:u}),m=p.promise;m.done(function(e){h.device=u.get(e),t.trigger("show:modal",h)}),t.trigger("show:modal",p)
}else h.device=u.first(),t.trigger("show:modal",h)}return r}),define("plex/desktop/commands/user/createSyncItemCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/mediaUtil","plex/base/utils/syncUtil","plex/base/utils/types/syncQualities","plex/base/adapters/settingsAdapter"],function(e,t,i,n,s,a,r,o){"use strict";function l(l){var c,d=l.section,u=l.item,h=l.childMediaType,p={},m="",f=l.device.get("screenResolution")||"1024x768";if(d){var g,v=d.get("items");
if(m=l.settings.title||d.get("title"),l.selectedItems){var y=[];e.each(l.selectedItems,function(e){y.push(e.get("ratingKey"))}),g="/library/metadata/"+y.join(",")}else g=v.url();c=d.server,p["SyncItem[Location][uri]"]="library://"+d.get("uuid")+"/directory/"+encodeURIComponent(g),p["SyncItem[machineIdentifier]"]=d.server.id,p["SyncItem[title]"]=m,p["SyncItem[rootTitle]"]=d.get("title"),p["SyncItem[metadataType]"]=h.typeString}else if(u){var b=u.get("type"),w=u.get("grandparentTitle"),x=u.get("parentTitle");
if(c=u.server,m=u.get("title"),w?m=w+" - "+u.get("title"):x&&(m=x+" - "+u.get("title")),u.get("isChannel"))p["SyncItem[Location][uri]"]=l.isDirectory?"channel://"+u.channel.get("identifier")+"/directory/"+encodeURIComponent(u.get("key")):"channel://"+u.channel.get("identifier")+"/item/"+encodeURIComponent(u.get("key")),p["SyncItem[rootTitle]"]=u.channel.get("title");else{if("episode"===b){var k=s.getSeasonEpisodeIndex({seasonIndex:u.get("parentIndex"),episodePrefix:" E{1}",episodeIndex:u.get("index"),date:u.get("originallyAvailableAt"),noLeadingZero:!0});
m+=" ("+k+")"}var S=u.server.getSectionForItem(u);if(e.isEmpty(S))return t.Deferred().reject().promise();var C=S.get("uuid"),P=S.get("title");p["SyncItem[Location][uri]"]=l.isDirectory?"library://"+C+"/directory/"+encodeURIComponent(u.get("key")):"library://"+C+"/item/"+encodeURIComponent(u.get("key")),p["SyncItem[rootTitle]"]=P}p["SyncItem[machineIdentifier]"]=u.server.id,p["SyncItem[title]"]=m,p["SyncItem[metadataType]"]=h.typeString}var A=r.getQuality(l.settings.quality);if(p["SyncItem[Policy][unwatched]"]=l.settings.unwatched,p["SyncItem[Policy][scope]"]=l.settings.scope,p["SyncItem[MediaSettings][videoQuality]"]=A.videoQuality,p["SyncItem[MediaSettings][photoQuality]"]=A.photoQuality,p["SyncItem[MediaSettings][musicBitrate]"]=A.musicBitrate,p["SyncItem[MediaSettings][audioBoost]"]=o.get("audioBoost"),p["SyncItem[MediaSettings][subtitleSize]"]=o.get("subtitleSize"),A.videoResolutionFactor){var _=f.split("x");
_[0]=Math.round(A.videoResolutionFactor*_[0]),_[1]=Math.round(A.videoResolutionFactor*_[1]);var I=_.join("x");p["SyncItem[MediaSettings][videoResolution]"]=I,p["SyncItem[MediaSettings][photoResolution]"]=I}l.settings.value&&(p["SyncItem[Policy][value]"]=l.settings.value);var T="/devices/"+l.device.get("clientIdentifier")+"/sync_items?"+t.param(p,!0),M=e.extend(l.device.server.getXHROptions(T),{type:"POST"});M=a.addVersionHeader(M,l.device);var D=t.ajax(M);return D=D.then(function(){var i="/sync/refreshSynclists",n=e.extend(c.getXHROptions(i),{type:"PUT"});
return t.ajax(n)}),D=D.then(function(){var i="/sync/refreshContent",n=e.extend(c.getXHROptions(i),{type:"PUT"});return t.ajax(n)}),D.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem syncing this media.")})}),D.promise()}return l}),define("plex/desktop/commands/user/editSyncItemCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/syncUtil","plex/base/utils/types/syncQualities","plex/base/adapters/settingsAdapter"],function(e,t,i,n,s,a,r){"use strict";
function o(o){var l=o.syncItem,c=l.parent,d={},u=l.device.get("screenResolution");u=u?u:"1024x768";var h=o.settings.title?o.settings.title:l.get("title"),p=a.getQuality(o.settings.quality);if(d["SyncItem[version]"]=l.get("version"),d["SyncItem[Location][uri]"]=l.get("Location").uri,d["SyncItem[machineIdentifier]"]=c.id,d["SyncItem[title]"]=h,d["SyncItem[rootTitle]"]=l.get("rootTitle"),d["SyncItem[metadataType]"]=l.get("metadataType"),d["SyncItem[Policy][unwatched]"]=o.settings.unwatched,d["SyncItem[Policy][scope]"]=o.settings.scope,d["SyncItem[MediaSettings][videoQuality]"]=p.videoQuality,d["SyncItem[MediaSettings][photoQuality]"]=p.photoQuality,d["SyncItem[MediaSettings][musicBitrate]"]=p.musicBitrate,d["SyncItem[MediaSettings][audioBoost]"]=r.get("audioBoost"),d["SyncItem[MediaSettings][subtitleSize]"]=r.get("subtitleSize"),p.videoResolutionFactor){var m=u.split("x");
m[0]=Math.round(p.videoResolutionFactor*m[0]),m[1]=Math.round(p.videoResolutionFactor*m[1]);var f=m.join("x");d["SyncItem[MediaSettings][videoResolution]"]=f,d["SyncItem[MediaSettings][photoResolution]"]=f}o.settings.value&&(d["SyncItem[Policy][value]"]=o.settings.value);var g="/devices/"+l.device.get("clientIdentifier")+"/sync_items/"+l.id+"?"+t.param(d,!0),v=e.extend(l.server.getXHROptions(g),{type:"PUT"});v=s.addVersionHeader(v,l.device);var y=t.ajax(v);return y=y.then(function(){var i="/sync/refreshSynclists",n=e.extend(c.getXHROptions(i),{type:"PUT"});
return t.ajax(n)}),y=y.then(function(){var i="/sync/refreshContent",n=e.extend(c.getXHROptions(i),{type:"PUT"});return t.ajax(n)}),y.done(function(){l.set("title",h),l.set("version",1+l.get("version")),l.set("MediaSettings",{videoQuality:p.videoQuality,photoQuality:p.photoQuality,musicBitrate:p.musicBitrate,audioBoost:p.audioBoost}),l.set("Policy",{scope:o.settings.scope,unwatched:o.settings.unwatched,value:o.settings.value})}),y.fail(function(){n.trigger("show:alert",{type:"error",message:i("There was a problem syncing this media.")})
}),y.promise()}return o}),define("plex/desktop/commands/user/refreshSyncItemsCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher"],function(e,t,i,n){"use strict";function s(s){var a=s.server,r="/sync/refreshSynclists",o=e.extend(a.getXHROptions(r),{type:"PUT"}),l=t.ajax(o);return s.skipContent||(l=l.then(function(){var i="/sync/refreshContent",n=e.extend(a.getXHROptions(i),{type:"PUT"});return t.ajax(n)})),l.done(function(){s.silent||n.trigger("show:alert",{type:"success",message:i("Synced items were refreshed.")})
}),l.promise()}return s}),define("plex/desktop/commands/user/removeDeviceCommand",["plex/base/utils/t","plex/base/utils/dispatcher","plex/desktop/views/modals/ConfirmModal"],function(e,t,i){"use strict";function n(n){function s(){var i=a.destroy({wait:!0});return i.fail(function(){t.trigger("show:alert",{type:"error",message:e("There was a problem removing this device.")})}),i.always(function(){r.hide()}),i.promise()}var a=n.device,r=new i({title:e("Remove Device"),message:e("If you remove this device, you will need to sign in again on the device to restore access to Plex."),confirmLabel:e("Remove"),cancelLabel:e("Cancel"),async:!0,hasDanger:!0}),o=r.promise;
return o=o.then(function(){return s()}),t.trigger("show:modal",r),o}return n}),define("plex/desktop/commands/user/removeFriendCommand",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/utils/formatters/stringUtil","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s){"use strict";function a(i){function s(){o&&a.set("home",!1);var i=a.destroy({wait:!0});return i.done(function(){var e=n.get("user"),t=a.get("serverShares");if(e.get("invites").fetch(),e.get("sentInvites").fetch(),o){var i=e.get("homeUsers");
i.fetch()}t.getLibraryCount({owned:!1})&&e.server.get("resources").fetch()}),i.fail(function(){o&&a.set("home",!0),t.trigger("show:alert",{type:"error",message:e("There was a problem removing this friend.")})}),i.always(function(){l.hide()}),i.promise()}var a=i.friend,o=a.get("home"),l=r(i),c=l.promise;return c=c.then(function(){return s()}),t.trigger("show:modal",l),c}function r(t){var a=t.friend,r=a.get("serverShares"),o=r.getLibraryCount({owned:!0}),l=r.getLibraryCount({owned:!1}),c=o+l,d=a.get("title"),u=e("Are you sure you want to remove {1}?",d),h=i.pluralize(e("library"),c,e("libraries"));
if(o&&l?u+=" "+e("You are sharing {1} {2} with each other.",c,h):o?u+=" "+e("You are sharing {1} {2} with this friend.",o,h):l&&(u+=" "+e("This friend is sharing {1} {2} with you.",l,h)),a.get("home")){var p=n.get("user"),m=p.get("homeUsers"),f=m.get(p.id);u+=f.get("admin")?" "+e("This friend will be removed from your home."):" "+e("You will be leaving your home.")}var g=new s({title:e("Remove Friend"),message:u,confirmLabel:e("Remove"),cancelLabel:e("Cancel"),async:!0,hasDanger:!0});return g}return a
}),define("plex/desktop/commands/user/acceptInviteCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal","plex/desktop/views/modals/user/UserSelectModal"],function(e,t,i,n,s,a,r){"use strict";function o(a){function r(){var e=o.save(null,{force:!0});o.trigger("destroy",o,d),e.done(function(){p.fetch(),h.get("friends").fetch(),h.get("sentInvites").fetch(),o.get("server")&&h.server.get("resources").fetch(),m.resolve()
}),e.fail(function(e){n.trigger("show:alert",{type:"error",message:i("There was a problem accepting this invite.")}),d.add(o,{at:u}),m.reject(e)})}var o=a.invite,d=o.collection,u=d.indexOf(o),h=s.get("user"),p=h.get("homeUsers"),m=t.Deferred();e.extend(a,{homeUsers:p,signedInHomeUser:p.get(h.id)});var f=l(a);return f.done(function(){c(a).always(r)}),f.fail(function(){m.reject()}),m.promise}function l(e){if(!e.invite.get("home"))return t.Deferred().resolve().promise();var s;s=i(e.homeUsers.length>1?e.signedInHomeUser.get("admin")?"You are the admin in your current home. If you leave, the remaining users will be removed and managed users will be deleted.":"Are you sure you want to join this home? You will leave your current home.":"The admin of this home will have access to your account. Other users of this home will be able to switch to your account by entering your PIN.");
var r=new a({title:i("Join Home"),message:s,confirmLabel:i("Join"),cancelLabel:i("Cancel"),hasDanger:!0});return n.trigger("show:modal",r),r.promise}function c(e){if(e.invite.get("home")&&!e.signedInHomeUser.get("protected")){var i=new r({model:e.signedInHomeUser,isEditing:!0,isEditWarning:!0});return n.trigger("show:modal",i),i.promise}return t.Deferred().resolve().promise()}return o}),define("plex/desktop/commands/user/rejectInviteCommand",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n){"use strict";
function s(e){function n(){var t=s.destroy({wait:!0});return t.done(function(){if(s.get("server")){var e=i.get("user");e.get("friends").fetch()}}),t.fail(function(){r(e)}),t.always(function(){o.hide()}),t.promise()}var s=e.invite,o=a(e),l=o.promise;return l=l.then(function(){return n()}),t.trigger("show:modal",o),l}function a(t){var i,s;"requests"===t.subset?(i=e("Reject Invite"),s=e("Are you sure you want to reject this invite?")):(i=e("Cancel Invite"),s=e("Are you sure you want to cancel this invite?"));
var a=new n({title:i,message:s,async:!0});return a}function r(i){var n;n=e("requests"===i.subset?"There was a problem rejecting this invite.":"There was a problem canceling this invite."),t.trigger("show:alert",{type:"error",message:n})}return s}),define("plex/desktop/commands/user/shareServerCommand",["underscore","jquery"],function(e,t){"use strict";function i(i){var n,s=i.user,a=i.serverShare,r=a.get("Section");if(!r||!r.length)return t.Deferred().resolve().promise();n=a.get("allLibraries")?[]:e.pluck(e.where(r,{shared:!0}),"id");
var o={server_id:a.get("machineIdentifier"),shared_server:{library_section_ids:n}};s.isNew()&&(o.sharing_settings=s.getSaveParams()),a.isNew()&&(s.isNew()?o.shared_server.invited_email=s.get("username"):o.shared_server.invited_id=s.id);var l=a.url(),c=e.extend(s.server.getXHROptions(l),{type:a.isNew()?"POST":"PUT",contentType:"application/json",data:JSON.stringify(o)});return t.ajax(c).promise()}return i}),define("plex/desktop/commands/user/removeServerShareCommand",["plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n){"use strict";
function s(s){function a(){var n=l.destroy({wait:!0});return n.done(function(){var e=i.get("user");e.get("friends").fetch(),e.get("invites").fetch(),e.server.get("resources").fetch()}),n.fail(function(){var i;i=e(l.get("owned")?"There was a problem removing this share.":"There was a problem leaving this server."),t.trigger("show:alert",{type:"error",message:i})}),n.always(function(){c.hide()}),n.promise()}var r,o,l=s.serverShare;l.get("owned")?(r=e("Stop Sharing"),o=e("Are you sure you want to stop sharing with this friend?")):(r=e("Leave Server"),o=e("Are you sure you want to leave this server? You can rejoin at any time."));
var c=new n({title:r,message:o,async:!0,hasDanger:!0}),d=c.promise;return d=d.then(function(){return a()}),t.trigger("show:modal",c),d}return s}),define("plex/desktop/commands/user/removeHomeUserCommand",["underscore","jquery","plex/base/utils/t","plex/base/utils/dispatcher","plex/base/models/appModel","plex/desktop/views/modals/ConfirmModal"],function(e,t,i,n,s,a){"use strict";function r(i){function a(){var n=e.extend(r.server.getXHROptions(r.url()),{type:"DELETE"}),s=t.ajax(n);return s.done(function(){var e=u.get(r.id);
e?(r.trigger("destroy",r,d),r.get("restricted")?e.trigger("destroy",e,u):e.set("home",!1)):(d.reset([r]),r.set("admin",!0),u.each(function(e){e.set("home",!1)})),c.set("home",c.hasHome())}),s.fail(function(){l(i)}),s.always(function(){h.hide()}),s.promise()}var r=i.homeUser,c=s.get("user"),d=c.get("homeUsers"),u=c.get("friends"),h=o(i),p=h.promise;return p=p.then(function(){return a()}),n.trigger("show:modal",h),p}function o(e){var t,n,s,r=e.homeUser;e.isSignedInUser?(t=i("Leave Home"),s=i("Leave"),n=i(r.get("admin")?"You are the admin in this home. If you leave, the remaining users will be removed and managed users will be deleted.":"Are you sure you want to leave this home?")):(t=i("Remove User"),s=i("Remove"),n=i(r.get("restricted")?"Removing a managed user from your home will delete the managed user. Watched status for this user will be lost. This cannot be undone.":"You will no longer be able to switch to this user."));
var o=new a({title:t,message:n,confirmLabel:s,cancelLabel:i("Cancel"),async:!0,hasDanger:!0});return o}function l(e){var t;t=i(e.isSignedInUser?"There was a problem leaving this home.":"There was a problem removing this user."),n.trigger("show:alert",{type:"error",message:t})}return r}),define("plex/desktop/commands/user/validateUsernameCommand",["underscore","jquery","plex/base/utils/parser"],function(e,t,i){"use strict";function n(n){var s=t.Deferred(),a="/api/users/validate?invited_email="+encodeURIComponent(n.username),r=e.extend(n.server.getXHROptions(a),{type:"POST"}),o=t.ajax(r);
return o.done(function(){s.resolve()}),o.fail(function(e){var t=e.responseText,n=i.parseXML(t);s.reject(e,n&&n.status)}),s.promise()}return n}),define("plex/desktop/commands/desktopCommands",["underscore","plex/base/commands/commands","plex/desktop/commands/library/playSoundCommand","plex/desktop/commands/library/refreshMetadataCommand","plex/desktop/commands/library/analyzeItemsCommand","plex/desktop/commands/library/analyzeSectionCommand","plex/desktop/commands/library/markWatchedCommand","plex/desktop/commands/library/markUnwatchedCommand","plex/desktop/commands/library/unmatchCommand","plex/desktop/commands/library/splitApartCommand","plex/desktop/commands/library/mergeCommand","plex/desktop/commands/library/deleteItemsCommand","plex/desktop/commands/library/deleteMediaItemCommand","plex/desktop/commands/library/deleteSectionCommand","plex/desktop/commands/library/deleteSectionThumbnailsCommand","plex/desktop/commands/library/deletePlaylistCommand","plex/desktop/commands/library/updateLibraryCommand","plex/desktop/commands/library/optimizeCommand","plex/desktop/commands/library/cleanBundlesCommand","plex/desktop/commands/library/emptyTrashCommand","plex/desktop/commands/library/matchCommand","plex/desktop/commands/library/autoMatchCommand","plex/desktop/commands/library/changeArtworkCommand","plex/desktop/commands/channel/installChannelCommand","plex/desktop/commands/channel/updateChannelCommand","plex/desktop/commands/channel/restartChannelCommand","plex/desktop/commands/channel/resetChannelCommand","plex/desktop/commands/channel/uninstallChannelCommand","plex/desktop/commands/channel/watchLaterCommand","plex/desktop/commands/player/playMediaCommand","plex/desktop/commands/player/queueMediaCommand","plex/desktop/commands/server/connectServerCommand","plex/desktop/commands/server/reconnectServerCommand","plex/desktop/commands/server/signInServerCommand","plex/desktop/commands/server/signUpServerCommand","plex/desktop/commands/server/signOutServerCommand","plex/desktop/commands/server/removeServerCommand","plex/desktop/commands/server/checkForBundleUpdatesCommand","plex/desktop/commands/server/installBundleUpdatesCommand","plex/desktop/commands/server/checkForServerUpdatesCommand","plex/desktop/commands/server/installServerUpdatesCommand","plex/desktop/commands/server/redirectToHttpCommand","plex/desktop/commands/ui/showTermsOfServiceCommand","plex/desktop/commands/user/showSyncModalCommand","plex/desktop/commands/user/createSyncItemCommand","plex/desktop/commands/user/editSyncItemCommand","plex/desktop/commands/user/refreshSyncItemsCommand","plex/desktop/commands/user/removeDeviceCommand","plex/desktop/commands/user/removeFriendCommand","plex/desktop/commands/user/acceptInviteCommand","plex/desktop/commands/user/rejectInviteCommand","plex/desktop/commands/user/shareServerCommand","plex/desktop/commands/user/removeServerShareCommand","plex/desktop/commands/user/removeHomeUserCommand","plex/desktop/commands/user/validateUsernameCommand"],function(e,t,i,n,s,a,r,o,l,c,d,u,h,p,m,f,g,v,y,b,w,x,k,S,C,P,A,_,I,T,M,D,E,L,R,O,N,F,B,U,V,z,j,q,H,W,$,Y,Q,K,X,G,J,Z,et){"use strict";
return e.extend(t.map,{playSound:i,refreshMetadata:n,analyzeItems:s,analyzeSection:a,markWatched:r,markUnwatched:o,unmatch:l,splitApart:c,merge:d,deleteItems:u,deleteMediaItem:h,deleteSection:p,deleteSectionThumbnails:m,deletePlaylist:f,updateLibrary:g,optimize:v,cleanBundles:y,emptyTrash:b,match:w,autoMatch:x,changeArtwork:k,installChannel:S,updateChannel:C,restartChannel:P,resetChannel:A,uninstallChannel:_,watchLater:I,playMedia:T,queueMedia:M,connectServer:D,reconnectServer:E,signInServer:L,signUpServer:R,signOutServer:O,removeServer:N,checkForBundleUpdates:F,installBundleUpdates:B,checkForServerUpdates:U,installServerUpdates:V,redirectToHttp:z,showTermsOfService:j,showSyncModal:q,createSyncItem:H,editSyncItem:W,refreshSyncItems:$,removeDevice:Y,removeFriend:Q,acceptInvite:K,rejectInvite:X,shareServer:G,removeServerShare:J,removeHomeUser:Z,validateUsername:et}),t
}),window.PLEXWEB=window.PLEXWEB||{},window.PLEXWEB.serverUpdate=!0,window.PLEXWEB.requestAllConnections=!0,window.PLEXWEB.includeHttps=!0,define("plex/desktop/desktopApp",["marionette","plex/desktop/adapters/desktopAdapters","plex/desktop/initializers/configs/desktopPartials","plex/desktop/initializers/mainInitializer","plex/desktop/commands/desktopCommands"],function(e,t,i,n){"use strict";t.registerAll();var s=new e.Application;return s.addInitializer(n),s}),require(["config/require.conf"],function(){"use strict";
require(["plex/desktop/desktopApp"],function(e){e.start()})}),define("main-desktop",function(){});